|
TachyonUI 0.1.0
High-performance UI for building tools.
|
Makes and manages the OS windows and delivers their input; GUIApplication::SetWindowBackend sets one, SDLWindowBackend is the default. More...
#include <gui_core/windows/gui_window_backend.h>
Public Member Functions | |
| IWindowBackend () | |
| virtual | ~IWindowBackend () |
| 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 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 | DestroyWindow (OSWindowHandle)=0 |
| Queues the window for destruction: the next PollEvents passes its context to cleanup, then destroys it. | |
| virtual void | AttachInputHandlerToWindow (OSWindowHandle window, IPlatformInputHandler *inputHandler)=0 |
| Where the window's input goes (see IPlatformInputHandler); not owned, nullptr for none. | |
| 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 input, and for PollEvents' cleanup. | |
| virtual void | DetachWindowContext (OSWindowHandle)=0 |
| Clears the context pointer stored in the OS window, so PollEvents' cleanup callback gets nullptr instead of double-freeing a context the caller destroys. | |
| 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 user) and for nullptr. | |
| virtual IWindowContext * | GetWindowContext (OSWindowHandle)=0 |
| The context attached with AttachContextToWindow, or nullptr. | |
| virtual void | BringToFront (OSWindowHandle)=0 |
| Raises the window above the others and asks the OS for the input focus. | |
| virtual OSWindowHandle | GetWindowUnderMouse ()=0 |
| The backend's window under the mouse, or nullptr. | |
| virtual OSWindowHandle | GetActiveWindow ()=0 |
| The window with the keyboard focus, or nullptr when none of the backend's windows has it. | |
| virtual uint32_t | GetFocusChangeCount () const =0 |
| Goes up whenever keyboard focus moves between windows, or to or from another application; open popups are checked against it. | |
| virtual void | PollEvents (std::function< void(OSWindowHandle, IWindowContext *)> cleanup)=0 |
| Handles the OS's pending events, delivering input to the attached handlers. | |
| 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). | |
| virtual float | GetDoubleClickMilliseconds () |
| The OS's double-click time in milliseconds, or 0 where the platform has none. | |
| virtual bool | PrefersReducedMotion () |
| Whether the OS asks for less motion (animations turned off); false where the platform has no such setting. | |
| virtual std::optional< color4b > | ReadScreenPixel (int2) |
| The color of a screen pixel, anywhere on the desktop (an eyedropper); nothing where the platform can't read the screen. | |
| virtual bool | TakeCloseRequest (OSWindowHandle) |
| Whether the OS asked to close a WindowFlags::ConfirmClose window since last asked. | |
| virtual void | SetCursor (MouseCursor cursor)=0 |
| Shows the system cursor for that shape; MouseCursor::None hides the cursor. | |
| 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 next to it. | |
| 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.5 on a 150% display). | |
| virtual IntRect | GetWindowPixelRect (OSWindowHandle window)=0 |
| The window's render target: OS position (for OS compositing) and size in physical pixels. | |
| virtual void | SwapBuffers (OSWindowHandle)=0 |
| Presents for a graphics API that swaps through the window (OpenGL). | |
| virtual IntRect | GetWindowRect (OSWindowHandle)=0 |
| Client area in pixels; {0,0,0,0} while minimized. | |
| virtual int2 | GetWindowPos (OSWindowHandle)=0 |
| The client area's top-left in screen pixels. | |
| 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, NSWindow on macOS, an X11 window or Wayland surface on Linux); nullptr without one. | |
| virtual bool | SetWindowRect (OSWindowHandle, const IntRect &clientRect)=0 |
| Moves and resizes the window so its client area is clientRect (screen pixels); the backend accounts for the frame. | |
| virtual void | SetWindowVisible (OSWindowHandle, bool visible)=0 |
| Shows or hides the window; hiding doesn't destroy it. | |
| virtual bool | SetWindowCloaked (OSWindowHandle, bool) |
| Cloaks a shown window: it takes frames but stays invisible, so it can be drawn before it appears. | |
| virtual uint32_t | ShowFade (OSWindowHandle, IWindowContext *, IntRect, float) |
| A layered stand-in for window showing what context drew last, at screenRect (screen pixels) and opacity (0 to 1), so the window itself can be hidden or cloaked while it fades in or out. | |
| virtual void | MoveFade (uint32_t, IntRect, float) |
| Moves a stand-in and sets its opacity. | |
| virtual void | EndFade (uint32_t) |
| Removes a stand-in. | |
| virtual std::vector< MonitorInfo > | GetMonitors () const =0 |
| Every monitor, the primary first. | |
| virtual int | GetMonitorAt (int2 pos) const =0 |
| Index into GetMonitors of the monitor holding the screen point pos; 0 (the primary) when no monitor holds it, -1 without monitors. | |
| virtual int | GetMonitorFromWindow (OSWindowHandle handle) const =0 |
| Index into GetMonitors of the window's monitor; -1 for an unknown window. | |
| virtual uint32_t | GetTicks () const =0 |
| A millisecond clock (SDL: since SDL started). | |
| virtual void | SetWindowMode (OSWindowHandle, WindowMode) |
| Sets the window's state: minimized, maximized, restored or fullscreen. | |
| virtual WindowMode | GetWindowMode (OSWindowHandle) const |
| The window's state as the OS has it now; WindowMode::Normal by default. | |
| 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. | |
| virtual int32_t | GetCursorSize () const |
| The OS mouse cursor's size in pixels (its accessibility size at the display's scale), or 0 when the platform doesn't say. | |
| virtual void | SetGraphicsContext (GraphicsContext *graphicsContext) |
| The graphics context the windows are made for and painted with (during an OS live resize). | |
| 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 (before the next frame), so it must be safe outside the frame. | |
| void | SetHitTestCallback (std::function< WindowHitArea(OSWindowHandle, int2 screenPos)> cb) |
| Classifies points (screen pixels) of CustomTitleBar windows for the OS. | |
| WindowHitArea | HitTestWindow (OSWindowHandle window, int2 screenPos) const |
| What a point (screen pixels) of the window is, from the hit-test callback; WindowHitArea::Client without one. | |
Protected Attributes | |
| std::function< void()> | m_onWindowMoved |
| Set by SetWindowMovedCallback; a backend calls it when a window moves or resizes. | |
| std::function< WindowHitArea(OSWindowHandle, int2)> | m_hitTest |
| Set by SetHitTestCallback; a backend asks it through HitTestWindow. | |
| GraphicsContext * | m_graphicsContext = nullptr |
| Set by SetGraphicsContext; not owned. | |
Makes and manages the OS windows and delivers their input; GUIApplication::SetWindowBackend sets one, SDLWindowBackend is the default.
Positions and sizes are physical pixels. NullWindowBackend is the minimal implementation.
|
inline |
|
inlinevirtual |
|
pure virtual |
Creates a window whose client area is size pixels, placed by the OS.
parentOSHandle is the owner window, or nullptr for a top-level one. Returns nullptr on failure.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
Creates a window whose client area is rect (screen pixels); otherwise as the size overload.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
Queues the window for destruction: the next PollEvents passes its context to cleanup, then destroys it.
False for a handle that isn't one of the backend's windows.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
Where the window's input goes (see IPlatformInputHandler); not owned, nullptr for none.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
Stores the window's context (not owned), for GetWindowContext, for the ID passed with the window's input, and for PollEvents' cleanup.
nullptr clears it.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
Clears the context pointer stored in the OS window, so PollEvents' cleanup callback gets nullptr instead of double-freeing a context the caller destroys.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
True while the handle is a live window of this backend; false once it was destroyed (by code or the user) and for nullptr.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
The context attached with AttachContextToWindow, or nullptr.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
Raises the window above the others and asks the OS for the input focus.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
The backend's window under the mouse, or nullptr.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
The window with the keyboard focus, or nullptr when none of the backend's windows has it.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
Goes up whenever keyboard focus moves between windows, or to or from another application; open popups are checked against it.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
Handles the OS's pending events, delivering input to the attached handlers.
Then the windows destroyed since the last call (DestroyWindow, or closed by the OS) go: cleanup gets each handle and its context while the window still exists. Runs in UpdateFrame, and again in RecordFrame.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
The mouse position in screen pixels (SDL: as of the last PollEvents).
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
The mouse buttons held down, wherever the mouse is (SDL: as of the last PollEvents).
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
inlinevirtual |
The OS's double-click time in milliseconds, or 0 where the platform has none.
Reimplemented in tachyon::SDLWindowBackend.
|
inlinevirtual |
Whether the OS asks for less motion (animations turned off); false where the platform has no such setting.
Reimplemented in tachyon::SDLWindowBackend.
The color of a screen pixel, anywhere on the desktop (an eyedropper); nothing where the platform can't read the screen.
Reimplemented in tachyon::ImageWindowBackend, and tachyon::SDLWindowBackend.
|
inlinevirtual |
Whether the OS asked to close a WindowFlags::ConfirmClose window since last asked.
Reimplemented in tachyon::ImageWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
Shows the system cursor for that shape; MouseCursor::None hides the cursor.
The library sets it once per frame.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
Where text is being typed in the window (window coordinates), so the IME places its candidate list next to it.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
The UI scale the OS asks for in this window: pixel density times the monitor's content scale (1.5 on a 150% display).
0 when unknown.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
The window's render target: OS position (for OS compositing) and size in physical pixels.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
Presents for a graphics API that swaps through the window (OpenGL).
The library doesn't call it: a Vulkan window context presents itself.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
Client area in pixels; {0,0,0,0} while minimized.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
The client area's top-left in screen pixels.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
The client area's size in pixels; {0,0} while minimized.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
The OS's own window handle, passed to GraphicsContext::CreateWindowContext (HWND on Windows, NSWindow on macOS, an X11 window or Wayland surface on Linux); nullptr without one.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
Moves and resizes the window so its client area is clientRect (screen pixels); the backend accounts for the frame.
True on success.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
Shows or hides the window; hiding doesn't destroy it.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
inlinevirtual |
Cloaks a shown window: it takes frames but stays invisible, so it can be drawn before it appears.
False when the backend can't (then the window is hidden until drawn instead).
Reimplemented in tachyon::SDLWindowBackend.
|
inlinevirtual |
A layered stand-in for window showing what context drew last, at screenRect (screen pixels) and opacity (0 to 1), so the window itself can be hidden or cloaked while it fades in or out.
Returns the stand-in, or 0 where there are none: then the window shows and hides at once.
Reimplemented in tachyon::SDLWindowBackend.
|
inlinevirtual |
Moves a stand-in and sets its opacity.
Reimplemented in tachyon::SDLWindowBackend.
|
inlinevirtual |
Removes a stand-in.
Reimplemented in tachyon::SDLWindowBackend.
|
pure virtual |
Every monitor, the primary first.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
Index into GetMonitors of the monitor holding the screen point pos; 0 (the primary) when no monitor holds it, -1 without monitors.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
Index into GetMonitors of the window's monitor; -1 for an unknown window.
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
pure virtual |
A millisecond clock (SDL: since SDL started).
Implemented in tachyon::ImageWindowBackend, tachyon::NullWindowBackend, and tachyon::SDLWindowBackend.
|
inlinevirtual |
Sets the window's state: minimized, maximized, restored or fullscreen.
The default does nothing.
Reimplemented in tachyon::ImageWindowBackend, and tachyon::SDLWindowBackend.
|
inlinevirtual |
The window's state as the OS has it now; WindowMode::Normal by default.
Reimplemented in tachyon::ImageWindowBackend, and tachyon::SDLWindowBackend.
|
inlinevirtual |
The user's preferred language as a BCP 47 tag ("ja", "en-US"), or empty when the platform doesn't say.
Reimplemented in tachyon::ImageWindowBackend, and tachyon::SDLWindowBackend.
|
inlinevirtual |
The OS mouse cursor's size in pixels (its accessibility size at the display's scale), or 0 when the platform doesn't say.
Reimplemented in tachyon::ImageWindowBackend, and tachyon::SDLWindowBackend.
|
inlinevirtual |
The graphics context the windows are made for and painted with (during an OS live resize).
GUIApplication::Initialize sets it before initializing the context.
Reimplemented in tachyon::ImageWindowBackend, and tachyon::SDLWindowBackend.
|
inline |
Sets cb, called as soon as any window moves or resizes, even inside the OS modal move / resize loop (before the next frame), so it must be safe outside the frame.
|
inline |
Classifies points (screen pixels) of CustomTitleBar windows for the OS.
Called from inside PollEvents and the OS's modal move/resize loop.
|
inline |
What a point (screen pixels) of the window is, from the hit-test callback; WindowHitArea::Client without one.
For backends, from their OS hit testing.
|
protected |
Set by SetWindowMovedCallback; a backend calls it when a window moves or resizes.
|
protected |
Set by SetHitTestCallback; a backend asks it through HitTestWindow.
|
protected |
Set by SetGraphicsContext; not owned.