PixelBullet  0.0.1
A C++ game engine
Loading...
Searching...
No Matches
callback_adapter_internal.h
1#ifndef PIXELBULLET_WINDOW_INTERNAL_CALLBACK_ADAPTER_INTERNAL_H_
2#define PIXELBULLET_WINDOW_INTERNAL_CALLBACK_ADAPTER_INTERNAL_H_
3
4#include "pixelbullet/core/event.h"
5#include "pixelbullet/input/input.h"
6
7#include <cstdint>
8#include <functional>
9
10#include <glm/glm.hpp>
11
12namespace pixelbullet::window_internal
13{
15{
16 std::uint32_t move_callback_count = 0;
17 std::uint32_t resize_callback_count = 0;
18 std::uint32_t focus_callback_count = 0;
19
20 [[nodiscard]] constexpr bool HasPlatformActivity() const noexcept
21 {
22 return move_callback_count != 0 || resize_callback_count != 0 || focus_callback_count != 0;
23 }
24};
25
27{
28public:
29 struct State
30 {
31 unsigned int& width;
32 unsigned int& height;
33 glm::ivec2& position;
34 bool& focused;
35 bool& fullscreen;
36 glm::ivec2& size;
37 glm::ivec2& fullscreen_size;
38 glm::vec2& content_scale;
39 uint32_t window_id;
41 const std::function<void(pixelbullet::core::Event&)>& event_callback;
42 const std::function<void(uint32_t)>& framebuffer_resize_callback;
43 WindowFrameActivity* frame_activity = nullptr;
44 };
45
46 enum class KeyAction
47 {
48 Press,
49 Release,
50 Repeat
51 };
52
53 enum class MouseButtonAction
54 {
55 Press,
56 Release
57 };
58
59 static void HandleWindowSize(State state, int width, int height);
60 static void HandleWindowClose(State state);
61 static void HandleKeyAction(State state, pixelbullet::input::KeyCode key_code, KeyAction action);
62 static void HandleTextInput(State state, char32_t codepoint);
63 static void HandleMouseButtonAction(State state, pixelbullet::input::MouseCode button, MouseButtonAction action);
64 static void HandleMouseScroll(State state, float x_offset, float y_offset);
65 static void HandleCursorPosition(State state, float x_pos, float y_pos);
66 static void HandleFramebufferSize(State state, int width, int height);
67 static void HandleContentScale(State state, float x_scale, float y_scale);
68 static void HandleFocusChanged(State state, bool focused);
69 static void HandleWindowMoved(State state, int x, int y);
70};
71} // namespace pixelbullet::window_internal
72
73#endif // PIXELBULLET_WINDOW_INTERNAL_CALLBACK_ADAPTER_INTERNAL_H_
Definition event.h:108
Definition callback_adapter_internal.h:27
Definition input.h:20
Definition callback_adapter_internal.h:15