]> git.sesse.net Git - kdenlive/blob - src/trackview.h
1a5b55b94e1e8e6d28bdc1cbafd3091e10fb1416
[kdenlive] / src / trackview.h
1 /***************************************************************************
2  *   Copyright (C) 2007 by Jean-Baptiste Mardelle (jb@kdenlive.org)        *
3  *                                                                         *
4  *   This program is free software; you can redistribute it and/or modify  *
5  *   it under the terms of the GNU General Public License as published by  *
6  *   the Free Software Foundation; either version 2 of the License, or     *
7  *   (at your option) any later version.                                   *
8  *                                                                         *
9  *   This program is distributed in the hope that it will be useful,       *
10  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
11  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
12  *   GNU General Public License for more details.                          *
13  *                                                                         *
14  *   You should have received a copy of the GNU General Public License     *
15  *   along with this program; if not, write to the                         *
16  *   Free Software Foundation, Inc.,                                       *
17  *   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA          *
18  ***************************************************************************/
19
20 /**
21 * @class TrackView
22 * @brief Manages the timline
23 * @author Jean-Baptiste Mardelle
24 */
25
26 #ifndef TRACKVIEW_H
27 #define TRACKVIEW_H
28
29 #include <QScrollArea>
30 #include <QGroupBox>
31 #include <QGraphicsScene>
32 #include <QGraphicsLineItem>
33 #include <QDomElement>
34
35 #include <KRuler>
36
37 #include "customtrackscene.h"
38 #include "effectslist.h"
39 #include "ui_timeline_ui.h"
40 #include "definitions.h"
41
42 class ClipItem;
43 class Transition;
44 class CustomTrackView;
45 class KdenliveDoc;
46 class CustomRuler;
47 class DocClipBase;
48
49 class TrackView : public QWidget, public Ui::TimeLine_UI
50 {
51     Q_OBJECT
52
53 public:
54     explicit TrackView(KdenliveDoc *doc, bool *ok, QWidget *parent = 0);
55     virtual ~ TrackView();
56     void setEditMode(const QString & editMode);
57     const QString & editMode() const;
58     QGraphicsScene *projectScene();
59     CustomTrackView *projectView();
60     int duration() const;
61     int tracksNumber() const;
62     KdenliveDoc *document();
63     void refresh() ;
64     void updateProjectFps();
65     int outPoint() const;
66     int inPoint() const;
67     int fitZoom() const;
68
69     /** @brief Updates (redraws) the ruler.
70     *
71     * Used to change from displaying frames to timecode or vice versa. */
72     void updateRuler();
73
74     /** @brief Parse tracks to see if project has audio in it.
75     *
76     * Parses all tracks to check if there is audio data. */
77     bool checkProjectAudio() const;
78
79 protected:
80     virtual void keyPressEvent(QKeyEvent * event);
81
82 public slots:
83     void slotDeleteClip(const QString &clipId);
84     void slotChangeZoom(int horizontal, int vertical = -1);
85     void setDuration(int dur);
86     void slotSetZone(QPoint p, bool updateDocumentProperties = true);
87     /** @brief Save a snapshot image of current timeline view */
88     void slotSaveTimelinePreview(const QString path);
89 private:
90     CustomRuler *m_ruler;
91     CustomTrackView *m_trackview;
92     QList <QString> m_invalidProducers;
93     double m_scale;
94     int m_projectTracks;
95     QString m_editMode;
96     CustomTrackScene *m_scene;
97
98     KdenliveDoc *m_doc;
99     int m_verticalZoom;
100     QString m_documentErrors;
101     void parseDocument(QDomDocument doc);
102     int slotAddProjectTrack(int ix, QDomElement xml, bool locked);
103     DocClipBase *getMissingProducer(const QString id) const;
104     void adjustTrackHeaders();
105     void slotAddProjectEffects(QDomNodeList effects, QDomElement parentNode, ClipItem *clip, int trackIndex);
106
107 private slots:
108     void setCursorPos(int pos);
109     void moveCursorPos(int pos);
110     /** @brief Rebuilds the track headers */
111     void slotRebuildTrackHeaders();
112     /** @brief The tracks count or a track name changed, rebuild and notify */
113     void slotReloadTracks();
114     void slotChangeTrackLock(int ix, bool lock);
115     void slotVerticalZoomDown();
116     void slotVerticalZoomUp();
117
118     /** @brief Changes the name of a track.
119     * @param ix Number of the track
120     * @param name New name */
121     void slotRenameTrack(int ix, QString name);
122     void slotRepaintTracks();
123
124     /** @brief Adjusts the margins of the header area.
125      *
126      * Avoid a shift between header area and trackview if
127      * the horizontal scrollbar is visible and the position
128      * of the vertical scrollbar is maximal */
129     void slotUpdateVerticalScroll(int min, int max);
130     void slotShowTrackEffects(int);
131     /** @brief Update the track label showing applied effects.*/
132     void slotUpdateTrackEffectState(int);
133
134 signals:
135     void mousePosition(int);
136     void cursorMoved();
137     void zoneMoved(int, int);
138     void insertTrack(int);
139     void deleteTrack(int);
140     void configTrack(int);
141     void updateTracksInfo();
142     void setZoom(int);
143     void showTrackEffects(int, TrackInfo);
144 };
145
146 #endif