Window
The Window class provides a cross-platform abstraction for creating, managing, and interacting with application windows. It allows the user to configure various window properties, such as title, size, visibility, and multisample support. The class includes methods for handling mouse input, keyboard events, touch interactions, and other common window features like fullscreen and transparency. This class provides essential functionality for building graphical user interfaces and handling real-time user input in applications across different platforms.
#include <platform/TellusimWindow.h>
Constructors
Window constructor.
Window()
explicit Window(Platform platform, uint32_t index = Maxu32)
explicit Window(Surface &surface)
Methods
All windows.
static uint32_t getNumWindows()
static Window getWindow(uint32_t index)
Update windows.
static void update(bool wait = false)
Window platform.
Platform getPlatform() const
const char *getPlatformName() const
Window device index.
uint32_t getIndex() const
Window surface.
void setSurface(Surface &surface)
Surface getSurface() const
Window handle.
void *getHandle() const
Check window.
virtual bool isCreated() const
Create window.
virtual bool create(const char *title, Flags flags = DefaultFlags)
virtual bool create(const String &title, Flags flags = DefaultFlags)
virtual bool create(Flags flags = DefaultFlags)
virtual void release()
Clear window.
bool clear(Color color)
Grab window.
bool grab(Image &image) const
Render window.
virtual bool render()
virtual bool present()
virtual bool finish()
Window format.
Format getColorFormat() const
Format getDepthFormat() const
uint32_t getMultisample() const
bool hasMultisample() const
Window flags.
virtual void setFlags(Flags flags)
Flags getFlags() const
bool hasFlag(Flags flags) const
bool hasFlags(Flags flags) const
Window refresh rate.
void setRefreshRate(uint32_t rate)
uint32_t getRefreshRate() const
Hide window.
virtual bool setHidden(bool hidden)
bool isHidden() const
Focus window.
virtual bool setFocused(bool focused)
bool isFocused() const
Minimize window.
virtual bool setMinimized(bool minimized)
bool isMinimized() const
Fullscreen window.
virtual bool setFullscreen(bool fullscreen)
bool isFullscreen() const
Occluded window.
bool isOccluded() const
Window title.
virtual bool setTitle(const char *title)
virtual bool setTitle(const String &title)
String getTitle() const
Window icon image.
virtual bool setIcon(const Image &image)
Image getIcon() const
Window geometry.
virtual bool setGeometry(int32_t x, int32_t y, uint32_t width, uint32_t height, bool force = false)
virtual bool setPosition(int32_t x, int32_t y, bool force = false)
int32_t getPositionX(bool title = false) const
int32_t getPositionY(bool title = false) const
virtual bool setSize(uint32_t width, uint32_t height, bool force = false)
uint32_t getWidth() const
uint32_t getHeight() const
float32_t getScale() const
uint32_t getDpiX() const
uint32_t getDpiY() const
Mouse position.
virtual bool setMouse(int32_t x, int32_t y, bool force = false)
int32_t getMouseX() const
int32_t getMouseY() const
bool setMouseDelta(int32_t dx, int32_t dy)
int32_t getMouseDX() const
int32_t getMouseDY() const
Mouse hidden flag.
virtual bool setMouseHidden(bool hidden, bool force = false)
bool isMouseHidden() const
Mouse clipped flag.
virtual bool setMouseClipped(bool clipped, bool force = false)
bool isMouseClipped() const
bool isMouseInside() const
Mouse cursor.
virtual bool setMouseCursor(Cursor cursor, bool force = false)
Cursor getMouseCursor() const
Mouse buttons.
bool setMouseButtons(Button buttons)
Button getMouseButtons() const
bool setMouseButton(Button button, bool value)
bool getMouseButton(Button button, bool clear = false) const
void releaseMouseButtons(Button buttons)
Button clearMouseButtons()
Mouse axes.
bool setMouseAxis(Axis axis, float32_t value)
float32_t getMouseAxis(Axis axis) const
float32_t clearMouseAxis(Axis axis)
Mouse pressed callback.
void setMousePressedCallback(const MousePressedCallback &func)
MousePressedCallback getMousePressedCallback() const
Mouse released callback.
void setMouseReleasedCallback(const MouseReleasedCallback &func)
MouseReleasedCallback getMouseReleasedCallback() const
Mouse changed callback.
void setMouseChangedCallback(const MouseChangedCallback &func)
MouseChangedCallback getMouseChangedCallback() const
Mouse rotated callback.
void setMouseRotatedCallback(const MouseRotatedCallback &func)
MouseRotatedCallback getMouseRotatedCallback() const
Touches.
uint32_t getNumTouches() const
uint32_t addTouch(int32_t x, int32_t y)
int32_t getTouchX(uint32_t touch) const
int32_t getTouchY(uint32_t touch) const
uint32_t findTouch(int32_t x, int32_t y) const
void clearTouches()
Touch changed callback.
void setTouchChangedCallback(const TouchChangedCallback &func)
TouchChangedCallback getTouchChangedCallback() const
Keyboard keys.
void setKeyboardKey(uint32_t key, bool value)
bool getKeyboardKey(uint32_t key, bool clear = false) const
Keyboard pressed callback.
void setKeyboardPressedCallback(const KeyboardPressedCallback &func)
KeyboardPressedCallback getKeyboardPressedCallback() const
Keyboard released callback.
void setKeyboardReleasedCallback(const KeyboardReleasedCallback &func)
KeyboardReleasedCallback getKeyboardReleasedCallback() const
Size changed callback.
void setSizeChangedCallback(const SizeChangedCallback &func)
SizeChangedCallback getSizeChangedCallback() const
Focus changed callback.
void setFocusChangedCallback(const FocusChangedCallback &func)
FocusChangedCallback getFocusChangedCallback() const
Close clicked callback.
void setCloseClickedCallback(const CloseClickedCallback &func)
CloseClickedCallback getCloseClickedCallback() const
Pause changed callback.
void setPauseChangedCallback(const PauseChangedCallback &func)
PauseChangedCallback getPauseChangedCallback() const
File dropped callback.
void setFileDroppedCallback(const FileDroppedCallback &func)
FileDroppedCallback getFileDroppedCallback() const
Update callback.
void setUpdateCallback(const UpdateCallback &func)
UpdateCallback getUpdateCallback() const
Present callback.
void setPresentCallback(const PresentCallback &func)
PresentCallback getPresentCallback() const
Window main loop callback.
MainLoopCallback getMainLoopCallback() const
virtual bool run(const MainLoopCallback &func)
virtual bool isRunning() const
virtual void stop()
Window copy/paste buffer.
bool setCopyText(const char *text)
bool setCopyText(const String &text)
String getPasteText() const
Types
using MousePressedCallback = Function<void(Button button)>
using MouseReleasedCallback = Function<void(Button button)>
using MouseChangedCallback = Function<void(int32_t x, int32_t y)>
using MouseRotatedCallback = Function<void(Axis axis, float32_t delta)>
using TouchChangedCallback = Function<void()>
using KeyboardPressedCallback = Function<void(uint32_t key, uint32_t code)>
using KeyboardReleasedCallback = Function<void(uint32_t key)>
using SizeChangedCallback = Function<void(uint32_t width, uint32_t height)>
using FocusChangedCallback = Function<void(bool changed)>
using CloseClickedCallback = Function<void()>
using PauseChangedCallback = Function<void(bool paused)>
using FileDroppedCallback = Function<void(const char *name, uint32_t remain)>
using UpdateCallback = Function<void()>
using PresentCallback = Function<void()>
using MainLoopCallback = Function<bool()>
Enums
Flags
Window flags.
Name | Value | Description |
---|---|---|
FlagNone | 0 | |
FlagTitle | (1 << 0) | Window has a title. |
FlagClose | (1 << 1) | Window has a close button. |
FlagFrame | (1 << 2) | Window has a frame border. |
FlagResize | (1 << 3) | Window is resizeable. |
FlagMinimize | (1 << 4) | Window has a minimize button. |
FlagMaximize | (1 << 5) | Window has a maximize button. |
FlagTransient | (1 << 6) | Window is not present in windows list. |
FlagFullscreen | (1 << 7) | Window is configured for fullscreen. |
FlagTransparent | (1 << 8) | Window supports transparent mode. |
FlagFileDropped | (1 << 9) | Window responds to drop actions. |
FlagMultisample2 | (1 << 10) | 2x multisample window. |
FlagMultisample4 | (1 << 11) | 4x multisample window. |
FlagMultisample8 | (1 << 12) | 8x multisample window. |
FlagVerticalSync | (1 << 13) | Vertical synchronization. |
FlagRefreshSync | (1 << 14) | Refresh synchronization. |
FlagColorRGBAu8ns | (1 << 15) | 8-bit sRGB integer color target format. |
FlagColorRGBu10Au2n | (1 << 16) | 10-bit mixed integer color target format. |
FlagColorRGBAf16 | (1 << 17) | 16-bit floating-point color target format. |
FlagMultisample | (FlagMultisample2 | FlagMultisample4 | FlagMultisample8) | |
DefaultFlags | (FlagTitle | FlagClose | FlagResize | FlagMinimize | FlagMaximize) | |
NumFlags | 18 |
Cursor
Mouse cursors.
Name | Value | Description |
---|---|---|
CursorArrow | 0 | Arrow cursor. |
CursorInvalid | 1 | Invalid cursor. |
CursorLeft | 2 | Resize left cursor. |
CursorRight | 3 | Resize right cursor. |
CursorBottom | 4 | Resize bottom cursor. |
CursorTop | 5 | Resize top cursor. |
CursorWidth | 6 | Resize left and right cursor. |
CursorHeight | 7 | Resize bottom and top cursor. |
CursorMajor | 8 | Resize top-left and bottom-right cursor. |
CursorMinor | 9 | Resize top-right and bottom-left cursor. |
CursorAll | 10 | Resize all cursor. |
NumCursors | 11 |
Button
Mouse buttons.
Name | Value |
---|---|
ButtonNone | 0 |
ButtonLeft | (1 << 0) |
ButtonLeft2 | (1 << 1) |
ButtonRight | (1 << 2) |
ButtonRight2 | (1 << 3) |
ButtonMiddle | (1 << 4) |
ButtonMiddle2 | (1 << 5) |
ButtonAux | (1 << 6) |
ButtonAux2 | (1 << 7) |
NumButtons | 8 |
Axis
Mouse axes.
Name | Value |
---|---|
AxisX | 0 |
AxisY | 1 |
AxisZ | 2 |
AxisW | 3 |
NumAxes | 4 |
Screen touches.
Name | Value |
---|---|
NumTouches | 16 |
Key
Keyboard keys.
Name | Value |
---|---|
KeyNone | 128 |
KeyEsc | 129 |
KeyTab | 130 |
KeyBackspace | 131 |
KeyDelete | 132 |
KeyInsert | 133 |
KeyReturn | 134 |
KeyPause | 135 |
KeyPrior | 136 |
KeyNext | 137 |
KeyEnd | 138 |
KeyHome | 139 |
KeyUp | 140 |
KeyDown | 141 |
KeyLeft | 142 |
KeyRight | 143 |
KeyNum | 144 |
KeyCaps | 145 |
KeyScroll | 146 |
KeyShift | 147 |
KeyCtrl | 148 |
KeyAlt | 149 |
KeyWin | 150 |
KeyCmd | 151 |
KeyMenu | 152 |
KeyF1 | 153 |
KeyF2 | 154 |
KeyF3 | 155 |
KeyF4 | 156 |
KeyF5 | 157 |
KeyF6 | 158 |
KeyF7 | 159 |
KeyF8 | 160 |
KeyF9 | 161 |
KeyF10 | 162 |
KeyF11 | 163 |
KeyF12 | 164 |
NumKeys | 165 |
KeyOption | KeyCmd |
KeyOption | KeyCtrl |