Remove GL context accessor and hence lock.
[dcpomatic.git] / src / wx / timing_panel.cc
index d47c81a15b1358781dc1c590c94c61947f76f833..739cf253dbfb35d9d287f902823006e386983a30 100644 (file)
@@ -33,6 +33,8 @@
 #include "lib/audio_content.h"
 #include "lib/string_text_file_content.h"
 #include "lib/video_content.h"
+#include "lib/dcp_content.h"
+#include "lib/ffmpeg_content.h"
 #include <dcp/locale_convert.h>
 #include <boost/foreach.hpp>
 #include <set>
@@ -46,6 +48,7 @@ using boost::weak_ptr;
 using boost::dynamic_pointer_cast;
 using boost::optional;
 using dcp::locale_convert;
+using namespace dcpomatic;
 
 TimingPanel::TimingPanel (ContentPanel* p, weak_ptr<FilmViewer> viewer)
        /* horrid hack for apparent lack of context support with wxWidgets i18n code */
@@ -169,12 +172,6 @@ TimingPanel::add_to_grid ()
        _move_to_start_of_reel->Show (full);
        _full_length_label->Show (full);
        _full_length->Show (full);
-       _trim_start_label->Show (full);
-       _trim_start->Show (full);
-       _trim_start_to_playhead->Show (full);
-       _trim_end_label->Show (full);
-       _trim_end->Show (full);
-       _trim_end_to_playhead->Show (full);
        _play_length_label->Show (full);
        _play_length->Show (full);
        _video_frame_rate_label->Show (full);
@@ -189,21 +186,23 @@ TimingPanel::add_to_grid ()
                add_label_to_sizer (_grid, _full_length_label, true, wxGBPosition(r, 0));
                _grid->Add (_full_length, wxGBPosition(r, 1));
                ++r;
+       }
 
-               add_label_to_sizer (_grid, _trim_start_label, true, wxGBPosition(r, 0));
-               _grid->Add (_trim_start, wxGBPosition(r, 1));
-               ++r;
+       add_label_to_sizer (_grid, _trim_start_label, true, wxGBPosition(r, 0));
+       _grid->Add (_trim_start, wxGBPosition(r, 1));
+       ++r;
 
-               _grid->Add (_trim_start_to_playhead, wxGBPosition(r, 1));
-               ++r;
+       _grid->Add (_trim_start_to_playhead, wxGBPosition(r, 1));
+       ++r;
 
-               add_label_to_sizer (_grid, _trim_end_label, true, wxGBPosition(r, 0));
-               _grid->Add (_trim_end, wxGBPosition(r, 1));
-               ++r;
+       add_label_to_sizer (_grid, _trim_end_label, true, wxGBPosition(r, 0));
+       _grid->Add (_trim_end, wxGBPosition(r, 1));
+       ++r;
 
-               _grid->Add (_trim_end_to_playhead, wxGBPosition(r, 1));
-               ++r;
+       _grid->Add (_trim_end_to_playhead, wxGBPosition(r, 1));
+       ++r;
 
+       if (full) {
                add_label_to_sizer (_grid, _play_length_label, true, wxGBPosition(r, 0));
                _grid->Add (_play_length, wxGBPosition(r, 1));
                ++r;
@@ -406,7 +405,6 @@ TimingPanel::trim_start_changed ()
        optional<FrameRateChange> ref_frc;
        optional<DCPTime> ref_ph;
 
-       ContentTime const trim = _trim_start->get (_parent->film()->video_frame_rate ());
 
        BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
                if (i->position() <= ph && ph < i->end(_parent->film())) {
@@ -419,6 +417,7 @@ TimingPanel::trim_start_changed ()
                        ref_ph = ph - i->position() + DCPTime (i->trim_start(), ref_frc.get());
                }
 
+               ContentTime const trim = _trim_start->get (i->video_frame_rate().get_value_or(_parent->film()->video_frame_rate()));
                i->set_trim_start (trim);
        }
 
@@ -439,8 +438,8 @@ TimingPanel::trim_end_changed ()
 
        fv->set_coalesce_player_changes (true);
 
-       ContentTime const trim = _trim_end->get (_parent->film()->video_frame_rate ());
        BOOST_FOREACH (shared_ptr<Content> i, _parent->selected ()) {
+               ContentTime const trim = _trim_end->get (i->video_frame_rate().get_value_or(_parent->film()->video_frame_rate()));
                i->set_trim_end (trim);
        }
 
@@ -449,7 +448,7 @@ TimingPanel::trim_end_changed ()
                fv->seek (_parent->film()->length() - DCPTime::from_frames(1, _parent->film()->video_frame_rate()), true);
        }
 
-       fv->set_coalesce_player_changes (true);
+       fv->set_coalesce_player_changes (false);
 }
 
 void
@@ -467,7 +466,22 @@ TimingPanel::play_length_changed ()
 void
 TimingPanel::video_frame_rate_changed ()
 {
-       _set_video_frame_rate->Enable (true);
+       bool enable = true;
+       if (_video_frame_rate->GetValue() == wxT("")) {
+               /* No frame rate has been entered; if the user clicks "set" now it would unset the video
+                  frame rate in the selected content.  This can't be allowed for some content types.
+               */
+               BOOST_FOREACH (shared_ptr<Content> i, _parent->selected()) {
+                       if (
+                               dynamic_pointer_cast<DCPContent>(i) ||
+                               dynamic_pointer_cast<FFmpegContent>(i)
+                               ) {
+                               enable = false;
+                       }
+               }
+       }
+
+       _set_video_frame_rate->Enable (enable);
 }
 
 void