Expose baseline on TextLayout, add Baseline alignment to Flex#1295
Merged
Expose baseline on TextLayout, add Baseline alignment to Flex#1295
Conversation
d57d9a7 to
d171d9c
Compare
raphlinus
approved these changes
Oct 13, 2020
Contributor
raphlinus
left a comment
There was a problem hiding this comment.
I'm going to approve this. I have some concerns about how well it will work in a multi-line configuration, but also I experimented a bit with the flex demo and find it works nicely for single line, and that's probably a good enough goal for this cycle; it's hugely useful for the kind of UI stuff we're doing, where labels are realistically single line.
Thanks!
druid/src/text/layout.rs
Outdated
| @@ -1,5 +1,6 @@ | |||
| // Copyright 2020 The xi-editor Authors. | |||
| // | |||
| ///// Return the distance from | |||
This introduces the idea of baseline alignment as a component of layout. During their `layout` calls, widgets can specify their baseline_offset, which is the distance from the bottom of their reported size to their baseline. Generally, the baseline will be derived from some text object, although widgets that do not contain text but which appear next to widgets that do can specify an arbitrary baseline. This also adds CrossAxisAlignment::Baseline to Flex; this is only meaningful in a Flex::row, in which case it aligns all of its children based on their own reported baselines. The best place to play around with this code is in examples/flex.rs.
d171d9c to
2230b23
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
This introduces the idea of baseline alignment as a component
of layout.
During their
layoutcalls, widgets can specify their baseline_offset,which is the distance from the bottom of their reported size to their
baseline.
Generally, the baseline will be derived from some text object,
although widgets that do not contain text but which appear next
to widgets that do can specify an arbitrary baseline.
This also adds CrossAxisAlignment::Baseline to Flex; this is
only meaningful in a Flex::row, in which case it aligns all of
its children based on their own reported baselines.
The best place to play around with this code is in examples/flex.rs.
This is also the last of the major outstanding text stuff??