From b3d598f551a874b34ff4fb51a0a65631fc3ad070 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Thu, 10 Oct 2013 15:00:41 +0100 Subject: [PATCH] Basic snapping in the timeline. --- ChangeLog | 2 ++ src/wx/timeline.cc | 57 +++++++++++++++++++++++++++++++++++++-- src/wx/timeline.h | 9 +++++++ src/wx/timeline_dialog.cc | 16 ++++++++++- src/wx/timeline_dialog.h | 3 +++ 5 files changed, 84 insertions(+), 3 deletions(-) diff --git a/ChangeLog b/ChangeLog index 2599b9b97..d741a3a2e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2013-10-10 Carl Hetherington + * Basic snapping in the timeline. + * Various improvements to dcpomatic_kdm. 2013-10-10 Carl Hetherington diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index 87070b35e..1f0aee4e8 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -33,7 +33,9 @@ using boost::shared_ptr; using boost::weak_ptr; using boost::dynamic_pointer_cast; using boost::bind; +using boost::optional; +/** Parent class for components of the timeline (e.g. a piece of content or an axis) */ class View : public boost::noncopyable { public: @@ -332,6 +334,7 @@ Timeline::Timeline (wxWindow* parent, FilmEditor* ed, shared_ptr film) , _down_view_position (0) , _first_move (false) , _menu (film, this) + , _snap (true) { #ifndef __WXOSX__ SetDoubleBuffered (true); @@ -577,6 +580,9 @@ Timeline::set_position_from_event (wxMouseEvent& ev) wxPoint const p = ev.GetPosition(); if (!_first_move) { + /* We haven't moved yet; in that case, we must move the mouse some reasonable distance + before the drag is considered to have started. + */ int const dist = sqrt (pow (p.x - _down_point.x, 2) + pow (p.y - _down_point.y, 2)); if (dist < 8) { return; @@ -584,9 +590,56 @@ Timeline::set_position_from_event (wxMouseEvent& ev) _first_move = true; } - Time const time_diff = (p.x - _down_point.x) / _pixels_per_time_unit; if (_down_view) { - _down_view->content()->set_position (max (static_cast