diff options
| author | Carl Hetherington <cth@carlh.net> | 2013-07-30 21:34:16 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2013-07-30 21:34:16 +0100 |
| commit | c57e92b12c64d4ad1a7f23876a97471565f9a252 (patch) | |
| tree | 008213d35e4be34c55caa51760ab7aef6fa33113 /src/wx | |
| parent | e241b3d295fe4158239170f17391e08473e159c5 (diff) | |
Somewhat untested and sketchy basics of trimming.
Diffstat (limited to 'src/wx')
| -rw-r--r-- | src/wx/film_editor.cc | 4 | ||||
| -rw-r--r-- | src/wx/timeline.cc | 40 | ||||
| -rw-r--r-- | src/wx/timeline.h | 4 | ||||
| -rw-r--r-- | src/wx/timing_panel.cc | 67 | ||||
| -rw-r--r-- | src/wx/timing_panel.h | 8 |
5 files changed, 86 insertions, 37 deletions
diff --git a/src/wx/film_editor.cc b/src/wx/film_editor.cc index 914dc6136..c0e169835 100644 --- a/src/wx/film_editor.cc +++ b/src/wx/film_editor.cc @@ -733,8 +733,10 @@ FilmEditor::content_selection_changed () /* All other sensitivity in content panels should be triggered by one of these. */ - film_content_changed (s, ContentProperty::START); + film_content_changed (s, ContentProperty::POSITION); film_content_changed (s, ContentProperty::LENGTH); + film_content_changed (s, ContentProperty::TRIM_START); + film_content_changed (s, ContentProperty::TRIM_END); film_content_changed (s, VideoContentProperty::VIDEO_CROP); film_content_changed (s, VideoContentProperty::VIDEO_RATIO); film_content_changed (s, VideoContentProperty::VIDEO_FRAME_TYPE); diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index f6e0dabb6..7c0690084 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -92,9 +92,9 @@ public: } return dcpomatic::Rect<int> ( - time_x (content->start ()) - 8, + time_x (content->position ()) - 8, y_pos (_track) - 8, - content->length () * _timeline.pixels_per_time_unit() + 16, + content->length_after_trim () * _timeline.pixels_per_time_unit() + 16, _timeline.track_height() + 16 ); } @@ -133,8 +133,8 @@ private: return; } - Time const start = cont->start (); - Time const len = cont->length (); + Time const position = cont->position (); + Time const len = cont->length_after_trim (); wxColour selected (colour().Red() / 2, colour().Green() / 2, colour().Blue() / 2); @@ -148,11 +148,11 @@ private: } wxGraphicsPath path = gc->CreatePath (); - path.MoveToPoint (time_x (start), y_pos (_track) + 4); - path.AddLineToPoint (time_x (start + len), y_pos (_track) + 4); - path.AddLineToPoint (time_x (start + len), y_pos (_track + 1) - 4); - path.AddLineToPoint (time_x (start), y_pos (_track + 1) - 4); - path.AddLineToPoint (time_x (start), y_pos (_track) + 4); + path.MoveToPoint (time_x (position), y_pos (_track) + 4); + path.AddLineToPoint (time_x (position + len), y_pos (_track) + 4); + path.AddLineToPoint (time_x (position + len), y_pos (_track + 1) - 4); + path.AddLineToPoint (time_x (position), y_pos (_track + 1) - 4); + path.AddLineToPoint (time_x (position), y_pos (_track) + 4); gc->StrokePath (path); gc->FillPath (path); @@ -163,8 +163,8 @@ private: wxDouble name_leading; gc->GetTextExtent (name, &name_width, &name_height, &name_descent, &name_leading); - gc->Clip (wxRegion (time_x (start), y_pos (_track), len * _timeline.pixels_per_time_unit(), _timeline.track_height())); - gc->DrawText (name, time_x (start) + 12, y_pos (_track + 1) - name_height - 4); + gc->Clip (wxRegion (time_x (position), y_pos (_track), len * _timeline.pixels_per_time_unit(), _timeline.track_height())); + gc->DrawText (name, time_x (position) + 12, y_pos (_track + 1) - name_height - 4); gc->ResetClip (); } @@ -177,7 +177,7 @@ private: { ensure_ui_thread (); - if (p == ContentProperty::START || p == ContentProperty::LENGTH) { + if (p == ContentProperty::POSITION || p == ContentProperty::LENGTH) { force_redraw (); } @@ -327,7 +327,7 @@ Timeline::Timeline (wxWindow* parent, FilmEditor* ed, shared_ptr<Film> film) , _tracks (0) , _pixels_per_time_unit (0) , _left_down (false) - , _down_view_start (0) + , _down_view_position (0) , _first_move (false) , _menu (film, this) { @@ -430,8 +430,8 @@ Timeline::assign_tracks () if (test && test->track() == t) { bool const no_overlap = - (acv_content->start() < test_content->start() && acv_content->end() < test_content->start()) || - (acv_content->start() > test_content->end() && acv_content->end() > test_content->end()); + (acv_content->position() < test_content->position() && acv_content->end() < test_content->position()) || + (acv_content->position() > test_content->end() && acv_content->end() > test_content->end()); if (!no_overlap) { /* we have an overlap on track `t' */ @@ -499,7 +499,7 @@ Timeline::left_down (wxMouseEvent& ev) if (content_view) { _down_view = content_view; - _down_view_start = content_view->content()->start (); + _down_view_position = content_view->content()->position (); } for (ViewList::iterator i = _views.begin(); i != _views.end(); ++i) { @@ -539,7 +539,7 @@ Timeline::left_up (wxMouseEvent& ev) _down_view->content()->set_change_signals_frequent (false); } - set_start_from_event (ev); + set_position_from_event (ev); } void @@ -549,7 +549,7 @@ Timeline::mouse_moved (wxMouseEvent& ev) return; } - set_start_from_event (ev); + set_position_from_event (ev); } void @@ -570,7 +570,7 @@ Timeline::right_down (wxMouseEvent& ev) } void -Timeline::set_start_from_event (wxMouseEvent& ev) +Timeline::set_position_from_event (wxMouseEvent& ev) { wxPoint const p = ev.GetPosition(); @@ -584,7 +584,7 @@ Timeline::set_start_from_event (wxMouseEvent& ev) Time const time_diff = (p.x - _down_point.x) / _pixels_per_time_unit; if (_down_view) { - _down_view->content()->set_start (max (static_cast<Time> (0), _down_view_start + time_diff)); + _down_view->content()->set_position (max (static_cast<Time> (0), _down_view_position + time_diff)); shared_ptr<Film> film = _film.lock (); assert (film); diff --git a/src/wx/timeline.h b/src/wx/timeline.h index db33dbbdc..0217373b9 100644 --- a/src/wx/timeline.h +++ b/src/wx/timeline.h @@ -73,7 +73,7 @@ private: void playlist_changed (); void resized (); void assign_tracks (); - void set_start_from_event (wxMouseEvent &); + void set_position_from_event (wxMouseEvent &); void clear_selection (); typedef std::vector<boost::shared_ptr<View> > ViewList; @@ -92,7 +92,7 @@ private: bool _left_down; wxPoint _down_point; boost::shared_ptr<ContentView> _down_view; - Time _down_view_start; + Time _down_view_position; bool _first_move; ContentMenu _menu; diff --git a/src/wx/timing_panel.cc b/src/wx/timing_panel.cc index 313543d2d..f11a4e5e6 100644 --- a/src/wx/timing_panel.cc +++ b/src/wx/timing_panel.cc @@ -34,46 +34,66 @@ TimingPanel::TimingPanel (FilmEditor* e) wxFlexGridSizer* grid = new wxFlexGridSizer (2, 4, 4); _sizer->Add (grid, 0, wxALL, 8); - add_label_to_sizer (grid, this, _("Start time"), true); - _start = new Timecode (this); - grid->Add (_start); + add_label_to_sizer (grid, this, _("Position"), true); + _position = new Timecode (this); + grid->Add (_position); add_label_to_sizer (grid, this, _("Length"), true); _length = new Timecode (this); grid->Add (_length); + add_label_to_sizer (grid, this, _("Trim from start"), true); + _trim_start = new Timecode (this); + grid->Add (_trim_start); + add_label_to_sizer (grid, this, _("Trim from end"), true); + _trim_end = new Timecode (this); + grid->Add (_trim_end); - _start->Changed.connect (boost::bind (&TimingPanel::start_changed, this)); - _length->Changed.connect (boost::bind (&TimingPanel::length_changed, this)); + _position->Changed.connect (boost::bind (&TimingPanel::position_changed, this)); + _length->Changed.connect (boost::bind (&TimingPanel::length_changed, this)); + _trim_start->Changed.connect (boost::bind (&TimingPanel::trim_start_changed, this)); + _trim_end->Changed.connect (boost::bind (&TimingPanel::trim_end_changed, this)); } void TimingPanel::film_content_changed (shared_ptr<Content> content, int property) { - if (property == ContentProperty::START) { + if (property == ContentProperty::POSITION) { if (content) { - _start->set (content->start (), _editor->film()->video_frame_rate ()); + _position->set (content->position (), _editor->film()->video_frame_rate ()); } else { - _start->set (0, 24); + _position->set (0, 24); } } else if (property == ContentProperty::LENGTH) { if (content) { - _length->set (content->length (), _editor->film()->video_frame_rate ()); + _length->set (content->full_length (), _editor->film()->video_frame_rate ()); } else { _length->set (0, 24); } - } + } else if (property == ContentProperty::TRIM_START) { + if (content) { + _trim_start->set (content->trim_start (), _editor->film()->video_frame_rate ()); + } else { + _trim_start->set (0, 24); + } + } else if (property == ContentProperty::TRIM_END) { + if (content) { + _trim_end->set (content->trim_end (), _editor->film()->video_frame_rate ()); + } else { + _trim_end->set (0, 24); + } + } _length->set_editable (dynamic_pointer_cast<StillImageContent> (content)); } void -TimingPanel::start_changed () +TimingPanel::position_changed () { shared_ptr<Content> c = _editor->selected_content (); if (!c) { return; } - c->set_start (_start->get (_editor->film()->video_frame_rate ())); + c->set_position (_position->get (_editor->film()->video_frame_rate ())); } void @@ -89,3 +109,26 @@ TimingPanel::length_changed () ic->set_video_length (_length->get (_editor->film()->video_frame_rate()) * ic->video_frame_rate() / TIME_HZ); } } + +void +TimingPanel::trim_start_changed () +{ + shared_ptr<Content> c = _editor->selected_content (); + if (!c) { + return; + } + + c->set_trim_start (_trim_start->get (_editor->film()->video_frame_rate ())); +} + + +void +TimingPanel::trim_end_changed () +{ + shared_ptr<Content> c = _editor->selected_content (); + if (!c) { + return; + } + + c->set_trim_end (_trim_end->get (_editor->film()->video_frame_rate ())); +} diff --git a/src/wx/timing_panel.h b/src/wx/timing_panel.h index b5c9ef026..b84ea52be 100644 --- a/src/wx/timing_panel.h +++ b/src/wx/timing_panel.h @@ -29,9 +29,13 @@ public: void film_content_changed (boost::shared_ptr<Content>, int); private: - void start_changed (); + void position_changed (); void length_changed (); + void trim_start_changed (); + void trim_end_changed (); - Timecode* _start; + Timecode* _position; Timecode* _length; + Timecode* _trim_start; + Timecode* _trim_end; }; |
