Replies: 2 comments 7 replies
-
Can you expand on the layout engine a little, you keep talking about it without mentioning what it does. From what I understand it's responsible for deciding where on the screen stuff is rendered. |
Beta Was this translation helpful? Give feedback.
-
I need to try the bevy ui since I haven't tried it yet. But I have a concern, you suggest having all the bevy ui from tools as children of a single parent node. How are regions defined? GenericUiModalTool has location and rectangle width & height. ModalDevUI doesn't have that, how do you enforce UI to fit within a region/zone at a certain location like with GenericUiModalTool? |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Motivation
The GitHub pull request (bevyengine/rfcs#77) offers a unified way to register and enable/disable dev tools in Bevy.
But part of the dev tools may want to display debugging information on the screen or get input from developers. For example, the FPS overlay displays the number of FPS in the bottom right corner, and the entity inspector may want to show editable fields and buttons near the right edge of the screen. Or the real-time statistics render graph will want to display rendering times information somewhere in the static area. If multiple dev_tools claim the same area of the screen to display information, it will be messy. Dev tools can and will conflict over displaying information. Accordingly, the question not solved and not asked in my opinion in RFC is "how is it planned to organize the location of the displayed information of dev modules?"
There's no silver bullet
Already after the RFC was published, several ideas have been proposed to distribute UI from each dev-tool:
It seems to me that each of the proposed approaches has its place for being used effectively, and there is no silver bullet for solving the UI problem in one way. Different use cases require different UI, layouts and styles.
For this reason, I suggest finding some unified way to organize place for dev tool UIs
Proposed solution
Layout engine
It is proposed to introduce the concept of layout engine, which is a plugin that:
DevToolsListPlugin
system described below)Each implemented layout engine must inherit the layout engine trait:
This way each layout engine can manipulate a given set of dev tools.
LayoutEngine can be designated as the main one, and all new added dev tools will be registered in it automatically via the fn register_dev_tool(&mut self, type_id: TypeId) method;
I propose to declare some layout engine as the main one in the following way
That said, judging from the trait, the layout engine has no special requirements and can technically be anything, as it is primarily a concept. To which, however, I propose to allow the use of the api for dev tool ui
Dev tool UI trait
Since the main purpose of the layout will be to reorganise nodes, it is proposed to make two traits for bevy_ui based dev tools and for non bevy_ui solutions:
Thus the proposed traits can provide basic manipulation over the UI of the dev tools. To demonstrate the capabilities of such an API, I suggest you consider creating a very simple layout in the form of a vertical list
Example (Vertical list plugin)
First, let's implement the plugin which will be responsible for creating and managing the vertical list:
Next, let's create a vertical list of dev tools:
The function which updates the dev tools list
The function which initializes an empty vertical list with a root node and adds it to the app state
As you can see in a few lines the proposed approach allows you to make a custom layout with arbitrary features via a unified api in a small number of lines.
Summary
The main idea is to propose the following concepts:
Beta Was this translation helpful? Give feedback.
All reactions