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;
111 /** \brief Dialog for entering unicode in text fields */
112 UnicodeDialog *m_unicodeDialog;
113 /** project path for storing title clips */
114 QString m_projectTitlePath;
117 /** See http://doc.trolltech.com/4.5/signalsandslots.html#advanced-signals-and-slots-usage */
118 QSignalMapper *m_signalMapper;
120 enum ValueType { ValueWidth = 0, ValueHeight = 1 };
122 /** \brief Sets the font weight value in the combo box. (#909) */
123 void setFontBoxWeight(int weight);
125 /** \brief Store the current choices of font, background and rect values */
127 /** \brief Read the last stored choices into the dialog */
129 /** \brief Update the displayed X/Y coordinate values */
130 void updateCoordinates(QGraphicsItem *i);
131 /** \brief Update displayed width/height values */
132 void updateDimension(QGraphicsItem *i);
133 /** \brief Update displayed rotation/zoom values */
134 void updateRotZoom(QGraphicsItem *i);
136 /** \brief Update the item's position */
137 void updatePosition(QGraphicsItem *i);
139 void textChanged(QGraphicsTextItem *i);
140 void updateAxisButtons(QGraphicsItem *i);
142 void updateTextOriginX();
143 void updateTextOriginY();
145 /** \brief Enables the toolbars suiting to toolType */
146 void enableToolbars(TITLETOOL toolType);
147 /** \brief Shows the toolbars suiting to toolType */
148 void showToolbars(TITLETOOL toolType);
149 /** \brief Check a tool button. */
150 void checkButton(TITLETOOL toolType);
152 void adjustFrameSize();
153 /** \brief Add a "start" and "end" info text to the animation viewports */
154 void addAnimInfoText();
155 /** \brief Update font for the "start" and "end" info text */
156 void updateInfoText();
157 /** \brief Remove the "start" and "end" info text from animation viewports */
158 void deleteAnimInfoText();
161 void slotNewText(QGraphicsTextItem *tt);
162 void slotNewRect(QGraphicsRectItem *rect);
163 void slotChangeBackground();
164 void selectionChanged();
166 void setupViewports();
167 void zIndexChanged(int);
168 void itemScaled(int);
169 void itemRotate(int);
170 void saveTitle(KUrl url = KUrl());
171 void loadTitle(KUrl url = KUrl());
174 void slotAdjustSelectedItem();
177 * \brief Switches the origin of the x axis between left and right
178 * border of the frame (offset from left/right frame border)
179 * \param originLeft Take left border?
181 * Called when the origin of the x coorinate has been changed. The
182 * x origin will either be at the left or at the right side of the frame.
184 * When the origin of the x axis is at the left side, the user can
185 * enter the distance between an element's left border and the left
188 * When on the right, the distance from the right border of the
189 * frame to the right border of the element can be entered. This
190 * would result in negative values as long as the element's right
191 * border is at the left of the frame's right border. As that is
192 * usually the case, I additionally invert the x axis.
194 * Default value is left.
196 * |----l----->|#######|----r--->|
200 * |----------m_frameWidth------>|
203 * Left selected: Value = l
204 * Right selected: Value = r
206 * To calculate between the two coorindate systems:
207 * l = m_frameWidth - w - r
208 * r = m_frameWidth - w - l
211 void slotOriginXClicked();
212 /** \brief Same as slotOriginYChanged, but for the Y axis; default is top.
213 * \param originTop Take top border? */
214 void slotOriginYClicked();
216 /** \brief Update coorinates of text fields if necessary and text has changed */
219 /** \param valueType Of type ValueType */
220 void slotValueChanged(int valueType);
222 void slotZoom(bool up);
223 void slotUpdateZoom(int pos);
224 void slotAdjustZoom();
225 void slotZoomOneToOne();
227 void slotUpdateText();
228 void slotInsertUnicode();
229 void slotInsertUnicodeString(QString);
231 void displayBackgroundFrame();
233 void setCurrentItem(QGraphicsItem *item);
237 void slotSelectTool();
238 void slotImageTool();
240 void slotAnimStart(bool);
241 void slotAnimEnd(bool);
242 void slotKeepAspect(bool keep);
251 void slotResize100();
252 void slotResize200();
254 /** \brief Called when accepted, stores the user selections for next time use */
257 void slotFontText(const QString& s);
259 void slotAddEffect(int ix);
260 void slotEditBlur(int ix);
261 void slotEditShadow();