small class rearrangement for ViewBackground and derived classes related to geometry management

This commit is contained in:
Paul Davis 2025-06-04 20:43:18 -06:00
parent 80a34fc3ec
commit 08f77136b9
5 changed files with 45 additions and 27 deletions

View file

@ -531,8 +531,3 @@ MidiStreamView::record_layer_check (std::shared_ptr<ARDOUR::Region> r, samplepos
check_record_layers (r, t); check_record_layers (r, t);
} }
int
MidiStreamView::y_position () const
{
return _trackview.y_position();
}

View file

@ -63,18 +63,15 @@ public:
MidiStreamView (MidiTimeAxisView&); MidiStreamView (MidiTimeAxisView&);
~MidiStreamView (); ~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 get_regions_with_selected_data (RegionSelection&);
void set_layer_display (LayerDisplay); 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. //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 (); 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<ARDOUR::Region>, bool, bool); RegionView* create_region_view (std::shared_ptr<ARDOUR::Region>, bool, bool);
bool paste (Temporal::timepos_t const & pos, const Selection& selection, PasteContext& ctx); bool paste (Temporal::timepos_t const & pos, const Selection& selection, PasteContext& ctx);

View file

@ -68,7 +68,7 @@ StreamView::StreamView (RouteTimeAxisView& tv, ArdourCanvas::Container* canvas_g
, stream_base_color(0xFFFFFFFF) , stream_base_color(0xFFFFFFFF)
, _layers (1) , _layers (1)
, _layer_display (Overlaid) , _layer_display (Overlaid)
, height (tv.height) , _height (tv.height)
, last_rec_data_sample(0) , last_rec_data_sample(0)
{ {
CANVAS_DEBUG_NAME (_canvas_group, string_compose ("SV canvas group %1", _trackview.name())); CANVAS_DEBUG_NAME (_canvas_group, string_compose ("SV canvas group %1", _trackview.name()));
@ -123,12 +123,12 @@ StreamView::set_height (double h)
return -1; return -1;
} }
if (height == h) { if (_height == h) {
return 0; return 0;
} }
height = h; _height = h;
canvas_rect->set_y1 (height); canvas_rect->set_y1 (_height);
update_contents_height (); update_contents_height ();
return 0; 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 (), /* Note: EditorAutomationLine::get_selectables() uses trackview.current_height (),
* disregarding Stacked layer display 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 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 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)); 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) { switch (_layer_display) {
case Overlaid: case Overlaid:
return height; return _height;
case Stacked: case Stacked:
return height / _layers; return _height / _layers;
case Expanded: case Expanded:
return height / (_layers * 2 + 1); return _height / (_layers * 2 + 1);
} }
abort(); /* NOTREACHED */ abort(); /* NOTREACHED */
return height; return _height;
} }
void void
@ -686,10 +686,10 @@ StreamView::update_contents_height ()
(*i)->set_y (0); (*i)->set_y (0);
break; break;
case Stacked: case Stacked:
(*i)->set_y (height - ((*i)->region()->layer() + 1) * h); (*i)->set_y (_height - ((*i)->region()->layer() + 1) * h);
break; break;
case Expanded: case Expanded:
(*i)->set_y (height - ((*i)->region()->layer() + 1) * 2 * h); (*i)->set_y (_height - ((*i)->region()->layer() + 1) * 2 * h);
break; break;
} }
@ -699,7 +699,7 @@ StreamView::update_contents_height ()
for (vector<RecBoxInfo>::iterator i = rec_rects.begin(); i != rec_rects.end(); ++i) { for (vector<RecBoxInfo>::iterator i = rec_rects.begin(); i != rec_rects.end(); ++i) {
switch (_layer_display) { switch (_layer_display) {
case Overlaid: case Overlaid:
i->rectangle->set_y1 (height); i->rectangle->set_y1 (_height);
break; break;
case Stacked: case Stacked:
case Expanded: 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;
}

View file

@ -33,6 +33,7 @@
#include "enums.h" #include "enums.h"
#include "selectable.h" #include "selectable.h"
#include "time_axis_view_item.h"
#include "view_background.h" #include "view_background.h"
namespace Gdk { namespace Gdk {
@ -77,6 +78,13 @@ public:
void set_zoom_all(); 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); int set_position (gdouble x, gdouble y);
virtual int set_height (double); virtual int set_height (double);
@ -185,7 +193,7 @@ protected:
ARDOUR::layer_t _layers; ARDOUR::layer_t _layers;
LayerDisplay _layer_display; LayerDisplay _layer_display;
double height; double _height;
PBD::ScopedConnectionList rec_data_ready_connections; PBD::ScopedConnectionList rec_data_ready_connections;
samplepos_t last_rec_data_sample; samplepos_t last_rec_data_sample;

View file

@ -40,9 +40,9 @@ class ViewBackground : public sigc::trackable
ViewBackground (); ViewBackground ();
virtual ~ViewBackground (); virtual ~ViewBackground ();
virtual int height() const { return 0; } virtual int height() const = 0;
virtual int width() const { return 0; } virtual int width() const = 0;
virtual int contents_height() const { return 0; } virtual int contents_height() const = 0;
/** @return y position, or -1 if hidden */ /** @return y position, or -1 if hidden */
virtual int y_position () const { return 0; } virtual int y_position () const { return 0; }