Add button to restore image subtitle colours.
authorCarl Hetherington <cth@carlh.net>
Sun, 20 Nov 2016 00:19:31 +0000 (00:19 +0000)
committerCarl Hetherington <cth@carlh.net>
Sun, 20 Nov 2016 00:19:31 +0000 (00:19 +0000)
src/wx/image_subtitle_colour_dialog.cc
src/wx/image_subtitle_colour_dialog.h
src/wx/rgba_colour_picker.cc
src/wx/rgba_colour_picker.h

index 59c8bc50cc136608b9256261b05753fdd6f10bd6..0d102f23939d86901514f4a22c8dc214b9717be5 100644 (file)
@@ -27,6 +27,7 @@
 using std::map;
 using std::cout;
 using boost::shared_ptr;
+using boost::bind;
 
 ImageSubtitleColourDialog::ImageSubtitleColourDialog (wxWindow* parent, shared_ptr<FFmpegContent> content, shared_ptr<FFmpegSubtitleStream> 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<RGBA, RGBAColourPicker*>::const_iterator i = _pickers.begin(); i != _pickers.end(); ++i) {
+               i->second->set (i->first);
+       }
+}
index f04b40b52eefcf2958d9eb52b233eca735f757b3..133c3b22bbf05af76e65c468fd18eb9b72fa3c0a 100644 (file)
@@ -34,6 +34,8 @@ public:
        void apply ();
 
 private:
+       void restore ();
+
        boost::shared_ptr<FFmpegContent> _content;
        boost::shared_ptr<FFmpegSubtitleStream> _stream;
        std::map<RGBA, RGBAColourPicker*> _pickers;
index 041c78de996ff1cb6ff136f51e65e2788142f5dc..038bf97e4e09d6d898f608b39bb2f734d7d7d738 100644 (file)
@@ -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);
+}
index 8e1fab2cd5cdb3c99bb1ba41f2a88598f2a90f2b..c7972d4b3ec157f9d8427f32a7027b2ec10b8cab 100644 (file)
@@ -30,6 +30,7 @@ public:
        RGBAColourPicker (wxWindow* parent, RGBA colour);
 
        RGBA colour () const;
+       void set (RGBA colour);
 
 private:
        wxColourPickerCtrl* _picker;