Make KDM output options checkboxes rather than radios (part of #848).
[dcpomatic.git] / src / wx / text_subtitle_appearance_dialog.cc
1 /*
2     Copyright (C) 2015-2016 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
6     DCP-o-matic is free software; you can redistribute it and/or modify
7     it under the terms of the GNU General Public License as published by
8     the Free Software Foundation; either version 2 of the License, or
9     (at your option) any later version.
10
11     DCP-o-matic is distributed in the hope that it will be useful,
12     but WITHOUT ANY WARRANTY; without even the implied warranty of
13     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14     GNU General Public License for more details.
15
16     You should have received a copy of the GNU General Public License
17     along with DCP-o-matic.  If not, see <http://www.gnu.org/licenses/>.
18
19 */
20
21 #include "text_subtitle_appearance_dialog.h"
22 #include "lib/text_subtitle_content.h"
23 #include "lib/subtitle_content.h"
24 #include <wx/wx.h>
25 #include <wx/clrpicker.h>
26
27 using boost::shared_ptr;
28
29 TextSubtitleAppearanceDialog::TextSubtitleAppearanceDialog (wxWindow* parent, shared_ptr<Content> content)
30         : TableDialog (parent, _("Subtitle appearance"), 2, 1, true)
31         , _content (content)
32 {
33         add (_("Colour"), true);
34         _colour = new wxColourPickerCtrl (this, wxID_ANY);
35         add (_colour);
36
37         wxRadioButton* no_effect = new wxRadioButton (this, wxID_ANY, _("No effect"), wxDefaultPosition, wxDefaultSize, wxRB_GROUP);
38         add (no_effect);
39         add_spacer ();
40
41         _outline = new wxRadioButton (this, wxID_ANY, _("Outline"));
42         add (_outline);
43         add_spacer ();
44
45         _shadow = new wxRadioButton (this, wxID_ANY, _("Shadow"));
46         add (_shadow);
47         add_spacer ();
48
49         add (_("Outline / shadow colour"), true);
50         _effect_colour = new wxColourPickerCtrl (this, wxID_ANY);
51         add (_effect_colour);
52
53         add (_("Fade in time"), true);
54         _fade_in = new Timecode<ContentTime> (this);
55         add (_fade_in);
56
57         add (_("Fade out time"), true);
58         _fade_out = new Timecode<ContentTime> (this);
59         add (_fade_out);
60
61         layout ();
62
63         _colour->SetColour (wxColour (_content->subtitle->colour().r, _content->subtitle->colour().g, _content->subtitle->colour().b));
64         _outline->SetValue (_content->subtitle->outline ());
65         _shadow->SetValue (_content->subtitle->shadow ());
66         _effect_colour->SetColour (
67                 wxColour (_content->subtitle->effect_colour().r, _content->subtitle->effect_colour().g, _content->subtitle->effect_colour().b)
68                 );
69         _fade_in->set (_content->subtitle->fade_in(), _content->active_video_frame_rate ());
70         _fade_out->set (_content->subtitle->fade_out(), _content->active_video_frame_rate ());
71 }
72
73 void
74 TextSubtitleAppearanceDialog::apply ()
75 {
76         wxColour const c = _colour->GetColour ();
77         _content->subtitle->set_colour (dcp::Colour (c.Red(), c.Green(), c.Blue()));
78         _content->subtitle->set_outline (_outline->GetValue ());
79         _content->subtitle->set_shadow (_shadow->GetValue ());
80         wxColour const ec = _effect_colour->GetColour ();
81         _content->subtitle->set_effect_colour (dcp::Colour (ec.Red(), ec.Green(), ec.Blue()));
82         _content->subtitle->set_fade_in (_fade_in->get (_content->active_video_frame_rate ()));
83         _content->subtitle->set_fade_out (_fade_out->get (_content->active_video_frame_rate ()));
84 }