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)
{
if(!Child.IsMeasureValid)
{
Child.Measure(Size.Infinity);
}
textRuns.Add(new EmbeddedControlRun(Child, CreateTextRunProperties()));
}

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

@ -195,14 +195,15 @@ namespace Avalonia.Controls.Primitives
}
/// <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>
/// <remarks>
/// This method is automatically called when the control is attached to a visual tree.
/// </remarks>
internal void AttachToScrollViewer()
{
var owner = this.FindAncestorOfType<ScrollViewer>();
var owner = this.TemplatedParent as ScrollViewer;
if (owner == null)
{

16
src/Avalonia.Controls/TextBlock.cs

@ -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);
}
}
}
}
}

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

@ -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);

Loading…
Cancel
Save