Skip to content

GUI module


Component class

Component

Base class for creating a UI component.

This class provides the basic structure and behavior for any UI component in the application. It manages the lifecycle of the component, its event handling, and its associated window.

window function

RC<GUIWindow> window()

Gets the GUIWindow associated with this component.
Returns RC<GUIWindow> A reference-counted pointer to the GUIWindow.

tree function

WidgetTree &tree()

Returns the WidgetTree for the component.
Returns WidgetTree& A reference to the WidgetTree.

makeWindow function

virtual RC<GUIWindow> makeWindow()

This method is called on the main thread and is expected to return the window object that the component will use.
Returns RC<GUIWindow> A reference-counted pointer to the GUIWindow.

build function

virtual RC<Widget> build()

Called to build the component's widget hierarchy.

This function should be overridden to construct and return the root widget of the component.
Returns RC<Widget> A reference-counted pointer to the root widget.

unhandledEvent function

virtual void unhandledEvent(Event &event)

Handles any unhandled events.

If an event is not handled by the widget tree, this function will be called. It can be overridden to provide custom handling for specific events.
Param event The unhandled event.

onScaleChanged function

virtual void onScaleChanged()

Called when the UI scale is changed.

This can be used to adjust the component's appearance for different screen scales.

configureWindow function

virtual void configureWindow(RC<GUIWindow> window)

Configures the window for the component.

This is called before the window is shown and allows customization of the window (title, size etc).
Param window The window to configure.

beforeFrame function

virtual void beforeFrame()

Called before rendering a new frame.

This is typically used for pre-frame updates, such as preparing data or animations.

closeWindow function

void closeWindow()

Closes the associated window.

This will hide and optionally destroy the window tied to the component.


DragEventSubtype enum

enum class DragEventSubtype

Enum representing drag event subtypes.

Over enumerator

Dragging over a target.

Enter enumerator

Dragging has entered a target.

Exit enumerator

Dragging has exited a target.


DropEventSubtype enum

enum class DropEventSubtype

Enum representing drop event subtypes.

Drop enumerator

A drop event.

Cancel enumerator

A canceled drop event.


Event class

Event

Event class representing a generic event with type and utility methods.

type function

EventType type() const

Returns the event type.

name function

std::string name() const

Returns the name of the event.

operator bool function

explicit operator bool() const

Checks if the event is valid.

shouldBubble function

bool shouldBubble() const

Checks if the event should propagate.

uint32_t cookie() const

Returns the event's unique cookie.

stopPropagation function

void stopPropagation()

Stops the event from propagating.

reinject function

void reinject()

Re-injects the event into the queue.

passThrough function

void passThrough()

Marks the event as pass-through.


EventBase class

EventBase

Base struct for events, holding a unique event cookie.

uint32_t cookie = ++eventCookie

Unique identifier for the event.


EventBlurred class

EventBlurred

Struct representing a blurred event.


EventCharacterTyped class

EventCharacterTyped

Struct representing a character typed event.

character variable

char32_t character

The character that was typed.


EventDragNDrop class

EventDragNDrop

Struct representing a drag-and-drop event.

point variable

PointF point

The current mouse position during the drag.

downPoint variable

optional<PointF> downPoint

The initial mouse position when the drag started.

object variable

std::shared_ptr<Object> object

The object being dragged.

source variable

std::shared_ptr<Widget> source

The widget initiating the drag.

target variable

std::shared_ptr<Widget> target

The target widget where the drop may occur.


EventDragging class

EventDragging

Struct representing a dragging event, derived from EventDragNDrop.

subtype variable

DragEventSubtype subtype

Subtype of the drag event.


EventDropped class

EventDropped

Struct representing a dropped event, derived from EventDragNDrop.

subtype variable

DropEventSubtype subtype

Subtype of the drop event.


EventFocused class

EventFocused

Struct representing a focused event.

keyboard variable

bool keyboard

Indicates if the focus is keyboard-based.


EventInput class

EventInput

Base struct for input events, derived from EventBase.

mods variable

KeyModifiers mods

Modifiers active during the input event.


EventKey class

EventKey

Struct representing a key event, derived from EventInput.

key variable

