From 08f77136b97eea3e79cfc2a9d20d539b748f95ae Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Wed, 4 Jun 2025 20:43:18 -0600 Subject: [PATCH] small class rearrangement for ViewBackground and derived classes related to geometry management --- gtk2_ardour/midi_streamview.cc | 5 ---- gtk2_ardour/midi_streamview.h | 9 +++----- gtk2_ardour/streamview.cc | 42 ++++++++++++++++++++++++---------- gtk2_ardour/streamview.h | 10 +++++++- gtk2_ardour/view_background.h | 6 ++--- 5 files changed, 45 insertions(+), 27 deletions(-) diff --git a/gtk2_ardour/midi_streamview.cc b/gtk2_ardour/midi_streamview.cc index 9d44e9417f..fcf546a7ed 100644 --- a/gtk2_ardour/midi_streamview.cc +++ b/gtk2_ardour/midi_streamview.cc @@ -531,8 +531,3 @@ MidiStreamView::record_layer_check (std::shared_ptr r, samplepos check_record_layers (r, t); } -int -MidiStreamView::y_position () const -{ - return _trackview.y_position(); -} diff --git a/gtk2_ardour/midi_streamview.h b/gtk2_ardour/midi_streamview.h index 9cc0c103ca..53ca4aa719 100644 --- a/gtk2_ardour/midi_streamview.h +++ b/gtk2_ardour/midi_streamview.h @@ -63,18 +63,15 @@ public: MidiStreamView (MidiTimeAxisView&); ~MidiStreamView (); + int contents_height() const { return StreamView::contents_height(); } + int y_position() const { return StreamView::y_position(); } + void get_regions_with_selected_data (RegionSelection&); void set_layer_display (LayerDisplay); //bool can_change_layer_display() const { return false; } // revert this change for now. Although stacked view is weirdly implemented wrt the "scroomer", it is still necessary to be able to manage layered regions. void redisplay_track (); - int contents_height() const { - return child_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 2; - } - - int y_position () const; - RegionView* create_region_view (std::shared_ptr, bool, bool); bool paste (Temporal::timepos_t const & pos, const Selection& selection, PasteContext& ctx); diff --git a/gtk2_ardour/streamview.cc b/gtk2_ardour/streamview.cc index 2b1e309ecd..e77a539985 100644 --- a/gtk2_ardour/streamview.cc +++ b/gtk2_ardour/streamview.cc @@ -68,7 +68,7 @@ StreamView::StreamView (RouteTimeAxisView& tv, ArdourCanvas::Container* canvas_g , stream_base_color(0xFFFFFFFF) , _layers (1) , _layer_display (Overlaid) - , height (tv.height) + , _height (tv.height) , last_rec_data_sample(0) { CANVAS_DEBUG_NAME (_canvas_group, string_compose ("SV canvas group %1", _trackview.name())); @@ -123,12 +123,12 @@ StreamView::set_height (double h) return -1; } - if (height == h) { + if (_height == h) { return 0; } - height = h; - canvas_rect->set_y1 (height); + _height = h; + canvas_rect->set_y1 (_height); update_contents_height (); return 0; @@ -625,7 +625,7 @@ StreamView::_get_selectables (timepos_t const & start, timepos_t const & end, do /* Note: EditorAutomationLine::get_selectables() uses trackview.current_height (), * disregarding Stacked layer display height */ - double const c = height; // child_height (); // XXX + double const c = _height; // child_height (); // XXX double const y = (*i)->get_canvas_group ()->position().y; double t = 1.0 - std::min (1.0, std::max (0., (top - _trackview.y_position () - y) / c)); double b = 1.0 - std::min (1.0, std::max (0., (bottom - _trackview.y_position () - y) / c)); @@ -664,15 +664,15 @@ StreamView::child_height () const { switch (_layer_display) { case Overlaid: - return height; + return _height; case Stacked: - return height / _layers; + return _height / _layers; case Expanded: - return height / (_layers * 2 + 1); + return _height / (_layers * 2 + 1); } abort(); /* NOTREACHED */ - return height; + return _height; } void @@ -686,10 +686,10 @@ StreamView::update_contents_height () (*i)->set_y (0); break; case Stacked: - (*i)->set_y (height - ((*i)->region()->layer() + 1) * h); + (*i)->set_y (_height - ((*i)->region()->layer() + 1) * h); break; case Expanded: - (*i)->set_y (height - ((*i)->region()->layer() + 1) * 2 * h); + (*i)->set_y (_height - ((*i)->region()->layer() + 1) * 2 * h); break; } @@ -699,7 +699,7 @@ StreamView::update_contents_height () for (vector::iterator i = rec_rects.begin(); i != rec_rects.end(); ++i) { switch (_layer_display) { case Overlaid: - i->rectangle->set_y1 (height); + i->rectangle->set_y1 (_height); break; case Stacked: case Expanded: @@ -781,3 +781,21 @@ StreamView::parameter_changed (string const & what) } } } + +int +StreamView::y_position () const +{ + return _trackview.y_position(); +} + +int +StreamView::height() const +{ + return _height; +} + +int +StreamView::width () const +{ + return (int) ArdourCanvas::COORD_MAX; +} diff --git a/gtk2_ardour/streamview.h b/gtk2_ardour/streamview.h index 69269e2b0f..fb902de9ea 100644 --- a/gtk2_ardour/streamview.h +++ b/gtk2_ardour/streamview.h @@ -33,6 +33,7 @@ #include "enums.h" #include "selectable.h" +#include "time_axis_view_item.h" #include "view_background.h" namespace Gdk { @@ -77,6 +78,13 @@ public: void set_zoom_all(); + int height() const; + int width() const; + int contents_height() const { + return child_height() - TimeAxisViewItem::NAME_HIGHLIGHT_SIZE - 2; + } + int y_position () const; + int set_position (gdouble x, gdouble y); virtual int set_height (double); @@ -185,7 +193,7 @@ protected: ARDOUR::layer_t _layers; LayerDisplay _layer_display; - double height; + double _height; PBD::ScopedConnectionList rec_data_ready_connections; samplepos_t last_rec_data_sample; diff --git a/gtk2_ardour/view_background.h b/gtk2_ardour/view_background.h index 8d0c6393ea..5ad54fd8a5 100644 --- a/gtk2_ardour/view_background.h +++ b/gtk2_ardour/view_background.h @@ -40,9 +40,9 @@ class ViewBackground : public sigc::trackable ViewBackground (); virtual ~ViewBackground (); - virtual int height() const { return 0; } - virtual int width() const { return 0; } - virtual int contents_height() const { return 0; } + virtual int height() const = 0; + virtual int width() const = 0; + virtual int contents_height() const = 0; /** @return y position, or -1 if hidden */ virtual int y_position () const { return 0; }