Ardour
9.0-pre0-350-gf17a656217
cairo_widget.h
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2011-2016 Paul Davis <paul@linuxaudiosystems.com>
3
* Copyright (C) 2014-2018 Robin Gareus <robin@gareus.org>
4
* Copyright (C) 2014 Ben Loftis <ben@harrisonconsoles.com>
5
*
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
10
*
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
15
*
16
* You should have received a copy of the GNU General Public License along
17
* with this program; if not, write to the Free Software Foundation, Inc.,
18
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19
*/
20
21
#ifndef __gtk2_ardour_cairo_widget_h__
22
#define __gtk2_ardour_cairo_widget_h__
23
24
#include <cairomm/context.h>
25
#include <cairomm/surface.h>
26
#include <
gtkmm/eventbox.h
>
27
28
#include "
gtkmm2ext/visibility.h
"
29
#include "
gtkmm2ext/cairo_canvas.h
"
30
#include "
gtkmm2ext/cairo_theme.h
"
31
#include "
gtkmm2ext/colors.h
"
32
#include "
gtkmm2ext/widget_state.h
"
33
37
class
LIBGTKMM2EXT_API
CairoWidget
:
public
Gtk::EventBox
,
public
Gtkmm2ext::CairoCanvas
,
public
Gtkmm2ext::CairoTheme
38
{
39
public
:
40
CairoWidget
();
41
virtual
~CairoWidget
();
42
43
void
set_canvas_widget
();
44
void
use_nsglview
(
bool
retina =
true
);
45
void
use_image_surface
(
bool
yn =
true
);
46
47
/* swizzle Gtk::Widget methods for Canvas::Widget */
48
void
queue_draw
();
49
void
queue_resize
();
50
int
get_width
()
const
;
51
int
get_height
()
const
;
52
void
size_allocate
(
Gtk::Allocation
&);
53
54
void
set_dirty
(cairo_rectangle_t *area = 0);
55
56
Gtkmm2ext::ActiveState
active_state
()
const
{
return
_active_state; }
57
Gtkmm2ext::VisualState
visual_state
()
const
{
return
_visual_state; }
58
59
/* derived widgets can override these two to catch
60
changes in active & visual state
61
*/
62
63
virtual
void
set_active_state
(
Gtkmm2ext::ActiveState
);
64
virtual
void
set_visual_state
(
Gtkmm2ext::VisualState
);
65
66
void
unset_active_state
() { set_active_state (
Gtkmm2ext::Off
); }
67
void
unset_visual_state
() { set_visual_state (
Gtkmm2ext::NoVisualState
); }
68
69
/* this is an API simplification for widgets
70
that only use the Active and Normal active states.
71
*/
72
void
set_active
(
bool
);
73
bool
get_active
()
const
{
return
active_state() !=
Gtkmm2ext::Off
; }
74
75
/* widgets can be told to only draw their "foreground, and thus leave
76
in place whatever background is drawn by their parent. the default
77
is that the widget will fill its event window with the background
78
color of the parent container.
79
*/
80
81
void
set_draw_background
(
bool
yn);
82
83
sigc::signal<void>
StateChanged
;
84
sigc::signal<bool>
QueueDraw
;
85
sigc::signal<bool>
QueueResize
;
86
87
static
void
provide_background_for_cairo_widget
(
Gtk::Widget
& w,
const
Gdk::Color
& bg);
88
89
uint32_t
background_color
();
90
91
92
static
void
set_source_rgb_a
( cairo_t* cr,
Gdk::Color
,
float
a=1.0 );
93
static
void
set_source_rgb_a
( cairo_t* cr,
Gtkmm2ext::Color
,
float
a=1.0 );
94
95
/* set_focus_handler() will cause all button-press events on any
96
CairoWidget to invoke this slot/functor/function/method/callback.
97
98
We do this because in general, CairoWidgets do not grab
99
keyboard focus, but a button press on them should
100
clear focus from any active text entry.
101
102
This is global to all CairoWidgets and derived types.
103
104
However, derived types can override the behaviour by defining their
105
own on_button_press_event() handler which returns true under all
106
conditions (which will block this handler from being called). If
107
they wish to invoke any existing focus handler from their own
108
button press handler, they can just use: focus_handler();
109
*/
110
static
void
set_focus_handler
(sigc::slot<void,Gtk::Widget*>);
111
112
protected
:
114
virtual
bool
on_expose_event
(
GdkEventExpose
*);
115
void
on_size_allocate
(
Gtk::Allocation
&);
116
void
on_state_changed
(
Gtk::StateType
);
117
void
on_style_changed
(
const
Glib::RefPtr<Gtk::Style>&);
118
void
on_realize
();
119
bool
on_button_press_event
(
GdkEventButton
*);
120
Gdk::Color
get_parent_bg
();
121
void
on_map
();
122
void
on_unmap
();
123
124
/* this is an additional virtual "on_..." method. Glibmm does not
125
provide a direct signal for name changes, so this acts as a proxy.
126
*/
127
128
virtual
void
on_name_changed
() {};
129
130
Gtkmm2ext::ActiveState
_active_state
;
131
Gtkmm2ext::VisualState
_visual_state
;
132
bool
_need_bg
;
133
bool
_grabbed
;
134
135
static
sigc::slot<void,Gtk::Widget*>
focus_handler
;
136
137
private
:
138
void
on_widget_name_changed
();
139
140
Cairo::RefPtr<Cairo::Surface>
image_surface
;
141
Glib::SignalProxyProperty
_name_proxy
;
142
sigc::connection
_parent_style_change
;
143
Widget *
_current_parent
;
144
bool
_canvas_widget
;
145
void
*
_nsglview
;
146
bool
_use_image_surface
;
147
Gdk::Rectangle
_allocation
;
148
Glib::ustring
_widget_name
;
149
150
};
151
152
#endif
cairo_canvas.h
cairo_theme.h
CairoWidget
Definition:
cairo_widget.h:38
CairoWidget::set_visual_state
virtual void set_visual_state(Gtkmm2ext::VisualState)
CairoWidget::_visual_state
Gtkmm2ext::VisualState _visual_state
Definition:
cairo_widget.h:131
CairoWidget::_active_state
Gtkmm2ext::ActiveState _active_state
Definition:
cairo_widget.h:128
CairoWidget::_nsglview
void * _nsglview
Definition:
cairo_widget.h:145
CairoWidget::on_expose_event
virtual bool on_expose_event(GdkEventExpose *)
CairoWidget::_parent_style_change
sigc::connection _parent_style_change
Definition:
cairo_widget.h:142
CairoWidget::provide_background_for_cairo_widget
static void provide_background_for_cairo_widget(Gtk::Widget &w, const Gdk::Color &bg)
CairoWidget::set_source_rgb_a
static void set_source_rgb_a(cairo_t *cr, Gdk::Color, float a=1.0)
CairoWidget::set_source_rgb_a
static void set_source_rgb_a(cairo_t *cr, Gtkmm2ext::Color, float a=1.0)
CairoWidget::~CairoWidget
virtual ~CairoWidget()
CairoWidget::_canvas_widget
bool _canvas_widget
Definition:
cairo_widget.h:144
CairoWidget::on_name_changed
virtual void on_name_changed()
Definition:
cairo_widget.h:128
CairoWidget::QueueDraw
sigc::signal< bool > QueueDraw
Definition:
cairo_widget.h:84
CairoWidget::set_active
void set_active(bool)
CairoWidget::QueueResize
sigc::signal< bool > QueueResize
Definition:
cairo_widget.h:85
CairoWidget::on_realize
void on_realize()
This is a default handler for the signal signal_realize().
CairoWidget::use_nsglview
void use_nsglview(bool retina=true)
CairoWidget::on_style_changed
void on_style_changed(const Glib::RefPtr< Gtk::Style > &)
CairoWidget::on_button_press_event
bool on_button_press_event(GdkEventButton *)
This is a default handler for the signal signal_button_press_event().
CairoWidget::queue_draw
void queue_draw()
CairoWidget::background_color
uint32_t background_color()
CairoWidget::_current_parent
Widget * _current_parent
Definition:
cairo_widget.h:143
CairoWidget::StateChanged
sigc::signal< void > StateChanged
Definition:
cairo_widget.h:83
CairoWidget::_use_image_surface
bool _use_image_surface
Definition:
cairo_widget.h:146
CairoWidget::on_unmap
void on_unmap()
This is a default handler for the signal signal_unmap().
CairoWidget::on_state_changed
void on_state_changed(Gtk::StateType)
This is a default handler for the signal signal_state_changed().
CairoWidget::image_surface
Cairo::RefPtr< Cairo::Surface > image_surface
Definition:
cairo_widget.h:140
CairoWidget::set_canvas_widget
void set_canvas_widget()
CairoWidget::focus_handler
static sigc::slot< void, Gtk::Widget * > focus_handler
Definition:
cairo_widget.h:135
CairoWidget::set_draw_background
void set_draw_background(bool yn)
CairoWidget::get_parent_bg
Gdk::Color get_parent_bg()
CairoWidget::_widget_name
Glib::ustring _widget_name
Definition:
cairo_widget.h:148
CairoWidget::use_image_surface
void use_image_surface(bool yn=true)
CairoWidget::active_state
Gtkmm2ext::ActiveState active_state() const
Definition:
cairo_widget.h:56
CairoWidget::size_allocate
void size_allocate(Gtk::Allocation &)
CairoWidget::unset_active_state
void unset_active_state()
Definition:
cairo_widget.h:66
CairoWidget::get_active
bool get_active() const
Definition:
cairo_widget.h:73
CairoWidget::visual_state
Gtkmm2ext::VisualState visual_state() const
Definition:
cairo_widget.h:57
CairoWidget::_name_proxy
Glib::SignalProxyProperty _name_proxy
Definition:
cairo_widget.h:141
CairoWidget::get_height
int get_height() const
CairoWidget::set_focus_handler
static void set_focus_handler(sigc::slot< void, Gtk::Widget * >)
CairoWidget::CairoWidget
CairoWidget()
CairoWidget::unset_visual_state
void unset_visual_state()
Definition:
cairo_widget.h:67
CairoWidget::get_width
int get_width() const
CairoWidget::on_size_allocate
void on_size_allocate(Gtk::Allocation &)
This is a default handler for the signal signal_size_allocate().
CairoWidget::_grabbed
bool _grabbed
Definition:
cairo_widget.h:133
CairoWidget::_need_bg
bool _need_bg
Definition:
cairo_widget.h:132
CairoWidget::queue_resize
void queue_resize()
CairoWidget::on_map
void on_map()
This is a default handler for the signal signal_map().
CairoWidget::set_active_state
virtual void set_active_state(Gtkmm2ext::ActiveState)
CairoWidget::_allocation
Gdk::Rectangle _allocation
Definition:
cairo_widget.h:147
CairoWidget::on_widget_name_changed
void on_widget_name_changed()
CairoWidget::set_dirty
void set_dirty(cairo_rectangle_t *area=0)
Gdk::Color
Definition:
color.h:55
Gdk::Rectangle
Definition:
tk/ydkmm/ydkmm/gdkmm/rectangle.h:42
Gtk::EventBox
Definition:
eventbox.h:59
Gtk::Widget
Definition:
tk/ytkmm/ytkmm/gtkmm/widget.h:336
Gtkmm2ext::CairoCanvas
Definition:
cairo_canvas.h:29
Gtkmm2ext::CairoTheme
Definition:
cairo_theme.h:29
colors.h
eventbox.h
Gtk::StateType
StateType
Definition:
libs/tk/ytkmm/ytkmm/gtkmm/enums.h:1138
visibility.h
LIBGTKMM2EXT_API
#define LIBGTKMM2EXT_API
Definition:
gtkmm2ext/gtkmm2ext/visibility.h:39
Gtkmm2ext::Color
uint32_t Color
Definition:
colors.h:33
Gtkmm2ext::VisualState
VisualState
Definition:
widget_state.h:36
Gtkmm2ext::NoVisualState
@ NoVisualState
Definition:
widget_state.h:38
Gtkmm2ext::ActiveState
ActiveState
Definition:
widget_state.h:30
Gtkmm2ext::Off
@ Off
Definition:
widget_state.h:31
_GdkEventButton
Definition:
gdkevents.h:321
_GdkEventExpose
Definition:
gdkevents.h:281
widget_state.h
libs
gtkmm2ext
gtkmm2ext
cairo_widget.h
Generated on Tue Nov 5 2024 05:28:30 for Ardour by
1.9.1