KeyCode key

The key involved in the event.


EventKeyPressed class

EventKeyPressed

Struct representing a key pressed event.

repeat variable

bool repeat

Indicates if the key press is a repeat.


EventKeyReleased class

EventKeyReleased

Struct representing a key released event.


EventMouse class

EventMouse

Struct representing a mouse event, derived from EventInput.

point variable

PointF point

The current mouse position.

downPoint variable

optional<PointF> downPoint

The mouse position at the time the button was pressed, if applicable.


EventMouseButton class

EventMouseButton

Struct representing a mouse button event, derived from EventMouse.

button variable

MouseButton button

The button involved in the event.


EventMouseButtonPressed class

EventMouseButtonPressed

Struct representing a mouse button pressed event.


EventMouseButtonReleased class

EventMouseButtonReleased

Struct representing a mouse button released event.


EventMouseDoubleClicked class

EventMouseDoubleClicked

Struct representing a mouse double-clicked event.


EventMouseEntered class

EventMouseEntered

Struct representing a mouse entered event.


EventMouseExited class

EventMouseExited

Struct representing a mouse exited event.


EventMouseMoved class

EventMouseMoved

Struct representing a mouse moved event.


EventMouseTripleClicked class

EventMouseTripleClicked

Struct representing a mouse triple-clicked event.


EventMouseXWheel class

EventMouseXWheel

Struct representing a mouse wheel event.

delta variable

float delta

The amount the mouse wheel was scrolled horizontally.


EventMouseYWheel class

EventMouseYWheel

Struct representing a mouse wheel event.

delta variable

float delta

The amount the mouse wheel was scrolled vertically.


EventSourceDragging class

EventSourceDragging

Struct representing a source dragging event.


EventSourceDropped class

EventSourceDropped

Struct representing a source dropped event.


EventTargetDragging class

EventTargetDragging

Struct representing a target dragging event.


EventTargetDropped class

EventTargetDropped

Struct representing a target dropped event.


EventTargeted class

EventTargeted

Struct representing a targeted event, derived from EventBase.

target variable

std::weak_ptr<Widget> target

The target widget of the event.


EventType enum

enum class EventType

Enum representing various event types.

Undefined enumerator

Undefined event type.

MouseMoved enumerator

Mouse moved event.

MouseYWheel enumerator

Mouse wheel event (vertical).

MouseXWheel enumerator

Mouse wheel event (horizontal).

MouseButtonPressed enumerator

Mouse button pressed event.

MouseButtonReleased enumerator

Mouse button released event.

MouseDoubleClicked enumerator

Mouse double-clicked event.

MouseTripleClicked enumerator

Mouse triple-clicked event.

KeyPressed enumerator

Key pressed event.

KeyReleased enumerator

Key released event.

CharacterTyped enumerator

Character typed event.

TargetDragging enumerator

Target dragging event.

TargetDropped enumerator

Target dropped event.

Focused enumerator

Focused event.

Blurred enumerator

Blurred event.

MouseEntered enumerator

Mouse entered event.

MouseExited enumerator

Mouse exited event.

SourceDragging enumerator

Source dragging event.

SourceDropped enumerator

Source dropped event.

Count enumerator

Total number of event types.


EventVariant typedef

EventVariant = std::variant<std::monostate,           //
                            EventMouseMoved,          //
                            EventMouseYWheel,         //
                            EventMouseXWheel,         //
                            EventMouseButtonPressed,  //
                            EventMouseButtonReleased, //
                            EventMouseDoubleClicked,  //
                            EventMouseTripleClicked,  //
                            EventKeyPressed,          //
                            EventKeyReleased,         //
                            EventCharacterTyped,      //
                            EventTargetDragging,      //
                            EventTargetDropped,       //
                                                      //
                            EventFocused,             //
                            EventBlurred,             //
                            EventMouseEntered,        //
                            EventMouseExited,         //
                            EventSourceDragging,      //
                            EventSourceDropped>

Typedef representing a variant of all possible events.


HitTestMap class

HitTestMap

Struct for managing hit test information for widgets.

widget variable

std::weak_ptr<Widget> widget

The widget involved in the hit test.

zindex variable

