Skip to content

Expose baseline on TextLayout, add Baseline alignment to Flex#1295

Merged
cmyr merged 1 commit intomasterfrom
baseline-alignment
Oct 13, 2020
Merged

Expose baseline on TextLayout, add Baseline alignment to Flex#1295
cmyr merged 1 commit intomasterfrom
baseline-alignment

Conversation

@cmyr
Copy link
Member

@cmyr cmyr commented Oct 8, 2020

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.

Screen Shot 2020-10-08 at 6 20 10 PM
Screen Shot 2020-10-08 at 6 20 21 PM
Screen Shot 2020-10-08 at 6 20 28 PM
Screen Shot 2020-10-08 at 6 20 36 PM

This is also the last of the major outstanding text stuff??

@cmyr cmyr mentioned this pull request Oct 9, 2020
7 tasks
@cmyr cmyr force-pushed the baseline-alignment branch from d57d9a7 to d171d9c Compare October 9, 2020 15:05
@cmyr cmyr mentioned this pull request Oct 9, 2020
12 tasks
@cmyr cmyr added the S-needs-review waits for review label Oct 12, 2020
Copy link
Contributor

@raphlinus raphlinus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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!

@@ -1,5 +1,6 @@
// Copyright 2020 The xi-editor Authors.
//
///// Return the distance from
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems misplaced.

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.
@cmyr cmyr force-pushed the baseline-alignment branch from d171d9c to 2230b23 Compare October 13, 2020 19:57
@cmyr cmyr merged commit 76baabd into master Oct 13, 2020
@cmyr cmyr deleted the baseline-alignment branch October 13, 2020 21:07
@maan2003 maan2003 removed the S-needs-review waits for review label May 3, 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.

3 participants