From de6178093e51b59c006ffea7c8235e492ad2234a Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Thu, 16 Dec 2021 18:54:32 -0700 Subject: [PATCH] allow FittedCanvasWidget to have it's root first child replaced --- gtk2_ardour/fitted_canvas_widget.cc | 8 +++++++- gtk2_ardour/fitted_canvas_widget.h | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/gtk2_ardour/fitted_canvas_widget.cc b/gtk2_ardour/fitted_canvas_widget.cc index ac3865a82b..ae6505a1b0 100644 --- a/gtk2_ardour/fitted_canvas_widget.cc +++ b/gtk2_ardour/fitted_canvas_widget.cc @@ -76,10 +76,16 @@ void FittedCanvasWidget::on_size_allocate (Gtk::Allocation& alloc) { GtkCanvas::on_size_allocate(alloc); + repeat_size_allocation (); +} +void +FittedCanvasWidget::repeat_size_allocation () +{ if (!_root.items().empty()) { ArdourCanvas::Item *fitted = *_root.items().begin(); - fitted->size_allocate(ArdourCanvas::Rect(0,0,alloc.get_width(), alloc.get_height())); + Gtk::Allocation a = get_allocation (); + fitted->size_allocate (ArdourCanvas::Rect (0, 0, a.get_width(), a.get_height())); } } diff --git a/gtk2_ardour/fitted_canvas_widget.h b/gtk2_ardour/fitted_canvas_widget.h index 6ab36b2da4..2de7a4fc52 100644 --- a/gtk2_ardour/fitted_canvas_widget.h +++ b/gtk2_ardour/fitted_canvas_widget.h @@ -55,10 +55,14 @@ public: /* per gtk convention you may use -1 for width OR height if you don't care about that dimension */ FittedCanvasWidget(float nominal_width, float nominal_height, bool follow_scale=true); + /* call if the root item's first child is changed, to force a size-allocate on it */ + void repeat_size_allocation (); + void on_size_request (Gtk::Requisition* req); //always returns the nominal size, regardless of children void on_size_allocate (Gtk::Allocation& alloc); private: + ArdourCanvas::Rect _allocation; float _nominal_width; float _nominal_height; bool _follow_scale;