No-op; fix GPL address and use the explicit-program-name version.
[dcpomatic.git] / src / wx / timeline_dialog.cc
1 /*
2     Copyright (C) 2013-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 <list>
22 #include <wx/graphics.h>
23 #include "lib/playlist.h"
24 #include "film_editor.h"
25 #include "timeline_dialog.h"
26 #include "wx_util.h"
27 #include "content_panel.h"
28 #include <iostream>
29
30 using std::list;
31 using std::cout;
32 using boost::shared_ptr;
33
34 TimelineDialog::TimelineDialog (ContentPanel* cp, shared_ptr<Film> film)
35         : wxDialog (cp->panel(), wxID_ANY, _("Timeline"), wxDefaultPosition, wxSize (640, 512), wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE)
36         , _film (film)
37         , _timeline (this, cp, film)
38 {
39         wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
40
41         wxBoxSizer* controls = new wxBoxSizer (wxHORIZONTAL);
42         _snap = new wxCheckBox (this, wxID_ANY, _("Snap"));
43         controls->Add (_snap);
44         _sequence = new wxCheckBox (this, wxID_ANY, _("Keep video and subtitles in sequence"));
45         controls->Add (_sequence, 1, wxLEFT, 12);
46
47         sizer->Add (controls, 0, wxALL, 12);
48         sizer->Add (&_timeline, 1, wxEXPAND | wxALL, 12);
49
50 #ifdef DCPOMATIC_LINUX
51         wxSizer* buttons = CreateSeparatedButtonSizer (wxCLOSE);
52         if (buttons) {
53                 sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
54         }
55 #endif
56
57         SetSizer (sizer);
58         sizer->Layout ();
59         sizer->SetSizeHints (this);
60
61         _snap->SetValue (_timeline.snap ());
62         _snap->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&TimelineDialog::snap_toggled, this));
63         film_changed (Film::SEQUENCE);
64         _sequence->Bind (wxEVT_COMMAND_CHECKBOX_CLICKED, boost::bind (&TimelineDialog::sequence_toggled, this));
65
66         _film_changed_connection = film->Changed.connect (bind (&TimelineDialog::film_changed, this, _1));
67 }
68
69 void
70 TimelineDialog::snap_toggled ()
71 {
72         _timeline.set_snap (_snap->GetValue ());
73 }
74
75 void
76 TimelineDialog::sequence_toggled ()
77 {
78         shared_ptr<Film> film = _film.lock ();
79         if (!film) {
80                 return;
81         }
82
83         film->set_sequence (_sequence->GetValue ());
84 }
85
86 void
87 TimelineDialog::film_changed (Film::Property p)
88 {
89         shared_ptr<Film> film = _film.lock ();
90         if (!film) {
91                 return;
92         }
93
94         if (p == Film::SEQUENCE) {
95                 _sequence->SetValue (film->sequence ());
96         }
97 }
98
99 void
100 TimelineDialog::set_selection (ContentList selection)
101 {
102         _timeline.set_selection (selection);
103 }