timebasedwidget: rewrote scroll catchup code
Code is much better. Less hacky queuing, implements cooldowns to improve navigation, and introduces a framework so that subclasses can make use of catchup/cooldown code too with any scrollbar they want
This commit is contained in:
@@ -906,8 +906,7 @@ void TimelineWidget::ViewMouseMoved(TimelineViewMouseEvent *event)
|
||||
|
||||
UpdateViewports();
|
||||
|
||||
QMetaObject::invokeMethod(this, "CatchUpScrollToPoint", Qt::QueuedConnection,
|
||||
Q_ARG(int, qRound(event->GetSceneX())));
|
||||
SetCatchUpScrollValue(event->GetScreenPos().x());
|
||||
} else {
|
||||
// Mouse is not down, attempt a hover event
|
||||
TimelineTool* hover_tool = GetActiveTool();
|
||||
@@ -922,6 +921,8 @@ void TimelineWidget::ViewMouseMoved(TimelineViewMouseEvent *event)
|
||||
|
||||
void TimelineWidget::ViewMouseReleased(TimelineViewMouseEvent *event)
|
||||
{
|
||||
StopCatchUpScrollTimer();
|
||||
|
||||
if (active_tool_) {
|
||||
if (GetConnectedNode()) {
|
||||
active_tool_->MouseRelease(event);
|
||||
@@ -956,16 +957,22 @@ void TimelineWidget::ViewDragMoved(TimelineViewMouseEvent *event)
|
||||
{
|
||||
import_tool_->DragMove(event);
|
||||
UpdateViewports();
|
||||
|
||||
SetCatchUpScrollValue(event->GetScreenPos().x());
|
||||
}
|
||||
|
||||
void TimelineWidget::ViewDragLeft(QDragLeaveEvent *event)
|
||||
{
|
||||
StopCatchUpScrollTimer();
|
||||
|
||||
import_tool_->DragLeave(event);
|
||||
UpdateViewports();
|
||||
}
|
||||
|
||||
void TimelineWidget::ViewDragDropped(TimelineViewMouseEvent *event)
|
||||
{
|
||||
StopCatchUpScrollTimer();
|
||||
|
||||
import_tool_->DragDrop(event);
|
||||
UpdateViewports();
|
||||
}
|
||||
|
||||
@@ -430,7 +430,8 @@ TimelineViewMouseEvent TimelineView::CreateMouseEvent(const QPoint& pos, Qt::Mou
|
||||
{
|
||||
QPointF scene_pt = mapToScene(pos);
|
||||
|
||||
return TimelineViewMouseEvent(scene_pt.x(),
|
||||
return TimelineViewMouseEvent(scene_pt,
|
||||
pos,
|
||||
GetScale(),
|
||||
timebase(),
|
||||
Track::Reference(ConnectedTrackType(), SceneToTrack(scene_pt.y())),
|
||||
|
||||
@@ -34,13 +34,15 @@ namespace olive {
|
||||
class TimelineViewMouseEvent
|
||||
{
|
||||
public:
|
||||
TimelineViewMouseEvent(const qreal& scene_x,
|
||||
TimelineViewMouseEvent(const QPointF& scene_pos,
|
||||
const QPoint &screen_pos,
|
||||
const double& scale_x,
|
||||
const rational& timebase,
|
||||
const Track::Reference &track,
|
||||
const Qt::MouseButton &button,
|
||||
const Qt::KeyboardModifiers& modifiers = Qt::NoModifier) :
|
||||
scene_x_(scene_x),
|
||||
scene_pos_(scene_pos),
|
||||
screen_pos_(screen_pos),
|
||||
scale_x_(scale_x),
|
||||
timebase_(timebase),
|
||||
track_(track),
|
||||
@@ -73,7 +75,7 @@ public:
|
||||
*/
|
||||
rational GetFrame(bool round = false) const
|
||||
{
|
||||
return TimeScaledObject::SceneToTime(scene_x_, scale_x_, timebase_, round);
|
||||
return TimeScaledObject::SceneToTime(GetSceneX(), scale_x_, timebase_, round);
|
||||
}
|
||||
|
||||
const Track::Reference& GetTrack() const
|
||||
@@ -96,11 +98,14 @@ public:
|
||||
source_event_ = event;
|
||||
}
|
||||
|
||||
const qreal& GetSceneX() const
|
||||
qreal GetSceneX() const
|
||||
{
|
||||
return scene_x_;
|
||||
return scene_pos_.x();
|
||||
}
|
||||
|
||||
const QPointF &GetScenePos() const { return scene_pos_; }
|
||||
const QPoint &GetScreenPos() const { return screen_pos_; }
|
||||
|
||||
const Qt::MouseButton& GetButton() const
|
||||
{
|
||||
return button_;
|
||||
@@ -122,7 +127,8 @@ public:
|
||||
void SetBypassImportBuffer(bool e) { bypass_import_buffer_ = e; }
|
||||
|
||||
private:
|
||||
qreal scene_x_;
|
||||
QPointF scene_pos_;
|
||||
QPoint screen_pos_;
|
||||
double scale_x_;
|
||||
rational timebase_;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user