-
Notifications
You must be signed in to change notification settings - Fork 9
Enhance layout engine with RTL support and performance optimizations #36
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
Merged
Changes from 18 commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
ba57c6c
Add Direction (RTL) support to layout engine
geom3trik c21de08
Flip horizontal alignment for RTL direction
geom3trik a8df548
Add wrapping support
geom3trik 9b0ca5a
Re-run relative children with final constraints
geom3trik bd28508
Update layout.rs
geom3trik 09609e5
Optimize layout computations and child traversal
geom3trik a572e6d
Record measured size and avoid redundant layout
geom3trik 827446a
Cache child layout constraints to avoid relayout
geom3trik 6173bd9
Optimize layout iteration and cross-stretch
geom3trik 8e5380c
Add layout memoization and steady-state bench
geom3trik 22a250a
Add cross-pass layout memoization with revisioning
geom3trik 1761f3c
Use generation-based layout memoization
geom3trik 05a3339
Handle RTL for inline layouts
geom3trik b34cb57
Don't apply parent padding to absolute children
geom3trik 0954fea
Improve layout logic, API updates and cleanups
geom3trik 531ed7a
Remove layout-result memoization hooks and relayout caching
geom3trik 55d2749
fmt
geom3trik a42258e
Use padding-box for absolute children; fix RTL
geom3trik bab9847
Swap absolute child space for RTL layouts
geom3trik File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| mod common; | ||
| use common::*; | ||
|
|
||
| fn main() { | ||
| let mut world = World::default(); | ||
|
|
||
| let root = world.add(None); | ||
| world.set_width(root, Units::Pixels(600.0)); | ||
| world.set_height(root, Units::Pixels(600.0)); | ||
| world.set_padding(root, Units::Pixels(20.0)); | ||
| world.set_layout_type(root, LayoutType::Column); | ||
| world.set_vertical_gap(root, Units::Pixels(20.0)); | ||
| world.set_alignment(root, Alignment::TopLeft); | ||
|
|
||
| // Row wrapping example | ||
| let row_wrap_container = world.add(Some(root)); | ||
| world.set_width(row_wrap_container, Units::Stretch(1.0)); | ||
| world.set_height(row_wrap_container, Units::Auto); | ||
| world.set_layout_type(row_wrap_container, LayoutType::Row); | ||
| world.set_wrap(row_wrap_container, LayoutWrap::Wrap); | ||
| world.set_horizontal_gap(row_wrap_container, Units::Pixels(10.0)); | ||
| world.set_vertical_gap(row_wrap_container, Units::Pixels(10.0)); | ||
| world.set_alignment(row_wrap_container, Alignment::TopLeft); | ||
|
|
||
| // Add items to row wrap container | ||
| for _i in 0..6 { | ||
| let item = world.add(Some(row_wrap_container)); | ||
| world.set_width(item, Units::Pixels(80.0)); | ||
| world.set_height(item, Units::Pixels(60.0)); | ||
| } | ||
|
|
||
| // Column wrapping example | ||
| let col_wrap_container = world.add(Some(root)); | ||
| world.set_width(col_wrap_container, Units::Pixels(200.0)); | ||
| world.set_height(col_wrap_container, Units::Pixels(250.0)); | ||
| world.set_layout_type(col_wrap_container, LayoutType::Column); | ||
| world.set_wrap(col_wrap_container, LayoutWrap::Wrap); | ||
| world.set_horizontal_gap(col_wrap_container, Units::Pixels(10.0)); | ||
| world.set_vertical_gap(col_wrap_container, Units::Pixels(10.0)); | ||
| world.set_alignment(col_wrap_container, Alignment::TopLeft); | ||
|
|
||
| // Add items to column wrap container | ||
| for _i in 0..6 { | ||
| let item = world.add(Some(col_wrap_container)); | ||
| world.set_width(item, Units::Pixels(60.0)); | ||
| world.set_height(item, Units::Pixels(50.0)); | ||
| } | ||
|
|
||
| // RTL wrapping example | ||
| let rtl_wrap_container = world.add(Some(root)); | ||
| world.set_width(rtl_wrap_container, Units::Pixels(300.0)); | ||
| world.set_height(rtl_wrap_container, Units::Auto); | ||
| world.set_layout_type(rtl_wrap_container, LayoutType::Row); | ||
| world.set_direction(rtl_wrap_container, Direction::RightToLeft); | ||
| world.set_wrap(rtl_wrap_container, LayoutWrap::Wrap); | ||
| world.set_horizontal_gap(rtl_wrap_container, Units::Pixels(10.0)); | ||
| world.set_vertical_gap(rtl_wrap_container, Units::Pixels(10.0)); | ||
| world.set_alignment(rtl_wrap_container, Alignment::TopLeft); | ||
|
|
||
| // Add items to RTL wrap container | ||
| for _i in 0..4 { | ||
| let item = world.add(Some(rtl_wrap_container)); | ||
| world.set_width(item, Units::Pixels(100.0)); | ||
| world.set_height(item, Units::Pixels(50.0)); | ||
| } | ||
|
|
||
| root.layout(&mut world.cache, &world.tree, &world.store, &mut ()); | ||
|
|
||
| render(world, root); | ||
| } |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.