Skip to content
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

Layout::layout method and layout visitor, make_layout macro #259

Merged
merged 53 commits into from
Dec 9, 2021
Merged

Conversation

dhardy
Copy link
Collaborator

@dhardy dhardy commented Dec 9, 2021

Continues revisions from #258, this time adding a new Layout::layout method which can be used to replace all other layout method impls (excepting possibly draw), most of the time. Incomplete (spatial_nav, for which it makes sense to update WidgetId first).

It is very likely that some renaming will happen a little later (since it's inconvenient having two things called Layout).

Layout::layout does not make size_rules, set_rect etc. redundant; some special cases will continue to implement these directly (e.g. ListView).

Unknown: whether the visitor system should allow user extension. So far this doesn't look sufficiently useful (since most special cases affect only a single widget, and then one can make a widget for this special case).

Test in examples/counter; this is currently quite hacky
Rationale 1: one less field needed in custom structs.
Rationale 2: allows simpler layout visitor construction?

Benchmarks: run examples/data-list with various numbers of
entries, timing layout::sizer::apply_rect.
Debug results: negligible change.
Release results: 2-5% increase in time.
Release after removing alignment tokens: <2% increase.
Unused and confusing (also call f on self)
This allows using the layout visitor
Also some tweaks to examples/clock
This is not really desirable but not too problematic.
Motivation: layout visitor can now generate draw.
These are not (x, y) coordinates, so it's better to take
inspiration from reading order (big endian) and intuition.
We already had row-before-column more often than not!
position and alignment specifiers within child #[widget]
attributes.
This is more consistent with other widgets
Manual implementations: -3 +4
At least the default is more likely to behave as expected
and there is a warning when this is not the case.
@dhardy dhardy merged commit 0c6b51f into master Dec 9, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant