1 /***************************************************************************
2 titlewidget.h - description
5 copyright : (C) 2008 by Marco Gittler
6 email : g.marco@freenet.de
7 ***************************************************************************/
9 /***************************************************************************
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
16 ***************************************************************************/
22 #include "ui_titlewidget_ui.h"
23 #include "titledocument.h"
25 #include "graphicsscenerectmove.h"
26 #include "unicodedialog.h"
30 #include <QSignalMapper>
41 double scalex, scaley;
45 class TitleWidget : public QDialog , public Ui::TitleWidget_UI
50 /** \brief Constructor
51 * \param projectPath Path to use when user requests loading or saving of titles as .kdenlivetitle documents */
52 TitleWidget(KUrl url, Timecode tc, QString projectTitlePath, Render *render, QWidget *parent = 0);
53 virtual ~TitleWidget();
55 void setXml(QDomDocument doc);
57 /** \brief Find first available filename of the form titleXXX.png in projectUrl + "/titles/" directory
58 * \param projectUrl Url to directory of project.
59 * \returns A list, with the name in the form of "/path/to/titles/titleXXX" as the first element, the extension
60 * ".png" as the second element.
62 * The path "/titles/" is appended to projectUrl to locate the actual directory that contains the title pngs. */
63 static QStringList getFreeTitleInfo(const KUrl &projectUrl, bool isClone = false);
65 /** \brief Return a list af all images included in a title
66 * \param xml The xml data for title
68 static QStringList extractImageList(QString xml);
70 /** \brief Build a filename from a projectUrl and a titleName
71 * \param projectUrl Url to directory of project.
72 * \param titleName Name of title, on the form "titleXXX"
74 * The path "/titles/" is appended to projectUrl to build the directoryname, then .pgn is appended to
75 * get the filename. It is not checked that the title png actually exists, only the name is build and
77 static QString getTitleResourceFromName(const KUrl &projectUrl, const QString &titleName);
79 /** \brief Get clip duration. */
83 virtual void resizeEvent(QResizeEvent * event);
86 /** \brief Rectangle describing animation start viewport */
87 QGraphicsRectItem *m_startViewport;
88 /** \brief Rectangle describing animation end viewport */
89 QGraphicsRectItem *m_endViewport;
90 /** \brief Scene for the titler */
91 GraphicsSceneRectMove *m_scene;
92 /** \brief Initialize the animation properties (viewport size,...) */
94 QMap<QGraphicsItem*, Transform > m_transformations;
95 TitleDocument m_titledocument;
96 QGraphicsRectItem *m_frameBorder;
97 QGraphicsPixmapItem *m_frameImage;
102 QAction *m_buttonRect;
103 QAction *m_buttonText;
104 QAction *m_buttonImage;
105 QAction *m_buttonCursor;
106 QAction *m_buttonSave;
107 QAction *m_buttonLoad;
109 QAction *m_unicodeAction;
115 /** \brief Dialog for entering unicode in text fields */
116 UnicodeDialog *m_unicodeDialog;
117 /** project path for storing title clips */
118 QString m_projectTitlePath;
121 /** See http://doc.trolltech.com/4.5/signalsandslots.html#advanced-signals-and-slots-usage */
122 QSignalMapper *m_signalMapper;
124 enum ValueType { ValueWidth = 0, ValueHeight = 1 };
126 /** \brief Sets the font weight value in the combo box. (#909) */
127 void setFontBoxWeight(int weight);
129 /** \brief Store the current choices of font, background and rect values */
131 /** \brief Read the last stored choices into the dialog */
133 /** \brief Update the displayed X/Y coordinate values */
134 void updateCoordinates(QGraphicsItem *i);
135 /** \brief Update displayed width/height values */
136 void updateDimension(QGraphicsItem *i);
137 /** \brief Update displayed rotation/zoom values */
138 void updateRotZoom(QGraphicsItem *i);
140 /** \brief Update the item's position */
141 void updatePosition(QGraphicsItem *i);
143 void textChanged(QGraphicsTextItem *i);
144 void updateAxisButtons(QGraphicsItem *i);
146 void updateTextOriginX();
147 void updateTextOriginY();
149 /** \brief Enables the toolbars suiting to toolType */
150 void enableToolbars(TITLETOOL toolType);
151 /** \brief Shows the toolbars suiting to toolType */
152 void showToolbars(TITLETOOL toolType);
153 /** \brief Check a tool button. */
154 void checkButton(TITLETOOL toolType);
156 void adjustFrameSize();
157 /** \brief Add a "start" and "end" info text to the animation viewports */
158 void addAnimInfoText();
159 /** \brief Update font for the "start" and "end" info text */
160 void updateInfoText();
161 /** \brief Remove the "start" and "end" info text from animation viewports */
162 void deleteAnimInfoText();
165 qreal zIndexBounds(bool maxBound);
168 void slotNewText(QGraphicsTextItem *tt);
169 void slotNewRect(QGraphicsRectItem *rect);
170 void slotChangeBackground();
171 void selectionChanged();
173 void setupViewports();
174 void zIndexChanged(int);
175 void itemScaled(int);
176 void itemRotate(int);
177 void saveTitle(KUrl url = KUrl());
178 void loadTitle(KUrl url = KUrl());
181 void slotAdjustSelectedItem();
184 * \brief Switches the origin of the x axis between left and right
185 * border of the frame (offset from left/right frame border)
186 * \param originLeft Take left border?
188 * Called when the origin of the x coorinate has been changed. The
189 * x origin will either be at the left or at the right side of the frame.
191 * When the origin of the x axis is at the left side, the user can
192 * enter the distance between an element's left border and the left
195 * When on the right, the distance from the right border of the
196 * frame to the right border of the element can be entered. This
197 * would result in negative values as long as the element's right
198 * border is at the left of the frame's right border. As that is
199 * usually the case, I additionally invert the x axis.
201 * Default value is left.
203 * |----l----->|#######|----r--->|
207 * |----------m_frameWidth------>|
210 * Left selected: Value = l
211 * Right selected: Value = r
213 * To calculate between the two coorindate systems:
214 * l = m_frameWidth - w - r
215 * r = m_frameWidth - w - l
218 void slotOriginXClicked();
219 /** \brief Same as slotOriginYChanged, but for the Y axis; default is top.
220 * \param originTop Take top border? */
221 void slotOriginYClicked();
223 /** \brief Update coorinates of text fields if necessary and text has changed */
226 /** \param valueType Of type ValueType */
227 void slotValueChanged(int valueType);
229 void slotZoom(bool up);
230 void slotUpdateZoom(int pos);
231 void slotAdjustZoom();
232 void slotZoomOneToOne();
234 void slotUpdateText();
235 void slotInsertUnicode();
236 void slotInsertUnicodeString(QString);
238 void displayBackgroundFrame();
240 void setCurrentItem(QGraphicsItem *item);
244 void slotSelectTool();
245 void slotImageTool();
247 void slotAnimStart(bool);
248 void slotAnimEnd(bool);
249 void slotKeepAspect(bool keep);
258 void slotResize100();
259 void slotResize200();
261 /** \brief Called when accepted, stores the user selections for next time use */
264 void slotFontText(const QString& s);
266 void slotAddEffect(int ix);
267 void slotEditBlur(int ix);
268 void slotEditShadow();
269 void slotEditTypewriter(int ix);
271 /** \brief Changes the z index of objects. */
273 void slotZIndexDown();
274 void slotZIndexTop();
275 void slotZIndexBottom();