6 #include <unordered_map>
7 #include <entity/Viewport.h>
19 namespace chira::Device {
23 POPUP_ERROR = 0x00000010,
24 POPUP_WARNING = 0x00000020,
25 POPUP_INFO = 0x00000040,
26 POPUP_BUTTONS_LEFT_TO_RIGHT = 0x00000080,
27 POPUP_BUTTONS_RIGHT_TO_LEFT = 0x00000100,
31 std::unordered_map<uuids::uuid, IPanel*> panels{};
32 SDL_Window* window =
nullptr;
33 ImGuiContext* imguiContext =
nullptr;
37 bool mouseCaptured =
false;
38 bool shouldClose =
false;
40 Viewport* viewport =
nullptr;
41 bool viewportIsSelfOwned =
false;
43 explicit inline operator bool()
const {
return window; }
44 inline bool operator!()
const {
return !window; }
47 [[nodiscard]]
bool initBackendAndCreateSplashscreen(
bool splashScreenVisible);
48 void destroySplashscreen();
49 void destroyBackend();
51 [[nodiscard]] std::uint64_t getTicks();
54 [[nodiscard]] WindowHandle* createWindow(
int width,
int height, std::string_view title, Viewport* viewport);
55 void refreshWindows();
56 [[nodiscard]]
int getWindowCount();
58 [[nodiscard]] Viewport* getWindowViewport(WindowHandle* handle);
60 void setWindowTitle(WindowHandle* handle, std::string_view title);
61 [[nodiscard]] std::string_view getWindowTitle(WindowHandle* handle);
63 void setWindowMaximized(WindowHandle* handle,
bool maximize);
64 [[nodiscard]]
bool isWindowMaximized(WindowHandle* handle);
66 void minimizeWindow(WindowHandle* handle,
bool minimize);
67 [[nodiscard]]
bool isWindowMinimized(WindowHandle* handle);
69 void setWindowFullscreen(WindowHandle* handle,
bool fullscreen);
70 [[nodiscard]]
bool isWindowFullscreen(WindowHandle* handle);
72 void setWindowVisibility(WindowHandle* handle,
bool visible);
73 [[nodiscard]]
bool isWindowVisible(WindowHandle* handle);
75 void setWindowSize(WindowHandle* handle,
int width,
int height);
76 [[nodiscard]] glm::vec2i getWindowSize(WindowHandle* handle);
78 void setWindowPosition(WindowHandle* handle,
int width,
int height);
79 void setWindowPositionFromCenter(WindowHandle* handle,
int width,
int height);
80 [[nodiscard]] glm::vec2i getWindowPosition(WindowHandle* handle);
82 void setMousePositionGlobal(
int x,
int y);
83 void setMousePositionInWindow(WindowHandle* handle,
int x,
int y);
84 [[nodiscard]] glm::vec2i getMousePositionGlobal();
85 [[nodiscard]] glm::vec2i getMousePositionInFocusedWindow();
87 void setMouseCapturedWindow(WindowHandle* handle,
bool captured);
88 [[nodiscard]]
bool isMouseCapturedWindow(WindowHandle* handle);
91 void queueDestroyWindow(WindowHandle* handle,
bool free);
92 [[nodiscard]]
bool isWindowAboutToBeDestroyed(WindowHandle* handle);
93 void destroyWindow(WindowHandle* handle);
94 void destroyAllWindows();
96 uuids::uuid addPanelToWindow(WindowHandle* handle, IPanel* panel);
97 [[nodiscard]] IPanel* getPanelOnWindow(WindowHandle* handle,
const uuids::uuid& panelID);
98 void removePanelFromWindow(WindowHandle* handle,
const uuids::uuid& panelID);
99 void removeAllPanelsFromWindow(WindowHandle* handle);
102 void popup(std::string_view message, std::string_view title,
unsigned int popupFlags, std::string_view ok =
"OK");
104 void popupInfo(std::string_view message, std::string_view title =
"Info");
106 void popupWarning(std::string_view message, std::string_view title =
"Warning");
108 void popupError(std::string_view message, std::string_view title =
"Error");
111 bool popupChoice(std::string_view message, std::string_view title,
unsigned int popupFlags, std::string_view ok =
"OK", std::string_view cancel =
"Cancel");
114 bool popupInfoChoice(std::string_view message, std::string_view title =
"Info");
117 bool popupWarningChoice(std::string_view message, std::string_view title =
"Warning");
120 bool popupErrorChoice(std::string_view message, std::string_view title =
"Error");