Lots of #include <iostream>s for Arch.
[dcpomatic.git] / src / wx / video_waveform_dialog.cc
1 /*
2     Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
3
4     This program is free software; you can redistribute it and/or modify
5     it under the terms of the GNU General Public License as published by
6     the Free Software Foundation; either version 2 of the License, or
7     (at your option) any later version.
8
9     This program is distributed in the hope that it will be useful,
10     but WITHOUT ANY WARRANTY; without even the implied warranty of
11     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12     GNU General Public License for more details.
13
14     You should have received a copy of the GNU General Public License
15     along with this program; if not, write to the Free Software
16     Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
17
18 */
19
20 #include "video_waveform_dialog.h"
21 #include "video_waveform_plot.h"
22 #include "film_viewer.h"
23 #include "wx_util.h"
24 #include <boost/bind.hpp>
25 #include <iostream>
26
27 using std::cout;
28 using boost::bind;
29
30 VideoWaveformDialog::VideoWaveformDialog (wxWindow* parent, FilmViewer* viewer)
31         : wxDialog (parent, wxID_ANY, _("Video Waveform"), wxDefaultPosition, wxSize (640, 512), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE)
32         , _viewer (viewer)
33 {
34         wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
35
36         wxBoxSizer* controls = new wxBoxSizer (wxHORIZONTAL);
37
38         _component = new wxChoice (this, wxID_ANY);
39         _component->Append (wxT ("X"));
40         _component->Append (wxT ("Y"));
41         _component->Append (wxT ("Z"));
42         add_label_to_sizer (controls, this, _("Component"), true);
43         controls->Add (_component, 1, wxALL, DCPOMATIC_SIZER_X_GAP);
44
45         add_label_to_sizer (controls, this, _("Contrast"), true);
46         _contrast = new wxSlider (this, wxID_ANY, 0, 0, 256);
47         controls->Add (_contrast, 1, wxALL, DCPOMATIC_SIZER_X_GAP);
48
49         overall_sizer->Add (controls, 0, wxALL | wxEXPAND, DCPOMATIC_SIZER_X_GAP);
50
51         _plot = new VideoWaveformPlot (this, _viewer);
52         overall_sizer->Add (_plot, 1, wxALL | wxEXPAND, 12);
53
54 #ifdef DCPOMATIC_LINUX
55         wxSizer* buttons = CreateSeparatedButtonSizer (wxCLOSE);
56         if (buttons) {
57                 overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
58         }
59 #endif
60
61         SetSizer (overall_sizer);
62         overall_sizer->Layout ();
63         overall_sizer->SetSizeHints (this);
64
65         Bind (wxEVT_SHOW, bind (&VideoWaveformDialog::shown, this, _1));
66         _component->Bind  (wxEVT_COMMAND_CHOICE_SELECTED, bind (&VideoWaveformDialog::component_changed, this));
67         _contrast->Bind (wxEVT_SCROLL_THUMBTRACK, bind (&VideoWaveformDialog::contrast_changed, this));
68
69         _component->SetSelection (0);
70         _contrast->SetValue (32);
71
72         component_changed ();
73         contrast_changed ();
74 }
75
76 void
77 VideoWaveformDialog::shown (wxShowEvent& ev)
78 {
79         _plot->set_enabled (ev.IsShown ());
80         if (ev.IsShown ()) {
81                 _viewer->refresh ();
82         }
83 }
84
85 void
86 VideoWaveformDialog::component_changed ()
87 {
88         _plot->set_component (_component->GetCurrentSelection ());
89 }
90
91 void
92 VideoWaveformDialog::contrast_changed ()
93 {
94         _plot->set_contrast (_contrast->GetValue ());
95 }