X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fcustomtrackview.h;h=e7d404f067650030a47154de7b572620cdf8722c;hb=f69a24d18f8134c93e407ea485967ac31187da47;hp=fdfdc798c0053c119a600510d54228d4672e2c48;hpb=5cd08771831888003c9e27ec60ea7971721ff58a;p=kdenlive diff --git a/src/customtrackview.h b/src/customtrackview.h index fdfdc798..e7d404f0 100644 --- a/src/customtrackview.h +++ b/src/customtrackview.h @@ -21,7 +21,8 @@ #ifndef CUSTOMTRACKVIEW_H #define CUSTOMTRACKVIEW_H -#include +#include +#include #include #include @@ -41,6 +42,7 @@ class ClipItem; class AbstractClipItem; class AbstractGroupItem; class Transition; +class AudioCorrelation; class CustomTrackView : public QGraphicsView { @@ -53,48 +55,60 @@ public: virtual void mouseReleaseEvent(QMouseEvent * event); virtual void mouseMoveEvent(QMouseEvent * event); virtual void mouseDoubleClickEvent(QMouseEvent *event); - void addTrack(TrackInfo type, int ix = -1); + void addTrack(const TrackInfo &type, int ix = -1); void removeTrack(int ix); /** @brief Makes the document use new track infos (name, type, ...). */ - void configTracks(QList trackInfos); - int cursorPos(); + void configTracks(const QList &trackInfos); + int cursorPos() const; void checkAutoScroll(); - void moveClip(const ItemInfo start, const ItemInfo end, bool refresh); - void moveGroup(QList startClip, QList startTransition, const GenTime offset, const int trackOffset, bool reverseMove = false); + /** + Move the clip at \c start to \c end. + + If \c out_actualEnd is not NULL, it will be set to the position the clip really ended up at. + For example, attempting to move a clip to t = -1 s will actually move it to t = 0 s. + */ + bool moveClip(const ItemInfo &start, const ItemInfo &end, bool refresh, ItemInfo *out_actualEnd = NULL); + void moveGroup(QList startClip, QList startTransition, const GenTime &offset, const int trackOffset, bool reverseMove = false); /** move transition, startPos = (old start, old end), endPos = (new start, new end) */ - void moveTransition(const ItemInfo start, const ItemInfo end, bool m_refresh); - void resizeClip(const ItemInfo start, const ItemInfo end, bool dontWorry = false); + void moveTransition(const ItemInfo &start, const ItemInfo &end, bool refresh); + void resizeClip(const ItemInfo &start, const ItemInfo &end, bool dontWorry = false); void addClip(QDomElement xml, const QString &clipId, ItemInfo info, EffectsList list = EffectsList(), bool overwrite = false, bool push = false, bool refresh = true); void deleteClip(ItemInfo info, bool refresh = true); void slotDeleteClipMarker(const QString &comment, const QString &id, const GenTime &position); void slotDeleteAllClipMarkers(const QString &id); - void addMarker(const QString &id, const GenTime &pos, const QString comment); + void addMarker(const QString &id, const CommentedTime &marker); + void addData(const QString &id, const QString &key, const QString &data); void setScale(double scaleFactor, double verticalScale); void deleteClip(const QString &clipId); - void slotAddEffect(QDomElement effect, GenTime pos, int track); - void slotAddGroupEffect(QDomElement effect, AbstractGroupItem *group); + /** @brief An effect was dropped on @param clip */ + void slotDropEffect(ClipItem *clip, QDomElement effect, GenTime pos, int track); + /** @brief Add effect to current clip */ + void slotAddEffect(QDomElement effect, const GenTime &pos, int track); + void slotAddGroupEffect(QDomElement effect, AbstractGroupItem *group, AbstractClipItem *dropTarget = NULL); void addEffect(int track, GenTime pos, QDomElement effect); - void deleteEffect(int track, GenTime pos, QDomElement effect); - void updateEffect(int track, GenTime pos, QDomElement insertedEffect, int ix, bool triggeredByUser = true); - void moveEffect(int track, GenTime pos, int oldPos, int newPos); - void addTransition(ItemInfo transitionInfo, int endTrack, QDomElement params, bool refresh); - void deleteTransition(ItemInfo transitionInfo, int endTrack, QDomElement params, bool refresh); - void updateTransition(int track, GenTime pos, QDomElement oldTransition, QDomElement transition, bool updateTransitionWidget); - void moveTransition(GenTime oldpos, GenTime newpos); + void deleteEffect(int track, const GenTime &pos, const QDomElement &effect); + void updateEffect(int track, GenTime pos, QDomElement insertedEffect, bool refreshEffectStack = false); + /** @brief Enable / disable a list of effects */ + void updateEffectState(int track, GenTime pos, QList effectIndexes, bool disable, bool updateEffectStack); + void moveEffect(int track, const GenTime &pos, const QList &oldPos, const QList &newPos); + void addTransition(const ItemInfo &transitionInfo, int endTrack, const QDomElement ¶ms, bool refresh); + void deleteTransition(const ItemInfo &transitionInfo, int endTrack, QDomElement params, bool refresh); + void updateTransition(int track, const GenTime &pos, const QDomElement &oldTransition, const QDomElement &transition, bool updateTransitionWidget); void activateMonitor(); int duration() const; void deleteSelectedClips(); /** @brief Cuts all clips that are selected at the timeline cursor position. */ void cutSelectedClips(); void setContextMenu(QMenu *timeline, QMenu *clip, QMenu *transition, QActionGroup *clipTypeGroup, QMenu *markermenu); - void checkTrackHeight(); + bool checkTrackHeight(); + void updateSceneFrameWidth(); //QList tracksList() const; - void setTool(PROJECTTOOL tool); - ClipItem *cutClip(ItemInfo info, GenTime cutTime, bool cut, bool execute = true); + void setTool(ProjectTool tool); + ClipItem *cutClip(const ItemInfo &info, const GenTime &cutTime, bool cut, const EffectsList &oldStack = EffectsList(), bool execute = true); void slotSeekToPreviousSnap(); void slotSeekToNextSnap(); double getSnapPointForPos(double pos); - void editKeyFrame(const GenTime pos, const int track, const int index, const QString keyframes); + void editKeyFrame(const GenTime &pos, const int track, const int index, const QString &keyframes); bool findString(const QString &text); void selectFound(QString track, QString pos); bool findNextString(const QString &text); @@ -103,8 +117,7 @@ public: QList findId(const QString &clipId); void clipStart(); void clipEnd(); - void changeClipSpeed(); - void doChangeClipSpeed(ItemInfo info, ItemInfo speedIndependantInfo, const double speed, const double oldspeed, int strobe, const QString &id); + void doChangeClipSpeed(ItemInfo info, const ItemInfo &speedIndependantInfo, const double speed, const double oldspeed, int strobe, const QString &id); /** @brief Sets the document as modified. */ void setDocumentModified(); void setInPoint(); @@ -116,12 +129,11 @@ public: void slotInsertSpace(); /** @brief Prepares removing space. */ void slotRemoveSpace(); - void insertSpace(QList clipsToMove, QList transToMove, int track, const GenTime duration, const GenTime offset); + void insertSpace(QList clipsToMove, QList transToMove, int track, const GenTime &duration, const GenTime &offset); ClipItem *getActiveClipUnderCursor(bool allowOutsideCursor = false) const; void deleteTimelineTrack(int ix, TrackInfo trackinfo); void saveThumbnails(); void autoTransition(); - QStringList getLadspaParams(QDomElement effect) const; void initCursorPos(int pos); /** @brief Locks or unlocks a track. @@ -131,18 +143,24 @@ public: * * Makes sure no clip on track to lock is selected. */ void lockTrack(int ix, bool lock, bool requestUpdate = true); - void groupClips(bool group = true); + void groupClips(bool group = true, QList itemList = QList(), QUndoCommand *command = NULL); void doGroupClips(QList clipInfos, QList transitionInfos, bool group); - void loadGroups(const QDomNodeList groups); + void loadGroups(const QDomNodeList &groups); /** @brief Creates SplitAudioCommands for selected clips. */ void splitAudio(); + /// Define which clip to take as reference for automatic audio alignment + void setAudioAlignReference(); + + /// Automatically align the currently selected clips to synchronize their audio with the reference's audio + void alignAudio(); + /** @brief Seperates the audio of a clip to a audio track. * @param pos Position of the clip to split * @param track Track of the clip * @param split Split or unsplit */ - void doSplitAudio(const GenTime &pos, int track, bool split); + void doSplitAudio(const GenTime &pos, int track, EffectsList effects, bool split); void setVideoOnly(); void setAudioOnly(); void setAudioAndVideo(); @@ -154,6 +172,8 @@ public: int selectedTrack() const; QStringList selectedClips() const; QList 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 @@ -163,7 +183,7 @@ public: void selectClip(bool add, bool group = false, int track = -1, int pos = -1); void selectTransition(bool add, bool group = false); QStringList extractTransitionsLumas(); - void setEditMode(EDITMODE mode); + void setEditMode(EditMode mode); /** @brief Inserts @param clip. * @param clip The clip to insert @@ -172,10 +192,9 @@ public: * * Inserts at the position of timeline cursor and selected track. */ void insertClipCut(DocClipBase *clip, int in, int out); - void clearSelection(); + void clearSelection(bool emitInfo = true); void editItemDuration(); void buildGuidesMenu(QMenu *goMenu) const; - KPixmapCache* pixmapCache; /** update the timeline objects when palette changes */ void updatePalette(); /** @brief Returns true if a track has audio data on it. @@ -184,14 +203,27 @@ public: * Check whether given track has a clip with audio in it. */ bool hasAudio(int track) const; + int getFrameWidth() const; + /** @brief Returns last requested seeking pos (or SEEK_INACTIVE if no seek). */ + int seekPosition() const; + + /** @brief Trigger a monitor refresh. */ + void monitorRefresh(); + + /** @brief Returns frame number of current mouse position. */ + int getMousePos() const; + public slots: - void setCursorPos(int pos, bool seek = true); + /** @brief Send seek request to MLT. */ + void seekCursorPos(int pos); + /** @brief Move timeline cursor to new position. */ + void setCursorPos(int pos); void moveCursorPos(int delta); void updateCursorPos(); 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 slotChangeEffectState(ClipItem *clip, int track, QList effectIndexes, bool disable); + void slotChangeEffectPosition(ClipItem *clip, int track, QList currentPos, int newPos); + void slotUpdateClipEffect(ClipItem *clip, int track, QDomElement oldeffect, QDomElement effect, int ix, bool refreshEffectStack = true); void slotUpdateClipRegion(ClipItem *clip, int ix, QString region); void slotRefreshEffects(ClipItem *clip); void setDuration(int duration); @@ -202,14 +234,26 @@ public slots: void slotSwitchTrackVideo(int ix); void slotSwitchTrackLock(int ix); void slotUpdateClip(const QString &clipId, bool reload = true); - void slotAddClipMarker(const QString &id, GenTime t, QString c); - bool addGuide(const GenTime pos, const QString &comment); - void slotAddGuide(); - void slotEditGuide(CommentedTime guide); + + /** @brief Add extra data to a clip. */ + void slotAddClipExtraData(const QString &id, const QString &key, const QString &data = QString(), QUndoCommand *groupCommand = 0); + /** @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, QList newMarker, QUndoCommand *groupCommand = 0); + void slotLoadClipMarkers(const QString &id); + void slotSaveClipMarkers(const QString &id); + bool addGuide(const GenTime &pos, const QString &comment); + + /** @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(const CommentedTime &guide); void slotEditGuide(int guidePos = -1); void slotDeleteGuide(int guidePos = -1); void slotDeleteAllGuides(); - void editGuide(const GenTime oldPos, const GenTime pos, const QString &comment); + void editGuide(const GenTime &oldPos, const GenTime &pos, const QString &comment); void copyClip(); void pasteClip(); void pasteClipEffects(); @@ -222,7 +266,7 @@ public slots: void slotDeleteTrack(int ix); /** @brief Shows the configure tracks dialog. */ void slotConfigTracks(int ix); - void clipNameChanged(const QString id, const QString name); + void clipNameChanged(const QString &id, const QString &name); void slotTrackUp(); void slotTrackDown(); void slotSelectTrack(int ix); @@ -231,26 +275,33 @@ public slots: /** @brief Rebuilds a group to fit again after children changed. * @param childTrack the track of one of the groups children * @param childPos The position of the same child */ - void rebuildGroup(int childTrack, GenTime childPos); + void rebuildGroup(int childTrack, const GenTime &childPos); /** @brief Rebuilds a group to fit again after children changed. * @param group The group to rebuild */ void rebuildGroup(AbstractGroupItem *group); - /** @brief Cuts a group into two parts. - * @param clips1 Clips before the cut - * @param transitions1 Transitions before the cut - * @param clipsCut Clips that need to be cut - * @param transitionsCut Transitions that need to be cut - * @param clips2 Clips behind the cut - * @param transitions2 Transitions behind the cut - * @param cutPos Absolute position of the cut - * @param cut true = cut, false = "uncut" */ - void slotRazorGroup(QList clips1, QList transitions1, QList clipsCut, QList transitionsCut, QList clips2, QList 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); + void slotAddTrackEffect(const QDomElement &effect, int ix); + /** @brief Select all clips in selected track. */ + void slotSelectClipsInTrack(); + /** @brief Select all clips in timeline. */ + void slotSelectAllClips(); + + /** @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 offsetList = QList (), bool skipSelectedItems = false); + + void slotAddEffect(ClipItem *clip, const QDomElement &effect); + void slotImportClipKeyframes(GraphicsRectItem type); + + /** @brief Get effect parameters ready for MLT*/ + static void adjustEffectParameters(EffectsParameterList ¶meters, QDomNodeList params, MltVideoProfile profile, const QString &prefix = QString()); + /** @brief Move playhead to mouse curser position if defined key is pressed */ + void slotAlignPlayheadToMousePos(); protected: virtual void drawBackground(QPainter * painter, const QRectF & rect); @@ -266,6 +317,7 @@ protected: virtual Qt::DropActions supportedDropActions() const; private: + int m_ct; int m_tracksHeight; int m_projectDuration; int m_cursorPos; @@ -274,8 +326,8 @@ private: QGraphicsLineItem *m_cursorLine; ItemInfo m_dragItemInfo; ItemInfo m_selectionGroupInfo; - OPERATIONTYPE m_operationMode; - OPERATIONTYPE m_moveOpMode; + OperationType m_operationMode; + OperationType m_moveOpMode; AbstractClipItem *m_dragItem; Guide *m_dragGuide; QUndoStack *m_commandStack; @@ -288,11 +340,12 @@ private: QPoint m_clickEvent; QList m_searchPoints; QList m_guides; - void updateSnapPoints(AbstractClipItem *selected, QList offsetList = QList (), bool skipSelectedItems = false); + ClipItem *getClipItemAt(int pos, int track); ClipItem *getClipItemAt(GenTime pos, int track); ClipItem *getClipItemAtEnd(GenTime pos, int track); ClipItem *getClipItemAtStart(GenTime pos, int track); + Transition *getTransitionItem(TransitionInfo info); Transition *getTransitionItemAt(int pos, int track); Transition *getTransitionItemAt(GenTime pos, int track); Transition *getTransitionItemAtEnd(GenTime pos, int track); @@ -310,6 +363,8 @@ private: QAction *m_ungroupAction; QAction *m_editGuide; QAction *m_deleteGuide; + QList m_audioActions; + QList m_avActions; QActionGroup *m_clipTypeGroup; QTimer m_scrollTimer; QTimer m_thumbsTimer; @@ -317,7 +372,7 @@ private: bool m_clipDrag; int m_findIndex; - PROJECTTOOL m_tool; + ProjectTool m_tool; QCursor m_razorCursor; QCursor m_spacerCursor; /** list containing items currently copied in the timeline */ @@ -330,8 +385,13 @@ private: int m_selectedTrack; int m_spacerOffset; + QMutex m_selectionMutex; QMutex m_mutex; QWaitCondition m_producerNotReady; + KStatefulBrush m_activeTrackBrush; + + AudioCorrelation *m_audioCorrelator; + ClipItem *m_audioAlignmentReference; /** 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. */ @@ -339,28 +399,27 @@ private: /** Get the index of the video track that is just below current track */ int getPreviousVideoTrack(int track); - void updatePositionEffects(ClipItem * item, ItemInfo info); - bool insertDropClips(const QMimeData *data, const QPoint pos); - bool canBePastedTo(ItemInfo info, int type) const; + void updatePositionEffects(ClipItem * item, const ItemInfo &info, bool standalone = true); + bool insertDropClips(const QMimeData *data, const QPoint &pos); bool canBePastedTo(QList infoList, int type) const; bool canBePasted(QList items, GenTime offset, int trackOffset) const; bool canBeMoved(QList items, GenTime offset, int trackOffset) const; ClipItem *getClipUnderCursor() const; AbstractClipItem *getMainActiveClip() const; void resetSelectionGroup(bool selectItems = true); - void groupSelectedItems(bool force = false, bool createNewGroup = false); + void groupSelectedItems(QList selection = QList (), bool createNewGroup = false, bool selectNewGroup = false); /** Get available space for clip move (min and max free positions) */ void getClipAvailableSpace(AbstractClipItem *item, GenTime &minimum, GenTime &maximum); /** Get available space for transition move (min and max free positions) */ void getTransitionAvailableSpace(AbstractClipItem *item, GenTime &minimum, GenTime &maximum); void updateClipTypeActions(ClipItem *clip); /** Whether an item can be moved to a new position without colliding with similar items */ - bool itemCollision(AbstractClipItem *item, ItemInfo newPos); + bool itemCollision(AbstractClipItem *item, const ItemInfo &newPos); /** Selects all items in the scene rect, and sets ok to false if a group going over several tracks is found in it */ QList checkForGroups(const QRectF &rect, bool *ok); /** Adjust clips under another one when working in overwrite mode */ - void adjustTimelineClips(EDITMODE mode, ClipItem *item, ItemInfo posinfo, QUndoCommand *command); - void adjustTimelineTransitions(EDITMODE mode, Transition *item, QUndoCommand *command); + void adjustTimelineClips(EditMode mode, ClipItem *item, ItemInfo posinfo, QUndoCommand *command); + void adjustTimelineTransitions(EditMode mode, Transition *item, QUndoCommand *command); /** Adjust keyframes when pasted to another clip */ void adjustKeyfames(GenTime oldstart, GenTime newstart, GenTime duration, QDomElement xml); @@ -370,7 +429,7 @@ private: * @param clip clip to display the tip on * @param mode operation mode for which the tip should be displayed * @param size size of the tip */ - void setTipAnimation(AbstractClipItem *clip, OPERATIONTYPE mode, const double size); + void setTipAnimation(AbstractClipItem *clip, OperationType mode, const double size); /** @brief Takes care of updating effects and attached transitions during a resize from start. * @param item Item to resize @@ -394,14 +453,32 @@ private: void razorGroup(AbstractGroupItem *group, GenTime cutPos); /** @brief Gets the effect parameters that will be passed to Mlt. */ - EffectsParameterList getEffectArgs(const QDomElement effect); + 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 + /** @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 * - */ - void updatePanZoom(ClipItem *item, GenTime cutPos = GenTime()); + * 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); + + /** @brief Prepare an add clip command for an effect */ + void processEffect(ClipItem *item, QDomElement effect, int offset, QUndoCommand *effectCommand); private slots: void slotRefreshGuides(); @@ -414,21 +491,32 @@ 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); + /** @brief A Filter job producer results. */ + void slotGotFilterJobResults(const QString &id, int startPos, int track, stringMap filterParams, stringMap extra); + 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 raise If true, the effect stack widget will be raised (come to front). */ + void clipItemSelected(ClipItem *clip, bool raise = true); void transitionItemSelected(Transition*, int track = 0, QPoint p = QPoint(), bool update = false); void activateDocumentMonitor(); void trackHeightChanged(); void tracksChanged(); - void displayMessage(const QString, MessageType); - void showClipFrame(DocClipBase *, QPoint, const int); + void displayMessage(const QString &, MessageType); + void showClipFrame(DocClipBase *, QPoint, bool, const int); void doTrackLock(int, bool); void updateClipMarkers(DocClipBase *); + void updateClipExtraData(DocClipBase *); void updateTrackHeaders(); void playMonitor(); /** @brief Monitor document changes (for example the presence of audio data in timeline for export widget.*/ @@ -437,6 +525,10 @@ signals: void showTrackEffects(int, TrackInfo); /** @brief Update the track effect button that shows if a track has effects or not.*/ void updateTrackEffectState(int); + /** @brief Cursor position changed, repaint ruler.*/ + void updateRuler(); + /** @brief Send data from a clip to be imported as keyframes for effect / transition.*/ + void importKeyframes(GraphicsRectItem type, const QString&, int maximum); }; #endif