Try to fix completely broken i18n.
[dcpomatic.git] / src / wx / timeline.cc
index 6ed91e098e17b05b5961fb47b5056191806e526a..b0197ad3dd12a19abb2b357b517197b5b69d9c05 100644 (file)
@@ -93,7 +93,12 @@ void
 Timeline::playlist_changed ()
 {
        ensure_ui_thread ();
-       
+       recreate_views ();
+}
+
+void
+Timeline::recreate_views ()
+{
        shared_ptr<const Film> fl = _film.lock ();
        if (!fl) {
                return;
@@ -108,7 +113,9 @@ Timeline::playlist_changed ()
                if (dynamic_pointer_cast<VideoContent> (*i)) {
                        _views.push_back (shared_ptr<TimelineView> (new TimelineVideoContentView (*this, *i)));
                }
-               if (dynamic_pointer_cast<AudioContent> (*i)) {
+
+               shared_ptr<AudioContent> ac = dynamic_pointer_cast<AudioContent> (*i);
+               if (ac && !ac->audio_mapping().mapped_output_channels().empty ()) {
                        _views.push_back (shared_ptr<TimelineView> (new TimelineAudioContentView (*this, *i)));
                }
 
@@ -130,8 +137,13 @@ Timeline::playlist_content_changed (int property)
 
        if (property == ContentProperty::POSITION) {
                assign_tracks ();
-               setup_pixels_per_second ();
+               if (!_left_down) {
+                       /* Only do this if we are not dragging, as it's confusing otherwise */
+                       setup_pixels_per_second ();
+               }
                Refresh ();
+       } else if (property == AudioContentProperty::AUDIO_STREAMS) {
+               recreate_views ();
        }
 }
 
@@ -277,6 +289,12 @@ Timeline::left_up (wxMouseEvent& ev)
        }
 
        set_position_from_event (ev);
+
+       /* We don't do this during drag, and set_position_from_event above
+          might not have changed the position, so do it now.
+       */
+       setup_pixels_per_second ();
+       Refresh ();
 }
 
 void
@@ -303,7 +321,7 @@ Timeline::right_down (wxMouseEvent& ev)
                cv->set_selected (true);
        }
 
-       _menu.popup (_film, selected_content (), ev.GetPosition ());
+       _menu.popup (_film, selected_content (), selected_views (), ev.GetPosition ());
 }
 
 void
@@ -345,7 +363,7 @@ Timeline::set_position_from_event (wxMouseEvent& ev)
        
        if (_snap) {
 
-               DCPTime const new_end = new_position + _down_view->content()->length_after_trim ();
+               DCPTime const new_end = new_position + _down_view->content()->length_after_trim () - DCPTime (1);
                /* Signed `distance' to nearest thing (i.e. negative is left on the timeline,
                   positive is right).
                */
@@ -354,14 +372,14 @@ Timeline::set_position_from_event (wxMouseEvent& ev)
                /* Find the nearest content edge; this is inefficient */
                for (TimelineViewList::iterator i = _views.begin(); i != _views.end(); ++i) {
                        shared_ptr<TimelineContentView> cv = dynamic_pointer_cast<TimelineContentView> (*i);
-                       if (!cv || cv == _down_view) {
+                       if (!cv || cv == _down_view || cv->content() == _down_view->content()) {
                                continue;
                        }
 
                        maybe_snap (cv->content()->position(), new_position, nearest_distance);
-                       maybe_snap (cv->content()->position(), new_end, nearest_distance);
-                       maybe_snap (cv->content()->end(), new_position, nearest_distance);
-                       maybe_snap (cv->content()->end(), new_end, nearest_distance);
+                       maybe_snap (cv->content()->position(), new_end + DCPTime (1), nearest_distance);
+                       maybe_snap (cv->content()->end() + DCPTime (1), new_position, nearest_distance);
+                       maybe_snap (cv->content()->end() + DCPTime (1), new_end, nearest_distance);
                }
                
                if (nearest_distance) {