载入中...
搜索中...
未找到
Window.h
浏览该文件的文档.
1#pragma once
2
3#include <cstdint>
4#include <string>
5#include <vector>
6
7#include "common/Export.h"
8#include "common/Module.h"
9
10namespace eve {
11
12namespace window {
13
19 float refreshrate = 0.0;
20 float dpi_scale = 1.0;
21 int32_t x = 0;
22 int32_t y = 0;
23 uint16_t width = 1366;
24 uint16_t height = 768;
25 uint16_t minwidth = 1;
26 uint16_t minheight = 1;
27 uint8_t vsync = 1;
28 uint8_t msaa = 0;
29 uint8_t depth = 0;
30 uint8_t display = 0;
31 bool borderless = false;
32 bool centered = true;
33 bool high_dpi = true;
34 bool use_dpi_scale = true;
35 bool use_position = false;
36 bool fullscreen = false;
37 bool desktop_mode = true;
38 bool stencil = true;
39 bool resizable = false;
40 bool always_on_top = false;
41};
42
48public:
50
52 struct WindowSize {
53 int width = 0;
54 int height = 0;
55
57 bool operator==(const WindowSize& w) const { return w.width == width && w.height == height; }
58 };
59
62 std::string type = "info";
63 std::string title;
64 std::string message;
65 int enterButtonIndex = 0;
66 int escapeButtonIndex = 0;
67 bool attachToWindow = false;
68 std::vector<std::string> buttons;
69 };
70
72 virtual ~Window() {}
73
75 virtual void setSize(int width, int height) = 0;
77 virtual int getWidth() const = 0;
79 virtual int getHeight() const = 0;
80
85
87 virtual void close() = 0;
88
90 virtual bool setFullscreenDesktop(bool fullscreen) = 0;
92 virtual bool setFullscreenExclusive(bool fullscreen) = 0;
93
95 virtual bool isOpen() const = 0;
96
98 virtual void setWindowTitle(const std::string& title) = 0;
100 virtual const std::string& getWindowTitle() const = 0;
102 virtual void setPosition(int x, int y, int display) = 0;
104 virtual void getPosition(int& x, int& y, int& display) = 0;
106 virtual void minimize() = 0;
108 virtual void maximize() = 0;
110 virtual void restore() = 0;
112 virtual bool isMaximized() const = 0;
114 virtual bool isMinimized() const = 0;
116 virtual bool hasFocus() const = 0;
118 virtual bool hasMouseFocus() const = 0;
120 virtual bool isVisible() const = 0;
122 virtual void setVSync(int vsync) = 0;
124 virtual int getVSync() const = 0;
125
127 virtual int getPixelWidth() const = 0;
129 virtual int getPixelHeight() const = 0;
131 virtual double getDPIScale() const = 0;
133 virtual double getNativeDPIScale() const = 0;
135 virtual void windowToPixelCoords(double* x, double* y) const = 0;
137 virtual void pixelToWindowCoords(double* x, double* y) const = 0;
139 virtual void windowToDPICoords(double* x, double* y) const = 0;
141 virtual void DPIToWindowCoords(double* x, double* y) const = 0;
143 virtual double toPixels(double x) const = 0;
145 virtual double fromPixels(double x) const = 0;
147 virtual void toPixelsXY(double wx, double wy, double& px, double& py) const = 0;
149 virtual void fromPixelsXY(double px, double py, double& wx, double& wy) const = 0;
150
152 virtual void *getHandle() const = 0;
153
155 virtual int getDisplayCount() const = 0;
157 virtual std::string getDisplayName(int display) const = 0;
159 virtual std::string getDisplayOrientation(int display) const = 0;
161 virtual std::vector<WindowSize> getFullscreenSizes(int display) const = 0;
163 virtual void getDesktopDimensions(int display, int& width, int& height) const = 0;
164
166 virtual bool showMessageBox(const std::string& title, const std::string& message,
167 const std::string& type, bool attachToWindow) = 0;
169 virtual int showMessageBoxData(const MessageBoxData& data) = 0;
171 virtual void requestAttention(bool continuous) = 0;
172
174 virtual bool setIconRGBA(const uint8_t* rgba, int width, int height) = 0;
175
176 // --- not yet implemented (kept as drafts) ---
177
178 // virtual bool onSizeChanged(int width, int height) = 0;
179
180 // virtual Rect getSafeArea() const = 0;
181
182 // virtual void setDisplaySleepEnabled(bool enable) = 0;
183 // virtual bool isDisplaySleepEnabled() const = 0;
184
185 // // default no-op implementation
186 // virtual void swapBuffers();
187
188 // virtual void setMouseGrab(bool grab) = 0;
189 // virtual bool isMouseGrabbed() const = 0;
190
191}; // Window
192
193} // namespace window
194} // namespace eve
float w
Definition AnimClip.cpp:738
float y
Definition AnimClip.cpp:738
float x
Definition AnimClip.cpp:738
float py
std::string title
#define EVENGINE_API_PLATFORM
Definition Export.h:107
std::string message
std::vector< Colorf > px
std::uint32_t height
std::uint32_t width
TerrainThermalSettings settings
float wx
float wy
EVENGINE_API_FOUNDATION public API.
Definition Module.h:46
Platform window interface (SDL implementation on desktop/mobile). Script: win <- eve....
Definition Window.h:47
virtual void setVSync(int vsync)=0
Enables/disables vertical sync (0 = off, 1 = on).
virtual int getDisplayCount() const =0
Number of displays attached to the system.
virtual int showMessageBoxData(const MessageBoxData &data)=0
Shows a configurable message box; returns the pressed button index.
virtual bool setFullscreenDesktop(bool fullscreen)=0
Switches between desktop fullscreen and windowed mode.
virtual void maximize()=0
Maximizes the window.
virtual double getNativeDPIScale() const =0
Native DPI scale reported by the OS for this window.
virtual bool hasFocus() const =0
True when the window has keyboard focus.
virtual bool isMinimized() const =0
True when the window is minimized.
virtual ~Window()
Releases the native window and related resources.
Definition Window.h:72
virtual void restore()=0
Restores from minimized/maximized state.
virtual void toPixelsXY(double wx, double wy, double &px, double &py) const =0
Converts a logical XY pair to framebuffer pixels.
virtual std::string getDisplayName(int display) const =0
Human-readable display name for a display index.
virtual bool showMessageBox(const std::string &title, const std::string &message, const std::string &type, bool attachToWindow)=0
Shows a modal message box ("info", "warning", or "error").
virtual bool isVisible() const =0
True when the window is visible (not hidden).
virtual std::vector< WindowSize > getFullscreenSizes(int display) const =0
Fullscreen sizes supported by a display.
virtual bool setFullscreenExclusive(bool fullscreen)=0
Switches between exclusive fullscreen and windowed mode.
virtual void setWindowTitle(const std::string &title)=0
Sets the window title shown in the OS title bar.
virtual void windowToDPICoords(double *x, double *y) const =0
Converts window logical coordinates to UI-DPI coordinates.
virtual const std::string & getWindowTitle() const =0
Current title string.
virtual bool setIconRGBA(const uint8_t *rgba, int width, int height)=0
Sets the window icon from tightly packed RGBA8 pixels (w*h*4 bytes).
virtual bool isOpen() const =0
True while the native window exists and has not been closed.
virtual bool hasMouseFocus() const =0
True when the window has mouse focus.
virtual void getDesktopDimensions(int display, int &width, int &height) const =0
Desktop resolution of a display.
virtual int getWidth() const =0
Current logical window width.
virtual void minimize()=0
Minimizes the window.
virtual double getDPIScale() const =0
Current UI/logical DPI scale (1.0 on non-retina displays).
virtual void windowToPixelCoords(double *x, double *y) const =0
Converts window logical coordinates to framebuffer pixel coordinates.
virtual bool setWindowSettings(WindowSettings settings)=0
Applies a full WindowSettings struct (recreates the window when needed).
virtual void requestAttention(bool continuous)=0
Requests OS attention (flashing taskbar); continuous repeats until focused.
virtual double toPixels(double x) const =0
Scales a logical length to UI pixels.
virtual void DPIToWindowCoords(double *x, double *y) const =0
Converts UI-DPI coordinates to window logical coordinates.
virtual std::string getDisplayOrientation(int display) const =0
Display orientation string (e.g. "landscape").
virtual bool isMaximized() const =0
True when the window is maximized.
virtual void close()=0
Closes and destroys the underlying window.
virtual void pixelToWindowCoords(double *x, double *y) const =0
Converts framebuffer pixel coordinates to window logical coordinates.
virtual double fromPixels(double x) const =0
Scales a UI-pixel length back to logical units.
virtual void getPosition(int &x, int &y, int &display)=0
Reads the current window position and display index.
virtual WindowSettings getWindowSettings()=0
Returns the settings last applied to this window.
virtual void setPosition(int x, int y, int display)=0
Moves the window to a position in logical units on the given display.
virtual int getHeight() const =0
Current logical window height.
virtual int getPixelWidth() const =0
Framebuffer (pixel) width of the window.
virtual void * getHandle() const =0
Native window handle (SDL_Window* on SDL backend).
virtual void setSize(int width, int height)=0
Requests a new logical window size.
virtual void fromPixelsXY(double px, double py, double &wx, double &wy) const =0
Converts a framebuffer pixel XY pair to logical coordinates.
virtual int getVSync() const =0
Current vsync setting (0 = off, 1 = on).
virtual int getPixelHeight() const =0
Framebuffer (pixel) height of the window.
WidgetDesc window(std::string title, std::vector< WidgetDesc > children, std::string id)
Top-level window widget with a title bar.
Definition Widget.cpp:292
Build metadata (engine git commit, build time, third-party version).
Definition Build.cpp:16
Display settings for window creation/resize. width/height == 0 selects the desktop display mode size.
Definition Window.h:18
Parameters for a multi-button modal message box.
Definition Window.h:61
std::vector< std::string > buttons
Definition Window.h:68
Logical width/height pair used by fullscreen size queries.
Definition Window.h:52
bool operator==(const WindowSize &w) const
True when both dimensions match.
Definition Window.h:57