From: Carl Hetherington Date: Sun, 20 Nov 2016 00:19:31 +0000 (+0000) Subject: Add button to restore image subtitle colours. X-Git-Tag: v2.10.3-test~27 X-Git-Url: https://git.carlh.net/gitweb/?a=commitdiff_plain;h=492bc5579d950e08847750ee1fba1187ba00d3c3;p=dcpomatic.git Add button to restore image subtitle colours. --- diff --git a/src/wx/image_subtitle_colour_dialog.cc b/src/wx/image_subtitle_colour_dialog.cc index 59c8bc50c..0d102f239 100644 --- a/src/wx/image_subtitle_colour_dialog.cc +++ b/src/wx/image_subtitle_colour_dialog.cc @@ -27,6 +27,7 @@ using std::map; using std::cout; using boost::shared_ptr; +using boost::bind; ImageSubtitleColourDialog::ImageSubtitleColourDialog (wxWindow* parent, shared_ptr content, shared_ptr stream) : wxDialog (parent, wxID_ANY, _("Subtitle colours")) @@ -66,6 +67,10 @@ ImageSubtitleColourDialog::ImageSubtitleColourDialog (wxWindow* parent, shared_p overall_sizer->Add (colours_panel, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); + wxButton* restore = new wxButton (this, wxID_ANY, _("Restore to original colours")); + restore->Bind (wxEVT_BUTTON, bind (&ImageSubtitleColourDialog::restore, this)); + overall_sizer->Add (restore, 0, wxALL, DCPOMATIC_SIZER_X_GAP); + wxSizer* buttons = CreateSeparatedButtonSizer (wxOK | wxCANCEL); if (buttons) { overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); @@ -81,3 +86,11 @@ ImageSubtitleColourDialog::apply () _content->signal_subtitle_stream_changed (); } + +void +ImageSubtitleColourDialog::restore () +{ + for (map::const_iterator i = _pickers.begin(); i != _pickers.end(); ++i) { + i->second->set (i->first); + } +} diff --git a/src/wx/image_subtitle_colour_dialog.h b/src/wx/image_subtitle_colour_dialog.h index f04b40b52..133c3b22b 100644 --- a/src/wx/image_subtitle_colour_dialog.h +++ b/src/wx/image_subtitle_colour_dialog.h @@ -34,6 +34,8 @@ public: void apply (); private: + void restore (); + boost::shared_ptr _content; boost::shared_ptr _stream; std::map _pickers; diff --git a/src/wx/rgba_colour_picker.cc b/src/wx/rgba_colour_picker.cc index 041c78de9..038bf97e4 100644 --- a/src/wx/rgba_colour_picker.cc +++ b/src/wx/rgba_colour_picker.cc @@ -44,3 +44,10 @@ RGBAColourPicker::colour () const wxColour const c = _picker->GetColour (); return RGBA (c.Red(), c.Green(), c.Blue(), _alpha->GetValue()); } + +void +RGBAColourPicker::set (RGBA colour) +{ + _picker->SetColour (wxColour (colour.r, colour.g, colour.b)); + _alpha->SetValue (colour.a); +} diff --git a/src/wx/rgba_colour_picker.h b/src/wx/rgba_colour_picker.h index 8e1fab2cd..c7972d4b3 100644 --- a/src/wx/rgba_colour_picker.h +++ b/src/wx/rgba_colour_picker.h @@ -30,6 +30,7 @@ public: RGBAColourPicker (wxWindow* parent, RGBA colour); RGBA colour () const; + void set (RGBA colour); private: wxColourPickerCtrl* _picker;