-
-
Notifications
You must be signed in to change notification settings - Fork 978
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New UI Layout System #2641
Comments
Looks like every parent would effectively be a stack panel, how do you think Grids would work under this new system ? In the video you've attached, we can see that the elements have both a I'm not sure I understood what the cross axis is for, I'm afraid the name/description is a bit too obtuse We could build an upgrader to take care of the breaking changes on the assets themselves, while other properties could temporarily remap to similar concepts in this new layout design with an added obsolete flag. |
I imagine that they would work much the same as they do now, with each row and column defined using a
I started it as a prototype to test the layout system, so to avoid ldealing with compile errors by changing the types of
The cross axis is the non-main layout axis of the stack panel. So if a stack panel arranges children vertically, the cross axis would be the horizontal axis. |
@Eideren This proposed new system, along with the Depth Removal PR and the Styling Changes proposal all being fairly breaking changes to the UI, with many having limited ability to migrate. And the UI system being used as little as it is. I wonder if it is really worth trying to prevent breaking changes at the cost of the API (like having to introduce new Opting instead for just a written guide for updating (blog post or page on the docs?). And only including the changes in the next major release. Asking because I would like to clean up my prototype and open a draft PR so others can actually try it out if they so desire, and to avoid just dropping a very large PR out of nowhere. But not sure what is okay to remove/change if we are going to try to support upgrading. Let me know what you think (or others too!), thanks! :D |
There is a mechanism to write asset updaters. It can be used to upgrade an old system to a new one. It doesn't cover breaking change in code though. In any case, breaking change should be kept to a major version of Stride. Maybe we should create a new branch for all UI related stuff (and have all those PRs target that branch), which will let us more time to test out regressions and breaks. |
Oh nice! Is there a class I could look at for an example (a quick search of the code base didn't reveal anything really)? And does it require the old properties to be present?
Yeah my intentation has been that these changes would be for a major version because they are breaking.
That seems like a good idea to me |
Have a look at the AssetUpgraderAttribute and references to it. Do you happen to have ideas on how we could improve the layout system to make supporting different screen sizes easier ? Building the UI around a static ratio doesn't work too well with the different screen ratios we have, especially when the game's window is resized. I know Unity has a weird anchor system were UI elements can be attached to screen edges, this makes it easier for certain ui types like the player's own health bars, spell bars and such. It's a bit obtuse though, and really works best with a fixed resolution. For example, it would be nice to fix the following case: a container with a specific size which should scale up to fit snugly inside the viewport, with some margin if at all possible. It would take the smallest size between the viewport's X/Y size and scales itself to match it in that axis while the other axis scales as well but should keep the same ratio. |
Ahh, not sure why I didn't see it when I searched eariler, thanks!
Yeah, I think the Percentage, and Flex can help a lot with that. You could combine a flex width with a maximum size to let things scale to take up as much space as they can up to a point. While being able to be 'squashed' when they have less room.
Stride has the For the ratio, I was thinking either a content container that specifically does ratio scaling from the parent's size, or a property on |
Yeah, that was one of the reason why I liked your idea of the flex and percentage stuff. |
Overview
The current UI layout system is has limited layout abilities, inconsistent behaviors, and un-needed properties. These make it clunky and slow to create complex UIs with. This proposes a new layout system using a single type that can be a fixed size, flex or percent of parent.
Current Issues
UIElement
has vertical and horizontal alignment properties that influence size and position.UIElement
has a default size property for each axis.MeasureOverirde()
both areNaN
.UIElement
has margins property for each side of the element.Proposed System
Introduce a new
Length
value type with three modes:Use
Length
for all spacing and sizing properties (Width
,Height
,Padding
, etc.).Refactored/Replace
StackPanel
Orientation
– Defines the layout axis.SpaceBefore
/SpaceAfter
– Controls space before/after the first/last element along the main axis.SpaceBetween
– Defines space between elements along the main axis.DefaultCrossAxisSpaceBefore
/After
– Default space between children between a child and the edges of the panel along the cross axis.CrossAxisSpaceBefore
/After
(attached property) – The cross axis spacing defined per-child.Other elements (
Canvas
,ContentControl
,Grid
, etc.) would see similar changes.New System Rules
Removals
Flex
.NaN
size.Conclusion
This system would allow much more versatile layouts than are currently possible, and keeps to a set of simple, predictable rules that are reused through the system.
Here is a prototype of the changes to the StackPanel showing the
Length
based properties.Stride.GameStudio_2025-02-15_10-55-21.mp4
This would either have to be a very breaking change, or introduce a lot of redundant properties and elements. For example, changing
public float Width {get; set;}
topublic Length Width {get; set; }
would be desired, but breaking. Could introduce a new property, but then you have 2 sets of widths (and lots of others) which would add to the bloat.Please let me know if you have any thoughts, like or dislike it, questions etc!
The text was updated successfully, but these errors were encountered: