✨ Features
- Added
opacity property to Control.
- Added control nesting support.
- Improved the debug view (
ugui.DEBUG)
- Added per-control instance drawing customization.
- Added the
colorpicker control.
- Added user-defined hittesting support.
- Changed
menu to only require one UID slot
- Added
Control.context_menu and meta context menu result
⚡ Performance
- Improved rich text drawing performance
- Improved general styler performance
🐞 Bugfixes
- Fixed distorted rendering of the checkmark icon when width ≠ height
- Fixed broken multiline tooltip rendering
- Fixed tall tooltips being misaligned
- Fixed joystick lines extending beyond the circle when non-rectangular
- Fixed menu item icons being drawn with unexpected color and size
⛔ Breaking changes
standard_styler.draw_rich_text now takes a parameter table
ugui.standard_styler.draw_rich_text now accepts a single table instead of positional arguments. Move each argument into the matching named field (rectangle, align_x, align_y, text, color, visual_state, plaintext, font_name, font_size, wrap, fit, or clip). For example:
-ugui.standard_styler.draw_rich_text(rectangle, align_x, align_y, text, color, visual_state)
+ugui.standard_styler.draw_rich_text({
+ rectangle = rectangle,
+ align_x = align_x,
+ align_y = align_y,
+ text = text,
+ color = color,
+ visual_state = visual_state,
+})
standard_styler.draw_icon no longer has visual_state parameter
The visual_state parameter to standard_styler.draw_icon has been removed, and UguiNinesliceStyle was adjusted accordingly
to only have one rectangle per icon.
Various styler consolidations
The following functions have been removed from the standard_styler:
draw_button
draw_togglebutton
draw_carrousel_button
draw_combobox
draw_joystick_inner
The following functions have gained a new visual_state parameter:
draw_textbox
draw_joystick
Removed UguiDrawRichTextParams.visual_state
The visual_state field was removed from UguiDrawRichTextParams.
If you were relying on ugui-side color lookps based on the visual state, do the lookup at the callsites.
ControlRegistryEntry.uids moved to ugui.<type>_uids
UID counts are now exposed through control-specific helpers, such as ugui.button_uids() instead of registry entries.
Dynamic UID changes
The menu control now has a static UID count, use just ugui.menu_uids().
The tabcontrol now requires only an item count to be passed in to the UID computation function, not an entire control instance.
ugui.control and ControlType removed
ugui.control and the ControlType type have been removed; use the specific control functions (e.g. ugui.button or ugui.label) instead.
If you need dynamic runtime lookup, write your own map of type strings to control functions.
Control type renamed to UguiControl (non-runtime breaking)
The Control type has been renamed to UguiControl.
Control registry removed (control authors only)
The control registry has been removed. Controls are now implemented using custom placement functions with per-instance callbacks.
This only affects API consumers who implement their own controls.
ControlRegistryEntry.setup moved to control placement
Use the fourth argument to ugui.internal.control in the contro's placement function instead.
ControlRegistryEntry.hittestable removed
Apply the default value in the control's placement function instead.
ControlRegistryEntry.added removed
There is no built-in alternative to this API. Try to write controls in a way that doesn't require this kind of lifecycle notification.
ControlRegistryEntry.validate removed
If you need to implement control validation, do it in the control's placement function, e.g.:
ControlRegistryEntry.logic moved to Control.get_return_value
Control logic is now provided by the per-instance Control.get_return_value callback instead of ControlRegistryEntry.logic.
ControlRegistryEntry.draw moved to Control.draw
Draw control graphics in the Control.draw callback instead.
💡 Tips
Control nesting
Controls can now be nested, with child controls being positioned relative to their parents.
Many UI patterns benefit from establishing a hierarchy, so you'll want to check and introduce hierarchies where appropriate.
You can configure clipping behavior with Control.clip_children.
Some properties on Control are now inherited, read the API definition for more details.
Control types
The valid set of control types is no longer defined by ugui (cf. removal of ugui.control and ControlType).
Adding controls of arbitrary type to the registry is now fully supported, but note that this part of the public API is more volatile.
Context menus
Context menus are now supported natively using Control.context_menu.
If you were reimplementing them by hiding/showing menus based on mouse clicks, you can remove that in favor of the built-in functionality.
tabcontrol content
Thanks to the new control nesting, you can now display tabcontrol content simply by providing it with a child callback:
local result = ugui.tabcontrol({
uid = ...,
rectangle = ...,
items = ...,
selected_index = ...,
}, function()
ugui.panel({
uid = ...,
rectangle = {
x = 0,
y = 0,
width = 100,
height = 100,
},
fill = '#FF00FF55',
})
end)
Note that there is no way to determine the available dimensions for the content, as result is not available inside the callback.