committed by
GitHub
375 changed files with 4406 additions and 3137 deletions
@ -1,7 +1,7 @@ |
|||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="HarfBuzzSharp" Version="2.8.2.1-preview.108" /> |
<PackageReference Include="HarfBuzzSharp" Version="2.8.2.3" /> |
||||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2.1-preview.108" /> |
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.Linux" Version="2.8.2.3" /> |
||||
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.WebAssembly" Version="2.8.2.1-preview.108" /> |
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="HarfBuzzSharp.NativeAssets.WebAssembly" Version="2.8.2.3" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -1,5 +1,5 @@ |
|||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.1" /> |
<PackageReference Include="SixLabors.ImageSharp" Version="2.1.3" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -1,5 +1,5 @@ |
|||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="Moq" Version="4.14.1" /> |
<PackageReference Include="Moq" Version="4.18.4" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -1,7 +1,7 @@ |
|||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
<ItemGroup> |
<ItemGroup> |
||||
<PackageReference Include="SkiaSharp" Version="2.88.1" /> |
<PackageReference Include="SkiaSharp" Version="2.88.3" /> |
||||
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.88.1" /> |
<PackageReference Condition="'$(IncludeLinuxSkia)' == 'true'" Include="SkiaSharp.NativeAssets.Linux" Version="2.88.3" /> |
||||
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.88.1" /> |
<PackageReference Condition="'$(IncludeWasmSkia)' == 'true'" Include="SkiaSharp.NativeAssets.WebAssembly" Version="2.88.3" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -0,0 +1,39 @@ |
|||||
|
#include "common.h" |
||||
|
|
||||
|
namespace |
||||
|
{ |
||||
|
id<NSObject> s_inhibitAppSleepHandle{}; |
||||
|
} |
||||
|
|
||||
|
class PlatformBehaviorInhibition : public ComSingleObject<IAvnPlatformBehaviorInhibition, &IID_IAvnCursorFactory> |
||||
|
{ |
||||
|
public: |
||||
|
FORWARD_IUNKNOWN() |
||||
|
|
||||
|
virtual void SetInhibitAppSleep(bool inhibitAppSleep, char* reason) override |
||||
|
{ |
||||
|
START_COM_CALL; |
||||
|
|
||||
|
@autoreleasepool |
||||
|
{ |
||||
|
if (inhibitAppSleep && s_inhibitAppSleepHandle == nullptr) |
||||
|
{ |
||||
|
NSActivityOptions options = NSActivityUserInitiatedAllowingIdleSystemSleep; |
||||
|
s_inhibitAppSleepHandle = [[NSProcessInfo processInfo] beginActivityWithOptions:options reason:[NSString stringWithUTF8String: reason]]; |
||||
|
} |
||||
|
|
||||
|
if (!inhibitAppSleep) |
||||
|
{ |
||||
|
s_inhibitAppSleepHandle = nullptr; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
extern IAvnPlatformBehaviorInhibition* CreatePlatformBehaviorInhibition() |
||||
|
{ |
||||
|
@autoreleasepool |
||||
|
{ |
||||
|
return new PlatformBehaviorInhibition(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,127 @@ |
|||||
|
using System; |
||||
|
using Android.Runtime; |
||||
|
using Android.Text; |
||||
|
using Android.Views; |
||||
|
using Android.Views.InputMethods; |
||||
|
using Avalonia.Android.Platform.SkiaPlatform; |
||||
|
using Avalonia.Controls.Presenters; |
||||
|
using Avalonia.Input; |
||||
|
using Avalonia.Input.Raw; |
||||
|
using Avalonia.Input.TextInput; |
||||
|
using Java.Lang; |
||||
|
using static System.Net.Mime.MediaTypeNames; |
||||
|
|
||||
|
namespace Avalonia.Android |
||||
|
{ |
||||
|
internal class InputEditable : SpannableStringBuilder, ITextEditable |
||||
|
{ |
||||
|
private readonly TopLevelImpl _topLevel; |
||||
|
private readonly IAndroidInputMethod _inputMethod; |
||||
|
private readonly AvaloniaInputConnection _avaloniaInputConnection; |
||||
|
private int _currentBatchLevel; |
||||
|
private string _previousText; |
||||
|
private int _previousSelectionStart; |
||||
|
private int _previousSelectionEnd; |
||||
|
|
||||
|
public event EventHandler TextChanged; |
||||
|
public event EventHandler SelectionChanged; |
||||
|
public event EventHandler CompositionChanged; |
||||
|
|
||||
|
public InputEditable(TopLevelImpl topLevel, IAndroidInputMethod inputMethod, AvaloniaInputConnection avaloniaInputConnection) |
||||
|
{ |
||||
|
_topLevel = topLevel; |
||||
|
_inputMethod = inputMethod; |
||||
|
_avaloniaInputConnection = avaloniaInputConnection; |
||||
|
} |
||||
|
|
||||
|
public InputEditable(ICharSequence text) : base(text) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public InputEditable(string text) : base(text) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public InputEditable(ICharSequence text, int start, int end) : base(text, start, end) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public InputEditable(string text, int start, int end) : base(text, start, end) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
protected InputEditable(IntPtr javaReference, JniHandleOwnership transfer) : base(javaReference, transfer) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public int SelectionStart |
||||
|
{ |
||||
|
get => Selection.GetSelectionStart(this); set |
||||
|
{ |
||||
|
var end = SelectionEnd < 0 ? 0 : SelectionEnd; |
||||
|
_avaloniaInputConnection.SetSelection(value, end); |
||||
|
_inputMethod.IMM.UpdateSelection(_topLevel.View, value, end, value, end); |
||||
|
} |
||||
|
} |
||||
|
public int SelectionEnd |
||||
|
{ |
||||
|
get => Selection.GetSelectionEnd(this); set |
||||
|
{ |
||||
|
var start = SelectionStart < 0 ? 0 : SelectionStart; |
||||
|
_avaloniaInputConnection.SetSelection(start, value); |
||||
|
_inputMethod.IMM.UpdateSelection(_topLevel.View, start, value, start, value); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public string? Text |
||||
|
{ |
||||
|
get => ToString(); set |
||||
|
{ |
||||
|
if (Text != value) |
||||
|
{ |
||||
|
Clear(); |
||||
|
Insert(0, value ?? ""); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public int CompositionStart => BaseInputConnection.GetComposingSpanStart(this); |
||||
|
|
||||
|
public int CompositionEnd => BaseInputConnection.GetComposingSpanEnd(this); |
||||
|
|
||||
|
public void BeginBatchEdit() |
||||
|
{ |
||||
|
_currentBatchLevel++; |
||||
|
|
||||
|
if (_currentBatchLevel == 1) |
||||
|
{ |
||||
|
_previousText = ToString(); |
||||
|
_previousSelectionStart = SelectionStart; |
||||
|
_previousSelectionEnd = SelectionEnd; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public void EndBatchEdit() |
||||
|
{ |
||||
|
if (_currentBatchLevel == 1) |
||||
|
{ |
||||
|
if(_previousText != Text) |
||||
|
{ |
||||
|
TextChanged?.Invoke(this, EventArgs.Empty); |
||||
|
} |
||||
|
|
||||
|
if (_previousSelectionStart != SelectionStart || _previousSelectionEnd != SelectionEnd) |
||||
|
{ |
||||
|
SelectionChanged?.Invoke(this, EventArgs.Empty); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
_currentBatchLevel--; |
||||
|
} |
||||
|
|
||||
|
public void RaiseCompositionChanged() |
||||
|
{ |
||||
|
CompositionChanged?.Invoke(this, EventArgs.Empty); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,23 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Text; |
||||
|
using System.Threading.Tasks; |
||||
|
using Avalonia.Metadata; |
||||
|
|
||||
|
namespace Avalonia.Input.TextInput |
||||
|
{ |
||||
|
[NotClientImplementable] |
||||
|
public interface ITextEditable |
||||
|
{ |
||||
|
event EventHandler TextChanged; |
||||
|
event EventHandler SelectionChanged; |
||||
|
event EventHandler CompositionChanged; |
||||
|
int SelectionStart { get; set; } |
||||
|
int SelectionEnd { get; set; } |
||||
|
int CompositionStart { get; } |
||||
|
int CompositionEnd { get; } |
||||
|
|
||||
|
string? Text { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,12 @@ |
|||||
|
using System.Threading.Tasks; |
||||
|
|
||||
|
namespace Avalonia.Platform |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Allows to inhibit platform specific behavior.
|
||||
|
/// </summary>
|
||||
|
public interface IPlatformBehaviorInhibition |
||||
|
{ |
||||
|
Task SetInhibitAppSleep(bool inhibitAppSleep, string reason); |
||||
|
} |
||||
|
} |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue