]> git.sesse.net Git - kdenlive/blob - src/titlewidget.h
New Dvd wizard (in menu File).
[kdenlive] / src / titlewidget.h
1 /***************************************************************************
2                           titlewidget.h  -  description
3                              -------------------
4     begin                : Feb 28 2008
5     copyright            : (C) 2008 by Marco Gittler
6     email                : g.marco@freenet.de
7  ***************************************************************************/
8
9 /***************************************************************************
10  *                                                                         *
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.                                   *
15  *                                                                         *
16  ***************************************************************************/
17
18 #ifndef TITLEWIDGET_H
19 #define TITLEWIDGET_H
20
21
22 #include <QDialog>
23
24 #include <QMap>
25
26 #include "ui_titlewidget_ui.h"
27 #include "titledocument.h"
28 #include "renderer.h"
29 #include "graphicsscenerectmove.h"
30
31
32
33 class Transform {
34 public:
35     Transform() {
36         scalex = 1.0;
37         scaley = 1.0;
38         rotate = 0.0;
39     }
40     double scalex, scaley;
41     double rotate;
42 };
43
44 class TitleWidget : public QDialog , public Ui::TitleWidget_UI {
45     Q_OBJECT
46
47 public:
48     /** \brief Constructor
49      * \param projectPath Path to use when user requests loading or saving of titles as .kdenlivetitle documents */
50     TitleWidget(KUrl url, QString projectPath, Render *render, QWidget *parent = 0);
51     virtual ~TitleWidget();
52     QDomDocument xml();
53     void setXml(QDomDocument doc);
54
55     /** \brief Find first available filename of the form titleXXX.png in projectUrl + "/titles/" directory
56     * \param projectUrl Url to directory of project.
57      * \returns A list, with the name in the form of "/path/to/titles/titleXXX" as the first element, the extension
58      * ".png" as the second element.
59      *
60      * The path "/titles/" is appended to projectUrl to locate the actual directory that contains the title pngs. */
61     static QStringList getFreeTitleInfo(const KUrl &projectUrl);
62
63     /** \brief Build a filename from a projectUrl and a titleName
64      * \param projectUrl Url to directory of project.
65      * \param titleName Name of title, on the form "titleXXX"
66      *
67      * The path "/titles/" is appended to projectUrl to build the directoryname, then .pgn is appended to
68      * get the filename. It is not checked that the title png actually exists, only the name is build and
69      * returned. */
70     static QString getTitleResourceFromName(const KUrl &projectUrl, const QString &titleName);
71
72 protected:
73     virtual void resizeEvent(QResizeEvent * event);
74
75 private:
76     QGraphicsPolygonItem *startViewport, *endViewport;
77     GraphicsSceneRectMove *m_scene;
78     void initViewports();
79     QMap<QGraphicsItem*, Transform > transformations;
80     TitleDocument m_titledocument;
81     QGraphicsRectItem *m_frameBorder;
82     QGraphicsPixmapItem *m_frameImage;
83     int m_frameWidth;
84     int m_frameHeight;
85     Render *m_render;
86     int m_count;
87     QAction *m_buttonRect;
88     QAction *m_buttonText;
89     QAction *m_buttonImage;
90     QAction *m_buttonCursor;
91     QAction *m_buttonSave;
92     QAction *m_buttonLoad;
93     /** project path for storing title clips */
94     QString m_projectPath;
95     /** \brief Store the current choices of font, background and rect values */
96     void writeChoices();
97     /** \brief Read the last stored choices into the dialog */
98     void readChoices();
99
100 public slots:
101     void slotNewText(QGraphicsTextItem *tt);
102     void slotNewRect(QGraphicsRectItem *rect);
103     void slotChangeBackground();
104     void selectionChanged();
105     void textChanged();
106     void rectChanged();
107     void fontBold();
108     void setupViewports();
109     void zIndexChanged(int);
110     void itemScaled(int);
111     void itemRotate(int);
112     void itemHCenter();
113     void itemVCenter();
114     void saveTitle(KUrl url = KUrl());
115     void loadTitle();
116     QImage renderedPixmap();
117
118 private slots:
119     void slotAdjustSelectedItem();
120     void slotUpdateZoom(int pos);
121     void slotZoom(bool up);
122     void slotAdjustZoom();
123     void slotZoomOneToOne();
124     void slotUpdateText();
125     void displayBackgroundFrame();
126     void setCurrentItem(QGraphicsItem *item);
127     void slotTextTool();
128     void slotRectTool();
129     void slotSelectTool();
130     void slotImageTool();
131     /** \brief Called when accepted, stores the user selections for next time use */
132     void slotAccepted();
133 };
134
135
136 #endif