From 294704d07de1fd6981362d85a26e4a83a6ef08fa Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 9 Nov 2015 00:43:48 +0000 Subject: [PATCH] Desensitize trim-up-to buttons as appropriate (#737). --- ChangeLog | 2 ++ src/wx/timing_panel.cc | 38 +++++++++++++++++++++++++++++--------- src/wx/timing_panel.h | 1 + 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 38d0ab14a..9a17f1e8d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,7 @@ 2015-11-09 Carl Hetherington + * Desensitise trim-playhead buttons as appropriate (#737). + * Keep same frame visible after trimming content start (#737). * Trim frames after the current one with "trim after current", leaving diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc index bb0547b9c..9f5aa78ea 100644 --- a/src/wx/timing_panel.cc +++ b/src/wx/timing_panel.cc @@ -147,6 +147,10 @@ TimingPanel::TimingPanel (ContentPanel* p, FilmViewer* viewer) _play_length->Changed.connect (boost::bind (&TimingPanel::play_length_changed, this)); _video_frame_rate->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&TimingPanel::video_frame_rate_changed, this)); _set_video_frame_rate->Bind (wxEVT_COMMAND_BUTTON_CLICKED, boost::bind (&TimingPanel::set_video_frame_rate, this)); + + _viewer->ImageChanged.connect (boost::bind (&TimingPanel::setup_sensitivity, this)); + + setup_sensitivity (); } void @@ -294,6 +298,7 @@ TimingPanel::film_content_changed (int property) _full_length->set_editable (have_still); _play_length->set_editable (!have_still); _set_video_frame_rate->Enable (false); + setup_sensitivity (); } void @@ -324,7 +329,6 @@ TimingPanel::trim_start_changed () } } - void TimingPanel::trim_end_changed () { @@ -372,14 +376,7 @@ TimingPanel::set_video_frame_rate () void TimingPanel::content_selection_changed () { - bool const e = !_parent->selected().empty (); - - _position->Enable (e); - _full_length->Enable (e); - _trim_start->Enable (e); - _trim_end->Enable (e); - _play_length->Enable (e); - _video_frame_rate->Enable (e); + setup_sensitivity (); film_content_changed (ContentProperty::POSITION); film_content_changed (ContentProperty::LENGTH); @@ -430,6 +427,29 @@ TimingPanel::trim_end_to_playhead_clicked () FrameRateChange const frc = _parent->film()->active_frame_rate_change (i->position ()); i->set_trim_end (ContentTime (i->position() + i->full_length() - ph - DCPTime::from_frames (1, frc.dcp), frc) - i->trim_start()); } + } +} + +void +TimingPanel::setup_sensitivity () +{ + bool const e = !_parent->selected().empty (); + + _position->Enable (e); + _full_length->Enable (e); + _trim_start->Enable (e); + _trim_end->Enable (e); + _play_length->Enable (e); + _video_frame_rate->Enable (e); + DCPTime const ph = _viewer->position (); + bool any_over_ph = false; + BOOST_FOREACH (shared_ptr i, _parent->selected ()) { + if (i->position() <= ph && ph < i->end()) { + any_over_ph = true; + } } + + _trim_start_to_playhead->Enable (any_over_ph); + _trim_end_to_playhead->Enable (any_over_ph); } diff --git a/src/wx/timing_panel.h b/src/wx/timing_panel.h index d1f5ea549..f73fbed55 100644 --- a/src/wx/timing_panel.h +++ b/src/wx/timing_panel.h @@ -43,6 +43,7 @@ private: void set_video_frame_rate (); void update_full_length (); void update_play_length (); + void setup_sensitivity (); FilmViewer* _viewer; -- 2.30.2