X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Ftimeline.cc;h=f6ede297db3a809408c1a2f7dad9b68437760ed8;hb=d8a8f4565b167aa23826999448601c8907728e8f;hp=3294676fc2f8daaf8d5e0b9ce0704f326b1917c0;hpb=9b946fc5250eff5a5dd4a661896916fcd5d9bd4b;p=dcpomatic.git diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index 3294676fc..f6ede297d 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -18,40 +18,42 @@ */ +#include "content_panel.h" #include "film_editor.h" +#include "film_viewer.h" #include "timeline.h" -#include "timeline_time_axis_view.h" -#include "timeline_reels_view.h" -#include "timeline_labels_view.h" -#include "timeline_video_content_view.h" +#include "timeline_atmos_content_view.h" #include "timeline_audio_content_view.h" +#include "timeline_labels_view.h" +#include "timeline_reels_view.h" #include "timeline_text_content_view.h" -#include "timeline_atmos_content_view.h" -#include "content_panel.h" +#include "timeline_time_axis_view.h" +#include "timeline_video_content_view.h" #include "wx_util.h" -#include "film_viewer.h" +#include "lib/atmos_mxf_content.h" +#include "lib/audio_content.h" #include "lib/film.h" -#include "lib/playlist.h" #include "lib/image_content.h" -#include "lib/timer.h" -#include "lib/audio_content.h" +#include "lib/playlist.h" #include "lib/text_content.h" +#include "lib/timer.h" #include "lib/video_content.h" -#include "lib/atmos_mxf_content.h" +#include +LIBDCP_DISABLE_WARNINGS #include -#include +LIBDCP_ENABLE_WARNINGS #include -#include +#include + +using std::abs; +using std::dynamic_pointer_cast; using std::list; -using std::cout; -using std::min; +using std::make_shared; using std::max; -using std::abs; +using std::min; using std::shared_ptr; using std::weak_ptr; -using std::dynamic_pointer_cast; -using std::make_shared; using boost::bind; using boost::optional; using namespace dcpomatic; @@ -59,10 +61,12 @@ using namespace dcpomatic; using namespace boost::placeholders; #endif + /* 3 hours in 640 pixels */ double const Timeline::_minimum_pixels_per_second = 640.0 / (60 * 60 * 3); int const Timeline::_minimum_pixels_per_track = 16; + Timeline::Timeline (wxWindow* parent, ContentPanel* cp, shared_ptr film, weak_ptr viewer) : wxPanel (parent, wxID_ANY) , _labels_canvas (new wxScrolledCanvas (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE)) @@ -77,7 +81,7 @@ Timeline::Timeline (wxWindow* parent, ContentPanel* cp, shared_ptr film, w , _left_down (false) , _down_view_position (0) , _first_move (false) - , _menu (this) + , _menu (this, viewer) , _snap (true) , _tool (SELECT) , _x_scroll_rate (16) @@ -112,7 +116,7 @@ Timeline::Timeline (wxWindow* parent, ContentPanel* cp, shared_ptr film, w _main_canvas->Bind (wxEVT_SCROLLWIN_PAGEDOWN, boost::bind (&Timeline::scrolled, this, _1)); _main_canvas->Bind (wxEVT_SCROLLWIN_THUMBTRACK, boost::bind (&Timeline::scrolled, this, _1)); - film_change (CHANGE_TYPE_DONE, Film::CONTENT); + film_change (ChangeType::DONE, Film::Property::CONTENT); SetMinSize (wxSize (640, 4 * pixels_per_track() + 96)); @@ -126,18 +130,21 @@ Timeline::Timeline (wxWindow* parent, ContentPanel* cp, shared_ptr film, w _labels_canvas->ShowScrollbars (wxSHOW_SB_NEVER, wxSHOW_SB_NEVER); } + void Timeline::update_playhead () { Refresh (); } + void Timeline::set_pixels_per_second (double pps) { _pixels_per_second = max (_minimum_pixels_per_second, pps); } + void Timeline::paint_labels () { @@ -152,11 +159,12 @@ Timeline::paint_labels () _labels_canvas->GetViewStart (&vsx, &vsy); gc->Translate (-vsx * _x_scroll_rate, -vsy * _y_scroll_rate + tracks_y_offset()); - _labels_view->paint (gc, list >()); + _labels_view->paint (gc, {}); delete gc; } + void Timeline::paint_main () { @@ -182,7 +190,7 @@ Timeline::paint_main () list> overlaps; for (auto j: _views) { auto jc = dynamic_pointer_cast (j); - /* No overlap with non-content views, views no different tracks, audio views or non-active views */ + /* No overlap with non-content views, views on different tracks, audio views or non-active views */ if (!ic || !jc || i == j || ic->track() != jc->track() || ic->track().get_value_or(2) >= 2 || !ic->active() || !jc->active()) { continue; } @@ -224,21 +232,23 @@ Timeline::paint_main () delete gc; } + void Timeline::film_change (ChangeType type, Film::Property p) { - if (type != CHANGE_TYPE_DONE) { + if (type != ChangeType::DONE) { return; } - if (p == Film::CONTENT || p == Film::REEL_TYPE || p == Film::REEL_LENGTH) { + if (p == Film::Property::CONTENT || p == Film::Property::REEL_TYPE || p == Film::Property::REEL_LENGTH) { ensure_ui_thread (); recreate_views (); - } else if (p == Film::CONTENT_ORDER) { + } else if (p == Film::Property::CONTENT_ORDER) { Refresh (); } } + void Timeline::recreate_views () { @@ -274,10 +284,11 @@ Timeline::recreate_views () Refresh (); } + void Timeline::film_content_change (ChangeType type, int property, bool frequent) { - if (type != CHANGE_TYPE_DONE) { + if (type != ChangeType::DONE) { return; } @@ -293,6 +304,7 @@ Timeline::film_content_change (ChangeType type, int property, bool frequent) } } + template int place (shared_ptr film, TimelineViewList& views, int& tracks) @@ -345,6 +357,7 @@ place (shared_ptr film, TimelineViewList& views, int& tracks) return tracks - base; } + /** Compare the mapped output channels of two TimelineViews, so we can into * order of first mapped DCP channel. */ @@ -366,12 +379,14 @@ struct AudioMappingComparator { } }; + void Timeline::assign_tracks () { /* Tracks are: - Video (mono or left-eye) - Video (right-eye) + Video 1 + Video 2 + Video N Text 1 Text 2 Text N @@ -393,29 +408,7 @@ Timeline::assign_tracks () } } - /* Video */ - - bool have_3d = false; - for (auto i: _views) { - auto cv = dynamic_pointer_cast(i); - if (!cv) { - continue; - } - - /* Video on tracks 0 and maybe 1 (left and right eye) */ - if (cv->content()->video->frame_type() == VIDEO_FRAME_TYPE_3D_RIGHT) { - cv->set_track (1); - _tracks = max (_tracks, 2); - have_3d = true; - } else { - cv->set_track (0); - } - } - - _tracks = max (_tracks, 1); - - /* Texts */ - + int const video_tracks = place (film, _views, _tracks); int const text_tracks = place (film, _views, _tracks); /* Atmos */ @@ -441,7 +434,7 @@ Timeline::assign_tracks () sort(views.begin(), views.end(), AudioMappingComparator()); int const audio_tracks = place (film, views, _tracks); - _labels_view->set_3d (have_3d); + _labels_view->set_video_tracks (video_tracks); _labels_view->set_audio_tracks (audio_tracks); _labels_view->set_text_tracks (text_tracks); _labels_view->set_atmos (have_atmos); @@ -450,12 +443,14 @@ Timeline::assign_tracks () _reels_view->set_y (8); } + int Timeline::tracks () const { return _tracks; } + void Timeline::setup_scrollbars () { @@ -472,6 +467,7 @@ Timeline::setup_scrollbars () _main_canvas->SetScrollRate (_x_scroll_rate, _y_scroll_rate); } + shared_ptr Timeline::event_to_view (wxMouseEvent& ev) { @@ -494,6 +490,7 @@ Timeline::event_to_view (wxMouseEvent& ev) return *i; } + void Timeline::left_down (wxMouseEvent& ev) { @@ -513,6 +510,7 @@ Timeline::left_down (wxMouseEvent& ev) } } + void Timeline::left_down_select (wxMouseEvent& ev) { @@ -569,6 +567,7 @@ Timeline::left_down_select (wxMouseEvent& ev) } } + void Timeline::left_up (wxMouseEvent& ev) { @@ -588,6 +587,7 @@ Timeline::left_up (wxMouseEvent& ev) } } + void Timeline::left_up_select (wxMouseEvent& ev) { @@ -612,6 +612,7 @@ Timeline::left_up_select (wxMouseEvent& ev) _end_snaps.clear (); } + void Timeline::left_up_zoom (wxMouseEvent& ev) { @@ -625,6 +626,8 @@ Timeline::left_up_zoom (wxMouseEvent& ev) if ((bottom_right.x - top_left.x) < 8 || (bottom_right.y - top_left.y) < 8) { /* Very small zoom rectangle: we assume it wasn't intentional */ + _zoom_point = optional (); + Refresh (); return; } @@ -645,12 +648,14 @@ Timeline::left_up_zoom (wxMouseEvent& ev) Refresh (); } + void Timeline::set_pixels_per_track (int h) { _pixels_per_track = max(_minimum_pixels_per_track, h); } + void Timeline::mouse_moved (wxMouseEvent& ev) { @@ -668,6 +673,7 @@ Timeline::mouse_moved (wxMouseEvent& ev) } } + void Timeline::mouse_moved_select (wxMouseEvent& ev) { @@ -678,6 +684,7 @@ Timeline::mouse_moved_select (wxMouseEvent& ev) set_position_from_event (ev); } + void Timeline::mouse_moved_zoom (wxMouseEvent& ev) { @@ -689,6 +696,7 @@ Timeline::mouse_moved_zoom (wxMouseEvent& ev) Refresh (); } + void Timeline::right_down (wxMouseEvent& ev) { @@ -710,6 +718,7 @@ Timeline::right_down (wxMouseEvent& ev) } } + void Timeline::right_down_select (wxMouseEvent& ev) { @@ -727,6 +736,7 @@ Timeline::right_down_select (wxMouseEvent& ev) _menu.popup (_film, selected_content (), selected_views (), ev.GetPosition ()); } + void Timeline::maybe_snap (DCPTime a, DCPTime b, optional& nearest_distance) const { @@ -736,6 +746,7 @@ Timeline::maybe_snap (DCPTime a, DCPTime b, optional& nearest_distance) } } + void Timeline::set_position_from_event (wxMouseEvent& ev, bool force_emit) { @@ -801,18 +812,21 @@ Timeline::set_position_from_event (wxMouseEvent& ev, bool force_emit) film->set_sequence (false); } + void Timeline::force_redraw (dcpomatic::Rect const & r) { _main_canvas->RefreshRect (wxRect (r.x, r.y, r.width, r.height), false); } + shared_ptr Timeline::film () const { return _film.lock (); } + void Timeline::resized () { @@ -823,6 +837,7 @@ Timeline::resized () setup_scrollbars (); } + void Timeline::clear_selection () { @@ -834,6 +849,7 @@ Timeline::clear_selection () } } + TimelineContentViewList Timeline::selected_views () const { @@ -849,6 +865,7 @@ Timeline::selected_views () const return sel; } + ContentList Timeline::selected_content () const { @@ -861,6 +878,7 @@ Timeline::selected_content () const return sel; } + void Timeline::set_selection (ContentList selection) { @@ -872,18 +890,21 @@ Timeline::set_selection (ContentList selection) } } + int Timeline::tracks_y_offset () const { return _reels_view->bbox().height + 4; } + int Timeline::width () const { return _main_canvas->GetVirtualSize().GetWidth(); } + void Timeline::scrolled (wxScrollWinEvent& ev) { @@ -895,6 +916,7 @@ Timeline::scrolled (wxScrollWinEvent& ev) ev.Skip (); } + void Timeline::tool_clicked (Tool t) { @@ -912,6 +934,7 @@ Timeline::tool_clicked (Tool t) } } + void Timeline::zoom_all () {