Lysa.ui  0.0
Lysa 3D Engine
Widget Class Referenceabstract

Detailed Description

The base class for all UI widgets. Provides layout, input handling, and child management.

Lua full name: lysa.ui.Widget

Public Member Functions

boolean is_enabled ()
 Returns true if the widget responds to mouse and keyboard input. More...
 
nil set_pos (x: number, y: number)
 Moves the widget to the given position in its parent's coordinate space. More...
 
nil set_size (width: number, height: number)
 Resizes the widget to the given width and height in virtual screen units. More...
 
nil set_rect (x: number, y: number, width: number, height: number)
 Sets the widget's position and size in one call. More...
 
nil remove (child: Widget)
 Removes and detaches the given direct child widget. More...
 
nil remove_all ()
 Removes and detaches all descendant widgets recursively. More...
 
nil refresh ()
 Forces a full redraw of the widget on the next frame. More...
 
nil resize_children ()
 Triggers a layout pass that repositions and resizes all direct children according to their alignment. More...
 
Widget set_focus (focus: boolean|nil)
 Requests keyboard focus for this widget (pass nil or true to acquire, false to release). Returns the widget itself. More...
 
nil set_children_offset (x: number, y: number)
 Sets the scroll offset applied to children during layout, enabling scrollable content. More...
 
Text create_text (alignment: Alignment, text: string)
 Creates and adds a Text child widget with the given alignment and initial text. More...
 
Text create_text (resource: string, alignment: Alignment, text: string)
 Creates and adds a Text child widget, loading its style from a resource string. More...
 
Panel create_panel (alignment: Alignment)
 Creates and adds a Panel child widget with the given alignment. More...
 
Panel create_panel (resource: string, alignment: Alignment)
 Creates and adds a Panel child widget, loading its style from a resource string. More...
 
Popup create_popup (x: number, y: number)
 Creates and adds a Popup child widget at the given position, rendered on top of siblings. More...
 
Popup create_popup (resource: string, x: number, y: number)
 Creates and adds a Popup child widget at the given position, loading its style from a resource string. More...
 
Box create_box (alignment: Alignment)
 Creates and adds a Box child widget with the given alignment. More...
 
Box create_box (resource: string, alignment: Alignment)
 Creates and adds a Box child widget, loading its style from a resource string. More...
 
Button create_button (alignment: Alignment)
 Creates and adds a Button child widget with the given alignment. More...
 
Button create_button (resource: string, alignment: Alignment)
 Creates and adds a Button child widget, loading its style from a resource string. More...
 
ToggleButton create_toggle_button (alignment: Alignment)
 Creates and adds a ToggleButton child widget with the given alignment. More...
 
ToggleButton create_toggle_button (resource: string, alignment: Alignment)
 Creates and adds a ToggleButton child widget, loading its style from a resource string. More...
 
HLine create_hline (alignment: Alignment)
 Creates and adds a horizontal Line child widget with the given alignment. More...
 
HLine create_hline (resource: string, alignment: Alignment)
 Creates and adds a horizontal Line child widget, loading its style from a resource string. More...
 
VLine create_vline (alignment: Alignment)
 Creates and adds a vertical Line child widget with the given alignment. More...
 
VLine create_vline (resource: string, alignment: Alignment)
 Creates and adds a vertical Line child widget, loading its style from a resource string. More...
 
Frame create_frame (alignment: Alignment, title: string)
 Creates and adds a Frame child widget with the given alignment and title. More...
 
Frame create_frame (resource: string, alignment: Alignment, title: string)
 Creates and adds a Frame child widget, loading its style from a resource string. More...
 
TextEdit create_text_edit (alignment: Alignment, text: string|nil)
 Creates and adds a TextEdit child widget with the given alignment and optional initial text. More...
 
TextEdit create_text_edit (resource: string, alignment: Alignment, text: string|nil)
 Creates and adds a TextEdit child widget, loading its style from a resource string. More...
 
Image create_image (alignment: Alignment)
 Creates and adds an Image child widget with the given alignment. More...
 
Image create_image (resource: string, alignment: Alignment)
 Creates and adds an Image child widget, loading its style from a resource string. More...
 
Image create_image (resource: string, alignment: Alignment, autoresize: boolean, fixedsize: boolean)
 Creates and adds an Image child widget with auto-resize and fixed-size options. More...
 
VScrollBar create_vscrollbar (alignment: Alignment)
 Creates and adds a vertical ScrollBar child widget with the given alignment. More...
 
VScrollBar create_vscrollbar (resource: string, alignment: Alignment)
 Creates and adds a vertical ScrollBar child widget, loading its style from a resource string. More...
 
HScrollBar create_hscrollbar (alignment: Alignment)
 Creates and adds a horizontal ScrollBar child widget with the given alignment. More...
 
HScrollBar create_hscrollbar (resource: string, alignment: Alignment)
 Creates and adds a horizontal ScrollBar child widget, loading its style from a resource string. More...
 
TreeView create_tree_view (alignment: Alignment)
 Creates and adds a TreeView child widget with the given alignment. More...
 
TreeView create_tree_view (resource: string, alignment: Alignment)
 Creates and adds a TreeView child widget, loading its style from a resource string. More...
 
Widget create_widget (alignment: Alignment)
 Creates and adds a transparent container Widget child with the given alignment. More...
 
Widget create_widget (resource: string, alignment: Alignment)
 Creates and adds a transparent container Widget child, loading its style from a resource string. More...
 
ListBox create_list_box (alignment: Alignment)
 Creates and adds a ListBox child widget with the given alignment. More...
 
ListBox create_list_box (resource: string, alignment: Alignment)
 Creates and adds a ListBox child widget, loading its style from a resource string. More...
 
ProgressBar create_progress_bar (alignment: Alignment)
 Creates and adds a ProgressBar child widget with the given alignment. More...
 
ProgressBar create_progress_bar (resource: string, alignment: Alignment)
 Creates and adds a ProgressBar child widget, loading its style from a resource string. More...
 
VProgressBar create_vprogress_bar (alignment: Alignment)
 Creates and adds a vertical ProgressBar child widget with the given alignment. More...
 
VProgressBar create_vprogress_bar (resource: string, alignment: Alignment)
 Creates and adds a vertical ProgressBar child widget, loading its style from a resource string. More...
 
HProgressBar create_hprogress_bar (alignment: Alignment)
 Creates and adds a horizontal ProgressBar child widget with the given alignment. More...
 
HProgressBar create_hprogress_bar (resource: string, alignment: Alignment)
 Creates and adds a horizontal ProgressBar child widget, loading its style from a resource string. More...
 
ScrollBox create_scroll_box (alignment: Alignment)
 Creates and adds a ScrollBox child widget with the given alignment. More...
 
ScrollBox create_scroll_box (resource: string, alignment: Alignment)
 Creates and adds a ScrollBox child widget, loading its style from a resource string. More...
 
Widget add_child (child: Widget, alignment: integer, resource: string|nil)
 Adds a pre-constructed child widget with the given alignment and optional resource string. More...
 

Properties

integer id
 The unique ID
 
integer type
 The concrete widget type (see lysa.ui.WidgetType). (read-only)
 
Widget[] children
 Ordered list of direct child widgets.
 
boolean visible
 True if the widget is visible; false hides it and all its children.
 
any user_data
 Lua user data.
 
boolean enabled
 Enables or disables the widget's response to input events (pass nil or true to enable, false to disable).
 
number width
 The widget width in virtual screen units.
 
number height
 The widget height in virtual screen units.
 
lysa.Rect rect
 The current position and size of the widget as a Rect.
 
integer alignment
 The current placement alignment within the parent (see lysa.ui.Alignment).
 
lysa.Font font
 The font used to render text within this widget.
 
number font_scale
 The scale factor applied to the widget's font.
 
boolean focused
 True if this widget currently holds keyboard focus. (read-only)
 
Widget|nil parent
 The direct parent widget, or nil if this is a root widget. (read-only)
 
number padding
 Spacing in virtual screen units between children during layout.
 
number vborder
 Vertical inset between the widget edges and its content area.
 
number hborder
 Horizontal inset between the widget edges and its content area.
 
boolean draw_background
 False if the widget's background should be drawn transparently.
 
boolean pushed
 True if the widget is currently in a pressed state (e.g. mouse button held down over it).
 
boolean pointed
 True if the mouse cursor is currently over this widget. (read-only)
 
boolean freezed
 True if the widget ignores all input events without being visually disabled.
 
boolean overlapping
 True if this widget visually overlaps one or more siblings. (read-only)
 
lysa.Rect children_rect
 The smallest Rect enclosing all direct children. (read-only)
 
integer group_index
 User-defined integer tag used to identify widgets within a logical group.
 
number transparency
 Global alpha multiplier for the widget (0.0 = fully transparent, 1.0 = opaque).
 
boolean consume_mouse_event
 When true, mouse events are consumed by this widget and not propagated to its parent.
 
number children_offset_x
 Horizontal scroll offset subtracted from child positions during layout (read-only; use set_children_offset to change).
 
number children_offset_y
 Vertical scroll offset subtracted from child positions during layout (read-only; use set_children_offset to change).
 

Member Function Documentation

boolean is_enabled ( )

Returns true if the widget responds to mouse and keyboard input.

Returns
boolean
nil set_pos ( number  x,
number  y)

Moves the widget to the given position in its parent's coordinate space.

Parameters
xnumber
ynumber
nil set_size ( number  width,
number  height)

Resizes the widget to the given width and height in virtual screen units.

Parameters
widthnumber
heightnumber
nil set_rect ( number  x,
number  y,
number  width,
number  height)

Sets the widget's position and size in one call.

Parameters
xnumber
ynumber
widthnumber
heightnumber
nil remove ( Widget  child)

Removes and detaches the given direct child widget.

Parameters
childWidget
nil remove_all ( )

Removes and detaches all descendant widgets recursively.

nil refresh ( )

Forces a full redraw of the widget on the next frame.

nil resize_children ( )

Triggers a layout pass that repositions and resizes all direct children according to their alignment.

Widget set_focus ( boolean|nil  focus)

Requests keyboard focus for this widget (pass nil or true to acquire, false to release). Returns the widget itself.

Parameters
focusboolean|nil
Returns
Widget
nil set_children_offset ( number  x,
number  y)

Sets the scroll offset applied to children during layout, enabling scrollable content.

Parameters
xnumber
ynumber
Text create_text ( Alignment  alignment,
string  text)

Creates and adds a Text child widget with the given alignment and initial text.

Parameters
alignmentAlignment
textstring
Returns
Text
Text create_text ( string  resource,
Alignment  alignment,
string  text)

Creates and adds a Text child widget, loading its style from a resource string.

Parameters
resourcestring
alignmentAlignment
textstring
Returns
Text
Panel create_panel ( Alignment  alignment)

Creates and adds a Panel child widget with the given alignment.

Parameters
alignmentAlignment
Returns
Panel
Panel create_panel ( string  resource,
Alignment  alignment)

Creates and adds a Panel child widget, loading its style from a resource string.

Parameters
resourcestring
alignmentAlignment
Returns
Panel
Popup create_popup ( number  x,
number  y)

Creates and adds a Popup child widget at the given position, rendered on top of siblings.

Parameters
xnumber
ynumber
Returns
Popup
Popup create_popup ( string  resource,
number  x,
number  y)

Creates and adds a Popup child widget at the given position, loading its style from a resource string.

Parameters
resourcestring
xnumber
ynumber
Returns
Popup
Box create_box ( Alignment  alignment)

Creates and adds a Box child widget with the given alignment.

Parameters
alignmentAlignment
Returns
Box
Box create_box ( string  resource,
Alignment  alignment)

Creates and adds a Box child widget, loading its style from a resource string.

Parameters
resourcestring
alignmentAlignment
Returns
Box
Button create_button ( Alignment  alignment)

Creates and adds a Button child widget with the given alignment.

Parameters
alignmentAlignment
Returns
Button
Button create_button ( string  resource,
Alignment  alignment)

Creates and adds a Button child widget, loading its style from a resource string.

Parameters
resourcestring
alignmentAlignment
Returns
Button
ToggleButton create_toggle_button ( Alignment  alignment)

Creates and adds a ToggleButton child widget with the given alignment.

Parameters
alignmentAlignment
Returns
ToggleButton
ToggleButton create_toggle_button ( string  resource,
Alignment  alignment)

Creates and adds a ToggleButton child widget, loading its style from a resource string.

Parameters
resourcestring
alignmentAlignment
Returns
ToggleButton
HLine create_hline ( Alignment  alignment)

Creates and adds a horizontal Line child widget with the given alignment.

Parameters
alignmentAlignment
Returns
HLine
HLine create_hline ( string  resource,
Alignment  alignment)

Creates and adds a horizontal Line child widget, loading its style from a resource string.

Parameters
resourcestring
alignmentAlignment
Returns
HLine
VLine create_vline ( Alignment  alignment)

Creates and adds a vertical Line child widget with the given alignment.

Parameters
alignmentAlignment
Returns
VLine
VLine create_vline ( string  resource,
Alignment  alignment)

Creates and adds a vertical Line child widget, loading its style from a resource string.

Parameters
resourcestring
alignmentAlignment
Returns
VLine
Frame create_frame ( Alignment  alignment,
string  title)

Creates and adds a Frame child widget with the given alignment and title.

Parameters
alignmentAlignment
titlestring
Returns
Frame
Frame create_frame ( string  resource,
Alignment  alignment,
string  title)

Creates and adds a Frame child widget, loading its style from a resource string.

Parameters
resourcestring
alignmentAlignment
titlestring
Returns
Frame
TextEdit create_text_edit ( Alignment  alignment,
string|nil  text)

Creates and adds a TextEdit child widget with the given alignment and optional initial text.

Parameters
alignmentAlignment
textstring|nil
Returns
TextEdit
TextEdit create_text_edit ( string  resource,
Alignment  alignment,
string|nil  text)

Creates and adds a TextEdit child widget, loading its style from a resource string.

Parameters
resourcestring
alignmentAlignment
textstring|nil
Returns
TextEdit
Image create_image ( Alignment  alignment)

Creates and adds an Image child widget with the given alignment.

Parameters
alignmentAlignment
Returns
Image
Image create_image ( string  resource,
Alignment  alignment)

Creates and adds an Image child widget, loading its style from a resource string.

Parameters
resourcestring
alignmentAlignment
Returns
Image
Image create_image ( string  resource,
Alignment  alignment,
boolean  autoresize,
boolean  fixedsize)

Creates and adds an Image child widget with auto-resize and fixed-size options.

Parameters
resourcestring
alignmentAlignment
autoresizeboolean
fixedsizeboolean
Returns
Image
VScrollBar create_vscrollbar ( Alignment  alignment)

Creates and adds a vertical ScrollBar child widget with the given alignment.

Parameters
alignmentAlignment
Returns
VScrollBar
VScrollBar create_vscrollbar ( string  resource,
Alignment  alignment)

Creates and adds a vertical ScrollBar child widget, loading its style from a resource string.

Parameters
resourcestring
alignmentAlignment
Returns
VScrollBar
HScrollBar create_hscrollbar ( Alignment  alignment)

Creates and adds a horizontal ScrollBar child widget with the given alignment.

Parameters
alignmentAlignment
Returns
HScrollBar
HScrollBar create_hscrollbar ( string  resource,
Alignment  alignment)

Creates and adds a horizontal ScrollBar child widget, loading its style from a resource string.

Parameters
resourcestring
alignmentAlignment
Returns
HScrollBar
TreeView create_tree_view ( Alignment  alignment)

Creates and adds a TreeView child widget with the given alignment.

Parameters
alignmentAlignment
Returns
TreeView
TreeView create_tree_view ( string  resource,
Alignment  alignment)

Creates and adds a TreeView child widget, loading its style from a resource string.

Parameters
resourcestring
alignmentAlignment
Returns
TreeView
Widget create_widget ( Alignment  alignment)

Creates and adds a transparent container Widget child with the given alignment.

Parameters
alignmentAlignment
Returns
Widget
Widget create_widget ( string  resource,
Alignment  alignment)

Creates and adds a transparent container Widget child, loading its style from a resource string.

Parameters
resourcestring
alignmentAlignment
Returns
Widget
ListBox create_list_box ( Alignment  alignment)

Creates and adds a ListBox child widget with the given alignment.

