|
TachyonUI 0.1.0
High-performance UI for building tools.
|
Adds windows that render to an image (WindowFlags::RenderToImage) to another window backend. More...
#include <gui_core/windows/gui_image_window_backend.h>
Public Member Functions | |
| ImageWindowBackend (IWindowBackend &osBackend) | |
| ~ImageWindowBackend () override | |
| bool | IsImageWindow (OSWindowHandle window) const |
| True when window is one of this backend's image windows. | |
| void | SetPointer (OSWindowHandle window, int2 screenPos, MouseButtons buttons) |
| The pointer is over an image window, at this screen position with these buttons held; it is then the window under the mouse. | |
| void | SetFocus (OSWindowHandle window) |
| The image window with keyboard focus, reported as the active window. | |
| void | SetGraphicsContext (GraphicsContext *graphicsContext) override |
| The graphics context the windows are made for and painted with (during an OS live resize). | |
| OSWindowHandle | CreateWindow (std::string_view title, int2 size, WindowFlags windowFlags, OSWindowHandle parentOSHandle) override |
| Creates a window whose client area is size pixels, placed by the OS. | |
| OSWindowHandle | CreateWindow (std::string_view title, IntRect rect, WindowFlags windowFlags, OSWindowHandle parentOSHandle) override |
| Creates a window whose client area is rect (screen pixels); otherwise as the size overload. | |
| bool | DestroyWindow (OSWindowHandle window) override |
| Queues the window for destruction: the next PollEvents passes its context to cleanup, then destroys it. | |
| void | AttachInputHandlerToWindow (OSWindowHandle window, IPlatformInputHandler *inputHandler) override |
| Where the window's input goes (see IPlatformInputHandler); not owned, nullptr for none. | |
| void | AttachContextToWindow (OSWindowHandle window, IWindowContext *context) override |
| Stores the window's context (not owned), for GetWindowContext, for the ID passed with the window's input, and for PollEvents' cleanup. | |
| void | DetachWindowContext (OSWindowHandle window) override |
| Clears the context pointer stored in the OS window, so PollEvents' cleanup callback gets nullptr instead of double-freeing a context the caller destroys. | |
| bool | IsWindow (OSWindowHandle window) override |
| True while the handle is a live window of this backend; false once it was destroyed (by code or the user) and for nullptr. | |
| IWindowContext * | GetWindowContext (OSWindowHandle window) override |
| The context attached with AttachContextToWindow, or nullptr. | |
| void | BringToFront (OSWindowHandle window) override |
| Raises the window above the others and asks the OS for the input focus. | |
| OSWindowHandle | GetWindowUnderMouse () override |
| The backend's window under the mouse, or nullptr. | |
| OSWindowHandle | GetActiveWindow () override |
| The window with the keyboard focus, or nullptr when none of the backend's windows has it. | |
| uint32_t | GetFocusChangeCount () const override |
| Goes up whenever keyboard focus moves between windows, or to or from another application; open popups are checked against it. | |
| void | PollEvents (std::function< void(OSWindowHandle, IWindowContext *)> cleanup) override |
| Handles the OS's pending events, delivering input to the attached handlers. | |
| int2 | GetScreenMousePos () override |
| The mouse position in screen pixels (SDL: as of the last PollEvents). | |
| std::optional< color4b > | ReadScreenPixel (int2 screenPos) override |
| The color of a screen pixel, anywhere on the desktop (an eyedropper); nothing where the platform can't read the screen. | |
| bool | TakeCloseRequest (OSWindowHandle window) override |
| Whether the OS asked to close a WindowFlags::ConfirmClose window since last asked. | |
| MouseButtons | GetMouseButtons () override |
| The mouse buttons held down, wherever the mouse is (SDL: as of the last PollEvents). | |
| void | SetCursor (MouseCursor cursor) override |
| Shows the system cursor for that shape; MouseCursor::None hides the cursor. | |
| void | SetTextInputArea (OSWindowHandle window, IntRect rect) override |
| Where text is being typed in the window (window coordinates), so the IME places its candidate list next to it. | |
| float | GetWindowDisplayScale (OSWindowHandle window) override |
| The UI scale the OS asks for in this window: pixel density times the monitor's content scale (1.5 on a 150% display). | |
| IntRect | GetWindowPixelRect (OSWindowHandle window) override |
| The window's render target: OS position (for OS compositing) and size in physical pixels. | |
| void | SwapBuffers (OSWindowHandle window) override |
| Presents for a graphics API that swaps through the window (OpenGL). | |
| IntRect | GetWindowRect (OSWindowHandle window) override |
| Client area in pixels; {0,0,0,0} while minimized. | |
| int2 | GetWindowPos (OSWindowHandle window) override |
| The client area's top-left in screen pixels. | |
| int2 | GetWindowSize (OSWindowHandle window) override |
| The client area's size in pixels; {0,0} while minimized. | |
| void * | GetNativeHandle (OSWindowHandle window) override |
| 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. | |
| bool | SetWindowRect (OSWindowHandle window, const IntRect &clientRect) override |
| Moves and resizes the window so its client area is clientRect (screen pixels); the backend accounts for the frame. | |
| void | SetWindowVisible (OSWindowHandle window, bool visible) override |
| Shows or hides the window; hiding doesn't destroy it. | |
| void | SetWindowMode (OSWindowHandle window, WindowMode mode) override |
| Sets the window's state: minimized, maximized, restored or fullscreen. | |
| WindowMode | GetWindowMode (OSWindowHandle window) const override |
| The window's state as the OS has it now; WindowMode::Normal by default. | |
| std::vector< MonitorInfo > | GetMonitors () const override |
| Every monitor, the primary first. | |
| int | GetMonitorAt (int2 pos) const override |
| Index into GetMonitors of the monitor holding the screen point pos; 0 (the primary) when no monitor holds it, -1 without monitors. | |
| int | GetMonitorFromWindow (OSWindowHandle window) const override |
| Index into GetMonitors of the window's monitor; -1 for an unknown window. | |
| uint32_t | GetTicks () const override |
| A millisecond clock (SDL: since SDL started). | |
| std::string | GetPreferredLanguage () const override |
| The user's preferred language as a BCP 47 tag ("ja", "en-US"), or empty when the platform doesn't say. | |
| int32_t | GetCursorSize () const override |
| The OS mouse cursor's size in pixels (its accessibility size at the display's scale), or 0 when the platform doesn't say. | |
| Public Member Functions inherited from tachyon::IWindowBackend | |
| IWindowBackend () | |
| virtual | ~IWindowBackend () |
| 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 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. | |
| 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. | |
Additional Inherited Members | |
| Protected Attributes inherited from tachyon::IWindowBackend | |
| 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. | |
Adds windows that render to an image (WindowFlags::RenderToImage) to another window backend.
They have no OS window: the backend keeps their rect and attached context, and everything else goes to the wrapped backend. The host feeds their input; SetPointer and SetFocus say where it goes.
|
explicit |
|
override |
| bool tachyon::ImageWindowBackend::IsImageWindow | ( | OSWindowHandle | window | ) | const |
True when window is one of this backend's image windows.
| void tachyon::ImageWindowBackend::SetPointer | ( | OSWindowHandle | window, |
| int2 | screenPos, | ||
| MouseButtons | buttons ) |
The pointer is over an image window, at this screen position with these buttons held; it is then the window under the mouse.
Null window: the pointer is back on the OS windows.
| void tachyon::ImageWindowBackend::SetFocus | ( | OSWindowHandle | window | ) |
The image window with keyboard focus, reported as the active window.
Null: the OS decides again.
|
inlineoverridevirtual |
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 from tachyon::IWindowBackend.
|
overridevirtual |
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.
Implements tachyon::IWindowBackend.
|
overridevirtual |
Creates a window whose client area is rect (screen pixels); otherwise as the size overload.
Implements tachyon::IWindowBackend.
|
overridevirtual |
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.
Implements tachyon::IWindowBackend.
|
overridevirtual |
Where the window's input goes (see IPlatformInputHandler); not owned, nullptr for none.
Implements tachyon::IWindowBackend.
|
overridevirtual |
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.
Implements tachyon::IWindowBackend.
|
overridevirtual |
Clears the context pointer stored in the OS window, so PollEvents' cleanup callback gets nullptr instead of double-freeing a context the caller destroys.
Implements tachyon::IWindowBackend.
|
overridevirtual |
True while the handle is a live window of this backend; false once it was destroyed (by code or the user) and for nullptr.
Implements tachyon::IWindowBackend.
|
overridevirtual |
The context attached with AttachContextToWindow, or nullptr.
Implements tachyon::IWindowBackend.
|
overridevirtual |
Raises the window above the others and asks the OS for the input focus.
Implements tachyon::IWindowBackend.
|
overridevirtual |
The backend's window under the mouse, or nullptr.
Implements tachyon::IWindowBackend.
|
overridevirtual |
The window with the keyboard focus, or nullptr when none of the backend's windows has it.
Implements tachyon::IWindowBackend.
|
inlineoverridevirtual |
Goes up whenever keyboard focus moves between windows, or to or from another application; open popups are checked against it.
Implements tachyon::IWindowBackend.
|
overridevirtual |
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.
Implements tachyon::IWindowBackend.
|
overridevirtual |
The mouse position in screen pixels (SDL: as of the last PollEvents).
Implements tachyon::IWindowBackend.
|
inlineoverridevirtual |
The color of a screen pixel, anywhere on the desktop (an eyedropper); nothing where the platform can't read the screen.
Reimplemented from tachyon::IWindowBackend.
|
inlineoverridevirtual |
Whether the OS asked to close a WindowFlags::ConfirmClose window since last asked.
Reimplemented from tachyon::IWindowBackend.
|
overridevirtual |
The mouse buttons held down, wherever the mouse is (SDL: as of the last PollEvents).
Implements tachyon::IWindowBackend.
|
overridevirtual |
Shows the system cursor for that shape; MouseCursor::None hides the cursor.
The library sets it once per frame.
Implements tachyon::IWindowBackend.
|
overridevirtual |
Where text is being typed in the window (window coordinates), so the IME places its candidate list next to it.
Implements tachyon::IWindowBackend.
|
overridevirtual |
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.
Implements tachyon::IWindowBackend.
|
overridevirtual |
The window's render target: OS position (for OS compositing) and size in physical pixels.
Implements tachyon::IWindowBackend.
|
overridevirtual |
Presents for a graphics API that swaps through the window (OpenGL).
The library doesn't call it: a Vulkan window context presents itself.
Implements tachyon::IWindowBackend.
|
overridevirtual |
Client area in pixels; {0,0,0,0} while minimized.
Implements tachyon::IWindowBackend.
|
overridevirtual |
The client area's top-left in screen pixels.
Implements tachyon::IWindowBackend.
|
overridevirtual |
The client area's size in pixels; {0,0} while minimized.
Implements tachyon::IWindowBackend.
|
overridevirtual |
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.
Implements tachyon::IWindowBackend.
|
overridevirtual |
Moves and resizes the window so its client area is clientRect (screen pixels); the backend accounts for the frame.
True on success.
Implements tachyon::IWindowBackend.
|
overridevirtual |
Shows or hides the window; hiding doesn't destroy it.
Implements tachyon::IWindowBackend.
|
inlineoverridevirtual |
Sets the window's state: minimized, maximized, restored or fullscreen.
The default does nothing.
Reimplemented from tachyon::IWindowBackend.
|
inlineoverridevirtual |
The window's state as the OS has it now; WindowMode::Normal by default.
Reimplemented from tachyon::IWindowBackend.
|
overridevirtual |
Every monitor, the primary first.
Implements tachyon::IWindowBackend.
|
overridevirtual |
Index into GetMonitors of the monitor holding the screen point pos; 0 (the primary) when no monitor holds it, -1 without monitors.
Implements tachyon::IWindowBackend.
|
overridevirtual |
Index into GetMonitors of the window's monitor; -1 for an unknown window.
Implements tachyon::IWindowBackend.
|
overridevirtual |
A millisecond clock (SDL: since SDL started).
Implements tachyon::IWindowBackend.
|
overridevirtual |
The user's preferred language as a BCP 47 tag ("ja", "en-US"), or empty when the platform doesn't say.
Reimplemented from tachyon::IWindowBackend.
|
overridevirtual |
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 from tachyon::IWindowBackend.