12000
};
-CustomRuler::CustomRuler(Timecode tc, QWidget *parent)
- : KRuler(parent), m_timecode(tc) {
+CustomRuler::CustomRuler(Timecode tc, CustomTrackView *parent)
+ : KRuler(parent), m_timecode(tc), m_view(parent) {
slotNewOffset(0);
setRulerMetricStyle(KRuler::Pixel);
setLength(1024);
// virtual
void CustomRuler::mousePressEvent(QMouseEvent * event) {
- int pos = event->x();
- slotMoveCursor(pos, true);
+ int pos = (event->x() + offset());
+ m_view->setCursorPos(pos);
}
// virtual
void CustomRuler::mouseMoveEvent(QMouseEvent * event) {
- int pos = event->x();
- slotMoveCursor(pos, true);
+ int pos = (event->x() + offset());
+ m_view->setCursorPos(pos);
}
void CustomRuler::slotMoveRuler(int newPos) {
int diff = offset() - newPos;
KRuler::slotNewOffset(newPos);
- KRuler::slotNewValue(m_cursorPosition * FRAME_SIZE * pixelPerMark() - offset());//value() + diff);
}
-void CustomRuler::slotMoveCursor(int _value, bool emitSignal) {
- m_cursorPosition = (_value + offset()) / pixelPerMark() / FRAME_SIZE;
- kDebug() << "RULER FR SZ: " << FRAME_SIZE << ", PPM: " << pixelPerMark();
- KRuler::slotNewValue(m_cursorPosition * FRAME_SIZE * pixelPerMark() - offset());
-
- if (emitSignal) emit cursorMoved(m_cursorPosition);
-}
-
-
-void CustomRuler::slotNewValue(int _value, bool emitSignal) {
- m_cursorPosition = _value / pixelPerMark();
- if (emitSignal) emit cursorMoved(m_cursorPosition / FRAME_SIZE);
- KRuler::slotNewValue(_value * pixelPerMark() - offset());
+void CustomRuler::slotCursorMoved(int oldpos, int newpos) {
+ //TODO: optimize (redraw only around cursor positions
+ update();
}
void CustomRuler::setPixelPerMark(double rate) {
int scale = comboScale[(int) rate];
- int newPos = m_cursorPosition * (1.0 / scale);
KRuler::setPixelPerMark(1.0 / scale);
- KRuler::slotNewValue(m_cursorPosition * FRAME_SIZE * pixelPerMark() - offset());
- //KRuler::slotNewValue( newPos );
}
// virtual
QStylePainter p(this);
-
- int value = this->value();
+ int value = m_view->cursorPos() - offset();
int minval = minimum();
int maxval = maximum() + offset() - endOffset();
#include <KRuler>
-#include <timecode.h>
+#include "customtrackview.h"
+#include "timecode.h"
class CustomRuler : public KRuler {
Q_OBJECT
public:
- CustomRuler(Timecode tc, QWidget *parent = 0);
+ CustomRuler(Timecode tc, CustomTrackView *parent);
virtual void mousePressEvent(QMouseEvent * event);
virtual void mouseMoveEvent(QMouseEvent * event);
void setPixelPerMark(double rate);
private:
int m_cursorPosition;
Timecode m_timecode;
- void slotMoveCursor(int _value, bool emitSignal);
+ CustomTrackView *m_view;
public slots:
- void slotNewValue(int _value, bool emitSignal = false);
void slotMoveRuler(int newPos);
+ void slotCursorMoved(int oldpos, int newpos);
-
-signals:
- void cursorMoved(int);
};
#endif
m_moveOpMode = NONE;
if (event->buttons() != Qt::NoButton) {
setCursorPos((int) mapToScene(event->pos().x(), 0).x());
- emit cursorMoved(cursorPos());
}
if (m_visualTip) {
if (m_animation) delete m_animation;
itemList.at(i)->setSelected(false);
emit clipItemSelected(NULL);
setCursorPos((int) mapToScene(event->x(), 0).x());
- emit cursorMoved(cursorPos());
}
}
updateSnapPoints(m_dragItem);
}
void CustomTrackView::setCursorPos(int pos, bool seek) {
+ emit cursorMoved(m_cursorPos, pos);
m_cursorPos = pos;
m_cursorLine->setPos(pos, 0);
int frame = pos / m_scale;
signals:
- void cursorMoved(int);
+ void cursorMoved(int, int);
void zoomIn();
void zoomOut();
void mousePosition(int);
setMouseTracking(true);
view = new Ui::TimeLine_UI();
view->setupUi(this);
- m_ruler = new CustomRuler(doc->timecode());
- QVBoxLayout *layout = new QVBoxLayout;
- view->ruler_frame->setLayout(layout);
- layout->addWidget(m_ruler);
m_scene = new QGraphicsScene();
m_trackview = new CustomTrackView(doc, m_scene, this);
m_trackview->setAlignment(Qt::AlignLeft | Qt::AlignTop);
//m_scene->addRect(QRectF(0, 0, 100, 100), QPen(), QBrush(Qt::red));
+ m_ruler = new CustomRuler(doc->timecode(), m_trackview);
+ QVBoxLayout *layout = new QVBoxLayout;
+ view->ruler_frame->setLayout(layout);
+ layout->addWidget(m_ruler);
+
m_headersLayout = new QVBoxLayout;
m_headersLayout->setContentsMargins(0, 0, 0, 0);
view->headers_frame->setLayout(m_headersLayout);
setEditMode("move");*/
connect(view->horizontalSlider, SIGNAL(valueChanged(int)), this, SLOT(slotChangeZoom(int)));
- connect(m_ruler, SIGNAL(cursorMoved(int)), this, SLOT(setCursorPos(int)));
- connect(m_trackview, SIGNAL(cursorMoved(int)), this, SLOT(slotCursorMoved(int)));
+ connect(m_trackview, SIGNAL(cursorMoved(int, int)), m_ruler, SLOT(slotCursorMoved(int, int)));
connect(m_trackview, SIGNAL(zoomIn()), this, SLOT(slotZoomIn()));
connect(m_trackview, SIGNAL(zoomOut()), this, SLOT(slotZoomOut()));
connect(m_trackview->horizontalScrollBar(), SIGNAL(valueChanged(int)), m_ruler, SLOT(slotMoveRuler(int)));
if (duration > m_projectDuration) m_projectDuration = duration;
}
m_trackview->setDuration(m_projectDuration);
- slotCursorMoved(cursorPos, true);
+ //m_trackview->setCursorPos(cursorPos);
//m_scrollBox->setGeometry(0, 0, 300 * zoomFactor(), m_scrollArea->height());
}
}
void TrackView::setCursorPos(int pos) {
- emit cursorMoved();
m_trackview->setCursorPos(pos * m_scale);
}
void TrackView::moveCursorPos(int pos) {
m_trackview->setCursorPos(pos * m_scale, false);
- m_ruler->slotNewValue(pos * FRAME_SIZE, false);
-}
-
-void TrackView::slotCursorMoved(int pos, bool emitSignal) {
- m_ruler->slotNewValue(pos * FRAME_SIZE / m_scale, emitSignal); //(int) m_trackview->mapToScene(QPoint(pos, 0)).x());
- //m_trackview->setCursorPos(pos);
- //m_trackview->invalidateScene(QRectF(), QGraphicsScene::ForegroundLayer);
}
void TrackView::slotChangeZoom(int factor) {
m_currentZoom = factor;
m_trackview->setScale(m_scale);
m_trackview->setCursorPos(pos * m_scale, false);
- m_ruler->slotNewValue(pos * FRAME_SIZE, false);
m_trackview->centerOn(QPointF(m_trackview->cursorPos(), 50));
}
private slots:
void slotChangeZoom(int factor);
- void slotCursorMoved(int pos, bool slotCursorMoved = false);
void slotZoomIn();
void slotZoomOut();
void setCursorPos(int pos);