-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
Replace UiRect
with distinct Margin
, Padding
, Position
and Border
types
#7710
Conversation
…o ui-rect-split
Very much in favor of this direction: much clearer, and the distinct defaults make it obvious that these should be split. |
Being able to split up the documentation is really nice I think. I'm not quite sure whether it's better to use traits or macros to implement the common functions. I used a trait basically only because it's been a while since I wrote any macros and I'd have had to look up the syntax again before I started. |
I think the trait will probably be easier to maintain: lots of folks are more comfortable with them and they're easier to read. No strong feelings though. |
Ping @nicoburns for review (you're not in the Bevy org so I can't request it directly) :) |
No me neither. I guess it doesn't really matter, the implementation would be easy to replace later if anyone hates it. |
This seems like a reasonable solution. My only concern with separate types would be having to import them all. But this way does have the advantage of having the 1:1 naming with the fields which could make importing easier. I definitely agree that For reference, in Taffy:
Ultimately I don't think end users should be expected to touch these types at all. I think we should:
so that you can do: .with_style(|style| {
style
.margin_left(5)
.margin_vertical(10)
.margin_all(20);
}) And all the documentation can live on the |
I think it would be better to wait for an actual use case to split those, then do them as needed |
I strongly agree that the current solution of I'm not yet sure if I would prefer entirely separate types like this PR introduces or an
I think not having a default implementation on the general type is a good idea if we go that route, the default can then be defined on the default of
This is an interesting concept and I think quite attractive from the UX point of view. Personally, I think I'd prefer builder patterns though. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am in favour of this change, but I do believe Position
should be named Inset
instead as that is the correct term for the functionality according to CSS specification: See https://developer.mozilla.org/en-US/docs/Web/CSS/inset
Having used bevy's UI a bit more, I'm now in favour of this PR. However, in There are also two other naming inconsistencies compared with CSS:
Finally, I would be really keen on the constructor methods for these types accepting bare floats and integers which are interpreted as being |
Personally, would prefer (I'm sorry if this is a necro post T_T) |
No no, it's not even dead really, I closed this because it doesn't make as much sense by itself, so I made a new PR #8096 that combines all the related changes to Val and UiRect. |
Objective
Problems with
UiRect
:UiRect
is confusingly named (nothing it represents is a rectangle).UiRect
s representing positions should have their fields set toAuto
by default, the others0.
UiRect
fields are meaningless (at the moment at least, may change).UiRect
has to explain its different behaviour for each of the four use cases.relevant discussion at #7656
Solution
Split
UiRect
into four distinct types, as it represents four very different things (padding, borders and margins might seem similar but they are actually different in sometimes very confusing ways).Implement the
UiRect
constructor functions using macros.Changelog
Removed
UiRect
.Added the
Margin
,Padding
,Position
andBorder
types.Implemented the common functionality with macros.
Migration Guide
UiRect
has been removed and is replaced by theMargin
,Padding
,Position
andBorder
types.