Split out Timeline from ContentTimeline.
authorCarl Hetherington <cth@carlh.net>
Wed, 13 Dec 2023 22:03:01 +0000 (23:03 +0100)
committerCarl Hetherington <cth@carlh.net>
Mon, 11 Mar 2024 23:43:51 +0000 (00:43 +0100)
src/wx/content_timeline.cc
src/wx/content_timeline.h
src/wx/timeline.cc [new file with mode: 0644]
src/wx/timeline.h [new file with mode: 0644]
src/wx/wscript

index 368cbcca485dedfe8b8de6a383c9ba1773903464..d5ed0f7bb3ecd37effd7bc19b2f90e8e749f6bfd 100644 (file)
@@ -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> 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()
 {
index 994f18ad4620f4380c100032332ab73f6a04600b..10f8801919c9fee93c022c5e30428195692fc8c2 100644 (file)
@@ -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<Film>, FilmViewer& viewer);
@@ -54,10 +55,6 @@ public:
                return _pixels_per_track;
        }
 
-       boost::optional<double> 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<TimelineReelsView> _reels_view;
        std::shared_ptr<TimelineLabelsView> _labels_view;
        int _tracks;
-       boost::optional<double> _pixels_per_second;
        bool _left_down;
        wxPoint _down_point;
        boost::optional<wxPoint> _zoom_point;
@@ -147,7 +142,6 @@ private:
        boost::optional<int> _last_mouse_wheel_x;
        boost::optional<double> _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 (file)
index 0000000..329f4ef
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+    Copyright (C) 2023 Carl Hetherington <cth@carlh.net>
+
+    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 <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#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 (file)
index 0000000..cc35913
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+    Copyright (C) 2023 Carl Hetherington <cth@carlh.net>
+
+    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 <http://www.gnu.org/licenses/>.
+
+*/
+
+
+#ifndef DCPOMATIC_TIMELINE_H
+#define DCPOMATIC_TIMELINE_H
+
+
+#include <dcp/warnings.h>
+LIBDCP_DISABLE_WARNINGS
+#include <wx/wx.h>
+LIBDCP_ENABLE_WARNINGS
+#include <boost/optional.hpp>
+
+
+class Timeline : public wxPanel
+{
+public:
+       explicit Timeline(wxWindow* parent);
+
+       boost::optional<double> pixels_per_second() const {
+               return _pixels_per_second;
+       }
+
+
+protected:
+       void set_pixels_per_second(double pps);
+
+       boost::optional<double> _pixels_per_second;
+};
+
+
+#endif
index 830d76731979551effd12ca56ef6aca99c78c2fc..2693bfa57d91d44c0f28c0999dd5640856bacb8c 100644 (file)
@@ -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