X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Fwx%2Ftimeline.cc;h=645cb3de3a5e876055177e8126894721e2b1e142;hb=313319ba2d8544bc25524e02e634804a503b54f1;hp=3187792bea4ea30545341917ea72a063f43f4a55;hpb=88c1642d83bed44a75c4fe6827c5f02fc50141c2;p=dcpomatic.git diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index 3187792be..645cb3de3 100644 --- a/src/wx/timeline.cc +++ b/src/wx/timeline.cc @@ -18,40 +18,39 @@ */ +#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 -#include #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 +58,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)) @@ -126,18 +127,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 () { @@ -157,6 +161,7 @@ Timeline::paint_labels () delete gc; } + void Timeline::paint_main () { @@ -224,6 +229,7 @@ Timeline::paint_main () delete gc; } + void Timeline::film_change (ChangeType type, Film::Property p) { @@ -239,6 +245,7 @@ Timeline::film_change (ChangeType type, Film::Property p) } } + void Timeline::recreate_views () { @@ -274,6 +281,7 @@ Timeline::recreate_views () Refresh (); } + void Timeline::film_content_change (ChangeType type, int property, bool frequent) { @@ -293,6 +301,7 @@ Timeline::film_content_change (ChangeType type, int property, bool frequent) } } + template int place (shared_ptr film, TimelineViewList& views, int& tracks) @@ -345,6 +354,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 +376,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 +405,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() == VideoFrameType::THREE_D_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 +431,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 +440,14 @@ Timeline::assign_tracks () _reels_view->set_y (8); } + int Timeline::tracks () const { return _tracks; } + void Timeline::setup_scrollbars () { @@ -472,6 +464,7 @@ Timeline::setup_scrollbars () _main_canvas->SetScrollRate (_x_scroll_rate, _y_scroll_rate); } + shared_ptr Timeline::event_to_view (wxMouseEvent& ev) { @@ -494,6 +487,7 @@ Timeline::event_to_view (wxMouseEvent& ev) return *i; } + void Timeline::left_down (wxMouseEvent& ev) { @@ -513,6 +507,7 @@ Timeline::left_down (wxMouseEvent& ev) } } + void Timeline::left_down_select (wxMouseEvent& ev) { @@ -569,6 +564,7 @@ Timeline::left_down_select (wxMouseEvent& ev) } } + void Timeline::left_up (wxMouseEvent& ev) { @@ -588,6 +584,7 @@ Timeline::left_up (wxMouseEvent& ev) } } + void Timeline::left_up_select (wxMouseEvent& ev) { @@ -612,6 +609,7 @@ Timeline::left_up_select (wxMouseEvent& ev) _end_snaps.clear (); } + void Timeline::left_up_zoom (wxMouseEvent& ev) { @@ -647,12 +645,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) { @@ -670,6 +670,7 @@ Timeline::mouse_moved (wxMouseEvent& ev) } } + void Timeline::mouse_moved_select (wxMouseEvent& ev) { @@ -680,6 +681,7 @@ Timeline::mouse_moved_select (wxMouseEvent& ev) set_position_from_event (ev); } + void Timeline::mouse_moved_zoom (wxMouseEvent& ev) { @@ -691,6 +693,7 @@ Timeline::mouse_moved_zoom (wxMouseEvent& ev) Refresh (); } + void Timeline::right_down (wxMouseEvent& ev) { @@ -712,6 +715,7 @@ Timeline::right_down (wxMouseEvent& ev) } } + void Timeline::right_down_select (wxMouseEvent& ev) { @@ -729,6 +733,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 { @@ -738,6 +743,7 @@ Timeline::maybe_snap (DCPTime a, DCPTime b, optional& nearest_distance) } } + void Timeline::set_position_from_event (wxMouseEvent& ev, bool force_emit) { @@ -803,18 +809,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 () { @@ -825,6 +834,7 @@ Timeline::resized () setup_scrollbars (); } + void Timeline::clear_selection () { @@ -836,6 +846,7 @@ Timeline::clear_selection () } } + TimelineContentViewList Timeline::selected_views () const { @@ -851,6 +862,7 @@ Timeline::selected_views () const return sel; } + ContentList Timeline::selected_content () const { @@ -863,6 +875,7 @@ Timeline::selected_content () const return sel; } + void Timeline::set_selection (ContentList selection) { @@ -874,18 +887,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) { @@ -897,6 +913,7 @@ Timeline::scrolled (wxScrollWinEvent& ev) ev.Skip (); } + void Timeline::tool_clicked (Tool t) { @@ -914,6 +931,7 @@ Timeline::tool_clicked (Tool t) } } + void Timeline::zoom_all () {