11#ifndef INKSCAPE_UI_WIDGET_EVENTS_CANVAS_EVENT_H
12#define INKSCAPE_UI_WIDGET_EVENTS_CANVAS_EVENT_H
19#include <gdkmm/enums.h>
20#include <gdkmm/event.h>
26namespace Gdk {
class Device; }
44 auto read = [&] (Gdk::AxisUse axis) -> std::optional<double> {
46 if (event.get_axis(axis, tmp)) {
54 .
pressure = read(Gdk::AxisUse::PRESSURE),
55 .xtilt = read(Gdk::AxisUse::XTILT),
56 .ytilt = read(Gdk::AxisUse::YTILT)
80 std::shared_ptr<Gdk::Device const>
device;
92 case 1:
return GDK_BUTTON1_MASK;
93 case 2:
return GDK_BUTTON2_MASK;
94 case 3:
return GDK_BUTTON3_MASK;
95 case 4:
return GDK_BUTTON4_MASK;
96 case 5:
return GDK_BUTTON5_MASK;
146 case GDK_KEY_Shift_L:
147 case GDK_KEY_Shift_R:
148 return GDK_SHIFT_MASK;
149 case GDK_KEY_Control_L:
150 case GDK_KEY_Control_R:
151 return GDK_CONTROL_MASK;
157 return GDK_META_MASK;
176 std::optional<Geom::Point>
pos;
251 Gdk::ScrollUnit
unit = Gdk::ScrollUnit::SURFACE;
257namespace canvas_event_detail {
262 return static_cast<E &
>(event);
268 return static_cast<E
const &
>(event);
274 return static_cast<E &&
>(event);
289template <
typename E,
typename... Fs>
292 using namespace canvas_event_detail;
296 switch (event.type()) {
298 overloaded(cast_helper<EnterEvent>(std::forward<E>(event)));
301 overloaded(cast_helper<LeaveEvent>(std::forward<E>(event)));
304 overloaded(cast_helper<MotionEvent>(std::forward<E>(event)));
307 overloaded(cast_helper<ButtonPressEvent>(std::forward<E>(event)));
310 overloaded(cast_helper<ButtonReleaseEvent>(std::forward<E>(event)));
313 overloaded(cast_helper<KeyPressEvent>(std::forward<E>(event)));
316 overloaded(cast_helper<KeyReleaseEvent>(std::forward<E>(event)));
319 overloaded(cast_helper<ScrollEvent>(std::forward<E>(event)));
333inline bool mod_shift(
unsigned modifiers) {
return modifiers & GDK_SHIFT_MASK; }
334inline bool mod_ctrl(
unsigned modifiers) {
return modifiers & GDK_CONTROL_MASK; }
335inline bool mod_alt(
unsigned modifiers) {
return modifiers & GDK_ALT_MASK; }
342template <
unsigned button>
343inline bool mod_button(
unsigned modifiers) {
return (1 <= button || button <= 5) && (modifiers & (GDK_BUTTON1_MASK << (button - 1))); }
354template <
unsigned button>
Cartesian point / 2D vector and related operations.
Two-dimensional point that doubles as a vector.
E & cast_helper(CanvasEvent &event)
Helper class to stream background task notifications as a series of messages.
bool mod_alt(unsigned modifiers)
EventType
The type of a CanvasEvent.
void inspect_event(E &&event, Fs... funcs)
Perform pattern-matching on a CanvasEvent.
bool mod_ctrl_only(unsigned modifiers)
bool mod_ctrl(unsigned modifiers)
bool mod_shift_only(unsigned modifiers)
bool mod_none(unsigned modifiers)
bool mod_shift(unsigned modifiers)
bool mod_alt_only(unsigned modifiers)
bool mod_button(unsigned modifiers)
ExtendedInput extinput_from_gdkevent(Gdk::Event const &event)
Read the extended input data from a Gdk::Event.
bool mod_any(unsigned modifiers)
constexpr auto INK_GDK_MODIFIER_MASK
All modifiers used by Inkscape.
Abstract base class for events.
unsigned modifiers
The modifiers mask immediately before the event.
virtual unsigned modifiersChange() const
Get the change in the modifiers due to this event.
unsigned modifiersAfter() const
Get the modifiers mask immediately after the event. (Convenience function.)
virtual EventType type() const =0
Return the dynamic type of the CanvasEvent.
std::shared_ptr< Gdk::Device const > device
The device that sourced the event. May be null.
The pointer has entered a widget or item.
Geom::Point pos
Location of the cursor.
EventType type() const override
Return the dynamic type of the CanvasEvent.
std::optional< Geom::Point > pos
Location of the cursor, in world coordinates.
uint32_t keyval
The key that was pressed/released. (Matches gdkkeysyms.h.)
unsigned modifiersChange() const override
Get the change in the modifiers due to this event.
int group
The keyboard group.
std::optional< Geom::Point > orig_pos
Location of the cursor, in GDK event / canvas widget coordinates.
uint16_t keycode
The raw code of the key that was pressed/released.
uint32_t time
Timestamp of the event in milliseconds.
EventType type() const override
Return the dynamic type of the CanvasEvent.
EventType type() const override
Return the dynamic type of the CanvasEvent.
The pointer has exited a widget or item.
EventType type() const override
Return the dynamic type of the CanvasEvent.
Movement of the mouse pointer.
bool control_point_synthesized
Whether this is a fake motion event synthesized by a control point.
EventType type() const override
Return the dynamic type of the CanvasEvent.
ExtendedInput extinput
Extended input data for graphics tablet input. Fields may be empty.
uint32_t time
Timestamp of the event in milliseconds.
Geom::Point pos
Location of the cursor.