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
*/
34
class
FittedCanvasWidget
:
public
ArdourCanvas::GtkCanvas
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 */
41
void
repeat_size_allocation
();
42
43
/* always returns the nominal size, regardless of children */
44
void
on_size_request
(
Gtk::Requisition
*);
45
46
void
on_size_allocate
(
Gtk::Allocation
&);
47
48
virtual
float
nominal_width
() {
return
_nominal_width
;}
49
virtual
float
nominal_height
() {
return
_nominal_height
;}
50
51
private
:
52
ArdourCanvas::Rect
_allocation
;
53
54
float
_nominal_width
;
55
float
_nominal_height
;
56
bool
_follow_scale
;
57
};
58
59
#endif
// _gtk_ardour_fitted_canvas_widget_h_
canvas.h
Declaration of the main canvas classes.
ArdourCanvas::GtkCanvas
Definition:
canvas/canvas/canvas.h:218
FittedCanvasWidget
Definition:
fitted_canvas_widget.h:35
FittedCanvasWidget::_nominal_width
float _nominal_width
Definition:
fitted_canvas_widget.h:54
FittedCanvasWidget::nominal_width
virtual float nominal_width()
Definition:
fitted_canvas_widget.h:48
FittedCanvasWidget::nominal_height
virtual float nominal_height()
Definition:
fitted_canvas_widget.h:49
FittedCanvasWidget::repeat_size_allocation
void repeat_size_allocation()
FittedCanvasWidget::_follow_scale
bool _follow_scale
Definition:
fitted_canvas_widget.h:56
FittedCanvasWidget::_allocation
ArdourCanvas::Rect _allocation
Definition:
fitted_canvas_widget.h:52
FittedCanvasWidget::_nominal_height
float _nominal_height
Definition:
fitted_canvas_widget.h:55
FittedCanvasWidget::on_size_allocate
void on_size_allocate(Gtk::Allocation &)
This is a default handler for the signal signal_size_allocate().
FittedCanvasWidget::FittedCanvasWidget
FittedCanvasWidget(float nominal_width, float nominal_height, bool follow_scale=true)
FittedCanvasWidget::on_size_request
void on_size_request(Gtk::Requisition *)
This is a default handler for the signal signal_size_request().
Gdk::Rectangle
Definition:
tk/ydkmm/ydkmm/gdkmm/rectangle.h:42
ArdourCanvas::Rect
Definition:
canvas/canvas/types.h:112
_GtkRequisition
Definition:
gtkwidget.h:520
layout.h
gtk2_ardour
fitted_canvas_widget.h
Generated on Wed Dec 25 2024 05:44:15 for Ardour by
1.9.1