#include "addtimelineclipcommand.h"
#include "addeffectcommand.h"
#include "editeffectcommand.h"
+#include "kdenlivesettings.h"
CustomTrackView::CustomTrackView(KdenliveDoc *doc, QGraphicsScene * projectscene, QWidget *parent)
- : QGraphicsView(projectscene, parent), m_tracksCount(0), m_cursorPos(0), m_dropItem(NULL), m_cursorLine(NULL), m_operationMode(NONE), m_startPos(QPointF()), m_dragItem(NULL), m_visualTip(NULL), m_moveOpMode(NONE), m_animation(NULL), m_projectDuration(0), m_scale(1.0), m_clickPoint(0), m_document(doc) {
+ : QGraphicsView(projectscene, parent), m_tracksCount(0), m_cursorPos(0), m_dropItem(NULL), m_cursorLine(NULL), m_operationMode(NONE), m_startPos(QPointF()), m_dragItem(NULL), m_visualTip(NULL), m_moveOpMode(NONE), m_animation(NULL), m_projectDuration(0), m_scale(1.0), m_clickPoint(0), m_document(doc), m_autoScroll(KdenliveSettings::autoscroll()) {
if (doc) m_commandStack = doc->commandStack();
else m_commandStack == NULL;
setMouseTracking(true);
}
}
-void CustomTrackView::initView() {
-
+void CustomTrackView::checkAutoScroll() {
+ m_autoScroll = KdenliveSettings::autoscroll();
}
// virtual
m_cursorLine->setPos(pos, 0);
int frame = pos / m_scale;
if (seek) m_document->renderer()->seek(GenTime(frame, m_document->fps()));
+ else if (m_autoScroll && m_scale < 50) checkScrolling();
}
int CustomTrackView::cursorPos() {
return m_cursorPos;
}
+void CustomTrackView::checkScrolling() {
+ QRect rectInView = viewport()->rect();
+ int delta = rectInView.width() / 3;
+ int max = rectInView.right() + horizontalScrollBar()->value() - delta;
+ //kDebug() << "CURSOR POS: "<<m_cursorPos<< "Scale: "<<m_scale;
+ if (m_cursorPos >= max) horizontalScrollBar()->setValue(horizontalScrollBar()->value() + 1 + m_scale);
+}
+
void CustomTrackView::mouseReleaseEvent(QMouseEvent * event) {
QGraphicsView::mouseReleaseEvent(event);
setDragMode(QGraphicsView::NoDrag);
}
void CustomTrackView::drawBackground(QPainter * painter, const QRectF & rect) {
- QRect rectInView;//this is the rect that is visible by the user
- if (scene()->views().size() > 0) {
- rectInView = scene()->views()[0]->viewport()->rect();
- rectInView.moveTo(scene()->views()[0]->horizontalScrollBar()->value(), scene()->views()[0]->verticalScrollBar()->value());
- }
- if (rectInView.isNull()) return;
+ QRect rectInView = viewport()->rect();
+ rectInView.moveTo(horizontalScrollBar()->value(), verticalScrollBar()->value());
QColor base = palette().button().color();
painter->setClipRect(rect);
void addTrack();
void removeTrack();
int cursorPos();
- void initView();
+ void checkAutoScroll();
void moveClip(const QPointF &startPos, const QPointF &endPos);
void resizeClip(const QPointF &startPos, const QPointF &endPos, bool resizeClipStart);
void addClip(QDomElement xml, int clipId, int track, int startpos, const QRectF &rect, int duration);
void updateSnapPoints(ClipItem *selected);
double getSnapPointForPos(double pos);
ClipItem *getClipItemAt(int pos, int track);
+ void checkScrolling();
+ /** Should we auto scroll while playing (keep in sync with KdenliveSettings::autoscroll() */
+ bool m_autoScroll;
signals:
// KConfigDialog didn't find an instance of this dialog, so lets
// create it :
KdenliveSettingsDialog* dialog = new KdenliveSettingsDialog(this);
- connect( dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()) );
+ connect(dialog, SIGNAL(settingsChanged(const QString&)), this, SLOT(updateConfiguration()));
dialog->show();
}
void MainWindow::updateConfiguration() {
TrackView *currentTab = (TrackView *) m_timelineArea->currentWidget();
- if (currentTab) currentTab->refresh();
+ if (currentTab) {
+ currentTab->refresh();
+ currentTab->projectView()->checkAutoScroll();
+ }
}
void MainWindow::slotGotProgressInfo(KUrl url, int progress) {