Merge Style properties into Node. Use ComputedNode for computed properties.#15975
Merge Style properties into Node. Use ComputedNode for computed properties.#15975cart merged 5 commits intobevyengine:mainfrom
Conversation
|
In #15898 I said this should wait until after Bevy 0.15. I've re-evaluated the cost:benefit of doing this now and I think we should merge this for Bevy 0.15. I was wrong. The wins here are big and the cost of porting is lower than I expected. I had it in my head that we needed to sort out the more controversial "Style breakup" problems as part of this, but I don't really see the need. Doing this now actually makes a future breakup easier as it can be framed as "just" moving fields out of |
|
I'm on board with doing this now :) I don't think this is the end game, but it's much nicer as an interim solution. |
alice-i-cecile
left a comment
There was a problem hiding this comment.
The semantics are much clearer, I'm extremely glad to have cleared up the Style name, and the reduced boilerplate is nice.
I don't think the migration will be hard at all: rename uses of Node to ComputedNode, then rename uses of Style to Node.
| /// - [MDN: Basic Concepts of Grid Layout](https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout) | ||
| /// - [A Complete Guide To CSS Grid](https://css-tricks.com/snippets/css/complete-guide-grid/) by CSS Tricks. This is detailed guide with illustrations and comprehensive written explanation of the different CSS Grid properties and how they work. | ||
| /// - [CSS Grid Garden](https://cssgridgarden.com/). An interactive tutorial/game that teaches the essential parts of CSS Grid in a fun engaging way. | ||
| /// |
There was a problem hiding this comment.
Feel like there needs to be a brief breakdown of the role of each required component in the doc comments for Node. Goes outside of the scope of this PR a bit though maybe.
tim-blackbird
left a comment
There was a problem hiding this comment.
LGTM, just some missed variable names left
You may want to adjust these docs as well
|
Ah wait missed a couple of non-code comment things. |
Objective
Continue improving the user experience of our UI Node API in the direction specified by Bevy's Next Generation Scene / UI System
Solution
As specified in the document above, merge
Stylefields intoNode, and move "computed Node fields" intoComputedNode(I chose this name over something likeComputedNodeLayoutbecause it currently contains more than just layout info. If we want to break this up / rename these concepts, lets do that in a separate PR).Stylehas been removed.This accomplishes a number of goals:
Ergonomics wins
Specifying both
NodeandStyleis now no longer required for non-default stylesBefore:
After:
Conceptual clarity
Stylewas never a comprehensive "style sheet". It only defined "core" style properties that allNodesshared. Any "styled property" that couldn't fit that mold had to be in a separate component. A "real" style system would style properties across components (Node,Button, etc). We have plans to build a true style system (see the doc linked above).By moving the
Stylefields toNode, we fully embraceNodeas the driving concept and remove the "style system" confusion.Next Steps
Migration Guide
Move any fields set on
StyleintoNodeand replace allStylecomponent usage withNode.Before:
After:
For any usage of the "computed node properties" that used to live on
Node, useComputedNodeinstead:Before:
After: