From 58cbd115b5f6051b1af19e85f250c1c5bdc5f52d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 12 Dec 2023 00:14:45 +0100 Subject: Rename "custom" reel type to "split by maximum reel size" (in the GUI). --- src/wx/dcp_panel.cc | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src') diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index d81e7bf95..b789a1a74 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -141,8 +141,7 @@ DCPPanel::DCPPanel(wxNotebook* n, shared_ptr film, FilmViewer& viewer) _reel_type->add(_("Single reel")); _reel_type->add(_("Split by video content")); - /// TRANSLATORS: translate the word "Custom" here; do not include the "Reel|" prefix - _reel_type->add(S_("Reel|Custom")); + _reel_type->add(S_("Split by maximum reel size")); _reel_type->SetToolTip(_("How the DCP should be split into parts internally. If in doubt, choose 'Single reel'")); _reel_length->SetRange (1, 64); -- cgit v1.2.3 From cc3a87b302581647330753a09815ca78c0a23fe4 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 12 Dec 2023 01:32:04 +0100 Subject: Rename Timeline -> ContentTimeline. --- src/wx/content_timeline.cc | 1029 +++++++++++++++++++++++++++++++++ src/wx/content_timeline.h | 155 +++++ src/wx/timeline.cc | 1029 --------------------------------- src/wx/timeline.h | 155 ----- src/wx/timeline_atmos_content_view.cc | 2 +- src/wx/timeline_atmos_content_view.h | 2 +- src/wx/timeline_audio_content_view.cc | 8 +- src/wx/timeline_audio_content_view.h | 2 +- src/wx/timeline_content_view.cc | 4 +- src/wx/timeline_content_view.h | 2 +- src/wx/timeline_dialog.cc | 20 +- src/wx/timeline_dialog.h | 4 +- src/wx/timeline_labels_view.cc | 4 +- src/wx/timeline_labels_view.h | 2 +- src/wx/timeline_reels_view.cc | 4 +- src/wx/timeline_reels_view.h | 2 +- src/wx/timeline_text_content_view.cc | 2 +- src/wx/timeline_text_content_view.h | 6 +- src/wx/timeline_time_axis_view.cc | 4 +- src/wx/timeline_time_axis_view.h | 2 +- src/wx/timeline_video_content_view.cc | 5 +- src/wx/timeline_video_content_view.h | 2 +- src/wx/timeline_view.cc | 4 +- src/wx/timeline_view.h | 6 +- src/wx/wscript | 2 +- 25 files changed, 1233 insertions(+), 1224 deletions(-) create mode 100644 src/wx/content_timeline.cc create mode 100644 src/wx/content_timeline.h delete mode 100644 src/wx/timeline.cc delete mode 100644 src/wx/timeline.h (limited to 'src') diff --git a/src/wx/content_timeline.cc b/src/wx/content_timeline.cc new file mode 100644 index 000000000..b650f8e92 --- /dev/null +++ b/src/wx/content_timeline.cc @@ -0,0 +1,1029 @@ +/* + Copyright (C) 2013-2021 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + +#include "content_panel.h" +#include "content_timeline.h" +#include "film_editor.h" +#include "film_viewer.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_time_axis_view.h" +#include "timeline_video_content_view.h" +#include "wx_util.h" +#include "lib/atmos_mxf_content.h" +#include "lib/audio_content.h" +#include "lib/film.h" +#include "lib/image_content.h" +#include "lib/playlist.h" +#include "lib/text_content.h" +#include "lib/timer.h" +#include "lib/video_content.h" +#include +#include +LIBDCP_DISABLE_WARNINGS +#include +LIBDCP_ENABLE_WARNINGS +#include +#include + + +using std::abs; +using std::dynamic_pointer_cast; +using std::list; +using std::make_shared; +using std::max; +using std::min; +using std::shared_ptr; +using std::weak_ptr; +using boost::bind; +using boost::optional; +using namespace dcpomatic; +#if BOOST_VERSION >= 106100 +using namespace boost::placeholders; +#endif + + +/* 3 hours in 640 pixels */ +double const ContentTimeline::_minimum_pixels_per_second = 640.0 / (60 * 60 * 3); +int const ContentTimeline::_minimum_pixels_per_track = 16; + + +ContentTimeline::ContentTimeline(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)) + , _content_panel (cp) + , _film (film) + , _viewer (viewer) + , _time_axis_view (new TimelineTimeAxisView (*this, 64)) + , _reels_view (new TimelineReelsView (*this, 32)) + , _labels_view (new TimelineLabelsView (*this)) + , _tracks (0) + , _left_down (false) + , _down_view_position (0) + , _first_move (false) + , _menu (this, viewer) + , _snap (true) + , _tool (SELECT) + , _x_scroll_rate (16) + , _y_scroll_rate (16) + , _pixels_per_track (48) + , _first_resize (true) + , _timer (this) +{ +#ifndef __WXOSX__ + _labels_canvas->SetDoubleBuffered (true); + _main_canvas->SetDoubleBuffered (true); +#endif + + auto sizer = new wxBoxSizer (wxHORIZONTAL); + sizer->Add (_labels_canvas, 0, wxEXPAND); + _labels_canvas->SetMinSize (wxSize (_labels_view->bbox().width, -1)); + sizer->Add (_main_canvas, 1, wxEXPAND); + SetSizer (sizer); + + _labels_canvas->Bind(wxEVT_PAINT, boost::bind(&ContentTimeline::paint_labels, this)); + _main_canvas->Bind (wxEVT_PAINT, boost::bind(&ContentTimeline::paint_main, this)); + _main_canvas->Bind (wxEVT_LEFT_DOWN, boost::bind(&ContentTimeline::left_down, this, _1)); + _main_canvas->Bind (wxEVT_LEFT_UP, boost::bind(&ContentTimeline::left_up, this, _1)); + _main_canvas->Bind (wxEVT_RIGHT_DOWN, boost::bind(&ContentTimeline::right_down, this, _1)); + _main_canvas->Bind (wxEVT_MOTION, boost::bind(&ContentTimeline::mouse_moved, this, _1)); + _main_canvas->Bind (wxEVT_SIZE, boost::bind(&ContentTimeline::resized, this)); + _main_canvas->Bind (wxEVT_MOUSEWHEEL, boost::bind(&ContentTimeline::mouse_wheel_turned, this, _1)); + _main_canvas->Bind (wxEVT_SCROLLWIN_TOP, boost::bind(&ContentTimeline::scrolled, this, _1)); + _main_canvas->Bind (wxEVT_SCROLLWIN_BOTTOM, boost::bind(&ContentTimeline::scrolled, this, _1)); + _main_canvas->Bind (wxEVT_SCROLLWIN_LINEUP, boost::bind(&ContentTimeline::scrolled, this, _1)); + _main_canvas->Bind (wxEVT_SCROLLWIN_LINEDOWN, boost::bind(&ContentTimeline::scrolled, this, _1)); + _main_canvas->Bind (wxEVT_SCROLLWIN_PAGEUP, boost::bind(&ContentTimeline::scrolled, this, _1)); + _main_canvas->Bind (wxEVT_SCROLLWIN_PAGEDOWN, boost::bind(&ContentTimeline::scrolled, this, _1)); + _main_canvas->Bind (wxEVT_SCROLLWIN_THUMBTRACK, boost::bind(&ContentTimeline::scrolled, this, _1)); + + film_change(ChangeType::DONE, FilmProperty::CONTENT); + + SetMinSize (wxSize (640, 4 * pixels_per_track() + 96)); + + _film_changed_connection = film->Change.connect(bind(&ContentTimeline::film_change, this, _1, _2)); + _film_content_change_connection = film->ContentChange.connect(bind(&ContentTimeline::film_content_change, this, _1, _3, _4)); + + Bind(wxEVT_TIMER, boost::bind(&ContentTimeline::update_playhead, this)); + _timer.Start (200, wxTIMER_CONTINUOUS); + + setup_scrollbars (); + _labels_canvas->ShowScrollbars (wxSHOW_SB_NEVER, wxSHOW_SB_NEVER); +} + + +void +ContentTimeline::mouse_wheel_turned(wxMouseEvent& event) +{ + auto const rotation = event.GetWheelRotation(); + + if (event.ControlDown()) { + /* On my mouse one click of the scroll wheel is 120, and it's -ve when + * scrolling the wheel towards me. + */ + auto const scale = rotation > 0 ? + (1.0 / (rotation / 90.0)) : + (-rotation / 90.0); + + int before_start_x; + int before_start_y; + _main_canvas->GetViewStart(&before_start_x, &before_start_y); + + auto const before_pps = _pixels_per_second.get_value_or(1); + auto const before_pos = _last_mouse_wheel_x && *_last_mouse_wheel_x == event.GetX() ? + *_last_mouse_wheel_time : + (before_start_x * _x_scroll_rate + event.GetX()) / before_pps; + + set_pixels_per_second(before_pps * scale); + setup_scrollbars(); + + auto after_left = std::max(0.0, before_pos * _pixels_per_second.get_value_or(1) - event.GetX()); + _main_canvas->Scroll(after_left / _x_scroll_rate, before_start_y); + _labels_canvas->Scroll(0, before_start_y); + Refresh(); + + if (!_last_mouse_wheel_x || *_last_mouse_wheel_x != event.GetX()) { + _last_mouse_wheel_x = event.GetX(); + _last_mouse_wheel_time = before_pos; + } + } else if (event.ShiftDown()) { + int before_start_x; + int before_start_y; + _main_canvas->GetViewStart(&before_start_x, &before_start_y); + auto const width = _main_canvas->GetSize().GetWidth(); + _main_canvas->Scroll(std::max(0.0, before_start_x - rotation * 100.0 / width), before_start_y); + } +} + + +void +ContentTimeline::update_playhead() +{ + Refresh (); +} + + +void +ContentTimeline::set_pixels_per_second(double pps) +{ + _pixels_per_second = max (_minimum_pixels_per_second, pps); +} + + +void +ContentTimeline::paint_labels() +{ + wxPaintDC dc (_labels_canvas); + + auto film = _film.lock(); + if (film->content().empty()) { + return; + } + + auto gc = wxGraphicsContext::Create (dc); + if (!gc) { + return; + } + + dcp::ScopeGuard sg = [gc]() { delete gc; }; + + int vsx, vsy; + _labels_canvas->GetViewStart (&vsx, &vsy); + gc->Translate (-vsx * _x_scroll_rate, -vsy * _y_scroll_rate + tracks_y_offset()); + + _labels_view->paint (gc, {}); +} + + +void +ContentTimeline::paint_main() +{ + wxPaintDC dc (_main_canvas); + dc.Clear(); + + auto film = _film.lock(); + if (film->content().empty()) { + return; + } + + _main_canvas->DoPrepareDC (dc); + + auto gc = wxGraphicsContext::Create (dc); + if (!gc) { + return; + } + + dcp::ScopeGuard sg = [gc]() { delete gc; }; + + gc->SetAntialiasMode (wxANTIALIAS_DEFAULT); + + for (auto i: _views) { + + auto ic = dynamic_pointer_cast (i); + + /* Find areas of overlap with other content views, so that we can plot them */ + list> overlaps; + for (auto j: _views) { + auto jc = dynamic_pointer_cast (j); + /* 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; + } + + auto r = j->bbox().intersection(i->bbox()); + if (r) { + overlaps.push_back (r.get ()); + } + } + + i->paint (gc, overlaps); + } + + if (_zoom_point) { + gc->SetPen(gui_is_dark() ? *wxWHITE_PEN : *wxBLACK_PEN); + gc->SetBrush (*wxTRANSPARENT_BRUSH); + gc->DrawRectangle ( + min (_down_point.x, _zoom_point->x), + min (_down_point.y, _zoom_point->y), + abs (_down_point.x - _zoom_point->x), + abs (_down_point.y - _zoom_point->y) + ); + } + + /* Playhead */ + + gc->SetPen (*wxRED_PEN); + auto path = gc->CreatePath (); + 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); +} + + +void +ContentTimeline::film_change(ChangeType type, FilmProperty p) +{ + if (type != ChangeType::DONE) { + return; + } + + if (p == FilmProperty::CONTENT || p == FilmProperty::REEL_TYPE || p == FilmProperty::REEL_LENGTH) { + ensure_ui_thread (); + recreate_views (); + } else if (p == FilmProperty::CONTENT_ORDER) { + Refresh (); + } +} + + +void +ContentTimeline::recreate_views() +{ + auto film = _film.lock (); + if (!film) { + return; + } + + _views.clear (); + _views.push_back (_time_axis_view); + _views.push_back (_reels_view); + + for (auto i: film->content ()) { + if (i->video) { + _views.push_back (make_shared(*this, i)); + } + + if (i->audio && !i->audio->mapping().mapped_output_channels().empty ()) { + _views.push_back (make_shared(*this, i)); + } + + for (auto j: i->text) { + _views.push_back (make_shared(*this, i, j)); + } + + if (i->atmos) { + _views.push_back (make_shared(*this, i)); + } + } + + assign_tracks (); + setup_scrollbars (); + Refresh (); +} + + +void +ContentTimeline::film_content_change(ChangeType type, int property, bool frequent) +{ + if (type != ChangeType::DONE) { + return; + } + + ensure_ui_thread (); + + if (property == AudioContentProperty::STREAMS || property == VideoContentProperty::FRAME_TYPE) { + recreate_views (); + } else if (property == ContentProperty::POSITION || property == ContentProperty::LENGTH) { + _reels_view->force_redraw (); + } else if (!frequent) { + setup_scrollbars (); + Refresh (); + } +} + + +template +int +place (shared_ptr film, TimelineViewList& views, int& tracks) +{ + int const base = tracks; + + for (auto i: views) { + if (!dynamic_pointer_cast(i)) { + continue; + } + + auto cv = dynamic_pointer_cast (i); + DCPOMATIC_ASSERT(cv); + + int t = base; + + auto content = cv->content(); + DCPTimePeriod const content_period = content->period(film); + + while (true) { + auto j = views.begin(); + while (j != views.end()) { + auto test = dynamic_pointer_cast (*j); + if (!test) { + ++j; + continue; + } + + auto test_content = test->content(); + if ( + test->track() && test->track().get() == t && + content_period.overlap(test_content->period(film)) + ) { + /* we have an overlap on track `t' */ + ++t; + break; + } + + ++j; + } + + if (j == views.end ()) { + /* no overlap on `t' */ + break; + } + } + + cv->set_track (t); + tracks = max (tracks, t + 1); + } + + return tracks - base; +} + + +/** Compare the mapped output channels of two TimelineViews, so we can into + * order of first mapped DCP channel. + */ +struct AudioMappingComparator { + bool operator()(shared_ptr a, shared_ptr b) { + int la = -1; + auto cva = dynamic_pointer_cast(a); + if (cva) { + auto oc = cva->content()->audio->mapping().mapped_output_channels(); + la = *min_element(boost::begin(oc), boost::end(oc)); + } + int lb = -1; + auto cvb = dynamic_pointer_cast(b); + if (cvb) { + auto oc = cvb->content()->audio->mapping().mapped_output_channels(); + lb = *min_element(boost::begin(oc), boost::end(oc)); + } + return la < lb; + } +}; + + +void +ContentTimeline::assign_tracks() +{ + /* Tracks are: + Video 1 + Video 2 + Video N + Text 1 + Text 2 + Text N + Atmos + Audio 1 + Audio 2 + Audio N + */ + + auto film = _film.lock (); + DCPOMATIC_ASSERT (film); + + _tracks = 0; + + for (auto i: _views) { + auto c = dynamic_pointer_cast(i); + if (c) { + c->unset_track (); + } + } + + int const video_tracks = place (film, _views, _tracks); + int const text_tracks = place (film, _views, _tracks); + + /* Atmos */ + + bool have_atmos = false; + for (auto i: _views) { + auto cv = dynamic_pointer_cast(i); + if (cv) { + cv->set_track (_tracks); + have_atmos = true; + } + } + + if (have_atmos) { + ++_tracks; + } + + /* Audio. We're sorting the views so that we get the audio views in order of increasing + DCP channel index. + */ + + auto views = _views; + sort(views.begin(), views.end(), AudioMappingComparator()); + int const audio_tracks = place (film, views, _tracks); + + _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); + + _time_axis_view->set_y (tracks()); + _reels_view->set_y (8); +} + + +int +ContentTimeline::tracks() const +{ + return _tracks; +} + + +void +ContentTimeline::setup_scrollbars() +{ + auto film = _film.lock (); + if (!film || !_pixels_per_second) { + return; + } + + int const h = tracks() * pixels_per_track() + tracks_y_offset() + _time_axis_view->bbox().height; + + _labels_canvas->SetVirtualSize (_labels_view->bbox().width, h); + _labels_canvas->SetScrollRate (_x_scroll_rate, _y_scroll_rate); + _main_canvas->SetVirtualSize (*_pixels_per_second * film->length().seconds(), h); + _main_canvas->SetScrollRate (_x_scroll_rate, _y_scroll_rate); +} + + +shared_ptr +ContentTimeline::event_to_view(wxMouseEvent& ev) +{ + /* Search backwards through views so that we find the uppermost one first */ + auto i = _views.rbegin(); + + int vsx, vsy; + _main_canvas->GetViewStart (&vsx, &vsy); + Position const p (ev.GetX() + vsx * _x_scroll_rate, ev.GetY() + vsy * _y_scroll_rate); + + while (i != _views.rend() && !(*i)->bbox().contains (p)) { + ++i; + } + + if (i == _views.rend ()) { + return {}; + } + + return *i; +} + + +void +ContentTimeline::left_down(wxMouseEvent& ev) +{ + _left_down = true; + _down_point = ev.GetPosition (); + + switch (_tool) { + case SELECT: + left_down_select (ev); + break; + case ZOOM: + case ZOOM_ALL: + case SNAP: + case SEQUENCE: + /* Nothing to do */ + break; + } +} + + +void +ContentTimeline::left_down_select(wxMouseEvent& ev) +{ + auto view = event_to_view (ev); + auto content_view = dynamic_pointer_cast(view); + + _down_view.reset (); + + if (content_view) { + _down_view = content_view; + _down_view_position = content_view->content()->position (); + } + + if (dynamic_pointer_cast(view)) { + int vsx, vsy; + _main_canvas->GetViewStart(&vsx, &vsy); + _viewer.seek(DCPTime::from_seconds((ev.GetPosition().x + vsx * _x_scroll_rate) / _pixels_per_second.get_value_or(1)), true); + } + + for (auto i: _views) { + auto cv = dynamic_pointer_cast(i); + if (!cv) { + continue; + } + + if (!ev.ShiftDown ()) { + cv->set_selected (view == i); + } + } + + if (content_view && ev.ShiftDown ()) { + content_view->set_selected (!content_view->selected ()); + } + + _first_move = false; + + if (_down_view) { + /* Pre-compute the points that we might snap to */ + for (auto i: _views) { + auto cv = dynamic_pointer_cast(i); + if (!cv || cv == _down_view || cv->content() == _down_view->content()) { + continue; + } + + auto film = _film.lock (); + DCPOMATIC_ASSERT (film); + + _start_snaps.push_back (cv->content()->position()); + _end_snaps.push_back (cv->content()->position()); + _start_snaps.push_back (cv->content()->end(film)); + _end_snaps.push_back (cv->content()->end(film)); + + for (auto i: cv->content()->reel_split_points(film)) { + _start_snaps.push_back (i); + } + } + + /* Tell everyone that things might change frequently during the drag */ + _down_view->content()->set_change_signals_frequent (true); + } +} + + +void +ContentTimeline::left_up(wxMouseEvent& ev) +{ + _left_down = false; + + switch (_tool) { + case SELECT: + left_up_select (ev); + break; + case ZOOM: + left_up_zoom (ev); + break; + case ZOOM_ALL: + case SNAP: + case SEQUENCE: + break; + } +} + + +void +ContentTimeline::left_up_select(wxMouseEvent& ev) +{ + if (_down_view) { + _down_view->content()->set_change_signals_frequent (false); + } + + _content_panel->set_selection (selected_content ()); + /* Since we may have just set change signals back to `not-frequent', we have to + make sure this position change is signalled, even if the position value has + not changed since the last time it was set (with frequent=true). This is + a bit of a hack. + */ + set_position_from_event (ev, true); + + /* Clear up up the stuff we don't do during drag */ + assign_tracks (); + setup_scrollbars (); + Refresh (); + + _start_snaps.clear (); + _end_snaps.clear (); +} + + +void +ContentTimeline::left_up_zoom(wxMouseEvent& ev) +{ + _zoom_point = ev.GetPosition (); + + int vsx, vsy; + _main_canvas->GetViewStart (&vsx, &vsy); + + wxPoint top_left(min(_down_point.x, _zoom_point->x), min(_down_point.y, _zoom_point->y)); + wxPoint bottom_right(max(_down_point.x, _zoom_point->x), max(_down_point.y, _zoom_point->y)); + + 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; + } + + auto const time_left = DCPTime::from_seconds((top_left.x + vsx) / *_pixels_per_second); + auto const time_right = DCPTime::from_seconds((bottom_right.x + vsx) / *_pixels_per_second); + set_pixels_per_second (double(GetSize().GetWidth()) / (time_right.seconds() - time_left.seconds())); + + double const tracks_top = double(top_left.y - tracks_y_offset()) / _pixels_per_track; + double const tracks_bottom = double(bottom_right.y - tracks_y_offset()) / _pixels_per_track; + set_pixels_per_track (lrint(GetSize().GetHeight() / (tracks_bottom - tracks_top))); + + setup_scrollbars (); + int const y = (tracks_top * _pixels_per_track + tracks_y_offset()) / _y_scroll_rate; + _main_canvas->Scroll (time_left.seconds() * *_pixels_per_second / _x_scroll_rate, y); + _labels_canvas->Scroll (0, y); + + _zoom_point = optional (); + Refresh (); +} + + +void +ContentTimeline::set_pixels_per_track(int h) +{ + _pixels_per_track = max(_minimum_pixels_per_track, h); +} + + +void +ContentTimeline::mouse_moved(wxMouseEvent& ev) +{ + switch (_tool) { + case SELECT: + mouse_moved_select (ev); + break; + case ZOOM: + mouse_moved_zoom (ev); + break; + case ZOOM_ALL: + case SNAP: + case SEQUENCE: + break; + } +} + + +void +ContentTimeline::mouse_moved_select(wxMouseEvent& ev) +{ + if (!_left_down) { + return; + } + + set_position_from_event (ev); +} + + +void +ContentTimeline::mouse_moved_zoom(wxMouseEvent& ev) +{ + if (!_left_down) { + return; + } + + _zoom_point = ev.GetPosition (); + setup_scrollbars(); + Refresh (); +} + + +void +ContentTimeline::right_down(wxMouseEvent& ev) +{ + switch (_tool) { + case SELECT: + right_down_select (ev); + break; + case ZOOM: + /* Zoom out */ + set_pixels_per_second (*_pixels_per_second / 2); + set_pixels_per_track (_pixels_per_track / 2); + setup_scrollbars (); + Refresh (); + break; + case ZOOM_ALL: + case SNAP: + case SEQUENCE: + break; + } +} + + +void +ContentTimeline::right_down_select(wxMouseEvent& ev) +{ + auto view = event_to_view (ev); + auto cv = dynamic_pointer_cast (view); + if (!cv) { + return; + } + + if (!cv->selected ()) { + clear_selection (); + cv->set_selected (true); + } + + _menu.popup (_film, selected_content (), selected_views (), ev.GetPosition ()); +} + + +void +ContentTimeline::maybe_snap(DCPTime a, DCPTime b, optional& nearest_distance) const +{ + auto const d = a - b; + if (!nearest_distance || d.abs() < nearest_distance.get().abs()) { + nearest_distance = d; + } +} + + +void +ContentTimeline::set_position_from_event(wxMouseEvent& ev, bool force_emit) +{ + if (!_pixels_per_second) { + return; + } + + double const pps = _pixels_per_second.get (); + + auto const p = ev.GetPosition(); + + if (!_first_move) { + /* We haven't moved yet; in that case, we must move the mouse some reasonable distance + before the drag is considered to have started. + */ + int const dist = sqrt (pow (p.x - _down_point.x, 2) + pow (p.y - _down_point.y, 2)); + if (dist < 8) { + return; + } + _first_move = true; + } + + if (!_down_view) { + return; + } + + auto new_position = _down_view_position + DCPTime::from_seconds ((p.x - _down_point.x) / pps); + + auto film = _film.lock (); + DCPOMATIC_ASSERT (film); + + if (_snap) { + auto const new_end = new_position + _down_view->content()->length_after_trim(film); + /* Signed `distance' to nearest thing (i.e. negative is left on the timeline, + positive is right). + */ + optional nearest_distance; + + /* Find the nearest snap point */ + + for (auto i: _start_snaps) { + maybe_snap (i, new_position, nearest_distance); + } + + for (auto i: _end_snaps) { + maybe_snap (i, new_end, nearest_distance); + } + + if (nearest_distance) { + /* Snap if it's close; `close' means within a proportion of the time on the timeline */ + if (nearest_distance.get().abs() < DCPTime::from_seconds ((width() / pps) / 64)) { + new_position += nearest_distance.get (); + } + } + } + + if (new_position < DCPTime ()) { + new_position = DCPTime (); + } + + _down_view->content()->set_position (film, new_position, force_emit); + + film->set_sequence (false); +} + + +void +ContentTimeline::force_redraw(dcpomatic::Rect const & r) +{ + _main_canvas->RefreshRect (wxRect (r.x, r.y, r.width, r.height), false); +} + + +shared_ptr +ContentTimeline::film() const +{ + return _film.lock (); +} + + +void +ContentTimeline::resized() +{ + if (_main_canvas->GetSize().GetWidth() > 0 && _first_resize) { + zoom_all (); + _first_resize = false; + } + setup_scrollbars (); +} + + +void +ContentTimeline::clear_selection() +{ + for (auto i: _views) { + shared_ptr cv = dynamic_pointer_cast(i); + if (cv) { + cv->set_selected (false); + } + } +} + + +TimelineContentViewList +ContentTimeline::selected_views() const +{ + TimelineContentViewList sel; + + for (auto i: _views) { + auto cv = dynamic_pointer_cast(i); + if (cv && cv->selected()) { + sel.push_back (cv); + } + } + + return sel; +} + + +ContentList +ContentTimeline::selected_content() const +{ + ContentList sel; + + for (auto i: selected_views()) { + sel.push_back(i->content()); + } + + return sel; +} + + +void +ContentTimeline::set_selection(ContentList selection) +{ + for (auto i: _views) { + auto cv = dynamic_pointer_cast (i); + if (cv) { + cv->set_selected (find (selection.begin(), selection.end(), cv->content ()) != selection.end ()); + } + } +} + + +int +ContentTimeline::tracks_y_offset() const +{ + return _reels_view->bbox().height + 4; +} + + +int +ContentTimeline::width() const +{ + return _main_canvas->GetVirtualSize().GetWidth(); +} + + +void +ContentTimeline::scrolled(wxScrollWinEvent& ev) +{ + if (ev.GetOrientation() == wxVERTICAL) { + int x, y; + _main_canvas->GetViewStart (&x, &y); + _labels_canvas->Scroll (0, y); + } + ev.Skip (); +} + + +void +ContentTimeline::tool_clicked(Tool t) +{ + switch (t) { + case ZOOM: + case SELECT: + _tool = t; + break; + case ZOOM_ALL: + zoom_all (); + break; + case SNAP: + case SEQUENCE: + break; + } +} + + +void +ContentTimeline::zoom_all() +{ + auto film = _film.lock (); + DCPOMATIC_ASSERT (film); + set_pixels_per_second((_main_canvas->GetSize().GetWidth() - 32) / std::max(1.0, film->length().seconds())); + set_pixels_per_track((_main_canvas->GetSize().GetHeight() - tracks_y_offset() - _time_axis_view->bbox().height - 32) / std::max(1, _tracks)); + setup_scrollbars (); + _main_canvas->Scroll (0, 0); + _labels_canvas->Scroll (0, 0); + Refresh (); +} + + +void +ContentTimeline::keypress(wxKeyEvent const& event) +{ + if (event.GetKeyCode() == WXK_DELETE) { + auto film = _film.lock(); + DCPOMATIC_ASSERT(film); + film->remove_content(selected_content()); + } else { + switch (event.GetRawKeyCode()) { + case '+': + set_pixels_per_second(_pixels_per_second.get_value_or(1) * 2); + setup_scrollbars(); + break; + case '-': + set_pixels_per_second(_pixels_per_second.get_value_or(1) / 2); + setup_scrollbars(); + break; + } + } +} + diff --git a/src/wx/content_timeline.h b/src/wx/content_timeline.h new file mode 100644 index 000000000..65b2ff956 --- /dev/null +++ b/src/wx/content_timeline.h @@ -0,0 +1,155 @@ +/* + Copyright (C) 2013-2019 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "content_menu.h" +#include "timeline_content_view.h" +#include "lib/film_property.h" +#include "lib/rect.h" +#include +LIBDCP_DISABLE_WARNINGS +#include +LIBDCP_ENABLE_WARNINGS +#include + + +class ContentPanel; +class Film; +class FilmViewer; +class TimelineLabelsView; +class TimelineReelsView; +class TimelineTimeAxisView; +class TimelineView; + + +class ContentTimeline : public wxPanel +{ +public: + ContentTimeline(wxWindow *, ContentPanel *, std::shared_ptr, FilmViewer& viewer); + + std::shared_ptr film () const; + + void force_redraw (dcpomatic::Rect const &); + + int width () const; + + int pixels_per_track () const { + return _pixels_per_track; + } + + boost::optional pixels_per_second () const { + return _pixels_per_second; + } + + int tracks () const; + + void set_snap (bool s) { + _snap = s; + } + + bool snap () const { + return _snap; + } + + void set_selection (ContentList selection); + + enum Tool { + SELECT, + ZOOM, + ZOOM_ALL, + SNAP, + SEQUENCE + }; + + void tool_clicked (Tool t); + + int tracks_y_offset () const; + + void keypress(wxKeyEvent const &); + +private: + void paint_labels (); + void paint_main (); + void left_down (wxMouseEvent &); + void left_down_select (wxMouseEvent &); + void left_up (wxMouseEvent &); + void left_up_select (wxMouseEvent &); + void left_up_zoom (wxMouseEvent &); + void right_down (wxMouseEvent &); + void right_down_select (wxMouseEvent &); + void mouse_moved (wxMouseEvent &); + void mouse_moved_select (wxMouseEvent &); + void mouse_moved_zoom (wxMouseEvent &); + void film_change(ChangeType type, FilmProperty); + void film_content_change (ChangeType type, int, bool frequent); + void resized (); + void assign_tracks (); + void set_position_from_event (wxMouseEvent& ev, bool force_emit = false); + void clear_selection (); + void recreate_views (); + void setup_scrollbars (); + void scrolled (wxScrollWinEvent& ev); + void set_pixels_per_second (double pps); + void set_pixels_per_track (int h); + void zoom_all (); + void update_playhead (); + void mouse_wheel_turned(wxMouseEvent& event); + + std::shared_ptr event_to_view (wxMouseEvent &); + TimelineContentViewList selected_views () const; + ContentList selected_content () const; + void maybe_snap (dcpomatic::DCPTime a, dcpomatic::DCPTime b, boost::optional& nearest_distance) const; + + wxScrolledCanvas* _labels_canvas; + wxScrolledCanvas* _main_canvas; + ContentPanel* _content_panel; + std::weak_ptr _film; + FilmViewer& _viewer; + TimelineViewList _views; + std::shared_ptr _time_axis_view; + std::shared_ptr _reels_view; + std::shared_ptr _labels_view; + int _tracks; + boost::optional _pixels_per_second; + bool _left_down; + wxPoint _down_point; + boost::optional _zoom_point; + std::shared_ptr _down_view; + dcpomatic::DCPTime _down_view_position; + bool _first_move; + ContentMenu _menu; + bool _snap; + std::list _start_snaps; + std::list _end_snaps; + Tool _tool; + int _x_scroll_rate; + int _y_scroll_rate; + int _pixels_per_track; + bool _first_resize; + wxTimer _timer; + boost::optional _last_mouse_wheel_x; + boost::optional _last_mouse_wheel_time; + + static double const _minimum_pixels_per_second; + static int const _minimum_pixels_per_track; + + boost::signals2::scoped_connection _film_changed_connection; + boost::signals2::scoped_connection _film_content_change_connection; +}; diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc deleted file mode 100644 index 38e9de4ee..000000000 --- a/src/wx/timeline.cc +++ /dev/null @@ -1,1029 +0,0 @@ -/* - Copyright (C) 2013-2021 Carl Hetherington - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see . - -*/ - -#include "content_panel.h" -#include "film_editor.h" -#include "film_viewer.h" -#include "timeline.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_time_axis_view.h" -#include "timeline_video_content_view.h" -#include "wx_util.h" -#include "lib/atmos_mxf_content.h" -#include "lib/audio_content.h" -#include "lib/film.h" -#include "lib/image_content.h" -#include "lib/playlist.h" -#include "lib/text_content.h" -#include "lib/timer.h" -#include "lib/video_content.h" -#include -#include -LIBDCP_DISABLE_WARNINGS -#include -LIBDCP_ENABLE_WARNINGS -#include -#include - - -using std::abs; -using std::dynamic_pointer_cast; -using std::list; -using std::make_shared; -using std::max; -using std::min; -using std::shared_ptr; -using std::weak_ptr; -using boost::bind; -using boost::optional; -using namespace dcpomatic; -#if BOOST_VERSION >= 106100 -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, 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)) - , _content_panel (cp) - , _film (film) - , _viewer (viewer) - , _time_axis_view (new TimelineTimeAxisView (*this, 64)) - , _reels_view (new TimelineReelsView (*this, 32)) - , _labels_view (new TimelineLabelsView (*this)) - , _tracks (0) - , _left_down (false) - , _down_view_position (0) - , _first_move (false) - , _menu (this, viewer) - , _snap (true) - , _tool (SELECT) - , _x_scroll_rate (16) - , _y_scroll_rate (16) - , _pixels_per_track (48) - , _first_resize (true) - , _timer (this) -{ -#ifndef __WXOSX__ - _labels_canvas->SetDoubleBuffered (true); - _main_canvas->SetDoubleBuffered (true); -#endif - - auto sizer = new wxBoxSizer (wxHORIZONTAL); - sizer->Add (_labels_canvas, 0, wxEXPAND); - _labels_canvas->SetMinSize (wxSize (_labels_view->bbox().width, -1)); - sizer->Add (_main_canvas, 1, wxEXPAND); - SetSizer (sizer); - - _labels_canvas->Bind (wxEVT_PAINT, boost::bind (&Timeline::paint_labels, this)); - _main_canvas->Bind (wxEVT_PAINT, boost::bind (&Timeline::paint_main, this)); - _main_canvas->Bind (wxEVT_LEFT_DOWN, boost::bind (&Timeline::left_down, this, _1)); - _main_canvas->Bind (wxEVT_LEFT_UP, boost::bind (&Timeline::left_up, this, _1)); - _main_canvas->Bind (wxEVT_RIGHT_DOWN, boost::bind (&Timeline::right_down, this, _1)); - _main_canvas->Bind (wxEVT_MOTION, boost::bind (&Timeline::mouse_moved, this, _1)); - _main_canvas->Bind (wxEVT_SIZE, boost::bind (&Timeline::resized, this)); - _main_canvas->Bind (wxEVT_MOUSEWHEEL, boost::bind(&Timeline::mouse_wheel_turned, this, _1)); - _main_canvas->Bind (wxEVT_SCROLLWIN_TOP, boost::bind (&Timeline::scrolled, this, _1)); - _main_canvas->Bind (wxEVT_SCROLLWIN_BOTTOM, boost::bind (&Timeline::scrolled, this, _1)); - _main_canvas->Bind (wxEVT_SCROLLWIN_LINEUP, boost::bind (&Timeline::scrolled, this, _1)); - _main_canvas->Bind (wxEVT_SCROLLWIN_LINEDOWN, boost::bind (&Timeline::scrolled, this, _1)); - _main_canvas->Bind (wxEVT_SCROLLWIN_PAGEUP, boost::bind (&Timeline::scrolled, this, _1)); - _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(ChangeType::DONE, FilmProperty::CONTENT); - - SetMinSize (wxSize (640, 4 * pixels_per_track() + 96)); - - _film_changed_connection = film->Change.connect (bind (&Timeline::film_change, this, _1, _2)); - _film_content_change_connection = film->ContentChange.connect (bind (&Timeline::film_content_change, this, _1, _3, _4)); - - Bind (wxEVT_TIMER, boost::bind(&Timeline::update_playhead, this)); - _timer.Start (200, wxTIMER_CONTINUOUS); - - setup_scrollbars (); - _labels_canvas->ShowScrollbars (wxSHOW_SB_NEVER, wxSHOW_SB_NEVER); -} - - -void -Timeline::mouse_wheel_turned(wxMouseEvent& event) -{ - auto const rotation = event.GetWheelRotation(); - - if (event.ControlDown()) { - /* On my mouse one click of the scroll wheel is 120, and it's -ve when - * scrolling the wheel towards me. - */ - auto const scale = rotation > 0 ? - (1.0 / (rotation / 90.0)) : - (-rotation / 90.0); - - int before_start_x; - int before_start_y; - _main_canvas->GetViewStart(&before_start_x, &before_start_y); - - auto const before_pps = _pixels_per_second.get_value_or(1); - auto const before_pos = _last_mouse_wheel_x && *_last_mouse_wheel_x == event.GetX() ? - *_last_mouse_wheel_time : - (before_start_x * _x_scroll_rate + event.GetX()) / before_pps; - - set_pixels_per_second(before_pps * scale); - setup_scrollbars(); - - auto after_left = std::max(0.0, before_pos * _pixels_per_second.get_value_or(1) - event.GetX()); - _main_canvas->Scroll(after_left / _x_scroll_rate, before_start_y); - _labels_canvas->Scroll(0, before_start_y); - Refresh(); - - if (!_last_mouse_wheel_x || *_last_mouse_wheel_x != event.GetX()) { - _last_mouse_wheel_x = event.GetX(); - _last_mouse_wheel_time = before_pos; - } - } else if (event.ShiftDown()) { - int before_start_x; - int before_start_y; - _main_canvas->GetViewStart(&before_start_x, &before_start_y); - auto const width = _main_canvas->GetSize().GetWidth(); - _main_canvas->Scroll(std::max(0.0, before_start_x - rotation * 100.0 / width), before_start_y); - } -} - - -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 () -{ - wxPaintDC dc (_labels_canvas); - - auto film = _film.lock(); - if (film->content().empty()) { - return; - } - - auto gc = wxGraphicsContext::Create (dc); - if (!gc) { - return; - } - - dcp::ScopeGuard sg = [gc]() { delete gc; }; - - int vsx, vsy; - _labels_canvas->GetViewStart (&vsx, &vsy); - gc->Translate (-vsx * _x_scroll_rate, -vsy * _y_scroll_rate + tracks_y_offset()); - - _labels_view->paint (gc, {}); -} - - -void -Timeline::paint_main () -{ - wxPaintDC dc (_main_canvas); - dc.Clear(); - - auto film = _film.lock(); - if (film->content().empty()) { - return; - } - - _main_canvas->DoPrepareDC (dc); - - auto gc = wxGraphicsContext::Create (dc); - if (!gc) { - return; - } - - dcp::ScopeGuard sg = [gc]() { delete gc; }; - - gc->SetAntialiasMode (wxANTIALIAS_DEFAULT); - - for (auto i: _views) { - - auto ic = dynamic_pointer_cast (i); - - /* Find areas of overlap with other content views, so that we can plot them */ - list> overlaps; - for (auto j: _views) { - auto jc = dynamic_pointer_cast (j); - /* 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; - } - - auto r = j->bbox().intersection(i->bbox()); - if (r) { - overlaps.push_back (r.get ()); - } - } - - i->paint (gc, overlaps); - } - - if (_zoom_point) { - gc->SetPen(gui_is_dark() ? *wxWHITE_PEN : *wxBLACK_PEN); - gc->SetBrush (*wxTRANSPARENT_BRUSH); - gc->DrawRectangle ( - min (_down_point.x, _zoom_point->x), - min (_down_point.y, _zoom_point->y), - abs (_down_point.x - _zoom_point->x), - abs (_down_point.y - _zoom_point->y) - ); - } - - /* Playhead */ - - gc->SetPen (*wxRED_PEN); - auto path = gc->CreatePath (); - 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); -} - - -void -Timeline::film_change(ChangeType type, FilmProperty p) -{ - if (type != ChangeType::DONE) { - return; - } - - if (p == FilmProperty::CONTENT || p == FilmProperty::REEL_TYPE || p == FilmProperty::REEL_LENGTH) { - ensure_ui_thread (); - recreate_views (); - } else if (p == FilmProperty::CONTENT_ORDER) { - Refresh (); - } -} - - -void -Timeline::recreate_views () -{ - auto film = _film.lock (); - if (!film) { - return; - } - - _views.clear (); - _views.push_back (_time_axis_view); - _views.push_back (_reels_view); - - for (auto i: film->content ()) { - if (i->video) { - _views.push_back (make_shared(*this, i)); - } - - if (i->audio && !i->audio->mapping().mapped_output_channels().empty ()) { - _views.push_back (make_shared(*this, i)); - } - - for (auto j: i->text) { - _views.push_back (make_shared(*this, i, j)); - } - - if (i->atmos) { - _views.push_back (make_shared(*this, i)); - } - } - - assign_tracks (); - setup_scrollbars (); - Refresh (); -} - - -void -Timeline::film_content_change (ChangeType type, int property, bool frequent) -{ - if (type != ChangeType::DONE) { - return; - } - - ensure_ui_thread (); - - if (property == AudioContentProperty::STREAMS || property == VideoContentProperty::FRAME_TYPE) { - recreate_views (); - } else if (property == ContentProperty::POSITION || property == ContentProperty::LENGTH) { - _reels_view->force_redraw (); - } else if (!frequent) { - setup_scrollbars (); - Refresh (); - } -} - - -template -int -place (shared_ptr film, TimelineViewList& views, int& tracks) -{ - int const base = tracks; - - for (auto i: views) { - if (!dynamic_pointer_cast(i)) { - continue; - } - - auto cv = dynamic_pointer_cast (i); - DCPOMATIC_ASSERT(cv); - - int t = base; - - auto content = cv->content(); - DCPTimePeriod const content_period = content->period(film); - - while (true) { - auto j = views.begin(); - while (j != views.end()) { - auto test = dynamic_pointer_cast (*j); - if (!test) { - ++j; - continue; - } - - auto test_content = test->content(); - if ( - test->track() && test->track().get() == t && - content_period.overlap(test_content->period(film)) - ) { - /* we have an overlap on track `t' */ - ++t; - break; - } - - ++j; - } - - if (j == views.end ()) { - /* no overlap on `t' */ - break; - } - } - - cv->set_track (t); - tracks = max (tracks, t + 1); - } - - return tracks - base; -} - - -/** Compare the mapped output channels of two TimelineViews, so we can into - * order of first mapped DCP channel. - */ -struct AudioMappingComparator { - bool operator()(shared_ptr a, shared_ptr b) { - int la = -1; - auto cva = dynamic_pointer_cast(a); - if (cva) { - auto oc = cva->content()->audio->mapping().mapped_output_channels(); - la = *min_element(boost::begin(oc), boost::end(oc)); - } - int lb = -1; - auto cvb = dynamic_pointer_cast(b); - if (cvb) { - auto oc = cvb->content()->audio->mapping().mapped_output_channels(); - lb = *min_element(boost::begin(oc), boost::end(oc)); - } - return la < lb; - } -}; - - -void -Timeline::assign_tracks () -{ - /* Tracks are: - Video 1 - Video 2 - Video N - Text 1 - Text 2 - Text N - Atmos - Audio 1 - Audio 2 - Audio N - */ - - auto film = _film.lock (); - DCPOMATIC_ASSERT (film); - - _tracks = 0; - - for (auto i: _views) { - auto c = dynamic_pointer_cast(i); - if (c) { - c->unset_track (); - } - } - - int const video_tracks = place (film, _views, _tracks); - int const text_tracks = place (film, _views, _tracks); - - /* Atmos */ - - bool have_atmos = false; - for (auto i: _views) { - auto cv = dynamic_pointer_cast(i); - if (cv) { - cv->set_track (_tracks); - have_atmos = true; - } - } - - if (have_atmos) { - ++_tracks; - } - - /* Audio. We're sorting the views so that we get the audio views in order of increasing - DCP channel index. - */ - - auto views = _views; - sort(views.begin(), views.end(), AudioMappingComparator()); - int const audio_tracks = place (film, views, _tracks); - - _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); - - _time_axis_view->set_y (tracks()); - _reels_view->set_y (8); -} - - -int -Timeline::tracks () const -{ - return _tracks; -} - - -void -Timeline::setup_scrollbars () -{ - auto film = _film.lock (); - if (!film || !_pixels_per_second) { - return; - } - - int const h = tracks() * pixels_per_track() + tracks_y_offset() + _time_axis_view->bbox().height; - - _labels_canvas->SetVirtualSize (_labels_view->bbox().width, h); - _labels_canvas->SetScrollRate (_x_scroll_rate, _y_scroll_rate); - _main_canvas->SetVirtualSize (*_pixels_per_second * film->length().seconds(), h); - _main_canvas->SetScrollRate (_x_scroll_rate, _y_scroll_rate); -} - - -shared_ptr -Timeline::event_to_view (wxMouseEvent& ev) -{ - /* Search backwards through views so that we find the uppermost one first */ - auto i = _views.rbegin(); - - int vsx, vsy; - _main_canvas->GetViewStart (&vsx, &vsy); - Position const p (ev.GetX() + vsx * _x_scroll_rate, ev.GetY() + vsy * _y_scroll_rate); - - while (i != _views.rend() && !(*i)->bbox().contains (p)) { - ++i; - } - - if (i == _views.rend ()) { - return {}; - } - - return *i; -} - - -void -Timeline::left_down (wxMouseEvent& ev) -{ - _left_down = true; - _down_point = ev.GetPosition (); - - switch (_tool) { - case SELECT: - left_down_select (ev); - break; - case ZOOM: - case ZOOM_ALL: - case SNAP: - case SEQUENCE: - /* Nothing to do */ - break; - } -} - - -void -Timeline::left_down_select (wxMouseEvent& ev) -{ - auto view = event_to_view (ev); - auto content_view = dynamic_pointer_cast(view); - - _down_view.reset (); - - if (content_view) { - _down_view = content_view; - _down_view_position = content_view->content()->position (); - } - - if (dynamic_pointer_cast(view)) { - int vsx, vsy; - _main_canvas->GetViewStart(&vsx, &vsy); - _viewer.seek(DCPTime::from_seconds((ev.GetPosition().x + vsx * _x_scroll_rate) / _pixels_per_second.get_value_or(1)), true); - } - - for (auto i: _views) { - auto cv = dynamic_pointer_cast(i); - if (!cv) { - continue; - } - - if (!ev.ShiftDown ()) { - cv->set_selected (view == i); - } - } - - if (content_view && ev.ShiftDown ()) { - content_view->set_selected (!content_view->selected ()); - } - - _first_move = false; - - if (_down_view) { - /* Pre-compute the points that we might snap to */ - for (auto i: _views) { - auto cv = dynamic_pointer_cast(i); - if (!cv || cv == _down_view || cv->content() == _down_view->content()) { - continue; - } - - auto film = _film.lock (); - DCPOMATIC_ASSERT (film); - - _start_snaps.push_back (cv->content()->position()); - _end_snaps.push_back (cv->content()->position()); - _start_snaps.push_back (cv->content()->end(film)); - _end_snaps.push_back (cv->content()->end(film)); - - for (auto i: cv->content()->reel_split_points(film)) { - _start_snaps.push_back (i); - } - } - - /* Tell everyone that things might change frequently during the drag */ - _down_view->content()->set_change_signals_frequent (true); - } -} - - -void -Timeline::left_up (wxMouseEvent& ev) -{ - _left_down = false; - - switch (_tool) { - case SELECT: - left_up_select (ev); - break; - case ZOOM: - left_up_zoom (ev); - break; - case ZOOM_ALL: - case SNAP: - case SEQUENCE: - break; - } -} - - -void -Timeline::left_up_select (wxMouseEvent& ev) -{ - if (_down_view) { - _down_view->content()->set_change_signals_frequent (false); - } - - _content_panel->set_selection (selected_content ()); - /* Since we may have just set change signals back to `not-frequent', we have to - make sure this position change is signalled, even if the position value has - not changed since the last time it was set (with frequent=true). This is - a bit of a hack. - */ - set_position_from_event (ev, true); - - /* Clear up up the stuff we don't do during drag */ - assign_tracks (); - setup_scrollbars (); - Refresh (); - - _start_snaps.clear (); - _end_snaps.clear (); -} - - -void -Timeline::left_up_zoom (wxMouseEvent& ev) -{ - _zoom_point = ev.GetPosition (); - - int vsx, vsy; - _main_canvas->GetViewStart (&vsx, &vsy); - - wxPoint top_left(min(_down_point.x, _zoom_point->x), min(_down_point.y, _zoom_point->y)); - wxPoint bottom_right(max(_down_point.x, _zoom_point->x), max(_down_point.y, _zoom_point->y)); - - 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; - } - - auto const time_left = DCPTime::from_seconds((top_left.x + vsx) / *_pixels_per_second); - auto const time_right = DCPTime::from_seconds((bottom_right.x + vsx) / *_pixels_per_second); - set_pixels_per_second (double(GetSize().GetWidth()) / (time_right.seconds() - time_left.seconds())); - - double const tracks_top = double(top_left.y - tracks_y_offset()) / _pixels_per_track; - double const tracks_bottom = double(bottom_right.y - tracks_y_offset()) / _pixels_per_track; - set_pixels_per_track (lrint(GetSize().GetHeight() / (tracks_bottom - tracks_top))); - - setup_scrollbars (); - int const y = (tracks_top * _pixels_per_track + tracks_y_offset()) / _y_scroll_rate; - _main_canvas->Scroll (time_left.seconds() * *_pixels_per_second / _x_scroll_rate, y); - _labels_canvas->Scroll (0, y); - - _zoom_point = optional (); - Refresh (); -} - - -void -Timeline::set_pixels_per_track (int h) -{ - _pixels_per_track = max(_minimum_pixels_per_track, h); -} - - -void -Timeline::mouse_moved (wxMouseEvent& ev) -{ - switch (_tool) { - case SELECT: - mouse_moved_select (ev); - break; - case ZOOM: - mouse_moved_zoom (ev); - break; - case ZOOM_ALL: - case SNAP: - case SEQUENCE: - break; - } -} - - -void -Timeline::mouse_moved_select (wxMouseEvent& ev) -{ - if (!_left_down) { - return; - } - - set_position_from_event (ev); -} - - -void -Timeline::mouse_moved_zoom (wxMouseEvent& ev) -{ - if (!_left_down) { - return; - } - - _zoom_point = ev.GetPosition (); - setup_scrollbars(); - Refresh (); -} - - -void -Timeline::right_down (wxMouseEvent& ev) -{ - switch (_tool) { - case SELECT: - right_down_select (ev); - break; - case ZOOM: - /* Zoom out */ - set_pixels_per_second (*_pixels_per_second / 2); - set_pixels_per_track (_pixels_per_track / 2); - setup_scrollbars (); - Refresh (); - break; - case ZOOM_ALL: - case SNAP: - case SEQUENCE: - break; - } -} - - -void -Timeline::right_down_select (wxMouseEvent& ev) -{ - auto view = event_to_view (ev); - auto cv = dynamic_pointer_cast (view); - if (!cv) { - return; - } - - if (!cv->selected ()) { - clear_selection (); - cv->set_selected (true); - } - - _menu.popup (_film, selected_content (), selected_views (), ev.GetPosition ()); -} - - -void -Timeline::maybe_snap (DCPTime a, DCPTime b, optional& nearest_distance) const -{ - auto const d = a - b; - if (!nearest_distance || d.abs() < nearest_distance.get().abs()) { - nearest_distance = d; - } -} - - -void -Timeline::set_position_from_event (wxMouseEvent& ev, bool force_emit) -{ - if (!_pixels_per_second) { - return; - } - - double const pps = _pixels_per_second.get (); - - auto const p = ev.GetPosition(); - - if (!_first_move) { - /* We haven't moved yet; in that case, we must move the mouse some reasonable distance - before the drag is considered to have started. - */ - int const dist = sqrt (pow (p.x - _down_point.x, 2) + pow (p.y - _down_point.y, 2)); - if (dist < 8) { - return; - } - _first_move = true; - } - - if (!_down_view) { - return; - } - - auto new_position = _down_view_position + DCPTime::from_seconds ((p.x - _down_point.x) / pps); - - auto film = _film.lock (); - DCPOMATIC_ASSERT (film); - - if (_snap) { - auto const new_end = new_position + _down_view->content()->length_after_trim(film); - /* Signed `distance' to nearest thing (i.e. negative is left on the timeline, - positive is right). - */ - optional nearest_distance; - - /* Find the nearest snap point */ - - for (auto i: _start_snaps) { - maybe_snap (i, new_position, nearest_distance); - } - - for (auto i: _end_snaps) { - maybe_snap (i, new_end, nearest_distance); - } - - if (nearest_distance) { - /* Snap if it's close; `close' means within a proportion of the time on the timeline */ - if (nearest_distance.get().abs() < DCPTime::from_seconds ((width() / pps) / 64)) { - new_position += nearest_distance.get (); - } - } - } - - if (new_position < DCPTime ()) { - new_position = DCPTime (); - } - - _down_view->content()->set_position (film, new_position, 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 () -{ - if (_main_canvas->GetSize().GetWidth() > 0 && _first_resize) { - zoom_all (); - _first_resize = false; - } - setup_scrollbars (); -} - - -void -Timeline::clear_selection () -{ - for (auto i: _views) { - shared_ptr cv = dynamic_pointer_cast(i); - if (cv) { - cv->set_selected (false); - } - } -} - - -TimelineContentViewList -Timeline::selected_views () const -{ - TimelineContentViewList sel; - - for (auto i: _views) { - auto cv = dynamic_pointer_cast(i); - if (cv && cv->selected()) { - sel.push_back (cv); - } - } - - return sel; -} - - -ContentList -Timeline::selected_content () const -{ - ContentList sel; - - for (auto i: selected_views()) { - sel.push_back(i->content()); - } - - return sel; -} - - -void -Timeline::set_selection (ContentList selection) -{ - for (auto i: _views) { - auto cv = dynamic_pointer_cast (i); - if (cv) { - cv->set_selected (find (selection.begin(), selection.end(), cv->content ()) != selection.end ()); - } - } -} - - -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) -{ - if (ev.GetOrientation() == wxVERTICAL) { - int x, y; - _main_canvas->GetViewStart (&x, &y); - _labels_canvas->Scroll (0, y); - } - ev.Skip (); -} - - -void -Timeline::tool_clicked (Tool t) -{ - switch (t) { - case ZOOM: - case SELECT: - _tool = t; - break; - case ZOOM_ALL: - zoom_all (); - break; - case SNAP: - case SEQUENCE: - break; - } -} - - -void -Timeline::zoom_all () -{ - auto film = _film.lock (); - DCPOMATIC_ASSERT (film); - set_pixels_per_second((_main_canvas->GetSize().GetWidth() - 32) / std::max(1.0, film->length().seconds())); - set_pixels_per_track((_main_canvas->GetSize().GetHeight() - tracks_y_offset() - _time_axis_view->bbox().height - 32) / std::max(1, _tracks)); - setup_scrollbars (); - _main_canvas->Scroll (0, 0); - _labels_canvas->Scroll (0, 0); - Refresh (); -} - - -void -Timeline::keypress(wxKeyEvent const& event) -{ - if (event.GetKeyCode() == WXK_DELETE) { - auto film = _film.lock(); - DCPOMATIC_ASSERT(film); - film->remove_content(selected_content()); - } else { - switch (event.GetRawKeyCode()) { - case '+': - set_pixels_per_second(_pixels_per_second.get_value_or(1) * 2); - setup_scrollbars(); - break; - case '-': - set_pixels_per_second(_pixels_per_second.get_value_or(1) / 2); - setup_scrollbars(); - break; - } - } -} - diff --git a/src/wx/timeline.h b/src/wx/timeline.h deleted file mode 100644 index 621609fa7..000000000 --- a/src/wx/timeline.h +++ /dev/null @@ -1,155 +0,0 @@ -/* - Copyright (C) 2013-2019 Carl Hetherington - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see . - -*/ - - -#include "content_menu.h" -#include "timeline_content_view.h" -#include "lib/film_property.h" -#include "lib/rect.h" -#include -LIBDCP_DISABLE_WARNINGS -#include -LIBDCP_ENABLE_WARNINGS -#include - - -class ContentPanel; -class Film; -class FilmViewer; -class TimelineLabelsView; -class TimelineReelsView; -class TimelineTimeAxisView; -class TimelineView; - - -class Timeline : public wxPanel -{ -public: - Timeline (wxWindow *, ContentPanel *, std::shared_ptr, FilmViewer& viewer); - - std::shared_ptr film () const; - - void force_redraw (dcpomatic::Rect const &); - - int width () const; - - int pixels_per_track () const { - return _pixels_per_track; - } - - boost::optional pixels_per_second () const { - return _pixels_per_second; - } - - int tracks () const; - - void set_snap (bool s) { - _snap = s; - } - - bool snap () const { - return _snap; - } - - void set_selection (ContentList selection); - - enum Tool { - SELECT, - ZOOM, - ZOOM_ALL, - SNAP, - SEQUENCE - }; - - void tool_clicked (Tool t); - - int tracks_y_offset () const; - - void keypress(wxKeyEvent const &); - -private: - void paint_labels (); - void paint_main (); - void left_down (wxMouseEvent &); - void left_down_select (wxMouseEvent &); - void left_up (wxMouseEvent &); - void left_up_select (wxMouseEvent &); - void left_up_zoom (wxMouseEvent &); - void right_down (wxMouseEvent &); - void right_down_select (wxMouseEvent &); - void mouse_moved (wxMouseEvent &); - void mouse_moved_select (wxMouseEvent &); - void mouse_moved_zoom (wxMouseEvent &); - void film_change(ChangeType type, FilmProperty); - void film_content_change (ChangeType type, int, bool frequent); - void resized (); - void assign_tracks (); - void set_position_from_event (wxMouseEvent& ev, bool force_emit = false); - void clear_selection (); - void recreate_views (); - void setup_scrollbars (); - void scrolled (wxScrollWinEvent& ev); - void set_pixels_per_second (double pps); - void set_pixels_per_track (int h); - void zoom_all (); - void update_playhead (); - void mouse_wheel_turned(wxMouseEvent& event); - - std::shared_ptr event_to_view (wxMouseEvent &); - TimelineContentViewList selected_views () const; - ContentList selected_content () const; - void maybe_snap (dcpomatic::DCPTime a, dcpomatic::DCPTime b, boost::optional& nearest_distance) const; - - wxScrolledCanvas* _labels_canvas; - wxScrolledCanvas* _main_canvas; - ContentPanel* _content_panel; - std::weak_ptr _film; - FilmViewer& _viewer; - TimelineViewList _views; - std::shared_ptr _time_axis_view; - std::shared_ptr _reels_view; - std::shared_ptr _labels_view; - int _tracks; - boost::optional _pixels_per_second; - bool _left_down; - wxPoint _down_point; - boost::optional _zoom_point; - std::shared_ptr _down_view; - dcpomatic::DCPTime _down_view_position; - bool _first_move; - ContentMenu _menu; - bool _snap; - std::list _start_snaps; - std::list _end_snaps; - Tool _tool; - int _x_scroll_rate; - int _y_scroll_rate; - int _pixels_per_track; - bool _first_resize; - wxTimer _timer; - boost::optional _last_mouse_wheel_x; - boost::optional _last_mouse_wheel_time; - - static double const _minimum_pixels_per_second; - static int const _minimum_pixels_per_track; - - boost::signals2::scoped_connection _film_changed_connection; - boost::signals2::scoped_connection _film_content_change_connection; -}; diff --git a/src/wx/timeline_atmos_content_view.cc b/src/wx/timeline_atmos_content_view.cc index ec0f06ec1..d40ede137 100644 --- a/src/wx/timeline_atmos_content_view.cc +++ b/src/wx/timeline_atmos_content_view.cc @@ -29,7 +29,7 @@ using std::shared_ptr; * @brief Timeline view for AtmosContent. */ -TimelineAtmosContentView::TimelineAtmosContentView (Timeline& tl, shared_ptr c) +TimelineAtmosContentView::TimelineAtmosContentView(ContentTimeline& tl, shared_ptr c) : TimelineContentView (tl, c) { diff --git a/src/wx/timeline_atmos_content_view.h b/src/wx/timeline_atmos_content_view.h index 15da14edc..9536837e0 100644 --- a/src/wx/timeline_atmos_content_view.h +++ b/src/wx/timeline_atmos_content_view.h @@ -28,7 +28,7 @@ class TimelineAtmosContentView : public TimelineContentView { public: - TimelineAtmosContentView (Timeline& tl, std::shared_ptr c); + TimelineAtmosContentView(ContentTimeline& tl, std::shared_ptr c); private: bool active () const override { diff --git a/src/wx/timeline_audio_content_view.cc b/src/wx/timeline_audio_content_view.cc index 057ebb944..2920bf4fd 100644 --- a/src/wx/timeline_audio_content_view.cc +++ b/src/wx/timeline_audio_content_view.cc @@ -18,20 +18,24 @@ */ + #include "timeline_audio_content_view.h" #include "wx_util.h" #include "lib/audio_content.h" #include "lib/util.h" + +using std::dynamic_pointer_cast; using std::list; using std::shared_ptr; -using std::dynamic_pointer_cast; + /** @class TimelineAudioContentView * @brief Timeline view for AudioContent. */ -TimelineAudioContentView::TimelineAudioContentView (Timeline& tl, shared_ptr c) + +TimelineAudioContentView::TimelineAudioContentView(ContentTimeline& tl, shared_ptr c) : TimelineContentView (tl, c) { diff --git a/src/wx/timeline_audio_content_view.h b/src/wx/timeline_audio_content_view.h index 5b8d6cdc2..29849adb2 100644 --- a/src/wx/timeline_audio_content_view.h +++ b/src/wx/timeline_audio_content_view.h @@ -28,7 +28,7 @@ class TimelineAudioContentView : public TimelineContentView { public: - TimelineAudioContentView (Timeline& tl, std::shared_ptr c); + TimelineAudioContentView(ContentTimeline& tl, std::shared_ptr c); private: bool active () const override { diff --git a/src/wx/timeline_content_view.cc b/src/wx/timeline_content_view.cc index 5d039d0d3..05ee6617b 100644 --- a/src/wx/timeline_content_view.cc +++ b/src/wx/timeline_content_view.cc @@ -19,7 +19,7 @@ */ -#include "timeline.h" +#include "content_timeline.h" #include "timeline_content_view.h" #include "wx_util.h" #include "lib/content.h" @@ -37,7 +37,7 @@ using namespace boost::placeholders; #endif -TimelineContentView::TimelineContentView (Timeline& tl, shared_ptr c) +TimelineContentView::TimelineContentView(ContentTimeline& tl, shared_ptr c) : TimelineView (tl) , _content (c) { diff --git a/src/wx/timeline_content_view.h b/src/wx/timeline_content_view.h index 7794120cd..ac84214f0 100644 --- a/src/wx/timeline_content_view.h +++ b/src/wx/timeline_content_view.h @@ -40,7 +40,7 @@ class Content; class TimelineContentView : public TimelineView { public: - TimelineContentView (Timeline& tl, std::shared_ptr c); + TimelineContentView(ContentTimeline& tl, std::shared_ptr c); dcpomatic::Rect bbox () const override; diff --git a/src/wx/timeline_dialog.cc b/src/wx/timeline_dialog.cc index e0e1689a8..f0216a9cb 100644 --- a/src/wx/timeline_dialog.cc +++ b/src/wx/timeline_dialog.cc @@ -73,11 +73,11 @@ TimelineDialog::TimelineDialog(ContentPanel* cp, shared_ptr film, FilmView _toolbar = new wxToolBar (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL); _toolbar->SetMargins (4, 4); _toolbar->SetToolBitmapSize (wxSize(32, 32)); - _toolbar->AddRadioTool ((int) Timeline::SELECT, _("Select"), select, wxNullBitmap, _("Select and move content")); - _toolbar->AddRadioTool ((int) Timeline::ZOOM, _("Zoom"), zoom, wxNullBitmap, _("Zoom in / out")); - _toolbar->AddTool ((int) Timeline::ZOOM_ALL, _("Zoom all"), zoom_all, _("Zoom out to whole film")); - _toolbar->AddCheckTool ((int) Timeline::SNAP, _("Snap"), snap, wxNullBitmap, _("Snap")); - _toolbar->AddCheckTool ((int) Timeline::SEQUENCE, _("Sequence"), sequence, wxNullBitmap, _("Keep video and subtitles in sequence")); + _toolbar->AddRadioTool(static_cast(ContentTimeline::SELECT), _("Select"), select, wxNullBitmap, _("Select and move content")); + _toolbar->AddRadioTool(static_cast(ContentTimeline::ZOOM), _("Zoom"), zoom, wxNullBitmap, _("Zoom in / out")); + _toolbar->AddTool(static_cast(ContentTimeline::ZOOM_ALL), _("Zoom all"), zoom_all, _("Zoom out to whole film")); + _toolbar->AddCheckTool(static_cast(ContentTimeline::SNAP), _("Snap"), snap, wxNullBitmap, _("Snap")); + _toolbar->AddCheckTool(static_cast(ContentTimeline::SEQUENCE), _("Sequence"), sequence, wxNullBitmap, _("Keep video and subtitles in sequence")); _toolbar->Realize (); _toolbar->Bind (wxEVT_TOOL, bind (&TimelineDialog::tool_clicked, this, _1)); @@ -98,7 +98,7 @@ TimelineDialog::TimelineDialog(ContentPanel* cp, shared_ptr film, FilmView Bind(wxEVT_CHAR_HOOK, boost::bind(&TimelineDialog::keypress, this, _1)); - _toolbar->ToggleTool ((int) Timeline::SNAP, _timeline.snap ()); + _toolbar->ToggleTool(static_cast(ContentTimeline::SNAP), _timeline.snap ()); film_change(ChangeType::DONE, FilmProperty::SEQUENCE); _film_changed_connection = film->Change.connect (bind (&TimelineDialog::film_change, this, _1, _2)); @@ -118,7 +118,7 @@ TimelineDialog::film_change(ChangeType type, FilmProperty p) } if (p == FilmProperty::SEQUENCE) { - _toolbar->ToggleTool ((int) Timeline::SEQUENCE, film->sequence ()); + _toolbar->ToggleTool(static_cast(ContentTimeline::SEQUENCE), film->sequence()); } } @@ -133,11 +133,11 @@ TimelineDialog::set_selection (ContentList selection) void TimelineDialog::tool_clicked (wxCommandEvent& ev) { - Timeline::Tool t = static_cast(ev.GetId()); + auto t = static_cast(ev.GetId()); _timeline.tool_clicked (t); - if (t == Timeline::SNAP) { + if (t == ContentTimeline::SNAP) { _timeline.set_snap (_toolbar->GetToolState(static_cast(t))); - } else if (t == Timeline::SEQUENCE) { + } else if (t == ContentTimeline::SEQUENCE) { auto film = _film.lock (); if (film) { film->set_sequence (_toolbar->GetToolState(static_cast(t))); diff --git a/src/wx/timeline_dialog.h b/src/wx/timeline_dialog.h index 8134aa6db..d2821c20c 100644 --- a/src/wx/timeline_dialog.h +++ b/src/wx/timeline_dialog.h @@ -19,7 +19,7 @@ */ -#include "timeline.h" +#include "content_timeline.h" #include LIBDCP_DISABLE_WARNINGS #include @@ -42,7 +42,7 @@ private: void keypress(wxKeyEvent const& event); std::weak_ptr _film; - Timeline _timeline; + ContentTimeline _timeline; wxToolBar* _toolbar; boost::signals2::scoped_connection _film_changed_connection; }; diff --git a/src/wx/timeline_labels_view.cc b/src/wx/timeline_labels_view.cc index 181adc5ca..48c879d13 100644 --- a/src/wx/timeline_labels_view.cc +++ b/src/wx/timeline_labels_view.cc @@ -19,7 +19,7 @@ */ -#include "timeline.h" +#include "content_timeline.h" #include "timeline_labels_view.h" #include "wx_util.h" #include @@ -34,7 +34,7 @@ using std::max; using std::min; -TimelineLabelsView::TimelineLabelsView (Timeline& tl) +TimelineLabelsView::TimelineLabelsView(ContentTimeline& tl) : TimelineView (tl) { wxString labels[] = { diff --git a/src/wx/timeline_labels_view.h b/src/wx/timeline_labels_view.h index fb80b1bf3..1fa5b60b1 100644 --- a/src/wx/timeline_labels_view.h +++ b/src/wx/timeline_labels_view.h @@ -28,7 +28,7 @@ class wxWindow; class TimelineLabelsView : public TimelineView { public: - explicit TimelineLabelsView (Timeline& tl); + explicit TimelineLabelsView(ContentTimeline& tl); dcpomatic::Rect bbox () const override; diff --git a/src/wx/timeline_reels_view.cc b/src/wx/timeline_reels_view.cc index 0601a1196..34ce96a4e 100644 --- a/src/wx/timeline_reels_view.cc +++ b/src/wx/timeline_reels_view.cc @@ -19,7 +19,7 @@ */ -#include "timeline.h" +#include "content_timeline.h" #include "timeline_reels_view.h" #include "wx_util.h" #include "lib/film.h" @@ -35,7 +35,7 @@ using std::list; using namespace dcpomatic; -TimelineReelsView::TimelineReelsView (Timeline& tl, int y) +TimelineReelsView::TimelineReelsView(ContentTimeline& tl, int y) : TimelineView (tl) , _y (y) { diff --git a/src/wx/timeline_reels_view.h b/src/wx/timeline_reels_view.h index 357fe2ce4..670df7c9d 100644 --- a/src/wx/timeline_reels_view.h +++ b/src/wx/timeline_reels_view.h @@ -25,7 +25,7 @@ class TimelineReelsView : public TimelineView { public: - TimelineReelsView (Timeline& tl, int y); + TimelineReelsView(ContentTimeline& tl, int y); dcpomatic::Rect bbox () const override; void set_y (int y); diff --git a/src/wx/timeline_text_content_view.cc b/src/wx/timeline_text_content_view.cc index a57398599..bc099d4d6 100644 --- a/src/wx/timeline_text_content_view.cc +++ b/src/wx/timeline_text_content_view.cc @@ -27,7 +27,7 @@ using std::shared_ptr; -TimelineTextContentView::TimelineTextContentView (Timeline& tl, shared_ptr c, shared_ptr caption) +TimelineTextContentView::TimelineTextContentView(ContentTimeline& tl, shared_ptr c, shared_ptr caption) : TimelineContentView (tl, c) , _caption (caption) { diff --git a/src/wx/timeline_text_content_view.h b/src/wx/timeline_text_content_view.h index 046f5b3e6..c33c2662e 100644 --- a/src/wx/timeline_text_content_view.h +++ b/src/wx/timeline_text_content_view.h @@ -18,10 +18,12 @@ */ + #include "timeline_content_view.h" + class TextContent; -class TextContent; + /** @class TimelineTextContentView * @brief Timeline view for TextContent. @@ -29,7 +31,7 @@ class TextContent; class TimelineTextContentView : public TimelineContentView { public: - TimelineTextContentView (Timeline& tl, std::shared_ptr, std::shared_ptr); + TimelineTextContentView(ContentTimeline& tl, std::shared_ptr, std::shared_ptr); private: bool active () const override; diff --git a/src/wx/timeline_time_axis_view.cc b/src/wx/timeline_time_axis_view.cc index d055bda7d..b17b274b2 100644 --- a/src/wx/timeline_time_axis_view.cc +++ b/src/wx/timeline_time_axis_view.cc @@ -19,7 +19,7 @@ */ -#include "timeline.h" +#include "content_timeline.h" #include "timeline_time_axis_view.h" #include "wx_util.h" #include @@ -34,7 +34,7 @@ using std::list; using namespace dcpomatic; -TimelineTimeAxisView::TimelineTimeAxisView (Timeline& tl, int y) +TimelineTimeAxisView::TimelineTimeAxisView(ContentTimeline& tl, int y) : TimelineView (tl) , _y (y) { diff --git a/src/wx/timeline_time_axis_view.h b/src/wx/timeline_time_axis_view.h index 4c8e090fe..6ffb9e5dc 100644 --- a/src/wx/timeline_time_axis_view.h +++ b/src/wx/timeline_time_axis_view.h @@ -23,7 +23,7 @@ class TimelineTimeAxisView : public TimelineView { public: - TimelineTimeAxisView (Timeline& tl, int y); + TimelineTimeAxisView(ContentTimeline& tl, int y); dcpomatic::Rect bbox () const override; void set_y (int y); diff --git a/src/wx/timeline_video_content_view.cc b/src/wx/timeline_video_content_view.cc index b0f4b4f5d..d72b1e149 100644 --- a/src/wx/timeline_video_content_view.cc +++ b/src/wx/timeline_video_content_view.cc @@ -18,14 +18,17 @@ */ + #include "lib/image_content.h" #include "lib/video_content.h" #include "timeline_video_content_view.h" + using std::dynamic_pointer_cast; using std::shared_ptr; -TimelineVideoContentView::TimelineVideoContentView (Timeline& tl, shared_ptr c) + +TimelineVideoContentView::TimelineVideoContentView(ContentTimeline& tl, shared_ptr c) : TimelineContentView (tl, c) { diff --git a/src/wx/timeline_video_content_view.h b/src/wx/timeline_video_content_view.h index fa8ddf54c..507f3caed 100644 --- a/src/wx/timeline_video_content_view.h +++ b/src/wx/timeline_video_content_view.h @@ -28,7 +28,7 @@ class TimelineVideoContentView : public TimelineContentView { public: - TimelineVideoContentView (Timeline& tl, std::shared_ptr c); + TimelineVideoContentView(ContentTimeline& tl, std::shared_ptr c); private: bool active () const override; diff --git a/src/wx/timeline_view.cc b/src/wx/timeline_view.cc index 2897c98e3..f81ddd413 100644 --- a/src/wx/timeline_view.cc +++ b/src/wx/timeline_view.cc @@ -19,8 +19,8 @@ */ +#include "content_timeline.h" #include "timeline_view.h" -#include "timeline.h" using std::list; @@ -30,7 +30,7 @@ using namespace dcpomatic; /** @class TimelineView * @brief Parent class for components of the timeline (e.g. a piece of content or an axis). */ -TimelineView::TimelineView (Timeline& t) +TimelineView::TimelineView(ContentTimeline& t) : _timeline (t) { diff --git a/src/wx/timeline_view.h b/src/wx/timeline_view.h index 166a1121a..e753255e3 100644 --- a/src/wx/timeline_view.h +++ b/src/wx/timeline_view.h @@ -28,7 +28,7 @@ class wxGraphicsContext; -class Timeline; +class ContentTimeline; /** @class TimelineView @@ -37,7 +37,7 @@ class Timeline; class TimelineView { public: - explicit TimelineView (Timeline& t); + explicit TimelineView(ContentTimeline& t); virtual ~TimelineView () {} TimelineView (TimelineView const&) = delete; @@ -54,7 +54,7 @@ protected: int time_x (dcpomatic::DCPTime t) const; int y_pos(int t) const; - Timeline& _timeline; + ContentTimeline& _timeline; private: dcpomatic::Rect _last_paint_bbox; diff --git a/src/wx/wscript b/src/wx/wscript index 7dbd214c6..abf260ad6 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -48,6 +48,7 @@ sources = """ content_panel.cc content_properties_dialog.cc content_sub_panel.cc + content_timeline.cc content_version_dialog.cc content_view.cc controls.cc @@ -160,7 +161,6 @@ sources = """ time_picker.cc timer_display.cc timecode.cc - timeline.cc timeline_atmos_content_view.cc timeline_content_view.cc timeline_dialog.cc -- cgit v1.2.3 From 1910147fd58ac58a21b8f3b874495179aa5424ab Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 13 Dec 2023 23:01:23 +0100 Subject: Rename TimelineView -> ContentTimelineView. --- src/wx/content_timeline.cc | 6 ++-- src/wx/content_timeline.h | 6 ++-- src/wx/content_timeline_view.cc | 69 +++++++++++++++++++++++++++++++++++++++ src/wx/content_timeline_view.h | 67 +++++++++++++++++++++++++++++++++++++ src/wx/timeline_content_view.cc | 2 +- src/wx/timeline_content_view.h | 4 +-- src/wx/timeline_labels_view.cc | 2 +- src/wx/timeline_labels_view.h | 4 +-- src/wx/timeline_reels_view.cc | 2 +- src/wx/timeline_reels_view.h | 4 +-- src/wx/timeline_time_axis_view.cc | 2 +- src/wx/timeline_time_axis_view.h | 6 ++-- src/wx/timeline_view.cc | 69 --------------------------------------- src/wx/timeline_view.h | 67 ------------------------------------- src/wx/wscript | 2 +- 15 files changed, 157 insertions(+), 155 deletions(-) create mode 100644 src/wx/content_timeline_view.cc create mode 100644 src/wx/content_timeline_view.h delete mode 100644 src/wx/timeline_view.cc delete mode 100644 src/wx/timeline_view.h (limited to 'src') diff --git a/src/wx/content_timeline.cc b/src/wx/content_timeline.cc index b650f8e92..368cbcca4 100644 --- a/src/wx/content_timeline.cc +++ b/src/wx/content_timeline.cc @@ -356,7 +356,7 @@ ContentTimeline::film_content_change(ChangeType type, int property, bool frequen template int -place (shared_ptr film, TimelineViewList& views, int& tracks) +place(shared_ptr film, ContentTimelineViewList& views, int& tracks) { int const base = tracks; @@ -413,7 +413,7 @@ place (shared_ptr film, TimelineViewList& views, int& tracks) * order of first mapped DCP channel. */ struct AudioMappingComparator { - bool operator()(shared_ptr a, shared_ptr b) { + bool operator()(shared_ptr a, shared_ptr b) { int la = -1; auto cva = dynamic_pointer_cast(a); if (cva) { @@ -519,7 +519,7 @@ ContentTimeline::setup_scrollbars() } -shared_ptr +shared_ptr ContentTimeline::event_to_view(wxMouseEvent& ev) { /* Search backwards through views so that we find the uppermost one first */ diff --git a/src/wx/content_timeline.h b/src/wx/content_timeline.h index 65b2ff956..994f18ad4 100644 --- a/src/wx/content_timeline.h +++ b/src/wx/content_timeline.h @@ -31,12 +31,12 @@ LIBDCP_ENABLE_WARNINGS class ContentPanel; +class ContentTimelineView; class Film; class FilmViewer; class TimelineLabelsView; class TimelineReelsView; class TimelineTimeAxisView; -class TimelineView; class ContentTimeline : public wxPanel @@ -112,7 +112,7 @@ private: void update_playhead (); void mouse_wheel_turned(wxMouseEvent& event); - std::shared_ptr event_to_view (wxMouseEvent &); + std::shared_ptr event_to_view(wxMouseEvent &); TimelineContentViewList selected_views () const; ContentList selected_content () const; void maybe_snap (dcpomatic::DCPTime a, dcpomatic::DCPTime b, boost::optional& nearest_distance) const; @@ -122,7 +122,7 @@ private: ContentPanel* _content_panel; std::weak_ptr _film; FilmViewer& _viewer; - TimelineViewList _views; + ContentTimelineViewList _views; std::shared_ptr _time_axis_view; std::shared_ptr _reels_view; std::shared_ptr _labels_view; diff --git a/src/wx/content_timeline_view.cc b/src/wx/content_timeline_view.cc new file mode 100644 index 000000000..05922d558 --- /dev/null +++ b/src/wx/content_timeline_view.cc @@ -0,0 +1,69 @@ +/* + Copyright (C) 2013-2021 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "content_timeline.h" +#include "content_timeline_view.h" + + +using std::list; +using namespace dcpomatic; + + +/** @class ContentContentTimelineView + * @brief Parent class for components of the content timeline (e.g. a piece of content or an axis). + */ +ContentTimelineView::ContentTimelineView(ContentTimeline& t) + : _timeline (t) +{ + +} + + +void +ContentTimelineView::paint(wxGraphicsContext* g, list> overlaps) +{ + _last_paint_bbox = bbox (); + do_paint (g, overlaps); +} + + +void +ContentTimelineView::force_redraw() +{ + _timeline.force_redraw (_last_paint_bbox.extended(4)); + _timeline.force_redraw (bbox().extended(4)); +} + + +int +ContentTimelineView::time_x(DCPTime t) const +{ + return t.seconds() * _timeline.pixels_per_second().get_value_or(0); +} + + +int +ContentTimelineView::y_pos(int t) const +{ + return t * _timeline.pixels_per_track() + _timeline.tracks_y_offset(); +} + + diff --git a/src/wx/content_timeline_view.h b/src/wx/content_timeline_view.h new file mode 100644 index 000000000..0f6eeae51 --- /dev/null +++ b/src/wx/content_timeline_view.h @@ -0,0 +1,67 @@ +/* + Copyright (C) 2013-2021 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#ifndef DCPOMATIC_CONTENT_TIMELINE_VIEW_H +#define DCPOMATIC_CONTENT_TIMELINE_VIEW_H + + +#include "lib/rect.h" +#include "lib/dcpomatic_time.h" + + +class wxGraphicsContext; +class ContentTimeline; + + +/** @class ContentTimelineView + * @brief Parent class for components of the content timeline (e.g. a piece of content or an axis). + */ +class ContentTimelineView +{ +public: + explicit ContentTimelineView(ContentTimeline& t); + virtual ~ContentTimelineView () = default; + + ContentTimelineView(ContentTimelineView const&) = delete; + ContentTimelineView& operator=(ContentTimelineView const&) = delete; + + void paint (wxGraphicsContext* g, std::list> overlaps); + void force_redraw (); + + virtual dcpomatic::Rect bbox () const = 0; + +protected: + virtual void do_paint (wxGraphicsContext *, std::list> overlaps) = 0; + + int time_x (dcpomatic::DCPTime t) const; + int y_pos(int t) const; + + ContentTimeline& _timeline; + +private: + dcpomatic::Rect _last_paint_bbox; +}; + + +typedef std::vector> ContentTimelineViewList; + + +#endif diff --git a/src/wx/timeline_content_view.cc b/src/wx/timeline_content_view.cc index 05ee6617b..cb0d10240 100644 --- a/src/wx/timeline_content_view.cc +++ b/src/wx/timeline_content_view.cc @@ -38,7 +38,7 @@ using namespace boost::placeholders; TimelineContentView::TimelineContentView(ContentTimeline& tl, shared_ptr c) - : TimelineView (tl) + : ContentTimelineView(tl) , _content (c) { _content_connection = c->Change.connect (bind (&TimelineContentView::content_change, this, _1, _3)); diff --git a/src/wx/timeline_content_view.h b/src/wx/timeline_content_view.h index ac84214f0..7b206d30f 100644 --- a/src/wx/timeline_content_view.h +++ b/src/wx/timeline_content_view.h @@ -23,7 +23,7 @@ #define DCPOMATIC_TIMELINE_CONTENT_VIEW_H -#include "timeline_view.h" +#include "content_timeline_view.h" #include "lib/change_signaller.h" #include LIBDCP_DISABLE_WARNINGS @@ -37,7 +37,7 @@ class Content; /** @class TimelineContentView * @brief Parent class for views of pieces of content. */ -class TimelineContentView : public TimelineView +class TimelineContentView : public ContentTimelineView { public: TimelineContentView(ContentTimeline& tl, std::shared_ptr c); diff --git a/src/wx/timeline_labels_view.cc b/src/wx/timeline_labels_view.cc index 48c879d13..c869d7ec5 100644 --- a/src/wx/timeline_labels_view.cc +++ b/src/wx/timeline_labels_view.cc @@ -35,7 +35,7 @@ using std::min; TimelineLabelsView::TimelineLabelsView(ContentTimeline& tl) - : TimelineView (tl) + : ContentTimelineView(tl) { wxString labels[] = { _("Video"), diff --git a/src/wx/timeline_labels_view.h b/src/wx/timeline_labels_view.h index 1fa5b60b1..324531c39 100644 --- a/src/wx/timeline_labels_view.h +++ b/src/wx/timeline_labels_view.h @@ -19,13 +19,13 @@ */ -#include "timeline_view.h" +#include "content_timeline_view.h" class wxWindow; -class TimelineLabelsView : public TimelineView +class TimelineLabelsView : public ContentTimelineView { public: explicit TimelineLabelsView(ContentTimeline& tl); diff --git a/src/wx/timeline_reels_view.cc b/src/wx/timeline_reels_view.cc index 34ce96a4e..5f2a78079 100644 --- a/src/wx/timeline_reels_view.cc +++ b/src/wx/timeline_reels_view.cc @@ -36,7 +36,7 @@ using namespace dcpomatic; TimelineReelsView::TimelineReelsView(ContentTimeline& tl, int y) - : TimelineView (tl) + : ContentTimelineView(tl) , _y (y) { diff --git a/src/wx/timeline_reels_view.h b/src/wx/timeline_reels_view.h index 670df7c9d..7dbc34308 100644 --- a/src/wx/timeline_reels_view.h +++ b/src/wx/timeline_reels_view.h @@ -19,10 +19,10 @@ */ -#include "timeline_view.h" +#include "content_timeline_view.h" -class TimelineReelsView : public TimelineView +class TimelineReelsView : public ContentTimelineView { public: TimelineReelsView(ContentTimeline& tl, int y); diff --git a/src/wx/timeline_time_axis_view.cc b/src/wx/timeline_time_axis_view.cc index b17b274b2..d9b7710c6 100644 --- a/src/wx/timeline_time_axis_view.cc +++ b/src/wx/timeline_time_axis_view.cc @@ -35,7 +35,7 @@ using namespace dcpomatic; TimelineTimeAxisView::TimelineTimeAxisView(ContentTimeline& tl, int y) - : TimelineView (tl) + : ContentTimelineView(tl) , _y (y) { diff --git a/src/wx/timeline_time_axis_view.h b/src/wx/timeline_time_axis_view.h index 6ffb9e5dc..f89121776 100644 --- a/src/wx/timeline_time_axis_view.h +++ b/src/wx/timeline_time_axis_view.h @@ -18,9 +18,11 @@ */ -#include "timeline_view.h" -class TimelineTimeAxisView : public TimelineView +#include "content_timeline_view.h" + + +class TimelineTimeAxisView : public ContentTimelineView { public: TimelineTimeAxisView(ContentTimeline& tl, int y); diff --git a/src/wx/timeline_view.cc b/src/wx/timeline_view.cc deleted file mode 100644 index f81ddd413..000000000 --- a/src/wx/timeline_view.cc +++ /dev/null @@ -1,69 +0,0 @@ -/* - Copyright (C) 2013-2021 Carl Hetherington - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see . - -*/ - - -#include "content_timeline.h" -#include "timeline_view.h" - - -using std::list; -using namespace dcpomatic; - - -/** @class TimelineView - * @brief Parent class for components of the timeline (e.g. a piece of content or an axis). - */ -TimelineView::TimelineView(ContentTimeline& t) - : _timeline (t) -{ - -} - - -void -TimelineView::paint (wxGraphicsContext* g, list> overlaps) -{ - _last_paint_bbox = bbox (); - do_paint (g, overlaps); -} - - -void -TimelineView::force_redraw () -{ - _timeline.force_redraw (_last_paint_bbox.extended(4)); - _timeline.force_redraw (bbox().extended(4)); -} - - -int -TimelineView::time_x (DCPTime t) const -{ - return t.seconds() * _timeline.pixels_per_second().get_value_or(0); -} - - -int -TimelineView::y_pos(int t) const -{ - return t * _timeline.pixels_per_track() + _timeline.tracks_y_offset(); -} - - diff --git a/src/wx/timeline_view.h b/src/wx/timeline_view.h deleted file mode 100644 index e753255e3..000000000 --- a/src/wx/timeline_view.h +++ /dev/null @@ -1,67 +0,0 @@ -/* - Copyright (C) 2013-2021 Carl Hetherington - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see . - -*/ - - -#ifndef DCPOMATIC_TIMELINE_VIEW_H -#define DCPOMATIC_TIMELINE_VIEW_H - - -#include "lib/rect.h" -#include "lib/dcpomatic_time.h" - - -class wxGraphicsContext; -class ContentTimeline; - - -/** @class TimelineView - * @brief Parent class for components of the timeline (e.g. a piece of content or an axis). - */ -class TimelineView -{ -public: - explicit TimelineView(ContentTimeline& t); - virtual ~TimelineView () {} - - TimelineView (TimelineView const&) = delete; - TimelineView& operator= (TimelineView const&) = delete; - - void paint (wxGraphicsContext* g, std::list> overlaps); - void force_redraw (); - - virtual dcpomatic::Rect bbox () const = 0; - -protected: - virtual void do_paint (wxGraphicsContext *, std::list> overlaps) = 0; - - int time_x (dcpomatic::DCPTime t) const; - int y_pos(int t) const; - - ContentTimeline& _timeline; - -private: - dcpomatic::Rect _last_paint_bbox; -}; - - -typedef std::vector> TimelineViewList; - - -#endif diff --git a/src/wx/wscript b/src/wx/wscript index abf260ad6..830d76731 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -49,6 +49,7 @@ sources = """ content_properties_dialog.cc content_sub_panel.cc content_timeline.cc + content_timeline_view.cc content_version_dialog.cc content_view.cc controls.cc @@ -170,7 +171,6 @@ sources = """ timeline_reels_view.cc timeline_time_axis_view.cc timeline_video_content_view.cc - timeline_view.cc timing_panel.cc try_unmount_dialog.cc update_dialog.cc -- cgit v1.2.3 From f81655002b1ef1427e2845dc5d354da6020bfafb Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 13 Dec 2023 23:03:01 +0100 Subject: Split out Timeline from ContentTimeline. --- src/wx/content_timeline.cc | 11 +--------- src/wx/content_timeline.h | 10 ++-------- src/wx/timeline.cc | 42 ++++++++++++++++++++++++++++++++++++++ src/wx/timeline.h | 50 ++++++++++++++++++++++++++++++++++++++++++++++ src/wx/wscript | 1 + 5 files changed, 96 insertions(+), 18 deletions(-) create mode 100644 src/wx/timeline.cc create mode 100644 src/wx/timeline.h (limited to 'src') diff --git a/src/wx/content_timeline.cc b/src/wx/content_timeline.cc index 368cbcca4..d5ed0f7bb 100644 --- a/src/wx/content_timeline.cc +++ b/src/wx/content_timeline.cc @@ -63,13 +63,11 @@ using namespace boost::placeholders; #endif -/* 3 hours in 640 pixels */ -double const ContentTimeline::_minimum_pixels_per_second = 640.0 / (60 * 60 * 3); int const ContentTimeline::_minimum_pixels_per_track = 16; ContentTimeline::ContentTimeline(wxWindow* parent, ContentPanel* cp, shared_ptr film, FilmViewer& viewer) - : wxPanel (parent, wxID_ANY) + : Timeline(parent) , _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)) , _content_panel (cp) @@ -184,13 +182,6 @@ ContentTimeline::update_playhead() } -void -ContentTimeline::set_pixels_per_second(double pps) -{ - _pixels_per_second = max (_minimum_pixels_per_second, pps); -} - - void ContentTimeline::paint_labels() { diff --git a/src/wx/content_timeline.h b/src/wx/content_timeline.h index 994f18ad4..10f880191 100644 --- a/src/wx/content_timeline.h +++ b/src/wx/content_timeline.h @@ -20,6 +20,7 @@ #include "content_menu.h" +#include "timeline.h" #include "timeline_content_view.h" #include "lib/film_property.h" #include "lib/rect.h" @@ -39,7 +40,7 @@ class TimelineReelsView; class TimelineTimeAxisView; -class ContentTimeline : public wxPanel +class ContentTimeline : public Timeline { public: ContentTimeline(wxWindow *, ContentPanel *, std::shared_ptr, FilmViewer& viewer); @@ -54,10 +55,6 @@ public: return _pixels_per_track; } - boost::optional pixels_per_second () const { - return _pixels_per_second; - } - int tracks () const; void set_snap (bool s) { @@ -106,7 +103,6 @@ private: void recreate_views (); void setup_scrollbars (); void scrolled (wxScrollWinEvent& ev); - void set_pixels_per_second (double pps); void set_pixels_per_track (int h); void zoom_all (); void update_playhead (); @@ -127,7 +123,6 @@ private: std::shared_ptr _reels_view; std::shared_ptr _labels_view; int _tracks; - boost::optional _pixels_per_second; bool _left_down; wxPoint _down_point; boost::optional _zoom_point; @@ -147,7 +142,6 @@ private: boost::optional _last_mouse_wheel_x; boost::optional _last_mouse_wheel_time; - static double const _minimum_pixels_per_second; static int const _minimum_pixels_per_track; boost::signals2::scoped_connection _film_changed_connection; diff --git a/src/wx/timeline.cc b/src/wx/timeline.cc new file mode 100644 index 000000000..329f4ef00 --- /dev/null +++ b/src/wx/timeline.cc @@ -0,0 +1,42 @@ +/* + Copyright (C) 2023 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "timeline.h" + + +/* 3 hours in 640 pixels */ +double constexpr minimum_pixels_per_second = 640.0 / (60 * 60 * 3); + + +Timeline::Timeline(wxWindow* parent) + : wxPanel(parent, wxID_ANY) +{ + +} + + +void +Timeline::set_pixels_per_second(double pps) +{ + _pixels_per_second = std::max(minimum_pixels_per_second, pps); +} + + diff --git a/src/wx/timeline.h b/src/wx/timeline.h new file mode 100644 index 000000000..cc35913b9 --- /dev/null +++ b/src/wx/timeline.h @@ -0,0 +1,50 @@ +/* + Copyright (C) 2023 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#ifndef DCPOMATIC_TIMELINE_H +#define DCPOMATIC_TIMELINE_H + + +#include +LIBDCP_DISABLE_WARNINGS +#include +LIBDCP_ENABLE_WARNINGS +#include + + +class Timeline : public wxPanel +{ +public: + explicit Timeline(wxWindow* parent); + + boost::optional pixels_per_second() const { + return _pixels_per_second; + } + + +protected: + void set_pixels_per_second(double pps); + + boost::optional _pixels_per_second; +}; + + +#endif diff --git a/src/wx/wscript b/src/wx/wscript index 830d76731..2693bfa57 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -162,6 +162,7 @@ sources = """ time_picker.cc timer_display.cc timecode.cc + timeline.cc timeline_atmos_content_view.cc timeline_content_view.cc timeline_dialog.cc -- cgit v1.2.3 From 783680c0efae1934409e4c93796b5a6265198e17 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 13 Dec 2023 23:27:05 +0100 Subject: Rename TimelineDialog -> ContentTimelineDialog. --- src/wx/content_panel.cc | 2 +- src/wx/content_panel.h | 4 +- src/wx/content_timeline_dialog.cc | 153 ++++++++++++++++++++++++++++++++++++++ src/wx/content_timeline_dialog.h | 48 ++++++++++++ src/wx/timeline_dialog.cc | 153 -------------------------------------- src/wx/timeline_dialog.h | 48 ------------ src/wx/wscript | 2 +- 7 files changed, 205 insertions(+), 205 deletions(-) create mode 100644 src/wx/content_timeline_dialog.cc create mode 100644 src/wx/content_timeline_dialog.h delete mode 100644 src/wx/timeline_dialog.cc delete mode 100644 src/wx/timeline_dialog.h (limited to 'src') diff --git a/src/wx/content_panel.cc b/src/wx/content_panel.cc index 9e73900fc..ed9c15c83 100644 --- a/src/wx/content_panel.cc +++ b/src/wx/content_panel.cc @@ -21,13 +21,13 @@ #include "audio_panel.h" #include "content_panel.h" +#include "content_timeline_dialog.h" #include "dcpomatic_button.h" #include "dir_dialog.h" #include "file_dialog.h" #include "film_viewer.h" #include "image_sequence_dialog.h" #include "text_panel.h" -#include "timeline_dialog.h" #include "timing_panel.h" #include "video_panel.h" #include "wx_util.h" diff --git a/src/wx/content_panel.h b/src/wx/content_panel.h index ca0d49719..38b634a62 100644 --- a/src/wx/content_panel.h +++ b/src/wx/content_panel.h @@ -33,12 +33,12 @@ LIBDCP_ENABLE_WARNINGS class AudioPanel; class ContentListCtrl; class ContentSubPanel; +class ContentTimelineDialog; class Film; class FilmEditor; class FilmViewer; class LimitedContentPanelSplitter; class TextPanel; -class TimelineDialog; class TimingPanel; class VideoPanel; class wxListCtrl; @@ -132,7 +132,7 @@ private: EnumIndexedVector _text_panel; TimingPanel* _timing_panel; ContentMenu* _menu; - wx_ptr _timeline_dialog; + wx_ptr _timeline_dialog; wxNotebook* _parent; wxWindow* _last_selected_tab = nullptr; diff --git a/src/wx/content_timeline_dialog.cc b/src/wx/content_timeline_dialog.cc new file mode 100644 index 000000000..697e6561f --- /dev/null +++ b/src/wx/content_timeline_dialog.cc @@ -0,0 +1,153 @@ +/* + Copyright (C) 2013-2021 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "content_panel.h" +#include "content_timeline_dialog.h" +#include "film_editor.h" +#include "wx_util.h" +#include "lib/compose.hpp" +#include "lib/cross.h" +#include "lib/film.h" +#include "lib/playlist.h" +#include +LIBDCP_DISABLE_WARNINGS +#include +LIBDCP_ENABLE_WARNINGS +#include + + +using std::list; +using std::shared_ptr; +using std::string; +using std::weak_ptr; +#if BOOST_VERSION >= 106100 +using namespace boost::placeholders; +#endif + + +ContentTimelineDialog::ContentTimelineDialog(ContentPanel* cp, shared_ptr film, FilmViewer& viewer) + : wxDialog ( + cp->window(), + wxID_ANY, + _("Timeline"), + wxDefaultPosition, + wxSize (640, 512), +#ifdef DCPOMATIC_OSX + /* I can't get wxFRAME_FLOAT_ON_PARENT to work on OS X, and although wxSTAY_ON_TOP keeps + the window above all others (and not just our own) it's better than nothing for now. + */ + wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE | wxSTAY_ON_TOP +#else + wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE | wxFRAME_FLOAT_ON_PARENT +#endif + ) + , _film (film) + , _timeline (this, cp, film, viewer) +{ + auto sizer = new wxBoxSizer (wxVERTICAL); + + wxBitmap select(icon_path("select"), wxBITMAP_TYPE_PNG); + wxBitmap zoom(icon_path("zoom"), wxBITMAP_TYPE_PNG); + wxBitmap zoom_all(icon_path("zoom_all"), wxBITMAP_TYPE_PNG); + wxBitmap snap(icon_path("snap"), wxBITMAP_TYPE_PNG); + wxBitmap sequence(icon_path("sequence"), wxBITMAP_TYPE_PNG); + + _toolbar = new wxToolBar (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL); + _toolbar->SetMargins (4, 4); + _toolbar->SetToolBitmapSize (wxSize(32, 32)); + _toolbar->AddRadioTool(static_cast(ContentTimeline::SELECT), _("Select"), select, wxNullBitmap, _("Select and move content")); + _toolbar->AddRadioTool(static_cast(ContentTimeline::ZOOM), _("Zoom"), zoom, wxNullBitmap, _("Zoom in / out")); + _toolbar->AddTool(static_cast(ContentTimeline::ZOOM_ALL), _("Zoom all"), zoom_all, _("Zoom out to whole film")); + _toolbar->AddCheckTool(static_cast(ContentTimeline::SNAP), _("Snap"), snap, wxNullBitmap, _("Snap")); + _toolbar->AddCheckTool(static_cast(ContentTimeline::SEQUENCE), _("Sequence"), sequence, wxNullBitmap, _("Keep video and subtitles in sequence")); + _toolbar->Realize (); + + _toolbar->Bind(wxEVT_TOOL, bind(&ContentTimelineDialog::tool_clicked, this, _1)); + + sizer->Add (_toolbar, 0, wxALL, 12); + sizer->Add (&_timeline, 1, wxEXPAND | wxALL, 12); + +#ifdef DCPOMATIC_LINUX + auto buttons = CreateSeparatedButtonSizer (wxCLOSE); + if (buttons) { + sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); + } +#endif + + SetSizer (sizer); + sizer->Layout (); + sizer->SetSizeHints (this); + + Bind(wxEVT_CHAR_HOOK, boost::bind(&ContentTimelineDialog::keypress, this, _1)); + + _toolbar->ToggleTool(static_cast(ContentTimeline::SNAP), _timeline.snap ()); + film_change(ChangeType::DONE, FilmProperty::SEQUENCE); + + _film_changed_connection = film->Change.connect(bind(&ContentTimelineDialog::film_change, this, _1, _2)); +} + + +void +ContentTimelineDialog::film_change(ChangeType type, FilmProperty p) +{ + if (type != ChangeType::DONE) { + return; + } + + auto film = _film.lock (); + if (!film) { + return; + } + + if (p == FilmProperty::SEQUENCE) { + _toolbar->ToggleTool(static_cast(ContentTimeline::SEQUENCE), film->sequence()); + } +} + + +void +ContentTimelineDialog::set_selection(ContentList selection) +{ + _timeline.set_selection (selection); +} + + +void +ContentTimelineDialog::tool_clicked(wxCommandEvent& ev) +{ + auto t = static_cast(ev.GetId()); + _timeline.tool_clicked (t); + if (t == ContentTimeline::SNAP) { + _timeline.set_snap (_toolbar->GetToolState(static_cast(t))); + } else if (t == ContentTimeline::SEQUENCE) { + auto film = _film.lock (); + if (film) { + film->set_sequence (_toolbar->GetToolState(static_cast(t))); + } + } +} + + +void +ContentTimelineDialog::keypress(wxKeyEvent const& event) +{ + _timeline.keypress(event); +} diff --git a/src/wx/content_timeline_dialog.h b/src/wx/content_timeline_dialog.h new file mode 100644 index 000000000..2babf0437 --- /dev/null +++ b/src/wx/content_timeline_dialog.h @@ -0,0 +1,48 @@ +/* + Copyright (C) 2013-2021 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "content_timeline.h" +#include +LIBDCP_DISABLE_WARNINGS +#include +LIBDCP_ENABLE_WARNINGS + + +class Playlist; + + +class ContentTimelineDialog : public wxDialog +{ +public: + ContentTimelineDialog(ContentPanel *, std::shared_ptr, FilmViewer& viewer); + + void set_selection (ContentList selection); + +private: + void film_change(ChangeType type, FilmProperty); + void tool_clicked (wxCommandEvent& id); + void keypress(wxKeyEvent const& event); + + std::weak_ptr _film; + ContentTimeline _timeline; + wxToolBar* _toolbar; + boost::signals2::scoped_connection _film_changed_connection; +}; diff --git a/src/wx/timeline_dialog.cc b/src/wx/timeline_dialog.cc deleted file mode 100644 index f0216a9cb..000000000 --- a/src/wx/timeline_dialog.cc +++ /dev/null @@ -1,153 +0,0 @@ -/* - Copyright (C) 2013-2021 Carl Hetherington - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see . - -*/ - - -#include "content_panel.h" -#include "film_editor.h" -#include "timeline_dialog.h" -#include "wx_util.h" -#include "lib/compose.hpp" -#include "lib/cross.h" -#include "lib/film.h" -#include "lib/playlist.h" -#include -LIBDCP_DISABLE_WARNINGS -#include -LIBDCP_ENABLE_WARNINGS -#include - - -using std::list; -using std::shared_ptr; -using std::string; -using std::weak_ptr; -#if BOOST_VERSION >= 106100 -using namespace boost::placeholders; -#endif - - -TimelineDialog::TimelineDialog(ContentPanel* cp, shared_ptr film, FilmViewer& viewer) - : wxDialog ( - cp->window(), - wxID_ANY, - _("Timeline"), - wxDefaultPosition, - wxSize (640, 512), -#ifdef DCPOMATIC_OSX - /* I can't get wxFRAME_FLOAT_ON_PARENT to work on OS X, and although wxSTAY_ON_TOP keeps - the window above all others (and not just our own) it's better than nothing for now. - */ - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE | wxSTAY_ON_TOP -#else - wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE | wxFRAME_FLOAT_ON_PARENT -#endif - ) - , _film (film) - , _timeline (this, cp, film, viewer) -{ - auto sizer = new wxBoxSizer (wxVERTICAL); - - wxBitmap select(icon_path("select"), wxBITMAP_TYPE_PNG); - wxBitmap zoom(icon_path("zoom"), wxBITMAP_TYPE_PNG); - wxBitmap zoom_all(icon_path("zoom_all"), wxBITMAP_TYPE_PNG); - wxBitmap snap(icon_path("snap"), wxBITMAP_TYPE_PNG); - wxBitmap sequence(icon_path("sequence"), wxBITMAP_TYPE_PNG); - - _toolbar = new wxToolBar (this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxTB_HORIZONTAL); - _toolbar->SetMargins (4, 4); - _toolbar->SetToolBitmapSize (wxSize(32, 32)); - _toolbar->AddRadioTool(static_cast(ContentTimeline::SELECT), _("Select"), select, wxNullBitmap, _("Select and move content")); - _toolbar->AddRadioTool(static_cast(ContentTimeline::ZOOM), _("Zoom"), zoom, wxNullBitmap, _("Zoom in / out")); - _toolbar->AddTool(static_cast(ContentTimeline::ZOOM_ALL), _("Zoom all"), zoom_all, _("Zoom out to whole film")); - _toolbar->AddCheckTool(static_cast(ContentTimeline::SNAP), _("Snap"), snap, wxNullBitmap, _("Snap")); - _toolbar->AddCheckTool(static_cast(ContentTimeline::SEQUENCE), _("Sequence"), sequence, wxNullBitmap, _("Keep video and subtitles in sequence")); - _toolbar->Realize (); - - _toolbar->Bind (wxEVT_TOOL, bind (&TimelineDialog::tool_clicked, this, _1)); - - sizer->Add (_toolbar, 0, wxALL, 12); - sizer->Add (&_timeline, 1, wxEXPAND | wxALL, 12); - -#ifdef DCPOMATIC_LINUX - auto buttons = CreateSeparatedButtonSizer (wxCLOSE); - if (buttons) { - sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); - } -#endif - - SetSizer (sizer); - sizer->Layout (); - sizer->SetSizeHints (this); - - Bind(wxEVT_CHAR_HOOK, boost::bind(&TimelineDialog::keypress, this, _1)); - - _toolbar->ToggleTool(static_cast(ContentTimeline::SNAP), _timeline.snap ()); - film_change(ChangeType::DONE, FilmProperty::SEQUENCE); - - _film_changed_connection = film->Change.connect (bind (&TimelineDialog::film_change, this, _1, _2)); -} - - -void -TimelineDialog::film_change(ChangeType type, FilmProperty p) -{ - if (type != ChangeType::DONE) { - return; - } - - auto film = _film.lock (); - if (!film) { - return; - } - - if (p == FilmProperty::SEQUENCE) { - _toolbar->ToggleTool(static_cast(ContentTimeline::SEQUENCE), film->sequence()); - } -} - - -void -TimelineDialog::set_selection (ContentList selection) -{ - _timeline.set_selection (selection); -} - - -void -TimelineDialog::tool_clicked (wxCommandEvent& ev) -{ - auto t = static_cast(ev.GetId()); - _timeline.tool_clicked (t); - if (t == ContentTimeline::SNAP) { - _timeline.set_snap (_toolbar->GetToolState(static_cast(t))); - } else if (t == ContentTimeline::SEQUENCE) { - auto film = _film.lock (); - if (film) { - film->set_sequence (_toolbar->GetToolState(static_cast(t))); - } - } -} - - -void -TimelineDialog::keypress(wxKeyEvent const& event) -{ - _timeline.keypress(event); -} diff --git a/src/wx/timeline_dialog.h b/src/wx/timeline_dialog.h deleted file mode 100644 index d2821c20c..000000000 --- a/src/wx/timeline_dialog.h +++ /dev/null @@ -1,48 +0,0 @@ -/* - Copyright (C) 2013-2021 Carl Hetherington - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see . - -*/ - - -#include "content_timeline.h" -#include -LIBDCP_DISABLE_WARNINGS -#include -LIBDCP_ENABLE_WARNINGS - - -class Playlist; - - -class TimelineDialog : public wxDialog -{ -public: - TimelineDialog(ContentPanel *, std::shared_ptr, FilmViewer& viewer); - - void set_selection (ContentList selection); - -private: - void film_change(ChangeType type, FilmProperty); - void tool_clicked (wxCommandEvent& id); - void keypress(wxKeyEvent const& event); - - std::weak_ptr _film; - ContentTimeline _timeline; - wxToolBar* _toolbar; - boost::signals2::scoped_connection _film_changed_connection; -}; diff --git a/src/wx/wscript b/src/wx/wscript index 2693bfa57..d6f1536e9 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -49,6 +49,7 @@ sources = """ content_properties_dialog.cc content_sub_panel.cc content_timeline.cc + content_timeline_dialog.cc content_timeline_view.cc content_version_dialog.cc content_view.cc @@ -165,7 +166,6 @@ sources = """ timeline.cc timeline_atmos_content_view.cc timeline_content_view.cc - timeline_dialog.cc timeline_audio_content_view.cc timeline_labels_view.cc timeline_text_content_view.cc -- cgit v1.2.3 From e5b053031e94a273ed889cd9e309d7d41c33a70d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 15 Dec 2023 00:32:00 +0100 Subject: Rename TimelineAtmosContentView -> ContentTimelineAtmosView. --- src/wx/content_timeline.cc | 6 ++--- src/wx/content_timeline_atmos_view.cc | 50 +++++++++++++++++++++++++++++++++++ src/wx/content_timeline_atmos_view.h | 40 ++++++++++++++++++++++++++++ src/wx/timeline_atmos_content_view.cc | 50 ----------------------------------- src/wx/timeline_atmos_content_view.h | 40 ---------------------------- src/wx/wscript | 2 +- 6 files changed, 94 insertions(+), 94 deletions(-) create mode 100644 src/wx/content_timeline_atmos_view.cc create mode 100644 src/wx/content_timeline_atmos_view.h delete mode 100644 src/wx/timeline_atmos_content_view.cc delete mode 100644 src/wx/timeline_atmos_content_view.h (limited to 'src') diff --git a/src/wx/content_timeline.cc b/src/wx/content_timeline.cc index d5ed0f7bb..0f993108d 100644 --- a/src/wx/content_timeline.cc +++ b/src/wx/content_timeline.cc @@ -22,7 +22,7 @@ #include "content_timeline.h" #include "film_editor.h" #include "film_viewer.h" -#include "timeline_atmos_content_view.h" +#include "content_timeline_atmos_view.h" #include "timeline_audio_content_view.h" #include "timeline_labels_view.h" #include "timeline_reels_view.h" @@ -315,7 +315,7 @@ ContentTimeline::recreate_views() } if (i->atmos) { - _views.push_back (make_shared(*this, i)); + _views.push_back(make_shared(*this, i)); } } @@ -457,7 +457,7 @@ ContentTimeline::assign_tracks() bool have_atmos = false; for (auto i: _views) { - auto cv = dynamic_pointer_cast(i); + auto cv = dynamic_pointer_cast(i); if (cv) { cv->set_track (_tracks); have_atmos = true; diff --git a/src/wx/content_timeline_atmos_view.cc b/src/wx/content_timeline_atmos_view.cc new file mode 100644 index 000000000..4b78a8aee --- /dev/null +++ b/src/wx/content_timeline_atmos_view.cc @@ -0,0 +1,50 @@ +/* + Copyright (C) 2016-2021 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "content_timeline_atmos_view.h" + + +using std::shared_ptr; + + +/** @class ContentTimelineContentView + * @brief Content timeline view for AtmosContent. + */ + +ContentTimelineAtmosView::ContentTimelineAtmosView(ContentTimeline& tl, shared_ptr c) + : TimelineContentView (tl, c) +{ + +} + + +wxColour +ContentTimelineAtmosView::background_colour() const +{ + return wxColour (149, 121, 232, 255); +} + + +wxColour +ContentTimelineAtmosView::foreground_colour() const +{ + return wxColour (0, 0, 0, 255); +} diff --git a/src/wx/content_timeline_atmos_view.h b/src/wx/content_timeline_atmos_view.h new file mode 100644 index 000000000..d5fea9248 --- /dev/null +++ b/src/wx/content_timeline_atmos_view.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2016-2021 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "timeline_content_view.h" + + +/** @class ContentTimelineAtmosContentView + * @brief Content timeline view for AtmosContent. + */ +class ContentTimelineAtmosView : public TimelineContentView +{ +public: + ContentTimelineAtmosView(ContentTimeline& tl, std::shared_ptr c); + +private: + bool active () const override { + return true; + } + + wxColour background_colour () const override; + wxColour foreground_colour () const override; +}; diff --git a/src/wx/timeline_atmos_content_view.cc b/src/wx/timeline_atmos_content_view.cc deleted file mode 100644 index d40ede137..000000000 --- a/src/wx/timeline_atmos_content_view.cc +++ /dev/null @@ -1,50 +0,0 @@ -/* - Copyright (C) 2016-2021 Carl Hetherington - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see . - -*/ - - -#include "timeline_atmos_content_view.h" - - -using std::shared_ptr; - - -/** @class TimelineAtmosContentView - * @brief Timeline view for AtmosContent. - */ - -TimelineAtmosContentView::TimelineAtmosContentView(ContentTimeline& tl, shared_ptr c) - : TimelineContentView (tl, c) -{ - -} - - -wxColour -TimelineAtmosContentView::background_colour () const -{ - return wxColour (149, 121, 232, 255); -} - - -wxColour -TimelineAtmosContentView::foreground_colour () const -{ - return wxColour (0, 0, 0, 255); -} diff --git a/src/wx/timeline_atmos_content_view.h b/src/wx/timeline_atmos_content_view.h deleted file mode 100644 index 9536837e0..000000000 --- a/src/wx/timeline_atmos_content_view.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 2016-2021 Carl Hetherington - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see . - -*/ - - -#include "timeline_content_view.h" - - -/** @class TimelineAtmosContentView - * @brief Timeline view for AtmosContent. - */ -class TimelineAtmosContentView : public TimelineContentView -{ -public: - TimelineAtmosContentView(ContentTimeline& tl, std::shared_ptr c); - -private: - bool active () const override { - return true; - } - - wxColour background_colour () const override; - wxColour foreground_colour () const override; -}; diff --git a/src/wx/wscript b/src/wx/wscript index d6f1536e9..f9573bd6d 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -49,6 +49,7 @@ sources = """ content_properties_dialog.cc content_sub_panel.cc content_timeline.cc + content_timeline_atmos_view.cc content_timeline_dialog.cc content_timeline_view.cc content_version_dialog.cc @@ -164,7 +165,6 @@ sources = """ timer_display.cc timecode.cc timeline.cc - timeline_atmos_content_view.cc timeline_content_view.cc timeline_audio_content_view.cc timeline_labels_view.cc -- cgit v1.2.3 From 306c28facff88f38dd03831062dedd5a865578fe Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 15 Dec 2023 00:40:41 +0100 Subject: Rename TimelineAudioContentView -> ContentTimelineAudioView. --- src/wx/content_menu.cc | 6 +-- src/wx/content_timeline.cc | 10 ++--- src/wx/content_timeline_audio_view.cc | 85 +++++++++++++++++++++++++++++++++++ src/wx/content_timeline_audio_view.h | 40 +++++++++++++++++ src/wx/timeline_audio_content_view.cc | 85 ----------------------------------- src/wx/timeline_audio_content_view.h | 40 ----------------- src/wx/wscript | 2 +- 7 files changed, 134 insertions(+), 134 deletions(-) create mode 100644 src/wx/content_timeline_audio_view.cc create mode 100644 src/wx/content_timeline_audio_view.h delete mode 100644 src/wx/timeline_audio_content_view.cc delete mode 100644 src/wx/timeline_audio_content_view.h (limited to 'src') diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc index 4af5a71b7..9f89835ff 100644 --- a/src/wx/content_menu.cc +++ b/src/wx/content_menu.cc @@ -23,13 +23,13 @@ #include "content_advanced_dialog.h" #include "content_menu.h" #include "content_properties_dialog.h" +#include "content_timeline_audio_view.h" #include "dir_dialog.h" #include "file_dialog.h" #include "film_viewer.h" #include "id.h" #include "repeat_dialog.h" #include "timeline_video_content_view.h" -#include "timeline_audio_content_view.h" #include "wx_util.h" #include "lib/audio_content.h" #include "lib/config.h" @@ -315,11 +315,11 @@ ContentMenu::remove () } shared_ptr video; - shared_ptr audio; + shared_ptr audio; for (auto j: _views) { auto v = dynamic_pointer_cast(j); - auto a = dynamic_pointer_cast(j); + auto a = dynamic_pointer_cast(j); if (v && v->content() == fc) { video = v; } else if (a && a->content() == fc) { diff --git a/src/wx/content_timeline.cc b/src/wx/content_timeline.cc index 0f993108d..3efb15d3f 100644 --- a/src/wx/content_timeline.cc +++ b/src/wx/content_timeline.cc @@ -23,7 +23,7 @@ #include "film_editor.h" #include "film_viewer.h" #include "content_timeline_atmos_view.h" -#include "timeline_audio_content_view.h" +#include "content_timeline_audio_view.h" #include "timeline_labels_view.h" #include "timeline_reels_view.h" #include "timeline_text_content_view.h" @@ -307,7 +307,7 @@ ContentTimeline::recreate_views() } if (i->audio && !i->audio->mapping().mapped_output_channels().empty ()) { - _views.push_back (make_shared(*this, i)); + _views.push_back(make_shared(*this, i)); } for (auto j: i->text) { @@ -406,13 +406,13 @@ place(shared_ptr film, ContentTimelineViewList& views, int& tracks) struct AudioMappingComparator { bool operator()(shared_ptr a, shared_ptr b) { int la = -1; - auto cva = dynamic_pointer_cast(a); + auto cva = dynamic_pointer_cast(a); if (cva) { auto oc = cva->content()->audio->mapping().mapped_output_channels(); la = *min_element(boost::begin(oc), boost::end(oc)); } int lb = -1; - auto cvb = dynamic_pointer_cast(b); + auto cvb = dynamic_pointer_cast(b); if (cvb) { auto oc = cvb->content()->audio->mapping().mapped_output_channels(); lb = *min_element(boost::begin(oc), boost::end(oc)); @@ -474,7 +474,7 @@ ContentTimeline::assign_tracks() auto views = _views; sort(views.begin(), views.end(), AudioMappingComparator()); - int const audio_tracks = place (film, views, _tracks); + int const audio_tracks = place(film, views, _tracks); _labels_view->set_video_tracks (video_tracks); _labels_view->set_audio_tracks (audio_tracks); diff --git a/src/wx/content_timeline_audio_view.cc b/src/wx/content_timeline_audio_view.cc new file mode 100644 index 000000000..9604ee7cc --- /dev/null +++ b/src/wx/content_timeline_audio_view.cc @@ -0,0 +1,85 @@ +/* + Copyright (C) 2013-2018 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "content_timeline_audio_view.h" +#include "wx_util.h" +#include "lib/audio_content.h" +#include "lib/util.h" + + +using std::dynamic_pointer_cast; +using std::list; +using std::shared_ptr; + + +/** @class ContentTimelineAudioView + * @brief Content timeline view for AudioContent. + */ + + +ContentTimelineAudioView::ContentTimelineAudioView(ContentTimeline& tl, shared_ptr c) + : TimelineContentView (tl, c) +{ + +} + +wxColour +ContentTimelineAudioView::background_colour () const +{ + return wxColour (149, 121, 232, 255); +} + +wxColour +ContentTimelineAudioView::foreground_colour () const +{ + return wxColour (0, 0, 0, 255); +} + +wxString +ContentTimelineAudioView::label () const +{ + wxString s = TimelineContentView::label (); + shared_ptr ac = content()->audio; + DCPOMATIC_ASSERT (ac); + + if (ac->gain() > 0.01) { + s += wxString::Format (" +%.1fdB", ac->gain()); + } else if (ac->gain() < -0.01) { + s += wxString::Format (" %.1fdB", ac->gain()); + } + + if (ac->delay() > 0) { + s += wxString::Format (_(" delayed by %dms"), ac->delay()); + } else if (ac->delay() < 0) { + s += wxString::Format (_(" advanced by %dms"), -ac->delay()); + } + + list mapped = ac->mapping().mapped_output_channels(); + if (!mapped.empty ()) { + s += wxString::FromUTF8(" → "); + for (auto i: mapped) { + s += std_to_wx(short_audio_channel_name(i)) + ", "; + } + s = s.Left(s.Length() - 2); + } + + return s; +} diff --git a/src/wx/content_timeline_audio_view.h b/src/wx/content_timeline_audio_view.h new file mode 100644 index 000000000..719c2536d --- /dev/null +++ b/src/wx/content_timeline_audio_view.h @@ -0,0 +1,40 @@ +/* + Copyright (C) 2013-2015 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "timeline_content_view.h" + + +/** @class ContentTimelineAudioView + * @brief Content timeline view for AudioContent. + */ +class ContentTimelineAudioView : public TimelineContentView +{ +public: + ContentTimelineAudioView(ContentTimeline& tl, std::shared_ptr c); + +private: + bool active () const override { + return true; + } + wxColour background_colour () const override; + wxColour foreground_colour () const override; + wxString label () const override; +}; diff --git a/src/wx/timeline_audio_content_view.cc b/src/wx/timeline_audio_content_view.cc deleted file mode 100644 index 2920bf4fd..000000000 --- a/src/wx/timeline_audio_content_view.cc +++ /dev/null @@ -1,85 +0,0 @@ -/* - Copyright (C) 2013-2018 Carl Hetherington - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see . - -*/ - - -#include "timeline_audio_content_view.h" -#include "wx_util.h" -#include "lib/audio_content.h" -#include "lib/util.h" - - -using std::dynamic_pointer_cast; -using std::list; -using std::shared_ptr; - - -/** @class TimelineAudioContentView - * @brief Timeline view for AudioContent. - */ - - -TimelineAudioContentView::TimelineAudioContentView(ContentTimeline& tl, shared_ptr c) - : TimelineContentView (tl, c) -{ - -} - -wxColour -TimelineAudioContentView::background_colour () const -{ - return wxColour (149, 121, 232, 255); -} - -wxColour -TimelineAudioContentView::foreground_colour () const -{ - return wxColour (0, 0, 0, 255); -} - -wxString -TimelineAudioContentView::label () const -{ - wxString s = TimelineContentView::label (); - shared_ptr ac = content()->audio; - DCPOMATIC_ASSERT (ac); - - if (ac->gain() > 0.01) { - s += wxString::Format (" +%.1fdB", ac->gain()); - } else if (ac->gain() < -0.01) { - s += wxString::Format (" %.1fdB", ac->gain()); - } - - if (ac->delay() > 0) { - s += wxString::Format (_(" delayed by %dms"), ac->delay()); - } else if (ac->delay() < 0) { - s += wxString::Format (_(" advanced by %dms"), -ac->delay()); - } - - list mapped = ac->mapping().mapped_output_channels(); - if (!mapped.empty ()) { - s += wxString::FromUTF8(" → "); - for (auto i: mapped) { - s += std_to_wx(short_audio_channel_name(i)) + ", "; - } - s = s.Left(s.Length() - 2); - } - - return s; -} diff --git a/src/wx/timeline_audio_content_view.h b/src/wx/timeline_audio_content_view.h deleted file mode 100644 index 29849adb2..000000000 --- a/src/wx/timeline_audio_content_view.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 2013-2015 Carl Hetherington - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see . - -*/ - - -#include "timeline_content_view.h" - - -/** @class TimelineAudioContentView - * @brief Timeline view for AudioContent. - */ -class TimelineAudioContentView : public TimelineContentView -{ -public: - TimelineAudioContentView(ContentTimeline& tl, std::shared_ptr c); - -private: - bool active () const override { - return true; - } - wxColour background_colour () const override; - wxColour foreground_colour () const override; - wxString label () const override; -}; diff --git a/src/wx/wscript b/src/wx/wscript index f9573bd6d..c2bcd72c5 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -50,6 +50,7 @@ sources = """ content_sub_panel.cc content_timeline.cc content_timeline_atmos_view.cc + content_timeline_audio_view.cc content_timeline_dialog.cc content_timeline_view.cc content_version_dialog.cc @@ -166,7 +167,6 @@ sources = """ timecode.cc timeline.cc timeline_content_view.cc - timeline_audio_content_view.cc timeline_labels_view.cc timeline_text_content_view.cc timeline_reels_view.cc -- cgit v1.2.3 From 1a9f9c30e355ff8c3085d7514984df02942a6336 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 15 Dec 2023 01:04:26 +0100 Subject: Rename TimelineVideoContentView -> ContentTimelineVideoView. --- src/wx/content_menu.cc | 6 ++-- src/wx/content_timeline.cc | 6 ++-- src/wx/content_timeline_video_view.cc | 63 +++++++++++++++++++++++++++++++++++ src/wx/content_timeline_video_view.h | 37 ++++++++++++++++++++ src/wx/timeline_video_content_view.cc | 63 ----------------------------------- src/wx/timeline_video_content_view.h | 37 -------------------- src/wx/wscript | 2 +- 7 files changed, 107 insertions(+), 107 deletions(-) create mode 100644 src/wx/content_timeline_video_view.cc create mode 100644 src/wx/content_timeline_video_view.h delete mode 100644 src/wx/timeline_video_content_view.cc delete mode 100644 src/wx/timeline_video_content_view.h (limited to 'src') diff --git a/src/wx/content_menu.cc b/src/wx/content_menu.cc index 9f89835ff..9c50d56da 100644 --- a/src/wx/content_menu.cc +++ b/src/wx/content_menu.cc @@ -24,12 +24,12 @@ #include "content_menu.h" #include "content_properties_dialog.h" #include "content_timeline_audio_view.h" +#include "content_timeline_video_view.h" #include "dir_dialog.h" #include "file_dialog.h" #include "film_viewer.h" #include "id.h" #include "repeat_dialog.h" -#include "timeline_video_content_view.h" #include "wx_util.h" #include "lib/audio_content.h" #include "lib/config.h" @@ -314,11 +314,11 @@ ContentMenu::remove () continue; } - shared_ptr video; + shared_ptr video; shared_ptr audio; for (auto j: _views) { - auto v = dynamic_pointer_cast(j); + auto v = dynamic_pointer_cast(j); auto a = dynamic_pointer_cast(j); if (v && v->content() == fc) { video = v; diff --git a/src/wx/content_timeline.cc b/src/wx/content_timeline.cc index 3efb15d3f..5e104f3b7 100644 --- a/src/wx/content_timeline.cc +++ b/src/wx/content_timeline.cc @@ -24,11 +24,11 @@ #include "film_viewer.h" #include "content_timeline_atmos_view.h" #include "content_timeline_audio_view.h" +#include "content_timeline_video_view.h" #include "timeline_labels_view.h" #include "timeline_reels_view.h" #include "timeline_text_content_view.h" #include "timeline_time_axis_view.h" -#include "timeline_video_content_view.h" #include "wx_util.h" #include "lib/atmos_mxf_content.h" #include "lib/audio_content.h" @@ -303,7 +303,7 @@ ContentTimeline::recreate_views() for (auto i: film->content ()) { if (i->video) { - _views.push_back (make_shared(*this, i)); + _views.push_back(make_shared(*this, i)); } if (i->audio && !i->audio->mapping().mapped_output_channels().empty ()) { @@ -450,7 +450,7 @@ ContentTimeline::assign_tracks() } } - int const video_tracks = place (film, _views, _tracks); + int const video_tracks = place(film, _views, _tracks); int const text_tracks = place (film, _views, _tracks); /* Atmos */ diff --git a/src/wx/content_timeline_video_view.cc b/src/wx/content_timeline_video_view.cc new file mode 100644 index 000000000..63b26a570 --- /dev/null +++ b/src/wx/content_timeline_video_view.cc @@ -0,0 +1,63 @@ +/* + Copyright (C) 2013-2019 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "lib/image_content.h" +#include "lib/video_content.h" +#include "content_timeline_video_view.h" + + +using std::dynamic_pointer_cast; +using std::shared_ptr; + + +ContentTimelineVideoView::ContentTimelineVideoView(ContentTimeline& tl, shared_ptr c) + : TimelineContentView (tl, c) +{ + +} + +wxColour +ContentTimelineVideoView::background_colour() const +{ + if (!active()) { + return wxColour (210, 210, 210, 128); + } + + return wxColour (242, 92, 120, 255); +} + +wxColour +ContentTimelineVideoView::foreground_colour() const +{ + if (!active()) { + return wxColour (180, 180, 180, 128); + } + + return wxColour (0, 0, 0, 255); +} + +bool +ContentTimelineVideoView::active() const +{ + auto c = _content.lock(); + DCPOMATIC_ASSERT (c); + return c->video && c->video->use(); +} diff --git a/src/wx/content_timeline_video_view.h b/src/wx/content_timeline_video_view.h new file mode 100644 index 000000000..940a1a305 --- /dev/null +++ b/src/wx/content_timeline_video_view.h @@ -0,0 +1,37 @@ +/* + Copyright (C) 2013-2015 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "timeline_content_view.h" + + +/** @class ContentTimelineVideoView + * @brief Content timeline view for VideoContent. + */ +class ContentTimelineVideoView : public TimelineContentView +{ +public: + ContentTimelineVideoView(ContentTimeline& tl, std::shared_ptr c); + +private: + bool active () const override; + wxColour background_colour () const override; + wxColour foreground_colour () const override; +}; diff --git a/src/wx/timeline_video_content_view.cc b/src/wx/timeline_video_content_view.cc deleted file mode 100644 index d72b1e149..000000000 --- a/src/wx/timeline_video_content_view.cc +++ /dev/null @@ -1,63 +0,0 @@ -/* - Copyright (C) 2013-2019 Carl Hetherington - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see . - -*/ - - -#include "lib/image_content.h" -#include "lib/video_content.h" -#include "timeline_video_content_view.h" - - -using std::dynamic_pointer_cast; -using std::shared_ptr; - - -TimelineVideoContentView::TimelineVideoContentView(ContentTimeline& tl, shared_ptr c) - : TimelineContentView (tl, c) -{ - -} - -wxColour -TimelineVideoContentView::background_colour () const -{ - if (!active()) { - return wxColour (210, 210, 210, 128); - } - - return wxColour (242, 92, 120, 255); -} - -wxColour -TimelineVideoContentView::foreground_colour () const -{ - if (!active()) { - return wxColour (180, 180, 180, 128); - } - - return wxColour (0, 0, 0, 255); -} - -bool -TimelineVideoContentView::active () const -{ - shared_ptr c = _content.lock (); - DCPOMATIC_ASSERT (c); - return c->video && c->video->use(); -} diff --git a/src/wx/timeline_video_content_view.h b/src/wx/timeline_video_content_view.h deleted file mode 100644 index 507f3caed..000000000 --- a/src/wx/timeline_video_content_view.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - Copyright (C) 2013-2015 Carl Hetherington - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see . - -*/ - - -#include "timeline_content_view.h" - - -/** @class TimelineVideoContentView - * @brief Timeline view for VideoContent. - */ -class TimelineVideoContentView : public TimelineContentView -{ -public: - TimelineVideoContentView(ContentTimeline& tl, std::shared_ptr c); - -private: - bool active () const override; - wxColour background_colour () const override; - wxColour foreground_colour () const override; -}; diff --git a/src/wx/wscript b/src/wx/wscript index c2bcd72c5..a3e3c06ed 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -52,6 +52,7 @@ sources = """ content_timeline_atmos_view.cc content_timeline_audio_view.cc content_timeline_dialog.cc + content_timeline_video_view.cc content_timeline_view.cc content_version_dialog.cc content_view.cc @@ -171,7 +172,6 @@ sources = """ timeline_text_content_view.cc timeline_reels_view.cc timeline_time_axis_view.cc - timeline_video_content_view.cc timing_panel.cc try_unmount_dialog.cc update_dialog.cc -- cgit v1.2.3 From 50931fab031d9dcdba131cb07ddd13e3528ab697 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 15 Dec 2023 01:32:41 +0100 Subject: Rename TimelineTextContentView -> ContentTimelineTextView. --- src/wx/content_timeline.cc | 6 ++-- src/wx/content_timeline_text_view.cc | 61 ++++++++++++++++++++++++++++++++++++ src/wx/content_timeline_text_view.h | 42 +++++++++++++++++++++++++ src/wx/timeline_text_content_view.cc | 61 ------------------------------------ src/wx/timeline_text_content_view.h | 42 ------------------------- src/wx/wscript | 2 +- 6 files changed, 107 insertions(+), 107 deletions(-) create mode 100644 src/wx/content_timeline_text_view.cc create mode 100644 src/wx/content_timeline_text_view.h delete mode 100644 src/wx/timeline_text_content_view.cc delete mode 100644 src/wx/timeline_text_content_view.h (limited to 'src') diff --git a/src/wx/content_timeline.cc b/src/wx/content_timeline.cc index 5e104f3b7..7257f3587 100644 --- a/src/wx/content_timeline.cc +++ b/src/wx/content_timeline.cc @@ -24,10 +24,10 @@ #include "film_viewer.h" #include "content_timeline_atmos_view.h" #include "content_timeline_audio_view.h" +#include "content_timeline_text_view.h" #include "content_timeline_video_view.h" #include "timeline_labels_view.h" #include "timeline_reels_view.h" -#include "timeline_text_content_view.h" #include "timeline_time_axis_view.h" #include "wx_util.h" #include "lib/atmos_mxf_content.h" @@ -311,7 +311,7 @@ ContentTimeline::recreate_views() } for (auto j: i->text) { - _views.push_back (make_shared(*this, i, j)); + _views.push_back(make_shared(*this, i, j)); } if (i->atmos) { @@ -451,7 +451,7 @@ ContentTimeline::assign_tracks() } int const video_tracks = place(film, _views, _tracks); - int const text_tracks = place (film, _views, _tracks); + int const text_tracks = place(film, _views, _tracks); /* Atmos */ diff --git a/src/wx/content_timeline_text_view.cc b/src/wx/content_timeline_text_view.cc new file mode 100644 index 000000000..3b7eeebce --- /dev/null +++ b/src/wx/content_timeline_text_view.cc @@ -0,0 +1,61 @@ +/* + Copyright (C) 2013-2018 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "content_timeline_text_view.h" +#include "lib/text_content.h" +#include "lib/content.h" + + +using std::shared_ptr; + + +ContentTimelineTextView::ContentTimelineTextView(ContentTimeline& tl, shared_ptr c, shared_ptr caption) + : TimelineContentView (tl, c) + , _caption (caption) +{ + +} + +wxColour +ContentTimelineTextView::background_colour() const +{ + if (!active ()) { + return wxColour (210, 210, 210, 128); + } + + return wxColour (163, 255, 154, 255); +} + +wxColour +ContentTimelineTextView::foreground_colour() const +{ + if (!active ()) { + return wxColour (180, 180, 180, 128); + } + + return wxColour (0, 0, 0, 255); +} + +bool +ContentTimelineTextView::active() const +{ + return _caption->use(); +} diff --git a/src/wx/content_timeline_text_view.h b/src/wx/content_timeline_text_view.h new file mode 100644 index 000000000..8d37ad489 --- /dev/null +++ b/src/wx/content_timeline_text_view.h @@ -0,0 +1,42 @@ +/* + Copyright (C) 2013-2016 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "timeline_content_view.h" + + +class TextContent; + + +/** @class ContentTimelineTextView + * @brief Content timeline view for TextContent. + */ +class ContentTimelineTextView : public TimelineContentView +{ +public: + ContentTimelineTextView(ContentTimeline& tl, std::shared_ptr, std::shared_ptr); + +private: + bool active () const override; + wxColour background_colour () const override; + wxColour foreground_colour () const override; + + std::shared_ptr _caption; +}; diff --git a/src/wx/timeline_text_content_view.cc b/src/wx/timeline_text_content_view.cc deleted file mode 100644 index bc099d4d6..000000000 --- a/src/wx/timeline_text_content_view.cc +++ /dev/null @@ -1,61 +0,0 @@ -/* - Copyright (C) 2013-2018 Carl Hetherington - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see . - -*/ - - -#include "timeline_text_content_view.h" -#include "lib/text_content.h" -#include "lib/content.h" - - -using std::shared_ptr; - - -TimelineTextContentView::TimelineTextContentView(ContentTimeline& tl, shared_ptr c, shared_ptr caption) - : TimelineContentView (tl, c) - , _caption (caption) -{ - -} - -wxColour -TimelineTextContentView::background_colour () const -{ - if (!active ()) { - return wxColour (210, 210, 210, 128); - } - - return wxColour (163, 255, 154, 255); -} - -wxColour -TimelineTextContentView::foreground_colour () const -{ - if (!active ()) { - return wxColour (180, 180, 180, 128); - } - - return wxColour (0, 0, 0, 255); -} - -bool -TimelineTextContentView::active () const -{ - return _caption->use(); -} diff --git a/src/wx/timeline_text_content_view.h b/src/wx/timeline_text_content_view.h deleted file mode 100644 index c33c2662e..000000000 --- a/src/wx/timeline_text_content_view.h +++ /dev/null @@ -1,42 +0,0 @@ -/* - Copyright (C) 2013-2016 Carl Hetherington - - This file is part of DCP-o-matic. - - DCP-o-matic is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 2 of the License, or - (at your option) any later version. - - DCP-o-matic is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with DCP-o-matic. If not, see . - -*/ - - -#include "timeline_content_view.h" - - -class TextContent; - - -/** @class TimelineTextContentView - * @brief Timeline view for TextContent. - */ -class TimelineTextContentView : public TimelineContentView -{ -public: - TimelineTextContentView(ContentTimeline& tl, std::shared_ptr, std::shared_ptr); - -private: - bool active () const override; - wxColour background_colour () const override; - wxColour foreground_colour () const override; - - std::shared_ptr _caption; -}; diff --git a/src/wx/wscript b/src/wx/wscript index a3e3c06ed..c644af96c 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -52,6 +52,7 @@ sources = """ content_timeline_atmos_view.cc content_timeline_audio_view.cc content_timeline_dialog.cc + content_timeline_text_view.cc content_timeline_video_view.cc content_timeline_view.cc content_version_dialog.cc @@ -169,7 +170,6 @@ sources = """ timeline.cc timeline_content_view.cc timeline_labels_view.cc - timeline_text_content_view.cc timeline_reels_view.cc timeline_time_axis_view.cc timing_panel.cc -- cgit v1.2.3 From 5d53e906d6f73ad9f9ae85a423a18f5814904bdb Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 13 Dec 2023 23:44:54 +0100 Subject: Split out TimelineView from ContentTimelineView. --- src/wx/content_timeline_view.cc | 31 ++---------------- src/wx/content_timeline_view.h | 23 +++++--------- src/wx/timeline_view.h | 69 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 44 deletions(-) create mode 100644 src/wx/timeline_view.h (limited to 'src') diff --git a/src/wx/content_timeline_view.cc b/src/wx/content_timeline_view.cc index 05922d558..127e440fa 100644 --- a/src/wx/content_timeline_view.cc +++ b/src/wx/content_timeline_view.cc @@ -27,39 +27,12 @@ using std::list; using namespace dcpomatic; -/** @class ContentContentTimelineView - * @brief Parent class for components of the content timeline (e.g. a piece of content or an axis). - */ -ContentTimelineView::ContentTimelineView(ContentTimeline& t) - : _timeline (t) +ContentTimelineView::ContentTimelineView(ContentTimeline& timeline) + : TimelineView(timeline) { } - -void -ContentTimelineView::paint(wxGraphicsContext* g, list> overlaps) -{ - _last_paint_bbox = bbox (); - do_paint (g, overlaps); -} - - -void -ContentTimelineView::force_redraw() -{ - _timeline.force_redraw (_last_paint_bbox.extended(4)); - _timeline.force_redraw (bbox().extended(4)); -} - - -int -ContentTimelineView::time_x(DCPTime t) const -{ - return t.seconds() * _timeline.pixels_per_second().get_value_or(0); -} - - int ContentTimelineView::y_pos(int t) const { diff --git a/src/wx/content_timeline_view.h b/src/wx/content_timeline_view.h index 0f6eeae51..450d19df4 100644 --- a/src/wx/content_timeline_view.h +++ b/src/wx/content_timeline_view.h @@ -23,6 +23,7 @@ #define DCPOMATIC_CONTENT_TIMELINE_VIEW_H +#include "timeline_view.h" #include "lib/rect.h" #include "lib/dcpomatic_time.h" @@ -34,30 +35,22 @@ class ContentTimeline; /** @class ContentTimelineView * @brief Parent class for components of the content timeline (e.g. a piece of content or an axis). */ -class ContentTimelineView +class ContentTimelineView : public TimelineView { public: explicit ContentTimelineView(ContentTimeline& t); virtual ~ContentTimelineView () = default; - ContentTimelineView(ContentTimelineView const&) = delete; - ContentTimelineView& operator=(ContentTimelineView const&) = delete; - - void paint (wxGraphicsContext* g, std::list> overlaps); - void force_redraw (); - - virtual dcpomatic::Rect bbox () const = 0; + void paint(wxGraphicsContext* gc, std::list> overlaps) + { + _last_paint_bbox = bbox(); + do_paint(gc, overlaps); + } protected: - virtual void do_paint (wxGraphicsContext *, std::list> overlaps) = 0; + virtual void do_paint(wxGraphicsContext *, std::list> overlaps) = 0; - int time_x (dcpomatic::DCPTime t) const; int y_pos(int t) const; - - ContentTimeline& _timeline; - -private: - dcpomatic::Rect _last_paint_bbox; }; diff --git a/src/wx/timeline_view.h b/src/wx/timeline_view.h new file mode 100644 index 000000000..32eedde09 --- /dev/null +++ b/src/wx/timeline_view.h @@ -0,0 +1,69 @@ +/* + Copyright (C) 2023 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#ifndef DCPOMATIC_TIMELINE_VIEW_H +#define DCPOMATIC_TIMELINE_VIEW_H + + +#include "lib/rect.h" +#include "lib/dcpomatic_time.h" + + +class wxGraphicsContext; + + +/** @class ContentTimelineView + * @brief Parent class for components of the content timeline (e.g. a piece of content or an axis). + */ +template +class TimelineView +{ +public: + explicit TimelineView(Timeline& timeline) + : _timeline(timeline) + {} + + virtual ~TimelineView () = default; + + TimelineView(TimelineView const&) = delete; + TimelineView& operator=(TimelineView const&) = delete; + + void force_redraw() + { + _timeline.force_redraw(_last_paint_bbox.extended(4)); + _timeline.force_redraw(bbox().extended(4)); + } + + virtual dcpomatic::Rect bbox() const = 0; + +protected: + int time_x(dcpomatic::DCPTime t) const + { + return t.seconds() * _timeline.pixels_per_second().get_value_or(0); + } + + Timeline& _timeline; + dcpomatic::Rect _last_paint_bbox; +}; + + +#endif + -- cgit v1.2.3 From afed87b4f64f8cb4d99a0cad0eda664a604a10f7 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 16 Dec 2023 22:50:25 +0100 Subject: Use std::vector and emplace_back(), lengthen variable name. --- src/lib/film.cc | 18 ++++++++++-------- src/lib/film.h | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) (limited to 'src') diff --git a/src/lib/film.cc b/src/lib/film.cc index d747efb0e..d94ef0af3 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1804,15 +1804,16 @@ Film::audio_analysis_finished () /* XXX */ } -list + +vector Film::reels () const { - list p; + vector periods; auto const len = length(); switch (reel_type ()) { case ReelType::SINGLE: - p.push_back (DCPTimePeriod (DCPTime (), len)); + periods.emplace_back(DCPTime(), len); break; case ReelType::BY_VIDEO_CONTENT: { @@ -1837,7 +1838,7 @@ Film::reels () const for (auto t: split_points) { if (last && (t - *last) >= DCPTime::from_seconds(1)) { /* Period from *last to t is long enough; use it and start a new one */ - p.push_back (DCPTimePeriod(*last, t)); + periods.emplace_back(*last, t); last = t; } else if (!last) { /* That was the first time, so start a new period */ @@ -1845,8 +1846,8 @@ Film::reels () const } } - if (!p.empty()) { - p.back().to = split_points.back(); + if (!periods.empty()) { + periods.back().to = split_points.back(); } break; } @@ -1859,16 +1860,17 @@ Film::reels () const Frame const reel_in_frames = max(_reel_length / ((j2k_bandwidth() / video_frame_rate()) / 8), static_cast(video_frame_rate())); while (current < len) { DCPTime end = min (len, current + DCPTime::from_frames (reel_in_frames, video_frame_rate ())); - p.push_back (DCPTimePeriod (current, end)); + periods.emplace_back(current, end); current = end; } break; } } - return p; + return periods; } + /** @param period A period within the DCP * @return Name of the content which most contributes to the given period. */ diff --git a/src/lib/film.h b/src/lib/film.h index 036bbed7e..a5cefa4d4 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -186,7 +186,7 @@ public: return _playlist; } - std::list reels () const; + std::vector reels() const; std::list mapped_audio_channels () const; boost::optional audio_language () const { -- cgit v1.2.3 From 4fa9f7e81789b44e5e61b01e4c5352a616d9ae6d Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Sat, 16 Dec 2023 23:23:58 +0100 Subject: Remove reel type / length controls from DCP panel. --- src/wx/dcp_panel.cc | 60 ----------------------------------------------------- src/wx/dcp_panel.h | 7 ------- 2 files changed, 67 deletions(-) (limited to 'src') diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index b789a1a74..1afc1be3d 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -106,13 +106,6 @@ DCPPanel::DCPPanel(wxNotebook* n, shared_ptr film, FilmViewer& viewer) auto size = dc.GetTextExtent (wxT ("GGGGGGGG...")); size.SetHeight (-1); - _reels_label = create_label (_panel, _("Reels"), true); - _reel_type = new Choice(_panel); - - _reel_length_label = create_label (_panel, _("Reel length"), true); - _reel_length = new SpinCtrl (_panel, DCPOMATIC_SPIN_CTRL_WIDTH); - _reel_length_gb_label = create_label (_panel, _("GB"), false); - _standard_label = create_label (_panel, _("Standard"), true); _standard = new Choice(_panel); @@ -130,8 +123,6 @@ DCPPanel::DCPPanel(wxNotebook* n, shared_ptr film, FilmViewer& viewer) _copy_isdcf_name_button->Bind(wxEVT_BUTTON, boost::bind(&DCPPanel::copy_isdcf_name_button_clicked, this)); _dcp_content_type->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::dcp_content_type_changed, this)); _encrypted->bind(&DCPPanel::encrypted_toggled, this); - _reel_type->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::reel_type_changed, this)); - _reel_length->Bind (wxEVT_SPINCTRL, boost::bind(&DCPPanel::reel_length_changed, this)); _standard->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::standard_changed, this)); _markers->Bind (wxEVT_BUTTON, boost::bind(&DCPPanel::markers_clicked, this)); _metadata->Bind (wxEVT_BUTTON, boost::bind(&DCPPanel::metadata_clicked, this)); @@ -139,13 +130,6 @@ DCPPanel::DCPPanel(wxNotebook* n, shared_ptr film, FilmViewer& viewer) _dcp_content_type->add(i->pretty_name()); } - _reel_type->add(_("Single reel")); - _reel_type->add(_("Split by video content")); - _reel_type->add(S_("Split by maximum reel size")); - _reel_type->SetToolTip(_("How the DCP should be split into parts internally. If in doubt, choose 'Single reel'")); - - _reel_length->SetRange (1, 64); - add_standards(); _standard->SetToolTip(_("The standard that the DCP should use. Interop is older, and SMPTE is the newer (current) standard. If in doubt, choose 'SMPTE'")); @@ -240,19 +224,6 @@ DCPPanel::add_to_grid () _grid->Add (_encrypted, wxGBPosition(r, 0), wxGBSpan(1, 2)); ++r; - add_label_to_sizer (_grid, _reels_label, true, wxGBPosition(r, 0)); - _grid->Add (_reel_type, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); - ++r; - - add_label_to_sizer (_grid, _reel_length_label, true, wxGBPosition(r, 0)); - { - auto s = new wxBoxSizer (wxHORIZONTAL); - s->Add (_reel_length); - add_label_to_sizer (s, _reel_length_gb_label, false, 0, wxLEFT | wxALIGN_CENTER_VERTICAL); - _grid->Add (s, wxGBPosition(r, 1)); - } - ++r; - add_label_to_sizer (_grid, _standard_label, true, wxGBPosition(r, 0)); _grid->Add (_standard, wxGBPosition(r, 1), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); ++r; @@ -473,13 +444,6 @@ DCPPanel::film_changed(FilmProperty p) setup_audio_channels_choice (_audio_channels, minimum_allowed_audio_channels()); film_changed (FilmProperty::AUDIO_CHANNELS); break; - case FilmProperty::REEL_TYPE: - checked_set (_reel_type, static_cast(_film->reel_type())); - _reel_length->Enable (_film->reel_type() == ReelType::BY_LENGTH); - break; - case FilmProperty::REEL_LENGTH: - checked_set (_reel_length, _film->reel_length() / 1000000000LL); - break; case FilmProperty::CONTENT: setup_dcp_name (); setup_sensitivity (); @@ -665,8 +629,6 @@ DCPPanel::setup_sensitivity () _audio_language->Enable (_enable_audio_language->GetValue()); _edit_audio_language->Enable (_enable_audio_language->GetValue()); _encrypted->Enable (_generally_sensitive); - _reel_type->Enable (_generally_sensitive && _film && !_film->references_dcp_video() && !_film->references_dcp_audio()); - _reel_length->Enable (_generally_sensitive && _film && _film->reel_type() == ReelType::BY_LENGTH); _markers->Enable (_generally_sensitive && _film && !_film->interop()); _metadata->Enable (_generally_sensitive); _frame_rate_choice->Enable (_generally_sensitive && _film && !_film->references_dcp_video() && !_film->contains_atmos_content()); @@ -1031,28 +993,6 @@ DCPPanel::show_audio_clicked () } -void -DCPPanel::reel_type_changed () -{ - if (!_film || !_reel_type->get()) { - return; - } - - _film->set_reel_type(static_cast(*_reel_type->get())); -} - - -void -DCPPanel::reel_length_changed () -{ - if (!_film) { - return; - } - - _film->set_reel_length (_reel_length->GetValue() * 1000000000LL); -} - - void DCPPanel::add_audio_processors () { diff --git a/src/wx/dcp_panel.h b/src/wx/dcp_panel.h index 849fe185c..a5af58921 100644 --- a/src/wx/dcp_panel.h +++ b/src/wx/dcp_panel.h @@ -82,8 +82,6 @@ private: void encrypted_toggled (); void audio_processor_changed (); void show_audio_clicked (); - void reel_type_changed (); - void reel_length_changed (); void markers_clicked (); void metadata_clicked (); void reencode_j2k_changed (); @@ -153,11 +151,6 @@ private: wxStaticText* _standard_label; Choice* _standard; CheckBox* _encrypted; - wxStaticText* _reels_label; - Choice* _reel_type; - wxStaticText* _reel_length_label; - wxStaticText* _reel_length_gb_label; - wxSpinCtrl* _reel_length; wxButton* _markers; wxButton* _metadata; wxSizer* _audio_panel_sizer; -- cgit v1.2.3 From 521424e747dced3ade9600fc62c48526e199ef16 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 19 Dec 2023 12:45:38 +0100 Subject: Add custom reels option to Film. --- src/lib/film.cc | 28 ++++++++++++++++++++++++++++ src/lib/film.h | 9 ++++++++- src/lib/film_property.h | 1 + src/lib/types.h | 3 ++- 4 files changed, 39 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib/film.cc b/src/lib/film.cc index d94ef0af3..835f3efdf 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -413,6 +413,9 @@ Film::metadata (bool with_content_paths) const } root->add_child("ReelType")->add_child_text (raw_convert (static_cast (_reel_type))); root->add_child("ReelLength")->add_child_text (raw_convert (_reel_length)); + for (auto boundary: _custom_reel_boundaries) { + root->add_child("CustomReelBoundary")->add_child_text(raw_convert(boundary.get())); + } root->add_child("ReencodeJ2K")->add_child_text (_reencode_j2k ? "1" : "0"); root->add_child("UserExplicitVideoFrameRate")->add_child_text(_user_explicit_video_frame_rate ? "1" : "0"); for (auto const& marker: _markers) { @@ -600,6 +603,9 @@ Film::read_metadata (optional path) _reel_type = static_cast (f.optional_number_child("ReelType").get_value_or (static_cast(ReelType::SINGLE))); _reel_length = f.optional_number_child("ReelLength").get_value_or (2000000000); + for (auto boundary: f.node_children("CustomReelBoundary")) { + _custom_reel_boundaries.push_back(DCPTime(raw_convert(boundary->content()))); + } _reencode_j2k = f.optional_bool_child("ReencodeJ2K").get_value_or(false); _user_explicit_video_frame_rate = f.optional_bool_child("UserExplicitVideoFrameRate").get_value_or(false); @@ -1233,6 +1239,16 @@ Film::set_reel_length (int64_t r) _reel_length = r; } + +void +Film::set_custom_reel_boundaries(vector boundaries) +{ + FilmChangeSignaller ch(this, FilmProperty::CUSTOM_REEL_BOUNDARIES); + std::sort(boundaries.begin(), boundaries.end()); + _custom_reel_boundaries = std::move(boundaries); +} + + void Film::set_reencode_j2k (bool r) { @@ -1865,6 +1881,18 @@ Film::reels () const } break; } + case ReelType::CUSTOM: + { + DCPTimePeriod current; + for (auto boundary: _custom_reel_boundaries) { + current.to = boundary; + periods.push_back(current); + current.from = boundary; + } + current.to = len; + periods.push_back(current); + break; + } } return periods; diff --git a/src/lib/film.h b/src/lib/film.h index a5cefa4d4..0a0c5a4e1 100644 --- a/src/lib/film.h +++ b/src/lib/film.h @@ -291,6 +291,10 @@ public: return _reel_length; } + std::vector custom_reel_boundaries() const { + return _custom_reel_boundaries; + } + std::string context_id () const { return _context_id; } @@ -408,6 +412,7 @@ public: void set_audio_processor (AudioProcessor const * processor); void set_reel_type (ReelType); void set_reel_length (int64_t); + void set_custom_reel_boundaries(std::vector boundaries); void set_reencode_j2k (bool); void set_marker (dcp::Marker type, dcpomatic::DCPTime time); void unset_marker (dcp::Marker type); @@ -527,8 +532,10 @@ private: bool _limit_to_smpte_bv20; AudioProcessor const * _audio_processor; ReelType _reel_type; - /** Desired reel length in bytes, if _reel_type == REELTYPE_BY_LENGTH */ + /** Desired reel length in bytes, if _reel_type == BY_LENGTH */ int64_t _reel_length; + /** Reel boundaries (excluding those at the start and end, sorted in ascending order) if _reel_type == CUSTOM */ + std::vector _custom_reel_boundaries; bool _reencode_j2k; /** true if the user has ever explicitly set the video frame rate of this film */ bool _user_explicit_video_frame_rate; diff --git a/src/lib/film_property.h b/src/lib/film_property.h index c23297965..0841caa5c 100644 --- a/src/lib/film_property.h +++ b/src/lib/film_property.h @@ -51,6 +51,7 @@ enum class FilmProperty { AUDIO_PROCESSOR, REEL_TYPE, REEL_LENGTH, + CUSTOM_REEL_BOUNDARIES, REENCODE_J2K, MARKERS, RATINGS, diff --git a/src/lib/types.h b/src/lib/types.h index 36059401e..c9c87bae5 100644 --- a/src/lib/types.h +++ b/src/lib/types.h @@ -107,7 +107,8 @@ enum class ReelType { SINGLE, BY_VIDEO_CONTENT, - BY_LENGTH + BY_LENGTH, + CUSTOM }; -- cgit v1.2.3 From 9936ec84cb2a5e5f8f4fe77bcd5742f06bdb2d6c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 20 Dec 2023 23:41:35 +0100 Subject: Add operator<= for HMSF. --- src/lib/dcpomatic_time.cc | 19 +++++++++++++++++++ src/lib/dcpomatic_time.h | 3 +++ 2 files changed, 22 insertions(+) (limited to 'src') diff --git a/src/lib/dcpomatic_time.cc b/src/lib/dcpomatic_time.cc index ac797f8f4..60fc5342a 100644 --- a/src/lib/dcpomatic_time.cc +++ b/src/lib/dcpomatic_time.cc @@ -27,6 +27,25 @@ using std::string; using namespace dcpomatic; +bool +dcpomatic::operator<=(HMSF const& a, HMSF const& b) +{ + if (a.h != b.h) { + return a.h <= b.h; + } + + if (a.m != b.m) { + return a.m <= b.m; + } + + if (a.s != b.s) { + return a.s <= b.s; + } + + return a.f <= b.f; +} + + template <> Time::Time (DCPTime d, FrameRateChange f) : _t (llrint(d.get() * f.speed_up)) diff --git a/src/lib/dcpomatic_time.h b/src/lib/dcpomatic_time.h index 9ebb334fe..63bb86549 100644 --- a/src/lib/dcpomatic_time.h +++ b/src/lib/dcpomatic_time.h @@ -64,6 +64,9 @@ public: }; +bool operator<=(HMSF const& a, HMSF const& b); + + /** A time in seconds, expressed as a number scaled up by Time::HZ. We want two different * versions of this class, dcpomatic::ContentTime and dcpomatic::DCPTime, and we want it to be impossible to * convert implicitly between the two. Hence there's this template hack. I'm not -- cgit v1.2.3 From 63b1442519ce5032a7fd85d9585aa203de639f27 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 20 Dec 2023 23:41:49 +0100 Subject: Add validity check to Timecode. --- src/wx/timecode.cc | 2 +- src/wx/timecode.h | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/wx/timecode.cc b/src/wx/timecode.cc index 1e6a1930d..64fe87190 100644 --- a/src/wx/timecode.cc +++ b/src/wx/timecode.cc @@ -114,7 +114,7 @@ void TimecodeBase::changed () { if (_set_button && !_ignore_changed) { - _set_button->Enable (true); + _set_button->Enable(valid()); } } diff --git a/src/wx/timecode.h b/src/wx/timecode.h index 6c5d8ae23..22899ddc9 100644 --- a/src/wx/timecode.h +++ b/src/wx/timecode.h @@ -50,6 +50,7 @@ public: protected: void changed (); void set_clicked (); + virtual bool valid() const = 0; wxSizer* _sizer; wxPanel* _editable; @@ -96,6 +97,11 @@ public: _frames->SetHint (std_to_wx(dcp::raw_convert(hmsf.f))); } + void set_maximum(dcpomatic::HMSF maximum) + { + _maximum = std::move(maximum); + } + dcpomatic::HMSF get () const { auto value_or_hint = [](wxTextCtrl const * t) { @@ -116,6 +122,13 @@ public: { return T(get(), fps); } + +private: + bool valid() const override { + return !_maximum || get() <= *_maximum; + } + + boost::optional _maximum; }; #endif -- cgit v1.2.3 From 0adb508ce5fbc69a4324b7278ac245f28095d38c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 22 Dec 2023 15:04:01 +0100 Subject: Extract timeline content colours to a header. --- src/wx/colours.h | 25 +++++++++++++++++++++++++ src/wx/content_timeline_atmos_view.cc | 3 ++- src/wx/content_timeline_audio_view.cc | 3 ++- src/wx/content_timeline_text_view.cc | 3 ++- src/wx/content_timeline_video_view.cc | 5 +++-- 5 files changed, 34 insertions(+), 5 deletions(-) create mode 100644 src/wx/colours.h (limited to 'src') diff --git a/src/wx/colours.h b/src/wx/colours.h new file mode 100644 index 000000000..0d33208e0 --- /dev/null +++ b/src/wx/colours.h @@ -0,0 +1,25 @@ +/* + Copyright (C) 2023 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#define VIDEO_CONTENT_COLOUR (wxColour(242, 92, 120, 255)) +#define AUDIO_CONTENT_COLOUR (wxColour(149, 121, 232, 255)) +#define TEXT_CONTENT_COLOUR (wxColour(163, 255, 154, 255)) +#define ATMOS_CONTENT_COLOUR (wxColour(149, 121, 232, 255)) diff --git a/src/wx/content_timeline_atmos_view.cc b/src/wx/content_timeline_atmos_view.cc index 4b78a8aee..2352ba5dc 100644 --- a/src/wx/content_timeline_atmos_view.cc +++ b/src/wx/content_timeline_atmos_view.cc @@ -19,6 +19,7 @@ */ +#include "colours.h" #include "content_timeline_atmos_view.h" @@ -39,7 +40,7 @@ ContentTimelineAtmosView::ContentTimelineAtmosView(ContentTimeline& tl, shared_p wxColour ContentTimelineAtmosView::background_colour() const { - return wxColour (149, 121, 232, 255); + return ATMOS_CONTENT_COLOUR; } diff --git a/src/wx/content_timeline_audio_view.cc b/src/wx/content_timeline_audio_view.cc index 9604ee7cc..600e39057 100644 --- a/src/wx/content_timeline_audio_view.cc +++ b/src/wx/content_timeline_audio_view.cc @@ -19,6 +19,7 @@ */ +#include "colours.h" #include "content_timeline_audio_view.h" #include "wx_util.h" #include "lib/audio_content.h" @@ -44,7 +45,7 @@ ContentTimelineAudioView::ContentTimelineAudioView(ContentTimeline& tl, shared_p wxColour ContentTimelineAudioView::background_colour () const { - return wxColour (149, 121, 232, 255); + return AUDIO_CONTENT_COLOUR; } wxColour diff --git a/src/wx/content_timeline_text_view.cc b/src/wx/content_timeline_text_view.cc index 3b7eeebce..f22f47850 100644 --- a/src/wx/content_timeline_text_view.cc +++ b/src/wx/content_timeline_text_view.cc @@ -19,6 +19,7 @@ */ +#include "colours.h" #include "content_timeline_text_view.h" #include "lib/text_content.h" #include "lib/content.h" @@ -41,7 +42,7 @@ ContentTimelineTextView::background_colour() const return wxColour (210, 210, 210, 128); } - return wxColour (163, 255, 154, 255); + return TEXT_CONTENT_COLOUR; } wxColour diff --git a/src/wx/content_timeline_video_view.cc b/src/wx/content_timeline_video_view.cc index 63b26a570..d907627cd 100644 --- a/src/wx/content_timeline_video_view.cc +++ b/src/wx/content_timeline_video_view.cc @@ -19,9 +19,10 @@ */ +#include "colours.h" +#include "content_timeline_video_view.h" #include "lib/image_content.h" #include "lib/video_content.h" -#include "content_timeline_video_view.h" using std::dynamic_pointer_cast; @@ -41,7 +42,7 @@ ContentTimelineVideoView::background_colour() const return wxColour (210, 210, 210, 128); } - return wxColour (242, 92, 120, 255); + return VIDEO_CONTENT_COLOUR; } wxColour -- cgit v1.2.3 From ffc489c67f97366016e51de9390eb3f6841ad069 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Fri, 22 Dec 2023 18:25:40 +0100 Subject: Extract snap subdivision to a constant. --- src/lib/constants.h | 1 + src/wx/content_timeline.cc | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/lib/constants.h b/src/lib/constants.h index 3b1871554..bfe144420 100644 --- a/src/lib/constants.h +++ b/src/lib/constants.h @@ -47,6 +47,7 @@ #define MAX_CLOSED_CAPTION_XML_SIZE (256 * 1024) #define MAX_CLOSED_CAPTION_XML_SIZE_TEXT "256KB" #define CERTIFICATE_VALIDITY_PERIOD (10 * 365) +#define SNAP_SUBDIVISION 64 #endif diff --git a/src/wx/content_timeline.cc b/src/wx/content_timeline.cc index 7257f3587..663f93030 100644 --- a/src/wx/content_timeline.cc +++ b/src/wx/content_timeline.cc @@ -32,6 +32,7 @@ #include "wx_util.h" #include "lib/atmos_mxf_content.h" #include "lib/audio_content.h" +#include "lib/constants.h" #include "lib/film.h" #include "lib/image_content.h" #include "lib/playlist.h" @@ -845,7 +846,7 @@ ContentTimeline::set_position_from_event(wxMouseEvent& ev, bool force_emit) if (nearest_distance) { /* Snap if it's close; `close' means within a proportion of the time on the timeline */ - if (nearest_distance.get().abs() < DCPTime::from_seconds ((width() / pps) / 64)) { + if (nearest_distance.get().abs() < DCPTime::from_seconds ((width() / pps) / SNAP_SUBDIVISION)) { new_position += nearest_distance.get (); } } -- cgit v1.2.3 From 1d028a206c999bf61df84544e3aeb70cec4e505c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Tue, 12 Mar 2024 00:31:10 +0100 Subject: Tweak SpinCtrl width for GTK3 to work with Mint's theme. --- src/wx/wx_util.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/wx/wx_util.h b/src/wx/wx_util.h index dcf5bbc18..d8935daa1 100644 --- a/src/wx/wx_util.h +++ b/src/wx/wx_util.h @@ -56,7 +56,7 @@ class PasswordEntry; #define DCPOMATIC_SIZER_GAP 8 #define DCPOMATIC_DIALOG_BORDER 12 #ifdef __WXGTK3__ -#define DCPOMATIC_SPIN_CTRL_WIDTH 118 +#define DCPOMATIC_SPIN_CTRL_WIDTH 124 #else #define DCPOMATIC_SPIN_CTRL_WIDTH 56 #endif -- cgit v1.2.3 From da46a695431d3b573924e53ac1a0163056a1a5b5 Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 13 Dec 2023 00:42:22 +0100 Subject: Add new interface for setting reel breaks (#2678). --- src/lib/film.cc | 17 + src/wx/dcp_panel.cc | 13 + src/wx/dcp_panel.h | 4 + src/wx/dcp_timeline.cc | 615 ++++++++++++++++++++++++++++++++ src/wx/dcp_timeline.h | 123 +++++++ src/wx/dcp_timeline_dialog.cc | 78 ++++ src/wx/dcp_timeline_dialog.h | 39 ++ src/wx/dcp_timeline_reel_marker_view.cc | 71 ++++ src/wx/dcp_timeline_reel_marker_view.h | 59 +++ src/wx/dcp_timeline_view.h | 44 +++ src/wx/wscript | 3 + 11 files changed, 1066 insertions(+) create mode 100644 src/wx/dcp_timeline.cc create mode 100644 src/wx/dcp_timeline.h create mode 100644 src/wx/dcp_timeline_dialog.cc create mode 100644 src/wx/dcp_timeline_dialog.h create mode 100644 src/wx/dcp_timeline_reel_marker_view.cc create mode 100644 src/wx/dcp_timeline_reel_marker_view.h create mode 100644 src/wx/dcp_timeline_view.h (limited to 'src') diff --git a/src/lib/film.cc b/src/lib/film.cc index 835f3efdf..d2c73c8b5 100644 --- a/src/lib/film.cc +++ b/src/lib/film.cc @@ -1616,6 +1616,23 @@ Film::check_settings_consistency () if (change_made) { Message (_("DCP-o-matic had to change your settings for referring to DCPs as OV. Please review those settings to make sure they are what you want.")); } + + if (reel_type() == ReelType::CUSTOM) { + auto boundaries = custom_reel_boundaries(); + auto too_late = std::find_if(boundaries.begin(), boundaries.end(), [this](dcpomatic::DCPTime const& time) { + return time >= length(); + }); + + if (too_late != boundaries.end()) { + if (std::distance(too_late, boundaries.end()) > 1) { + Message(_("DCP-o-matic had to remove some of your custom reel boundaries as they no longer lie within the film.")); + } else { + Message(_("DCP-o-matic had to remove one of your custom reel boundaries as it no longer lies within the film.")); + } + boundaries.erase(too_late, boundaries.end()); + set_custom_reel_boundaries(boundaries); + } + } } void diff --git a/src/wx/dcp_panel.cc b/src/wx/dcp_panel.cc index 1afc1be3d..64b4935cc 100644 --- a/src/wx/dcp_panel.cc +++ b/src/wx/dcp_panel.cc @@ -23,6 +23,7 @@ #include "check_box.h" #include "check_box.h" #include "dcp_panel.h" +#include "dcp_timeline_dialog.h" #include "dcpomatic_button.h" #include "dcpomatic_choice.h" #include "dcpomatic_spin_ctrl.h" @@ -111,6 +112,7 @@ DCPPanel::DCPPanel(wxNotebook* n, shared_ptr film, FilmViewer& viewer) _markers = new Button (_panel, _("Markers...")); _metadata = new Button (_panel, _("Metadata...")); + _reels = new Button(_panel, _("Reels...")); _notebook = new wxNotebook (_panel, wxID_ANY); _sizer->Add (_notebook, 1, wxEXPAND | wxTOP, 6); @@ -126,6 +128,8 @@ DCPPanel::DCPPanel(wxNotebook* n, shared_ptr film, FilmViewer& viewer) _standard->Bind (wxEVT_CHOICE, boost::bind(&DCPPanel::standard_changed, this)); _markers->Bind (wxEVT_BUTTON, boost::bind(&DCPPanel::markers_clicked, this)); _metadata->Bind (wxEVT_BUTTON, boost::bind(&DCPPanel::metadata_clicked, this)); + _reels->Bind(wxEVT_BUTTON, boost::bind(&DCPPanel::reels_clicked, this)); + for (auto i: DCPContentType::all()) { _dcp_content_type->add(i->pretty_name()); } @@ -231,6 +235,7 @@ DCPPanel::add_to_grid () auto extra = new wxBoxSizer (wxHORIZONTAL); extra->Add (_markers, 1, wxRIGHT, DCPOMATIC_SIZER_X_GAP); extra->Add (_metadata, 1, wxRIGHT, DCPOMATIC_SIZER_X_GAP); + extra->Add(_reels, 1, wxRIGHT, DCPOMATIC_SIZER_X_GAP); _grid->Add (extra, wxGBPosition(r, 0), wxGBSpan(1, 2)); ++r; } @@ -343,6 +348,14 @@ DCPPanel::metadata_clicked () } +void +DCPPanel::reels_clicked() +{ + _dcp_timeline.reset(_panel, _film); + _dcp_timeline->Show(); +} + + void DCPPanel::film_changed(FilmProperty p) { diff --git a/src/wx/dcp_panel.h b/src/wx/dcp_panel.h index a5af58921..6c97a41c3 100644 --- a/src/wx/dcp_panel.h +++ b/src/wx/dcp_panel.h @@ -39,6 +39,7 @@ class wxGridBagSizer; class AudioDialog; class Choice; +class DCPTimelineDialog; class Film; class FilmViewer; class InteropMetadataDialog; @@ -84,6 +85,7 @@ private: void show_audio_clicked (); void markers_clicked (); void metadata_clicked (); + void reels_clicked(); void reencode_j2k_changed (); void enable_audio_language_toggled (); void edit_audio_language_clicked (); @@ -153,12 +155,14 @@ private: CheckBox* _encrypted; wxButton* _markers; wxButton* _metadata; + Button* _reels; wxSizer* _audio_panel_sizer; wx_ptr _audio_dialog; wx_ptr _markers_dialog; wx_ptr _interop_metadata_dialog; wx_ptr _smpte_metadata_dialog; + wx_ptr _dcp_timeline; std::shared_ptr _film; FilmViewer& _viewer; diff --git a/src/wx/dcp_timeline.cc b/src/wx/dcp_timeline.cc new file mode 100644 index 000000000..3974997eb --- /dev/null +++ b/src/wx/dcp_timeline.cc @@ -0,0 +1,615 @@ +/* + Copyright (C) 2023 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "check_box.h" +#include "colours.h" +#include "dcp_timeline.h" +#include "dcp_timeline_reel_marker_view.h" +#include "dcpomatic_choice.h" +#include "dcpomatic_spin_ctrl.h" +#include "timecode.h" +#include "wx_util.h" +#include "lib/atmos_content.h" +#include "lib/audio_content.h" +#include "lib/constants.h" +#include "lib/film.h" +#include "lib/text_content.h" +#include "lib/video_content.h" +#include +LIBDCP_DISABLE_WARNINGS +#include +LIBDCP_ENABLE_WARNINGS + + +using std::dynamic_pointer_cast; +using std::make_shared; +using std::shared_ptr; +using std::vector; +using boost::optional; +#if BOOST_VERSION >= 106100 +using namespace boost::placeholders; +#endif +using namespace dcpomatic; + + +auto constexpr reel_marker_y_pos = 48; +auto constexpr content_y_pos = 112; +auto constexpr content_type_height = 12; + +enum { + ID_add_reel_boundary, +}; + + +class ReelBoundary +{ +public: + ReelBoundary(wxWindow* parent, wxGridBagSizer* sizer, int index, DCPTime maximum, int fps, DCPTimeline& timeline, bool editable) + : _label(new wxStaticText(parent, wxID_ANY, wxString::Format(_("Reel %d to reel %d"), index + 1, index + 2))) + , _timecode(new Timecode(parent, true)) + , _index(index) + , _view(timeline, reel_marker_y_pos) + , _fps(fps) + { + sizer->Add(_label, wxGBPosition(index, 0), wxDefaultSpan, wxALIGN_CENTER_VERTICAL); + sizer->Add(_timecode, wxGBPosition(index, 1)); + + _timecode->set_maximum(maximum.split(fps)); + _timecode->set_editable(editable); + _timecode->Changed.connect(boost::bind(&ReelBoundary::timecode_changed, this)); + } + + ~ReelBoundary() + { + if (_label) { + _label->Destroy(); + } + + if (_timecode) { + _timecode->Destroy(); + } + } + + ReelBoundary(ReelBoundary const&) = delete; + ReelBoundary& operator=(ReelBoundary const&) = delete; + + ReelBoundary(ReelBoundary&& other) = delete; + ReelBoundary& operator=(ReelBoundary&& other) = delete; + + void set_time(DCPTime time) + { + if (_timecode) { + _timecode->set(time, _fps); + } + _view.set_time(time); + } + + dcpomatic::DCPTime time() const { + return _view.time(); + } + + int index() const { + return _index; + } + + DCPTimelineReelMarkerView& view() { + return _view; + } + + DCPTimelineReelMarkerView const& view() const { + return _view; + } + + boost::signals2::signal Changed; + +private: + void timecode_changed() { + set_time(_timecode->get(_fps)); + Changed(_index, time()); + } + + wxStaticText* _label = nullptr; + Timecode* _timecode = nullptr; + int _index = 0; + DCPTimelineReelMarkerView _view; + int _fps; +}; + + +DCPTimeline::DCPTimeline(wxWindow* parent, shared_ptr film) + : Timeline(parent) + , _film(film) + , _canvas(new wxScrolledCanvas(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxFULL_REPAINT_ON_RESIZE)) + , _reel_settings(new wxPanel(this, wxID_ANY)) + , _reel_detail(new wxPanel(this, wxID_ANY)) + , _reel_detail_sizer(new wxGridBagSizer(DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP)) +{ +#ifndef __WXOSX__ + _canvas->SetDoubleBuffered(true); +#endif + _reel_detail->SetSizer(_reel_detail_sizer); + + auto sizer = new wxBoxSizer(wxVERTICAL); + sizer->Add(_reel_settings, 0); + sizer->Add(_canvas, 0, wxEXPAND); + sizer->Add(_reel_detail, 1, wxEXPAND | wxALL, DCPOMATIC_DIALOG_BORDER); + SetSizer(sizer); + + SetMinSize(wxSize(640, 480)); + _canvas->SetMinSize({-1, content_y_pos + content_type_height * 4}); + + _canvas->Bind(wxEVT_PAINT, boost::bind(&DCPTimeline::paint, this)); + _canvas->Bind(wxEVT_SIZE, boost::bind(&DCPTimeline::setup_pixels_per_second, this)); + _canvas->Bind(wxEVT_LEFT_DOWN, boost::bind(&DCPTimeline::left_down, this, _1)); + _canvas->Bind(wxEVT_RIGHT_DOWN, boost::bind(&DCPTimeline::right_down, this, _1)); + _canvas->Bind(wxEVT_LEFT_UP, boost::bind(&DCPTimeline::left_up, this, _1)); + _canvas->Bind(wxEVT_MOTION, boost::bind(&DCPTimeline::mouse_moved, this, _1)); + + _film_connection = film->Change.connect(boost::bind(&DCPTimeline::film_changed, this, _1, _2)); + + _menu = new wxMenu; + _add_reel_boundary = _menu->Append(ID_add_reel_boundary, _("Add reel")); + _canvas->Bind(wxEVT_MENU, boost::bind(&DCPTimeline::add_reel_boundary, this)); + + setup_reel_settings(); + setup_reel_boundaries(); + + sizer->Layout(); + setup_pixels_per_second(); + setup_sensitivity(); +} + + +void +DCPTimeline::add_reel_boundary() +{ + auto boundaries = film()->custom_reel_boundaries(); + boundaries.push_back(DCPTime::from_seconds(_right_down_position.x / _pixels_per_second.get_value_or(1))); + film()->set_custom_reel_boundaries(boundaries); +} + + +void +DCPTimeline::film_changed(ChangeType type, FilmProperty property) +{ + if (type != ChangeType::DONE) { + return; + } + + switch (property) { + case FilmProperty::REEL_TYPE: + case FilmProperty::REEL_LENGTH: + case FilmProperty::CUSTOM_REEL_BOUNDARIES: + setup_sensitivity(); + setup_reel_boundaries(); + break; + case FilmProperty::CONTENT: + case FilmProperty::CONTENT_ORDER: + setup_pixels_per_second(); + Refresh(); + break; + default: + break; + } +} + + +void +DCPTimeline::setup_sensitivity() +{ + _snap->Enable(editable()); + _maximum_reel_size->Enable(film()->reel_type() == ReelType::BY_LENGTH); +} + + +void +DCPTimeline::setup_reel_settings() +{ + auto sizer = new wxGridBagSizer(DCPOMATIC_SIZER_X_GAP, DCPOMATIC_SIZER_Y_GAP); + _reel_settings->SetSizer(sizer); + + int r = 0; + add_label_to_sizer(sizer, _reel_settings, _("Reel mode"), true, wxGBPosition(r, 0)); + _reel_type = new Choice(_reel_settings); + _reel_type->add(_("Single reel")); + _reel_type->add(_("Split by video content")); + _reel_type->add(_("Split by maximum reel size")); + _reel_type->add(_("Custom")); + sizer->Add(_reel_type, wxGBPosition(r, 1)); + ++r; + + add_label_to_sizer(sizer, _reel_settings, _("Maximum reel size"), true, wxGBPosition(r, 0)); + _maximum_reel_size = new SpinCtrl(_reel_settings, DCPOMATIC_SPIN_CTRL_WIDTH); + _maximum_reel_size->SetRange(1, 1000); + { + auto s = new wxBoxSizer(wxHORIZONTAL); + s->Add(_maximum_reel_size, 0); + add_label_to_sizer(s, _reel_settings, _("GB"), false, 0, wxALIGN_CENTER_VERTICAL | wxLEFT); + sizer->Add(s, wxGBPosition(r, 1)); + } + ++r; + + _snap = new CheckBox(_reel_settings, _("Snap when dragging")); + sizer->Add(_snap, wxGBPosition(r, 1)); + ++r; + + _reel_type->set(static_cast(film()->reel_type())); + _maximum_reel_size->SetValue(film()->reel_length() / 1000000000LL); + + _reel_type->bind(&DCPTimeline::reel_mode_changed, this); + _maximum_reel_size->Bind(wxEVT_SPINCTRL, boost::bind(&DCPTimeline::maximum_reel_size_changed, this)); +} + + +void +DCPTimeline::reel_mode_changed() +{ + film()->set_reel_type(static_cast(*_reel_type->get())); +} + + +void +DCPTimeline::maximum_reel_size_changed() +{ + film()->set_reel_length(_maximum_reel_size->GetValue() * 1000000000LL); +} + + +void +DCPTimeline::set_reel_boundary(int index, DCPTime time) +{ + auto boundaries = film()->custom_reel_boundaries(); + DCPOMATIC_ASSERT(index >= 0 && index < static_cast(boundaries.size())); + boundaries[index] = time.round(film()->video_frame_rate()); + film()->set_custom_reel_boundaries(boundaries); +} + + +void +DCPTimeline::setup_reel_boundaries() +{ + auto const reels = film()->reels(); + if (reels.empty()) { + _reel_boundaries.clear(); + return; + } + + size_t const boundaries = reels.size() - 1; + auto const maximum = film()->length(); + for (size_t i = _reel_boundaries.size(); i < boundaries; ++i) { + auto boundary = std::make_shared( + _reel_detail, _reel_detail_sizer, i, maximum, film()->video_frame_rate(), *this, editable() + ); + + boundary->Changed.connect(boost::bind(&DCPTimeline::set_reel_boundary, this, _1, _2)); + _reel_boundaries.push_back(boundary); + } + + _reel_boundaries.resize(boundaries); + + auto const active = editable(); + for (size_t i = 0; i < boundaries; ++i) { + _reel_boundaries[i]->set_time(reels[i].to); + _reel_boundaries[i]->view().set_active(active); + } + + _reel_detail_sizer->Layout(); + _canvas->Refresh(); +} + + +void +DCPTimeline::paint() +{ + wxPaintDC dc(_canvas); + dc.Clear(); + + if (film()->content().empty()) { + return; + } + + _canvas->DoPrepareDC(dc); + + auto gc = wxGraphicsContext::Create(dc); + if (!gc) { + return; + } + + dcp::ScopeGuard sg = [gc]() { delete gc; }; + + gc->SetAntialiasMode(wxANTIALIAS_DEFAULT); + + paint_reels(gc); + paint_content(gc); +} + + +void +DCPTimeline::paint_reels(wxGraphicsContext* gc) +{ + constexpr int x_offset = 2; + + for (auto const& boundary: _reel_boundaries) { + boundary->view().paint(gc); + } + + gc->SetFont(gc->CreateFont(*wxNORMAL_FONT, wxColour(0, 0, 0))); + gc->SetPen(*wxThePenList->FindOrCreatePen(wxColour(0, 0, 0), 2, wxPENSTYLE_SOLID)); + + auto const pps = pixels_per_second().get_value_or(1); + + auto start = gc->CreatePath(); + start.MoveToPoint(x_offset, reel_marker_y_pos); + start.AddLineToPoint(x_offset, reel_marker_y_pos + DCPTimelineReelMarkerView::HEIGHT); + gc->StrokePath(start); + + auto const length = film()->length().seconds() * pps; + auto end = gc->CreatePath(); + end.MoveToPoint(x_offset + length, reel_marker_y_pos); + end.AddLineToPoint(x_offset + length, reel_marker_y_pos + DCPTimelineReelMarkerView::HEIGHT); + gc->StrokePath(end); + + auto const y = reel_marker_y_pos + DCPTimelineReelMarkerView::HEIGHT * 3 / 4; + + auto paint_reel = [gc, y](double from, double to, int index) { + auto path = gc->CreatePath(); + path.MoveToPoint(from, y); + path.AddLineToPoint(to, y); + gc->StrokePath(path); + + auto str = wxString::Format(wxT("#%d"), index + 1); + wxDouble str_width; + wxDouble str_height; + wxDouble str_descent; + wxDouble str_leading; + gc->GetTextExtent(str, &str_width, &str_height, &str_descent, &str_leading); + + if (str_width < (to - from)) { + gc->DrawText(str, (from + to - str_width) / 2, y - str_height - 2); + } + }; + + gc->SetPen(*wxThePenList->FindOrCreatePen(wxColour(0, 0, 255), 2, wxPENSTYLE_DOT)); + int index = 0; + DCPTime last; + for (auto const& boundary: _reel_boundaries) { + paint_reel(last.seconds() * pps + 2, boundary->time().seconds() * pps, index++); + last = boundary->time(); + } + + paint_reel(last.seconds() * pps + 2, film()->length().seconds() * pps, index); +} + + +void +DCPTimeline::paint_content(wxGraphicsContext* gc) +{ + auto const pps = pixels_per_second().get_value_or(1); + auto const film = this->film(); + + auto const& solid_pen = *wxThePenList->FindOrCreatePen(wxColour(0, 0, 0), 1, wxPENSTYLE_SOLID); + auto const& dotted_pen = *wxThePenList->FindOrCreatePen(wxColour(0, 0, 0), 1, wxPENSTYLE_DOT); + + auto const& video_brush = *wxTheBrushList->FindOrCreateBrush(VIDEO_CONTENT_COLOUR, wxBRUSHSTYLE_SOLID); + auto const& audio_brush = *wxTheBrushList->FindOrCreateBrush(AUDIO_CONTENT_COLOUR, wxBRUSHSTYLE_SOLID); + auto const& text_brush = *wxTheBrushList->FindOrCreateBrush(TEXT_CONTENT_COLOUR, wxBRUSHSTYLE_SOLID); + auto const& atmos_brush = *wxTheBrushList->FindOrCreateBrush(ATMOS_CONTENT_COLOUR, wxBRUSHSTYLE_SOLID); + + auto maybe_draw = + [gc, film, pps, solid_pen, dotted_pen] + (shared_ptr content, shared_ptr part, wxBrush brush, int offset) { + if (part) { + auto const y = content_y_pos + offset * content_type_height + 1; + gc->SetPen(solid_pen); + gc->SetBrush(brush); + gc->DrawRectangle( + content->position().seconds() * pps, + y, + content->length_after_trim(film).seconds() * pps, + content_type_height - 2 + ); + + gc->SetPen(dotted_pen); + for (auto split: content->reel_split_points(film)) { + if (split != content->position()) { + auto path = gc->CreatePath(); + path.MoveToPoint(split.seconds() * pps, y); + path.AddLineToPoint(split.seconds() * pps, y + content_type_height - 2); + gc->StrokePath(path); + } + } + } + }; + + for (auto content: film->content()) { + maybe_draw(content, dynamic_pointer_cast(content->video), video_brush, 0); + maybe_draw(content, dynamic_pointer_cast(content->audio), audio_brush, 1); + for (auto text: content->text) { + maybe_draw(content, dynamic_pointer_cast(text), text_brush, 2); + } + maybe_draw(content, dynamic_pointer_cast(content->atmos), atmos_brush, 3); + } +} + + +void +DCPTimeline::setup_pixels_per_second() +{ + set_pixels_per_second((_canvas->GetSize().GetWidth() - 4) / std::max(1.0, film()->length().seconds())); +} + + +shared_ptr +DCPTimeline::event_to_reel_boundary(wxMouseEvent& ev) const +{ + Position const position(ev.GetX(), ev.GetY()); + auto iter = std::find_if(_reel_boundaries.begin(), _reel_boundaries.end(), [position](shared_ptr boundary) { + return boundary->view().bbox().contains(position); + }); + + if (iter == _reel_boundaries.end()) { + return {}; + } + + return *iter; +} + + +void +DCPTimeline::left_down(wxMouseEvent& ev) +{ + if (!editable()) { + return; + } + + if (auto boundary = event_to_reel_boundary(ev)) { + auto const snap_distance = DCPTime::from_seconds((_canvas->GetSize().GetWidth() / _pixels_per_second.get_value_or(1)) / SNAP_SUBDIVISION); + _drag = DCPTimeline::Drag( + boundary, + _reel_boundaries, + film(), + static_cast(ev.GetX() - boundary->time().seconds() * _pixels_per_second.get_value_or(0)), + _snap->get(), + snap_distance + ); + } else { + _drag = boost::none; + } +} + + +void +DCPTimeline::right_down(wxMouseEvent& ev) +{ + _right_down_position = ev.GetPosition(); + _canvas->PopupMenu(_menu, _right_down_position); +} + + +void +DCPTimeline::left_up(wxMouseEvent&) +{ + if (!_drag) { + return; + } + + set_reel_boundary(_drag->reel_boundary->index(), _drag->time()); + _drag = boost::none; +} + + +void +DCPTimeline::mouse_moved(wxMouseEvent& ev) +{ + if (!_drag) { + return; + } + + auto time = DCPTime::from_seconds((ev.GetPosition().x - _drag->offset) / _pixels_per_second.get_value_or(1)); + time = std::max(_drag->previous ? _drag->previous->time() : DCPTime(), time); + time = std::min(_drag->next ? _drag->next->time() : film()->length(), time); + _drag->set_time(time); + _canvas->RefreshRect({0, reel_marker_y_pos - 2, _canvas->GetSize().GetWidth(), DCPTimelineReelMarkerView::HEIGHT + 4}, true); +} + + +void +DCPTimeline::force_redraw(dcpomatic::Rect const & r) +{ + _canvas->RefreshRect(wxRect(r.x, r.y, r.width, r.height), false); +} + + +shared_ptr +DCPTimeline::film() const +{ + auto film = _film.lock(); + DCPOMATIC_ASSERT(film); + return film; +} + + +bool +DCPTimeline::editable() const +{ + return film()->reel_type() == ReelType::CUSTOM; +} + + +DCPTimeline::Drag::Drag( + shared_ptr reel_boundary_, + vector> const& reel_boundaries, + shared_ptr film, + int offset_, + bool snap, + DCPTime snap_distance + ) + : reel_boundary(reel_boundary_) + , offset(offset_) + , _snap_distance(snap_distance) +{ + auto iter = std::find(reel_boundaries.begin(), reel_boundaries.end(), reel_boundary); + auto index = std::distance(reel_boundaries.begin(), iter); + + if (index > 0) { + previous = reel_boundaries[index - 1]; + } + if (index < static_cast(reel_boundaries.size() - 1)) { + next = reel_boundaries[index + 1]; + } + + if (snap) { + for (auto content: film->content()) { + for (auto split: content->reel_split_points(film)) { + _snaps.push_back(split); + } + } + } +} + + +void +DCPTimeline::Drag::set_time(DCPTime time) +{ + optional nearest_distance; + optional nearest_time; + for (auto snap: _snaps) { + auto const distance = time - snap; + if (!nearest_distance || distance.abs() < nearest_distance->abs()) { + nearest_distance = distance.abs(); + nearest_time = snap; + } + } + + if (nearest_distance && *nearest_distance < _snap_distance) { + reel_boundary->set_time(*nearest_time); + } else { + reel_boundary->set_time(time); + } +} + + +DCPTime +DCPTimeline::Drag::time() const +{ + return reel_boundary->time(); +} + diff --git a/src/wx/dcp_timeline.h b/src/wx/dcp_timeline.h new file mode 100644 index 000000000..3413c2814 --- /dev/null +++ b/src/wx/dcp_timeline.h @@ -0,0 +1,123 @@ +/* + Copyright (C) 2023 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#ifndef DCPOMATIC_DCP_TIMELINE_H +#define DCPOMATIC_DCP_TIMELINE_H + + +#include "timecode.h" +#include "timeline.h" +#include "lib/rect.h" +#include +LIBDCP_DISABLE_WARNINGS +#include +LIBDCP_ENABLE_WARNINGS +#include + + +class CheckBox; +class Choice; +class Film; +class ReelBoundary; +class SpinCtrl; +class wxGridBagSizer; + + +class DCPTimeline : public Timeline +{ +public: + DCPTimeline(wxWindow* parent, std::shared_ptr film); + + void force_redraw(dcpomatic::Rect const &); + +private: + void paint(); + void paint_reels(wxGraphicsContext* gc); + void paint_content(wxGraphicsContext* gc); + void setup_pixels_per_second(); + void left_down(wxMouseEvent& ev); + void right_down(wxMouseEvent& ev); + void left_up(wxMouseEvent& ev); + void mouse_moved(wxMouseEvent& ev); + void reel_mode_changed(); + void maximum_reel_size_changed(); + void film_changed(ChangeType type, FilmProperty property); + std::shared_ptr film() const; + void setup_sensitivity(); + + void add_reel_boundary(); + void setup_reel_settings(); + void setup_reel_boundaries(); + std::shared_ptr event_to_reel_boundary(wxMouseEvent& ev) const; + void set_reel_boundary(int index, dcpomatic::DCPTime time); + bool editable() const; + + std::weak_ptr _film; + + wxScrolledCanvas* _canvas; + + class Drag + { + public: + Drag( + std::shared_ptr reel_boundary_, + std::vector> const& reel_boundaries, + std::shared_ptr film, + int offset_, + bool snap, + dcpomatic::DCPTime snap_distance + ); + + std::shared_ptr reel_boundary; + std::shared_ptr previous; + std::shared_ptr next; + int offset = 0; + + void set_time(dcpomatic::DCPTime time); + dcpomatic::DCPTime time() const; + + private: + std::vector _snaps; + dcpomatic::DCPTime _snap_distance; + }; + + boost::optional _drag; + + wxPoint _right_down_position; + + wxPanel* _reel_settings; + Choice* _reel_type; + SpinCtrl* _maximum_reel_size; + CheckBox* _snap; + wxPanel* _reel_detail; + wxGridBagSizer* _reel_detail_sizer; + + wxMenu* _menu; + wxMenuItem* _add_reel_boundary; + + boost::signals2::scoped_connection _film_connection; + + std::vector> _reel_boundaries; +}; + + +#endif + diff --git a/src/wx/dcp_timeline_dialog.cc b/src/wx/dcp_timeline_dialog.cc new file mode 100644 index 000000000..2cf6a74f1 --- /dev/null +++ b/src/wx/dcp_timeline_dialog.cc @@ -0,0 +1,78 @@ +/* + Copyright (C) 2013-2021 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "dcp_panel.h" +#include "dcp_timeline_dialog.h" +#include "film_editor.h" +#include "wx_util.h" +#include "lib/compose.hpp" +#include "lib/cross.h" +#include "lib/film.h" +#include "lib/playlist.h" +#include +LIBDCP_DISABLE_WARNINGS +#include +LIBDCP_ENABLE_WARNINGS +#include + + +using std::list; +using std::shared_ptr; +using std::string; +using std::weak_ptr; +#if BOOST_VERSION >= 106100 +using namespace boost::placeholders; +#endif + + +DCPTimelineDialog::DCPTimelineDialog(wxWindow* parent, shared_ptr film) + : wxDialog( + parent, + wxID_ANY, + _("Reels"), + wxDefaultPosition, + wxSize(640, 512), +#ifdef DCPOMATIC_OSX + /* I can't get wxFRAME_FLOAT_ON_PARENT to work on OS X, and although wxSTAY_ON_TOP keeps + the window above all others (and not just our own) it's better than nothing for now. + */ + wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE | wxSTAY_ON_TOP +#else + wxDEFAULT_DIALOG_STYLE | wxRESIZE_BORDER | wxFULL_REPAINT_ON_RESIZE | wxFRAME_FLOAT_ON_PARENT +#endif + ) + , _timeline(this, film) +{ + auto sizer = new wxBoxSizer(wxVERTICAL); + sizer->Add (&_timeline, 1, wxEXPAND | wxALL, 12); + +#ifdef DCPOMATIC_LINUX + auto buttons = CreateSeparatedButtonSizer (wxCLOSE); + if (buttons) { + sizer->Add (buttons, wxSizerFlags().Expand().DoubleBorder()); + } +#endif + + SetSizer(sizer); + sizer->Layout(); + sizer->SetSizeHints(this); +} + diff --git a/src/wx/dcp_timeline_dialog.h b/src/wx/dcp_timeline_dialog.h new file mode 100644 index 000000000..d1293ca26 --- /dev/null +++ b/src/wx/dcp_timeline_dialog.h @@ -0,0 +1,39 @@ +/* + Copyright (C) 2023 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "dcp_timeline.h" +#include +LIBDCP_DISABLE_WARNINGS +#include +LIBDCP_ENABLE_WARNINGS +#include + + +class DCPTimelineDialog : public wxDialog +{ +public: + DCPTimelineDialog(wxWindow* parent, std::shared_ptr film); + +private: + std::weak_ptr _film; + DCPTimeline _timeline; +}; + diff --git a/src/wx/dcp_timeline_reel_marker_view.cc b/src/wx/dcp_timeline_reel_marker_view.cc new file mode 100644 index 000000000..1c97ca175 --- /dev/null +++ b/src/wx/dcp_timeline_reel_marker_view.cc @@ -0,0 +1,71 @@ +/* + Copyright (C) 2023 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "dcp_timeline_reel_marker_view.h" +LIBDCP_DISABLE_WARNINGS +#include +LIBDCP_ENABLE_WARNINGS + + +using namespace std; +using namespace dcpomatic; + + +DCPTimelineReelMarkerView::DCPTimelineReelMarkerView(DCPTimeline& timeline, int y_pos) + : DCPTimelineView(timeline) + , _y_pos(y_pos) +{ + +} + + +int +DCPTimelineReelMarkerView::x_pos() const +{ + /* Nudge it over slightly so that the full line width is drawn on the left hand side */ + return time_x(_time) + 2; +} + + +void +DCPTimelineReelMarkerView::do_paint(wxGraphicsContext* gc) +{ + wxColour const outline = _active ? wxColour(0, 0, 0) : wxColour(128, 128, 128); + wxColour const fill = _active ? wxColour(255, 0, 0) : wxColour(192, 192, 192); + gc->SetPen(*wxThePenList->FindOrCreatePen(outline, 2, wxPENSTYLE_SOLID)); + gc->SetBrush(*wxTheBrushList->FindOrCreateBrush(fill, wxBRUSHSTYLE_SOLID)); + + gc->DrawRectangle(x_pos(), _y_pos, HEAD_SIZE, HEAD_SIZE); + + auto path = gc->CreatePath(); + path.MoveToPoint(x_pos(), _y_pos + HEAD_SIZE + TAIL_LENGTH); + path.AddLineToPoint(x_pos(), _y_pos); + gc->StrokePath(path); + gc->FillPath(path); +} + + +dcpomatic::Rect +DCPTimelineReelMarkerView::bbox() const +{ + return { x_pos(), _y_pos, HEAD_SIZE, HEAD_SIZE + TAIL_LENGTH }; +} + diff --git a/src/wx/dcp_timeline_reel_marker_view.h b/src/wx/dcp_timeline_reel_marker_view.h new file mode 100644 index 000000000..273d98259 --- /dev/null +++ b/src/wx/dcp_timeline_reel_marker_view.h @@ -0,0 +1,59 @@ +/* + Copyright (C) 2023 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "dcp_timeline_view.h" + + +class DCPTimeline; + + +class DCPTimelineReelMarkerView : public DCPTimelineView +{ +public: + DCPTimelineReelMarkerView(DCPTimeline& timeline, int y_pos); + + dcpomatic::Rect bbox() const override; + + dcpomatic::DCPTime time() const { + return _time; + } + + void set_time(dcpomatic::DCPTime time) { + _time = time; + } + + void set_active(bool active) { + _active = active; + } + + static auto constexpr HEAD_SIZE = 16; + static auto constexpr TAIL_LENGTH = 28; + static auto constexpr HEIGHT = HEAD_SIZE + TAIL_LENGTH; + +private: + void do_paint(wxGraphicsContext* gc) override; + int x_pos() const; + + dcpomatic::DCPTime _time; + int _y_pos; + bool _active = false; +}; + diff --git a/src/wx/dcp_timeline_view.h b/src/wx/dcp_timeline_view.h new file mode 100644 index 000000000..24a75cad2 --- /dev/null +++ b/src/wx/dcp_timeline_view.h @@ -0,0 +1,44 @@ +/* + Copyright (C) 2013-2021 Carl Hetherington + + This file is part of DCP-o-matic. + + DCP-o-matic is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + DCP-o-matic is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with DCP-o-matic. If not, see . + +*/ + + +#include "dcp_timeline.h" +#include "timeline_view.h" + + +class DCPTimelineView : public TimelineView +{ +public: + explicit DCPTimelineView(DCPTimeline& timeline) + : TimelineView(timeline) + {} + + void paint(wxGraphicsContext* gc) + { + _last_paint_bbox = bbox(); + do_paint(gc); + } + +protected: + virtual void do_paint(wxGraphicsContext* context) = 0; +}; + + + diff --git a/src/wx/wscript b/src/wx/wscript index c644af96c..cf05dfe7d 100644 --- a/src/wx/wscript +++ b/src/wx/wscript @@ -62,6 +62,9 @@ sources = """ custom_scale_dialog.cc dcp_referencing_dialog.cc dcp_panel.cc + dcp_timeline.cc + dcp_timeline_dialog.cc + dcp_timeline_reel_marker_view.cc dcp_text_track_dialog.cc dcpomatic_button.cc dcpomatic_choice.cc -- cgit v1.2.3