Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
f35ad647
Commit
f35ad647
authored
Oct 27, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #1814 from abarth/fix_right_align
Right-aligned text paints offscreen sometimes
parents
a13147d0
69a0689a
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
21 deletions
+20
-21
text_painter.dart
packages/flutter/lib/src/painting/text_painter.dart
+6
-5
editable_paragraph.dart
packages/flutter/lib/src/rendering/editable_paragraph.dart
+4
-6
paragraph.dart
packages/flutter/lib/src/rendering/paragraph.dart
+9
-9
label.dart
packages/flutter_sprites/lib/src/label.dart
+1
-1
No files found.
packages/flutter/lib/src/painting/text_painter.dart
View file @
f35ad647
...
...
@@ -166,21 +166,22 @@ class TextPainter {
}
/// The width at which decreasing the width of the text would prevent it from painting itself completely within its bounds
double
get
min
Content
Width
{
double
get
min
Intrinsic
Width
{
assert
(!
_needsLayout
);
return
_applyFloatingPointHack
(
_paragraph
.
minIntrinsicWidth
);
}
/// The width at which increasing the width of the text no longer decreases the height
double
get
max
Content
Width
{
double
get
max
Intrinsic
Width
{
assert
(!
_needsLayout
);
return
_applyFloatingPointHack
(
_paragraph
.
maxIntrinsicWidth
);
}
/// The height required to paint the text completely within its bounds
double
get
height
{
Size
get
size
{
assert
(!
_needsLayout
);
return
_applyFloatingPointHack
(
_paragraph
.
height
);
double
height
=
_applyFloatingPointHack
(
_paragraph
.
height
);
double
width
=
_applyFloatingPointHack
(
_paragraph
.
width
);
return
new
Size
(
width
,
height
);
}
/// The distance from the top of the text to the first baseline of the given type
...
...
packages/flutter/lib/src/rendering/editable_paragraph.dart
View file @
f35ad647
...
...
@@ -68,7 +68,7 @@ class RenderEditableParagraph extends RenderParagraph {
// because we only support single-line text.
layoutText
(
constraints
);
return
constraints
.
constrainWidth
(
textPainter
.
maxContentW
idth
+
_kCursorGap
+
_kCursorWidth
textPainter
.
size
.
w
idth
+
_kCursorGap
+
_kCursorWidth
);
}
...
...
@@ -83,10 +83,8 @@ class RenderEditableParagraph extends RenderParagraph {
void
performLayout
()
{
layoutText
(
constraints
);
Size
newContentSize
=
new
Size
(
textPainter
.
maxContentWidth
+
_kCursorGap
+
_kCursorWidth
,
textPainter
.
height
);
Offset
cursorPadding
=
const
Offset
(
_kCursorGap
+
_kCursorWidth
,
0.0
);
Size
newContentSize
=
textPainter
.
size
+
cursorPadding
;
size
=
constraints
.
constrain
(
newContentSize
);
if
(
_contentSize
==
null
||
_contentSize
!=
newContentSize
)
{
...
...
@@ -109,7 +107,7 @@ class RenderEditableParagraph extends RenderParagraph {
if
(
_showCursor
)
{
Rect
cursorRect
=
new
Rect
.
fromLTWH
(
textPainter
.
maxContentW
idth
+
_kCursorGap
,
textPainter
.
size
.
w
idth
+
_kCursorGap
,
_kCursorHeightOffset
,
_kCursorWidth
,
size
.
height
-
2.0
*
_kCursorHeightOffset
...
...
packages/flutter/lib/src/rendering/paragraph.dart
View file @
f35ad647
...
...
@@ -59,22 +59,27 @@ class RenderParagraph extends RenderBox {
textPainter
.
minHeight
=
constraints
.
minHeight
;
textPainter
.
maxHeight
=
constraints
.
maxHeight
;
textPainter
.
layout
();
// By default, we shrinkwrap to the intrinsic width.
double
width
=
constraints
.
constrainWidth
(
textPainter
.
maxIntrinsicWidth
);
textPainter
.
minWidth
=
width
;
textPainter
.
maxWidth
=
width
;
textPainter
.
layout
();
_constraintsForCurrentLayout
=
constraints
;
}
double
getMinIntrinsicWidth
(
BoxConstraints
constraints
)
{
layoutText
(
constraints
);
return
constraints
.
constrainWidth
(
textPainter
.
min
Content
Width
);
return
constraints
.
constrainWidth
(
textPainter
.
min
Intrinsic
Width
);
}
double
getMaxIntrinsicWidth
(
BoxConstraints
constraints
)
{
layoutText
(
constraints
);
return
constraints
.
constrainWidth
(
textPainter
.
max
Content
Width
);
return
constraints
.
constrainWidth
(
textPainter
.
max
Intrinsic
Width
);
}
double
_getIntrinsicHeight
(
BoxConstraints
constraints
)
{
layoutText
(
constraints
);
return
constraints
.
constrainHeight
(
textPainter
.
height
);
return
constraints
.
constrainHeight
(
textPainter
.
size
.
height
);
}
double
getMinIntrinsicHeight
(
BoxConstraints
constraints
)
{
...
...
@@ -93,12 +98,7 @@ class RenderParagraph extends RenderBox {
void
performLayout
()
{
layoutText
(
constraints
);
// We use textPainter.maxContentWidth here, rather that textPainter.width,
// because the latter is the width that it used to wrap the text, whereas
// the former is the actual width of the text.
size
=
constraints
.
constrain
(
new
Size
(
textPainter
.
maxContentWidth
,
textPainter
.
height
));
size
=
constraints
.
constrain
(
textPainter
.
size
);
}
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
...
...
packages/flutter_sprites/lib/src/label.dart
View file @
f35ad647
...
...
@@ -43,7 +43,7 @@ class Label extends Node {
_painter
.
minWidth
=
0.0
;
_painter
.
layout
();
_width
=
_painter
.
max
Content
Width
.
ceil
().
toDouble
();
_width
=
_painter
.
max
Intrinsic
Width
.
ceil
().
toDouble
();
_painter
.
maxWidth
=
_width
;
_painter
.
minWidth
=
_width
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment