Skip to content

Commit

Permalink
Fix InlineUIContainer clipping in text when ArrangeOverride called. (#…
Browse files Browse the repository at this point in the history
…17183) (#17194)

* InlineUiContainer clip fix

* Removed LINQ, redo check

* bugfix/InlineUiContainer-clip-in-text: redo everything

* fixes by Gillibald

---------

Co-authored-by: Benedikt Stebner <[email protected]>
  • Loading branch information
Danich27rus and Gillibald authored Oct 30, 2024
1 parent 397fc75 commit a06ae34
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/Avalonia.Controls/TextBlock.cs
Original file line number Diff line number Diff line change
Expand Up @@ -759,7 +759,10 @@ protected override Size ArrangeOverride(Size finalSize)
var textLayout = TextLayout;

if (HasComplexContent)
{
{
//Clear visual children before complex run arrangement
VisualChildren.Clear();

var currentY = padding.Top;

foreach (var textLine in textLayout.TextLines)
Expand All @@ -773,6 +776,10 @@ protected override Size ArrangeOverride(Size finalSize)
if (drawable is EmbeddedControlRun controlRun
&& controlRun.Control is Control control)
{
//Add again to prevent clipping
//Fixes: #17194
VisualChildren.Add(control);

control.Arrange(
new Rect(new Point(currentX, currentY),
new Size(control.DesiredSize.Width, textLine.Height)));
Expand Down Expand Up @@ -964,6 +971,6 @@ public InlinesTextSource(IReadOnlyList<TextRun> textRuns, IReadOnlyList<ValueSpa

return new TextEndOfParagraph();
}
}
}
}
}

0 comments on commit a06ae34

Please sign in to comment.