Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
widget-vfuncs-class-init.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
5/*
6 * Authors:
7 * Daniel Boles <dboles.src+inkscape@gmail.com>
8 *
9 * Copyright (C) 2023 Daniel Boles
10 *
11 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
12 */
13
14#ifndef SEEN_UI_WIDGET_WIDGET_VFUNCS_CLASS_INIT_H
15#define SEEN_UI_WIDGET_WIDGET_VFUNCS_CLASS_INIT_H
16
17#include <optional>
18#include <glibmm/extraclassinit.h>
19#include <gtk/gtk.h>
20#include <gtkmm/enums.h>
21
22namespace Inkscape::UI::Widget {
23
29class WidgetVfuncsClassInit : public Glib::ExtraClassInit {
30public:
32 struct CFuncs final {
33 using CssChanged = void (GtkWidget *, GtkCssStyleChange *);
34 using Focus = gboolean (GtkWidget *, GtkDirectionType );
35
37 Focus *focus = nullptr;
38 };
39
40protected:
41 [[nodiscard]] WidgetVfuncsClassInit();
42 ~WidgetVfuncsClassInit() override;
43
45 virtual void css_changed(GtkCssStyleChange *change) {}
46
49 virtual std::optional<bool> focus(Gtk::DirectionType direction) { return std::nullopt; }
50
51private:
52 // The following ‘thunk’ vfunc impls...
55 // ...are used by every instance of us.
56 static constexpr CFuncs cfuncs = {
58 &_focus ,
59 };
60};
61
62} // namespace Inkscape::UI::Widget
63
64#endif // SEEN_UI_WIDGET_WIDGET_VFUNCS_CLASS_INIT_H
65
66/*
67 Local Variables:
68 mode:c++
69 c-file-style:"stroustrup"
70 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
71 indent-tabs-mode:nil
72 fill-column:99
73 End:
74*/
75// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :
A class you can inherit to access GTK4ʼs Widget.css_changed & .focus vfuncs, missing in gtkmm4.
virtual std::optional< bool > focus(Gtk::DirectionType direction)
Called before gtk_widget_focus(): return true if moving in direction keeps focus w/in self,...
virtual void css_changed(GtkCssStyleChange *change)
Called after gtk_widget_css_changed(): when a CSS widget node is validated & style changed.
Custom widgets.
Definition desktop.h:126
static Geom::Point direction(Geom::Point const &first, Geom::Point const &second)
Computes an unit vector of the direction from first to second control point.
Definition node.cpp:164