class GUIManager

Inherits: Module<GUIManager>

Manages the rendering and input of all GUI widgets in the scene.

Public

Constructors

GUIManager

GUIManager()

Methods

~GUIManager

~GUIManager() noexcept

RegisterWidget

void RegisterWidget(GUIWidget *widget)

Registers a newly created widget with the GUI manager.

This should be called by every GUI widget on creation.

UnregisterWidget

void UnregisterWidget(GUIWidget *widget)

Unregisters a GUI widget from the GUI manager.

This should be called by every GUI widget before getting deleted.

Update

void Update()

Called once per frame.

QueueForDestroy

void QueueForDestroy(GUIElement *element)

Queues the GUI element for destruction.

Element will be destroyed during the next call to update().

ProcessDestroyQueue

void ProcessDestroyQueue()

Forces all GUI elements that are queued for destruction to be destroyed immediately.

SetFocus

void SetFocus(GUIInteractable *element, bool focus, bool clear)

Change the GUI element focus state.

element
Element whose focus state to change
focus
Give the element focus or take it away.
clear
If true the focus will be cleared from any elements currently in focus. Otherwise the element will just be appended to the in-focus list (if enabling focus).

SetCaretColor

void SetCaretColor(const Color &color)

Changes the color of the input caret used in input boxes and similar controls.

SetTextSelectionColor

void SetTextSelectionColor(const Color &color)

Changes the text selection highlight color used in input boxes and similar controls.

GetCaretTexture

const HSpriteTexture &GetCaretTexture() const

Returns the default caret texture used for rendering the input caret sprite.

GetTextSelectionTexture

const HSpriteTexture &GetTextSelectionTexture() const

Returns the default selection highlight texture used for rendering the selection highlight sprites.

GetCaretBlinkState

bool GetCaretBlinkState() const

Checks is the input caret visible this frame.

GetInputCaretTool

GUIInputCaret *GetInputCaretTool() const

Returns input caret helper tool that allows you to easily position and show an input caret in your GUI controls.

GetInputSelectionTool

GUIInputSelection *GetInputSelectionTool() const

Returns input selection helper tool that allows you to easily position and show an input selection highlight in your GUI controls.

GetVectorSpriteAtlas

GUIVectorSpriteAtlas &GetVectorSpriteAtlas() const

Returns an atlas that vector paths are rasterized into.

Any GUI element using vector paths will register the path in this atlas. GUI manager will then rasterize the shapes before they are needed in GUI rendering.

SetInputBridge

void SetInputBridge(const SPtr<RenderTexture> &renderTex, const GUIInteractable *element)

Allows you to bridge GUI input from a GUI element into another render target.

renderTex
The render target to which to bridge the input.
element
The element from which to bridge input. Input will be transformed according to this elements position and size. Provide nullptr if you want to remove a bridge for the specified widget.

WindowToBridgedCoords

GUIPhysicalPoint WindowToBridgedCoords(const SPtr<RenderTarget> &target, const GUIPhysicalPoint &windowPos) const

Converts window coordinates to coordinates relative to the specified bridged render target (target displayed with a GUI element).

Returned coordinates will be relative to the bridge element.

Returns: If provided widget has no bridge, coordinates are returned as is.

GetBridgeWindow

SPtr<RenderWindow> GetBridgeWindow(const SPtr<RenderTexture> &target) const

Returns the render window that holds the GUI element that displays the provided render texture.

target
Render texture to find the bridged window for.

Returns: Window that displays the GUI element with the render texture, or null if the render texture is not bridged.

GetBridgedElements

void GetBridgedElements(const GUIWidget *widget, TInlineArray<std::pair<const GUIInteractable *, SPtr<const RenderTarget>>, 4> &elements)

Returns all GUI elements that have input bridging set up and belong to the provided GUI widget.

GetWidgetWindow

const RenderWindow *GetWidgetWindow(const GUIWidget &widget) const

Returns the parent render window of the specified widget.

staticInstance

static T &Instance()

Returns a reference to the module instance.

Module has to have been started up first otherwise an exception will be thrown.

staticInstancePtr

static T *InstancePtr()

Returns a pointer to the module instance.

Module has to have been started up first otherwise an exception will be thrown.

staticShutDown

static void ShutDown()

Shuts down this module and frees any resources it is using.

staticIsStarted

static bool IsStarted()

Query if the module has been started.

Protected

Methods

~Module<T>

virtual ~Module<T>() = default

OnStartUp

virtual void OnStartUp()

Override if you want your module to be notified once it has been constructed and started.

OnShutDown

virtual void OnShutDown()

Override if you want your module to be notified just before it is deleted.

staticInstanceInternal

static T *&InstanceInternal()

Returns a singleton instance of this module.

staticIsDestroyed

static bool &IsDestroyed()

Checks has the Module been shut down.

staticIsStartedUp

static bool &IsStartedUp()

Checks has the Module been started up.

Private

Methods

UpdateCaretTexture

void UpdateCaretTexture()

Recreates the input caret texture.

UpdateTextSelectionTexture

void UpdateTextSelectionTexture()

Recreates the input text selection highlight texture.

DestroyRenderer

void DestroyRenderer(render::GUIRenderer *renderer)

Destroys the render thread counterpart of the GUI manager.

renderer
Previously constructed render thread GUI manager instance.

ProcessDestroyQueueIteration

bool ProcessDestroyQueueIteration()

Destroys any elements or widgets queued for destruction.

FindElementUnderPointer

bool FindElementUnderPointer(const GUIPhysicalPoint &screenMousePos, bool buttonStates[3], bool shift, bool control, bool alt)

Finds a GUI element under the pointer at the specified screen position.

This method will also trigger pointer move/hover/leave events.

screenMousePos
Position of the pointer in screen coordinates.
buttonStates
States of the three mouse buttons (left, right, middle).
shift
Is shift key held.
control
Is control key held.
alt
Is alt key held.

OnPointerMoved

void OnPointerMoved(const PointerEvent &event)

Called whenever a pointer (for example mouse cursor) is moved.

OnPointerReleased

void OnPointerReleased(const PointerEvent &event)

Called whenever a pointer button (for example mouse button) is released.

OnPointerPressed

void OnPointerPressed(const PointerEvent &event)

Called whenever a pointer button (for example mouse button) is pressed.

OnPointerDoubleClick

void OnPointerDoubleClick(const PointerEvent &event)

Called whenever a pointer button (for example mouse button) is double clicked.

OnTextInput

void OnTextInput(const TextInputEvent &event)

Called whenever a text is input.

OnInputCommandEntered

void OnInputCommandEntered(InputCommandType commandType)

Called whenever an input command is input.

OnVirtualButtonDown

void OnVirtualButtonDown(const VirtualButton &button, u32 deviceIdx)

Called whenever a virtual button is pressed.

OnMouseDragEnded

void OnMouseDragEnded(const PointerEvent &event, DragCallbackInfo &dragInfo)

Called by the drag and drop managed to notify us the drag ended.

OnWindowFocusGained

void OnWindowFocusGained(RenderWindow &win)

Called when the specified window gains focus.

OnWindowFocusLost

void OnWindowFocusLost(RenderWindow &win)

Called when the specified window loses focus.

OnMouseLeftWindow

void OnMouseLeftWindow(RenderWindow &win)

Called when the mouse leaves the specified window.

ButtonToGuiButton

GUIMouseButton ButtonToGuiButton(PointerEventButton pointerButton) const

Converts pointer buttons to mouse buttons.

GetWidgetRelativePos

GUIPhysicalPoint GetWidgetRelativePos(const GUIWidget *widget, const GUIPhysicalPoint &screenPos) const

Converts screen coordinates to coordinates relative to the specified widget.

HideTooltip

void HideTooltip()

Hides the tooltip if any is shown.

TabFocusFirst

void TabFocusFirst()

Switches the focus to the first element in the tab group.

TabFocusNext

void TabFocusNext()

Switches the focus to the next element in the tab group.

Usually triggered when the user hits Tab key.

SendMouseEvent

bool SendMouseEvent(GUIInteractable *element, const GUIMouseEvent &event)

Sends a mouse event to the specified GUI element.

element
Element to send the event to.
event
Event data.

SendTextInputEvent

bool SendTextInputEvent(GUIInteractable *element, const GUITextInputEvent &event)

Sends a text input event to the specified GUI element.

element
Element to send the event to.
event
Event data.

SendCommandEvent

bool SendCommandEvent(GUIInteractable *element, const GUICommandEvent &event)

Sends a command event to the specified GUI element.

element
Element to send the event to.
event
Event data.

SendVirtualButtonEvent

bool SendVirtualButtonEvent(GUIInteractable *element, const GUIVirtualButtonEvent &event)

Sends a virtual button event to the specified GUI element.

element
Element to send the event to.
event
Event data.

Fields

mWidgets

Vector<WidgetInfo> mWidgets

mRenderer

SPtr<render::GUIRenderer> mRenderer

mScheduledForDestruction

Stack<GUIElement *> mScheduledForDestruction

mElementsUnderPointer

Vector<ElementInfoUnderPointer> mElementsUnderPointer

mNewElementsUnderPointer

Vector<ElementInfoUnderPointer> mNewElementsUnderPointer

mActiveMouseButton

GUIMouseButton mActiveMouseButton

mActiveElements

Vector<ElementInfo> mActiveElements

mNewActiveElements

Vector<ElementInfo> mNewActiveElements

mElementsInFocus

Vector<ElementFocusInfo> mElementsInFocus

mNewElementsInFocus

Vector<ElementFocusInfo> mNewElementsInFocus

mSavedFocusElements

UnorderedMap<RenderWindow *, Vector<ElementFocusInfo>> mSavedFocusElements

mForcedClearFocus

bool mForcedClearFocus

mForcedFocusElements

Vector<ElementForcedFocusInfo> mForcedFocusElements

mShowTooltip

bool mShowTooltip

mTooltipElementHoverStart

float mTooltipElementHoverStart

mInputCaret

GUIInputCaret * mInputCaret

mInputSelection

GUIInputSelection * mInputSelection

mLastPointerScreenPos

Vector2I mLastPointerScreenPos

mDragState

DragState mDragState

mLastPointerClickPos

GUIPhysicalPoint mLastPointerClickPos

mDragStartPos

GUIPhysicalPoint mDragStartPos

mMouseEvent

GUIMouseEvent mMouseEvent

mTextInputEvent

GUITextInputEvent mTextInputEvent

mCommandEvent

GUICommandEvent mCommandEvent

mVirtualButtonEvent

GUIVirtualButtonEvent mVirtualButtonEvent

mCaretImage

HSpriteTexture mCaretImage

mCaretColor

Color mCaretColor

mCaretBlinkInterval

float mCaretBlinkInterval

mCaretLastBlinkTime

float mCaretLastBlinkTime

mIsCaretOn

bool mIsCaretOn

mActiveCursor

CursorType mActiveCursor

mTextSelectionImage

HSpriteTexture mTextSelectionImage

mTextSelectionColor

Color mTextSelectionColor

mInputBridge

Map<SPtr<const RenderTexture>, const GUIInteractable *> mInputBridge

mVectorSpriteAtlas

UPtr<GUIVectorSpriteAtlas> mVectorSpriteAtlas

mOnPointerMovedConn

HEvent mOnPointerMovedConn

mOnPointerPressedConn

HEvent mOnPointerPressedConn

mOnPointerReleasedConn

HEvent mOnPointerReleasedConn

mOnPointerDoubleClick

HEvent mOnPointerDoubleClick

mOnTextInputConn

HEvent mOnTextInputConn

mOnInputCommandConn

HEvent mOnInputCommandConn

mOnVirtualButtonDown

HEvent mOnVirtualButtonDown

mDragEndedConn

HEvent mDragEndedConn

mWindowGainedFocusConn

HEvent mWindowGainedFocusConn

mWindowLostFocusConn

HEvent mWindowLostFocusConn

mMouseLeftWindowConn

HEvent mMouseLeftWindowConn