2 Copyright (C) 2015 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
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.
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.
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/>.
21 #include "video_waveform_dialog.h"
22 #include "video_waveform_plot.h"
23 #include "film_viewer.h"
25 #include <boost/bind.hpp>
30 using boost::weak_ptr;
32 VideoWaveformDialog::VideoWaveformDialog (wxWindow* parent, weak_ptr<const Film> film, FilmViewer* viewer)
39 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE | wxFRAME_FLOAT_ON_PARENT
43 wxBoxSizer* overall_sizer = new wxBoxSizer (wxVERTICAL);
45 wxBoxSizer* controls = new wxBoxSizer (wxHORIZONTAL);
47 _component = new wxChoice (this, wxID_ANY);
48 _component->Append (wxT ("X"));
49 _component->Append (wxT ("Y"));
50 _component->Append (wxT ("Z"));
51 add_label_to_sizer (controls, this, _("Component"), true);
52 controls->Add (_component, 1, wxALL, DCPOMATIC_SIZER_X_GAP);
54 add_label_to_sizer (controls, this, _("Contrast"), true);
55 _contrast = new wxSlider (this, wxID_ANY, 0, 0, 256);
56 controls->Add (_contrast, 1, wxALL, DCPOMATIC_SIZER_X_GAP);
58 overall_sizer->Add (controls, 0, wxALL | wxEXPAND, DCPOMATIC_SIZER_X_GAP);
60 wxBoxSizer* position = new wxBoxSizer (wxHORIZONTAL);
61 add_label_to_sizer (position, this, _("Image X position"), true);
62 _x_position = new wxStaticText (this, wxID_ANY, "");
63 _x_position->SetMinSize (wxSize (64, -1));
64 position->Add (_x_position, 0, wxALL, DCPOMATIC_SIZER_X_GAP);
65 add_label_to_sizer (position, this, _("component value"), true);
66 _value = new wxStaticText (this, wxID_ANY, "");
67 _value->SetMinSize (wxSize (64, -1));
68 position->Add (_value, 0, wxALL, DCPOMATIC_SIZER_X_GAP);
69 overall_sizer->Add (position, 0, wxEXPAND | wxALL, DCPOMATIC_SIZER_Y_GAP);
71 _plot = new VideoWaveformPlot (this, film, _viewer);
72 overall_sizer->Add (_plot, 1, wxALL | wxEXPAND, 12);
74 #ifdef DCPOMATIC_LINUX
75 wxSizer* buttons = CreateSeparatedButtonSizer (wxCLOSE);
77 overall_sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
81 SetSizer (overall_sizer);
82 overall_sizer->Layout ();
83 overall_sizer->SetSizeHints (this);
85 Bind (wxEVT_SHOW, bind (&VideoWaveformDialog::shown, this, _1));
86 _component->Bind (wxEVT_COMMAND_CHOICE_SELECTED, bind (&VideoWaveformDialog::component_changed, this));
87 _contrast->Bind (wxEVT_SCROLL_THUMBTRACK, bind (&VideoWaveformDialog::contrast_changed, this));
88 _plot->MouseMoved.connect (bind (&VideoWaveformDialog::mouse_moved, this, _1, _2, _3, _4));
90 _component->SetSelection (0);
91 _contrast->SetValue (32);
98 VideoWaveformDialog::shown (wxShowEvent& ev)
100 _plot->set_enabled (ev.IsShown ());
107 VideoWaveformDialog::component_changed ()
109 _plot->set_component (_component->GetCurrentSelection ());
113 VideoWaveformDialog::contrast_changed ()
115 _plot->set_contrast (_contrast->GetValue ());
119 VideoWaveformDialog::mouse_moved (int x1, int x2, int y1, int y2)
122 _x_position->SetLabel (wxString::Format ("%d-%d", x1, x2));
124 _x_position->SetLabel (wxString::Format ("%d", x1));
128 _value->SetLabel (wxString::Format ("%d-%d", y1, y2));
130 _value->SetLabel (wxString::Format ("%d", y1));