From f3fc4b2a63ccc0a4da61371b3c2b10c8e9b8247d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 24 Jun 2014 10:06:25 +0100 Subject: Re-assign timeline tracks when things are moved about. --- src/wx/timeline.cc | 32 ++++++++++++++++++++++++++++---- src/wx/timeline.h | 4 +++- 2 files changed, 31 insertions(+), 5 deletions(-) (limited to 'src') diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index d4df6d8b2..eba12c47f 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -123,6 +123,10 @@ public: _track = t; } + void unset_track () { + _track = boost::optional (); + } + optional track () const { return _track; } @@ -362,7 +366,8 @@ Timeline::Timeline (wxWindow* parent, FilmEditor* ed, shared_ptr film) SetMinSize (wxSize (640, tracks() * track_height() + 96)); - _playlist_connection = film->playlist()->Changed.connect (bind (&Timeline::playlist_changed, this)); + _playlist_changed_connection = film->playlist()->Changed.connect (bind (&Timeline::playlist_changed, this)); + _playlist_content_changed_connection = film->playlist()->ContentChanged.connect (bind (&Timeline::playlist_content_changed, this, _2)); } void @@ -413,19 +418,38 @@ Timeline::playlist_changed () Refresh (); } +void +Timeline::playlist_content_changed (int property) +{ + ensure_ui_thread (); + + if (property == ContentProperty::POSITION) { + assign_tracks (); + setup_pixels_per_time_unit (); + Refresh (); + } +} + void Timeline::assign_tracks () { + for (ViewList::iterator i = _views.begin(); i != _views.end(); ++i) { + shared_ptr c = dynamic_pointer_cast (*i); + if (c) { + c->unset_track (); + } + } + for (ViewList::iterator i = _views.begin(); i != _views.end(); ++i) { shared_ptr cv = dynamic_pointer_cast (*i); if (!cv) { continue; } - + shared_ptr content = cv->content(); int t = 0; - while (1) { + while (true) { ViewList::iterator j = _views.begin(); while (j != _views.end()) { shared_ptr test = dynamic_pointer_cast (*j); @@ -650,7 +674,7 @@ Timeline::set_position_from_event (wxMouseEvent& ev) if (new_position < 0) { new_position = 0; } - + _down_view->content()->set_position (new_position); shared_ptr film = _film.lock (); diff --git a/src/wx/timeline.h b/src/wx/timeline.h index 7b4d75d09..fafb09c0e 100644 --- a/src/wx/timeline.h +++ b/src/wx/timeline.h @@ -79,6 +79,7 @@ private: void right_down (wxMouseEvent &); void mouse_moved (wxMouseEvent &); void playlist_changed (); + void playlist_content_changed (int); void resized (); void assign_tracks (); void set_position_from_event (wxMouseEvent &); @@ -105,5 +106,6 @@ private: ContentMenu _menu; bool _snap; - boost::signals2::scoped_connection _playlist_connection; + boost::signals2::scoped_connection _playlist_changed_connection; + boost::signals2::scoped_connection _playlist_content_changed_connection; }; -- cgit v1.2.3