Skip to content

Commit

Permalink
Initial attempt to port WPF's TextContainer
Browse files Browse the repository at this point in the history
  • Loading branch information
Gillibald committed Apr 23, 2021
1 parent 9b792b7 commit 9a27555
Show file tree
Hide file tree
Showing 89 changed files with 36,377 additions and 1 deletion.
54 changes: 54 additions & 0 deletions Avalonia.sln
Original file line number Diff line number Diff line change
Expand Up @@ -212,6 +212,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.FreeDesktop", "src
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Controls.DataGrid.UnitTests", "tests\Avalonia.Controls.DataGrid.UnitTests\Avalonia.Controls.DataGrid.UnitTests.csproj", "{351337F5-D66F-461B-A957-4EF60BDB4BA6}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Documents", "src\Avalonia.Documents\Avalonia.Documents.csproj", "{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Avalonia.Documents.UnitTests", "tests\Avalonia.Documents.UnitTests\Avalonia.Documents.UnitTests.csproj", "{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "NativeEmbedSample", "samples\interop\NativeEmbedSample\NativeEmbedSample.csproj", "{3C84E04B-36CF-4D0D-B965-C26DD649D1F3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Avalonia.Themes.Fluent", "src\Avalonia.Themes.Fluent\Avalonia.Themes.Fluent.csproj", "{C42D2FC1-A531-4ED4-84B9-89AEC7C962FC}"
Expand All @@ -236,6 +239,8 @@ Global
GlobalSection(SharedMSBuildProjectFiles) = preSolution
src\Shared\RenderHelpers\RenderHelpers.projitems*{3c4c0cb4-0c0f-4450-a37b-148c84ff905f}*SharedItemsImports = 13
src\Shared\RenderHelpers\RenderHelpers.projitems*{3e908f67-5543-4879-a1dc-08eace79b3cd}*SharedItemsImports = 5
src\Shared\PlatformSupport\PlatformSupport.projitems*{4488ad85-1495-4809-9aa4-ddfe0a48527e}*SharedItemsImports = 4
src\Shared\PlatformSupport\PlatformSupport.projitems*{7b92af71-6287-4693-9dcb-bd5b6e927e23}*SharedItemsImports = 4
src\Shared\PlatformSupport\PlatformSupport.projitems*{7b92af71-6287-4693-9dcb-bd5b6e927e23}*SharedItemsImports = 5
src\Shared\RenderHelpers\RenderHelpers.projitems*{7d2d3083-71dd-4cc9-8907-39a0d86fb322}*SharedItemsImports = 5
src\Shared\PlatformSupport\PlatformSupport.projitems*{88060192-33d5-4932-b0f9-8bd2763e857d}*SharedItemsImports = 5
Expand Down Expand Up @@ -1902,6 +1907,54 @@ Global
{351337F5-D66F-461B-A957-4EF60BDB4BA6}.Release|iPhone.Build.0 = Release|Any CPU
{351337F5-D66F-461B-A957-4EF60BDB4BA6}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{351337F5-D66F-461B-A957-4EF60BDB4BA6}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.AppStore|iPhone.Build.0 = Debug|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.Debug|iPhone.Build.0 = Debug|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.Release|Any CPU.Build.0 = Release|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.Release|iPhone.ActiveCfg = Release|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.Release|iPhone.Build.0 = Release|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{1F01FC28-7EDA-43C3-B8A5-3BD9858B2CF7}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.Ad-Hoc|iPhone.Build.0 = Debug|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.Ad-Hoc|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.Ad-Hoc|iPhoneSimulator.Build.0 = Debug|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.AppStore|Any CPU.ActiveCfg = Debug|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.AppStore|Any CPU.Build.0 = Debug|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.AppStore|iPhone.ActiveCfg = Debug|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.AppStore|iPhone.Build.0 = Debug|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.AppStore|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.AppStore|iPhoneSimulator.Build.0 = Debug|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.Debug|iPhone.Build.0 = Debug|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.Release|Any CPU.ActiveCfg = Release|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.Release|Any CPU.Build.0 = Release|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.Release|iPhone.ActiveCfg = Release|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.Release|iPhone.Build.0 = Release|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{3C84E04B-36CF-4D0D-B965-C26DD649D1F3}.Ad-Hoc|Any CPU.ActiveCfg = Debug|Any CPU
{3C84E04B-36CF-4D0D-B965-C26DD649D1F3}.Ad-Hoc|Any CPU.Build.0 = Debug|Any CPU
{3C84E04B-36CF-4D0D-B965-C26DD649D1F3}.Ad-Hoc|iPhone.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -2198,6 +2251,7 @@ Global
{D775DECB-4E00-4ED5-A75A-5FCE58ADFF0B} = {9B9E3891-2366-4253-A952-D08BCEB71098}
{AF915D5C-AB00-4EA0-B5E6-001F4AE84E68} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
{351337F5-D66F-461B-A957-4EF60BDB4BA6} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
{F0589BDA-BFBC-4BDE-9E79-EFE101EED592} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B}
{3C84E04B-36CF-4D0D-B965-C26DD649D1F3} = {A0CC0258-D18C-4AB3-854F-7101680FC3F9}
{909A8CBD-7D0E-42FD-B841-022AD8925820} = {8B6A8209-894F-4BA1-B880-965FD453982C}
{11BE52AF-E2DD-4CF0-B19A-05285ACAF571} = {9B9E3891-2366-4253-A952-D08BCEB71098}
Expand Down
4 changes: 4 additions & 0 deletions src/Avalonia.Base/ApiCompatBaseline.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Compat issues with assembly Avalonia.Base:
InterfacesShouldHaveSameMembers : Interface member 'public Avalonia.LocalValueEnumerator Avalonia.IAvaloniaObject.GetLocalValueEnumerator()' is present in the implementation but not in the contract.
InterfacesShouldHaveSameMembers : Interface member 'public System.Object Avalonia.IAvaloniaObject.ReadLocalValue(Avalonia.AvaloniaProperty)' is present in the implementation but not in the contract.
Total Issues: 2
10 changes: 10 additions & 0 deletions src/Avalonia.Base/AvaloniaObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -894,6 +894,16 @@ private void LogPropertySet<T>(AvaloniaProperty<T> property, T value, BindingPri
priority);
}

public object ReadLocalValue(AvaloniaProperty property)
{
throw new NotImplementedException();
}

public LocalValueEnumerator GetLocalValueEnumerator()
{
throw new NotImplementedException();
}

private class DirectBindingSubscription<T> : IObserver<BindingValue<T>>, IDisposable
{
private readonly AvaloniaObject _owner;
Expand Down
4 changes: 4 additions & 0 deletions src/Avalonia.Base/IAvaloniaObject.cs
Original file line number Diff line number Diff line change
Expand Up @@ -156,5 +156,9 @@ void InheritedPropertyChanged<T>(
AvaloniaProperty<T> property,
Optional<T> oldValue,
Optional<T> newValue);

object ReadLocalValue(AvaloniaProperty property);

LocalValueEnumerator GetLocalValueEnumerator();
}
}
209 changes: 209 additions & 0 deletions src/Avalonia.Base/LocalValueEnumerator.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,209 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.Collections;
//using System.Diagnostics;
//using MS.Internal.WindowsBase;

#pragma warning disable 1634, 1691 // suppressing PreSharp warnings

namespace Avalonia
{
/// <summary>
/// Local value enumeration object
/// </summary>
/// <remarks>
/// Modifying local values (via SetValue or ClearValue) during enumeration
/// is unsupported
/// </remarks>
public struct LocalValueEnumerator : IEnumerator
{
/// <summary>
/// Overrides Object.GetHashCode
/// </summary>
/// <returns>An integer that represents the hashcode for this object</returns>
public override int GetHashCode()
{
return base.GetHashCode();
}

/// <summary>
/// Determine equality
/// </summary>
public override bool Equals(object obj)
{
if(obj is LocalValueEnumerator)
{
LocalValueEnumerator other = (LocalValueEnumerator) obj;

return (_count == other._count &&
_index == other._index &&
_snapshot == other._snapshot);
}
else
{
// being compared against something that isn't a LocalValueEnumerator.
return false;
}
}

/// <summary>
/// Determine equality
/// </summary>
public static bool operator ==(LocalValueEnumerator obj1, LocalValueEnumerator obj2)
{
return obj1.Equals(obj2);
}

/// <summary>
/// Determine inequality
/// </summary>
public static bool operator !=(LocalValueEnumerator obj1, LocalValueEnumerator obj2)
{
return !(obj1 == obj2);
}

/// <summary>
/// Get current entry
/// </summary>
public LocalValueEntry Current
{
get
{
if(_index == -1 )
{
#pragma warning suppress 6503 // IEnumerator.Current is documented to throw this exception
throw new InvalidOperationException(/*SR.Get(SRID.LocalValueEnumerationReset)*/);
}

if(_index >= Count )
{
#pragma warning suppress 6503 // IEnumerator.Current is documented to throw this exception
throw new InvalidOperationException(/*SR.Get(SRID.LocalValueEnumerationOutOfBounds)*/);
}

return _snapshot[_index];
}
}

/// <summary>
/// Get current entry (object reference based)
/// </summary>
object IEnumerator.Current
{
get { return Current; }
}

/// <summary>
/// Move to the next item in the enumerator
/// </summary>
/// <returns>Success of the method</returns>
public bool MoveNext()
{
_index++;

return _index < Count;
}

/// <summary>
/// Reset enumeration
/// </summary>
public void Reset()
{
_index = -1;
}

/// <summary>
/// Return number of items represented in the collection
/// </summary>
public int Count
{
get { return _count; }
}

internal LocalValueEnumerator(LocalValueEntry[] snapshot, int count)
{
_index = -1;
_count = count;
_snapshot = snapshot;
}

private int _index;
private LocalValueEntry[] _snapshot;
private int _count;
}


/// <summary>
/// Represents a Property-Value pair for local value enumeration
/// </summary>
public struct LocalValueEntry
{
/// <summary>
/// Overrides Object.GetHashCode
/// </summary>
/// <returns>An integer that represents the hashcode for this object</returns>
public override int GetHashCode()
{
return base.GetHashCode();
}

/// <summary>
/// Determine equality
/// </summary>
public override bool Equals(object obj)
{
LocalValueEntry other = (LocalValueEntry) obj;

return (_dp == other._dp &&
_value == other._value);
}

/// <summary>
/// Determine equality
/// </summary>
public static bool operator ==(LocalValueEntry obj1, LocalValueEntry obj2)
{
return obj1.Equals(obj2);
}

/// <summary>
/// Determine inequality
/// </summary>
public static bool operator !=(LocalValueEntry obj1, LocalValueEntry obj2)
{
return !(obj1 == obj2);
}

/// <summary>
/// Dependency property
/// </summary>
public AvaloniaProperty Property
{
get { return _dp; }
}

/// <summary>
/// Value of the property
/// </summary>
public object Value
{
get { return _value; }
}

internal LocalValueEntry(AvaloniaProperty dp, object value)
{
_dp = dp;
_value = value;
}

// Internal here because we need to change these around when building
// the snapshot for the LocalValueEnumerator, and we can't make internal
// setters when we have public getters.
internal AvaloniaProperty _dp;
internal object _value;
}
}

14 changes: 14 additions & 0 deletions src/Avalonia.Documents/Avalonia.Documents.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netstandard2.0</TargetFramework>
<RootNamespace>Avalonia</RootNamespace>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\Avalonia.Base\Avalonia.Base.csproj" />
<ProjectReference Include="..\Avalonia.Styling\Avalonia.Styling.csproj" />
<ProjectReference Include="..\Avalonia.Visuals\Avalonia.Visuals.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit 9a27555

Please sign in to comment.