Remove user-configurable colour conversion presets.
[dcpomatic.git] / src / wx / content_colour_conversion_dialog.cc
index 8fca090adac4953db6123ff28a17a2daed279741..b382c342937f5d01ab77c43a527ab259958fcadd 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2013 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2013-2015 Carl Hetherington <cth@carlh.net>
 
     This program is free software; you can redistribute it and/or modify
     it under the terms of the GNU General Public License as published by
 
 */
 
-#include <wx/statline.h>
 #include "lib/colour_conversion.h"
 #include "lib/config.h"
+#include "lib/util.h"
 #include "wx_util.h"
 #include "content_colour_conversion_dialog.h"
 #include "colour_conversion_editor.h"
+#include <wx/statline.h>
+#include <boost/foreach.hpp>
 
 using std::string;
 using std::vector;
@@ -44,7 +46,7 @@ ContentColourConversionDialog::ContentColourConversionDialog (wxWindow* parent)
        table->Add (_preset_choice);
 
        overall_sizer->Add (table, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER);
-       overall_sizer->Add (new wxStaticLine (this, wxID_ANY));
+       overall_sizer->Add (new wxStaticLine (this, wxID_ANY), 0, wxEXPAND);
        overall_sizer->Add (_editor);
 
        wxSizer* buttons = CreateSeparatedButtonSizer (wxOK);
@@ -58,11 +60,10 @@ ContentColourConversionDialog::ContentColourConversionDialog (wxWindow* parent)
        _preset_check->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&ContentColourConversionDialog::preset_check_clicked, this));
        _preset_choice->Bind (wxEVT_COMMAND_CHOICE_SELECTED, boost::bind (&ContentColourConversionDialog::preset_choice_changed, this));
 
-       _editor->Changed.connect (boost::bind (&ContentColourConversionDialog::check_for_preset, this));
+       _editor_connection = _editor->Changed.connect (boost::bind (&ContentColourConversionDialog::check_for_preset, this));
 
-       vector<PresetColourConversion> presets = Config::instance()->colour_conversions ();
-       for (vector<PresetColourConversion>::const_iterator i = presets.begin(); i != presets.end(); ++i) {
-               _preset_choice->Append (std_to_wx (i->name));
+       BOOST_FOREACH (PresetColourConversion const &i, PresetColourConversion::all ()) {
+               _preset_choice->Append (std_to_wx (i.name));
        }
 }
 
@@ -78,7 +79,7 @@ ContentColourConversionDialog::set (ColourConversion c)
        _setting = true;
        _editor->set (c);
        _setting = false;
-       
+
        check_for_preset ();
 }
 
@@ -93,7 +94,11 @@ ContentColourConversionDialog::check_for_preset ()
 
        _preset_check->SetValue (preset);
        _preset_choice->Enable (preset);
-       _preset_choice->SetSelection (preset.get_value_or (-1));
+       if (preset) {
+               _preset_choice->SetSelection (preset.get ());
+       } else {
+               _preset_choice->SetSelection (-1);
+       }
 }
 
 void
@@ -111,8 +116,8 @@ ContentColourConversionDialog::preset_check_clicked ()
 void
 ContentColourConversionDialog::preset_choice_changed ()
 {
-       vector<PresetColourConversion> presets = Config::instance()->colour_conversions ();
-       int const s = _preset_choice->GetSelection();
+       vector<PresetColourConversion> presets = PresetColourConversion::all ();
+       int const s = _preset_choice->GetCurrentSelection();
        if (s != -1) {
                set (presets[s].conversion);
        }