Browse Source

tmp: test wrapping issue:4824, 4830 and issue:4831 textblock don;t update

Andrey Kunchev 5 years ago
parent
commit
f461759395
  1. 1
      samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj
  2. 25
      samples/ControlCatalog/Pages/TextBlockPage.xaml
  3. 21
      samples/ControlCatalog/Pages/TextBlockPage.xaml.cs
  4. 28
      tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextLayoutTests.cs

1
samples/ControlCatalog.NetCore/ControlCatalog.NetCore.csproj

@ -10,6 +10,7 @@
<ProjectReference Include="..\..\src\Avalonia.Headless.Vnc\Avalonia.Headless.Vnc.csproj" />
<ProjectReference Include="..\..\src\Avalonia.Dialogs\Avalonia.Dialogs.csproj" />
<ProjectReference Include="..\..\src\Linux\Avalonia.LinuxFramebuffer\Avalonia.LinuxFramebuffer.csproj" />
<ProjectReference Include="..\..\src\Windows\Avalonia.Direct2D1\Avalonia.Direct2D1.csproj" />
<ProjectReference Include="..\ControlCatalog\ControlCatalog.csproj" />
<ProjectReference Include="..\..\src\Avalonia.X11\Avalonia.X11.csproj" />
<PackageReference Include="Avalonia.Angle.Windows.Natives" Version="2.1.0.2020091801" />

25
samples/ControlCatalog/Pages/TextBlockPage.xaml

@ -1,6 +1,11 @@
<UserControl x:Class="ControlCatalog.Pages.TextBlockPage"
xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<!--<UserControl.Styles>
<Style Selector="TextBlock">
<Setter Property="Background" Value="Transparent" />
</Style>
</UserControl.Styles>-->
<StackPanel>
<TextBlock Classes="h2">A control that can display text</TextBlock>
<WrapPanel MaxWidth="680"
@ -28,9 +33,25 @@
<TextBlock Text="Right aligned text" TextAlignment="Right" />
</StackPanel>
</Border>
<Border>
<StackPanel Width="300" Spacing="8">
<TextBlock Text="text update issue 4824:" />
<TextBlock x:Name="txtChanging" />
<TextPresenter x:Name="tpChanging" />
<Button x:Name="btn" Content="Update" />
<TextBlock Text="TextWrapping right/left issue- 4830:" />
<Panel HorizontalAlignment="Left">
<Border BorderBrush="Blue" BorderThickness="2">
<TextPresenter Text="0123456 0123456 0123456 0123456" Width="80"
TextWrapping="Wrap" TextAlignment="Right" Background="Yellow" HorizontalAlignment="Left"/>
</Border>
<Border Width="2" HorizontalAlignment="Center" BorderBrush="Gray" Opacity="0.3" BorderThickness="1" />
</Panel>
</StackPanel>
</Border>
<Border>
<StackPanel Spacing="8">
<TextBlock Text="Multiline TextBlock with TextWrapping.&#xD;&#xD;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est." TextWrapping="Wrap" />
<TextBlock Text="new line\r\n &#x0d;&#x0a;new line\r &#x0a;new line\n &#x0d;Multiline TextBlock with TextWrapping.&#xD;&#xD;Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus magna. Cras in mi at felis aliquet congue. Ut a est eget ligula molestie gravida. Curabitur massa. Donec eleifend, libero at sagittis mollis, tellus est malesuada tellus, at luctus turpis elit sit amet quam. Vivamus pretium ornare est." TextWrapping="Wrap" />
</StackPanel>
</Border>
<Border>
@ -55,6 +76,7 @@
</Border>
<Border>
<StackPanel Spacing="8">
<TextBlock Text="new line\n\r &#x0a;&#x0d;new line\r\n &#x0d;&#x0a;new line\n &#x0a;new line\r &#x0d;last line"/>
<TextBlock Text="Underline" TextDecorations="Underline" />
<TextBlock Text="Strikethrough" TextDecorations="Strikethrough" />
<TextBlock Text="Overline" TextDecorations="Overline" />
@ -110,6 +132,7 @@
<TextBlock Text="🏽 👌🏽" />
<TextBlock Text="🏾 👌🏾" />
<TextBlock Text="🏿 👌🏿" />
<TextPresenter Text="🏿 👌🏿"/>
</StackPanel>
</Border>
<Border>

21
samples/ControlCatalog/Pages/TextBlockPage.xaml.cs

@ -1,5 +1,8 @@
using System;
using Avalonia.Controls;
using Avalonia.Controls.Presenters;
using Avalonia.Markup.Xaml;
using Avalonia.Threading;
namespace ControlCatalog.Pages
{
@ -8,6 +11,24 @@ namespace ControlCatalog.Pages
public TextBlockPage()
{
this.InitializeComponent();
var txtChanging = this.Get<TextBlock>("txtChanging");
var tpChanging = this.Get<TextPresenter>("tpChanging");
void update()
{
var time = DateTime.Now.TimeOfDay.ToString();
txtChanging.Text = $"TextBlock: {time}";
tpChanging.Text = $"TextPresenter: {time}";
}
var btn = this.Get<Button>("btn");
btn.Click += (s, e) => update();
//DispatcherTimer.Run(() =>
//{
// update();
// return true;
//}, TimeSpan.FromSeconds(1));
}
private void InitializeComponent()

28
tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextLayoutTests.cs

@ -324,6 +324,34 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
}
}
[Fact(Skip= "enable when fixed 4830 textwrap not aligned properly with center/right")]
public void Test_Wrapping_lines_With_Space_Are_Equal_Width()
{
using (Start())
{
const string text =
"foo foo foo foo";
var foreground = new SolidColorBrush(Colors.Red).ToImmutable();
var layout = new TextLayout(
text,
Typeface.Default,
12.0f,
Brushes.Black.ToImmutable(),
textWrapping: TextWrapping.Wrap,
maxWidth: 30);
var expected = layout.TextLines[0].LineMetrics.Size.Width;
foreach(var l in layout.TextLines.Skip(1))
{
Assert.Equal(expected, l.LineMetrics.Size.Width);
}
}
}
[Fact]
public void Should_Apply_TextStyleSpan_To_MultiLine()
{

Loading…
Cancel
Save