int zindex

Z-index for rendering order.

rect variable

Rectangle rect

Rectangle area for the hit test.

anywhere variable

bool anywhere

Indicates if the widget is valid anywhere.

list variable

std::vector<HTEntry> list

List of hit test entries.

get function

std::shared_ptr<Widget> get(float x, float y,
                            bool respect_anywhere) const

Retrieves the widget at the specified coordinates.
Param x X-coordinate.
Param y Y-coordinate.
Param respect_anywhere Whether to respect the "anywhere" flag.
Returns The widget at the specified coordinates, if any.

clear function

void clear()

Clears all hit test entries.


InputQueue class

InputQueue

Manages the input queue, handling event dispatch and processing.

capturingMouse variable

std::vector<std::weak_ptr<Widget>> capturingMouse

List of widgets capturing the mouse input.

capturingKeys variable

std::vector<std::weak_ptr<Widget>> capturingKeys

List of widgets capturing keyboard input.

eventTarget variable

std::shared_ptr<Widget> eventTarget

The target widget of the event currently processed, unaffected by bubbling.

mousePos variable

PointF mousePos

Mouse position relative to the window.

addTabStop function

void addTabStop(std::weak_ptr<Widget> ptr)

Adds a widget to the tab stop list.
Param ptr The widget to add.

setAutoFocus function

void setAutoFocus(std::weak_ptr<Widget> ptr)

Sets the auto-focus widget.
Param ptr The widget to auto-focus.

enterFocusCapture function

void enterFocusCapture()

Increases the focus capture level.

leaveFocusCapture function

void leaveFocusCapture()

Decreases the focus capture level.

hasFocus function

bool hasFocus()

Checks if any widget currently has focus.
Returns True if a widget has focus, false otherwise.

mouseLeave function

void mouseLeave()

Handles mouse leave events.

processMouseState function

void processMouseState(
    const std::shared_ptr<Widget> &target)

Processes the mouse state for the given target widget.
Param target The target widget.

beginDrag function

void beginDrag(std::shared_ptr<Widget> dragSource,
               std::shared_ptr<Object> dragObject,
               MouseButton btn)

Begins dragging an object from the given source widget.
Param dragSource The source widget initiating the drag.
Param dragObject The object being dragged.
Param btn The mouse button involved in the drag.

isDragging function

bool isDragging() const

Checks if an object is currently being dragged.
Returns True if dragging, false otherwise.

allowDrop function

void allowDrop()

Allows the current drag to be dropped.

cancelDragging function

void cancelDragging()

Cancels the current drag operation.

setLastMouseEvent function

void setLastMouseEvent(EventMouse e)

Sets the last mouse event processed.
Param e The last mouse event.

setLastInputEvent function

void setLastInputEvent(EventInput e)

Sets the last input event processed.
Param e The last input event.

mousePosFor function

optional<PointF> mousePosFor(Widget *widget) const

Returns the mouse position relative to the window if it lies within the given widget.
Param widget The widget to check.
Returns The mouse position relative to the widget, if applicable.

mousePosForClient function

optional<PointF> mousePosForClient(Widget *widget) const

Returns the mouse position relative to the widget's client area, if within its bounds.
Param widget The widget to check.
Returns The mouse position relative to the widget's client area, if applicable.

getAt function

std::tuple<std::shared_ptr<Widget>, int>
getAt(Point pt, int offset = -1,
      bool respect_anywhere = true) const

Gets the widget at the specified point, starting from a specified offset.
Param pt The point to check.
Param offset The offset to start from (-1 starts from capturingMouse.front()).
Param respect_anywhere Whether to respect the "anywhere" flag.
Returns A tuple containing the widget at the point and the corresponding index.

mouseAtBubble function

bool mouseAtBubble(const function<bool(Widget *)> &fn,
                   bool bubble = true,
                   bool useMouseCapture = true) const

Calls the provided function for each widget at the current mouse position, optionally bubbling.
Param fn The function to call for each widget.
Param bubble Whether to allow event bubbling.
Param useMouseCapture Whether to use mouse capture information.
Returns True if the function succeeds, false otherwise.

getDescriptionAtMouse function

optional<std::string> getDescriptionAtMouse() const

Gets the description of the widget under the mouse, if any.
Returns The description of the widget, if applicable.

getCursorAtMouse function

optional<Cursor> getCursorAtMouse() const

Gets the cursor type for the widget under the mouse, if any.
Returns The cursor type, if applicable.

setFocus function

void setFocus(std::shared_ptr<Widget> focus, bool keyboard)

Sets the focus to the specified widget.
Param focus The widget to focus.
Param keyboard Whether the focus is set by keyboard.

resetFocus function

void resetFocus()

Resets the current focus.

reset function

void reset()

Resets the input queue state.

captureMouse function

void captureMouse(const std::shared_ptr<Widget> &target)

Captures the mouse for the specified widget.
Param target The widget to capture the mouse.

captureKeys function

void captureKeys(const std::shared_ptr<Widget> &target)

Captures keyboard input for the specified widget.
Param target The widget to capture keyboard input.

stopCaptureMouse function

void stopCaptureMouse(const std::shared_ptr<Widget> &target)

Stops capturing the mouse for the specified widget.
Param target The widget to stop capturing the mouse.

stopCaptureKeys function

void stopCaptureKeys(const std::shared_ptr<Widget> &target)

Stops capturing keyboard input for the specified widget.
Param target The widget to stop capturing keyboard input.

handleFocusEvents function

void handleFocusEvents(Event &e)

Handles focus-related events.
Param e The event to handle.

injectEvent function

void injectEvent(Event event)

Injects an event into the queue to be processed at the next frame.
Param event The event to inject.

addEvent function

void addEvent(Event event)

Adds an event to the queue to be processed in the next call to processEvent.
Param event The event to add.

processEvents function

void processEvents()

Processes all events in the queue.

processKeyEvent function

void processKeyEvent(Event e)

Processes a key event.
Param e The key event to process.

processMouseEvent function

void processMouseEvent(Event e)

Processes a mouse event.
Param e The mouse event to process.

processDragEvent function

void processDragEvent(Event e)

Processes a drag event.
Param e The drag event to process.

processTargetedEvent function

void processTargetedEvent(Event e)

Processes a targeted event.
Param e The targeted event to process.

InputQueue function

InputQueue()

Constructor for the InputQueue class.


Iterator class

Iterator

/////////////////////////////////////////////////////////////////////////////


apply function

void apply(Builder builder)

/////////////////////////////////////////////////////////////////////////////


blur function

void blur()

Clears focus


close function

virtual void close(Widget *sender)

closeNearestPopup function

void closeNearestPopup()

Closes nearest parent with m_isPopup set to true


doPaint function

void doPaint(Canvas &canvas) const

////////////////////////////////////////////////////////////////////////////


eventCookie variable

extern std::atomic_uint32_t eventCookie

Global atomic event counter.


eventTypeNames variable

extern const char *const eventTypeNames[+EventType::Count]

Array of event type names.


focus function

void focus(bool byKeyboard = false)

Sets focus to this widget


hasClass function

bool hasClass(std::string_view className) const

/////////////////////////////////////////////////////////////////////////////


isVisible function

bool isVisible() const noexcept

/////////////////////////////////////////////////////////////////////////////


name function

std::string name() const

/////////////////////////////////////////////////////////////////////////////


operator+ function

constexpr int operator+(EventType t)

Helper function to convert EventType to an integer.
Param t The event type to convert.
Returns The integer representation of the event type.


paintTo function

void paintTo(Canvas &canvas) const

/////////////////////////////////////////////////////////////////////////////


replace function

bool replace(Ptr oldWidget, Ptr newWidget, bool deep)

Replaces oldWidget with newWidget.
Param deep in subtree
Returns false if oldWidget wasn't found


toggleState function

void toggleState(WidgetState mask, bool on)

////////////////////////////////////////////////////////////////////////////


viewportSize function

Size viewportSize() const noexcept

////////////////////////////////////////////////////////////////////////////


widgets function

const WidgetPtrs &widgets() const

/////////////////////////////////////////////////////////////////////////////


Auto-generated from sources, Revision , https://github.com/brisklib/brisk/blob//include/brisk/