Browse Source
Merge pull request #12695 from Gillibald/fixes/inlinesTrimming
Fix Inlines TextTrimming with embedded controls
focus_prototype
Benedikt Stebner
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
16 additions and
6 deletions
-
src/Avalonia.Controls/Documents/InlineUIContainer.cs
-
src/Avalonia.Controls/TextBlock.cs
-
tests/Avalonia.Controls.UnitTests/TextBlockTests.cs
|
|
|
@ -58,6 +58,11 @@ namespace Avalonia.Controls.Documents |
|
|
|
|
|
|
|
internal override void BuildTextRun(IList<TextRun> textRuns) |
|
|
|
{ |
|
|
|
if(!Child.IsMeasureValid) |
|
|
|
{ |
|
|
|
Child.Measure(Size.Infinity); |
|
|
|
} |
|
|
|
|
|
|
|
textRuns.Add(new EmbeddedControlRun(Child, CreateTextRunProperties())); |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@ -679,14 +679,18 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
_textRuns = textRuns; |
|
|
|
|
|
|
|
foreach (var textRun in _textRuns) |
|
|
|
foreach (var textLine in TextLayout.TextLines) |
|
|
|
{ |
|
|
|
if (textRun is EmbeddedControlRun controlRun && |
|
|
|
controlRun.Control is Control control) |
|
|
|
foreach (var run in textLine.TextRuns) |
|
|
|
{ |
|
|
|
VisualChildren.Add(control); |
|
|
|
|
|
|
|
control.Measure(Size.Infinity); |
|
|
|
if (run is DrawableTextRun drawable) |
|
|
|
{ |
|
|
|
if (drawable is EmbeddedControlRun controlRun |
|
|
|
&& controlRun.Control is Control control) |
|
|
|
{ |
|
|
|
VisualChildren.Add(control); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -170,6 +170,7 @@ namespace Avalonia.Controls.UnitTests |
|
|
|
target.Inlines.Add("123456"); |
|
|
|
|
|
|
|
target.Measure(Size.Infinity); |
|
|
|
target.Arrange(new Rect(target.DesiredSize)); |
|
|
|
|
|
|
|
Assert.True(button.IsMeasureValid); |
|
|
|
Assert.Equal(80, button.DesiredSize.Width); |
|
|
|
|