2 Copyright (C) 2012-2013 Carl Hetherington <cth@carlh.net>
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.
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.
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.
20 #include "lib/content.h"
21 #include "lib/still_image_content.h"
22 #include "timing_panel.h"
25 #include "film_editor.h"
28 using boost::shared_ptr;
29 using boost::dynamic_pointer_cast;
31 TimingPanel::TimingPanel (FilmEditor* e)
32 : FilmEditorPanel (e, _("Timing"))
34 wxFlexGridSizer* grid = new wxFlexGridSizer (2, 4, 4);
35 _sizer->Add (grid, 0, wxALL, 8);
37 add_label_to_sizer (grid, this, _("Position"), true);
38 _position = new Timecode (this);
39 grid->Add (_position);
40 add_label_to_sizer (grid, this, _("Length"), true);
41 _length = new Timecode (this);
43 add_label_to_sizer (grid, this, _("Trim from start"), true);
44 _trim_start = new Timecode (this);
45 grid->Add (_trim_start);
46 add_label_to_sizer (grid, this, _("Trim from end"), true);
47 _trim_end = new Timecode (this);
48 grid->Add (_trim_end);
50 _position->Changed.connect (boost::bind (&TimingPanel::position_changed, this));
51 _length->Changed.connect (boost::bind (&TimingPanel::length_changed, this));
52 _trim_start->Changed.connect (boost::bind (&TimingPanel::trim_start_changed, this));
53 _trim_end->Changed.connect (boost::bind (&TimingPanel::trim_end_changed, this));
57 TimingPanel::film_content_changed (int property)
59 ContentList cl = _editor->selected_content ();
60 shared_ptr<Content> content;
62 content = cl.front ();
65 if (property == ContentProperty::POSITION) {
67 _position->set (content->position (), _editor->film()->video_frame_rate ());
69 _position->set (0, 24);
71 } else if (property == ContentProperty::LENGTH) {
73 _length->set (content->full_length (), _editor->film()->video_frame_rate ());
77 } else if (property == ContentProperty::TRIM_START) {
79 _trim_start->set (content->trim_start (), _editor->film()->video_frame_rate ());
81 _trim_start->set (0, 24);
83 } else if (property == ContentProperty::TRIM_END) {
85 _trim_end->set (content->trim_end (), _editor->film()->video_frame_rate ());
87 _trim_end->set (0, 24);
91 _length->set_editable (dynamic_pointer_cast<StillImageContent> (content));
95 TimingPanel::position_changed ()
97 ContentList c = _editor->selected_content ();
99 c.front()->set_position (_position->get (_editor->film()->video_frame_rate ()));
104 TimingPanel::length_changed ()
106 ContentList c = _editor->selected_content ();
108 shared_ptr<StillImageContent> ic = dynamic_pointer_cast<StillImageContent> (c.front ());
110 ic->set_video_length (rint (_length->get (_editor->film()->video_frame_rate()) * ic->video_frame_rate() / TIME_HZ));
116 TimingPanel::trim_start_changed ()
118 ContentList c = _editor->selected_content ();
120 c.front()->set_trim_start (_trim_start->get (_editor->film()->video_frame_rate ()));
126 TimingPanel::trim_end_changed ()
128 ContentList c = _editor->selected_content ();
130 c.front()->set_trim_end (_trim_end->get (_editor->film()->video_frame_rate ()));
135 TimingPanel::content_selection_changed ()