2 Copyright (C) 2013-2018 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 "film_editor.h"
22 #include "timeline_dialog.h"
24 #include "content_panel.h"
25 #include "lib/playlist.h"
26 #include "lib/cross.h"
27 #include <wx/graphics.h>
33 using boost::shared_ptr;
35 TimelineDialog::TimelineDialog (ContentPanel* cp, shared_ptr<Film> film)
43 /* I can't get wxFRAME_FLOAT_ON_PARENT to work on OS X, and although wxSTAY_ON_TOP keeps
44 the window above all others (and not just our own) it's better than nothing for now.
46 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE | wxSTAY_ON_TOP
48 wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE | wxFRAME_FLOAT_ON_PARENT
52 , _timeline (this, cp, film)
54 wxBoxSizer* sizer = new wxBoxSizer (wxVERTICAL);
56 wxBoxSizer* controls = new wxBoxSizer (wxHORIZONTAL);
58 wxBitmap select (wxString::Format (wxT ("%s/select.png"), std_to_wx (shared_path().string())), wxBITMAP_TYPE_PNG);
59 wxBitmap zoom (wxString::Format (wxT ("%s/zoom.png"), std_to_wx (shared_path().string())), wxBITMAP_TYPE_PNG);
60 wxBitmap zoom_all (wxString::Format (wxT ("%s/zoom_all.png"), std_to_wx (shared_path().string())), wxBITMAP_TYPE_PNG);
62 wxToolBar* toolbar = new wxToolBar (this, wxID_ANY);
63 toolbar->AddRadioTool ((int) Timeline::SELECT, _("Select"), select, wxNullBitmap, _("Select and move content"));
64 toolbar->AddRadioTool ((int) Timeline::ZOOM, _("Zoom"), zoom, wxNullBitmap, _("Zoom in / out"));
65 toolbar->AddTool ((int) Timeline::ZOOM_ALL, _("Zoom all"), zoom_all, _("Zoom out to whole film"));
66 controls->Add (toolbar);
67 toolbar->Bind (wxEVT_TOOL, bind (&TimelineDialog::tool_clicked, this, _1));
69 _snap = new wxCheckBox (this, wxID_ANY, _("Snap"));
70 controls->Add (_snap);
71 _sequence = new wxCheckBox (this, wxID_ANY, _("Keep video and subtitles in sequence"));
72 controls->Add (_sequence, 1, wxLEFT, 12);
74 sizer->Add (controls, 0, wxALL, 12);
75 sizer->Add (&_timeline, 1, wxEXPAND | wxALL, 12);
77 #ifdef DCPOMATIC_LINUX
78 wxSizer* buttons = CreateSeparatedButtonSizer (wxCLOSE);
80 sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder());
86 sizer->SetSizeHints (this);
88 _snap->SetValue (_timeline.snap ());
89 _snap->Bind (wxEVT_CHECKBOX, boost::bind (&TimelineDialog::snap_toggled, this));
90 film_changed (Film::SEQUENCE);
91 _sequence->Bind (wxEVT_CHECKBOX, boost::bind (&TimelineDialog::sequence_toggled, this));
93 _film_changed_connection = film->Changed.connect (bind (&TimelineDialog::film_changed, this, _1));
97 TimelineDialog::snap_toggled ()
99 _timeline.set_snap (_snap->GetValue ());
103 TimelineDialog::sequence_toggled ()
105 shared_ptr<Film> film = _film.lock ();
110 film->set_sequence (_sequence->GetValue ());
114 TimelineDialog::film_changed (Film::Property p)
116 shared_ptr<Film> film = _film.lock ();
121 if (p == Film::SEQUENCE) {
122 _sequence->SetValue (film->sequence ());
127 TimelineDialog::set_selection (ContentList selection)
129 _timeline.set_selection (selection);
133 TimelineDialog::tool_clicked (wxCommandEvent& ev)
135 _timeline.tool_clicked ((Timeline::Tool) ev.GetId());