diff options
| author | Carl Hetherington <cth@carlh.net> | 2016-02-26 21:06:27 +0000 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2016-02-26 21:06:27 +0000 |
| commit | cef07676fb15c9f1c3c3073d22f06ffe95d9c2ce (patch) | |
| tree | ad67d2991961429c52dda4d7adc1ded37ce71c0a /src/wx | |
| parent | 2b54b284e2c2ffcaa082b1c201abecf25edc21c9 (diff) | |
Allow changes to colours of FFmpeg subtitles (#795).
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/image_subtitle_colour_dialog.cc | 63 | ||||
| -rw-r--r-- | src/wx/image_subtitle_colour_dialog.h | 39 | ||||
| -rw-r--r-- | src/wx/rgba_colour_picker.cc | 45 | ||||
| -rw-r--r-- | src/wx/rgba_colour_picker.h | 36 | ||||
| -rw-r--r-- | src/wx/subtitle_panel.cc | 23 | ||||
| -rw-r--r-- | src/wx/subtitle_panel.h | 1 | ||||
| -rw-r--r-- | src/wx/table_dialog.h | 4 | ||||
| -rw-r--r-- | src/wx/wscript | 2 |
8 files changed, 203 insertions, 10 deletions
diff --git a/src/wx/image_subtitle_colour_dialog.cc b/src/wx/image_subtitle_colour_dialog.cc new file mode 100644 index 000000000..58f5de286 --- /dev/null +++ b/src/wx/image_subtitle_colour_dialog.cc @@ -0,0 +1,63 @@ +/* + Copyright (C) 2016 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "image_subtitle_colour_dialog.h" +#include "rgba_colour_picker.h" +#include "lib/ffmpeg_subtitle_stream.h" +#include "lib/ffmpeg_content.h" + +using std::map; +using std::cout; +using boost::shared_ptr; + +ImageSubtitleColourDialog::ImageSubtitleColourDialog (wxWindow* parent, shared_ptr<FFmpegContent> content, shared_ptr<FFmpegSubtitleStream> stream) + : TableDialog (parent, _("Subtitle colours"), 2, 1, true) + , _content (content) + , _stream (stream) +{ + map<RGBA, RGBA> colours = _stream->colours (); + + wxStaticText* t = new wxStaticText (this, wxID_ANY, ""); + t->SetLabelMarkup (_("<b>Original colour</b>")); + add (t); + t = new wxStaticText (this, wxID_ANY, "", wxDefaultPosition, wxDefaultSize, wxALIGN_CENTRE_HORIZONTAL); + t->SetLabelMarkup (_("<b>New colour</b>")); + add (t, 1, wxALIGN_CENTER); + + for (map<RGBA, RGBA>::const_iterator i = colours.begin(); i != colours.end(); ++i) { + wxPanel* from = new wxPanel (this, wxID_ANY); + from->SetBackgroundColour (wxColour (i->first.r, i->first.g, i->first.b, i->first.a)); + add (from); + RGBAColourPicker* to = new RGBAColourPicker (this, i->second); + add (to); + _pickers[i->first] = to; + } + + layout (); +} + +void +ImageSubtitleColourDialog::apply () +{ + for (map<RGBA, RGBAColourPicker*>::const_iterator i = _pickers.begin(); i != _pickers.end(); ++i) { + _stream->set_colour (i->first, i->second->colour ()); + } + + _content->signal_subtitle_stream_changed (); +} diff --git a/src/wx/image_subtitle_colour_dialog.h b/src/wx/image_subtitle_colour_dialog.h new file mode 100644 index 000000000..8103bf98b --- /dev/null +++ b/src/wx/image_subtitle_colour_dialog.h @@ -0,0 +1,39 @@ +/* + Copyright (C) 2016 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "table_dialog.h" +#include "lib/rgba.h" +#include <map> + +class RGBAColourPicker; +class FFmpegContent; +class FFmpegSubtitleStream; + +class ImageSubtitleColourDialog : public TableDialog +{ +public: + ImageSubtitleColourDialog (wxWindow* parent, boost::shared_ptr<FFmpegContent> content, boost::shared_ptr<FFmpegSubtitleStream> stream); + + void apply (); + +private: + boost::shared_ptr<FFmpegContent> _content; + boost::shared_ptr<FFmpegSubtitleStream> _stream; + std::map<RGBA, RGBAColourPicker*> _pickers; +}; diff --git a/src/wx/rgba_colour_picker.cc b/src/wx/rgba_colour_picker.cc new file mode 100644 index 000000000..7e8c84b11 --- /dev/null +++ b/src/wx/rgba_colour_picker.cc @@ -0,0 +1,45 @@ +/* + Copyright (C) 2016 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "rgba_colour_picker.h" +#include "wx_util.h" +#include <wx/clrpicker.h> + +RGBAColourPicker::RGBAColourPicker (wxWindow* parent, RGBA colour) + : wxPanel (parent, wxID_ANY) +{ + wxBoxSizer* sizer = new wxBoxSizer (wxHORIZONTAL); + + _picker = new wxColourPickerCtrl (this, wxID_ANY); + _picker->SetColour (wxColour (colour.r, colour.g, colour.b)); + sizer->Add (_picker, 1, wxEXPAND | wxALL, DCPOMATIC_SIZER_X_GAP); + sizer->Add (new wxStaticText (this, wxID_ANY, _("Alpha 0")), 0, wxALIGN_CENTRE_VERTICAL); + _alpha = new wxSlider (this, wxID_ANY, colour.a, 0, 255); + sizer->Add (_alpha, 1, wxEXPAND | wxALL, DCPOMATIC_SIZER_X_GAP); + sizer->Add (new wxStaticText (this, wxID_ANY, _("255")), 0, wxALIGN_CENTRE_VERTICAL); + + SetSizer (sizer); +} + +RGBA +RGBAColourPicker::colour () const +{ + wxColour const c = _picker->GetColour (); + return RGBA (c.Red(), c.Green(), c.Blue(), _alpha->GetValue()); +} diff --git a/src/wx/rgba_colour_picker.h b/src/wx/rgba_colour_picker.h new file mode 100644 index 000000000..e4e58760f --- /dev/null +++ b/src/wx/rgba_colour_picker.h @@ -0,0 +1,36 @@ +/* + Copyright (C) 2016 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 + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#include "lib/rgba.h" +#include <wx/wx.h> + +class wxColourPickerCtrl; +class wxSlider; + +class RGBAColourPicker : public wxPanel +{ +public: + RGBAColourPicker (wxWindow* parent, RGBA colour); + + RGBA colour () const; + +private: + wxColourPickerCtrl* _picker; + wxSlider* _alpha; +}; diff --git a/src/wx/subtitle_panel.cc b/src/wx/subtitle_panel.cc index f02ad9bb7..9422bb894 100644 --- a/src/wx/subtitle_panel.cc +++ b/src/wx/subtitle_panel.cc @@ -24,6 +24,7 @@ #include "content_panel.h" #include "fonts_dialog.h" #include "text_subtitle_appearance_dialog.h" +#include "image_subtitle_colour_dialog.h" #include "lib/ffmpeg_content.h" #include "lib/text_subtitle_content.h" #include "lib/ffmpeg_subtitle_stream.h" @@ -285,7 +286,7 @@ SubtitlePanel::setup_sensitivity () _stream->Enable (!reference && ffmpeg_subs == 1); _subtitle_view_button->Enable (!reference && (text_subs == 1 || dcp_subs == 1)); _fonts_dialog_button->Enable (!reference && (text_subs == 1 || dcp_subs == 1)); - _appearance_dialog_button->Enable (!reference && text_subs == 1); + _appearance_dialog_button->Enable (!reference && (ffmpeg_subs == 1 || text_subs == 1)); } void @@ -433,11 +434,19 @@ SubtitlePanel::appearance_dialog_clicked () DCPOMATIC_ASSERT (c.size() == 1); shared_ptr<TextSubtitleContent> sr = dynamic_pointer_cast<TextSubtitleContent> (c.front ()); - DCPOMATIC_ASSERT (sr); - - TextSubtitleAppearanceDialog* d = new TextSubtitleAppearanceDialog (this, sr); - if (d->ShowModal () == wxID_OK) { - d->apply (); + if (sr) { + TextSubtitleAppearanceDialog* d = new TextSubtitleAppearanceDialog (this, sr); + if (d->ShowModal () == wxID_OK) { + d->apply (); + } + d->Destroy (); + } else { + shared_ptr<FFmpegContent> fc = dynamic_pointer_cast<FFmpegContent> (c.front ()); + DCPOMATIC_ASSERT (fc); + ImageSubtitleColourDialog* d = new ImageSubtitleColourDialog (this, fc, fc->subtitle_stream ()); + if (d->ShowModal() == wxID_OK) { + d->apply (); + } + d->Destroy (); } - d->Destroy (); } diff --git a/src/wx/subtitle_panel.h b/src/wx/subtitle_panel.h index e3fd7cd75..3dbae9909 100644 --- a/src/wx/subtitle_panel.h +++ b/src/wx/subtitle_panel.h @@ -23,7 +23,6 @@ class wxCheckBox; class wxSpinCtrl; class SubtitleView; class FontsDialog; -class SubtitleAppearanceDialog; class SubtitlePanel : public ContentSubPanel { diff --git a/src/wx/table_dialog.h b/src/wx/table_dialog.h index 555721031..9e1d09d57 100644 --- a/src/wx/table_dialog.h +++ b/src/wx/table_dialog.h @@ -29,8 +29,8 @@ public: protected: template<class T> - T* add (T* w) { - _table->Add (w, 1, wxEXPAND); + T* add (T* w, int proportion = 1, int flag = wxEXPAND) { + _table->Add (w, proportion, flag); return w; } diff --git a/src/wx/wscript b/src/wx/wscript index c5c4d39ce..d01e8eda8 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -41,6 +41,7 @@ sources = """ dcp_panel.cc email_dialog.cc image_sequence_dialog.cc + image_subtitle_colour_dialog.cc isdcf_metadata_dialog.cc dir_picker_ctrl.cc dolby_doremi_certificate_panel.cc @@ -68,6 +69,7 @@ sources = """ preset_colour_conversion_dialog.cc repeat_dialog.cc report_problem_dialog.cc + rgba_colour_picker.cc screen_dialog.cc screens_panel.cc self_dkdm_dialog.cc |
