]> git.sesse.net Git - kdenlive/blob - src/titlewidget.h
Added some documentation
[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     QDomDocument xml();
52     void setXml(QDomDocument doc);
53     
54     /** \brief Find first available filename of the form titleXXX.png in projectUrl + "/titles/" directory
55     * \param projectUrl Url to directory of project. 
56      * \returns A list, with the name in the form of "/path/to/titles/titleXXX" as the first element, the extension
57      * ".png" as the second element.
58      * 
59      * The path "/titles/" is appended to projectUrl to locate the actual directory that contains the title pngs. */
60     static QStringList getFreeTitleInfo(const KUrl &projectUrl);
61     
62     /** \brief Build a filename from a projectUrl and a titleName
63      * \param projectUrl Url to directory of project.
64      * \param titleName Name of title, on the form "titleXXX"
65      * 
66      * The path "/titles/" is appended to projectUrl to build the directoryname, then .pgn is appended to
67      * get the filename. It is not checked that the title png actually exists, only the name is build and
68      * returned. */
69     static QString getTitleResourceFromName(const KUrl &projectUrl, const QString &titleName);
70
71 protected:
72     virtual void resizeEvent(QResizeEvent * event);
73
74 private:
75     QGraphicsPolygonItem *startViewport, *endViewport;
76     GraphicsSceneRectMove *m_scene;
77     void initViewports();
78     QMap<QGraphicsItem*, Transform > transformations;
79     TitleDocument m_titledocument;
80     QGraphicsRectItem *m_frameBorder;
81     QGraphicsPixmapItem *m_frameImage;
82     int m_frameWidth;
83     int m_frameHeight;
84     Render *m_render;
85     int m_count;
86     QAction *m_buttonRect;
87     QAction *m_buttonText;
88     QAction *m_buttonImage;
89     QAction *m_buttonCursor;
90     QAction *m_buttonSave;
91     QAction *m_buttonLoad;
92     /** project path for storing title clips */
93     QString m_projectPath;
94
95 public slots:
96     void slotNewText(QGraphicsTextItem *tt);
97     void slotNewRect(QGraphicsRectItem *rect);
98     void slotChangeBackground();
99     void selectionChanged();
100     void textChanged();
101     void rectChanged();
102     void fontBold();
103     void setupViewports();
104     void zIndexChanged(int);
105     void itemScaled(int);
106     void itemRotate(int);
107     void itemHCenter();
108     void itemVCenter();
109     void saveTitle(KUrl url = KUrl());
110     void loadTitle();
111     QPixmap renderedPixmap();
112
113 private slots:
114     void slotAdjustSelectedItem();
115     void slotUpdateZoom(int pos);
116     void slotZoom(bool up);
117     void slotAdjustZoom();
118     void slotZoomOneToOne();
119     void slotUpdateText();
120     void displayBackgroundFrame();
121     void setCurrentItem(QGraphicsItem *item);
122     void slotTextTool();
123     void slotRectTool();
124     void slotSelectTool();
125     void slotImageTool();
126 };
127
128
129 #endif