Ardour  9.0-pre0-582-g084a23a80d
fitted_canvas_widget.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2021 Paul Davis
3  Author: Ben Loftis <ben@harrisonconsoles.com>
4 
5  This program is free software; you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation; either version 2 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program; if not, write to the Free Software
17  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 
20 #ifndef _gtk_ardour_fitted_canvas_widget_h_
21 #define _gtk_ardour_fitted_canvas_widget_h_
22 
23 #include <canvas/canvas.h>
24 
25 #include <gtkmm/layout.h>
26 
27 /* FittedCanvasWidget has these properties:
28  * it is provided a 'nominal size' on construction, which it will request of gtk
29  * if asked, will resize itself when the user gui/font scale changes
30  * it 'fits' the Item that was first attached to Root (presumably the top-level widget or container)
31  * the fitted Item will be explicitly resized to fit when the canvas size is allocated
32  * the fitted Item may be a container; it should allocate child positions during size_allocate()
33  */
35 {
36 public:
37  /* per gtk convention you may use -1 for width OR height if you don't care about that dimension */
38  FittedCanvasWidget (float nominal_width, float nominal_height, bool follow_scale = true);
39 
40  /* call if the root item's first child is changed, to force a size-allocate on it */
42 
43  /* always returns the nominal size, regardless of children */
45 
47 
48  virtual float nominal_width() {return _nominal_width;}
49  virtual float nominal_height() {return _nominal_height;}
50 
51 private:
53 
57 };
58 
59 #endif // _gtk_ardour_fitted_canvas_widget_h_
Declaration of the main canvas classes.
virtual float nominal_width()
virtual float nominal_height()
void repeat_size_allocation()
ArdourCanvas::Rect _allocation
void on_size_allocate(Gtk::Allocation &)
This is a default handler for the signal signal_size_allocate().
FittedCanvasWidget(float nominal_width, float nominal_height, bool follow_scale=true)
void on_size_request(Gtk::Requisition *)
This is a default handler for the signal signal_size_request().