-
Notifications
You must be signed in to change notification settings - Fork 570
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
Expose word wrap in TextLayout and Label #1195
Conversation
d598323
to
a3d1b41
Compare
This looks really good! (Looking at the pics not code! ) |
a3d1b41
to
ca40deb
Compare
ca40deb
to
832b17e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See inline, I think this PR sets off a much deeper discussion than was planned...
This should get a changlog entry. |
I'm going to rework this to have a different API. |
9a3a716
to
ce1cbd8
Compare
Okay, I've reworked this significantly so that instead of exposing an explicit wrap-width in label, we expose a |
That looks glorious |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good, thanks!
With this patch, the TextLayout object can now be given a width for wrapping words. This is exposed in the Label via a new LineBreaking enum, with three options. With LineBreaking::WordWrap, the TextLayout's wrap-width is set to the maximum width of the label's BoxConstraints, and lines are broken appropriately. The other two options (LineBreaking::Overflow and LineBreaking::Clip) both disable line-breaking; in the former case if text exceeds the width of the label it is painted outside of the label's bounds, and in the latter case the text is clipped to the bounds of the label. It would be nice if, in the clipping case, we could use a gradient mask or something to fade the edges of the clipped text, but I don't believe this is currently possible in piet. A simple alternative of drawing a gradient from (transparent -> label background color) doesn't work, because label's do not have an explicit background color, which I think is also correct. progress on #1192
ce1cbd8
to
7261854
Compare
With this patch, the TextLayout object can now be given a width
for wrapping words. This is exposed in the Label via a new
LineBreaking enum, with three options. With LineBreaking::WordWrap,
the TextLayout's wrap-width is set to the maximum width of the label's
BoxConstraints, and lines are broken appropriately. The other two
options (LineBreaking::Overflow and LineBreaking::Clip) both disable
line-breaking; in the former case if text exceeds the width of
the label it is painted outside of the label's bounds, and in the
latter case the text is clipped to the bounds of the label.
It would be nice if, in the clipping case, we could use a gradient
mask or something to fade the edges of the clipped text, but I don't
believe this is currently possible in piet. A simple alternative
of drawing a gradient from (transparent -> label background color)
doesn't work, because label's do not have an explicit background color,
which I think is also correct.
progress on #1192
![Screen Shot 2020-09-10 at 12 08 45 PM](https://user-images.githubusercontent.com/3330916/92760209-709c7a80-f35e-11ea-97e8-8fbac52a2a25.png)
![Screen Shot 2020-09-10 at 12 08 50 PM](https://user-images.githubusercontent.com/3330916/92760129-667a7c00-f35e-11ea-94ec-bcc6cf20abb1.png)
![Screen Shot 2020-09-10 at 12 10 17 PM](https://user-images.githubusercontent.com/3330916/92760378-97f34780-f35e-11ea-8e55-a2e67e9fa695.png)
![Screen Shot 2020-09-10 at 12 10 23 PM](https://user-images.githubusercontent.com/3330916/92760392-9b86ce80-f35e-11ea-8ff2-44a950b9ec51.png)