13
0
livetrax/gtk2_ardour/fitted_canvas_widget.h

57 lines
2.1 KiB
C
Raw Normal View History

/*
Copyright (C) 2021 Paul Davis
Author: Ben Loftis <ben@harrisonconsoles.com>
This program 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.
This program 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 this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
2021-12-17 09:30:14 -05:00
#ifndef _gtk_ardour_fitted_canvas_widget_h_
#define _gtk_ardour_fitted_canvas_widget_h_
#include <canvas/canvas.h>
#include <gtkmm/layout.h>
/* FittedCanvasWidget has these properties:
* it is provided a 'nominal size' on construction, which it will request of gtk
* if asked, will resize itself when the user gui/font scale changes
* it 'fits' the Item that was first attached to Root (presumably the top-level widget or container)
* the fitted Item will be explicitly resized to fit when the canvas size is allocated
* the fitted Item may be a container; it should allocate child positions during size_allocate()
2021-12-17 09:30:14 -05:00
*/
class FittedCanvasWidget : public ArdourCanvas::GtkCanvas
{
public:
/* per gtk convention you may use -1 for width OR height if you don't care about that dimension */
2021-12-17 09:30:14 -05:00
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 ();
2021-12-17 09:30:14 -05:00
/* always returns the nominal size, regardless of children */
void on_size_request (Gtk::Requisition*);
void on_size_allocate (Gtk::Allocation&);
private:
ArdourCanvas::Rect _allocation;
2021-12-17 09:30:14 -05:00
float _nominal_width;
float _nominal_height;
bool _follow_scale;
};
2021-12-17 09:30:14 -05:00
#endif // _gtk_ardour_fitted_canvas_widget_h_