Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 05c8c489 authored by Jason Wood's avatar Jason Wood

Can now scroll by dragging to the edge of the timeline or by dragging the ruler.

svn path=/trunk/kdenlive/; revision=299
parent e75d40fc
......@@ -44,11 +44,18 @@
uint KMMTimeLine::snapTolerance=10;
namespace {
uint g_scrollTimerDelay = 50;
uint g_scrollThreshold = 50;
}
KMMTimeLine::KMMTimeLine(KdenliveApp *app, QWidget *rulerToolWidget, QWidget *scrollToolWidget, KdenliveDoc *document, QWidget *parent, const char *name ) :
QVBox(parent, name),
m_document(document),
m_selection(),
m_snapToGrid(document)
m_snapToGrid(document),
m_scrollTimer(this, "scroll timer"),
m_scrollingRight(true)
{
m_app = app;
m_rulerBox = new QHBox(this, "ruler box");
......@@ -92,6 +99,10 @@ KMMTimeLine::KMMTimeLine(KdenliveApp *app, QWidget *rulerToolWidget, QWidget *sc
connect(m_ruler, SIGNAL(sliderValueChanged(int, int)), m_ruler, SLOT(repaint()));
connect(m_ruler, SIGNAL(sliderValueChanged(int, int)), this, SLOT(slotSliderMoved(int, int)));
connect(m_ruler, SIGNAL(requestScrollLeft()), this, SLOT(slotScrollLeft()));
connect(m_ruler, SIGNAL(requestScrollRight()), this, SLOT(slotScrollRight()));
connect(&m_scrollTimer, SIGNAL(timeout()), this, SLOT(slotTimerScroll()));
setAcceptDrops(true);
syncWithDocument();
......@@ -254,6 +265,20 @@ void KMMTimeLine::dragMoveEvent ( QDragMoveEvent *event )
}
calculateProjectSize();
m_trackViewArea->repaint();
if(pos.x() < g_scrollThreshold) {
if(!m_scrollTimer.isActive()) {
m_scrollTimer.start(g_scrollTimerDelay, false);
}
m_scrollingRight = false;
} else if(m_trackViewArea->width() - pos.x() < g_scrollThreshold) {
if(!m_scrollTimer.isActive()) {
m_scrollTimer.start(g_scrollTimerDelay, false);
}
m_scrollingRight = true;
} else {
m_scrollTimer.stop();
}
}
void KMMTimeLine::dragLeaveEvent ( QDragLeaveEvent *event )
......@@ -293,6 +318,8 @@ void KMMTimeLine::dragLeaveEvent ( QDragLeaveEvent *event )
calculateProjectSize();
drawTrackViewBackBuffer();
m_scrollTimer.stop();
}
void KMMTimeLine::dropEvent ( QDropEvent *event )
......@@ -318,6 +345,8 @@ void KMMTimeLine::dropEvent ( QDropEvent *event )
m_app->addCommand(m_moveClipsCommand, false);
m_moveClipsCommand = 0; // KdenliveApp is now managing this command, we do not need to delete it.
}
m_scrollTimer.stop();
}
/** This method maps a local coordinate value to the corresponding
......@@ -809,3 +838,22 @@ GenTime KMMTimeLine::projectLength() const
{
return GenTime(m_ruler->maxValue(), m_document->framesPerSecond());
}
void KMMTimeLine::slotTimerScroll()
{
if(m_scrollingRight) {
m_scrollBar->addLine();
} else {
m_scrollBar->subtractLine();
}
}
void KMMTimeLine::slotScrollLeft()
{
m_scrollBar->subtractLine();
}
void KMMTimeLine::slotScrollRight()
{
m_scrollBar->addLine();
}
......@@ -20,6 +20,7 @@
#include <qvaluelist.h>
#include <qvbox.h>
#include <qtimer.h>
#include "kmmtrackpanel.h"
#include "kdenlive.h"
......@@ -120,31 +121,37 @@ private: // attributes
operations.
*/
SnapToGrid m_snapToGrid;
/** Timer for timeline scroll functionality */
QTimer m_scrollTimer;
/** Controls scroll direction. */
bool m_scrollingRight;
public: // Public methods
/** This method adds a new track to the trackGrid. */
void appendTrack(KMMTrackPanel *track);
/** This method adds a new track to the trackGrid. */
void appendTrack(KMMTrackPanel *track);
void resizeEvent(QResizeEvent *event);
void resizeEvent(QResizeEvent *event);
/** Inserts a track at the position specified by index */
void insertTrack(int index, KMMTrackPanel *track);
/** Inserts a track at the position specified by index */
void insertTrack(int index, KMMTrackPanel *track);
/** No descriptions */
void polish();
/** No descriptions */
void polish();
void dragEnterEvent ( QDragEnterEvent * );
void dragMoveEvent ( QDragMoveEvent * );
void dragLeaveEvent ( QDragLeaveEvent * );
void dropEvent ( QDropEvent * );
/** Deselects all clips on the timeline. This does not affect any clips that are "in transition" onto the
timeline,i.e. in a drag process, clips that are in m_selection but have not been placed do not become
deselected */
KCommand *selectNone();
/** Returns m_trackList
/** Deselects all clips on the timeline. This does not affect any clips that are "in transition"
* onto the timeline,i.e. in a drag process, clips that are in m_selection but have not been
* placed do not become deselected */
KCommand *selectNone();
Warning - this method is a bit of a hack, not good OOP practice, and should be removed at some point. */
/** Returns m_trackList
Warning - this method is a bit of a hack, not good OOP practice, and should be removed at
some point. */
QPtrList<KMMTrackPanel> &trackList();
/** Moves all selected clips to a new position. The new start position is that for the master clip,
......@@ -263,35 +270,42 @@ it does not remove the clips from the timeline. */
*/
QValueList<GenTime> selectedClipTimes();
public slots: // Public slots
/** Called when a track within the project has been added or removed.
*
* The timeline needs to be updated to show these changes. */
void syncWithDocument();
/** Update the back buffer for the track views, and tell the trackViewArea widget to
repaint itself. */
void drawTrackViewBackBuffer();
/** Sets a new time scale for the timeline. This in turn calls the correct kruler funtion and
updates the display. */
void setTimeScale(int scale);
/** Calculates the size of the project, and sets up the timeline to accomodate it. */
void calculateProjectSize();
/** A ruler slider has moved - do something! */
void slotSliderMoved(int slider, int value);
/** Seek the timeline to the current position. */
void seek(const GenTime &time);
/** Called when a track within the project has been added or removed.
* The timeline needs to be updated to show these changes. */
void syncWithDocument();
/** Update the back buffer for the track views, and tell the trackViewArea widget to
repaint itself. */
void drawTrackViewBackBuffer();
/** Sets a new time scale for the timeline. This in turn calls the correct kruler funtion and
updates the display. */
void setTimeScale(int scale);
/** Calculates the size of the project, and sets up the timeline to accomodate it. */
void calculateProjectSize();
/** A ruler slider has moved - do something! */
void slotSliderMoved(int slider, int value);
/** Seek the timeline to the current position. */
void seek(const GenTime &time);
/** Scroll the timeline left */
void slotScrollLeft();
/** Scroll the timeline Right */
void slotScrollRight();
private slots: // Private slots
/** Scroll the timeline by a set amount. Should be connected to m_scrollTimer */
void slotTimerScroll();
signals: // Signals
/** emitted when the length of the project has changed. */
void projectLengthChanged(int);
/** Emitted when the seek position on the timeline changes. */
void seekPositionChanged(const GenTime &);
/** Emitted when the clip crop start has changed for a clip. */
void signalClipCropStartChanged(const GenTime &);
/** Emitted when the clip crop end has changed for a clip. */
void signalClipCropEndChanged(const GenTime &);
/** emitted when something of interest is happening over a clip on the timeline. */
void lookingAtClip(DocClipBase *, const GenTime &);
/** emitted when the length of the project has changed. */
void projectLengthChanged(int);
/** Emitted when the seek position on the timeline changes. */
void seekPositionChanged(const GenTime &);
/** Emitted when the clip crop start has changed for a clip. */
void signalClipCropStartChanged(const GenTime &);
/** Emitted when the clip crop end has changed for a clip. */
void signalClipCropEndChanged(const GenTime &);
/** emitted when something of interest is happening over a clip on the timeline. */
void lookingAtClip(DocClipBase *, const GenTime &);
};
#endif
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment