Browse Source

API changes and test fixes.

Dariusz Komosinski 3 years ago
parent
commit
1273448981

+ 1 - 1
src/Avalonia.Visuals/ApiCompatBaseline.txt

@@ -85,7 +85,7 @@ MembersMustExist : Member 'public void Avalonia.Media.TextFormatting.ShapedTextC
 MembersMustExist : Member 'public Avalonia.Media.TextFormatting.ShapedTextCharacters.SplitTextCharactersResult Avalonia.Media.TextFormatting.ShapedTextCharacters.Split(System.Int32)' does not exist in the implementation but it does exist in the contract.
 TypesMustExist : Type 'Avalonia.Media.TextFormatting.ShapedTextCharacters.SplitTextCharactersResult' does not exist in the implementation but it does exist in the contract.
 MembersMustExist : Member 'protected System.Boolean Avalonia.Media.TextFormatting.TextCharacters.TryGetRunProperties(Avalonia.Utilities.ReadOnlySlice<System.Char>, Avalonia.Media.Typeface, Avalonia.Media.Typeface, System.Int32)' does not exist in the implementation but it does exist in the contract.
-CannotAddAbstractMembers : Member 'public System.Collections.Generic.IReadOnlyList<Avalonia.Media.TextFormatting.TextRun> Avalonia.Media.TextFormatting.TextCollapsingProperties.Collapse(Avalonia.Media.TextFormatting.TextLine, Avalonia.Media.FlowDirection)' is abstract in the implementation but is missing in the contract.
+CannotAddAbstractMembers : Member 'public System.Collections.Generic.IReadOnlyList<Avalonia.Media.TextFormatting.TextRun> Avalonia.Media.TextFormatting.TextCollapsingProperties.Collapse(Avalonia.Media.TextFormatting.TextLine)' is abstract in the implementation but is missing in the contract.
 MembersMustExist : Member 'public Avalonia.Media.TextFormatting.TextCollapsingStyle Avalonia.Media.TextFormatting.TextCollapsingProperties.Style.get()' does not exist in the implementation but it does exist in the contract.
 TypesMustExist : Type 'Avalonia.Media.TextFormatting.TextCollapsingStyle' does not exist in the implementation but it does exist in the contract.
 MembersMustExist : Member 'public void Avalonia.Media.TextFormatting.TextEndOfLine..ctor()' does not exist in the implementation but it does exist in the contract.

+ 1 - 2
src/Avalonia.Visuals/Media/TextFormatting/TextCollapsingProperties.cs

@@ -21,7 +21,6 @@ namespace Avalonia.Media.TextFormatting
         /// Collapses given text line.
         /// </summary>
         /// <param name="textLine">Text line to collapse.</param>
-        /// <param name="flowDirection">Text flow direction.</param>
-        public abstract IReadOnlyList<TextRun>? Collapse(TextLine textLine, FlowDirection flowDirection);
+        public abstract IReadOnlyList<TextRun>? Collapse(TextLine textLine);
     }
 }

+ 2 - 2
src/Avalonia.Visuals/Media/TextFormatting/TextEllipsisHelper.cs

@@ -5,7 +5,7 @@ namespace Avalonia.Media.TextFormatting
 {
     internal class TextEllipsisHelper
     {
-        public static List<ShapedTextCharacters>? Collapse(TextLine textLine, FlowDirection flowDirection, TextCollapsingProperties properties, bool isWordEllipsis)
+        public static List<ShapedTextCharacters>? Collapse(TextLine textLine, TextCollapsingProperties properties, bool isWordEllipsis)
         {
             var shapedTextRuns = textLine.TextRuns as List<ShapedTextCharacters>;
 
@@ -18,7 +18,7 @@ namespace Avalonia.Media.TextFormatting
             var currentWidth = 0.0;
             var collapsedLength = 0;
             var textRange = textLine.TextRange;
-            var shapedSymbol = TextFormatterImpl.CreateSymbol(properties.Symbol, flowDirection);
+            var shapedSymbol = TextFormatterImpl.CreateSymbol(properties.Symbol, FlowDirection.LeftToRight);
 
             if (properties.Width < shapedSymbol.GlyphRun.Size.Width)
             {

+ 2 - 2
src/Avalonia.Visuals/Media/TextFormatting/TextLeadingPrefixCharacterEllipsis.cs

@@ -40,7 +40,7 @@ namespace Avalonia.Media.TextFormatting
         /// <inheritdoc/>
         public sealed override TextRun Symbol { get; }
 
-        public override IReadOnlyList<TextRun>? Collapse(TextLine textLine, FlowDirection flowDirection)
+        public override IReadOnlyList<TextRun>? Collapse(TextLine textLine)
         {
             var shapedTextRuns = textLine.TextRuns as List<ShapedTextCharacters>;
 
@@ -51,7 +51,7 @@ namespace Avalonia.Media.TextFormatting
 
             var runIndex = 0;
             var currentWidth = 0.0;
-            var shapedSymbol = TextFormatterImpl.CreateSymbol(Symbol, flowDirection);
+            var shapedSymbol = TextFormatterImpl.CreateSymbol(Symbol, FlowDirection.LeftToRight);
 
             if (Width < shapedSymbol.GlyphRun.Size.Width)
             {

+ 1 - 1
src/Avalonia.Visuals/Media/TextFormatting/TextLineImpl.cs

@@ -106,7 +106,7 @@ namespace Avalonia.Media.TextFormatting
 
             var collapsingProperties = collapsingPropertiesList[0];
 
-            var collapsedRuns = collapsingProperties.Collapse(this, _paragraphProperties.FlowDirection);
+            var collapsedRuns = collapsingProperties.Collapse(this);
 
             if (collapsedRuns is List<ShapedTextCharacters> shapedRuns)
             {

+ 2 - 2
src/Avalonia.Visuals/Media/TextFormatting/TextTrailingCharacterEllipsis.cs

@@ -27,9 +27,9 @@ namespace Avalonia.Media.TextFormatting
         /// <inheritdoc/>
         public sealed override TextRun Symbol { get; }
 
-        public override IReadOnlyList<TextRun>? Collapse(TextLine textLine, FlowDirection flowDirection)
+        public override IReadOnlyList<TextRun>? Collapse(TextLine textLine)
         {
-            return TextEllipsisHelper.Collapse(textLine, flowDirection, this, false);
+            return TextEllipsisHelper.Collapse(textLine, this, false);
         }
     }
 }

+ 2 - 2
src/Avalonia.Visuals/Media/TextFormatting/TextTrailingWordEllipsis.cs

@@ -31,9 +31,9 @@ namespace Avalonia.Media.TextFormatting
         /// <inheritdoc/>
         public sealed override TextRun Symbol { get; }
 
-        public override IReadOnlyList<TextRun>? Collapse(TextLine textLine, FlowDirection flowDirection)
+        public override IReadOnlyList<TextRun>? Collapse(TextLine textLine)
         {
-            return TextEllipsisHelper.Collapse(textLine, flowDirection, this, true);
+            return TextEllipsisHelper.Collapse(textLine, this, true);
         }
     }
 }

+ 5 - 0
src/Avalonia.Visuals/Media/TextTrimming.cs

@@ -30,6 +30,11 @@ namespace Avalonia.Media
         /// </summary>
         public static TextTrimming PrefixCharacterEllipsis { get; } = new TextLeadingPrefixTrimming(s_defaultEllipsisChar, 8);
 
+        /// <summary>
+        /// Text is trimmed at a character boundary starting from the beginning. An ellipsis (...) is drawn in place of remaining text.
+        /// </summary>
+        public static TextTrimming LeadingCharacterEllipsis { get; } = new TextLeadingPrefixTrimming(s_defaultEllipsisChar, 0);
+
         /// <summary>
         /// Creates properties that will be used for collapsing lines of text.
         /// </summary>

+ 1 - 1
tests/Avalonia.Skia.UnitTests/Media/TextFormatting/TextLineTests.cs

@@ -364,7 +364,7 @@ namespace Avalonia.Skia.UnitTests.Media.TextFormatting
         {
             get
             {
-                yield return CreateData("01234 01234 01234", 120, TextTrimming.PrefixEllipsis, "01234 01\u20264 01234");
+                yield return CreateData("01234 01234 01234", 120, TextTrimming.PrefixCharacterEllipsis, "01234 01\u20264 01234");
                 yield return CreateData("01234 01234", 58, TextTrimming.CharacterEllipsis, "01234 0\u2026");
                 yield return CreateData("01234 01234", 58, TextTrimming.WordEllipsis, "01234\u2026");
                 yield return CreateData("01234", 9, TextTrimming.CharacterEllipsis, "\u2026");