Cleanup
[carla.git] / source / modules / dgl / Base.hpp
blob1ecdb64dc7f5f05d239983aaca7da00b82e2e0e3
1 /*
2 * DISTRHO Plugin Framework (DPF)
3 * Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com>
5 * Permission to use, copy, modify, and/or distribute this software for any purpose with
6 * or without fee is hereby granted, provided that the above copyright notice and this
7 * permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
10 * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
11 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
17 #ifndef DGL_BASE_HPP_INCLUDED
18 #define DGL_BASE_HPP_INCLUDED
20 #include "../distrho/extra/LeakDetector.hpp"
21 #include "../distrho/extra/ScopedPointer.hpp"
23 // --------------------------------------------------------------------------------------------------------------------
24 // Define namespace
26 #ifndef DGL_NAMESPACE
27 # define DGL_NAMESPACE DGL
28 #endif
30 #define START_NAMESPACE_DGL namespace DGL_NAMESPACE {
31 #define END_NAMESPACE_DGL }
32 #define USE_NAMESPACE_DGL using namespace DGL_NAMESPACE;
34 START_NAMESPACE_DGL
36 // --------------------------------------------------------------------------------------------------------------------
37 // Base DGL enums
39 /**
40 Keyboard modifier flags.
42 enum Modifier {
43 kModifierShift = 1u << 0u, ///< Shift key
44 kModifierControl = 1u << 1u, ///< Control key
45 kModifierAlt = 1u << 2u, ///< Alt/Option key
46 kModifierSuper = 1u << 3u ///< Mod4/Command/Windows key
49 /**
50 Keyboard key codepoints.
52 All keys are identified by a Unicode code point in Widget::KeyboardEvent::key.
53 This enumeration defines constants for special keys that do not have a standard
54 code point, and some convenience constants for control characters.
55 Note that all keys are handled in the same way, this enumeration is just for
56 convenience when writing hard-coded key bindings.
58 Keys that do not have a standard code point use values in the Private Use
59 Area in the Basic Multilingual Plane (`U+E000` to `U+F8FF`).
60 Applications must take care to not interpret these values beyond key detection,
61 the mapping used here is arbitrary and specific to DPF.
63 enum Key {
64 // Convenience symbols for ASCII control characters
65 kKeyBackspace = 0x08,
66 kKeyEscape = 0x1B,
67 kKeyDelete = 0x7F,
69 // Backwards compatibility with old DPF
70 kCharBackspace DISTRHO_DEPRECATED_BY("kKeyBackspace") = kKeyBackspace,
71 kCharEscape DISTRHO_DEPRECATED_BY("kKeyEscape") = kKeyEscape,
72 kCharDelete DISTRHO_DEPRECATED_BY("kKeyDelete") = kKeyDelete,
74 // Unicode Private Use Area
75 kKeyF1 = 0xE000,
76 kKeyF2,
77 kKeyF3,
78 kKeyF4,
79 kKeyF5,
80 kKeyF6,
81 kKeyF7,
82 kKeyF8,
83 kKeyF9,
84 kKeyF10,
85 kKeyF11,
86 kKeyF12,
87 kKeyLeft,
88 kKeyUp,
89 kKeyRight,
90 kKeyDown,
91 kKeyPageUp,
92 kKeyPageDown,
93 kKeyHome,
94 kKeyEnd,
95 kKeyInsert,
96 kKeyShift,
97 kKeyShiftL = kKeyShift,
98 kKeyShiftR,
99 kKeyControl,
100 kKeyControlL = kKeyControl,
101 kKeyControlR,
102 kKeyAlt,
103 kKeyAltL = kKeyAlt,
104 kKeyAltR,
105 kKeySuper,
106 kKeySuperL = kKeySuper,
107 kKeySuperR,
108 kKeyMenu,
109 kKeyCapsLock,
110 kKeyScrollLock,
111 kKeyNumLock,
112 kKeyPrintScreen,
113 kKeyPause
117 Common flags for all events.
119 enum EventFlag {
120 kFlagSendEvent = 1, ///< Event is synthetic
121 kFlagIsHint = 2 ///< Event is a hint (not direct user input)
125 Reason for a crossing event.
127 enum CrossingMode {
128 kCrossingNormal, ///< Crossing due to pointer motion
129 kCrossingGrab, ///< Crossing due to a grab
130 kCrossingUngrab ///< Crossing due to a grab release
134 A mouse button.
136 Mouse button numbers start from 1, and are ordered: primary, secondary, middle.
137 So, on a typical right-handed mouse, the button numbers are:
139 Left: 1
140 Right: 2
141 Middle (often a wheel): 3
143 Higher button numbers are reported in the same order they are represented on the system.
144 There is no universal standard here, but buttons 4 and 5 are typically a pair of buttons or a rocker,
145 which are usually bound to "back" and "forward" operations.
147 Note that these numbers may differ from those used on the underlying
148 platform, since they are manipulated to provide a consistent portable API.
150 enum MouseButton {
151 kMouseButtonLeft = 1,
152 kMouseButtonRight,
153 kMouseButtonMiddle,
157 A mouse cursor type.
159 This is a portable subset of mouse cursors that exist on X11, MacOS, and Windows.
161 enum MouseCursor {
162 kMouseCursorArrow, ///< Default pointing arrow
163 kMouseCursorCaret, ///< Caret (I-Beam) for text entry
164 kMouseCursorCrosshair, ///< Cross-hair
165 kMouseCursorHand, ///< Hand with a pointing finger
166 kMouseCursorNotAllowed, ///< Operation not allowed
167 kMouseCursorLeftRight, ///< Left/right arrow for horizontal resize
168 kMouseCursorUpDown, ///< Up/down arrow for vertical resize
169 kMouseCursorDiagonal, ///< Top-left to bottom-right arrow for diagonal resize
170 kMouseCursorAntiDiagonal ///< Bottom-left to top-right arrow for diagonal resize
174 Scroll direction.
176 Describes the direction of a scroll event along with whether the scroll is a "smooth" scroll.
177 The discrete directions are for devices like mouse wheels with constrained axes,
178 while a smooth scroll is for those with arbitrary scroll direction freedom, like some touchpads.
180 enum ScrollDirection {
181 kScrollUp, ///< Scroll up
182 kScrollDown, ///< Scroll down
183 kScrollLeft, ///< Scroll left
184 kScrollRight, ///< Scroll right
185 kScrollSmooth ///< Smooth scroll in any direction
189 A clipboard data offer.
190 @see Window::onClipboardDataOffer
192 struct ClipboardDataOffer {
194 The id of this data offer.
195 @note The value 0 is reserved for null/invalid.
197 uint32_t id;
200 The type of this data offer.
201 Usually a MIME type, but may also be another platform-specific type identifier.
203 const char* type;
206 // --------------------------------------------------------------------------------------------------------------------
207 // Base DGL classes
210 Graphics context, definition depends on build type.
212 struct GraphicsContext {};
215 Idle callback.
217 struct IdleCallback
219 virtual ~IdleCallback() {}
220 virtual void idleCallback() = 0;
223 // --------------------------------------------------------------------------------------------------------------------
225 END_NAMESPACE_DGL
227 #ifndef DONT_SET_USING_DGL_NAMESPACE
228 // If your code uses a lot of DGL classes, then this will obviously save you
229 // a lot of typing, but can be disabled by setting DONT_SET_USING_DGL_NAMESPACE.
230 using namespace DGL_NAMESPACE;
231 #endif
233 // --------------------------------------------------------------------------------------------------------------------
235 #endif // DGL_BASE_HPP_INCLUDED