Skip to content

Commit d505b40

Browse files
committed
move Event (and related classes) to core
1 parent 60a14d6 commit d505b40

File tree

23 files changed

+158
-134
lines changed

23 files changed

+158
-134
lines changed

bin/gf2_tmx_display.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include <gf2/core/ResourceRegistry.h>
1111
#include <gf2/core/RichMapResource.h>
1212
#include <gf2/core/TiledMap.h>
13+
#include <gf2/core/Zoom.h>
1314

1415
#include <gf2/graphics/Entity.h>
1516
#include <gf2/graphics/RenderManager.h>
@@ -18,7 +19,6 @@
1819
#include <gf2/graphics/RichMapRenderer.h>
1920
#include <gf2/graphics/Scene.h>
2021
#include <gf2/graphics/SceneManager.h>
21-
#include <gf2/graphics/Zoom.h>
2222

2323
namespace {
2424
constexpr auto ViewSize = gf::vec(1600, 900);

docs/snippets/graphics_event.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
#include <gf2/graphics/Event.h>
1+
#include <gf2/graphics/Events.h>
22

33
void doc_Event() {
44

55
// tag::loop[]
6-
while (auto event = gf::Event::poll()) {
6+
while (auto event = gf::Events::poll()) {
77
switch (event->type()) {
88
case gf::EventType::Quit:
99
// close the window
@@ -17,7 +17,7 @@ void doc_Event() {
1717
// end::loop[]
1818

1919
// tag::specific[]
20-
while (auto event = gf::Event::poll()) {
20+
while (auto event = gf::Events::poll()) {
2121
switch (event->type()) {
2222
case gf::EventType::Quit:
2323
// close the window

docs/snippets/graphics_window.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <gf2/graphics/Window.h>
2-
#include <gf2/graphics/Event.h>
2+
#include <gf2/graphics/Events.h>
33

44
void doc_Window() {
55

@@ -8,7 +8,7 @@ void doc_Window() {
88

99
while (!window.should_close()) {
1010

11-
while (auto event = gf::Event::poll()) {
11+
while (auto event = gf::Events::poll()) {
1212
switch (event->type()) {
1313
case gf::EventType::Quit:
1414
window.close(); // don't forget this!

examples/19-gridmap.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
// SPDX-License-Identifier: Zlib
22
// Copyright (c) 2023-2025 Julien Bernard
33

4+
#include <gf2/core/ActionGroup.h>
45
#include <gf2/core/Color.h>
56
#include <gf2/core/GridMap.h>
67
#include <gf2/core/Log.h>
78
#include <gf2/core/Range.h>
89
#include <gf2/core/ShapeBuffer.h>
910

10-
#include <gf2/graphics/ActionGroup.h>
1111
#include <gf2/graphics/Entity.h>
1212
#include <gf2/graphics/RenderObject.h>
1313
#include <gf2/graphics/RenderRecorder.h>

games/HOME/bits/SplashScene.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
#ifndef HOME_SPLASH_SCENE_H
22
#define HOME_SPLASH_SCENE_H
33

4+
#include <gf2/core/ActionGroup.h>
45
#include <gf2/core/ResourceBundle.h>
56

6-
#include <gf2/graphics/ActionGroup.h>
77
#include <gf2/graphics/Scene.h>
88
#include <gf2/graphics/SpriteEntity.h>
99
#include <gf2/graphics/TextEntity.h>

games/HOME/bits/WorldScene.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
#ifndef HOME_WORLD_SCENE_H
22
#define HOME_WORLD_SCENE_H
33

4+
#include <gf2/core/ActionGroup.h>
45
#include <gf2/core/ResourceBundle.h>
56

67
#include <gf2/audio/Music.h>
78
#include <gf2/audio/Sound.h>
89
#include <gf2/framework/GraphicsPhysicsDebug.h>
9-
#include <gf2/graphics/ActionGroup.h>
1010
#include <gf2/graphics/Scene.h>
1111
#include <gf2/graphics/TextEntity.h>
1212
#include <gf2/physics/PhysicsWorld.h>

include/gf2/graphics/Action.h renamed to include/gf2/core/Action.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,13 @@
55

66
#include <vector>
77

8-
#include <gf2/core/ActionSettings.h>
9-
8+
#include "ActionSettings.h"
109
#include "Control.h"
11-
#include "GraphicsApi.h"
10+
#include "CoreApi.h"
1211

1312
namespace gf {
1413

15-
class GF_GRAPHICS_API Action {
14+
class GF_CORE_API Action {
1615
public:
1716
Action(ActionType type = ActionType::Instantaneous);
1817
Action(const ActionSettings& settings);

include/gf2/graphics/ActionGroup.h renamed to include/gf2/core/ActionGroup.h

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,14 @@
55

66
#include <string_view>
77

8-
#include <gf2/core/ActionSettings.h>
9-
#include <gf2/core/Id.h>
10-
118
#include "Action.h"
12-
#include "GraphicsApi.h"
9+
#include "ActionSettings.h"
10+
#include "CoreApi.h"
11+
#include "Id.h"
1312

1413
namespace gf {
1514

16-
class GF_GRAPHICS_API ActionGroup {
15+
class GF_CORE_API ActionGroup {
1716
public:
1817
ActionGroup() = default;
1918
ActionGroup(const ActionGroupSettings& settings);

include/gf2/graphics/Control.h renamed to include/gf2/core/Control.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,13 @@
33
#ifndef GF_CONTROL_H
44
#define GF_CONTROL_H
55

6-
#include <gf2/core/ControlSettings.h>
7-
6+
#include "ControlSettings.h"
7+
#include "CoreApi.h"
88
#include "Event.h"
9-
#include "GraphicsApi.h"
109

1110
namespace gf {
1211

13-
class GF_GRAPHICS_API Control {
12+
class GF_CORE_API Control {
1413
public:
1514
Control(const ControlSettings& settings);
1615

include/gf2/graphics/Event.h renamed to include/gf2/core/Event.h

Lines changed: 35 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
#include <gf2/core/TouchTypes.h>
1818
#include <gf2/core/Vec2.h>
1919

20-
#include "GraphicsApi.h"
20+
#include "CoreApi.h"
2121

2222
namespace gf {
2323

@@ -66,166 +66,166 @@ namespace gf {
6666
};
6767

6868
// clang-format off
69-
struct GF_GRAPHICS_API QuitEvent {
69+
struct GF_CORE_API QuitEvent {
7070
};
7171
// clang-format on
7272

73-
struct GF_GRAPHICS_API WindowShownEvent {
73+
struct GF_CORE_API WindowShownEvent {
7474
uint32_t window_id;
7575
};
7676

77-
struct GF_GRAPHICS_API WindowHiddenEvent {
77+
struct GF_CORE_API WindowHiddenEvent {
7878
uint32_t window_id;
7979
};
8080

81-
struct GF_GRAPHICS_API WindowExposedEvent {
81+
struct GF_CORE_API WindowExposedEvent {
8282
uint32_t window_id;
8383
};
8484

85-
struct GF_GRAPHICS_API WindowMovedEvent {
85+
struct GF_CORE_API WindowMovedEvent {
8686
uint32_t window_id;
8787
Vec2I position;
8888
};
8989

90-
struct GF_GRAPHICS_API WindowResizedEvent {
90+
struct GF_CORE_API WindowResizedEvent {
9191
uint32_t window_id;
9292
Vec2I size;
9393
};
9494

95-
// struct GF_GRAPHICS_API WindowPixelSizeChangedEvent {
95+
// struct GF_CORE_API WindowPixelSizeChangedEvent {
9696
// uint32_t window_id;
9797
// Vec2I size;
9898
// };
9999

100-
struct GF_GRAPHICS_API WindowMinimizedEvent {
100+
struct GF_CORE_API WindowMinimizedEvent {
101101
uint32_t window_id;
102102
};
103103

104-
struct GF_GRAPHICS_API WindowMaximizedEvent {
104+
struct GF_CORE_API WindowMaximizedEvent {
105105
uint32_t window_id;
106106
};
107107

108-
struct GF_GRAPHICS_API WindowRestoredEvent {
108+
struct GF_CORE_API WindowRestoredEvent {
109109
uint32_t window_id;
110110
};
111111

112-
struct GF_GRAPHICS_API MouseFocusGainedEvent {
112+
struct GF_CORE_API MouseFocusGainedEvent {
113113
uint32_t window_id;
114114
};
115115

116-
struct GF_GRAPHICS_API MouseFocusLostEvent {
116+
struct GF_CORE_API MouseFocusLostEvent {
117117
uint32_t window_id;
118118
};
119119

120-
struct GF_GRAPHICS_API KeyboardFocusGainedEvent {
120+
struct GF_CORE_API KeyboardFocusGainedEvent {
121121
uint32_t window_id;
122122
};
123123

124-
struct GF_GRAPHICS_API KeyboardFocusLostEvent {
124+
struct GF_CORE_API KeyboardFocusLostEvent {
125125
uint32_t window_id;
126126
};
127127

128-
struct GF_GRAPHICS_API WindowCloseRequestedEvent {
128+
struct GF_CORE_API WindowCloseRequestedEvent {
129129
uint32_t window_id;
130130
};
131131

132-
struct GF_GRAPHICS_API KeyPressedEvent {
132+
struct GF_CORE_API KeyPressedEvent {
133133
uint32_t window_id;
134134
Keycode keycode;
135135
Scancode scancode;
136136
Flags<Modifier> modifiers;
137137
};
138138

139-
struct GF_GRAPHICS_API KeyRepeatedEvent {
139+
struct GF_CORE_API KeyRepeatedEvent {
140140
uint32_t window_id;
141141
Keycode keycode;
142142
Scancode scancode;
143143
Flags<Modifier> modifiers;
144144
uint8_t repeat;
145145
};
146146

147-
struct GF_GRAPHICS_API KeyReleasedEvent {
147+
struct GF_CORE_API KeyReleasedEvent {
148148
uint32_t window_id;
149149
Keycode keycode;
150150
Scancode scancode;
151151
Flags<Modifier> modifiers;
152152
};
153153

154-
// struct GF_GRAPHICS_API TextEditedEvent {
154+
// struct GF_CORE_API TextEditedEvent {
155155
// uint32_t window_id;
156156
// std::string_view text;
157157
// int32_t start;
158158
// int32_t length;
159159
// };
160160

161-
struct GF_GRAPHICS_API TextEnteredEvent {
161+
struct GF_CORE_API TextEnteredEvent {
162162
uint32_t window_id;
163163
std::array<char, 32> text; // TODO: SDL3: changed to a std::string_view
164164
};
165165

166-
// struct GF_GRAPHICS_API TextCandidatesShownEvent {
166+
// struct GF_CORE_API TextCandidatesShownEvent {
167167
// uint32_t window_id;
168168
// std::array<std::string_view, 10> candidates;
169169
// int32_t count;
170170
// int32_t selected;
171171
// bool horizontal;
172172
// };
173173

174-
struct GF_GRAPHICS_API MouseMovedEvent {
174+
struct GF_CORE_API MouseMovedEvent {
175175
uint32_t window_id;
176176
MouseId mouse_id;
177177
Vec2I position;
178178
Vec2I motion;
179179
};
180180

181-
struct GF_GRAPHICS_API MouseButtonPressedEvent {
181+
struct GF_CORE_API MouseButtonPressedEvent {
182182
uint32_t window_id;
183183
MouseId mouse_id;
184184
MouseButton button;
185185
Vec2I position;
186186
uint8_t clicks;
187187
};
188188

189-
struct GF_GRAPHICS_API MouseButtonReleasedEvent {
189+
struct GF_CORE_API MouseButtonReleasedEvent {
190190
uint32_t window_id;
191191
MouseId mouse_id;
192192
MouseButton button;
193193
Vec2I position;
194194
uint8_t clicks;
195195
};
196196

197-
struct GF_GRAPHICS_API MouseWheelScrolledEvent {
197+
struct GF_CORE_API MouseWheelScrolledEvent {
198198
uint32_t window_id;
199199
MouseId mouse_id;
200200
Vec2I offset;
201201
MouseWheelDirection direction;
202202
};
203203

204-
struct GF_GRAPHICS_API GamepadAxisMovedEvent {
204+
struct GF_CORE_API GamepadAxisMovedEvent {
205205
GamepadId gamepad_id;
206206
GamepadAxis axis;
207207
int16_t value;
208208
};
209209

210-
struct GF_GRAPHICS_API GamepadButtonPressedEvent {
210+
struct GF_CORE_API GamepadButtonPressedEvent {
211211
GamepadId gamepad_id;
212212
GamepadButton button;
213213
};
214214

215-
struct GF_GRAPHICS_API GamepadButtonReleasedEvent {
215+
struct GF_CORE_API GamepadButtonReleasedEvent {
216216
GamepadId gamepad_id;
217217
GamepadButton button;
218218
};
219219

220-
struct GF_GRAPHICS_API GamepadConnectedEvent {
220+
struct GF_CORE_API GamepadConnectedEvent {
221221
GamepadHwId gamepad_hw_id;
222222
};
223223

224-
struct GF_GRAPHICS_API GamepadDisconnectedEvent {
224+
struct GF_CORE_API GamepadDisconnectedEvent {
225225
GamepadId gamepad_id;
226226
};
227227

228-
struct GF_GRAPHICS_API TouchPressedEvent {
228+
struct GF_CORE_API TouchPressedEvent {
229229
uint32_t window_id;
230230
TouchId touch_id;
231231
FingerId finger;
@@ -234,7 +234,7 @@ namespace gf {
234234
float pressure;
235235
};
236236

237-
struct GF_GRAPHICS_API TouchReleasedEvent {
237+
struct GF_CORE_API TouchReleasedEvent {
238238
uint32_t window_id;
239239
TouchId touch_id;
240240
FingerId finger;
@@ -243,7 +243,7 @@ namespace gf {
243243
float pressure;
244244
};
245245

246-
struct GF_GRAPHICS_API TouchMovedEvent {
246+
struct GF_CORE_API TouchMovedEvent {
247247
uint32_t window_id;
248248
TouchId touch_id;
249249
FingerId finger;
@@ -252,7 +252,7 @@ namespace gf {
252252
float pressure;
253253
};
254254

255-
class GF_GRAPHICS_API Event {
255+
class GF_CORE_API Event {
256256
public:
257257
constexpr Event() = default;
258258

@@ -303,9 +303,6 @@ namespace gf {
303303
return std::get<static_cast<std::size_t>(E)>(m_data);
304304
}
305305

306-
static std::optional<Event> poll();
307-
static Event wait();
308-
309306
private:
310307
uint64_t m_timestamp = 0;
311308

0 commit comments

Comments
 (0)