97 virtual bool ReadPixels(std::span<uint8_t> ) {
return false; }
A graphics backend: the device, the window contexts that render the GUI's windows,...
Definition gui_graphics_context.h:60
virtual OSWindowHandle CreateWindow(std::string_view title, int2 size, WindowFlags windowFlags, OSWindowHandle parentOSHandle)=0
Creates a window whose client area is size pixels, placed by the OS.
virtual bool SetWindowRect(OSWindowHandle, const IntRect &clientRect)=0
Moves and resizes the window so its client area is clientRect (screen pixels); the backend accounts f...
virtual IWindowContext * GetWindowContext(OSWindowHandle)=0
The context attached with AttachContextToWindow, or nullptr.
virtual IntRect GetWindowRect(OSWindowHandle)=0
Client area in pixels; {0,0,0,0} while minimized.
virtual IntRect GetWindowPixelRect(OSWindowHandle window)=0
The window's render target: OS position (for OS compositing) and size in physical pixels.
virtual void BringToFront(OSWindowHandle)=0
Raises the window above the others and asks the OS for the input focus.
virtual uint32_t ShowFade(OSWindowHandle, IWindowContext *, IntRect, float)
A layered stand-in for window showing what context drew last, at screenRect (screen pixels) and opaci...
Definition gui_window_backend.h:214
virtual void DetachWindowContext(OSWindowHandle)=0
Clears the context pointer stored in the OS window, so PollEvents' cleanup callback gets nullptr inst...
virtual void PollEvents(std::function< void(OSWindowHandle, IWindowContext *)> cleanup)=0
Handles the OS's pending events, delivering input to the attached handlers.
virtual std::vector< MonitorInfo > GetMonitors() const =0
Every monitor, the primary first.
virtual bool IsWindow(OSWindowHandle)=0
True while the handle is a live window of this backend; false once it was destroyed (by code or the u...
virtual bool DestroyWindow(OSWindowHandle)=0
Queues the window for destruction: the next PollEvents passes its context to cleanup,...
virtual int2 GetWindowSize(OSWindowHandle)=0
The client area's size in pixels; {0,0} while minimized.
virtual void * GetNativeHandle(OSWindowHandle)=0
The OS's own window handle, passed to GraphicsContext::CreateWindowContext (HWND on Windows,...
virtual int GetMonitorAt(int2 pos) const =0
Index into GetMonitors of the monitor holding the screen point pos; 0 (the primary) when no monitor h...
virtual void SetTextInputArea(OSWindowHandle window, IntRect rect)=0
Where text is being typed in the window (window coordinates), so the IME places its candidate list ne...
virtual void SetGraphicsContext(GraphicsContext *graphicsContext)
The graphics context the windows are made for and painted with (during an OS live resize).
Definition gui_window_backend.h:247
virtual void AttachInputHandlerToWindow(OSWindowHandle window, IPlatformInputHandler *inputHandler)=0
Where the window's input goes (see IPlatformInputHandler); not owned, nullptr for none.
virtual ~IWindowBackend()
Definition gui_window_backend.h:109
virtual float GetDoubleClickMilliseconds()
The OS's double-click time in milliseconds, or 0 where the platform has none.
Definition gui_window_backend.h:159
virtual OSWindowHandle GetActiveWindow()=0
The window with the keyboard focus, or nullptr when none of the backend's windows has it.
virtual void EndFade(uint32_t)
Removes a stand-in.
Definition gui_window_backend.h:218
virtual int GetMonitorFromWindow(OSWindowHandle handle) const =0
Index into GetMonitors of the window's monitor; -1 for an unknown window.
virtual OSWindowHandle GetWindowUnderMouse()=0
The backend's window under the mouse, or nullptr.
virtual uint32_t GetTicks() const =0
A millisecond clock (SDL: since SDL started).
std::function< WindowHitArea(OSWindowHandle, int2)> m_hitTest
Set by SetHitTestCallback; a backend asks it through HitTestWindow.
Definition gui_window_backend.h:267
virtual void SetWindowMode(OSWindowHandle, WindowMode)
Sets the window's state: minimized, maximized, restored or fullscreen.
Definition gui_window_backend.h:233
virtual bool TakeCloseRequest(OSWindowHandle)
Whether the OS asked to close a WindowFlags::ConfirmClose window since last asked.
Definition gui_window_backend.h:167
virtual int2 GetScreenMousePos()=0
The mouse position in screen pixels (SDL: as of the last PollEvents).
virtual MouseButtons GetMouseButtons()=0
The mouse buttons held down, wherever the mouse is (SDL: as of the last PollEvents).
IWindowBackend()
Definition gui_window_backend.h:107
virtual void SetWindowVisible(OSWindowHandle, bool visible)=0
Shows or hides the window; hiding doesn't destroy it.
virtual std::optional< color4b > ReadScreenPixel(int2)
The color of a screen pixel, anywhere on the desktop (an eyedropper); nothing where the platform can'...
Definition gui_window_backend.h:165
virtual uint32_t GetFocusChangeCount() const =0
Goes up whenever keyboard focus moves between windows, or to or from another application; open popups...
virtual void MoveFade(uint32_t, IntRect, float)
Moves a stand-in and sets its opacity.
Definition gui_window_backend.h:216
virtual bool SetWindowCloaked(OSWindowHandle, bool)
Cloaks a shown window: it takes frames but stays invisible, so it can be drawn before it appears.
Definition gui_window_backend.h:208
virtual void AttachContextToWindow(OSWindowHandle window, IWindowContext *context)=0
Stores the window's context (not owned), for GetWindowContext, for the ID passed with the window's in...
GraphicsContext * m_graphicsContext
Set by SetGraphicsContext; not owned.
Definition gui_window_backend.h:269
virtual OSWindowHandle CreateWindow(std::string_view title, IntRect rect, WindowFlags windowFlags, OSWindowHandle parentOSHandle)=0
Creates a window whose client area is rect (screen pixels); otherwise as the size overload.
virtual bool PrefersReducedMotion()
Whether the OS asks for less motion (animations turned off); false where the platform has no such set...
Definition gui_window_backend.h:162
void SetWindowMovedCallback(std::function< void()> cb)
Sets cb, called as soon as any window moves or resizes, even inside the OS modal move / resize loop (...
Definition gui_window_backend.h:251
virtual void SwapBuffers(OSWindowHandle)=0
Presents for a graphics API that swaps through the window (OpenGL).
virtual void SetCursor(MouseCursor cursor)=0
Shows the system cursor for that shape; MouseCursor::None hides the cursor.
virtual float GetWindowDisplayScale(OSWindowHandle window)=0
The UI scale the OS asks for in this window: pixel density times the monitor's content scale (1....
std::function< void()> m_onWindowMoved
Set by SetWindowMovedCallback; a backend calls it when a window moves or resizes.
Definition gui_window_backend.h:265
virtual std::string GetPreferredLanguage() const
The user's preferred language as a BCP 47 tag ("ja", "en-US"), or empty when the platform doesn't say...
Definition gui_window_backend.h:239
void SetHitTestCallback(std::function< WindowHitArea(OSWindowHandle, int2 screenPos)> cb)
Classifies points (screen pixels) of CustomTitleBar windows for the OS.
Definition gui_window_backend.h:255
virtual WindowMode GetWindowMode(OSWindowHandle) const
The window's state as the OS has it now; WindowMode::Normal by default.
Definition gui_window_backend.h:235
virtual int2 GetWindowPos(OSWindowHandle)=0
The client area's top-left in screen pixels.
virtual int32_t GetCursorSize() const
The OS mouse cursor's size in pixels (its accessibility size at the display's scale),...
Definition gui_window_backend.h:243
WindowHitArea HitTestWindow(OSWindowHandle window, int2 screenPos) const
What a point (screen pixels) of the window is, from the hit-test callback; WindowHitArea::Client with...
Definition gui_window_backend.h:258
A window's rendering state: made by GraphicsContext::CreateWindowContext for each OS window,...
Definition gui_window_backend.h:72
virtual void PresentWindowFrame()
May wait for vsync; nothing to do for a render-to-image window.
Definition gui_window_backend.h:90
virtual bool IsTransparent() const =0
Whether the window has WindowFlags::Transparent.
virtual OSWindowHandle GetWindowHandle() const =0
The window it was created for.
virtual bool ReadPixels(std::span< uint8_t >)
The last rendered frame, BGRA8 with tightly packed rows; bgra holds width x height x 4 bytes of the w...
Definition gui_window_backend.h:97
virtual void RenderWindowFrame(tachyon::GraphicsContext *graphicsContext, tachyon::IntRect rect, bool resizing)=0
A frame is recorded (drawn and submitted), then presented.
virtual ID GetID() const =0
The GUI window's ID; the backend passes it with the window's input.
virtual ~IWindowContext()=default
virtual void RecordWindowFrame(tachyon::GraphicsContext *graphicsContext, tachyon::IntRect rect)
Records and submits a frame without presenting it; PresentWindowFrame presents.
Definition gui_window_backend.h:88
virtual void UpdateTransparentWindow(int2)
A transparent window the OS composites from a CPU copy (a layered window on Windows): shows its last ...
Definition gui_window_backend.h:93
MouseCursor
Mouse cursor shown over an element (CSS: cursor).
Definition gui_style.h:478
@ Normal
Normal (400); the zero-initialized default.
Definition gui_style_text.h:116
WindowFlags
How an OS window is made and behaves (IWindowBackend::CreateWindow); flags combine with |.
Definition gui_window_flags.h:12
WindowMode
A window's state (IWindowBackend::SetWindowMode). Any window can go fullscreen.
Definition gui_window_backend.h:60
WindowHitArea
What a point of a window with a custom title bar (WindowFlags::CustomTitleBar) is to the OS.
Definition gui_window_backend.h:52
void * OSWindowHandle
An OS window, opaque; what it points to is up to the window backend.
Definition gui_window_backend.h:37
@ Minimized
Definition gui_window_backend.h:62
@ Fullscreen
borderless, covering its monitor at the desktop resolution
Definition gui_window_backend.h:64
@ Maximized
Definition gui_window_backend.h:63
@ ExclusiveFullscreen
takes the monitor over, in its desktop display mode
Definition gui_window_backend.h:65
@ Normal
as placed (restored)
Definition gui_window_backend.h:61
@ Caption
drags the window; a double-click maximizes it
Definition gui_window_backend.h:54
@ Client
the GUI handles it
Definition gui_window_backend.h:53
@ MaximizeButton
the GUI's maximize button, so the OS can offer its snap layouts
Definition gui_window_backend.h:55
Definition gui_logging.h:24
A 64-bit element ID whose bit layout depends on its IDMode.
Definition gui_id.h:23
Definition gui_base_types.h:407
Window, monitor and mouse coordinates are physical pixels.
Definition gui_window_backend.h:42
float refreshRate
Hz; 0 when unknown.
Definition gui_window_backend.h:47
float contentScale
UI scale the user chose for this monitor (1.0 = 100%).
Definition gui_window_backend.h:46
IntRect workArea
Usable area (excludes taskbar/dock).
Definition gui_window_backend.h:44
bool isPrimary
The OS's main monitor.
Definition gui_window_backend.h:45
IntRect rect
Full monitor bounds (virtual screen pixels).
Definition gui_window_backend.h:43
Integer 2D vector.
Definition gui_base_types.h:19