Skip to content

Conversation

jason-simmons
Copy link
Member

Fixes #4478

@jason-simmons
Copy link
Member Author

@abarth

canvas.saveLayer(bounds, new Paint());
else
canvas.save();
canvas.save();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we still need to do a saveLayer here if we need to generate the fade effect because the fade effect needs to blend the text against the background.

Copy link
Contributor

Choose a reason for hiding this comment

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

Probably _overflowShader is the thing to change the check to.

Copy link
Member Author

Choose a reason for hiding this comment

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

done

@abarth
Copy link
Contributor

abarth commented Sep 27, 2016

LGTM

double textScaleFactor: 1.0
}) : _text = text, _textAlign = textAlign, _textScaleFactor = textScaleFactor {
double textScaleFactor: 1.0,
ui.TextOverflow textOverflow,
Copy link
Contributor

Choose a reason for hiding this comment

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

please re-export this so that consumers don't have to get it from dart:ui

Copy link
Member Author

Choose a reason for hiding this comment

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

That would conflict with the TextOverflow enum in the framework package

Copy link
Contributor

Choose a reason for hiding this comment

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

ok well we definitely shouldn't have both if they're both going to be exposed in the framework API.

@Hixie
Copy link
Contributor

Hixie commented Sep 27, 2016

in general i'd like to not see ui.OverflowEffect anywhere in the framework code.

edit: as in, it should just be OverflowEffect, the same way we reexport Color.

@jason-simmons
Copy link
Member Author

TextOverflow is provided by the framework and includes overflow effects that are rendered on the framework side (i.e. fade).

ui.TextOverflow only covers overflow policies that are implemented within the engine

@Hixie
Copy link
Contributor

Hixie commented Sep 27, 2016

Is ui.TextOverflow only used at the lowest levels, like ui.TextStyle? It looks like you have some classes in the framework that take ui.TextOverflow.

@Hixie
Copy link
Contributor

Hixie commented Sep 27, 2016

I think the best way to resolve this really is to have the engine take a string instead of this enum. That would remove any API conflict.

@Hixie
Copy link
Contributor

Hixie commented Sep 27, 2016

(the framework would then just pass in the ellipsis character as the string value when its enum is set to the ellipsis value.)

@jason-simmons
Copy link
Member Author

ui.TextOverflow is used by low-level text painting APIs that talk to the engine API (TextPainter and TextStyle/ParagraphStyle)

TextOverflow is used by widgets and render objects (RichText and RenderParagraph)

@Hixie
Copy link
Contributor

Hixie commented Sep 28, 2016

TextPainter is not a low-level API. It's the API you use when you paint on a canvas from user code. It shouldn't use any non-reexported dart:ui types in its API.

@jason-simmons
Copy link
Member Author

Updated for the new engine API.

PTAL

double textScaleFactor: 1.0
}) : _text = text, _textAlign = textAlign, _textScaleFactor = textScaleFactor {
double textScaleFactor: 1.0,
String ellipsis
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: these days, when you have a list like this, stick a trailing comma in there so future changes don't need to edit the previous line

@@ -80,6 +81,18 @@ class TextPainter {
_needsLayout = true;
}

/// The string used to ellipsize overflowing text.
Copy link
Contributor

Choose a reason for hiding this comment

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

Add more documentation, for example:

  • Is providing a string sufficient to cause ellipsising?
  • Is there a difference between null and the empty string? (If not, consider disallowing one just to remove that axis of freedom.)
  • What are the performance implications of this feature?
  • What are edge cases you might run into, and how are they handled? e.g. if the ellipsising string is wider than the container, if it contains unbalanced bidi characters, combining characters, or explicit line breaks, that kind of thing.
  • How is the ellipsising done? (clipping truncation vs character truncation vs ligature truncation etc)

Weave all these answers into a coherent narrative. :-)

Copy link
Member Author

Choose a reason for hiding this comment

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

Clarified the docs and added an assert for empty ellipsis strings

(I don't know the internals of the text rendering engine well enough to precisely describe its behavior)

@@ -162,7 +175,11 @@ class TextPainter {
if (_paragraph == null) {
ui.ParagraphBuilder builder = new ui.ParagraphBuilder();
_text.build(builder, textScaleFactor: textScaleFactor);
ui.ParagraphStyle paragraphStyle = _text.style?.getParagraphStyle(textAlign: textAlign, textScaleFactor: textScaleFactor);
ui.ParagraphStyle paragraphStyle = _text.style?.getParagraphStyle(
textAlign: textAlign,
Copy link
Contributor

Choose a reason for hiding this comment

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

we usually do a two-character indent here. we'll probably change at some point to match typical dart style but for now let's keep the code consistent.

ui.ParagraphStyle paragraphStyle = _text.style?.getParagraphStyle(
textAlign: textAlign,
textScaleFactor: textScaleFactor,
ellipsis: _ellipsis
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: trailing comma

return new ui.ParagraphStyle(
textAlign: textAlign,
fontWeight: fontWeight,
fontStyle: fontStyle,
fontFamily: fontFamily,
fontSize: fontSize == null ? null : fontSize * textScaleFactor,
lineHeight: height
lineHeight: height,
ellipsis: ellipsis
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

text: text,
textAlign: textAlign,
textScaleFactor: textScaleFactor,
ellipsis: overflow == TextOverflow.ellipsis ? _kEllipsis : null
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

@Hixie
Copy link
Contributor

Hixie commented Oct 1, 2016

LGTM

@jason-simmons jason-simmons merged commit 21acf22 into flutter:master Oct 3, 2016
aam added a commit to aam/flutter that referenced this pull request Aug 29, 2018
Changes since last roll:
```
5613939 Roll src/third_party/skia 7ba1d64f0706..5f0726b01019 (12 commits) (flutter#6104)
47a1ce0 Allow embedders to set the root surface transformation. (flutter#6085)
```
aam added a commit that referenced this pull request Aug 29, 2018
* Roll engine to 5613939.6

Changes since last roll:
```
5613939 Roll src/third_party/skia 7ba1d64f0706..5f0726b01019 (12 commits) (#6104)
47a1ce0 Allow embedders to set the root surface transformation. (#6085)
```

* Roll engine to f3ff83a. (dart roll).

* Add const

* Add ignore analyzer prefer_const_constructors_in_immutables
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 15, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Text overflow with ellipsis also has fade
3 participants