Add basics of colourspace conversion bypass (#266).
[dcpomatic.git] / src / wx / video_panel.cc
index b33a97591c6617e45fe3a2da2a04bd1fca0fbe24..eb0b812a5dd194c99130b206650e51bcc51bc399 100644 (file)
@@ -147,7 +147,7 @@ VideoPanel::VideoPanel (FilmEditor* e)
                wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
 
                wxClientDC dc (this);
-               wxSize size = dc.GetTextExtent (wxT ("A quite long name"));
+               wxSize size = dc.GetTextExtent (wxT ("A quite long-ish name"));
                size.SetHeight (-1);
                
                _filters = new wxStaticText (this, wxID_ANY, _("None"), wxDefaultPosition, size);
@@ -159,11 +159,13 @@ VideoPanel::VideoPanel (FilmEditor* e)
        ++r;
        
        {
-               add_label_to_grid_bag_sizer (grid, this, _("Colour conversion"), true, wxGBPosition (r, 0));
+               _enable_colour_conversion = new wxCheckBox (this, wxID_ANY, _("Colour conversion"));
+               grid->Add (_enable_colour_conversion, wxGBPosition (r, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL);
+
                wxSizer* s = new wxBoxSizer (wxHORIZONTAL);
 
                wxClientDC dc (this);
-               wxSize size = dc.GetTextExtent (wxT ("A quite long name"));
+               wxSize size = dc.GetTextExtent (wxT ("A quite long-ish name"));
                size.SetHeight (-1);
                
                _colour_conversion = new wxStaticText (this, wxID_ANY, wxT (""), wxDefaultPosition, size);
@@ -202,6 +204,7 @@ VideoPanel::VideoPanel (FilmEditor* e)
        _frame_type->wrapped()->Append (_("3D right only"));
 
        _filters_button->Bind           (wxEVT_COMMAND_BUTTON_CLICKED,   boost::bind (&VideoPanel::edit_filters_clicked, this));
+       _enable_colour_conversion->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&VideoPanel::enable_colour_conversion_clicked, this));
        _colour_conversion_button->Bind (wxEVT_COMMAND_BUTTON_CLICKED,   boost::bind (&VideoPanel::edit_colour_conversion_clicked, this));
 }
 
@@ -239,9 +242,21 @@ VideoPanel::film_content_changed (int property)
        } else if (property == VideoContentProperty::VIDEO_FRAME_RATE) {
                setup_description ();
        } else if (property == VideoContentProperty::COLOUR_CONVERSION) {
-               optional<size_t> preset = vcs ? vcs->colour_conversion().preset () : optional<size_t> ();
-               vector<PresetColourConversion> cc = Config::instance()->colour_conversions ();
-               _colour_conversion->SetLabel (preset ? std_to_wx (cc[preset.get()].name) : _("Custom"));
+               if (!vcs) {
+                       _colour_conversion->SetLabel (wxT (""));
+               } else if (vcs->colour_conversion ()) {
+                       optional<size_t> preset = vcs->colour_conversion().get().preset ();
+                       vector<PresetColourConversion> cc = Config::instance()->colour_conversions ();
+                       _colour_conversion->SetLabel (preset ? std_to_wx (cc[preset.get()].name) : _("Custom"));
+                       _enable_colour_conversion->SetValue (true);
+                       _colour_conversion->Enable (true);
+                       _colour_conversion_button->Enable (true);
+               } else {
+                       _colour_conversion->SetLabel (_("None"));
+                       _enable_colour_conversion->SetValue (false);
+                       _colour_conversion->Enable (false);
+                       _colour_conversion_button->Enable (false);
+               }
        } else if (property == FFmpegContentProperty::FILTERS) {
                if (fcs) {
                        string const p = Filter::ffmpeg_string (fcs->filters ());
@@ -351,7 +366,11 @@ VideoPanel::edit_colour_conversion_clicked ()
                return;
        }
 
-       ColourConversion conversion = vc.front()->colour_conversion ();
+       if (!vc.front()->colour_conversion ()) {
+               return;
+       }
+
+       ColourConversion conversion = vc.front()->colour_conversion().get ();
        ContentColourConversionDialog* d = new ContentColourConversionDialog (this);
        d->set (conversion);
        d->ShowModal ();
@@ -383,3 +402,18 @@ VideoPanel::content_selection_changed ()
        film_content_changed (VideoContentProperty::COLOUR_CONVERSION);
        film_content_changed (FFmpegContentProperty::FILTERS);
 }
+
+void
+VideoPanel::enable_colour_conversion_clicked ()
+{
+       VideoContentList vc = _editor->selected_video_content ();
+       if (vc.size() != 1) {
+               return;
+       }
+
+       if (_enable_colour_conversion->GetValue()) {
+               vc.front()->set_default_colour_conversion ();
+       } else {
+               vc.front()->unset_colour_conversion ();
+       }
+}