summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2014-03-22 13:44:30 +0000
committerCarl Hetherington <cth@carlh.net>2014-03-22 13:44:30 +0000
commita8e30a77bdd434ea2cdd81407f4ea75664fdce93 (patch)
treefb088bb1105da6822df8a8e66d4b9b23cbc0cb2c /src
parente885dd4272448b7bf0e54d9b149f54b53bede229 (diff)
Another attempt to fix glitches in the colour conversion dialog
on OS X. Reported-by: Adam Colt
Diffstat (limited to 'src')
-rw-r--r--src/wx/colour_conversion_editor.cc29
-rw-r--r--src/wx/colour_conversion_editor.h5
-rw-r--r--src/wx/content_colour_conversion_dialog.cc11
3 files changed, 38 insertions, 7 deletions
diff --git a/src/wx/colour_conversion_editor.cc b/src/wx/colour_conversion_editor.cc
index a4ec23411..6617b66d6 100644
--- a/src/wx/colour_conversion_editor.cc
+++ b/src/wx/colour_conversion_editor.cc
@@ -93,20 +93,20 @@ ColourConversionEditor::ColourConversionEditor (wxWindow* parent)
_output_gamma->SetDigits (2);
_output_gamma->SetIncrement (0.1);
- _input_gamma->Bind (wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, boost::bind (&ColourConversionEditor::changed, this));
+ _input_gamma->Bind (wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, boost::bind (&ColourConversionEditor::changed, this, _input_gamma));
_input_gamma_linearised->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&ColourConversionEditor::changed, this));
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
_matrix[i][j]->Bind (wxEVT_COMMAND_TEXT_UPDATED, boost::bind (&ColourConversionEditor::changed, this));
}
}
- _output_gamma->Bind (wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, boost::bind (&ColourConversionEditor::changed, this));
+ _output_gamma->Bind (wxEVT_COMMAND_SPINCTRLDOUBLE_UPDATED, boost::bind (&ColourConversionEditor::changed, this, _output_gamma));
}
void
ColourConversionEditor::set (ColourConversion conversion)
{
- _input_gamma->SetValue (conversion.input_gamma);
+ set_spin_ctrl (_input_gamma, conversion.input_gamma);
_input_gamma_linearised->SetValue (conversion.input_gamma_linearised);
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) {
@@ -117,7 +117,7 @@ ColourConversionEditor::set (ColourConversion conversion)
_matrix[i][j]->SetValue (std_to_wx (s.str ()));
}
}
- _output_gamma->SetValue (conversion.output_gamma);
+ set_spin_ctrl (_output_gamma, conversion.output_gamma);
}
ColourConversion
@@ -150,3 +150,24 @@ ColourConversionEditor::changed ()
Changed ();
}
+void
+ColourConversionEditor::changed (wxSpinCtrlDouble* sc)
+{
+ /* On OS X, it seems that in some cases when a wxSpinCtrlDouble loses focus
+ it emits an erroneous changed signal, which messes things up.
+ Check for that here.
+ */
+ if (fabs (_last_spin_ctrl_value[sc] - sc->GetValue()) < 1e-3) {
+ return;
+ }
+
+ Changed ();
+}
+
+void
+ColourConversionEditor::set_spin_ctrl (wxSpinCtrlDouble* control, double value)
+{
+ _last_spin_ctrl_value[control] = value;
+ control->SetValue (value);
+}
+
diff --git a/src/wx/colour_conversion_editor.h b/src/wx/colour_conversion_editor.h
index 8567cac22..ed22104e2 100644
--- a/src/wx/colour_conversion_editor.h
+++ b/src/wx/colour_conversion_editor.h
@@ -38,6 +38,11 @@ public:
private:
void changed ();
+ void changed (wxSpinCtrlDouble *);
+
+ void set_spin_ctrl (wxSpinCtrlDouble *, double);
+
+ std::map<wxSpinCtrlDouble*, double> _last_spin_ctrl_value;
wxSpinCtrlDouble* _input_gamma;
wxCheckBox* _input_gamma_linearised;
diff --git a/src/wx/content_colour_conversion_dialog.cc b/src/wx/content_colour_conversion_dialog.cc
index d8e768bcd..3fa8e120a 100644
--- a/src/wx/content_colour_conversion_dialog.cc
+++ b/src/wx/content_colour_conversion_dialog.cc
@@ -20,6 +20,7 @@
#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"
@@ -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
@@ -112,7 +117,7 @@ void
ContentColourConversionDialog::preset_choice_changed ()
{
vector<PresetColourConversion> presets = Config::instance()->colour_conversions ();
- int const s = _preset_choice->GetSelection();
+ int const s = _preset_choice->GetCurrentSelection();
if (s != -1) {
set (presets[s].conversion);
}