Inkscape
Vector Graphics Editor
Loading...
Searching...
No Matches
enums.h
Go to the documentation of this file.
1// SPDX-License-Identifier: GPL-2.0-or-later
2/*
3 * Authors:
4 * Matthew Jakeman <mjakeman26@outlook.co.nz>
5 * PBS <pbs3141@gmail.com>
6 *
7 * Copyright (C) 2022 Authors
8 *
9 * Released under GNU GPL v2+, read the file 'COPYING' for more information.
10 */
11#ifndef INKSCAPE_UI_WIDGET_EVENTS_ENUMS_H
12#define INKSCAPE_UI_WIDGET_EVENTS_ENUMS_H
13
14#include <limits>
15
16namespace Inkscape {
17
21enum class EventType
22{
23 ENTER,
24 LEAVE,
25 MOTION,
30 SCROLL,
32};
33
38{
39public:
40 EventMask() = default;
41 constexpr EventMask(EventType type) : _mask(1 << (int)type) {} // allow implicit conversion - unsurprising
42
43 constexpr operator bool() const { return _mask; }
44 constexpr EventMask operator~() const { return EventMask(~_mask); }
45 constexpr EventMask operator&(EventMask other) const { return EventMask(_mask & other._mask); }
46 constexpr EventMask operator|(EventMask other) const { return EventMask(_mask | other._mask); }
47
48private:
49 unsigned _mask = 0;
50 static_assert(std::numeric_limits<decltype(_mask)>::digits >= (int)EventType::NUM_EVENTS);
51
52 explicit constexpr EventMask(unsigned mask) : _mask(mask) {}
53};
54
55constexpr EventMask operator~(EventType a) { return ~EventMask(a); }
56constexpr EventMask operator&(EventType a, EventMask b) { return EventMask(a) & b; }
57constexpr EventMask operator|(EventType a, EventMask b) { return EventMask(a) | b; }
58
59} // namespace Inkscape
60
61#endif // INKSCAPE_UI_WIDGET_EVENTS_ENUMS_H
A mask representing a subset of EventTypes.
Definition enums.h:38
constexpr EventMask operator~() const
Definition enums.h:44
unsigned _mask
Definition enums.h:49
constexpr EventMask(unsigned mask)
Definition enums.h:52
constexpr EventMask(EventType type)
Definition enums.h:41
constexpr EventMask operator|(EventMask other) const
Definition enums.h:46
constexpr EventMask operator&(EventMask other) const
Definition enums.h:45
Helper class to stream background task notifications as a series of messages.
constexpr EventMask operator|(EventType a, EventMask b)
Definition enums.h:57
EventType
The type of a CanvasEvent.
Definition enums.h:22
constexpr EventMask operator&(EventType a, EventMask b)
Definition enums.h:56
constexpr EventMask operator~(EventType a)
Definition enums.h:55