Browse Source

Merge branch 'master' into fix-vala-panel-global-menu

pull/12730/head
affederaffe 3 years ago
committed by GitHub
parent
commit
3808b340f4
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      src/Avalonia.Controls/Documents/InlineUIContainer.cs
  2. 5
      src/Avalonia.Controls/Primitives/ScrollBar.cs
  3. 16
      src/Avalonia.Controls/TextBlock.cs
  4. 1
      tests/Avalonia.Controls.UnitTests/TextBlockTests.cs

5
src/Avalonia.Controls/Documents/InlineUIContainer.cs

@ -58,6 +58,11 @@ namespace Avalonia.Controls.Documents
internal override void BuildTextRun(IList<TextRun> textRuns) internal override void BuildTextRun(IList<TextRun> textRuns)
{ {
if(!Child.IsMeasureValid)
{
Child.Measure(Size.Infinity);
}
textRuns.Add(new EmbeddedControlRun(Child, CreateTextRunProperties())); textRuns.Add(new EmbeddedControlRun(Child, CreateTextRunProperties()));
} }

5
src/Avalonia.Controls/Primitives/ScrollBar.cs

@ -195,14 +195,15 @@ namespace Avalonia.Controls.Primitives
} }
/// <summary> /// <summary>
/// Locates the first <see cref="ScrollViewer"/> ancestor and binds to its properties. Properties which have been set through other means are not bound. /// Try to attach to TemplatedParent if it is a <see cref="ScrollViewer"/> and binds to its properties.
/// Properties which have been set through other means are not bound.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// This method is automatically called when the control is attached to a visual tree. /// This method is automatically called when the control is attached to a visual tree.
/// </remarks> /// </remarks>
internal void AttachToScrollViewer() internal void AttachToScrollViewer()
{ {
var owner = this.FindAncestorOfType<ScrollViewer>(); var owner = this.TemplatedParent as ScrollViewer;
if (owner == null) if (owner == null)
{ {

16
src/Avalonia.Controls/TextBlock.cs

@ -679,14 +679,18 @@ namespace Avalonia.Controls
_textRuns = textRuns; _textRuns = textRuns;
foreach (var textRun in _textRuns) foreach (var textLine in TextLayout.TextLines)
{ {
if (textRun is EmbeddedControlRun controlRun && foreach (var run in textLine.TextRuns)
controlRun.Control is Control control)
{ {
VisualChildren.Add(control); if (run is DrawableTextRun drawable)
{
control.Measure(Size.Infinity); if (drawable is EmbeddedControlRun controlRun
&& controlRun.Control is Control control)
{
VisualChildren.Add(control);
}
}
} }
} }
} }

1
tests/Avalonia.Controls.UnitTests/TextBlockTests.cs

@ -170,6 +170,7 @@ namespace Avalonia.Controls.UnitTests
target.Inlines.Add("123456"); target.Inlines.Add("123456");
target.Measure(Size.Infinity); target.Measure(Size.Infinity);
target.Arrange(new Rect(target.DesiredSize));
Assert.True(button.IsMeasureValid); Assert.True(button.IsMeasureValid);
Assert.Equal(80, button.DesiredSize.Width); Assert.Equal(80, button.DesiredSize.Width);

Loading…
Cancel
Save