Aceeri / citrine

Amethyst's soon-to-be UI toolkit
Other
16 stars 0 forks source link

Layout and Parent-Child Element Positioning #3

Open Aceeri opened 6 years ago

Aceeri commented 6 years ago

Positioning

For reference this the current component for position (The documentation is a bit off on them since I rethought it a bit) https://github.com/Aceeri/citrine/blob/master/src/class.rs#L88

UI elements should be able to be positioned relative to the parent depending on a couple rules:

Layout

Each layout should use its own Component and being attached to a UI element, which will then mess with the child entities' positions. The built-in Parent-Child system should handle the Free/Absolute variants by default and for Relative UI elements it should first default the position to a Free-esque position (no layout) and let the layout systems do the rest.

Xaeroxe commented 6 years ago

This looks great, make sure to also keep in mind the width and height of the elements. Personally I think the absolute positioning has limited utility and probably only serves to complicate the code without providing new features.

Xaeroxe commented 6 years ago

Also: keep in mind some people are going to want to use floats between 0 and 1 for percentage based positioning, sort of similar to the use of % in CSS

Aceeri commented 6 years ago

@Xaeroxe That will probably be handled with the Coordinate struct, which is just an abstraction over pixels and percentile and such.