Parameters
alignmentAlignment
Returns
ListBox
ListBox create_list_box ( string  resource,
Alignment  alignment)

Creates and adds a ListBox child widget, loading its style from a resource string.

Parameters
resourcestring
alignmentAlignment
Returns
ListBox
ProgressBar create_progress_bar ( Alignment  alignment)

Creates and adds a ProgressBar child widget with the given alignment.

Parameters
alignmentAlignment
Returns
ProgressBar
ProgressBar create_progress_bar ( string  resource,
Alignment  alignment)

Creates and adds a ProgressBar child widget, loading its style from a resource string.

Parameters
resourcestring
alignmentAlignment
Returns
ProgressBar
VProgressBar create_vprogress_bar ( Alignment  alignment)

Creates and adds a vertical ProgressBar child widget with the given alignment.

Parameters
alignmentAlignment
Returns
VProgressBar
VProgressBar create_vprogress_bar ( string  resource,
Alignment  alignment)

Creates and adds a vertical ProgressBar child widget, loading its style from a resource string.

Parameters
resourcestring
alignmentAlignment
Returns
VProgressBar
HProgressBar create_hprogress_bar ( Alignment  alignment)

Creates and adds a horizontal ProgressBar child widget with the given alignment.

Parameters
alignmentAlignment
Returns
HProgressBar
HProgressBar create_hprogress_bar ( string  resource,
Alignment  alignment)

Creates and adds a horizontal ProgressBar child widget, loading its style from a resource string.

Parameters
resourcestring
alignmentAlignment
Returns
HProgressBar
ScrollBox create_scroll_box ( Alignment  alignment)

Creates and adds a ScrollBox child widget with the given alignment.

Parameters
alignmentAlignment
Returns
ScrollBox
ScrollBox create_scroll_box ( string  resource,
Alignment  alignment)

Creates and adds a ScrollBox child widget, loading its style from a resource string.

Parameters
resourcestring
alignmentAlignment
Returns
ScrollBox
Widget add_child ( Widget  child,
integer  alignment,
string|nil  resource)

Adds a pre-constructed child widget with the given alignment and optional resource string.

Parameters
childWidget
alignmentinteger
resourcestring|nil
Returns
Widget

Property Documentation

integer id

The unique ID

integer type

The concrete widget type (see lysa.ui.WidgetType). (read-only)

Widget[] children

Ordered list of direct child widgets.

boolean visible

True if the widget is visible; false hides it and all its children.

any user_data

Lua user data.

boolean enabled

Enables or disables the widget's response to input events (pass nil or true to enable, false to disable).

number width

The widget width in virtual screen units.

number height

The widget height in virtual screen units.

lysa.Rect rect

The current position and size of the widget as a Rect.

integer alignment

The current placement alignment within the parent (see lysa.ui.Alignment).

lysa.Font font

The font used to render text within this widget.

number font_scale

The scale factor applied to the widget's font.

boolean focused

True if this widget currently holds keyboard focus. (read-only)

Widget|nil parent

The direct parent widget, or nil if this is a root widget. (read-only)

number padding

Spacing in virtual screen units between children during layout.

number vborder

Vertical inset between the widget edges and its content area.

number hborder

Horizontal inset between the widget edges and its content area.

boolean draw_background

False if the widget's background should be drawn transparently.

boolean pushed

True if the widget is currently in a pressed state (e.g. mouse button held down over it).

boolean pointed

True if the mouse cursor is currently over this widget. (read-only)

boolean freezed

True if the widget ignores all input events without being visually disabled.

boolean overlapping

True if this widget visually overlaps one or more siblings. (read-only)

lysa.Rect children_rect

The smallest Rect enclosing all direct children. (read-only)

integer group_index

User-defined integer tag used to identify widgets within a logical group.

number transparency

Global alpha multiplier for the widget (0.0 = fully transparent, 1.0 = opaque).

boolean consume_mouse_event

When true, mouse events are consumed by this widget and not propagated to its parent.

number children_offset_x

Horizontal scroll offset subtracted from child positions during layout (read-only; use set_children_offset to change).

number children_offset_y

Vertical scroll offset subtracted from child positions during layout (read-only; use set_children_offset to change).