X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Fwx%2Ftimeline.cc;h=80f4133c03fdc9df6f567dc02c4eb1b73b29c1df;hp=359de9bf9f1b93d65e64e2045487ad120f6d6071;hb=ef25237193100de106eccdb8f40524fa670bda76;hpb=14a9755762cf1d1e33877dec4a02b627dfa400cb diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc index 359de9bf9..80f4133c0 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,11 +61,13 @@ 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) + +Timeline::Timeline(wxWindow* parent, ContentPanel* cp, shared_ptr film, FilmViewer& viewer) : wxPanel (parent, wxID_ANY) , _labels_canvas (new wxScrolledCanvas (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE)) , _main_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) @@ -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 () { @@ -199,7 +207,7 @@ Timeline::paint_main () if (_zoom_point) { /* Translate back as _down_point and _zoom_point do not take scroll into account */ gc->Translate (vsx * _x_scroll_rate, vsy * _y_scroll_rate); - gc->SetPen (*wxBLACK_PEN); + gc->SetPen(gui_is_dark() ? *wxWHITE_PEN : *wxBLACK_PEN); gc->SetBrush (*wxTRANSPARENT_BRUSH); gc->DrawRectangle ( min (_down_point.x, _zoom_point->x), @@ -211,12 +219,9 @@ Timeline::paint_main () /* Playhead */ - auto vp = _viewer.lock (); - DCPOMATIC_ASSERT (vp); - gc->SetPen (*wxRED_PEN); auto path = gc->CreatePath (); - double const ph = vp->position().seconds() * pixels_per_second().get_value_or(0); + double const ph = _viewer.position().seconds() * pixels_per_second().get_value_or(0); path.MoveToPoint (ph, 0); path.AddLineToPoint (ph, pixels_per_track() * _tracks + 32); gc->StrokePath (path); @@ -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,6 +376,7 @@ struct AudioMappingComparator { } }; + void Timeline::assign_tracks () { @@ -429,12 +440,14 @@ Timeline::assign_tracks () _reels_view->set_y (8); } + int Timeline::tracks () const { return _tracks; } + void Timeline::setup_scrollbars () { @@ -451,6 +464,7 @@ Timeline::setup_scrollbars () _main_canvas->SetScrollRate (_x_scroll_rate, _y_scroll_rate); } + shared_ptr Timeline::event_to_view (wxMouseEvent& ev) { @@ -462,7 +476,6 @@ Timeline::event_to_view (wxMouseEvent& ev) Position const p (ev.GetX() + vsx * _x_scroll_rate, ev.GetY() + vsy * _y_scroll_rate); while (i != _views.rend() && !(*i)->bbox().contains (p)) { - auto cv = dynamic_pointer_cast(*i); ++i; } @@ -473,6 +486,7 @@ Timeline::event_to_view (wxMouseEvent& ev) return *i; } + void Timeline::left_down (wxMouseEvent& ev) { @@ -492,6 +506,7 @@ Timeline::left_down (wxMouseEvent& ev) } } + void Timeline::left_down_select (wxMouseEvent& ev) { @@ -548,6 +563,7 @@ Timeline::left_down_select (wxMouseEvent& ev) } } + void Timeline::left_up (wxMouseEvent& ev) { @@ -567,6 +583,7 @@ Timeline::left_up (wxMouseEvent& ev) } } + void Timeline::left_up_select (wxMouseEvent& ev) { @@ -591,6 +608,7 @@ Timeline::left_up_select (wxMouseEvent& ev) _end_snaps.clear (); } + void Timeline::left_up_zoom (wxMouseEvent& ev) { @@ -626,12 +644,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) { @@ -649,6 +669,7 @@ Timeline::mouse_moved (wxMouseEvent& ev) } } + void Timeline::mouse_moved_select (wxMouseEvent& ev) { @@ -659,6 +680,7 @@ Timeline::mouse_moved_select (wxMouseEvent& ev) set_position_from_event (ev); } + void Timeline::mouse_moved_zoom (wxMouseEvent& ev) { @@ -670,6 +692,7 @@ Timeline::mouse_moved_zoom (wxMouseEvent& ev) Refresh (); } + void Timeline::right_down (wxMouseEvent& ev) { @@ -691,6 +714,7 @@ Timeline::right_down (wxMouseEvent& ev) } } + void Timeline::right_down_select (wxMouseEvent& ev) { @@ -708,6 +732,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 { @@ -717,6 +742,7 @@ Timeline::maybe_snap (DCPTime a, DCPTime b, optional& nearest_distance) } } + void Timeline::set_position_from_event (wxMouseEvent& ev, bool force_emit) { @@ -782,18 +808,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 () { @@ -804,6 +833,7 @@ Timeline::resized () setup_scrollbars (); } + void Timeline::clear_selection () { @@ -815,6 +845,7 @@ Timeline::clear_selection () } } + TimelineContentViewList Timeline::selected_views () const { @@ -830,6 +861,7 @@ Timeline::selected_views () const return sel; } + ContentList Timeline::selected_content () const { @@ -842,6 +874,7 @@ Timeline::selected_content () const return sel; } + void Timeline::set_selection (ContentList selection) { @@ -853,18 +886,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) { @@ -876,6 +912,7 @@ Timeline::scrolled (wxScrollWinEvent& ev) ev.Skip (); } + void Timeline::tool_clicked (Tool t) { @@ -893,6 +930,7 @@ Timeline::tool_clicked (Tool t) } } + void Timeline::zoom_all () {