if (isSelected()) {
fades = QBrush(QColor(200, 50, 50, 150));
}
- else fades = QBrush(QColor(200, 200, 200, 150));
+ else fades = QBrush(QColor(200, 200, 200, 200));
if (m_startFade != 0) {
QPainterPath fadeInPath;
void CustomTrackView::mouseMoveEvent ( QMouseEvent * event )
{
int pos = event->x();
+ emit mousePosition(mapToScene(event->pos()).x() / m_scale);
/*if (event->modifiers() == Qt::ControlModifier)
setDragMode(QGraphicsView::ScrollHandDrag);
else if (event->modifiers() == Qt::ShiftModifier)
if (m_dragItem) { //event->button() == Qt::LeftButton) {
// a button was pressed, delete visual tips
-
if (m_operationMode == MOVE) {
- int moveX = mapToScene(event->pos()).x();
+ int snappedPos = getSnapPointForPos(mapToScene(event->pos()).x() - m_clickPoint);
+ int moveX = snappedPos; //mapToScene(event->pos()).x();
//kDebug()<<"/////// MOVE CLIP, EVENTĀ Y: "<<event->scenePos().y()<<", SCENE HEIGHT: "<<scene()->sceneRect().height();
int moveTrack = (int) mapToScene(event->pos()).y() / 50;
int currentTrack = m_dragItem->track();
int offset = moveTrack - currentTrack;
if (offset != 0) offset = 50 * offset;
- m_dragItem->moveTo((moveX - m_clickPoint) / m_scale, m_scale, offset, moveTrack);
+ m_dragItem->moveTo(moveX / m_scale, m_scale, offset, moveTrack);
}
else if (m_operationMode == RESIZESTART) {
int pos = mapToScene(event->pos()).x();
void CustomTrackView::mousePressEvent ( QMouseEvent * event )
{
int pos = event->x();
+ updateSnapPoints();
if (event->modifiers() == Qt::ControlModifier)
setDragMode(QGraphicsView::ScrollHandDrag);
else if (event->modifiers() == Qt::ShiftModifier)
}
}
+double CustomTrackView::getSnapPointForPos(double pos)
+{
+ for (int i = 0; i < m_snapPoints.size(); ++i) {
+ if (abs(pos - m_snapPoints.at(i) * m_scale) < 6) return m_snapPoints.at(i) * m_scale;
+ if (m_snapPoints.at(i) > pos) break;
+ }
+ return pos;
+}
+
+void CustomTrackView::updateSnapPoints()
+{
+ m_snapPoints.clear();
+ QList<QGraphicsItem *> itemList = items();
+ for (int i = 0; i < itemList.count(); i++) {
+ if (itemList.at(i)->type() == 70000) {
+ ClipItem *item = (ClipItem *)itemList.at(i);
+ m_snapPoints.append(item->startPos());
+ if (item->fadeIn() != 0) m_snapPoints.append(item->startPos() + item->fadeIn());
+ m_snapPoints.append(item->endPos());
+ if (item->fadeOut() != 0) m_snapPoints.append(item->endPos() - item->fadeOut());
+ }
+ }
+ qSort(m_snapPoints);
+}
+
void CustomTrackView::setScale(double scaleFactor)
{
QColor m_tipColor;
double m_scale;
int m_clickPoint;
+ QList <int> m_snapPoints;
+ void updateSnapPoints();
+ double getSnapPointForPos(double pos);
signals:
void cursorMoved(int);
void zoomIn();
void zoomOut();
+ void mousePosition(int);
};
#include <KRuler>
#include <KConfigDialog>
#include <KXMLGUIFactory>
+#include <KStatusBar>
#include <mlt++/Mlt.h>
#include "mainwindow.h"
#include "kdenlivesettings.h"
#include "ui_configmisc_ui.h"
+
+#define ID_STATUS_MSG 1
+#define ID_EDITMODE_MSG 2
+#define ID_TIMELINE_MSG 3
+#define ID_TIMELINE_POS 4
+#define ID_TIMELINE_FORMAT 5
MainWindow::MainWindow(QWidget *parent)
: KXmlGuiWindow(parent),
tabifyDockWidget (clipMonitorDock, projectMonitorDock);
setCentralWidget(m_timelineArea);
+
+ m_timecodeFormat = new KComboBox(this);
+ m_timecodeFormat->addItem(i18n("hh:mm:ss::ff"));
+ m_timecodeFormat->addItem(i18n("Frames"));
+ statusBar()->insertPermanentFixedItem("00:00:00:00", ID_TIMELINE_POS);
+ statusBar()->insertPermanentWidget(ID_TIMELINE_FORMAT, m_timecodeFormat);
+
setupGUI(Default, "kdenliveui.rc");
connect(projectMonitorDock, SIGNAL(visibilityChanged (bool)), m_projectMonitor, SLOT(refreshMonitor(bool)));
//connectDocument(trackView, doc);
}
+void MainWindow::slotUpdateMousePosition(int pos)
+{
+ if (m_activeDocument)
+ switch(m_timecodeFormat->currentIndex()) {
+ case 0:
+ statusBar()->changeItem(m_activeDocument->timecode().getTimecodeFromFrames(pos), ID_TIMELINE_POS);
+ break;
+ default:
+ statusBar()->changeItem(QString::number(pos), ID_TIMELINE_POS);
+ }
+}
+
void MainWindow::connectDocument(TrackView *trackView, KdenliveDoc *doc) //changed
{
//m_projectMonitor->stop();
m_activeDocument->setProducers(m_projectList->producersList());
m_activeDocument->setRenderer(NULL);
}
+ connect(trackView, SIGNAL(mousePosition(int)), this, SLOT(slotUpdateMousePosition(int)));
m_projectList->setDocument(doc);
m_monitorManager->setTimecode(doc->timecode());
doc->setRenderer(m_projectMonitor->render);
#include <KTabWidget>
#include <KUndoStack>
#include <KRecentFilesAction>
+#include <KComboBox>
#include "projectlist.h"
#include "monitor.h"
QAction *m_undo;
QAction *m_redo;
+ KComboBox *m_timecodeFormat;
+
QDockWidget *overviewDock;
CustomTrackView *m_overView;
void slotConnectMonitors();
void slotRaiseMonitor(bool clipMonitor);
void slotSetClipDuration(int id, int duration);
+ void slotUpdateMousePosition(int pos);
};
#endif
connect(m_trackview, SIGNAL(zoomIn ()), this, SLOT(slotZoomIn()));
connect(m_trackview, SIGNAL(zoomOut ()), this, SLOT(slotZoomOut()));
connect(m_trackview->horizontalScrollBar(), SIGNAL(sliderMoved( int )), m_ruler, SLOT(slotMoveRuler( int )));
+ connect(m_trackview, SIGNAL(mousePosition(int)), this, SIGNAL(mousePosition(int)));
view->horizontalSlider->setValue(4);
m_currentZoom = view->horizontalSlider->value();
void slotCursorMoved(int pos, bool slotCursorMoved = false);
void slotZoomIn();
void slotZoomOut();
+
+ signals:
+ void mousePosition(int);
};
#endif