No-op; fix GPL address and use the explicit-program-name version.
[dcpomatic.git] / src / wx / video_waveform_dialog.cc
1 /*
2     Copyright (C) 2015 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 "video_waveform_dialog.h"
22 #include "video_waveform_plot.h"
23 #include "film_viewer.h"
24 #include "wx_util.h"
25 #include <boost/bind.hpp>
26 #include <iostream>
27
28 using std::cout;
29 using boost::bind;
30
31 VideoWaveformDialog::VideoWaveformDialog (wxWindow* parent, FilmViewer* viewer)
32         : wxDialog (parent, wxID_ANY, _("Video Waveform"), wxDefaultPosition, wxSize (640, 512), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE)
33         , _viewer (viewer)
34 {
35         wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
36
37         wxBoxSizer* controls = new wxBoxSizer (wxHORIZONTAL);
38
39         _component = new wxChoice (this, wxID_ANY);
40         _component->Append (wxT ("X"));
41         _component->Append (wxT ("Y"));
42         _component->Append (wxT ("Z"));
43         add_label_to_sizer (controls, this, _("Component"), true);
44         controls->Add (_component, 1, wxALL, DCPOMATIC_SIZER_X_GAP);
45
46         add_label_to_sizer (controls, this, _("Contrast"), true);
47         _contrast = new wxSlider (this, wxID_ANY, 0, 0, 256);
48         controls->Add (_contrast, 1, wxALL, DCPOMATIC_SIZER_X_GAP);
49
50         overall_sizer->Add (controls, 0, wxALL | wxEXPAND, DCPOMATIC_SIZER_X_GAP);
51
52         _plot = new VideoWaveformPlot (this, _viewer);
53         overall_sizer->Add (_plot, 1, wxALL | wxEXPAND, 12);
54
55 #ifdef DCPOMATIC_LINUX
56         wxSizer* buttons = CreateSeparatedButtonSizer (wxCLOSE);
57         if (buttons) {
58                 overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
59         }
60 #endif
61
62         SetSizer (overall_sizer);
63         overall_sizer->Layout ();
64         overall_sizer->SetSizeHints (this);
65
66         Bind (wxEVT_SHOW, bind (&VideoWaveformDialog::shown, this, _1));
67         _component->Bind  (wxEVT_COMMAND_CHOICE_SELECTED, bind (&VideoWaveformDialog::component_changed, this));
68         _contrast->Bind (wxEVT_SCROLL_THUMBTRACK, bind (&VideoWaveformDialog::contrast_changed, this));
69
70         _component->SetSelection (0);
71         _contrast->SetValue (32);
72
73         component_changed ();
74         contrast_changed ();
75 }
76
77 void
78 VideoWaveformDialog::shown (wxShowEvent& ev)
79 {
80         _plot->set_enabled (ev.IsShown ());
81         if (ev.IsShown ()) {
82                 _viewer->refresh ();
83         }
84 }
85
86 void
87 VideoWaveformDialog::component_changed ()
88 {
89         _plot->set_component (_component->GetCurrentSelection ());
90 }
91
92 void
93 VideoWaveformDialog::contrast_changed ()
94 {
95         _plot->set_contrast (_contrast->GetValue ());
96 }