Merge branch 'master' into move-serialization
This commit is contained in:
@@ -157,6 +157,16 @@ void TimeBasedView::SetViewerNode(ViewerOutput *v)
|
||||
}
|
||||
}
|
||||
|
||||
QPointF TimeBasedView::ScalePoint(const QPointF &p) const
|
||||
{
|
||||
return QPointF(p.x() * GetScale(), p.y() * GetYScale());
|
||||
}
|
||||
|
||||
QPointF TimeBasedView::UnscalePoint(const QPointF &p) const
|
||||
{
|
||||
return QPointF(p.x() / GetScale(), p.y() / GetYScale());
|
||||
}
|
||||
|
||||
void TimeBasedView::drawForeground(QPainter *painter, const QRectF &rect)
|
||||
{
|
||||
QGraphicsView::drawForeground(painter, rect);
|
||||
|
||||
@@ -64,6 +64,9 @@ public:
|
||||
|
||||
void SetViewerNode(ViewerOutput *v);
|
||||
|
||||
QPointF ScalePoint(const QPointF &p) const;
|
||||
QPointF UnscalePoint(const QPointF &p) const;
|
||||
|
||||
public slots:
|
||||
void SetEndTime(const rational& length);
|
||||
|
||||
|
||||
@@ -53,9 +53,10 @@ public:
|
||||
drawn_objects_.clear();
|
||||
}
|
||||
|
||||
void DeclareDrawnObject(T *object, const QRectF &pos)
|
||||
void DeclareDrawnObject(T *object, const QRectF &rect)
|
||||
{
|
||||
drawn_objects_.push_back({object, pos});
|
||||
QRectF r(view_->UnscalePoint(rect.topLeft()), view_->UnscalePoint(rect.bottomRight()));
|
||||
drawn_objects_.push_back({object, r});
|
||||
}
|
||||
|
||||
bool Select(T *key)
|
||||
@@ -345,23 +346,24 @@ public:
|
||||
void RubberBandStart(QMouseEvent *event)
|
||||
{
|
||||
if (event->button() == Qt::LeftButton || event->button() == Qt::RightButton) {
|
||||
rubberband_start_ = event->pos();
|
||||
rubberband_scene_start_ = view_->UnscalePoint(view_->mapToScene(event->pos()));
|
||||
|
||||
rubberband_ = new QRubberBand(QRubberBand::Rectangle, view_);
|
||||
rubberband_->setGeometry(QRect(rubberband_start_.x(), rubberband_start_.y(), 0, 0));
|
||||
rubberband_->setGeometry(QRect(event->pos().x(), event->pos().y(), 0, 0));
|
||||
rubberband_->show();
|
||||
|
||||
rubberband_preselected_ = selected_;
|
||||
}
|
||||
}
|
||||
|
||||
void RubberBandMove(QMouseEvent *event)
|
||||
void RubberBandMove(const QPoint &pos)
|
||||
{
|
||||
if (IsRubberBanding()) {
|
||||
QRect band_rect = QRect(rubberband_start_, event->pos()).normalized();
|
||||
rubberband_->setGeometry(band_rect);
|
||||
QRectF band_rect = QRectF(view_->mapFromScene(view_->ScalePoint(rubberband_scene_start_)), pos).normalized();
|
||||
rubberband_->setGeometry(band_rect.toRect());
|
||||
|
||||
QRectF scene_rect = view_->mapToScene(band_rect).boundingRect();
|
||||
QPointF current = view_->UnscalePoint(view_->mapToScene(pos));
|
||||
QRectF scene_rect = QRectF(rubberband_scene_start_, current).normalized();
|
||||
|
||||
selected_ = rubberband_preselected_;
|
||||
foreach (const DrawnObject &kp, drawn_objects_) {
|
||||
@@ -445,7 +447,7 @@ private:
|
||||
rational timebase_;
|
||||
|
||||
QRubberBand *rubberband_;
|
||||
QPoint rubberband_start_;
|
||||
QPointF rubberband_scene_start_;
|
||||
std::vector<T*> rubberband_preselected_;
|
||||
|
||||
TimeBasedWidget::SnapMask snap_mask_;
|
||||
|
||||
@@ -49,6 +49,7 @@ TimeBasedWidget::TimeBasedWidget(bool ruler_text_visible, bool ruler_cache_statu
|
||||
ruler_ = new TimeRuler(ruler_text_visible, ruler_cache_status_visible, this);
|
||||
ConnectTimelineView(ruler_);
|
||||
ruler()->SetSnapService(this);
|
||||
connect(ruler(), &TimeRuler::DragMoved, this, static_cast<void(TimeBasedWidget::*)(int)>(&TimeBasedWidget::SetCatchUpScrollValue));
|
||||
connect(ruler(), &TimeRuler::DragReleased, this, static_cast<void(TimeBasedWidget::*)()>(&TimeBasedWidget::StopCatchUpScrollTimer));
|
||||
|
||||
catchup_scroll_timer_ = new QTimer(this);
|
||||
@@ -230,6 +231,15 @@ void TimeBasedWidget::CatchUpTimerTimeout()
|
||||
const CatchUpScrollData &d = it.value();
|
||||
PageScrollInternal(sb, d.maximum, sb->value() + d.value, false);
|
||||
}
|
||||
|
||||
SendCatchUpScrollEvent();
|
||||
}
|
||||
|
||||
void TimeBasedWidget::SendCatchUpScrollEvent()
|
||||
{
|
||||
for (auto v : this->timeline_views_) {
|
||||
v->CatchUpScrollEvent();
|
||||
}
|
||||
}
|
||||
|
||||
void TimeBasedWidget::AutoUpdateTimebase()
|
||||
@@ -283,6 +293,8 @@ void TimeBasedWidget::ScaleChangedEvent(const double &scale)
|
||||
|
||||
UpdateMaximumScroll();
|
||||
|
||||
QMetaObject::invokeMethod(this, &TimeBasedWidget::SendCatchUpScrollEvent, Qt::QueuedConnection);
|
||||
|
||||
toggle_show_all_ = false;
|
||||
}
|
||||
|
||||
|
||||
@@ -141,7 +141,6 @@ protected:
|
||||
void ConnectTimelineView(TimeBasedView* base);
|
||||
|
||||
void SetCatchUpScrollValue(QScrollBar *b, int v, int maximum);
|
||||
void SetCatchUpScrollValue(int v);
|
||||
void StopCatchUpScrollTimer(QScrollBar *b);
|
||||
|
||||
virtual const QVector<Block*> *GetSnapBlocks() const { return nullptr; }
|
||||
@@ -169,11 +168,16 @@ protected slots:
|
||||
StopCatchUpScrollTimer(scrollbar_);
|
||||
}
|
||||
|
||||
void SetCatchUpScrollValue(int v);
|
||||
|
||||
signals:
|
||||
void TimebaseChanged(const rational&);
|
||||
|
||||
void ConnectedNodeChanged(ViewerOutput* old, ViewerOutput* now);
|
||||
|
||||
protected slots:
|
||||
virtual void SendCatchUpScrollEvent();
|
||||
|
||||
private:
|
||||
/**
|
||||
* @brief Set either in or out point to the current playhead
|
||||
|
||||
Reference in New Issue
Block a user