feat!: layout system and tree scene hierarchy - #83
Closed
abart27 wants to merge 102 commits into
Closed
Conversation
UID `0` is now reserved for the root panel.
abart27
marked this pull request as draft
May 10, 2026 19:14
Open
also removes the hacks for other controls, which breaks them but we're fixing that
Member
Author
|
The dynamic layout part (stacks, scrollviewers, etc...) is blowing up in complexity. For that reason, we'll delay the implementation of that functionality indefinitely. For now, this PR will only provide basic layout functionality with no dynamic layouts. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TODO
Breaking Changes
UID slot changes
Various controls now use more UID slots due to internal changes.
button- 2 slotstoggle_button- 2 slotscarrousel_button- 4 slotscombobox- 9 slotsspinner- 9 slotstabcontrol-n(children) * 2 + 1Tip: if you find yourself having to fix UID-related breakage often, space out the UIDs in your scene by
20.Reserved UID
UID
math.minintegeris now reserved by ugui and can't be used by library consumers. If you're using that UID, change it to something else.Control references
While not explicitly documented anywhere, previous versions of ugui somewhat tolerated holding on to a
Controlinstance after it's consumed byugui.control(or one of the control placing functions likeugui.button).This behavior is now out the window: reading back from control tables after they're consumed is undefined behavior.
Barely any library consumers rely on this behavior, but if you do, you can re-architect your script to store data in a safe local context instead of smuggling it through ugui.
Templated controls
ugui.controlas well as all control spawning functions (e.g.ugui.button) now have an additional parameter,fn.fnis a callback that's called immediately after the control was placed. Any controls placed within the callback will be parented to the newly placed control.It's important to note that the controls themselves decide when
fnis called. Therefore, it behaves more like a slot, similar to WPF'sContentPresenter.Many controls now place children by default, but this isn't something public API consumers should care about.
Layout
A rudimentary layout system has been introduced: controls can specify how their children are laid out, with the only layout modes being
relativeandstack.background,border, andborder_widthIt's now possible to specify a
background,border, andborder_widthfor any control.These are drawn before handing over to the control-specific drawing code and are particularly useful when used together with a
panel.Control.rectangleThe
Control.rectanglefield has been deprecated.Any usages of it will be internally translated to margins and sizes (see below).
Control positioning and sizing
The positioning and sizing of controls is now controlled via the
Control.margin,Control.align,Control.size, andControl.paddingproperties. See the docs.Note the
Smart[...]units.Units
A unit system has been introduced.
If you're familiar with CSS units, these are basically a barebones version of that. Here are the docs:
I understand that the type design for this isn't the most efficient or idiomatic in Lua. Cleaner design would be some lightweight factory that generates these in a more type-safe manner.
But I went for this because it was the simplest and nicest for now. I'm not particularly attached to this design, so fire away lol