|
|
|
@ -2,6 +2,7 @@ using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Diagnostics; |
|
|
|
using Avalonia.Automation.Peers; |
|
|
|
using Avalonia.Collections; |
|
|
|
using Avalonia.Controls.Documents; |
|
|
|
using Avalonia.Layout; |
|
|
|
using Avalonia.Media; |
|
|
|
@ -668,16 +669,18 @@ namespace Avalonia.Controls |
|
|
|
/// Invalidates <see cref="TextLayout"/>.
|
|
|
|
/// </summary>
|
|
|
|
protected void InvalidateTextLayout() |
|
|
|
{ |
|
|
|
InvalidateMeasure(); |
|
|
|
} |
|
|
|
|
|
|
|
protected override void OnMeasureInvalidated() |
|
|
|
{ |
|
|
|
_textLayout?.Dispose(); |
|
|
|
_textLayout = null; |
|
|
|
|
|
|
|
VisualChildren.Clear(); |
|
|
|
|
|
|
|
_textRuns = null; |
|
|
|
|
|
|
|
InvalidateVisual(); |
|
|
|
InvalidateMeasure(); |
|
|
|
base.OnMeasureInvalidated(); |
|
|
|
} |
|
|
|
|
|
|
|
protected override Size MeasureOverride(Size availableSize) |
|
|
|
@ -686,8 +689,6 @@ namespace Avalonia.Controls |
|
|
|
var padding = LayoutHelper.RoundLayoutThickness(Padding, scale, scale); |
|
|
|
|
|
|
|
_constraint = availableSize.Deflate(padding); |
|
|
|
_textLayout?.Dispose(); |
|
|
|
_textLayout = null; |
|
|
|
|
|
|
|
var inlines = Inlines; |
|
|
|
|
|
|
|
@ -701,21 +702,6 @@ namespace Avalonia.Controls |
|
|
|
} |
|
|
|
|
|
|
|
_textRuns = textRuns; |
|
|
|
|
|
|
|
foreach (var textLine in TextLayout.TextLines) |
|
|
|
{ |
|
|
|
foreach (var run in textLine.TextRuns) |
|
|
|
{ |
|
|
|
if (run is DrawableTextRun drawable) |
|
|
|
{ |
|
|
|
if (drawable is EmbeddedControlRun controlRun |
|
|
|
&& controlRun.Control is Control control) |
|
|
|
{ |
|
|
|
VisualChildren.Add(control); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
var width = TextLayout.OverhangLeading + TextLayout.WidthIncludingTrailingWhitespace + TextLayout.OverhangTrailing; |
|
|
|
@ -827,27 +813,31 @@ namespace Avalonia.Controls |
|
|
|
|
|
|
|
private void OnInlinesChanged(InlineCollection? oldValue, InlineCollection? newValue) |
|
|
|
{ |
|
|
|
VisualChildren.Clear(); |
|
|
|
|
|
|
|
if (oldValue is not null) |
|
|
|
{ |
|
|
|
oldValue.LogicalChildren = null; |
|
|
|
oldValue.InlineHost = null; |
|
|
|
oldValue.Invalidated -= (s, e) => InvalidateTextLayout(); |
|
|
|
oldValue.Invalidated -= (s, e) => InvalidateMeasure(); |
|
|
|
} |
|
|
|
|
|
|
|
if (newValue is not null) |
|
|
|
{ |
|
|
|
newValue.LogicalChildren = LogicalChildren; |
|
|
|
newValue.InlineHost = this; |
|
|
|
newValue.Invalidated += (s, e) => InvalidateTextLayout(); |
|
|
|
newValue.Invalidated += (s, e) => InvalidateMeasure(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
void IInlineHost.Invalidate() |
|
|
|
{ |
|
|
|
InvalidateTextLayout(); |
|
|
|
InvalidateMeasure(); |
|
|
|
} |
|
|
|
|
|
|
|
private readonly record struct SimpleTextSource : ITextSource |
|
|
|
IAvaloniaList<Visual> IInlineHost.VisualChildren => VisualChildren; |
|
|
|
|
|
|
|
protected readonly record struct SimpleTextSource : ITextSource |
|
|
|
{ |
|
|
|
private readonly string _text; |
|
|
|
private readonly TextRunProperties _defaultProperties; |
|
|
|
|