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, _("Start time"), true);
38 _start = new Timecode (this);
40 add_label_to_sizer (grid, this, _("Length"), true);
41 _length = new Timecode (this);
44 _start->Changed.connect (boost::bind (&TimingPanel::start_changed, this));
45 _length->Changed.connect (boost::bind (&TimingPanel::length_changed, this));
49 TimingPanel::film_content_changed (shared_ptr<Content> content, int property)
51 if (property == ContentProperty::START) {
53 _start->set (content->start (), _editor->film()->video_frame_rate ());
57 } else if (property == ContentProperty::LENGTH) {
59 _length->set (content->length (), _editor->film()->video_frame_rate ());
65 _length->set_editable (dynamic_pointer_cast<StillImageContent> (content));
69 TimingPanel::start_changed ()
71 shared_ptr<Content> c = _editor->selected_content ();
76 c->set_start (_start->get (_editor->film()->video_frame_rate ()));
80 TimingPanel::length_changed ()
82 shared_ptr<Content> c = _editor->selected_content ();
87 shared_ptr<StillImageContent> ic = dynamic_pointer_cast<StillImageContent> (c);
89 ic->set_video_length (_length->get (_editor->film()->video_frame_rate()) * ic->video_frame_rate() / TIME_HZ);