Include trimming.
[dcpomatic.git] / src / wx / colour_conversion_editor.cc
index 92dd417a534d51a1c61999bc429d78e41ea5b35f..aab05d71bd3836dd4b7be9b73bfacc549a4fe889 100644 (file)
 #include <dcp/modified_gamma_transfer_function.h>
 #include <wx/spinctrl.h>
 #include <wx/gbsizer.h>
-#include <boost/lexical_cast.hpp>
 #include <iostream>
 
 using std::string;
 using std::cout;
 using boost::shared_ptr;
 using boost::dynamic_pointer_cast;
-using boost::lexical_cast;
 
-ColourConversionEditor::ColourConversionEditor (wxWindow* parent)
+ColourConversionEditor::ColourConversionEditor (wxWindow* parent, bool yuv)
        : wxPanel (parent, wxID_ANY)
+       , _ignore_chromaticity_changed (false)
 {
        wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
        SetSizer (overall_sizer);
@@ -92,15 +91,21 @@ ColourConversionEditor::ColourConversionEditor (wxWindow* parent)
 
        /* YUV to RGB conversion */
 
-       subhead (table, this, _("YUV to RGB conversion"), r);
+       wxStaticText* yuv_heading = subhead (table, this, _("YUV to RGB conversion"), r);
 
-       add_label_to_sizer (table, this, _("YUV to RGB matrix"), true, wxGBPosition (r, 0));
+       wxStaticText* yuv_label = add_label_to_sizer (table, this, _("YUV to RGB matrix"), true, wxGBPosition (r, 0));
        _yuv_to_rgb = new wxChoice (this, wxID_ANY);
        _yuv_to_rgb->Append (_("Rec. 601"));
        _yuv_to_rgb->Append (_("Rec. 709"));
        table->Add (_yuv_to_rgb, wxGBPosition (r, 1));
        ++r;
 
+       if (!yuv) {
+               yuv_heading->Enable (false);
+               yuv_label->Enable (false);
+               _yuv_to_rgb->Enable (false);
+       }
+
        /* RGB to XYZ conversion */
 
        subhead (table, this, _("RGB to XYZ conversion"), r);
@@ -207,13 +212,16 @@ ColourConversionEditor::ColourConversionEditor (wxWindow* parent)
        _yuv_to_rgb->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&ColourConversionEditor::changed, this));
 }
 
-void
+wxStaticText *
 ColourConversionEditor::subhead (wxGridBagSizer* sizer, wxWindow* parent, wxString text, int& row) const
 {
-       wxStaticText* m = new wxStaticText (parent, wxID_ANY, wxT (""));
-       m->SetLabelMarkup ("<b>" + text + "</b>");
+       wxStaticText* m = new wxStaticText (parent, wxID_ANY, text);
+       wxFont font (*wxNORMAL_FONT);
+       font.SetWeight (wxFONTWEIGHT_BOLD);
+       m->SetFont (font);
        sizer->Add (m, wxGBPosition (row, 0), wxGBSpan (1, 3), wxALIGN_CENTER_VERTICAL | wxTOP, 12);
        ++row;
+       return m;
 }
 
 void
@@ -236,6 +244,8 @@ ColourConversionEditor::set (ColourConversion conversion)
 
        _yuv_to_rgb->SetSelection (conversion.yuv_to_rgb ());
 
+       _ignore_chromaticity_changed = true;
+
        SafeStringStream s;
        s.setf (std::ios::fixed, std::ios::floatfield);
        s.precision (6);
@@ -271,6 +281,8 @@ ColourConversionEditor::set (ColourConversion conversion)
        s << conversion.white().y;
        _white_y->SetValue (std_to_wx (s.str ()));
 
+       _ignore_chromaticity_changed = false;
+
        if (conversion.adjusted_white ()) {
                _adjust_white->SetValue (true);
                s.str ("");
@@ -285,6 +297,7 @@ ColourConversionEditor::set (ColourConversion conversion)
 
        update_rgb_to_xyz ();
        update_bradford ();
+       changed ();
 }
 
 ColourConversion
@@ -356,6 +369,10 @@ ColourConversionEditor::changed ()
 void
 ColourConversionEditor::chromaticity_changed ()
 {
+       if (_ignore_chromaticity_changed) {
+               return;
+       }
+
        update_rgb_to_xyz ();
        changed ();
 }