From f81655002b1ef1427e2845dc5d354da6020bfafb Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Wed, 13 Dec 2023 23:03:01 +0100 Subject: [PATCH] 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 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 -- 2.30.2