308 changed files with 12380 additions and 3236 deletions
@ -0,0 +1,89 @@ |
|||||
|
jobs: |
||||
|
- job: Linux |
||||
|
pool: |
||||
|
vmImage: 'ubuntu-16.04' |
||||
|
steps: |
||||
|
- task: CmdLine@2 |
||||
|
inputs: |
||||
|
script: | |
||||
|
sudo apt-get update |
||||
|
sudo apt-get install castxml |
||||
|
- task: CmdLine@2 |
||||
|
inputs: |
||||
|
script: | |
||||
|
dotnet tool install -g Cake.Tool --version 0.30.0 |
||||
|
|
||||
|
- script: | |
||||
|
export PATH="$PATH:$HOME/.dotnet/tools" |
||||
|
dotnet --info |
||||
|
printenv |
||||
|
dotnet cake build.cake -target="Azure-Linux" -configuration="Release" |
||||
|
|
||||
|
- job: macOS |
||||
|
pool: |
||||
|
vmImage: 'xcode9-macos10.13' |
||||
|
steps: |
||||
|
- task: DotNetCoreInstaller@0 |
||||
|
inputs: |
||||
|
version: '2.1.403' |
||||
|
- task: Xcode@5 |
||||
|
inputs: |
||||
|
actions: 'build' |
||||
|
scheme: '' |
||||
|
sdk: 'macosx10.13' |
||||
|
configuration: 'Release' |
||||
|
xcWorkspacePath: '**/*.xcodeproj/project.xcworkspace' |
||||
|
xcodeVersion: 'default' # Options: 8, 9, default, specifyPath |
||||
|
args: '-derivedDataPath ./' |
||||
|
- task: CmdLine@2 |
||||
|
inputs: |
||||
|
script: brew install castxml |
||||
|
- task: CmdLine@2 |
||||
|
inputs: |
||||
|
script: | |
||||
|
dotnet tool install -g Cake.Tool --version 0.30.0 |
||||
|
- script: | |
||||
|
export COREHOST_TRACE=0 |
||||
|
export DOTNET_SKIP_FIRST_TIME_EXPERIENCE=1 |
||||
|
export DOTNET_CLI_TELEMETRY_OPTOUT=1 |
||||
|
which dotnet |
||||
|
dotnet --info |
||||
|
export PATH="$PATH:$HOME/.dotnet/tools" |
||||
|
dotnet --info |
||||
|
printenv |
||||
|
dotnet cake build.cake -target="Azure-OSX" -configuration="Release" |
||||
|
|
||||
|
- task: PublishBuildArtifacts@1 |
||||
|
inputs: |
||||
|
pathToPublish: '$(Build.SourcesDirectory)/Build/Products/Release/' |
||||
|
artifactName: 'Avalonia.Native.OSX' |
||||
|
- task: PublishBuildArtifacts@1 |
||||
|
inputs: |
||||
|
pathToPublish: '$(Build.SourcesDirectory)/artifacts/bin' |
||||
|
artifactName: 'BinariesOSX' |
||||
|
|
||||
|
- job: Windows |
||||
|
pool: |
||||
|
vmImage: 'vs2017-win2016' |
||||
|
steps: |
||||
|
- task: CmdLine@2 |
||||
|
inputs: |
||||
|
script: | |
||||
|
dotnet tool install -g Cake.Tool --version 0.30.0 |
||||
|
- task: CmdLine@2 |
||||
|
inputs: |
||||
|
script: | |
||||
|
set PATH=%PATH%;%USERPROFILE%\.dotnet\tools |
||||
|
dotnet cake build.cake -target="Azure-Windows" -configuration="Release" |
||||
|
- task: PublishBuildArtifacts@1 |
||||
|
inputs: |
||||
|
pathtoPublish: '$(Build.SourcesDirectory)/artifacts/nuget' |
||||
|
artifactName: 'NuGet' |
||||
|
- task: PublishBuildArtifacts@1 |
||||
|
inputs: |
||||
|
pathToPublish: '$(Build.SourcesDirectory)/artifacts/zip' |
||||
|
artifactName: 'Samples' |
||||
|
- task: PublishBuildArtifacts@1 |
||||
|
inputs: |
||||
|
pathToPublish: '$(Build.SourcesDirectory)/artifacts/bin' |
||||
|
artifactName: 'BinariesWindows' |
||||
@ -1,5 +0,0 @@ |
|||||
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
|
||||
<ItemGroup> |
|
||||
<PackageReference Include="MonoMac.NetStandard" Version="0.0.4" /> |
|
||||
</ItemGroup> |
|
||||
</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="reactiveui" Version="8.7.1" /> |
<PackageReference Include="reactiveui" Version="9.0.1" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -0,0 +1,30 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Reactive.Linq; |
||||
|
using System.Text; |
||||
|
using Avalonia.Reactive; |
||||
|
|
||||
|
namespace Avalonia.Animation |
||||
|
{ |
||||
|
public class Clock : ClockBase |
||||
|
{ |
||||
|
public static IClock GlobalClock => AvaloniaLocator.Current.GetService<IGlobalClock>(); |
||||
|
|
||||
|
private IDisposable _parentSubscription; |
||||
|
|
||||
|
public Clock() |
||||
|
:this(GlobalClock) |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public Clock(IClock parent) |
||||
|
{ |
||||
|
_parentSubscription = parent.Subscribe(Pulse); |
||||
|
} |
||||
|
|
||||
|
protected override void Stop() |
||||
|
{ |
||||
|
_parentSubscription?.Dispose(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,72 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Reactive.Linq; |
||||
|
using System.Text; |
||||
|
using Avalonia.Reactive; |
||||
|
|
||||
|
namespace Avalonia.Animation |
||||
|
{ |
||||
|
public class ClockBase : IClock |
||||
|
{ |
||||
|
private ClockObservable _observable; |
||||
|
|
||||
|
private IObservable<TimeSpan> _connectedObservable; |
||||
|
|
||||
|
private TimeSpan? _previousTime; |
||||
|
private TimeSpan _internalTime; |
||||
|
|
||||
|
protected ClockBase() |
||||
|
{ |
||||
|
_observable = new ClockObservable(); |
||||
|
_connectedObservable = _observable.Publish().RefCount(); |
||||
|
} |
||||
|
|
||||
|
protected bool HasSubscriptions => _observable.HasSubscriptions; |
||||
|
|
||||
|
public PlayState PlayState { get; set; } |
||||
|
|
||||
|
protected void Pulse(TimeSpan systemTime) |
||||
|
{ |
||||
|
if (!_previousTime.HasValue) |
||||
|
{ |
||||
|
_previousTime = systemTime; |
||||
|
_internalTime = TimeSpan.Zero; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
if (PlayState == PlayState.Pause) |
||||
|
{ |
||||
|
_previousTime = systemTime; |
||||
|
return; |
||||
|
} |
||||
|
var delta = systemTime - _previousTime; |
||||
|
_internalTime += delta.Value; |
||||
|
_previousTime = systemTime; |
||||
|
} |
||||
|
|
||||
|
_observable.Pulse(_internalTime); |
||||
|
|
||||
|
if (PlayState == PlayState.Stop) |
||||
|
{ |
||||
|
Stop(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
protected virtual void Stop() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public IDisposable Subscribe(IObserver<TimeSpan> observer) |
||||
|
{ |
||||
|
return _connectedObservable.Subscribe(observer); |
||||
|
} |
||||
|
|
||||
|
private class ClockObservable : LightweightObservableBase<TimeSpan> |
||||
|
{ |
||||
|
public bool HasSubscriptions { get; private set; } |
||||
|
public void Pulse(TimeSpan time) => PublishNext(time); |
||||
|
protected override void Initialize() => HasSubscriptions = true; |
||||
|
protected override void Deinitialize() => HasSubscriptions = false; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,65 @@ |
|||||
|
// Copyright (c) The Avalonia Project. All rights reserved.
|
||||
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
||||
|
|
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using System.Reactive.Linq; |
||||
|
using Avalonia.Animation.Utils; |
||||
|
using Avalonia.Collections; |
||||
|
using Avalonia.Data; |
||||
|
using Avalonia.Reactive; |
||||
|
|
||||
|
namespace Avalonia.Animation |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Manages the lifetime of animation instances as determined by its selector state.
|
||||
|
/// </summary>
|
||||
|
internal class DisposeAnimationInstanceSubject<T> : IObserver<bool>, IDisposable |
||||
|
{ |
||||
|
private IDisposable _lastInstance; |
||||
|
private bool _lastMatch; |
||||
|
private Animator<T> _animator; |
||||
|
private Animation _animation; |
||||
|
private Animatable _control; |
||||
|
private Action _onComplete; |
||||
|
private IClock _clock; |
||||
|
|
||||
|
public DisposeAnimationInstanceSubject(Animator<T> animator, Animation animation, Animatable control, IClock clock, Action onComplete) |
||||
|
{ |
||||
|
this._animator = animator; |
||||
|
this._animation = animation; |
||||
|
this._control = control; |
||||
|
this._onComplete = onComplete; |
||||
|
this._clock = clock; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public void Dispose() |
||||
|
{ |
||||
|
_lastInstance?.Dispose(); |
||||
|
} |
||||
|
|
||||
|
public void OnCompleted() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
public void OnError(Exception error) |
||||
|
{ |
||||
|
_lastInstance?.Dispose(); |
||||
|
} |
||||
|
|
||||
|
void IObserver<bool>.OnNext(bool matchVal) |
||||
|
{ |
||||
|
if (matchVal != _lastMatch) |
||||
|
{ |
||||
|
_lastInstance?.Dispose(); |
||||
|
if (matchVal) |
||||
|
{ |
||||
|
_lastInstance = _animator.Run(_animation, _control, _clock, _onComplete); |
||||
|
} |
||||
|
_lastMatch = matchVal; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Avalonia.Animation |
||||
|
{ |
||||
|
public interface IClock : IObservable<TimeSpan> |
||||
|
{ |
||||
|
PlayState PlayState { get; set; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,10 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Text; |
||||
|
|
||||
|
namespace Avalonia.Animation |
||||
|
{ |
||||
|
public interface IGlobalClock : IClock |
||||
|
{ |
||||
|
} |
||||
|
} |
||||
@ -1,54 +0,0 @@ |
|||||
// Copyright (c) The Avalonia Project. All rights reserved.
|
|
||||
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|
||||
|
|
||||
using System; |
|
||||
using System.Linq; |
|
||||
using System.Reactive.Linq; |
|
||||
using Avalonia.Threading; |
|
||||
|
|
||||
namespace Avalonia.Animation |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Provides global timing functions for animations.
|
|
||||
/// </summary>
|
|
||||
public static class Timing |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// The number of frames per second.
|
|
||||
/// </summary>
|
|
||||
public const int FramesPerSecond = 60; |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// The time span of each frame.
|
|
||||
/// </summary>
|
|
||||
internal static readonly TimeSpan FrameTick = TimeSpan.FromSeconds(1.0 / FramesPerSecond); |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Initializes static members of the <see cref="Timing"/> class.
|
|
||||
/// </summary>
|
|
||||
static Timing() |
|
||||
{ |
|
||||
var globalTimer = Observable.Interval(FrameTick, AvaloniaScheduler.Instance); |
|
||||
|
|
||||
AnimationsTimer = globalTimer |
|
||||
.Select(_ => GetTickCount()) |
|
||||
.Publish() |
|
||||
.RefCount(); |
|
||||
} |
|
||||
|
|
||||
internal static TimeSpan GetTickCount() => TimeSpan.FromMilliseconds(Environment.TickCount); |
|
||||
|
|
||||
/// <summary>
|
|
||||
/// Gets the animation timer.
|
|
||||
/// </summary>
|
|
||||
/// <remarks>
|
|
||||
/// The animation timer triggers usually at 60 times per second or as
|
|
||||
/// defined in <see cref="FramesPerSecond"/>.
|
|
||||
/// The parameter passed to a subsciber is the current playstate of the animation.
|
|
||||
/// </remarks>
|
|
||||
internal static IObservable<TimeSpan> AnimationsTimer |
|
||||
{ |
|
||||
get; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,18 @@ |
|||||
|
using System; |
||||
|
|
||||
|
namespace Avalonia.Platform.Interop |
||||
|
{ |
||||
|
public interface IDynamicLibraryLoader |
||||
|
{ |
||||
|
IntPtr LoadLibrary(string dll); |
||||
|
IntPtr GetProcAddress(IntPtr dll, string proc, bool optional); |
||||
|
} |
||||
|
|
||||
|
public class DynamicLibraryLoaderException : Exception |
||||
|
{ |
||||
|
public DynamicLibraryLoaderException(string message) : base(message) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,38 @@ |
|||||
|
// Copyright (c) The Avalonia Project. All rights reserved.
|
||||
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
||||
|
|
||||
|
using System; |
||||
|
using Avalonia.Interactivity; |
||||
|
|
||||
|
namespace Avalonia.Diagnostics.Models |
||||
|
{ |
||||
|
internal class EventChainLink |
||||
|
{ |
||||
|
public EventChainLink(object handler, bool handled, RoutingStrategies route) |
||||
|
{ |
||||
|
Contract.Requires<ArgumentNullException>(handler != null); |
||||
|
|
||||
|
this.Handler = handler; |
||||
|
this.Handled = handled; |
||||
|
this.Route = route; |
||||
|
} |
||||
|
|
||||
|
public object Handler { get; } |
||||
|
|
||||
|
public string HandlerName |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
if (Handler is INamed named && !string.IsNullOrEmpty(named.Name)) |
||||
|
{ |
||||
|
return named.Name + " (" + Handler.GetType().Name + ")"; |
||||
|
} |
||||
|
return Handler.GetType().Name; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public bool Handled { get; } |
||||
|
|
||||
|
public RoutingStrategies Route { get; } |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,61 @@ |
|||||
|
// Copyright (c) The Avalonia Project. All rights reserved.
|
||||
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
||||
|
|
||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Linq; |
||||
|
using Avalonia.Collections; |
||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.Input; |
||||
|
using Avalonia.Interactivity; |
||||
|
|
||||
|
namespace Avalonia.Diagnostics.ViewModels |
||||
|
{ |
||||
|
internal class EventOwnerTreeNode : EventTreeNodeBase |
||||
|
{ |
||||
|
private static readonly RoutedEvent[] s_defaultEvents = new RoutedEvent[] |
||||
|
{ |
||||
|
Button.ClickEvent, |
||||
|
InputElement.KeyDownEvent, |
||||
|
InputElement.KeyUpEvent, |
||||
|
InputElement.TextInputEvent, |
||||
|
InputElement.PointerReleasedEvent, |
||||
|
InputElement.PointerPressedEvent, |
||||
|
}; |
||||
|
|
||||
|
public EventOwnerTreeNode(Type type, IEnumerable<RoutedEvent> events, EventsViewModel vm) |
||||
|
: base(null, type.Name) |
||||
|
{ |
||||
|
this.Children = new AvaloniaList<EventTreeNodeBase>(events.OrderBy(e => e.Name) |
||||
|
.Select(e => new EventTreeNode(this, e, vm) { IsEnabled = s_defaultEvents.Contains(e) })); |
||||
|
this.IsExpanded = true; |
||||
|
} |
||||
|
|
||||
|
public override bool? IsEnabled |
||||
|
{ |
||||
|
get => base.IsEnabled; |
||||
|
set |
||||
|
{ |
||||
|
if (base.IsEnabled != value) |
||||
|
{ |
||||
|
base.IsEnabled = value; |
||||
|
if (_updateChildren && value != null) |
||||
|
{ |
||||
|
foreach (var child in Children) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
child._updateParent = false; |
||||
|
child.IsEnabled = value; |
||||
|
} |
||||
|
finally |
||||
|
{ |
||||
|
child._updateParent = true; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,98 @@ |
|||||
|
// Copyright (c) The Avalonia Project. All rights reserved.
|
||||
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
||||
|
|
||||
|
using System; |
||||
|
|
||||
|
using Avalonia.Diagnostics.Models; |
||||
|
using Avalonia.Interactivity; |
||||
|
using Avalonia.Threading; |
||||
|
using Avalonia.VisualTree; |
||||
|
|
||||
|
namespace Avalonia.Diagnostics.ViewModels |
||||
|
{ |
||||
|
internal class EventTreeNode : EventTreeNodeBase |
||||
|
{ |
||||
|
private RoutedEvent _event; |
||||
|
private EventsViewModel _parentViewModel; |
||||
|
private bool _isRegistered; |
||||
|
private FiredEvent _currentEvent; |
||||
|
|
||||
|
public EventTreeNode(EventOwnerTreeNode parent, RoutedEvent @event, EventsViewModel vm) |
||||
|
: base(parent, @event.Name) |
||||
|
{ |
||||
|
Contract.Requires<ArgumentNullException>(@event != null); |
||||
|
Contract.Requires<ArgumentNullException>(vm != null); |
||||
|
|
||||
|
this._event = @event; |
||||
|
this._parentViewModel = vm; |
||||
|
} |
||||
|
|
||||
|
public override bool? IsEnabled |
||||
|
{ |
||||
|
get => base.IsEnabled; |
||||
|
set |
||||
|
{ |
||||
|
if (base.IsEnabled != value) |
||||
|
{ |
||||
|
base.IsEnabled = value; |
||||
|
UpdateTracker(); |
||||
|
if (Parent != null && _updateParent) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
Parent._updateChildren = false; |
||||
|
Parent.UpdateChecked(); |
||||
|
} |
||||
|
finally |
||||
|
{ |
||||
|
Parent._updateChildren = true; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void UpdateTracker() |
||||
|
{ |
||||
|
if (IsEnabled.GetValueOrDefault() && !_isRegistered) |
||||
|
{ |
||||
|
_event.AddClassHandler(typeof(object), HandleEvent, (RoutingStrategies)7, handledEventsToo: true); |
||||
|
_isRegistered = true; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void HandleEvent(object sender, RoutedEventArgs e) |
||||
|
{ |
||||
|
if (!_isRegistered || IsEnabled == false) |
||||
|
return; |
||||
|
if (sender is IVisual v && DevTools.BelongsToDevTool(v)) |
||||
|
return; |
||||
|
|
||||
|
var s = sender; |
||||
|
var handled = e.Handled; |
||||
|
var route = e.Route; |
||||
|
|
||||
|
Action handler = delegate |
||||
|
{ |
||||
|
if (_currentEvent == null || !_currentEvent.IsPartOfSameEventChain(e)) |
||||
|
{ |
||||
|
_currentEvent = new FiredEvent(e, new EventChainLink(s, handled, route)); |
||||
|
|
||||
|
_parentViewModel.RecordedEvents.Add(_currentEvent); |
||||
|
|
||||
|
while (_parentViewModel.RecordedEvents.Count > 100) |
||||
|
_parentViewModel.RecordedEvents.RemoveAt(0); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
_currentEvent.AddToChain(new EventChainLink(s, handled, route)); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
if (!Dispatcher.UIThread.CheckAccess()) |
||||
|
Dispatcher.UIThread.Post(handler); |
||||
|
else |
||||
|
handler(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,78 @@ |
|||||
|
// Copyright (c) The Avalonia Project. All rights reserved.
|
||||
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
||||
|
|
||||
|
using Avalonia.Collections; |
||||
|
|
||||
|
namespace Avalonia.Diagnostics.ViewModels |
||||
|
{ |
||||
|
internal abstract class EventTreeNodeBase : ViewModelBase |
||||
|
{ |
||||
|
internal bool _updateChildren = true; |
||||
|
internal bool _updateParent = true; |
||||
|
private bool _isExpanded; |
||||
|
private bool? _isEnabled = false; |
||||
|
|
||||
|
public EventTreeNodeBase(EventTreeNodeBase parent, string text) |
||||
|
{ |
||||
|
this.Parent = parent; |
||||
|
this.Text = text; |
||||
|
} |
||||
|
|
||||
|
public IAvaloniaReadOnlyList<EventTreeNodeBase> Children |
||||
|
{ |
||||
|
get; |
||||
|
protected set; |
||||
|
} |
||||
|
|
||||
|
public bool IsExpanded |
||||
|
{ |
||||
|
get { return _isExpanded; } |
||||
|
set { RaiseAndSetIfChanged(ref _isExpanded, value); } |
||||
|
} |
||||
|
|
||||
|
public virtual bool? IsEnabled |
||||
|
{ |
||||
|
get { return _isEnabled; } |
||||
|
set { RaiseAndSetIfChanged(ref _isEnabled, value); } |
||||
|
} |
||||
|
|
||||
|
public EventTreeNodeBase Parent |
||||
|
{ |
||||
|
get; |
||||
|
} |
||||
|
|
||||
|
public string Text |
||||
|
{ |
||||
|
get; |
||||
|
private set; |
||||
|
} |
||||
|
|
||||
|
internal void UpdateChecked() |
||||
|
{ |
||||
|
IsEnabled = GetValue(); |
||||
|
|
||||
|
bool? GetValue() |
||||
|
{ |
||||
|
if (Children == null) |
||||
|
return false; |
||||
|
bool? value = false; |
||||
|
for (int i = 0; i < Children.Count; i++) |
||||
|
{ |
||||
|
if (i == 0) |
||||
|
{ |
||||
|
value = Children[i].IsEnabled; |
||||
|
continue; |
||||
|
} |
||||
|
|
||||
|
if (value != Children[i].IsEnabled) |
||||
|
{ |
||||
|
value = null; |
||||
|
break; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return value; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,60 @@ |
|||||
|
// Copyright (c) The Avalonia Project. All rights reserved.
|
||||
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
||||
|
|
||||
|
using System; |
||||
|
using System.Collections.ObjectModel; |
||||
|
using System.Globalization; |
||||
|
using System.Linq; |
||||
|
using System.Windows.Input; |
||||
|
|
||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.Data.Converters; |
||||
|
using Avalonia.Interactivity; |
||||
|
using Avalonia.Media; |
||||
|
|
||||
|
namespace Avalonia.Diagnostics.ViewModels |
||||
|
{ |
||||
|
internal class EventsViewModel : ViewModelBase |
||||
|
{ |
||||
|
private readonly IControl _root; |
||||
|
private FiredEvent _selectedEvent; |
||||
|
|
||||
|
public EventsViewModel(IControl root) |
||||
|
{ |
||||
|
this._root = root; |
||||
|
this.Nodes = RoutedEventRegistry.Instance.GetAllRegistered() |
||||
|
.GroupBy(e => e.OwnerType) |
||||
|
.OrderBy(e => e.Key.Name) |
||||
|
.Select(g => new EventOwnerTreeNode(g.Key, g, this)) |
||||
|
.ToArray(); |
||||
|
} |
||||
|
|
||||
|
public EventTreeNodeBase[] Nodes { get; } |
||||
|
|
||||
|
public ObservableCollection<FiredEvent> RecordedEvents { get; } = new ObservableCollection<FiredEvent>(); |
||||
|
|
||||
|
public FiredEvent SelectedEvent |
||||
|
{ |
||||
|
get => _selectedEvent; |
||||
|
set => RaiseAndSetIfChanged(ref _selectedEvent, value); |
||||
|
} |
||||
|
|
||||
|
private void Clear() |
||||
|
{ |
||||
|
RecordedEvents.Clear(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
internal class BoolToBrushConverter : IValueConverter |
||||
|
{ |
||||
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) |
||||
|
{ |
||||
|
return (bool)value ? Brushes.LightGreen : Brushes.Transparent; |
||||
|
} |
||||
|
|
||||
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) |
||||
|
{ |
||||
|
throw new NotImplementedException(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,80 @@ |
|||||
|
// Copyright (c) The Avalonia Project. All rights reserved.
|
||||
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
||||
|
|
||||
|
using System; |
||||
|
using System.Collections.ObjectModel; |
||||
|
|
||||
|
using Avalonia.Diagnostics.Models; |
||||
|
using Avalonia.Interactivity; |
||||
|
|
||||
|
namespace Avalonia.Diagnostics.ViewModels |
||||
|
{ |
||||
|
internal class FiredEvent : ViewModelBase |
||||
|
{ |
||||
|
private RoutedEventArgs _eventArgs; |
||||
|
private EventChainLink _handledBy; |
||||
|
|
||||
|
public FiredEvent(RoutedEventArgs eventArgs, EventChainLink originator) |
||||
|
{ |
||||
|
Contract.Requires<ArgumentNullException>(eventArgs != null); |
||||
|
Contract.Requires<ArgumentNullException>(originator != null); |
||||
|
|
||||
|
this._eventArgs = eventArgs; |
||||
|
this.Originator = originator; |
||||
|
AddToChain(originator); |
||||
|
} |
||||
|
|
||||
|
public bool IsPartOfSameEventChain(RoutedEventArgs e) |
||||
|
{ |
||||
|
return e == _eventArgs; |
||||
|
} |
||||
|
|
||||
|
public RoutedEvent Event => _eventArgs.RoutedEvent; |
||||
|
|
||||
|
public bool IsHandled => HandledBy?.Handled == true; |
||||
|
|
||||
|
public ObservableCollection<EventChainLink> EventChain { get; } = new ObservableCollection<EventChainLink>(); |
||||
|
|
||||
|
public string DisplayText |
||||
|
{ |
||||
|
get |
||||
|
{ |
||||
|
if (IsHandled) |
||||
|
{ |
||||
|
return $"{Event.Name} on {Originator.HandlerName};" + Environment.NewLine + |
||||
|
$"strategies: {Event.RoutingStrategies}; handled by: {HandledBy.HandlerName}"; |
||||
|
} |
||||
|
return $"{Event.Name} on {Originator.HandlerName}; strategies: {Event.RoutingStrategies}"; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public EventChainLink Originator { get; } |
||||
|
|
||||
|
public EventChainLink HandledBy |
||||
|
{ |
||||
|
get { return _handledBy; } |
||||
|
set |
||||
|
{ |
||||
|
if (_handledBy != value) |
||||
|
{ |
||||
|
_handledBy = value; |
||||
|
RaisePropertyChanged(); |
||||
|
RaisePropertyChanged(nameof(IsHandled)); |
||||
|
RaisePropertyChanged(nameof(DisplayText)); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
public void AddToChain(object handler, bool handled, RoutingStrategies route) |
||||
|
{ |
||||
|
AddToChain(new EventChainLink(handler, handled, route)); |
||||
|
} |
||||
|
|
||||
|
public void AddToChain(EventChainLink link) |
||||
|
{ |
||||
|
EventChain.Add(link); |
||||
|
if (HandledBy == null && link.Handled) |
||||
|
HandledBy = link; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,53 @@ |
|||||
|
<UserControl xmlns="https://github.com/avaloniaui" |
||||
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
||||
|
xmlns:vm="clr-namespace:Avalonia.Diagnostics.ViewModels"> |
||||
|
<UserControl.Resources> |
||||
|
<vm:BoolToBrushConverter x:Key="boolToBrush" /> |
||||
|
</UserControl.Resources> |
||||
|
<Grid ColumnDefinitions="*,4,3*"> |
||||
|
<TreeView Name="tree" Items="{Binding Nodes}" SelectedItem="{Binding SelectedNode, Mode=TwoWay}" Grid.RowSpan="2"> |
||||
|
<TreeView.DataTemplates> |
||||
|
<TreeDataTemplate DataType="vm:EventTreeNodeBase" |
||||
|
ItemsSource="{Binding Children}"> |
||||
|
<CheckBox Content="{Binding Text}" IsChecked="{Binding IsEnabled, Mode=TwoWay}" /> |
||||
|
</TreeDataTemplate> |
||||
|
</TreeView.DataTemplates> |
||||
|
<TreeView.Styles> |
||||
|
<Style Selector="TreeViewItem"> |
||||
|
<Setter Property="IsExpanded" Value="{Binding IsExpanded, Mode=TwoWay}"/> |
||||
|
</Style> |
||||
|
</TreeView.Styles> |
||||
|
</TreeView> |
||||
|
|
||||
|
<GridSplitter Width="4" Grid.Column="1" /> |
||||
|
<Grid RowDefinitions="*,4,2*,Auto" Grid.Column="2"> |
||||
|
<ListBox Name="eventsList" Items="{Binding RecordedEvents}" SelectedItem="{Binding SelectedEvent, Mode=TwoWay}"> |
||||
|
<ListBox.ItemTemplate> |
||||
|
<DataTemplate> |
||||
|
<TextBlock Background="{Binding IsHandled, Converter={StaticResource boolToBrush}}" Text="{Binding DisplayText}" /> |
||||
|
</DataTemplate> |
||||
|
</ListBox.ItemTemplate> |
||||
|
</ListBox> |
||||
|
<GridSplitter Height="4" Grid.Row="1" /> |
||||
|
<DockPanel Grid.Row="2" LastChildFill="True"> |
||||
|
<TextBlock DockPanel.Dock="Top" FontSize="16" Text="Event chain:" /> |
||||
|
<ListBox Items="{Binding SelectedEvent.EventChain}"> |
||||
|
<ListBox.ItemTemplate> |
||||
|
<DataTemplate> |
||||
|
<StackPanel Orientation="Horizontal" Background="{Binding Handled, Converter={StaticResource boolToBrush}}"> |
||||
|
<TextBlock Text="{Binding Route}" /> |
||||
|
<TextBlock Text=": " /> |
||||
|
<TextBlock Text="{Binding HandlerName}" /> |
||||
|
<TextBlock Text=" handled: " /> |
||||
|
<TextBlock Text="{Binding Handled}" /> |
||||
|
</StackPanel> |
||||
|
</DataTemplate> |
||||
|
</ListBox.ItemTemplate> |
||||
|
</ListBox> |
||||
|
</DockPanel> |
||||
|
<StackPanel Orientation="Horizontal" Grid.Row="3"> |
||||
|
<Button Content="Clear" Margin="3" Command="{Binding Clear}" /> |
||||
|
</StackPanel> |
||||
|
</Grid> |
||||
|
</Grid> |
||||
|
</UserControl> |
||||
@ -0,0 +1,32 @@ |
|||||
|
// Copyright (c) The Avalonia Project. All rights reserved.
|
||||
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
||||
|
|
||||
|
using System.Linq; |
||||
|
|
||||
|
using Avalonia.Controls; |
||||
|
using Avalonia.Diagnostics.ViewModels; |
||||
|
using Avalonia.Markup.Xaml; |
||||
|
|
||||
|
namespace Avalonia.Diagnostics.Views |
||||
|
{ |
||||
|
public class EventsView : UserControl |
||||
|
{ |
||||
|
private ListBox _events; |
||||
|
|
||||
|
public EventsView() |
||||
|
{ |
||||
|
this.InitializeComponent(); |
||||
|
_events = this.FindControl<ListBox>("events"); |
||||
|
} |
||||
|
|
||||
|
private void RecordedEvents_CollectionChanged(object sender, System.Collections.Specialized.NotifyCollectionChangedEventArgs e) |
||||
|
{ |
||||
|
_events.ScrollIntoView(_events.Items.OfType<FiredEvent>().LastOrDefault()); |
||||
|
} |
||||
|
|
||||
|
private void InitializeComponent() |
||||
|
{ |
||||
|
AvaloniaXamlLoader.Load(this); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,98 @@ |
|||||
|
using System.Collections.Generic; |
||||
|
|
||||
|
namespace Avalonia.Input.Platform |
||||
|
{ |
||||
|
public class PlatformHotkeyConfiguration |
||||
|
{ |
||||
|
public PlatformHotkeyConfiguration() : this(InputModifiers.Control) |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
|
||||
|
public PlatformHotkeyConfiguration(InputModifiers commandModifiers, |
||||
|
InputModifiers selectionModifiers = InputModifiers.Shift, |
||||
|
InputModifiers wholeWordTextActionModifiers = InputModifiers.Control) |
||||
|
{ |
||||
|
CommandModifiers = commandModifiers; |
||||
|
SelectionModifiers = selectionModifiers; |
||||
|
WholeWordTextActionModifiers = wholeWordTextActionModifiers; |
||||
|
Copy = new List<KeyGesture> |
||||
|
{ |
||||
|
new KeyGesture(Key.C, commandModifiers) |
||||
|
}; |
||||
|
Cut = new List<KeyGesture> |
||||
|
{ |
||||
|
new KeyGesture(Key.X, commandModifiers) |
||||
|
}; |
||||
|
Paste = new List<KeyGesture> |
||||
|
{ |
||||
|
new KeyGesture(Key.V, commandModifiers) |
||||
|
}; |
||||
|
Undo = new List<KeyGesture> |
||||
|
{ |
||||
|
new KeyGesture(Key.Z, commandModifiers) |
||||
|
}; |
||||
|
Redo = new List<KeyGesture> |
||||
|
{ |
||||
|
new KeyGesture(Key.Y, commandModifiers), |
||||
|
new KeyGesture(Key.Z, commandModifiers | selectionModifiers) |
||||
|
}; |
||||
|
SelectAll = new List<KeyGesture> |
||||
|
{ |
||||
|
new KeyGesture(Key.A, commandModifiers) |
||||
|
}; |
||||
|
MoveCursorToTheStartOfLine = new List<KeyGesture> |
||||
|
{ |
||||
|
new KeyGesture(Key.Home) |
||||
|
}; |
||||
|
MoveCursorToTheEndOfLine = new List<KeyGesture> |
||||
|
{ |
||||
|
new KeyGesture(Key.End) |
||||
|
}; |
||||
|
MoveCursorToTheStartOfDocument = new List<KeyGesture> |
||||
|
{ |
||||
|
new KeyGesture(Key.Home, commandModifiers) |
||||
|
}; |
||||
|
MoveCursorToTheEndOfDocument = new List<KeyGesture> |
||||
|
{ |
||||
|
new KeyGesture(Key.End, commandModifiers) |
||||
|
}; |
||||
|
MoveCursorToTheStartOfLineWithSelection = new List<KeyGesture> |
||||
|
{ |
||||
|
new KeyGesture(Key.Home, selectionModifiers) |
||||
|
}; |
||||
|
MoveCursorToTheEndOfLineWithSelection = new List<KeyGesture> |
||||
|
{ |
||||
|
new KeyGesture(Key.End, selectionModifiers) |
||||
|
}; |
||||
|
MoveCursorToTheStartOfDocumentWithSelection = new List<KeyGesture> |
||||
|
{ |
||||
|
new KeyGesture(Key.Home, commandModifiers | selectionModifiers) |
||||
|
}; |
||||
|
MoveCursorToTheEndOfDocumentWithSelection = new List<KeyGesture> |
||||
|
{ |
||||
|
new KeyGesture(Key.End, commandModifiers | selectionModifiers) |
||||
|
}; |
||||
|
} |
||||
|
|
||||
|
public InputModifiers CommandModifiers { get; set; } |
||||
|
public InputModifiers WholeWordTextActionModifiers { get; set; } |
||||
|
public InputModifiers SelectionModifiers { get; set; } |
||||
|
public List<KeyGesture> Copy { get; set; } |
||||
|
public List<KeyGesture> Cut { get; set; } |
||||
|
public List<KeyGesture> Paste { get; set; } |
||||
|
public List<KeyGesture> Undo { get; set; } |
||||
|
public List<KeyGesture> Redo { get; set; } |
||||
|
public List<KeyGesture> SelectAll { get; set; } |
||||
|
public List<KeyGesture> MoveCursorToTheStartOfLine { get; set; } |
||||
|
public List<KeyGesture> MoveCursorToTheEndOfLine { get; set; } |
||||
|
public List<KeyGesture> MoveCursorToTheStartOfDocument { get; set; } |
||||
|
public List<KeyGesture> MoveCursorToTheEndOfDocument { get; set; } |
||||
|
public List<KeyGesture> MoveCursorToTheStartOfLineWithSelection { get; set; } |
||||
|
public List<KeyGesture> MoveCursorToTheEndOfLineWithSelection { get; set; } |
||||
|
public List<KeyGesture> MoveCursorToTheStartOfDocumentWithSelection { get; set; } |
||||
|
public List<KeyGesture> MoveCursorToTheEndOfDocumentWithSelection { get; set; } |
||||
|
|
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,4 @@ |
|||||
|
build |
||||
|
|
||||
|
Avalonia.Native.OSX.xcodeproj/xcuserdata |
||||
|
Avalonia.Native.OSX.xcodeproj/project.xcworkspace/xcuserdata |
||||
@ -0,0 +1,328 @@ |
|||||
|
// !$*UTF8*$! |
||||
|
{ |
||||
|
archiveVersion = 1; |
||||
|
classes = { |
||||
|
}; |
||||
|
objectVersion = 46; |
||||
|
objects = { |
||||
|
|
||||
|
/* Begin PBXBuildFile section */ |
||||
|
37A517B32159597E00FBA241 /* Screens.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37A517B22159597E00FBA241 /* Screens.mm */; }; |
||||
|
37C09D8821580FE4006A6758 /* SystemDialogs.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37C09D8721580FE4006A6758 /* SystemDialogs.mm */; }; |
||||
|
37E2330F21583241000CB7E2 /* KeyTransform.mm in Sources */ = {isa = PBXBuildFile; fileRef = 37E2330E21583241000CB7E2 /* KeyTransform.mm */; }; |
||||
|
5B21A982216530F500CEE36E /* cursor.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5B21A981216530F500CEE36E /* cursor.mm */; }; |
||||
|
5B8BD94F215BFEA6005ED2A7 /* clipboard.mm in Sources */ = {isa = PBXBuildFile; fileRef = 5B8BD94E215BFEA6005ED2A7 /* clipboard.mm */; }; |
||||
|
AB00E4F72147CA920032A60A /* main.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB00E4F62147CA920032A60A /* main.mm */; }; |
||||
|
AB1E522C217613570091CD71 /* OpenGL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB1E522B217613570091CD71 /* OpenGL.framework */; }; |
||||
|
AB573DC4217605E400D389A2 /* gl.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB573DC3217605E400D389A2 /* gl.mm */; }; |
||||
|
AB661C1E2148230F00291242 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = AB661C1D2148230F00291242 /* AppKit.framework */; }; |
||||
|
AB661C202148286E00291242 /* window.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB661C1F2148286E00291242 /* window.mm */; }; |
||||
|
AB8F7D6B21482D7F0057DBA5 /* platformthreading.mm in Sources */ = {isa = PBXBuildFile; fileRef = AB8F7D6A21482D7F0057DBA5 /* platformthreading.mm */; }; |
||||
|
/* End PBXBuildFile section */ |
||||
|
|
||||
|
/* Begin PBXFileReference section */ |
||||
|
379860FE214DA0C000CD0246 /* KeyTransform.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = KeyTransform.h; sourceTree = "<group>"; }; |
||||
|
37A4E71A2178846A00EACBCD /* headers */ = {isa = PBXFileReference; lastKnownFileType = folder; name = headers; path = ../Avalonia.Native/headers; sourceTree = "<group>"; }; |
||||
|
37A517B22159597E00FBA241 /* Screens.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = Screens.mm; sourceTree = "<group>"; }; |
||||
|
37C09D8721580FE4006A6758 /* SystemDialogs.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = SystemDialogs.mm; sourceTree = "<group>"; }; |
||||
|
37C09D8A21581EF2006A6758 /* window.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = window.h; sourceTree = "<group>"; }; |
||||
|
37E2330E21583241000CB7E2 /* KeyTransform.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = KeyTransform.mm; sourceTree = "<group>"; }; |
||||
|
5B21A981216530F500CEE36E /* cursor.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = cursor.mm; sourceTree = "<group>"; }; |
||||
|
5B8BD94E215BFEA6005ED2A7 /* clipboard.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = clipboard.mm; sourceTree = "<group>"; }; |
||||
|
5BF943652167AD1D009CAE35 /* cursor.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cursor.h; sourceTree = "<group>"; }; |
||||
|
AB00E4F62147CA920032A60A /* main.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = main.mm; sourceTree = "<group>"; }; |
||||
|
AB1E522B217613570091CD71 /* OpenGL.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = OpenGL.framework; path = System/Library/Frameworks/OpenGL.framework; sourceTree = SDKROOT; }; |
||||
|
AB573DC3217605E400D389A2 /* gl.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = gl.mm; sourceTree = "<group>"; }; |
||||
|
AB661C1D2148230F00291242 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; }; |
||||
|
AB661C1F2148286E00291242 /* window.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = window.mm; sourceTree = "<group>"; }; |
||||
|
AB661C212148288600291242 /* common.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = common.h; sourceTree = "<group>"; }; |
||||
|
AB7A61EF2147C815003C5833 /* libAvalonia.Native.OSX.dylib */ = {isa = PBXFileReference; explicitFileType = "compiled.mach-o.dylib"; includeInIndex = 0; path = libAvalonia.Native.OSX.dylib; sourceTree = BUILT_PRODUCTS_DIR; }; |
||||
|
AB8F7D6A21482D7F0057DBA5 /* platformthreading.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = platformthreading.mm; sourceTree = "<group>"; }; |
||||
|
/* End PBXFileReference section */ |
||||
|
|
||||
|
/* Begin PBXFrameworksBuildPhase section */ |
||||
|
AB7A61EC2147C814003C5833 /* Frameworks */ = { |
||||
|
isa = PBXFrameworksBuildPhase; |
||||
|
buildActionMask = 2147483647; |
||||
|
files = ( |
||||
|
AB1E522C217613570091CD71 /* OpenGL.framework in Frameworks */, |
||||
|
AB661C1E2148230F00291242 /* AppKit.framework in Frameworks */, |
||||
|
); |
||||
|
runOnlyForDeploymentPostprocessing = 0; |
||||
|
}; |
||||
|
/* End PBXFrameworksBuildPhase section */ |
||||
|
|
||||
|
/* Begin PBXGroup section */ |
||||
|
AB661C1C2148230E00291242 /* Frameworks */ = { |
||||
|
isa = PBXGroup; |
||||
|
children = ( |
||||
|
AB1E522B217613570091CD71 /* OpenGL.framework */, |
||||
|
AB661C1D2148230F00291242 /* AppKit.framework */, |
||||
|
); |
||||
|
name = Frameworks; |
||||
|
sourceTree = "<group>"; |
||||
|
}; |
||||
|
AB7A61E62147C814003C5833 = { |
||||
|
isa = PBXGroup; |
||||
|
children = ( |
||||
|
37A4E71A2178846A00EACBCD /* headers */, |
||||
|
AB573DC3217605E400D389A2 /* gl.mm */, |
||||
|
5BF943652167AD1D009CAE35 /* cursor.h */, |
||||
|
5B21A981216530F500CEE36E /* cursor.mm */, |
||||
|
5B8BD94E215BFEA6005ED2A7 /* clipboard.mm */, |
||||
|
AB8F7D6A21482D7F0057DBA5 /* platformthreading.mm */, |
||||
|
AB661C212148288600291242 /* common.h */, |
||||
|
379860FE214DA0C000CD0246 /* KeyTransform.h */, |
||||
|
37E2330E21583241000CB7E2 /* KeyTransform.mm */, |
||||
|
AB661C1F2148286E00291242 /* window.mm */, |
||||
|
37C09D8A21581EF2006A6758 /* window.h */, |
||||
|
AB00E4F62147CA920032A60A /* main.mm */, |
||||
|
37A517B22159597E00FBA241 /* Screens.mm */, |
||||
|
37C09D8721580FE4006A6758 /* SystemDialogs.mm */, |
||||
|
AB7A61F02147C815003C5833 /* Products */, |
||||
|
AB661C1C2148230E00291242 /* Frameworks */, |
||||
|
); |
||||
|
sourceTree = "<group>"; |
||||
|
}; |
||||
|
AB7A61F02147C815003C5833 /* Products */ = { |
||||
|
isa = PBXGroup; |
||||
|
children = ( |
||||
|
AB7A61EF2147C815003C5833 /* libAvalonia.Native.OSX.dylib */, |
||||
|
); |
||||
|
name = Products; |
||||
|
sourceTree = "<group>"; |
||||
|
}; |
||||
|
/* End PBXGroup section */ |
||||
|
|
||||
|
/* Begin PBXHeadersBuildPhase section */ |
||||
|
AB7A61ED2147C814003C5833 /* Headers */ = { |
||||
|
isa = PBXHeadersBuildPhase; |
||||
|
buildActionMask = 2147483647; |
||||
|
files = ( |
||||
|
); |
||||
|
runOnlyForDeploymentPostprocessing = 0; |
||||
|
}; |
||||
|
/* End PBXHeadersBuildPhase section */ |
||||
|
|
||||
|
/* Begin PBXNativeTarget section */ |
||||
|
AB7A61EE2147C814003C5833 /* Avalonia.Native.OSX */ = { |
||||
|
isa = PBXNativeTarget; |
||||
|
buildConfigurationList = AB7A61F82147C815003C5833 /* Build configuration list for PBXNativeTarget "Avalonia.Native.OSX" */; |
||||
|
buildPhases = ( |
||||
|
AB7A61EB2147C814003C5833 /* Sources */, |
||||
|
AB7A61EC2147C814003C5833 /* Frameworks */, |
||||
|
AB7A61ED2147C814003C5833 /* Headers */, |
||||
|
); |
||||
|
buildRules = ( |
||||
|
); |
||||
|
dependencies = ( |
||||
|
); |
||||
|
name = Avalonia.Native.OSX; |
||||
|
productName = Avalonia.Native.OSX; |
||||
|
productReference = AB7A61EF2147C815003C5833 /* libAvalonia.Native.OSX.dylib */; |
||||
|
productType = "com.apple.product-type.library.dynamic"; |
||||
|
}; |
||||
|
/* End PBXNativeTarget section */ |
||||
|
|
||||
|
/* Begin PBXProject section */ |
||||
|
AB7A61E72147C814003C5833 /* Project object */ = { |
||||
|
isa = PBXProject; |
||||
|
attributes = { |
||||
|
LastUpgradeCheck = 1000; |
||||
|
ORGANIZATIONNAME = Avalonia; |
||||
|
TargetAttributes = { |
||||
|
AB7A61EE2147C814003C5833 = { |
||||
|
CreatedOnToolsVersion = 8.3.2; |
||||
|
ProvisioningStyle = Automatic; |
||||
|
}; |
||||
|
}; |
||||
|
}; |
||||
|
buildConfigurationList = AB7A61EA2147C814003C5833 /* Build configuration list for PBXProject "Avalonia.Native.OSX" */; |
||||
|
compatibilityVersion = "Xcode 3.2"; |
||||
|
developmentRegion = English; |
||||
|
hasScannedForEncodings = 0; |
||||
|
knownRegions = ( |
||||
|
en, |
||||
|
); |
||||
|
mainGroup = AB7A61E62147C814003C5833; |
||||
|
productRefGroup = AB7A61F02147C815003C5833 /* Products */; |
||||
|
projectDirPath = ""; |
||||
|
projectRoot = ""; |
||||
|
targets = ( |
||||
|
AB7A61EE2147C814003C5833 /* Avalonia.Native.OSX */, |
||||
|
); |
||||
|
}; |
||||
|
/* End PBXProject section */ |
||||
|
|
||||
|
/* Begin PBXSourcesBuildPhase section */ |
||||
|
AB7A61EB2147C814003C5833 /* Sources */ = { |
||||
|
isa = PBXSourcesBuildPhase; |
||||
|
buildActionMask = 2147483647; |
||||
|
files = ( |
||||
|
5B8BD94F215BFEA6005ED2A7 /* clipboard.mm in Sources */, |
||||
|
5B21A982216530F500CEE36E /* cursor.mm in Sources */, |
||||
|
AB8F7D6B21482D7F0057DBA5 /* platformthreading.mm in Sources */, |
||||
|
37E2330F21583241000CB7E2 /* KeyTransform.mm in Sources */, |
||||
|
37A517B32159597E00FBA241 /* Screens.mm in Sources */, |
||||
|
AB00E4F72147CA920032A60A /* main.mm in Sources */, |
||||
|
37C09D8821580FE4006A6758 /* SystemDialogs.mm in Sources */, |
||||
|
AB573DC4217605E400D389A2 /* gl.mm in Sources */, |
||||
|
AB661C202148286E00291242 /* window.mm in Sources */, |
||||
|
); |
||||
|
runOnlyForDeploymentPostprocessing = 0; |
||||
|
}; |
||||
|
/* End PBXSourcesBuildPhase section */ |
||||
|
|
||||
|
/* Begin XCBuildConfiguration section */ |
||||
|
AB7A61F62147C815003C5833 /* Debug */ = { |
||||
|
isa = XCBuildConfiguration; |
||||
|
buildSettings = { |
||||
|
ALWAYS_SEARCH_USER_PATHS = NO; |
||||
|
CLANG_ANALYZER_NONNULL = YES; |
||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; |
||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; |
||||
|
CLANG_CXX_LIBRARY = "libc++"; |
||||
|
CLANG_ENABLE_MODULES = YES; |
||||
|
CLANG_ENABLE_OBJC_ARC = YES; |
||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; |
||||
|
CLANG_WARN_BOOL_CONVERSION = YES; |
||||
|
CLANG_WARN_COMMA = YES; |
||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES; |
||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; |
||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; |
||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES; |
||||
|
CLANG_WARN_EMPTY_BODY = YES; |
||||
|
CLANG_WARN_ENUM_CONVERSION = YES; |
||||
|
CLANG_WARN_INFINITE_RECURSION = YES; |
||||
|
CLANG_WARN_INT_CONVERSION = YES; |
||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; |
||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; |
||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; |
||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; |
||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; |
||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES; |
||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES; |
||||
|
CLANG_WARN_UNREACHABLE_CODE = YES; |
||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; |
||||
|
CODE_SIGN_IDENTITY = "-"; |
||||
|
COPY_PHASE_STRIP = NO; |
||||
|
DEBUG_INFORMATION_FORMAT = dwarf; |
||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES; |
||||
|
ENABLE_TESTABILITY = YES; |
||||
|
GCC_C_LANGUAGE_STANDARD = gnu99; |
||||
|
GCC_DYNAMIC_NO_PIC = NO; |
||||
|
GCC_NO_COMMON_BLOCKS = YES; |
||||
|
GCC_OPTIMIZATION_LEVEL = 0; |
||||
|
GCC_PREPROCESSOR_DEFINITIONS = ( |
||||
|
"DEBUG=1", |
||||
|
"$(inherited)", |
||||
|
); |
||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; |
||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; |
||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES; |
||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; |
||||
|
GCC_WARN_UNUSED_FUNCTION = YES; |
||||
|
GCC_WARN_UNUSED_VARIABLE = YES; |
||||
|
MACOSX_DEPLOYMENT_TARGET = 10.12; |
||||
|
MTL_ENABLE_DEBUG_INFO = YES; |
||||
|
ONLY_ACTIVE_ARCH = YES; |
||||
|
SDKROOT = macosx; |
||||
|
}; |
||||
|
name = Debug; |
||||
|
}; |
||||
|
AB7A61F72147C815003C5833 /* Release */ = { |
||||
|
isa = XCBuildConfiguration; |
||||
|
buildSettings = { |
||||
|
ALWAYS_SEARCH_USER_PATHS = NO; |
||||
|
CLANG_ANALYZER_NONNULL = YES; |
||||
|
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; |
||||
|
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; |
||||
|
CLANG_CXX_LIBRARY = "libc++"; |
||||
|
CLANG_ENABLE_MODULES = YES; |
||||
|
CLANG_ENABLE_OBJC_ARC = YES; |
||||
|
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES; |
||||
|
CLANG_WARN_BOOL_CONVERSION = YES; |
||||
|
CLANG_WARN_COMMA = YES; |
||||
|
CLANG_WARN_CONSTANT_CONVERSION = YES; |
||||
|
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES; |
||||
|
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR; |
||||
|
CLANG_WARN_DOCUMENTATION_COMMENTS = YES; |
||||
|
CLANG_WARN_EMPTY_BODY = YES; |
||||
|
CLANG_WARN_ENUM_CONVERSION = YES; |
||||
|
CLANG_WARN_INFINITE_RECURSION = YES; |
||||
|
CLANG_WARN_INT_CONVERSION = YES; |
||||
|
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES; |
||||
|
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; |
||||
|
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; |
||||
|
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; |
||||
|
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; |
||||
|
CLANG_WARN_STRICT_PROTOTYPES = YES; |
||||
|
CLANG_WARN_SUSPICIOUS_MOVE = YES; |
||||
|
CLANG_WARN_UNREACHABLE_CODE = YES; |
||||
|
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; |
||||
|
CODE_SIGN_IDENTITY = "-"; |
||||
|
COPY_PHASE_STRIP = NO; |
||||
|
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; |
||||
|
ENABLE_NS_ASSERTIONS = NO; |
||||
|
ENABLE_STRICT_OBJC_MSGSEND = YES; |
||||
|
GCC_C_LANGUAGE_STANDARD = gnu99; |
||||
|
GCC_NO_COMMON_BLOCKS = YES; |
||||
|
GCC_WARN_64_TO_32_BIT_CONVERSION = YES; |
||||
|
GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; |
||||
|
GCC_WARN_UNDECLARED_SELECTOR = YES; |
||||
|
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; |
||||
|
GCC_WARN_UNUSED_FUNCTION = YES; |
||||
|
GCC_WARN_UNUSED_VARIABLE = YES; |
||||
|
MACOSX_DEPLOYMENT_TARGET = 10.12; |
||||
|
MTL_ENABLE_DEBUG_INFO = NO; |
||||
|
SDKROOT = macosx; |
||||
|
}; |
||||
|
name = Release; |
||||
|
}; |
||||
|
AB7A61F92147C815003C5833 /* Debug */ = { |
||||
|
isa = XCBuildConfiguration; |
||||
|
buildSettings = { |
||||
|
DYLIB_COMPATIBILITY_VERSION = 1; |
||||
|
DYLIB_CURRENT_VERSION = 1; |
||||
|
EXECUTABLE_PREFIX = lib; |
||||
|
HEADER_SEARCH_PATHS = ../Avalonia.Native/headers; |
||||
|
PRODUCT_NAME = "$(TARGET_NAME)"; |
||||
|
}; |
||||
|
name = Debug; |
||||
|
}; |
||||
|
AB7A61FA2147C815003C5833 /* Release */ = { |
||||
|
isa = XCBuildConfiguration; |
||||
|
buildSettings = { |
||||
|
DYLIB_COMPATIBILITY_VERSION = 1; |
||||
|
DYLIB_CURRENT_VERSION = 1; |
||||
|
EXECUTABLE_PREFIX = lib; |
||||
|
HEADER_SEARCH_PATHS = ../Avalonia.Native/headers; |
||||
|
PRODUCT_NAME = "$(TARGET_NAME)"; |
||||
|
}; |
||||
|
name = Release; |
||||
|
}; |
||||
|
/* End XCBuildConfiguration section */ |
||||
|
|
||||
|
/* Begin XCConfigurationList section */ |
||||
|
AB7A61EA2147C814003C5833 /* Build configuration list for PBXProject "Avalonia.Native.OSX" */ = { |
||||
|
isa = XCConfigurationList; |
||||
|
buildConfigurations = ( |
||||
|
AB7A61F62147C815003C5833 /* Debug */, |
||||
|
AB7A61F72147C815003C5833 /* Release */, |
||||
|
); |
||||
|
defaultConfigurationIsVisible = 0; |
||||
|
defaultConfigurationName = Release; |
||||
|
}; |
||||
|
AB7A61F82147C815003C5833 /* Build configuration list for PBXNativeTarget "Avalonia.Native.OSX" */ = { |
||||
|
isa = XCConfigurationList; |
||||
|
buildConfigurations = ( |
||||
|
AB7A61F92147C815003C5833 /* Debug */, |
||||
|
AB7A61FA2147C815003C5833 /* Release */, |
||||
|
); |
||||
|
defaultConfigurationIsVisible = 0; |
||||
|
defaultConfigurationName = Release; |
||||
|
}; |
||||
|
/* End XCConfigurationList section */ |
||||
|
}; |
||||
|
rootObject = AB7A61E72147C814003C5833 /* Project object */; |
||||
|
} |
||||
@ -0,0 +1,7 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<Workspace |
||||
|
version = "1.0"> |
||||
|
<FileRef |
||||
|
location = "self:Avalonia.Native.OSX.xcodeproj"> |
||||
|
</FileRef> |
||||
|
</Workspace> |
||||
@ -0,0 +1,91 @@ |
|||||
|
<?xml version="1.0" encoding="UTF-8"?> |
||||
|
<Scheme |
||||
|
LastUpgradeVersion = "1000" |
||||
|
version = "1.3"> |
||||
|
<BuildAction |
||||
|
parallelizeBuildables = "YES" |
||||
|
buildImplicitDependencies = "YES"> |
||||
|
<BuildActionEntries> |
||||
|
<BuildActionEntry |
||||
|
buildForTesting = "YES" |
||||
|
buildForRunning = "YES" |
||||
|
buildForProfiling = "YES" |
||||
|
buildForArchiving = "YES" |
||||
|
buildForAnalyzing = "YES"> |
||||
|
<BuildableReference |
||||
|
BuildableIdentifier = "primary" |
||||
|
BlueprintIdentifier = "AB7A61EE2147C814003C5833" |
||||
|
BuildableName = "libAvalonia.Native.OSX.dylib" |
||||
|
BlueprintName = "Avalonia.Native.OSX" |
||||
|
ReferencedContainer = "container:Avalonia.Native.OSX.xcodeproj"> |
||||
|
</BuildableReference> |
||||
|
</BuildActionEntry> |
||||
|
</BuildActionEntries> |
||||
|
</BuildAction> |
||||
|
<TestAction |
||||
|
buildConfiguration = "Debug" |
||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" |
||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" |
||||
|
shouldUseLaunchSchemeArgsEnv = "YES"> |
||||
|
<Testables> |
||||
|
</Testables> |
||||
|
<AdditionalOptions> |
||||
|
</AdditionalOptions> |
||||
|
</TestAction> |
||||
|
<LaunchAction |
||||
|
buildConfiguration = "Debug" |
||||
|
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB" |
||||
|
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB" |
||||
|
launchStyle = "0" |
||||
|
useCustomWorkingDirectory = "YES" |
||||
|
customWorkingDirectory = "$PROJECT_DIR/../../samples/ControlCatalog" |
||||
|
ignoresPersistentStateOnLaunch = "NO" |
||||
|
debugDocumentVersioning = "YES" |
||||
|
debugServiceExtension = "internal" |
||||
|
allowLocationSimulation = "YES"> |
||||
|
<PathRunnable |
||||
|
runnableDebuggingMode = "0" |
||||
|
FilePath = "/usr/local/share/dotnet/dotnet"> |
||||
|
</PathRunnable> |
||||
|
<MacroExpansion> |
||||
|
<BuildableReference |
||||
|
BuildableIdentifier = "primary" |
||||
|
BlueprintIdentifier = "AB7A61EE2147C814003C5833" |
||||
|
BuildableName = "libAvalonia.Native.OSX.dylib" |
||||
|
BlueprintName = "Avalonia.Native.OSX" |
||||
|
ReferencedContainer = "container:Avalonia.Native.OSX.xcodeproj"> |
||||
|
</BuildableReference> |
||||
|
</MacroExpansion> |
||||
|
<CommandLineArguments> |
||||
|
<CommandLineArgument |
||||
|
argument = "bin/Debug/netcoreapp2.0/ControlCatalog.dll" |
||||
|
isEnabled = "YES"> |
||||
|
</CommandLineArgument> |
||||
|
</CommandLineArguments> |
||||
|
<AdditionalOptions> |
||||
|
</AdditionalOptions> |
||||
|
</LaunchAction> |
||||
|
<ProfileAction |
||||
|
buildConfiguration = "Release" |
||||
|
shouldUseLaunchSchemeArgsEnv = "YES" |
||||
|
savedToolIdentifier = "" |
||||
|
useCustomWorkingDirectory = "NO" |
||||
|
debugDocumentVersioning = "YES"> |
||||
|
<MacroExpansion> |
||||
|
<BuildableReference |
||||
|
BuildableIdentifier = "primary" |
||||
|
BlueprintIdentifier = "AB7A61EE2147C814003C5833" |
||||
|
BuildableName = "libAvalonia.Native.OSX.dylib" |
||||
|
BlueprintName = "Avalonia.Native.OSX" |
||||
|
ReferencedContainer = "container:Avalonia.Native.OSX.xcodeproj"> |
||||
|
</BuildableReference> |
||||
|
</MacroExpansion> |
||||
|
</ProfileAction> |
||||
|
<AnalyzeAction |
||||
|
buildConfiguration = "Debug"> |
||||
|
</AnalyzeAction> |
||||
|
<ArchiveAction |
||||
|
buildConfiguration = "Release" |
||||
|
revealArchiveInOrganizer = "YES"> |
||||
|
</ArchiveAction> |
||||
|
</Scheme> |
||||
@ -0,0 +1,12 @@ |
|||||
|
// Copyright (c) The Avalonia Project. All rights reserved.
|
||||
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
||||
|
|
||||
|
#ifndef keytransform_h |
||||
|
#define keytransform_h |
||||
|
#include "common.h" |
||||
|
#include "key.h" |
||||
|
#include <map> |
||||
|
|
||||
|
extern std::map<int, AvnKey> s_KeyMap; |
||||
|
|
||||
|
#endif |
||||
@ -0,0 +1,241 @@ |
|||||
|
// Copyright (c) The Avalonia Project. All rights reserved. |
||||
|
// Licensed under the MIT license. See licence.md file in the project root for full license information. |
||||
|
|
||||
|
#include "KeyTransform.h" |
||||
|
|
||||
|
const int kVK_ANSI_A = 0x00; |
||||
|
const int kVK_ANSI_S = 0x01; |
||||
|
const int kVK_ANSI_D = 0x02; |
||||
|
const int kVK_ANSI_F = 0x03; |
||||
|
const int kVK_ANSI_H = 0x04; |
||||
|
const int kVK_ANSI_G = 0x05; |
||||
|
const int kVK_ANSI_Z = 0x06; |
||||
|
const int kVK_ANSI_X = 0x07; |
||||
|
const int kVK_ANSI_C = 0x08; |
||||
|
const int kVK_ANSI_V = 0x09; |
||||
|
const int kVK_ANSI_B = 0x0B; |
||||
|
const int kVK_ANSI_Q = 0x0C; |
||||
|
const int kVK_ANSI_W = 0x0D; |
||||
|
const int kVK_ANSI_E = 0x0E; |
||||
|
const int kVK_ANSI_R = 0x0F; |
||||
|
const int kVK_ANSI_Y = 0x10; |
||||
|
const int kVK_ANSI_T = 0x11; |
||||
|
const int kVK_ANSI_1 = 0x12; |
||||
|
const int kVK_ANSI_2 = 0x13; |
||||
|
const int kVK_ANSI_3 = 0x14; |
||||
|
const int kVK_ANSI_4 = 0x15; |
||||
|
const int kVK_ANSI_6 = 0x16; |
||||
|
const int kVK_ANSI_5 = 0x17; |
||||
|
//const int kVK_ANSI_Equal = 0x18; |
||||
|
const int kVK_ANSI_9 = 0x19; |
||||
|
const int kVK_ANSI_7 = 0x1A; |
||||
|
const int kVK_ANSI_Minus = 0x1B; |
||||
|
const int kVK_ANSI_8 = 0x1C; |
||||
|
const int kVK_ANSI_0 = 0x1D; |
||||
|
const int kVK_ANSI_RightBracket = 0x1E; |
||||
|
const int kVK_ANSI_O = 0x1F; |
||||
|
const int kVK_ANSI_U = 0x20; |
||||
|
const int kVK_ANSI_LeftBracket = 0x21; |
||||
|
const int kVK_ANSI_I = 0x22; |
||||
|
const int kVK_ANSI_P = 0x23; |
||||
|
const int kVK_ANSI_L = 0x25; |
||||
|
const int kVK_ANSI_J = 0x26; |
||||
|
const int kVK_ANSI_Quote = 0x27; |
||||
|
const int kVK_ANSI_K = 0x28; |
||||
|
const int kVK_ANSI_Semicolon = 0x29; |
||||
|
const int kVK_ANSI_Backslash = 0x2A; |
||||
|
const int kVK_ANSI_Comma = 0x2B; |
||||
|
//const int kVK_ANSI_Slash = 0x2C; |
||||
|
const int kVK_ANSI_N = 0x2D; |
||||
|
const int kVK_ANSI_M = 0x2E; |
||||
|
const int kVK_ANSI_Period = 0x2F; |
||||
|
//const int kVK_ANSI_Grave = 0x32; |
||||
|
const int kVK_ANSI_KeypadDecimal = 0x41; |
||||
|
const int kVK_ANSI_KeypadMultiply = 0x43; |
||||
|
const int kVK_ANSI_KeypadPlus = 0x45; |
||||
|
const int kVK_ANSI_KeypadClear = 0x47; |
||||
|
const int kVK_ANSI_KeypadDivide = 0x4B; |
||||
|
const int kVK_ANSI_KeypadEnter = 0x4C; |
||||
|
const int kVK_ANSI_KeypadMinus = 0x4E; |
||||
|
//const int kVK_ANSI_KeypadEquals = 0x51; |
||||
|
const int kVK_ANSI_Keypad0 = 0x52; |
||||
|
const int kVK_ANSI_Keypad1 = 0x53; |
||||
|
const int kVK_ANSI_Keypad2 = 0x54; |
||||
|
const int kVK_ANSI_Keypad3 = 0x55; |
||||
|
const int kVK_ANSI_Keypad4 = 0x56; |
||||
|
const int kVK_ANSI_Keypad5 = 0x57; |
||||
|
const int kVK_ANSI_Keypad6 = 0x58; |
||||
|
const int kVK_ANSI_Keypad7 = 0x59; |
||||
|
const int kVK_ANSI_Keypad8 = 0x5B; |
||||
|
const int kVK_ANSI_Keypad9 = 0x5C; |
||||
|
const int kVK_Return = 0x24; |
||||
|
const int kVK_Tab = 0x30; |
||||
|
const int kVK_Space = 0x31; |
||||
|
const int kVK_Delete = 0x33; |
||||
|
const int kVK_Escape = 0x35; |
||||
|
const int kVK_Command = 0x37; |
||||
|
const int kVK_Shift = 0x38; |
||||
|
const int kVK_CapsLock = 0x39; |
||||
|
const int kVK_Option = 0x3A; |
||||
|
const int kVK_Control = 0x3B; |
||||
|
const int kVK_RightCommand = 0x36; |
||||
|
const int kVK_RightShift = 0x3C; |
||||
|
const int kVK_RightOption = 0x3D; |
||||
|
const int kVK_RightControl = 0x3E; |
||||
|
//const int kVK_Function = 0x3F; |
||||
|
const int kVK_F17 = 0x40; |
||||
|
const int kVK_VolumeUp = 0x48; |
||||
|
const int kVK_VolumeDown = 0x49; |
||||
|
const int kVK_Mute = 0x4A; |
||||
|
const int kVK_F18 = 0x4F; |
||||
|
const int kVK_F19 = 0x50; |
||||
|
const int kVK_F20 = 0x5A; |
||||
|
const int kVK_F5 = 0x60; |
||||
|
const int kVK_F6 = 0x61; |
||||
|
const int kVK_F7 = 0x62; |
||||
|
const int kVK_F3 = 0x63; |
||||
|
const int kVK_F8 = 0x64; |
||||
|
const int kVK_F9 = 0x65; |
||||
|
const int kVK_F11 = 0x67; |
||||
|
const int kVK_F13 = 0x69; |
||||
|
const int kVK_F16 = 0x6A; |
||||
|
const int kVK_F14 = 0x6B; |
||||
|
const int kVK_F10 = 0x6D; |
||||
|
const int kVK_F12 = 0x6F; |
||||
|
const int kVK_F15 = 0x71; |
||||
|
const int kVK_Help = 0x72; |
||||
|
const int kVK_Home = 0x73; |
||||
|
const int kVK_PageUp = 0x74; |
||||
|
const int kVK_ForwardDelete = 0x75; |
||||
|
const int kVK_F4 = 0x76; |
||||
|
const int kVK_End = 0x77; |
||||
|
const int kVK_F2 = 0x78; |
||||
|
const int kVK_PageDown = 0x79; |
||||
|
const int kVK_F1 = 0x7A; |
||||
|
const int kVK_LeftArrow = 0x7B; |
||||
|
const int kVK_RightArrow = 0x7C; |
||||
|
const int kVK_DownArrow = 0x7D; |
||||
|
const int kVK_UpArrow = 0x7E; |
||||
|
//const int kVK_ISO_Section = 0x0A; |
||||
|
//const int kVK_JIS_Yen = 0x5D; |
||||
|
//const int kVK_JIS_Underscore = 0x5E; |
||||
|
//const int kVK_JIS_KeypadComma = 0x5F; |
||||
|
//const int kVK_JIS_Eisu = 0x66; |
||||
|
//const int kVK_JIS_Kana = 0x68; |
||||
|
|
||||
|
std::map<int, AvnKey> s_KeyMap = |
||||
|
{ |
||||
|
{kVK_ANSI_A, A}, |
||||
|
{kVK_ANSI_S, S}, |
||||
|
{kVK_ANSI_D, D}, |
||||
|
{kVK_ANSI_F, F}, |
||||
|
{kVK_ANSI_H, H}, |
||||
|
{kVK_ANSI_G, G}, |
||||
|
{kVK_ANSI_Z, Z}, |
||||
|
{kVK_ANSI_X, X}, |
||||
|
{kVK_ANSI_C, C}, |
||||
|
{kVK_ANSI_V, V}, |
||||
|
{kVK_ANSI_B, B}, |
||||
|
{kVK_ANSI_Q, Q}, |
||||
|
{kVK_ANSI_W, W}, |
||||
|
{kVK_ANSI_E, E}, |
||||
|
{kVK_ANSI_R, R}, |
||||
|
{kVK_ANSI_Y, Y}, |
||||
|
{kVK_ANSI_T, T}, |
||||
|
{kVK_ANSI_1, D1}, |
||||
|
{kVK_ANSI_2, D2}, |
||||
|
{kVK_ANSI_3, D3}, |
||||
|
{kVK_ANSI_4, D4}, |
||||
|
{kVK_ANSI_6, D6}, |
||||
|
{kVK_ANSI_5, D5}, |
||||
|
//{kVK_ANSI_Equal, ?}, |
||||
|
{kVK_ANSI_9, D9}, |
||||
|
{kVK_ANSI_7, D7}, |
||||
|
{kVK_ANSI_Minus, OemMinus}, |
||||
|
{kVK_ANSI_8, D8}, |
||||
|
{kVK_ANSI_0, D0}, |
||||
|
{kVK_ANSI_RightBracket, OemCloseBrackets}, |
||||
|
{kVK_ANSI_O, O}, |
||||
|
{kVK_ANSI_U, U}, |
||||
|
{kVK_ANSI_LeftBracket, OemOpenBrackets}, |
||||
|
{kVK_ANSI_I, I}, |
||||
|
{kVK_ANSI_P, P}, |
||||
|
{kVK_ANSI_L, L}, |
||||
|
{kVK_ANSI_J, J}, |
||||
|
{kVK_ANSI_Quote, OemQuotes}, |
||||
|
{kVK_ANSI_K, AvnKeyK}, |
||||
|
{kVK_ANSI_Semicolon, OemSemicolon}, |
||||
|
{kVK_ANSI_Backslash, OemBackslash}, |
||||
|
{kVK_ANSI_Comma, OemComma}, |
||||
|
//{kVK_ANSI_Slash, ?}, |
||||
|
{kVK_ANSI_N, N}, |
||||
|
{kVK_ANSI_M, M}, |
||||
|
{kVK_ANSI_Period, OemPeriod}, |
||||
|
//{kVK_ANSI_Grave, ?}, |
||||
|
{kVK_ANSI_KeypadDecimal, Decimal}, |
||||
|
{kVK_ANSI_KeypadMultiply, Multiply}, |
||||
|
{kVK_ANSI_KeypadPlus, OemPlus}, |
||||
|
{kVK_ANSI_KeypadClear, AvnKeyClear}, |
||||
|
{kVK_ANSI_KeypadDivide, Divide}, |
||||
|
{kVK_ANSI_KeypadEnter, AvnKeyEnter}, |
||||
|
{kVK_ANSI_KeypadMinus, OemMinus}, |
||||
|
//{kVK_ANSI_KeypadEquals, ?}, |
||||
|
{kVK_ANSI_Keypad0, NumPad0}, |
||||
|
{kVK_ANSI_Keypad1, NumPad1}, |
||||
|
{kVK_ANSI_Keypad2, NumPad2}, |
||||
|
{kVK_ANSI_Keypad3, NumPad3}, |
||||
|
{kVK_ANSI_Keypad4, NumPad4}, |
||||
|
{kVK_ANSI_Keypad5, NumPad5}, |
||||
|
{kVK_ANSI_Keypad6, NumPad6}, |
||||
|
{kVK_ANSI_Keypad7, NumPad7}, |
||||
|
{kVK_ANSI_Keypad8, NumPad8}, |
||||
|
{kVK_ANSI_Keypad9, NumPad9}, |
||||
|
{kVK_Return, AvnKeyReturn}, |
||||
|
{kVK_Tab, AvnKeyTab}, |
||||
|
{kVK_Space, Space}, |
||||
|
{kVK_Delete, AvnKeyBack}, |
||||
|
{kVK_Escape, Escape}, |
||||
|
{kVK_Command, LWin}, |
||||
|
{kVK_Shift, LeftShift}, |
||||
|
{kVK_CapsLock, AvnKeyCapsLock}, |
||||
|
{kVK_Option, LeftAlt}, |
||||
|
{kVK_Control, LeftCtrl}, |
||||
|
{kVK_RightCommand, RWin}, |
||||
|
{kVK_RightShift, RightShift}, |
||||
|
{kVK_RightOption, RightAlt}, |
||||
|
{kVK_RightControl, RightCtrl}, |
||||
|
//{kVK_Function, ?}, |
||||
|
{kVK_F17, F17}, |
||||
|
{kVK_VolumeUp, VolumeUp}, |
||||
|
{kVK_VolumeDown, VolumeDown}, |
||||
|
{kVK_Mute, VolumeMute}, |
||||
|
{kVK_F18, F18}, |
||||
|
{kVK_F19, F19}, |
||||
|
{kVK_F20, F20}, |
||||
|
{kVK_F5, F5}, |
||||
|
{kVK_F6, F6}, |
||||
|
{kVK_F7, F7}, |
||||
|
{kVK_F3, F3}, |
||||
|
{kVK_F8, F8}, |
||||
|
{kVK_F9, F9}, |
||||
|
{kVK_F11, F11}, |
||||
|
{kVK_F13, F13}, |
||||
|
{kVK_F16, F16}, |
||||
|
{kVK_F14, F14}, |
||||
|
{kVK_F10, F10}, |
||||
|
{kVK_F12, F12}, |
||||
|
{kVK_F15, F15}, |
||||
|
{kVK_Help, Help}, |
||||
|
{kVK_Home, Home}, |
||||
|
{kVK_PageUp, PageUp}, |
||||
|
{kVK_ForwardDelete, Delete}, |
||||
|
{kVK_F4, F4}, |
||||
|
{kVK_End, End}, |
||||
|
{kVK_F2, F2}, |
||||
|
{kVK_PageDown, PageDown}, |
||||
|
{kVK_F1, F1}, |
||||
|
{kVK_LeftArrow, Left}, |
||||
|
{kVK_RightArrow, Right}, |
||||
|
{kVK_DownArrow, Down}, |
||||
|
{kVK_UpArrow, Up} |
||||
|
}; |
||||
@ -0,0 +1,51 @@ |
|||||
|
// Copyright (c) The Avalonia Project. All rights reserved. |
||||
|
// Licensed under the MIT license. See licence.md file in the project root for full license information. |
||||
|
|
||||
|
#include "common.h" |
||||
|
|
||||
|
class Screens : public ComSingleObject<IAvnScreens, &IID_IAvnScreens> |
||||
|
{ |
||||
|
public: |
||||
|
FORWARD_IUNKNOWN() |
||||
|
virtual HRESULT GetScreenCount (int* ret) |
||||
|
{ |
||||
|
@autoreleasepool |
||||
|
{ |
||||
|
*ret = (int)[NSScreen screens].count; |
||||
|
|
||||
|
return S_OK; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
virtual HRESULT GetScreen (int index, AvnScreen* ret) |
||||
|
{ |
||||
|
@autoreleasepool |
||||
|
{ |
||||
|
if(index < 0 || index >= [NSScreen screens].count) |
||||
|
{ |
||||
|
return E_INVALIDARG; |
||||
|
} |
||||
|
|
||||
|
auto screen = [[NSScreen screens] objectAtIndex:index]; |
||||
|
|
||||
|
ret->Bounds.X = [screen frame].origin.x; |
||||
|
ret->Bounds.Y = [screen frame].origin.y; |
||||
|
ret->Bounds.Height = [screen frame].size.height; |
||||
|
ret->Bounds.Width = [screen frame].size.width; |
||||
|
|
||||
|
ret->WorkingArea.X = [screen visibleFrame].origin.x; |
||||
|
ret->WorkingArea.Y = [screen visibleFrame].origin.y; |
||||
|
ret->WorkingArea.Height = [screen visibleFrame].size.height; |
||||
|
ret->WorkingArea.Width = [screen visibleFrame].size.width; |
||||
|
|
||||
|
ret->Primary = index == 0; |
||||
|
|
||||
|
return S_OK; |
||||
|
} |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
extern IAvnScreens* CreateScreens() |
||||
|
{ |
||||
|
return new Screens(); |
||||
|
} |
||||
@ -0,0 +1,262 @@ |
|||||
|
// Copyright (c) The Avalonia Project. All rights reserved. |
||||
|
// Licensed under the MIT license. See licence.md file in the project root for full license information. |
||||
|
|
||||
|
#include "common.h" |
||||
|
#include "window.h" |
||||
|
|
||||
|
class SystemDialogs : public ComSingleObject<IAvnSystemDialogs, &IID_IAvnSystemDialogs> |
||||
|
{ |
||||
|
public: |
||||
|
FORWARD_IUNKNOWN() |
||||
|
virtual void SelectFolderDialog (IAvnWindow* parentWindowHandle, |
||||
|
IAvnSystemDialogEvents* events, |
||||
|
const char* title, |
||||
|
const char* initialDirectory) |
||||
|
{ |
||||
|
@autoreleasepool |
||||
|
{ |
||||
|
auto panel = [NSOpenPanel openPanel]; |
||||
|
|
||||
|
panel.canChooseDirectories = true; |
||||
|
panel.canCreateDirectories = true; |
||||
|
panel.canChooseFiles = false; |
||||
|
|
||||
|
if(title != nullptr) |
||||
|
{ |
||||
|
panel.title = [NSString stringWithUTF8String:title]; |
||||
|
} |
||||
|
|
||||
|
if(initialDirectory != nullptr) |
||||
|
{ |
||||
|
auto directoryString = [NSString stringWithUTF8String:initialDirectory]; |
||||
|
panel.directoryURL = [NSURL fileURLWithPath:directoryString]; |
||||
|
} |
||||
|
|
||||
|
auto handler = ^(NSModalResponse result) { |
||||
|
if(result == NSFileHandlingPanelOKButton) |
||||
|
{ |
||||
|
auto urls = [panel URLs]; |
||||
|
|
||||
|
if(urls.count > 0) |
||||
|
{ |
||||
|
void* strings[urls.count]; |
||||
|
|
||||
|
for(int i = 0; i < urls.count; i++) |
||||
|
{ |
||||
|
auto url = [urls objectAtIndex:i]; |
||||
|
|
||||
|
auto string = [url absoluteString]; |
||||
|
string = [string substringFromIndex:7]; |
||||
|
|
||||
|
strings[i] = (void*)[string UTF8String]; |
||||
|
} |
||||
|
|
||||
|
events->OnCompleted((int)urls.count, &strings[0]); |
||||
|
|
||||
|
[panel orderOut:panel]; |
||||
|
|
||||
|
if(parentWindowHandle != nullptr) |
||||
|
{ |
||||
|
auto windowHolder = dynamic_cast<INSWindowHolder*>(parentWindowHandle); |
||||
|
[windowHolder->GetNSWindow() makeKeyAndOrderFront:windowHolder->GetNSWindow()]; |
||||
|
} |
||||
|
|
||||
|
return; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
events->OnCompleted(0, nullptr); |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
if(parentWindowHandle != nullptr) |
||||
|
{ |
||||
|
auto windowBase = dynamic_cast<INSWindowHolder*>(parentWindowHandle); |
||||
|
|
||||
|
[panel beginSheetModalForWindow:windowBase->GetNSWindow() completionHandler:handler]; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
[panel beginWithCompletionHandler: handler]; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
virtual void OpenFileDialog (IAvnWindow* parentWindowHandle, |
||||
|
IAvnSystemDialogEvents* events, |
||||
|
bool allowMultiple, |
||||
|
const char* title, |
||||
|
const char* initialDirectory, |
||||
|
const char* initialFile, |
||||
|
const char* filters) |
||||
|
{ |
||||
|
@autoreleasepool |
||||
|
{ |
||||
|
auto panel = [NSOpenPanel openPanel]; |
||||
|
|
||||
|
panel.allowsMultipleSelection = allowMultiple; |
||||
|
|
||||
|
if(title != nullptr) |
||||
|
{ |
||||
|
panel.title = [NSString stringWithUTF8String:title]; |
||||
|
} |
||||
|
|
||||
|
if(initialDirectory != nullptr) |
||||
|
{ |
||||
|
auto directoryString = [NSString stringWithUTF8String:initialDirectory]; |
||||
|
panel.directoryURL = [NSURL fileURLWithPath:directoryString]; |
||||
|
} |
||||
|
|
||||
|
if(initialFile != nullptr) |
||||
|
{ |
||||
|
panel.nameFieldStringValue = [NSString stringWithUTF8String:initialFile]; |
||||
|
} |
||||
|
|
||||
|
if(filters != nullptr) |
||||
|
{ |
||||
|
auto filtersString = [NSString stringWithUTF8String:filters]; |
||||
|
|
||||
|
if(filtersString.length > 0) |
||||
|
{ |
||||
|
auto allowedTypes = [filtersString componentsSeparatedByString:@";"]; |
||||
|
|
||||
|
panel.allowedFileTypes = allowedTypes; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
auto handler = ^(NSModalResponse result) { |
||||
|
if(result == NSFileHandlingPanelOKButton) |
||||
|
{ |
||||
|
auto urls = [panel URLs]; |
||||
|
|
||||
|
if(urls.count > 0) |
||||
|
{ |
||||
|
void* strings[urls.count]; |
||||
|
|
||||
|
for(int i = 0; i < urls.count; i++) |
||||
|
{ |
||||
|
auto url = [urls objectAtIndex:i]; |
||||
|
|
||||
|
auto string = [url absoluteString]; |
||||
|
string = [string substringFromIndex:7]; |
||||
|
|
||||
|
strings[i] = (void*)[string UTF8String]; |
||||
|
} |
||||
|
|
||||
|
events->OnCompleted((int)urls.count, &strings[0]); |
||||
|
|
||||
|
[panel orderOut:panel]; |
||||
|
|
||||
|
if(parentWindowHandle != nullptr) |
||||
|
{ |
||||
|
auto windowHolder = dynamic_cast<INSWindowHolder*>(parentWindowHandle); |
||||
|
[windowHolder->GetNSWindow() makeKeyAndOrderFront:windowHolder->GetNSWindow()]; |
||||
|
} |
||||
|
|
||||
|
return; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
events->OnCompleted(0, nullptr); |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
if(parentWindowHandle != nullptr) |
||||
|
{ |
||||
|
auto windowHolder = dynamic_cast<INSWindowHolder*>(parentWindowHandle); |
||||
|
|
||||
|
[panel beginSheetModalForWindow:windowHolder->GetNSWindow() completionHandler:handler]; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
[panel beginWithCompletionHandler: handler]; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
virtual void SaveFileDialog (IAvnWindow* parentWindowHandle, |
||||
|
IAvnSystemDialogEvents* events, |
||||
|
const char* title, |
||||
|
const char* initialDirectory, |
||||
|
const char* initialFile, |
||||
|
const char* filters) |
||||
|
{ |
||||
|
@autoreleasepool |
||||
|
{ |
||||
|
auto panel = [NSSavePanel savePanel]; |
||||
|
|
||||
|
if(title != nullptr) |
||||
|
{ |
||||
|
panel.title = [NSString stringWithUTF8String:title]; |
||||
|
} |
||||
|
|
||||
|
if(initialDirectory != nullptr) |
||||
|
{ |
||||
|
auto directoryString = [NSString stringWithUTF8String:initialDirectory]; |
||||
|
panel.directoryURL = [NSURL fileURLWithPath:directoryString]; |
||||
|
} |
||||
|
|
||||
|
if(initialFile != nullptr) |
||||
|
{ |
||||
|
panel.nameFieldStringValue = [NSString stringWithUTF8String:initialFile]; |
||||
|
} |
||||
|
|
||||
|
if(filters != nullptr) |
||||
|
{ |
||||
|
auto filtersString = [NSString stringWithUTF8String:filters]; |
||||
|
|
||||
|
if(filtersString.length > 0) |
||||
|
{ |
||||
|
auto allowedTypes = [filtersString componentsSeparatedByString:@";"]; |
||||
|
|
||||
|
panel.allowedFileTypes = allowedTypes; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
auto handler = ^(NSModalResponse result) { |
||||
|
if(result == NSFileHandlingPanelOKButton) |
||||
|
{ |
||||
|
void* strings[1]; |
||||
|
|
||||
|
auto url = [panel URL]; |
||||
|
|
||||
|
auto string = [url absoluteString]; |
||||
|
string = [string substringFromIndex:7]; |
||||
|
strings[0] = (void*)[string UTF8String]; |
||||
|
|
||||
|
events->OnCompleted(1, &strings[0]); |
||||
|
|
||||
|
[panel orderOut:panel]; |
||||
|
|
||||
|
if(parentWindowHandle != nullptr) |
||||
|
{ |
||||
|
auto windowHolder = dynamic_cast<INSWindowHolder*>(parentWindowHandle); |
||||
|
[windowHolder->GetNSWindow() makeKeyAndOrderFront:windowHolder->GetNSWindow()]; |
||||
|
} |
||||
|
|
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
events->OnCompleted(0, nullptr); |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
if(parentWindowHandle != nullptr) |
||||
|
{ |
||||
|
auto windowBase = dynamic_cast<INSWindowHolder*>(parentWindowHandle); |
||||
|
|
||||
|
[panel beginSheetModalForWindow:windowBase->GetNSWindow() completionHandler:handler]; |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
[panel beginWithCompletionHandler: handler]; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
extern IAvnSystemDialogs* CreateSystemDialogs() |
||||
|
{ |
||||
|
return new SystemDialogs(); |
||||
|
} |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue