]> git.sesse.net Git - kdenlive/blobdiff - src/customtrackview.h
Fix compilation with KDE < 4.5
[kdenlive] / src / customtrackview.h
index 4df0fdb1293d39f3ef2878108de90de7b027a537..a88286fe51c29dbba64169bff99aa94c01f30f9f 100644 (file)
 #ifndef CUSTOMTRACKVIEW_H
 #define CUSTOMTRACKVIEW_H
 
+#include <kdeversion.h>
+#if KDE_IS_VERSION(4,5,0)
+#include <KImageCache>
+#else
 #include <KPixmapCache>
+#endif
+
+#include <KColorScheme>
 
 #include <QGraphicsView>
 #include <QGraphicsItemAnimation>
@@ -127,9 +134,10 @@ public:
     /** @brief Locks or unlocks a track.
     * @param ix number of track
     * @param lock whether to lock or unlock
+    * @param requestUpdate (default = true) Whether to request an update of the icon in the track header
     *
     * Makes sure no clip on track to lock is selected. */
-    void lockTrack(int ix, bool lock);
+    void lockTrack(int ix, bool lock, bool requestUpdate = true);
     void groupClips(bool group = true);
     void doGroupClips(QList <ItemInfo> clipInfos, QList <ItemInfo> transitionInfos, bool group);
     void loadGroups(const QDomNodeList groups);
@@ -153,6 +161,8 @@ public:
     int selectedTrack() const;
     QStringList selectedClips() const;
     QList<ClipItem *> selectedClipItems() const;
+    /** @brief Checks wheter an item can be inserted (make sure it does not overlap another item) */
+    bool canBePastedTo(ItemInfo info, int type) const;
 
     /** @brief Selects a clip.
     * @param add Whether to select or deselect
@@ -174,7 +184,11 @@ public:
     void clearSelection();
     void editItemDuration();
     void buildGuidesMenu(QMenu *goMenu) const;
-    KPixmapCache* pixmapCache;
+#if KDE_IS_VERSION(4,5,0)
+    KImageCache* m_pixmapCache;
+#else
+    KPixmapCache* m_pixmapCache;
+#endif
     /** update the timeline objects when palette changes */
     void updatePalette();
     /** @brief Returns true if a track has audio data on it.
@@ -187,10 +201,10 @@ public slots:
     void setCursorPos(int pos, bool seek = true);
     void moveCursorPos(int delta);
     void updateCursorPos();
-    void slotDeleteEffect(ClipItem *clip, QDomElement effect, bool affectGroup = true);
-    void slotChangeEffectState(ClipItem *clip, int effectPos, bool disable);
-    void slotChangeEffectPosition(ClipItem *clip, int currentPos, int newPos);
-    void slotUpdateClipEffect(ClipItem *clip, QDomElement oldeffect, QDomElement effect, int ix);
+    void slotDeleteEffect(ClipItem *clip, int track, QDomElement effect, bool affectGroup = true);
+    void slotChangeEffectState(ClipItem *clip, int track, int effectPos, bool disable);
+    void slotChangeEffectPosition(ClipItem *clip, int track, int currentPos, int newPos);
+    void slotUpdateClipEffect(ClipItem *clip, int track, QDomElement oldeffect, QDomElement effect, int ix);
     void slotUpdateClipRegion(ClipItem *clip, int ix, QString region);
     void slotRefreshEffects(ClipItem *clip);
     void setDuration(int duration);
@@ -201,9 +215,17 @@ public slots:
     void slotSwitchTrackVideo(int ix);
     void slotSwitchTrackLock(int ix);
     void slotUpdateClip(const QString &clipId, bool reload = true);
+
+    /** @brief Creates a AddClipCommand to add, edit or delete a marker.
+     * @param id Id of the marker's clip
+     * @param t Position of the marker
+     * @param c Comment of the marker */
     void slotAddClipMarker(const QString &id, GenTime t, QString c);
     bool addGuide(const GenTime pos, const QString &comment);
-    void slotAddGuide();
+
+    /** @brief Shows a dialog for adding a guide.
+     * @param dialog (default = true) false = do not show the dialog but use current position as position and comment */
+    void slotAddGuide(bool dialog = true);
     void slotEditGuide(CommentedTime guide);
     void slotEditGuide(int guidePos = -1);
     void slotDeleteGuide(int guidePos = -1);
@@ -246,6 +268,17 @@ public slots:
     * @param cut true = cut, false = "uncut" */
     void slotRazorGroup(QList <ItemInfo> clips1, QList <ItemInfo> transitions1, QList <ItemInfo> clipsCut, QList <ItemInfo> transitionsCut, QList <ItemInfo> clips2, QList <ItemInfo> transitions2, GenTime cutPos, bool cut);
 
+    /** @brief Add en effect to a track.
+    * @param effect The new effect xml
+    * @param ix The track index */
+    void slotAddTrackEffect(const QDomElement effect, int ix);
+
+    /** @brief Update the list of snap points (sticky timeline hotspots).
+    * @param selected The currently selected clip if any
+    * @param offsetList The list of points that should also snap (for example when movin a clip, start and end points should snap
+    * @param skipSelectedItems if true, the selected item start and end points will not be added to snap list */
+    void updateSnapPoints(AbstractClipItem *selected, QList <GenTime> offsetList = QList <GenTime> (), bool skipSelectedItems = false);
+
 protected:
     virtual void drawBackground(QPainter * painter, const QRectF & rect);
     //virtual void drawForeground ( QPainter * painter, const QRectF & rect );
@@ -282,7 +315,7 @@ private:
     QPoint m_clickEvent;
     QList <CommentedTime> m_searchPoints;
     QList <Guide *> m_guides;
-    void updateSnapPoints(AbstractClipItem *selected, QList <GenTime> offsetList = QList <GenTime> (), bool skipSelectedItems = false);
+
     ClipItem *getClipItemAt(int pos, int track);
     ClipItem *getClipItemAt(GenTime pos, int track);
     ClipItem *getClipItemAtEnd(GenTime pos, int track);
@@ -326,12 +359,16 @@ private:
 
     QMutex m_mutex;
     QWaitCondition m_producerNotReady;
+    KStatefulBrush m_activeTrackBrush;
+
+    /** stores the state of the control modifier during mouse press.
+     * Will then be used to identify whether we resize a group or only one item of it. */
+    bool m_controlModifier;
 
     /** Get the index of the video track that is just below current track */
     int getPreviousVideoTrack(int track);
-    void updatePositionEffects(ClipItem * item, ItemInfo info);
+    void updatePositionEffects(ClipItem * item, ItemInfo info, bool standalone = true);
     bool insertDropClips(const QMimeData *data, const QPoint pos);
-    bool canBePastedTo(ItemInfo info, int type) const;
     bool canBePastedTo(QList <ItemInfo> infoList, int type) const;
     bool canBePasted(QList<AbstractClipItem *> items, GenTime offset, int trackOffset) const;
     bool canBeMoved(QList<AbstractClipItem *> items, GenTime offset, int trackOffset) const;
@@ -383,6 +420,36 @@ private:
     * @param cutPos The absolute position of the cut */
     void razorGroup(AbstractGroupItem *group, GenTime cutPos);
 
+    /** @brief Gets the effect parameters that will be passed to Mlt. */
+    EffectsParameterList getEffectArgs(const QDomElement effect);
+
+    /** @brief Updates @param item's pan and zoom effect after resize or cut.
+     * @param item clip whose pan and zoom effect should be updated
+     * @param cutPos (optional) if clip was cut, cut position relative to the original's clip position */
+    void updatePanZoom(ClipItem *item, GenTime cutPos = GenTime());
+
+    /** @brief Update Tracknames to fit again after track was added/deleted.
+     * @param track Number of track which was added/deleted
+     * @param added true = track added, false = track deleted
+     * 
+     * The default track name consists of type + number. If we add/delete a track the number has to be adjusted
+     * if the name is still the default one. */
+    void updateTrackNames(int track, bool added);
+
+    /** @brief Updates the duration stored in a track's TrackInfo.
+     * @param track Number of track as used in ItemInfo (not the numbering used in KdenliveDoc) (negative for all tracks)
+     * @param command If effects need to be updated the commands to do this will be attached to this undo command
+     * 
+     * In addition to update the duration in TrackInfo it updates effects with keyframes on the track. */
+    void updateTrackDuration(int track, QUndoCommand *command);
+
+    /** @brief Adjusts effects after a clip resize.
+     * @param item The item that was resized
+     * @param oldInfo pre resize info
+     * @param fromStart false = resize from end
+     * @param command Used as a parent for EditEffectCommand */
+    void adjustEffects(ClipItem *item, ItemInfo oldInfo, QUndoCommand *command);
+
 private slots:
     void slotRefreshGuides();
     void slotEnableRefresh();
@@ -394,13 +461,21 @@ private slots:
     void slotGoToMarker(QAction *action);
     void slotResetMenuPosition();
     void slotDoResetMenuPosition();
+    /** @brief Re-create the clip thumbnails.
+     *  @param id The clip's Id string.
+     *  @param resetThumbs Should we recreate the timeline thumbnails. */
+    void slotRefreshThumbs(const QString &id, bool resetThumbs);
 
 signals:
     void cursorMoved(int, int);
     void zoomIn();
     void zoomOut();
     void mousePosition(int);
-    void clipItemSelected(ClipItem*, int ix = -1);
+    /** @brief A clip was selected in timeline, update the effect stack
+     *  @param clip The clip
+     *  @param ix The index of currently selected effect
+     *  @param raise If true, the effect stack widget will be raised (come to front). */
+    void clipItemSelected(ClipItem *clip, int ix = -1, bool raise = true);
     void transitionItemSelected(Transition*, int track = 0, QPoint p = QPoint(), bool update = false);
     void activateDocumentMonitor();
     void trackHeightChanged();
@@ -414,6 +489,9 @@ signals:
     /** @brief Monitor document changes (for example the presence of audio data in timeline for export widget.*/
     void documentModified();
     void forceClipProcessing(const QString &);
+    void showTrackEffects(int, TrackInfo);
+    /** @brief Update the track effect button that shows if a track has effects or not.*/
+    void updateTrackEffectState(int);
 };
 
 #endif