501 changed files with 15084 additions and 5992 deletions
@ -1,6 +0,0 @@ |
|||||
<ProjectConfiguration> |
|
||||
<Settings> |
|
||||
<IgnoreThisComponentCompletely>False</IgnoreThisComponentCompletely> |
|
||||
<PreviouslyBuiltSuccessfully>True</PreviouslyBuiltSuccessfully> |
|
||||
</Settings> |
|
||||
</ProjectConfiguration> |
|
||||
@ -1,5 +0,0 @@ |
|||||
<ProjectConfiguration> |
|
||||
<Settings> |
|
||||
<PreviouslyBuiltSuccessfully>True</PreviouslyBuiltSuccessfully> |
|
||||
</Settings> |
|
||||
</ProjectConfiguration> |
|
||||
@ -1,5 +0,0 @@ |
|||||
<ProjectConfiguration> |
|
||||
<Settings> |
|
||||
<PreviouslyBuiltSuccessfully>True</PreviouslyBuiltSuccessfully> |
|
||||
</Settings> |
|
||||
</ProjectConfiguration> |
|
||||
@ -1,3 +0,0 @@ |
|||||
<ProjectConfiguration> |
|
||||
<Settings /> |
|
||||
</ProjectConfiguration> |
|
||||
@ -1,3 +0,0 @@ |
|||||
<ProjectConfiguration> |
|
||||
<Settings /> |
|
||||
</ProjectConfiguration> |
|
||||
@ -1,6 +0,0 @@ |
|||||
<ProjectConfiguration> |
|
||||
<Settings> |
|
||||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|
||||
<PreviouslyBuiltSuccessfully>True</PreviouslyBuiltSuccessfully> |
|
||||
</Settings> |
|
||||
</ProjectConfiguration> |
|
||||
@ -1,5 +0,0 @@ |
|||||
<ProjectConfiguration> |
|
||||
<Settings> |
|
||||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|
||||
</Settings> |
|
||||
</ProjectConfiguration> |
|
||||
@ -1,8 +0,0 @@ |
|||||
<ProjectConfiguration> |
|
||||
<Settings> |
|
||||
<HiddenComponentWarnings> |
|
||||
<Value>MissingOrIgnoredProjectReference</Value> |
|
||||
</HiddenComponentWarnings> |
|
||||
<PreviouslyBuiltSuccessfully>True</PreviouslyBuiltSuccessfully> |
|
||||
</Settings> |
|
||||
</ProjectConfiguration> |
|
||||
@ -1,6 +0,0 @@ |
|||||
<ProjectConfiguration> |
|
||||
<Settings> |
|
||||
<IgnoreThisComponentCompletely>True</IgnoreThisComponentCompletely> |
|
||||
<PreviouslyBuiltSuccessfully>True</PreviouslyBuiltSuccessfully> |
|
||||
</Settings> |
|
||||
</ProjectConfiguration> |
|
||||
@ -0,0 +1,5 @@ |
|||||
|
<Project> |
||||
|
<PropertyGroup> |
||||
|
<PackageOutputPath Condition="'$(PackageOutputPath)' == ''">$(MSBuildThisFileDirectory)artifacts/nuget</PackageOutputPath> |
||||
|
</PropertyGroup> |
||||
|
</Project> |
||||
@ -0,0 +1,128 @@ |
|||||
|
jobs: |
||||
|
- job: Linux |
||||
|
pool: |
||||
|
vmImage: 'ubuntu-16.04' |
||||
|
steps: |
||||
|
- task: CmdLine@2 |
||||
|
displayName: 'Install CastXML' |
||||
|
inputs: |
||||
|
script: | |
||||
|
sudo apt-get update |
||||
|
sudo apt-get install castxml |
||||
|
|
||||
|
- task: CmdLine@2 |
||||
|
displayName: 'Install Cake' |
||||
|
inputs: |
||||
|
script: | |
||||
|
dotnet tool install -g Cake.Tool --version 0.30.0 |
||||
|
|
||||
|
- task: CmdLine@2 |
||||
|
displayName: 'Run Cake' |
||||
|
inputs: |
||||
|
script: | |
||||
|
export PATH="$PATH:$HOME/.dotnet/tools" |
||||
|
dotnet --info |
||||
|
printenv |
||||
|
dotnet cake build.cake -target="Azure-Linux" -configuration="Release" |
||||
|
|
||||
|
- task: PublishTestResults@2 |
||||
|
inputs: |
||||
|
testResultsFormat: 'VSTest' |
||||
|
testResultsFiles: '$(Build.SourcesDirectory)/artifacts/test-results/*.trx' |
||||
|
condition: not(canceled()) |
||||
|
|
||||
|
- 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 |
||||
|
displayName: 'Install CastXML' |
||||
|
inputs: |
||||
|
script: brew install castxml |
||||
|
|
||||
|
- task: CmdLine@2 |
||||
|
displayName: 'Install Cake' |
||||
|
inputs: |
||||
|
script: | |
||||
|
dotnet tool install -g Cake.Tool --version 0.30.0 |
||||
|
|
||||
|
- task: CmdLine@2 |
||||
|
displayName: 'Run Cake' |
||||
|
inputs: |
||||
|
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: PublishTestResults@2 |
||||
|
inputs: |
||||
|
testResultsFormat: 'VSTest' |
||||
|
testResultsFiles: '$(Build.SourcesDirectory)/artifacts/test-results/*.trx' |
||||
|
condition: not(canceled()) |
||||
|
|
||||
|
- task: PublishBuildArtifacts@1 |
||||
|
inputs: |
||||
|
pathToPublish: '$(Build.SourcesDirectory)/Build/Products/Release/' |
||||
|
artifactName: 'Avalonia.Native.OSX' |
||||
|
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false)) |
||||
|
|
||||
|
- task: PublishBuildArtifacts@1 |
||||
|
inputs: |
||||
|
pathtoPublish: '$(Build.SourcesDirectory)/artifacts/nuget' |
||||
|
artifactName: 'NuGetOSX' |
||||
|
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false)) |
||||
|
|
||||
|
- job: Windows |
||||
|
pool: |
||||
|
vmImage: 'vs2017-win2016' |
||||
|
steps: |
||||
|
- task: CmdLine@2 |
||||
|
displayName: 'Install Cake' |
||||
|
inputs: |
||||
|
script: | |
||||
|
dotnet tool install -g Cake.Tool --version 0.30.0 |
||||
|
|
||||
|
- task: CmdLine@2 |
||||
|
displayName: 'Run Cake' |
||||
|
inputs: |
||||
|
script: | |
||||
|
set PATH=%PATH%;%USERPROFILE%\.dotnet\tools |
||||
|
dotnet cake build.cake -target="Azure-Windows" -configuration="Release" |
||||
|
|
||||
|
- task: PublishTestResults@2 |
||||
|
inputs: |
||||
|
testResultsFormat: 'VSTest' |
||||
|
testResultsFiles: '$(Build.SourcesDirectory)/artifacts/test-results/*.trx' |
||||
|
condition: not(canceled()) |
||||
|
|
||||
|
- task: PublishBuildArtifacts@1 |
||||
|
inputs: |
||||
|
pathtoPublish: '$(Build.SourcesDirectory)/artifacts/nuget' |
||||
|
artifactName: 'NuGet' |
||||
|
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false)) |
||||
|
|
||||
|
- task: PublishBuildArtifacts@1 |
||||
|
inputs: |
||||
|
pathToPublish: '$(Build.SourcesDirectory)/artifacts/zip' |
||||
|
artifactName: 'Samples' |
||||
|
condition: and(succeeded(), eq(variables['system.pullrequest.isfork'], false)) |
||||
@ -0,0 +1,6 @@ |
|||||
|
# /bin/sh |
||||
|
|
||||
|
mkdir native-build |
||||
|
cd native-build |
||||
|
cmake -DCMAKE_BUILD_TYPE=$1 ../native |
||||
|
cmake --build . --target install |
||||
@ -0,0 +1,20 @@ |
|||||
|
<Project> |
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.Base/Avalonia.Base.csproj" /> |
||||
|
<ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.Animation/Avalonia.Animation.csproj" /> |
||||
|
<ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.Controls/Avalonia.Controls.csproj" /> |
||||
|
<ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.DesignerSupport/Avalonia.DesignerSupport.csproj" /> |
||||
|
<ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.Diagnostics/Avalonia.Diagnostics.csproj" /> |
||||
|
<ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.Input/Avalonia.Input.csproj" /> |
||||
|
<ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.Interactivity/Avalonia.Interactivity.csproj" /> |
||||
|
<ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.Layout/Avalonia.Layout.csproj" /> |
||||
|
<ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.Logging.Serilog/Avalonia.Logging.Serilog.csproj" /> |
||||
|
<ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.Visuals/Avalonia.Visuals.csproj" /> |
||||
|
<ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.Styling/Avalonia.Styling.csproj" /> |
||||
|
<ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.Themes.Default/Avalonia.Themes.Default.csproj" /> |
||||
|
<ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.OpenGL/Avalonia.OpenGL.csproj" /> |
||||
|
<ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Markup/Avalonia.Markup/Avalonia.Markup.csproj" /> |
||||
|
<ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Markup/Avalonia.Markup.Xaml/Avalonia.Markup.Xaml.csproj" /> |
||||
|
<ProjectReference Include="$(MSBuildThisFileDirectory)/../src/Avalonia.DesktopRuntime/Avalonia.DesktopRuntime.csproj" Condition="'$(TargetFramework)' != 'netstandard2.0'" /> |
||||
|
</ItemGroup> |
||||
|
</Project> |
||||
@ -0,0 +1,3 @@ |
|||||
|
<Project> |
||||
|
<Target Name="Pack" /> |
||||
|
</Project> |
||||
@ -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,6 @@ |
|||||
|
<Project> |
||||
|
<Import Condition="'$(TargetFramework)' == 'netcoreapp2.0'" Project="CoreLibraries.props" /> |
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="$(MSBuildThisFileDirectory)../packages/Avalonia/Avalonia.csproj" /> |
||||
|
</ItemGroup> |
||||
|
</Project> |
||||
@ -1,9 +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="System.Reactive" Version="4.0.0" /> |
<PackageReference Include="System.Reactive" Version="4.0.0" /> |
||||
<PackageReference Include="System.Reactive.Core" Version="4.0.0" /> |
|
||||
<PackageReference Include="System.Reactive.Interfaces" Version="4.0.0" /> |
|
||||
<PackageReference Include="System.Reactive.Linq" Version="4.0.0" /> |
|
||||
<PackageReference Include="System.Reactive.PlatformServices" Version="4.0.0" /> |
|
||||
</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="System.Drawing.Common" Version="4.5.0-preview1-25914-04" /> |
<PackageReference Include="System.Drawing.Common" Version="4.5.0" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -1,6 +1,7 @@ |
|||||
{ |
{ |
||||
"msbuild-sdks": { |
"msbuild-sdks": { |
||||
"Microsoft.Build.Traversal": "1.0.41", |
"Microsoft.Build.Traversal": "1.0.43", |
||||
"MSBuild.Sdk.Extras": "1.6.46" |
"MSBuild.Sdk.Extras": "1.6.46", |
||||
|
"AggregatePackage.NuGet.Sdk" : "0.1.12" |
||||
} |
} |
||||
} |
} |
||||
|
|||||
@ -0,0 +1,5 @@ |
|||||
|
// 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.
|
||||
|
|
||||
|
#define COM_GUIDS_MATERIALIZE |
||||
|
#include "avalonia-native.h" |
||||
@ -0,0 +1,363 @@ |
|||||
|
// 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 "com.h" |
||||
|
#include "key.h" |
||||
|
|
||||
|
#define AVNCOM(name, id) COMINTERFACE(name, 2e2cda0a, 9ae5, 4f1b, 8e, 20, 08, 1a, 04, 27, 9f, id) |
||||
|
|
||||
|
struct IAvnWindowEvents; |
||||
|
struct IAvnWindow; |
||||
|
struct IAvnPopup; |
||||
|
struct IAvnMacOptions; |
||||
|
struct IAvnPlatformThreadingInterface; |
||||
|
struct IAvnSystemDialogEvents; |
||||
|
struct IAvnSystemDialogs; |
||||
|
struct IAvnScreens; |
||||
|
struct IAvnClipboard; |
||||
|
struct IAvnCursor; |
||||
|
struct IAvnCursorFactory; |
||||
|
struct IAvnGlFeature; |
||||
|
struct IAvnGlContext; |
||||
|
struct IAvnGlDisplay; |
||||
|
struct IAvnGlSurfaceRenderTarget; |
||||
|
struct IAvnGlSurfaceRenderingSession; |
||||
|
|
||||
|
struct AvnSize |
||||
|
{ |
||||
|
double Width, Height; |
||||
|
}; |
||||
|
|
||||
|
struct AvnPixelSize |
||||
|
{ |
||||
|
int Width, Height; |
||||
|
}; |
||||
|
|
||||
|
struct AvnRect |
||||
|
{ |
||||
|
double X, Y, Width, Height; |
||||
|
}; |
||||
|
|
||||
|
struct AvnVector |
||||
|
{ |
||||
|
double X, Y; |
||||
|
}; |
||||
|
|
||||
|
struct AvnPoint |
||||
|
{ |
||||
|
double X, Y; |
||||
|
}; |
||||
|
|
||||
|
struct AvnScreen |
||||
|
{ |
||||
|
AvnRect Bounds; |
||||
|
AvnRect WorkingArea; |
||||
|
bool Primary; |
||||
|
}; |
||||
|
|
||||
|
enum AvnPixelFormat |
||||
|
{ |
||||
|
kAvnRgb565, |
||||
|
kAvnRgba8888, |
||||
|
kAvnBgra8888 |
||||
|
}; |
||||
|
|
||||
|
struct AvnFramebuffer |
||||
|
{ |
||||
|
void* Data; |
||||
|
int Width; |
||||
|
int Height; |
||||
|
int Stride; |
||||
|
AvnVector Dpi; |
||||
|
AvnPixelFormat PixelFormat; |
||||
|
}; |
||||
|
|
||||
|
struct AvnColor |
||||
|
{ |
||||
|
unsigned char Alpha; |
||||
|
unsigned char Red; |
||||
|
unsigned char Green; |
||||
|
unsigned char Blue; |
||||
|
}; |
||||
|
|
||||
|
enum AvnRawMouseEventType |
||||
|
{ |
||||
|
LeaveWindow, |
||||
|
LeftButtonDown, |
||||
|
LeftButtonUp, |
||||
|
RightButtonDown, |
||||
|
RightButtonUp, |
||||
|
MiddleButtonDown, |
||||
|
MiddleButtonUp, |
||||
|
Move, |
||||
|
Wheel, |
||||
|
NonClientLeftButtonDown |
||||
|
}; |
||||
|
|
||||
|
enum AvnRawKeyEventType |
||||
|
{ |
||||
|
KeyDown, |
||||
|
KeyUp |
||||
|
}; |
||||
|
|
||||
|
enum AvnInputModifiers |
||||
|
{ |
||||
|
AvnInputModifiersNone = 0, |
||||
|
Alt = 1, |
||||
|
Control = 2, |
||||
|
Shift = 4, |
||||
|
Windows = 8, |
||||
|
LeftMouseButton = 16, |
||||
|
RightMouseButton = 32, |
||||
|
MiddleMouseButton = 64 |
||||
|
}; |
||||
|
|
||||
|
enum AvnWindowState |
||||
|
{ |
||||
|
Normal, |
||||
|
Minimized, |
||||
|
Maximized, |
||||
|
}; |
||||
|
|
||||
|
enum AvnStandardCursorType |
||||
|
{ |
||||
|
CursorArrow, |
||||
|
CursorIbeam, |
||||
|
CursorWait, |
||||
|
CursorCross, |
||||
|
CursorUpArrow, |
||||
|
CursorSizeWestEast, |
||||
|
CursorSizeNorthSouth, |
||||
|
CursorSizeAll, |
||||
|
CursorNo, |
||||
|
CursorHand, |
||||
|
CursorAppStarting, |
||||
|
CursorHelp, |
||||
|
CursorTopSide, |
||||
|
CursorBottomSize, |
||||
|
CursorLeftSide, |
||||
|
CursorRightSide, |
||||
|
CursorTopLeftCorner, |
||||
|
CursorTopRightCorner, |
||||
|
CursorBottomLeftCorner, |
||||
|
CursorBottomRightCorner, |
||||
|
CursorDragMove, |
||||
|
CursorDragCopy, |
||||
|
CursorDragLink, |
||||
|
}; |
||||
|
|
||||
|
enum AvnWindowEdge |
||||
|
{ |
||||
|
WindowEdgeNorthWest, |
||||
|
WindowEdgeNorth, |
||||
|
WindowEdgeNorthEast, |
||||
|
WindowEdgeWest, |
||||
|
WindowEdgeEast, |
||||
|
WindowEdgeSouthWest, |
||||
|
WindowEdgeSouth, |
||||
|
WindowEdgeSouthEast |
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvaloniaNativeFactory, 01) : IUnknown |
||||
|
{ |
||||
|
public: |
||||
|
virtual HRESULT Initialize() = 0; |
||||
|
virtual IAvnMacOptions* GetMacOptions() = 0; |
||||
|
virtual HRESULT CreateWindow(IAvnWindowEvents* cb, IAvnWindow** ppv) = 0; |
||||
|
virtual HRESULT CreatePopup (IAvnWindowEvents* cb, IAvnPopup** ppv) = 0; |
||||
|
virtual HRESULT CreatePlatformThreadingInterface(IAvnPlatformThreadingInterface** ppv) = 0; |
||||
|
virtual HRESULT CreateSystemDialogs (IAvnSystemDialogs** ppv) = 0; |
||||
|
virtual HRESULT CreateScreens (IAvnScreens** ppv) = 0; |
||||
|
virtual HRESULT CreateClipboard(IAvnClipboard** ppv) = 0; |
||||
|
virtual HRESULT CreateCursorFactory(IAvnCursorFactory** ppv) = 0; |
||||
|
virtual HRESULT ObtainGlFeature(IAvnGlFeature** ppv) = 0; |
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvnWindowBase, 02) : IUnknown |
||||
|
{ |
||||
|
virtual HRESULT Show() = 0; |
||||
|
virtual HRESULT Hide () = 0; |
||||
|
virtual HRESULT Close() = 0; |
||||
|
virtual HRESULT Activate () = 0; |
||||
|
virtual HRESULT GetClientSize(AvnSize*ret) = 0; |
||||
|
virtual HRESULT GetMaxClientSize(AvnSize* ret) = 0; |
||||
|
virtual HRESULT GetScaling(double*ret)=0; |
||||
|
virtual HRESULT SetMinMaxSize(AvnSize minSize, AvnSize maxSize) = 0; |
||||
|
virtual HRESULT Resize(double width, double height) = 0; |
||||
|
virtual HRESULT Invalidate (AvnRect rect) = 0; |
||||
|
virtual HRESULT BeginMoveDrag () = 0; |
||||
|
virtual HRESULT BeginResizeDrag (AvnWindowEdge edge) = 0; |
||||
|
virtual HRESULT GetPosition (AvnPoint*ret) = 0; |
||||
|
virtual HRESULT SetPosition (AvnPoint point) = 0; |
||||
|
virtual HRESULT PointToClient (AvnPoint point, AvnPoint*ret) = 0; |
||||
|
virtual HRESULT PointToScreen (AvnPoint point, AvnPoint*ret) = 0; |
||||
|
virtual HRESULT ThreadSafeSetSwRenderedFrame(AvnFramebuffer* fb, IUnknown* dispose) = 0; |
||||
|
virtual HRESULT SetTopMost (bool value) = 0; |
||||
|
virtual HRESULT SetCursor(IAvnCursor* cursor) = 0; |
||||
|
virtual HRESULT CreateGlRenderTarget(IAvnGlSurfaceRenderTarget** ret) = 0; |
||||
|
virtual HRESULT GetSoftwareFramebuffer(AvnFramebuffer*ret) = 0; |
||||
|
virtual bool TryLock() = 0; |
||||
|
virtual void Unlock() = 0; |
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvnPopup, 03) : virtual IAvnWindowBase |
||||
|
{ |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvnWindow, 04) : virtual IAvnWindowBase |
||||
|
{ |
||||
|
virtual HRESULT ShowDialog (IUnknown**ppv) = 0; |
||||
|
virtual HRESULT SetCanResize(bool value) = 0; |
||||
|
virtual HRESULT SetHasDecorations(bool value) = 0; |
||||
|
virtual HRESULT SetTitle (const char* title) = 0; |
||||
|
virtual HRESULT SetTitleBarColor (AvnColor color) = 0; |
||||
|
virtual HRESULT SetWindowState(AvnWindowState state) = 0; |
||||
|
virtual HRESULT GetWindowState(AvnWindowState*ret) = 0; |
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvnWindowBaseEvents, 05) : IUnknown |
||||
|
{ |
||||
|
virtual HRESULT Paint() = 0; |
||||
|
virtual void Closed() = 0; |
||||
|
virtual void Activated() = 0; |
||||
|
virtual void Deactivated() = 0; |
||||
|
virtual void Resized(const AvnSize& size) = 0; |
||||
|
virtual void PositionChanged (AvnPoint position) = 0; |
||||
|
virtual void RawMouseEvent (AvnRawMouseEventType type, |
||||
|
unsigned int timeStamp, |
||||
|
AvnInputModifiers modifiers, |
||||
|
AvnPoint point, |
||||
|
AvnVector delta) = 0; |
||||
|
virtual bool RawKeyEvent (AvnRawKeyEventType type, unsigned int timeStamp, AvnInputModifiers modifiers, unsigned int key) = 0; |
||||
|
virtual bool RawTextInputEvent (unsigned int timeStamp, const char* text) = 0; |
||||
|
virtual void ScalingChanged(double scaling) = 0; |
||||
|
virtual void RunRenderPriorityJobs() = 0; |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
AVNCOM(IAvnWindowEvents, 06) : IAvnWindowBaseEvents |
||||
|
{ |
||||
|
/**
|
||||
|
* Closing Event |
||||
|
* Called when the user presses the OS window close button. |
||||
|
* return true to allow the close, return false to prevent close. |
||||
|
*/ |
||||
|
virtual bool Closing () = 0; |
||||
|
|
||||
|
virtual void WindowStateChanged (AvnWindowState state) = 0; |
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvnMacOptions, 07) : IUnknown |
||||
|
{ |
||||
|
virtual HRESULT SetShowInDock(int show) = 0; |
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvnActionCallback, 08) : IUnknown |
||||
|
{ |
||||
|
virtual void Run() = 0; |
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvnSignaledCallback, 09) : IUnknown |
||||
|
{ |
||||
|
virtual void Signaled(int priority, bool priorityContainsMeaningfulValue) = 0; |
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvnLoopCancellation, 0a) : IUnknown |
||||
|
{ |
||||
|
virtual void Cancel() = 0; |
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvnPlatformThreadingInterface, 0b) : IUnknown |
||||
|
{ |
||||
|
virtual bool GetCurrentThreadIsLoopThread() = 0; |
||||
|
virtual void SetSignaledCallback(IAvnSignaledCallback* cb) = 0; |
||||
|
virtual IAvnLoopCancellation* CreateLoopCancellation() = 0; |
||||
|
virtual void RunLoop(IAvnLoopCancellation* cancel) = 0; |
||||
|
// Can't pass int* to sharpgentools for some reason
|
||||
|
virtual void Signal(int priority) = 0; |
||||
|
virtual IUnknown* StartTimer(int priority, int ms, IAvnActionCallback* callback) = 0; |
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvnSystemDialogEvents, 0c) : IUnknown |
||||
|
{ |
||||
|
virtual void OnCompleted (int numResults, void* ptrFirstResult) = 0; |
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvnSystemDialogs, 0d) : IUnknown |
||||
|
{ |
||||
|
virtual void SelectFolderDialog (IAvnWindow* parentWindowHandle, |
||||
|
IAvnSystemDialogEvents* events, |
||||
|
const char* title, |
||||
|
const char* initialPath) = 0; |
||||
|
|
||||
|
virtual void OpenFileDialog (IAvnWindow* parentWindowHandle, |
||||
|
IAvnSystemDialogEvents* events, |
||||
|
bool allowMultiple, |
||||
|
const char* title, |
||||
|
const char* initialDirectory, |
||||
|
const char* initialFile, |
||||
|
const char* filters) = 0; |
||||
|
|
||||
|
virtual void SaveFileDialog (IAvnWindow* parentWindowHandle, |
||||
|
IAvnSystemDialogEvents* events, |
||||
|
const char* title, |
||||
|
const char* initialDirectory, |
||||
|
const char* initialFile, |
||||
|
const char* filters) = 0; |
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvnScreens, 0e) : IUnknown |
||||
|
{ |
||||
|
virtual HRESULT GetScreenCount (int* ret) = 0; |
||||
|
virtual HRESULT GetScreen (int index, AvnScreen* ret) = 0; |
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvnClipboard, 0f) : IUnknown |
||||
|
{ |
||||
|
virtual HRESULT GetText (void** retOut) = 0; |
||||
|
virtual HRESULT SetText (char* text) = 0; |
||||
|
virtual HRESULT Clear() = 0; |
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvnCursor, 10) : IUnknown |
||||
|
{ |
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvnCursorFactory, 11) : IUnknown |
||||
|
{ |
||||
|
virtual HRESULT GetCursor (AvnStandardCursorType cursorType, IAvnCursor** retOut) = 0; |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
AVNCOM(IAvnGlFeature, 12) : IUnknown |
||||
|
{ |
||||
|
virtual HRESULT ObtainDisplay(IAvnGlDisplay**retOut) = 0; |
||||
|
virtual HRESULT ObtainImmediateContext(IAvnGlContext**retOut) = 0; |
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvnGlDisplay, 13) : IUnknown |
||||
|
{ |
||||
|
virtual HRESULT GetSampleCount(int* ret) = 0; |
||||
|
virtual HRESULT GetStencilSize(int* ret) = 0; |
||||
|
virtual HRESULT ClearContext() = 0; |
||||
|
virtual void* GetProcAddress(char* proc) = 0; |
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvnGlContext, 14) : IUnknown |
||||
|
{ |
||||
|
virtual HRESULT MakeCurrent() = 0; |
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvnGlSurfaceRenderTarget, 15) : IUnknown |
||||
|
{ |
||||
|
virtual HRESULT BeginDrawing(IAvnGlSurfaceRenderingSession** ret) = 0; |
||||
|
}; |
||||
|
|
||||
|
AVNCOM(IAvnGlSurfaceRenderingSession, 16) : IUnknown |
||||
|
{ |
||||
|
virtual HRESULT GetPixelSize(AvnPixelSize* ret) = 0; |
||||
|
virtual HRESULT GetScaling(double* ret) = 0; |
||||
|
}; |
||||
|
|
||||
|
extern "C" IAvaloniaNativeFactory* CreateAvaloniaNative(); |
||||
@ -0,0 +1,57 @@ |
|||||
|
// 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.
|
||||
|
|
||||
|
#pragma clang diagnostic push |
||||
|
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection" |
||||
|
#ifndef COM_H_INCLUDED |
||||
|
#define COM_H_INCLUDED |
||||
|
|
||||
|
|
||||
|
typedef struct _GUID { |
||||
|
unsigned int Data1; |
||||
|
unsigned short Data2; |
||||
|
unsigned short Data3; |
||||
|
unsigned char Data4[ 8 ]; |
||||
|
} GUID; |
||||
|
typedef GUID IID; |
||||
|
typedef const IID* REFIID; |
||||
|
typedef unsigned int HRESULT; |
||||
|
typedef unsigned int DWORD; |
||||
|
typedef DWORD ULONG; |
||||
|
|
||||
|
#define STDMETHODCALLTYPE |
||||
|
|
||||
|
#define S_OK 0x0L |
||||
|
|
||||
|
#define E_NOTIMPL 0x80004001L |
||||
|
#define E_NOINTERFACE 0x80004002L |
||||
|
#define E_POINTER 0x80004003L |
||||
|
#define E_ABORT 0x80004004L |
||||
|
#define E_FAIL 0x80004005L |
||||
|
#define E_UNEXPECTED 0x8000FFFFL |
||||
|
#define E_HANDLE 0x80070006L |
||||
|
#define E_INVALIDARG 0x80070057L |
||||
|
|
||||
|
struct IUnknown |
||||
|
{ |
||||
|
virtual HRESULT STDMETHODCALLTYPE QueryInterface( |
||||
|
REFIID riid, |
||||
|
void **ppvObject) = 0; |
||||
|
|
||||
|
virtual ULONG STDMETHODCALLTYPE AddRef( void) = 0; |
||||
|
|
||||
|
virtual ULONG STDMETHODCALLTYPE Release( void) = 0; |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
#ifdef COM_GUIDS_MATERIALIZE |
||||
|
#define __IID_DEF(name,d1,d2,d3, d41, d42, d43, d44, d45, d46, d47, d48) extern "C" const GUID IID_ ## name = {0x ## d1, 0x ## d2, 0x ## d3, \ |
||||
|
{0x ## d41, 0x ## d42, 0x ## d42, 0x ## d42, 0x ## d42, 0x ## d42, 0x ## d42, 0x ## d42 } }; |
||||
|
#else |
||||
|
#define __IID_DEF(name,d1,d2,d3, d41, d42, d43, d44, d45, d46, d47, d48) extern "C" const GUID IID_ ## name; |
||||
|
#endif |
||||
|
#define COMINTERFACE(name,d1,d2,d3, d41, d42, d43, d44, d45, d46, d47, d48) __IID_DEF(name,d1,d2,d3, d41, d42, d43, d44, d45, d46, d47, d48) \ |
||||
|
struct __attribute__((annotate("uuid(" #d1 "-" #d2 "-" #d3 "-" #d41 #d42 "-" #d43 #d44 #d45 #d46 #d47 #d48 ")" ))) name |
||||
|
|
||||
|
#endif // COM_H_INCLUDED
|
||||
|
#pragma clang diagnostic pop |
||||
@ -0,0 +1,184 @@ |
|||||
|
// 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 "com.h" |
||||
|
#pragma clang diagnostic push |
||||
|
#pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection" |
||||
|
#ifndef COMIMPL_H_INCLUDED |
||||
|
#define COMIMPL_H_INCLUDED |
||||
|
|
||||
|
#include <cstring> |
||||
|
|
||||
|
__IID_DEF(IUnknown, 0, 0, 0, C0, 00, 00, 00, 00, 00, 00, 46); |
||||
|
|
||||
|
class ComObject : public virtual IUnknown |
||||
|
{ |
||||
|
private: |
||||
|
unsigned int _refCount; |
||||
|
public: |
||||
|
|
||||
|
virtual ULONG AddRef() |
||||
|
{ |
||||
|
_refCount++; |
||||
|
return _refCount; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
virtual ULONG Release() |
||||
|
{ |
||||
|
_refCount--; |
||||
|
ULONG rv = _refCount; |
||||
|
if(_refCount == 0) |
||||
|
delete(this); |
||||
|
return rv; |
||||
|
} |
||||
|
|
||||
|
ComObject() |
||||
|
{ |
||||
|
_refCount = 1; |
||||
|
|
||||
|
} |
||||
|
virtual ~ComObject() |
||||
|
{ |
||||
|
} |
||||
|
|
||||
|
|
||||
|
virtual ::HRESULT STDMETHODCALLTYPE QueryInterfaceImpl(REFIID riid, void **ppvObject) = 0; |
||||
|
|
||||
|
virtual ::HRESULT STDMETHODCALLTYPE QueryInterface(REFIID riid, |
||||
|
void **ppvObject) |
||||
|
{ |
||||
|
if(0 == memcmp(riid, &IID_IUnknown, sizeof(GUID))) |
||||
|
*ppvObject = (IUnknown*)this; |
||||
|
else |
||||
|
{ |
||||
|
auto rv = QueryInterfaceImpl(riid, ppvObject); |
||||
|
if(rv != S_OK) |
||||
|
return rv; |
||||
|
} |
||||
|
_refCount++; |
||||
|
return S_OK; |
||||
|
} |
||||
|
|
||||
|
}; |
||||
|
|
||||
|
|
||||
|
#define FORWARD_IUNKNOWN() \ |
||||
|
virtual ULONG Release() override \ |
||||
|
{ \ |
||||
|
return ComObject::Release(); \ |
||||
|
} \ |
||||
|
virtual ULONG AddRef() override \ |
||||
|
{ \ |
||||
|
return ComObject::AddRef(); \ |
||||
|
} \ |
||||
|
virtual HRESULT QueryInterface(REFIID riid, void **ppvObject) override \ |
||||
|
{ \ |
||||
|
return ComObject::QueryInterface(riid, ppvObject); \ |
||||
|
} |
||||
|
|
||||
|
#define BEGIN_INTERFACE_MAP() public: virtual HRESULT STDMETHODCALLTYPE QueryInterfaceImpl(REFIID riid, void **ppvObject) override { |
||||
|
#define INTERFACE_MAP_ENTRY(TInterface, IID) if(0 == memcmp(riid, &IID, sizeof(GUID))) { TInterface* casted = this; *ppvObject = casted; return S_OK; } |
||||
|
#define END_INTERFACE_MAP() return E_NOINTERFACE; } |
||||
|
#define INHERIT_INTERFACE_MAP(TBase) if(TBase::QueryInterfaceImpl(riid, ppvObject) == S_OK) return S_OK; |
||||
|
|
||||
|
|
||||
|
|
||||
|
class ComUnknownObject : public ComObject |
||||
|
{ |
||||
|
public: |
||||
|
FORWARD_IUNKNOWN() |
||||
|
virtual ::HRESULT STDMETHODCALLTYPE QueryInterfaceImpl(REFIID riid, void **ppvObject) override |
||||
|
{ |
||||
|
return E_NOINTERFACE; |
||||
|
}; |
||||
|
virtual ~ComUnknownObject(){} |
||||
|
}; |
||||
|
|
||||
|
template<class TInterface, GUID const* TIID> class ComSingleObject : public ComObject, public virtual TInterface |
||||
|
{ |
||||
|
BEGIN_INTERFACE_MAP() |
||||
|
INTERFACE_MAP_ENTRY(TInterface, *TIID) |
||||
|
END_INTERFACE_MAP() |
||||
|
|
||||
|
public: |
||||
|
virtual ~ComSingleObject(){} |
||||
|
}; |
||||
|
|
||||
|
template<class TInterface> |
||||
|
class ComPtr |
||||
|
{ |
||||
|
private: |
||||
|
TInterface* _obj; |
||||
|
public: |
||||
|
ComPtr() |
||||
|
{ |
||||
|
_obj = 0; |
||||
|
} |
||||
|
|
||||
|
ComPtr(TInterface* pObj) |
||||
|
{ |
||||
|
_obj = 0; |
||||
|
|
||||
|
if (pObj) |
||||
|
{ |
||||
|
_obj = pObj; |
||||
|
_obj->AddRef(); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
ComPtr(const ComPtr& ptr) |
||||
|
{ |
||||
|
_obj = 0; |
||||
|
|
||||
|
if (ptr._obj) |
||||
|
{ |
||||
|
_obj = ptr._obj; |
||||
|
_obj->AddRef(); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
ComPtr& operator=(ComPtr other) |
||||
|
{ |
||||
|
if(_obj != NULL) |
||||
|
_obj->Release(); |
||||
|
_obj = other._obj; |
||||
|
if(_obj != NULL) |
||||
|
_obj->AddRef(); |
||||
|
return *this; |
||||
|
} |
||||
|
|
||||
|
~ComPtr() |
||||
|
{ |
||||
|
if (_obj) |
||||
|
{ |
||||
|
_obj->Release(); |
||||
|
_obj = 0; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
TInterface* getRaw() |
||||
|
{ |
||||
|
return _obj; |
||||
|
} |
||||
|
|
||||
|
operator TInterface*() const |
||||
|
{ |
||||
|
return _obj; |
||||
|
} |
||||
|
TInterface& operator*() const |
||||
|
{ |
||||
|
return *_obj; |
||||
|
} |
||||
|
TInterface** operator&() |
||||
|
{ |
||||
|
return &_obj; |
||||
|
} |
||||
|
TInterface* operator->() const |
||||
|
{ |
||||
|
return _obj; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
#endif // COMIMPL_H_INCLUDED
|
||||
|
#pragma clang diagnostic pop |
||||
File diff suppressed because it is too large
@ -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 = ../../inc; 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 = ../../inc; |
||||
|
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 = ../../inc; |
||||
|
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.NetCore" |
||||
|
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.NetCore.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) override |
||||
|
{ |
||||
|
@autoreleasepool |
||||
|
{ |
||||
|
*ret = (int)[NSScreen screens].count; |
||||
|
|
||||
|
return S_OK; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
virtual HRESULT GetScreen (int index, AvnScreen* ret) override |
||||
|
{ |
||||
|
@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) override |
||||
|
{ |
||||
|
@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) override |
||||
|
{ |
||||
|
@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) override |
||||
|
{ |
||||
|
@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(); |
||||
|
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
// 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 Clipboard : public ComSingleObject<IAvnClipboard, &IID_IAvnClipboard> |
||||
|
{ |
||||
|
public: |
||||
|
FORWARD_IUNKNOWN() |
||||
|
virtual HRESULT GetText (void** retOut) override |
||||
|
{ |
||||
|
@autoreleasepool |
||||
|
{ |
||||
|
NSString *str = [[NSPasteboard generalPasteboard] stringForType:NSPasteboardTypeString]; |
||||
|
*retOut = (void *)str.UTF8String; |
||||
|
} |
||||
|
|
||||
|
return S_OK; |
||||
|
} |
||||
|
|
||||
|
virtual HRESULT SetText (char* text) override |
||||
|
{ |
||||
|
@autoreleasepool |
||||
|
{ |
||||
|
NSPasteboard *pasteBoard = [NSPasteboard generalPasteboard]; |
||||
|
[pasteBoard clearContents]; |
||||
|
[pasteBoard setString:@(text) forType:NSPasteboardTypeString]; |
||||
|
} |
||||
|
|
||||
|
return S_OK; |
||||
|
} |
||||
|
|
||||
|
virtual HRESULT Clear() override |
||||
|
{ |
||||
|
@autoreleasepool |
||||
|
{ |
||||
|
[[NSPasteboard generalPasteboard] clearContents]; |
||||
|
} |
||||
|
|
||||
|
return S_OK; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
extern IAvnClipboard* CreateClipboard() |
||||
|
{ |
||||
|
return new Clipboard(); |
||||
|
} |
||||
@ -0,0 +1,34 @@ |
|||||
|
// 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 common_h |
||||
|
#define common_h |
||||
|
#include "comimpl.h" |
||||
|
#include "avalonia-native.h" |
||||
|
#include <stdio.h> |
||||
|
#import <Foundation/Foundation.h> |
||||
|
#import <AppKit/AppKit.h> |
||||
|
#include <pthread.h> |
||||
|
|
||||
|
extern IAvnPlatformThreadingInterface* CreatePlatformThreading(); |
||||
|
extern IAvnWindow* CreateAvnWindow(IAvnWindowEvents*events); |
||||
|
extern IAvnPopup* CreateAvnPopup(IAvnWindowEvents*events); |
||||
|
extern IAvnSystemDialogs* CreateSystemDialogs(); |
||||
|
extern IAvnScreens* CreateScreens(); |
||||
|
extern IAvnClipboard* CreateClipboard(); |
||||
|
extern IAvnCursorFactory* CreateCursorFactory(); |
||||
|
extern IAvnGlFeature* GetGlFeature(); |
||||
|
extern IAvnGlSurfaceRenderTarget* CreateGlRenderTarget(NSWindow* window, NSView* view); |
||||
|
|
||||
|
extern NSPoint ToNSPoint (AvnPoint p); |
||||
|
extern AvnPoint ToAvnPoint (NSPoint p); |
||||
|
extern AvnPoint ConvertPointY (AvnPoint p); |
||||
|
extern NSSize ToNSSize (AvnSize s); |
||||
|
|
||||
|
#ifdef DEBUG |
||||
|
#define NSDebugLog(...) NSLog(__VA_ARGS__) |
||||
|
#else |
||||
|
#define NSDebugLog(...) (void)0 |
||||
|
#endif |
||||
|
|
||||
|
#endif |
||||
@ -0,0 +1,29 @@ |
|||||
|
// 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 cursor_h |
||||
|
#define cursor_h |
||||
|
|
||||
|
#include "common.h" |
||||
|
#include <map> |
||||
|
|
||||
|
class Cursor : public ComSingleObject<IAvnCursor, &IID_IAvnCursor> |
||||
|
{ |
||||
|
private: |
||||
|
NSCursor * _native; |
||||
|
|
||||
|
public: |
||||
|
FORWARD_IUNKNOWN() |
||||
|
Cursor(NSCursor * cursor) |
||||
|
{ |
||||
|
_native = cursor; |
||||
|
} |
||||
|
|
||||
|
NSCursor* GetNative() |
||||
|
{ |
||||
|
return _native; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
extern std::map<AvnStandardCursorType, Cursor*> s_cursorMap; |
||||
|
#endif /* cursor_h */ |
||||
@ -0,0 +1,73 @@ |
|||||
|
// 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 "cursor.h" |
||||
|
#include <map> |
||||
|
|
||||
|
class CursorFactory : public ComSingleObject<IAvnCursorFactory, &IID_IAvnCursorFactory> |
||||
|
{ |
||||
|
Cursor* arrowCursor = new Cursor([NSCursor arrowCursor]); |
||||
|
Cursor* crossCursor = new Cursor([NSCursor crosshairCursor]); |
||||
|
Cursor* resizeUpCursor = new Cursor([NSCursor resizeUpCursor]); |
||||
|
Cursor* resizeDownCursor = new Cursor([NSCursor resizeDownCursor]); |
||||
|
Cursor* resizeUpDownCursor = new Cursor([NSCursor resizeUpDownCursor]); |
||||
|
Cursor* dragCopyCursor = new Cursor([NSCursor dragCopyCursor]); |
||||
|
Cursor* dragLinkCursor = new Cursor([NSCursor dragLinkCursor]); |
||||
|
Cursor* pointingHandCursor = new Cursor([NSCursor pointingHandCursor]); |
||||
|
Cursor* contextualMenuCursor = new Cursor([NSCursor contextualMenuCursor]); |
||||
|
Cursor* IBeamCursor = new Cursor([NSCursor IBeamCursor]); |
||||
|
Cursor* resizeLeftCursor = new Cursor([NSCursor resizeLeftCursor]); |
||||
|
Cursor* resizeRightCursor = new Cursor([NSCursor resizeRightCursor]); |
||||
|
Cursor* resizeWestEastCursor = new Cursor([NSCursor resizeLeftRightCursor]); |
||||
|
Cursor* operationNotAllowedCursor = new Cursor([NSCursor operationNotAllowedCursor]); |
||||
|
|
||||
|
std::map<AvnStandardCursorType, Cursor*> s_cursorMap = |
||||
|
{ |
||||
|
{ CursorArrow, arrowCursor }, |
||||
|
{ CursorAppStarting, arrowCursor }, |
||||
|
{ CursorWait, arrowCursor }, |
||||
|
{ CursorTopLeftCorner, crossCursor }, |
||||
|
{ CursorTopRightCorner, crossCursor }, |
||||
|
{ CursorBottomLeftCorner, crossCursor }, |
||||
|
{ CursorBottomRightCorner, crossCursor }, |
||||
|
{ CursorCross, crossCursor }, |
||||
|
{ CursorSizeAll, crossCursor }, |
||||
|
{ CursorSizeNorthSouth, resizeUpDownCursor}, |
||||
|
{ CursorSizeWestEast, resizeWestEastCursor}, |
||||
|
{ CursorTopSide, resizeUpCursor }, |
||||
|
{ CursorUpArrow, resizeUpCursor }, |
||||
|
{ CursorBottomSize, resizeDownCursor }, |
||||
|
{ CursorDragCopy, dragCopyCursor }, |
||||
|
{ CursorDragMove, dragCopyCursor }, |
||||
|
{ CursorDragLink, dragLinkCursor }, |
||||
|
{ CursorHand, pointingHandCursor }, |
||||
|
{ CursorHelp, contextualMenuCursor }, |
||||
|
{ CursorIbeam, IBeamCursor }, |
||||
|
{ CursorLeftSide, resizeLeftCursor }, |
||||
|
{ CursorRightSide, resizeRightCursor }, |
||||
|
{ CursorNo, operationNotAllowedCursor } |
||||
|
}; |
||||
|
|
||||
|
public: |
||||
|
FORWARD_IUNKNOWN() |
||||
|
virtual HRESULT GetCursor (AvnStandardCursorType cursorType, IAvnCursor** retOut) override |
||||
|
{ |
||||
|
*retOut = s_cursorMap[cursorType]; |
||||
|
|
||||
|
if(*retOut != nullptr) |
||||
|
{ |
||||
|
(*retOut)->AddRef(); |
||||
|
} |
||||
|
|
||||
|
return S_OK; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
extern IAvnCursorFactory* CreateCursorFactory() |
||||
|
{ |
||||
|
@autoreleasepool |
||||
|
{ |
||||
|
return new CursorFactory(); |
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,255 @@ |
|||||
|
#include "common.h" |
||||
|
#include <OpenGL/gl.h> |
||||
|
#include <dlfcn.h> |
||||
|
|
||||
|
template <typename T, size_t N> char (&ArrayCounter(T (&a)[N]))[N]; |
||||
|
#define ARRAY_COUNT(a) (sizeof(ArrayCounter(a))) |
||||
|
|
||||
|
NSOpenGLPixelFormat* CreateFormat() |
||||
|
{ |
||||
|
NSOpenGLPixelFormatAttribute attribs[] = |
||||
|
{ |
||||
|
NSOpenGLPFADoubleBuffer, |
||||
|
NSOpenGLPFAColorSize, 32, |
||||
|
NSOpenGLPFAStencilSize, 8, |
||||
|
NSOpenGLPFADepthSize, 8, |
||||
|
0 |
||||
|
}; |
||||
|
return [[NSOpenGLPixelFormat alloc] initWithAttributes:attribs]; |
||||
|
} |
||||
|
|
||||
|
class AvnGlContext : public virtual ComSingleObject<IAvnGlContext, &IID_IAvnGlContext> |
||||
|
{ |
||||
|
public: |
||||
|
FORWARD_IUNKNOWN() |
||||
|
NSOpenGLContext* GlContext; |
||||
|
GLuint Framebuffer, RenderBuffer, StencilBuffer; |
||||
|
AvnGlContext(NSOpenGLContext* gl, bool offscreen) |
||||
|
{ |
||||
|
Framebuffer = 0; |
||||
|
RenderBuffer = 0; |
||||
|
StencilBuffer = 0; |
||||
|
GlContext = gl; |
||||
|
if(offscreen) |
||||
|
{ |
||||
|
[GlContext makeCurrentContext]; |
||||
|
|
||||
|
glGenFramebuffersEXT(1, &Framebuffer); |
||||
|
glBindFramebufferEXT(GL_FRAMEBUFFER, Framebuffer); |
||||
|
glGenRenderbuffersEXT(1, &RenderBuffer); |
||||
|
glGenRenderbuffersEXT(1, &StencilBuffer); |
||||
|
|
||||
|
glBindRenderbufferEXT(GL_RENDERBUFFER, StencilBuffer); |
||||
|
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, StencilBuffer); |
||||
|
glBindRenderbufferEXT(GL_RENDERBUFFER, RenderBuffer); |
||||
|
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, RenderBuffer); |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
|
||||
|
|
||||
|
virtual HRESULT MakeCurrent() override |
||||
|
{ |
||||
|
[GlContext makeCurrentContext];/* |
||||
|
glBindFramebufferEXT(GL_FRAMEBUFFER, Framebuffer); |
||||
|
glBindRenderbufferEXT(GL_RENDERBUFFER, RenderBuffer); |
||||
|
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_RENDERBUFFER, RenderBuffer); |
||||
|
glBindRenderbufferEXT(GL_RENDERBUFFER, StencilBuffer); |
||||
|
glFramebufferRenderbufferEXT(GL_FRAMEBUFFER, GL_STENCIL_ATTACHMENT, GL_RENDERBUFFER, StencilBuffer);*/ |
||||
|
return S_OK; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
class AvnGlDisplay : public virtual ComSingleObject<IAvnGlDisplay, &IID_IAvnGlDisplay> |
||||
|
{ |
||||
|
int _sampleCount, _stencilSize; |
||||
|
void* _libgl; |
||||
|
|
||||
|
public: |
||||
|
FORWARD_IUNKNOWN() |
||||
|
|
||||
|
AvnGlDisplay(int sampleCount, int stencilSize) |
||||
|
{ |
||||
|
_sampleCount = sampleCount; |
||||
|
_stencilSize = stencilSize; |
||||
|
_libgl = dlopen("/System/Library/Frameworks/OpenGL.framework/Versions/A/Libraries/libGL.dylib", RTLD_LAZY); |
||||
|
} |
||||
|
|
||||
|
virtual HRESULT GetSampleCount(int* ret) override |
||||
|
{ |
||||
|
*ret = _sampleCount; |
||||
|
return S_OK; |
||||
|
} |
||||
|
virtual HRESULT GetStencilSize(int* ret) override |
||||
|
{ |
||||
|
*ret = _stencilSize; |
||||
|
return S_OK; |
||||
|
} |
||||
|
|
||||
|
virtual HRESULT ClearContext() override |
||||
|
{ |
||||
|
[NSOpenGLContext clearCurrentContext]; |
||||
|
return S_OK; |
||||
|
} |
||||
|
|
||||
|
virtual void* GetProcAddress(char* proc) override |
||||
|
{ |
||||
|
return dlsym(_libgl, proc); |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
class GlFeature : public virtual ComSingleObject<IAvnGlFeature, &IID_IAvnGlFeature> |
||||
|
{ |
||||
|
IAvnGlDisplay* _display; |
||||
|
AvnGlContext *_immediate; |
||||
|
NSOpenGLContext* _shared; |
||||
|
public: |
||||
|
FORWARD_IUNKNOWN() |
||||
|
NSOpenGLPixelFormat* _format; |
||||
|
GlFeature(IAvnGlDisplay* display, AvnGlContext* immediate, NSOpenGLPixelFormat* format) |
||||
|
{ |
||||
|
_display = display; |
||||
|
_immediate = immediate; |
||||
|
_format = format; |
||||
|
_shared = [[NSOpenGLContext alloc] initWithFormat:_format shareContext:_immediate->GlContext]; |
||||
|
} |
||||
|
|
||||
|
NSOpenGLContext* CreateContext() |
||||
|
{ |
||||
|
return _shared; |
||||
|
//return [[NSOpenGLContext alloc] initWithFormat:_format shareContext:nil]; |
||||
|
} |
||||
|
|
||||
|
virtual HRESULT ObtainDisplay(IAvnGlDisplay**retOut) override |
||||
|
{ |
||||
|
*retOut = _display; |
||||
|
_display->AddRef(); |
||||
|
return S_OK; |
||||
|
} |
||||
|
|
||||
|
virtual HRESULT ObtainImmediateContext(IAvnGlContext**retOut) override |
||||
|
{ |
||||
|
*retOut = _immediate; |
||||
|
_immediate->AddRef(); |
||||
|
return S_OK; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
static GlFeature* Feature; |
||||
|
|
||||
|
GlFeature* CreateGlFeature() |
||||
|
{ |
||||
|
auto format = CreateFormat(); |
||||
|
if(format == nil) |
||||
|
{ |
||||
|
NSLog(@"Unable to choose pixel format"); |
||||
|
return NULL; |
||||
|
} |
||||
|
|
||||
|
auto immediateContext = [[NSOpenGLContext alloc] initWithFormat:format shareContext:nil]; |
||||
|
if(immediateContext == nil) |
||||
|
{ |
||||
|
NSLog(@"Unable to create NSOpenGLContext"); |
||||
|
return NULL; |
||||
|
} |
||||
|
|
||||
|
int stencilBits = 0, sampleCount = 0; |
||||
|
|
||||
|
auto fmt = CGLGetPixelFormat([immediateContext CGLContextObj]); |
||||
|
CGLDescribePixelFormat(fmt, 0, kCGLPFASamples, &sampleCount); |
||||
|
CGLDescribePixelFormat(fmt, 0, kCGLPFAStencilSize, &stencilBits); |
||||
|
|
||||
|
auto offscreen = new AvnGlContext(immediateContext, true); |
||||
|
auto display = new AvnGlDisplay(sampleCount, stencilBits); |
||||
|
|
||||
|
return new GlFeature(display, offscreen, format); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
static GlFeature* GetFeature() |
||||
|
{ |
||||
|
if(Feature == nil) |
||||
|
Feature = CreateGlFeature(); |
||||
|
return Feature; |
||||
|
} |
||||
|
|
||||
|
extern IAvnGlFeature* GetGlFeature() |
||||
|
{ |
||||
|
return GetFeature(); |
||||
|
} |
||||
|
|
||||
|
class AvnGlRenderingSession : public ComSingleObject<IAvnGlSurfaceRenderingSession, &IID_IAvnGlSurfaceRenderingSession> |
||||
|
{ |
||||
|
NSView* _view; |
||||
|
NSWindow* _window; |
||||
|
NSOpenGLContext* _context; |
||||
|
public: |
||||
|
FORWARD_IUNKNOWN() |
||||
|
AvnGlRenderingSession(NSWindow*window, NSView* view, NSOpenGLContext* context) |
||||
|
{ |
||||
|
_context = context; |
||||
|
_window = window; |
||||
|
_view = view; |
||||
|
} |
||||
|
|
||||
|
virtual HRESULT GetPixelSize(AvnPixelSize* ret) override |
||||
|
{ |
||||
|
auto fsize = [_view convertSizeToBacking: [_view frame].size]; |
||||
|
ret->Width = (int)fsize.width; |
||||
|
ret->Height = (int)fsize.height; |
||||
|
return S_OK; |
||||
|
} |
||||
|
virtual HRESULT GetScaling(double* ret) override |
||||
|
{ |
||||
|
*ret = [_window backingScaleFactor]; |
||||
|
return S_OK; |
||||
|
} |
||||
|
|
||||
|
virtual ~AvnGlRenderingSession() |
||||
|
{ |
||||
|
glFlush(); |
||||
|
[_context flushBuffer]; |
||||
|
[_context setView:nil]; |
||||
|
CGLUnlockContext([_context CGLContextObj]); |
||||
|
[_view unlockFocus]; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
class AvnGlRenderTarget : public ComSingleObject<IAvnGlSurfaceRenderTarget, &IID_IAvnGlSurfaceRenderTarget> |
||||
|
{ |
||||
|
NSView* _view; |
||||
|
NSWindow* _window; |
||||
|
NSOpenGLContext* _context; |
||||
|
public: |
||||
|
FORWARD_IUNKNOWN() |
||||
|
AvnGlRenderTarget(NSWindow* window, NSView*view) |
||||
|
{ |
||||
|
_window = window; |
||||
|
_view = view; |
||||
|
_context = GetFeature()->CreateContext(); |
||||
|
} |
||||
|
|
||||
|
virtual HRESULT BeginDrawing(IAvnGlSurfaceRenderingSession** ret) override |
||||
|
{ |
||||
|
auto f = GetFeature(); |
||||
|
if(f == NULL) |
||||
|
return E_FAIL; |
||||
|
if(![_view lockFocusIfCanDraw]) |
||||
|
return E_ABORT; |
||||
|
|
||||
|
auto gl = _context; |
||||
|
CGLLockContext([_context CGLContextObj]); |
||||
|
[gl setView: _view]; |
||||
|
[gl makeCurrentContext]; |
||||
|
auto frame = [_view frame]; |
||||
|
|
||||
|
*ret = new AvnGlRenderingSession(_window, _view, gl); |
||||
|
return S_OK; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
extern IAvnGlSurfaceRenderTarget* CreateGlRenderTarget(NSWindow* window, NSView* view) |
||||
|
{ |
||||
|
return new AvnGlRenderTarget(window, view); |
||||
|
} |
||||
@ -0,0 +1,178 @@ |
|||||
|
// 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. |
||||
|
|
||||
|
//This file will contain actual IID structures |
||||
|
#define COM_GUIDS_MATERIALIZE |
||||
|
#include "common.h" |
||||
|
|
||||
|
static BOOL ShowInDock = 1; |
||||
|
|
||||
|
static void SetActivationPolicy() |
||||
|
{ |
||||
|
[[NSApplication sharedApplication] setActivationPolicy: (ShowInDock ? NSApplicationActivationPolicyRegular : NSApplicationActivationPolicyAccessory)]; |
||||
|
} |
||||
|
|
||||
|
class MacOptions : public ComSingleObject<IAvnMacOptions, &IID_IAvnMacOptions> |
||||
|
{ |
||||
|
public: |
||||
|
FORWARD_IUNKNOWN() |
||||
|
virtual HRESULT SetShowInDock(int show) override |
||||
|
{ |
||||
|
ShowInDock = show; |
||||
|
SetActivationPolicy(); |
||||
|
return S_OK; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
|
||||
|
/// See "Using POSIX Threads in a Cocoa Application" section here: |
||||
|
/// https://developer.apple.com/library/content/documentation/Cocoa/Conceptual/Multithreading/CreatingThreads/CreatingThreads.html#//apple_ref/doc/uid/20000738-125024 |
||||
|
@interface ThreadingInitializer : NSObject |
||||
|
- (void) do; |
||||
|
@end |
||||
|
@implementation ThreadingInitializer |
||||
|
|
||||
|
pthread_mutex_t mutex; |
||||
|
pthread_cond_t cond; |
||||
|
|
||||
|
- (void) runOnce |
||||
|
{ |
||||
|
pthread_mutex_lock(&mutex); |
||||
|
pthread_cond_signal(&cond); |
||||
|
pthread_mutex_unlock(&mutex); |
||||
|
} |
||||
|
|
||||
|
- (void) do |
||||
|
{ |
||||
|
pthread_mutex_init(&mutex, NULL); |
||||
|
pthread_cond_init(&cond, NULL); |
||||
|
[[[NSThread alloc] initWithTarget:self selector:@selector(runOnce) object:nil] start]; |
||||
|
pthread_mutex_lock(&mutex); |
||||
|
pthread_cond_wait(&cond, &mutex); |
||||
|
pthread_mutex_unlock(&mutex); |
||||
|
pthread_cond_destroy(&cond); |
||||
|
pthread_mutex_destroy(&mutex); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@end |
||||
|
|
||||
|
|
||||
|
class AvaloniaNative : public ComSingleObject<IAvaloniaNativeFactory, &IID_IAvaloniaNativeFactory> |
||||
|
{ |
||||
|
|
||||
|
public: |
||||
|
FORWARD_IUNKNOWN() |
||||
|
virtual HRESULT Initialize() override |
||||
|
{ |
||||
|
@autoreleasepool{ |
||||
|
[[ThreadingInitializer new] do]; |
||||
|
return S_OK; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
virtual IAvnMacOptions* GetMacOptions() override |
||||
|
{ |
||||
|
return (IAvnMacOptions*)new MacOptions(); |
||||
|
} |
||||
|
|
||||
|
virtual HRESULT CreateWindow(IAvnWindowEvents* cb, IAvnWindow** ppv) override |
||||
|
{ |
||||
|
if(cb == nullptr || ppv == nullptr) |
||||
|
return E_POINTER; |
||||
|
*ppv = CreateAvnWindow(cb); |
||||
|
return S_OK; |
||||
|
}; |
||||
|
|
||||
|
virtual HRESULT CreatePopup(IAvnWindowEvents* cb, IAvnPopup** ppv) override |
||||
|
{ |
||||
|
if(cb == nullptr || ppv == nullptr) |
||||
|
return E_POINTER; |
||||
|
|
||||
|
*ppv = CreateAvnPopup(cb); |
||||
|
return S_OK; |
||||
|
} |
||||
|
|
||||
|
virtual HRESULT CreatePlatformThreadingInterface(IAvnPlatformThreadingInterface** ppv) override |
||||
|
{ |
||||
|
*ppv = CreatePlatformThreading(); |
||||
|
return S_OK; |
||||
|
} |
||||
|
|
||||
|
virtual HRESULT CreateSystemDialogs(IAvnSystemDialogs** ppv) override |
||||
|
{ |
||||
|
*ppv = ::CreateSystemDialogs(); |
||||
|
return S_OK; |
||||
|
} |
||||
|
|
||||
|
virtual HRESULT CreateScreens (IAvnScreens** ppv) override |
||||
|
{ |
||||
|
*ppv = ::CreateScreens (); |
||||
|
return S_OK; |
||||
|
} |
||||
|
|
||||
|
virtual HRESULT CreateClipboard(IAvnClipboard** ppv) override |
||||
|
{ |
||||
|
*ppv = ::CreateClipboard (); |
||||
|
return S_OK; |
||||
|
} |
||||
|
|
||||
|
virtual HRESULT CreateCursorFactory(IAvnCursorFactory** ppv) override |
||||
|
{ |
||||
|
*ppv = ::CreateCursorFactory(); |
||||
|
return S_OK; |
||||
|
} |
||||
|
|
||||
|
virtual HRESULT ObtainGlFeature(IAvnGlFeature** ppv) override |
||||
|
{ |
||||
|
auto rv = ::GetGlFeature(); |
||||
|
if(rv == NULL) |
||||
|
return E_FAIL; |
||||
|
rv->AddRef(); |
||||
|
*ppv = rv; |
||||
|
return S_OK; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
extern "C" IAvaloniaNativeFactory* CreateAvaloniaNative() |
||||
|
{ |
||||
|
return new AvaloniaNative(); |
||||
|
}; |
||||
|
|
||||
|
NSSize ToNSSize (AvnSize s) |
||||
|
{ |
||||
|
NSSize result; |
||||
|
result.width = s.Width; |
||||
|
result.height = s.Height; |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
NSPoint ToNSPoint (AvnPoint p) |
||||
|
{ |
||||
|
NSPoint result; |
||||
|
result.x = p.X; |
||||
|
result.y = p.Y; |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
AvnPoint ToAvnPoint (NSPoint p) |
||||
|
{ |
||||
|
AvnPoint result; |
||||
|
result.X = p.x; |
||||
|
result.Y = p.y; |
||||
|
|
||||
|
return result; |
||||
|
} |
||||
|
|
||||
|
AvnPoint ConvertPointY (AvnPoint p) |
||||
|
{ |
||||
|
auto sw = [NSScreen.screens objectAtIndex:0].frame; |
||||
|
|
||||
|
auto t = MAX(sw.origin.y, sw.origin.y + sw.size.height); |
||||
|
p.Y = t - p.Y; |
||||
|
|
||||
|
return p; |
||||
|
} |
||||
@ -0,0 +1,190 @@ |
|||||
|
// 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 PlatformThreadingInterface; |
||||
|
@interface Signaler : NSObject |
||||
|
-(void) setParent: (PlatformThreadingInterface*)parent; |
||||
|
-(void) signal: (int) priority; |
||||
|
-(Signaler*) init; |
||||
|
@end |
||||
|
|
||||
|
|
||||
|
@interface ActionCallback : NSObject |
||||
|
- (ActionCallback*) initWithCallback: (IAvnActionCallback*) callback; |
||||
|
- (void) action; |
||||
|
@end |
||||
|
|
||||
|
@implementation ActionCallback |
||||
|
{ |
||||
|
ComPtr<IAvnActionCallback> _callback; |
||||
|
|
||||
|
} |
||||
|
- (ActionCallback*) initWithCallback: (IAvnActionCallback*) callback |
||||
|
{ |
||||
|
_callback = callback; |
||||
|
return self; |
||||
|
} |
||||
|
|
||||
|
- (void) action |
||||
|
{ |
||||
|
_callback->Run(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
@end |
||||
|
|
||||
|
class TimerWrapper : public ComUnknownObject |
||||
|
{ |
||||
|
NSTimer* _timer; |
||||
|
public: |
||||
|
TimerWrapper(IAvnActionCallback* callback, int ms) |
||||
|
{ |
||||
|
auto cb = [[ActionCallback alloc] initWithCallback:callback]; |
||||
|
_timer = [NSTimer scheduledTimerWithTimeInterval:(NSTimeInterval)(double)ms/1000 target:cb selector:@selector(action) userInfo:nullptr repeats:true]; |
||||
|
} |
||||
|
|
||||
|
virtual ~TimerWrapper() |
||||
|
{ |
||||
|
[_timer invalidate]; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
|
||||
|
|
||||
|
class PlatformThreadingInterface : public ComSingleObject<IAvnPlatformThreadingInterface, &IID_IAvnPlatformThreadingInterface> |
||||
|
{ |
||||
|
private: |
||||
|
Signaler* _signaler; |
||||
|
|
||||
|
class LoopCancellation : public ComSingleObject<IAvnLoopCancellation, &IID_IAvnLoopCancellation> |
||||
|
{ |
||||
|
public: |
||||
|
FORWARD_IUNKNOWN() |
||||
|
bool Cancelled = 0; |
||||
|
virtual void Cancel() override |
||||
|
{ |
||||
|
Cancelled = 1; |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
public: |
||||
|
FORWARD_IUNKNOWN() |
||||
|
ComPtr<IAvnSignaledCallback> SignaledCallback; |
||||
|
|
||||
|
PlatformThreadingInterface() |
||||
|
{ |
||||
|
_signaler = [Signaler new]; |
||||
|
[_signaler setParent:this]; |
||||
|
} |
||||
|
|
||||
|
~PlatformThreadingInterface() |
||||
|
{ |
||||
|
if(_signaler) |
||||
|
[_signaler setParent: NULL]; |
||||
|
_signaler = NULL; |
||||
|
} |
||||
|
|
||||
|
virtual bool GetCurrentThreadIsLoopThread() override |
||||
|
{ |
||||
|
return [[NSThread currentThread] isMainThread]; |
||||
|
} |
||||
|
virtual void SetSignaledCallback(IAvnSignaledCallback* cb) override |
||||
|
{ |
||||
|
SignaledCallback = cb; |
||||
|
} |
||||
|
virtual IAvnLoopCancellation* CreateLoopCancellation() override |
||||
|
{ |
||||
|
return new LoopCancellation(); |
||||
|
} |
||||
|
|
||||
|
virtual void RunLoop(IAvnLoopCancellation* cancel) override |
||||
|
{ |
||||
|
@autoreleasepool { |
||||
|
auto can = dynamic_cast<LoopCancellation*>(cancel); |
||||
|
[[NSApplication sharedApplication] activateIgnoringOtherApps:true]; |
||||
|
while(true) |
||||
|
{ |
||||
|
@autoreleasepool |
||||
|
{ |
||||
|
if(can != NULL && can->Cancelled) |
||||
|
return; |
||||
|
NSEvent* ev = [[NSApplication sharedApplication] |
||||
|
nextEventMatchingMask:NSEventMaskAny |
||||
|
untilDate: [NSDate dateWithTimeIntervalSinceNow:1] |
||||
|
inMode:NSDefaultRunLoopMode |
||||
|
dequeue:true]; |
||||
|
if(can != NULL && can->Cancelled) |
||||
|
return; |
||||
|
if(ev != NULL) |
||||
|
[[NSApplication sharedApplication] sendEvent:ev]; |
||||
|
} |
||||
|
} |
||||
|
NSDebugLog(@"RunLoop exited"); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
virtual void Signal(int priority) override |
||||
|
{ |
||||
|
[_signaler signal:priority]; |
||||
|
} |
||||
|
|
||||
|
virtual IUnknown* StartTimer(int priority, int ms, IAvnActionCallback* callback) override |
||||
|
{ |
||||
|
@autoreleasepool { |
||||
|
|
||||
|
return new TimerWrapper(callback, ms); |
||||
|
} |
||||
|
} |
||||
|
}; |
||||
|
|
||||
|
@implementation Signaler |
||||
|
|
||||
|
PlatformThreadingInterface* _parent = 0; |
||||
|
bool _signaled = 0; |
||||
|
NSArray<NSString*>* _modes; |
||||
|
|
||||
|
-(Signaler*) init |
||||
|
{ |
||||
|
if(self = [super init]) |
||||
|
{ |
||||
|
_modes = [NSArray arrayWithObjects: NSDefaultRunLoopMode, NSEventTrackingRunLoopMode, NSModalPanelRunLoopMode, NSRunLoopCommonModes, NSConnectionReplyMode, nil]; |
||||
|
} |
||||
|
return self; |
||||
|
} |
||||
|
|
||||
|
-(void) perform |
||||
|
{ |
||||
|
@synchronized (self) { |
||||
|
_signaled = false; |
||||
|
if(_parent != NULL && _parent->SignaledCallback != NULL) |
||||
|
_parent->SignaledCallback->Signaled(0, false); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
-(void) setParent:(PlatformThreadingInterface *)parent |
||||
|
{ |
||||
|
@synchronized (self) { |
||||
|
_parent = parent; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
-(void) signal: (int) priority |
||||
|
{ |
||||
|
|
||||
|
@synchronized (self) { |
||||
|
if(_signaled) |
||||
|
return; |
||||
|
_signaled = true; |
||||
|
[self performSelector:@selector(perform) onThread:[NSThread mainThread] withObject:NULL waitUntilDone:false modes:_modes]; |
||||
|
} |
||||
|
|
||||
|
} |
||||
|
@end |
||||
|
|
||||
|
|
||||
|
extern IAvnPlatformThreadingInterface* CreatePlatformThreading() |
||||
|
{ |
||||
|
return new PlatformThreadingInterface(); |
||||
|
} |
||||
@ -0,0 +1,33 @@ |
|||||
|
// 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 window_h |
||||
|
#define window_h |
||||
|
|
||||
|
class WindowBaseImpl; |
||||
|
|
||||
|
@interface AvnView : NSView<NSTextInputClient> |
||||
|
-(AvnView* _Nonnull) initWithParent: (WindowBaseImpl* _Nonnull) parent; |
||||
|
-(NSEvent* _Nonnull) lastMouseDownEvent; |
||||
|
-(AvnPoint) translateLocalPoint:(AvnPoint)pt; |
||||
|
-(void) setSwRenderedFrame: (AvnFramebuffer* _Nonnull) fb dispose: (IUnknown* _Nonnull) dispose; |
||||
|
-(void) onClosed; |
||||
|
@end |
||||
|
|
||||
|
@interface AvnWindow : NSWindow <NSWindowDelegate> |
||||
|
-(AvnWindow* _Nonnull) initWithParent: (WindowBaseImpl* _Nonnull) parent; |
||||
|
-(void) setCanBecomeKeyAndMain; |
||||
|
-(void) pollModalSession: (NSModalSession _Nonnull) session; |
||||
|
@end |
||||
|
|
||||
|
struct INSWindowHolder |
||||
|
{ |
||||
|
virtual AvnWindow* _Nonnull GetNSWindow () = 0; |
||||
|
}; |
||||
|
|
||||
|
struct IWindowStateChanged |
||||
|
{ |
||||
|
virtual void WindowStateChanged () = 0; |
||||
|
}; |
||||
|
|
||||
|
#endif /* window_h */ |
||||
File diff suppressed because it is too large
@ -1,504 +0,0 @@ |
|||||
using System; |
|
||||
using System.Collections; |
|
||||
using System.Collections.Generic; |
|
||||
using System.Xml.Linq; |
|
||||
|
|
||||
public class Packages |
|
||||
{ |
|
||||
public List<NuGetPackSettings> NuspecNuGetSettings { get; private set; } |
|
||||
public FilePath[] NugetPackages { get; private set; } |
|
||||
public FilePath[] BinFiles { get; private set; } |
|
||||
public string NugetPackagesDir {get; private set;} |
|
||||
public string SkiaSharpVersion {get; private set; } |
|
||||
public string SkiaSharpLinuxVersion {get; private set; } |
|
||||
public Dictionary<string, IList<Tuple<string,string>>> PackageVersions{get; private set;} |
|
||||
|
|
||||
class DependencyBuilder : List<NuSpecDependency> |
|
||||
{ |
|
||||
Packages _parent; |
|
||||
|
|
||||
public DependencyBuilder(Packages parent) |
|
||||
{ |
|
||||
_parent = parent; |
|
||||
} |
|
||||
|
|
||||
string GetVersion(string name) |
|
||||
{ |
|
||||
return _parent.PackageVersions[name].First().Item1; |
|
||||
} |
|
||||
|
|
||||
public DependencyBuilder Dep(string name, params string[] fws) |
|
||||
{ |
|
||||
if(fws.Length == 0) |
|
||||
Add(new NuSpecDependency() { Id = name, Version = GetVersion(name) }); |
|
||||
foreach(var fw in fws) |
|
||||
Add(new NuSpecDependency() { Id = name, TargetFramework = fw, Version = GetVersion(name) }); |
|
||||
return this; |
|
||||
} |
|
||||
public DependencyBuilder Deps(string[] fws, params string[] deps) |
|
||||
{ |
|
||||
foreach(var fw in fws) |
|
||||
foreach(var name in deps) |
|
||||
Add(new NuSpecDependency() { Id = name, TargetFramework = fw, Version = GetVersion(name) }); |
|
||||
return this; |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public Packages(ICakeContext context, Parameters parameters) |
|
||||
{ |
|
||||
// NUGET NUSPECS |
|
||||
context.Information("Getting git modules:"); |
|
||||
|
|
||||
var ignoredSubModulesPaths = System.IO.File.ReadAllLines(".git/config").Where(m=>m.StartsWith("[submodule ")).Select(m => |
|
||||
{ |
|
||||
var path = m.Split(' ')[1].Trim("\"[] \t".ToArray()); |
|
||||
context.Information(path); |
|
||||
return ((DirectoryPath)context.Directory(path)).FullPath; |
|
||||
}).ToList(); |
|
||||
|
|
||||
var normalizePath = new Func<string, string>( |
|
||||
path => path.Replace(System.IO.Path.DirectorySeparatorChar, System.IO.Path.AltDirectorySeparatorChar).ToUpperInvariant()); |
|
||||
|
|
||||
// Key: Package Id |
|
||||
// Value is Tuple where Item1: Package Version, Item2: The *.csproj/*.props file path. |
|
||||
var packageVersions = new Dictionary<string, IList<Tuple<string,string>>>(); |
|
||||
PackageVersions = packageVersions; |
|
||||
System.IO.Directory.EnumerateFiles(((DirectoryPath)context.Directory("./build")).FullPath, |
|
||||
"*.props", SearchOption.AllDirectories).ToList().ForEach(fileName => |
|
||||
{ |
|
||||
if (!ignoredSubModulesPaths.Any(i => normalizePath(fileName).Contains(normalizePath(i)))) |
|
||||
{ |
|
||||
var xdoc = XDocument.Load(fileName); |
|
||||
foreach (var reference in xdoc.Descendants().Where(x => x.Name.LocalName == "PackageReference")) |
|
||||
{ |
|
||||
var name = reference.Attribute("Include").Value; |
|
||||
var versionAttribute = reference.Attribute("Version"); |
|
||||
var version = versionAttribute != null |
|
||||
? versionAttribute.Value |
|
||||
: reference.Elements().First(x=>x.Name.LocalName == "Version").Value; |
|
||||
IList<Tuple<string, string>> versions; |
|
||||
packageVersions.TryGetValue(name, out versions); |
|
||||
if (versions == null) |
|
||||
{ |
|
||||
versions = new List<Tuple<string, string>>(); |
|
||||
packageVersions[name] = versions; |
|
||||
} |
|
||||
versions.Add(Tuple.Create(version, fileName)); |
|
||||
} |
|
||||
} |
|
||||
}); |
|
||||
|
|
||||
context.Information("Checking installed NuGet package dependencies versions:"); |
|
||||
|
|
||||
packageVersions.ToList().ForEach(package => |
|
||||
{ |
|
||||
var packageVersion = package.Value.First().Item1; |
|
||||
bool isValidVersion = package.Value.All(x => x.Item1 == packageVersion); |
|
||||
if (!isValidVersion) |
|
||||
{ |
|
||||
context.Information("Error: package {0} has multiple versions installed:", package.Key); |
|
||||
foreach (var v in package.Value) |
|
||||
{ |
|
||||
context.Information("{0}, file: {1}", v.Item1, v.Item2); |
|
||||
} |
|
||||
throw new Exception("Detected multiple NuGet package version installed for different projects."); |
|
||||
} |
|
||||
}); |
|
||||
|
|
||||
context.Information("Setting NuGet package dependencies versions:"); |
|
||||
|
|
||||
var SerilogVersion = packageVersions["Serilog"].FirstOrDefault().Item1; |
|
||||
var SerilogSinksDebugVersion = packageVersions["Serilog.Sinks.Debug"].FirstOrDefault().Item1; |
|
||||
var SerilogSinksTraceVersion = packageVersions["Serilog.Sinks.Trace"].FirstOrDefault().Item1; |
|
||||
var SystemReactiveVersion = packageVersions["System.Reactive"].FirstOrDefault().Item1; |
|
||||
var ReactiveUIVersion = packageVersions["reactiveui"].FirstOrDefault().Item1; |
|
||||
var SystemValueTupleVersion = packageVersions["System.ValueTuple"].FirstOrDefault().Item1; |
|
||||
SkiaSharpVersion = packageVersions["SkiaSharp"].FirstOrDefault().Item1; |
|
||||
SkiaSharpLinuxVersion = packageVersions["Avalonia.Skia.Linux.Natives"].FirstOrDefault().Item1; |
|
||||
var SharpDXVersion = packageVersions["SharpDX"].FirstOrDefault().Item1; |
|
||||
var SharpDXDirect2D1Version = packageVersions["SharpDX.Direct2D1"].FirstOrDefault().Item1; |
|
||||
var SharpDXDirect3D11Version = packageVersions["SharpDX.Direct3D11"].FirstOrDefault().Item1; |
|
||||
var SharpDXDirect3D9Version = packageVersions["SharpDX.Direct3D9"].FirstOrDefault().Item1; |
|
||||
var SharpDXDXGIVersion = packageVersions["SharpDX.DXGI"].FirstOrDefault().Item1; |
|
||||
var SystemMemoryVersion = packageVersions["System.Memory"].FirstOrDefault().Item1; |
|
||||
|
|
||||
context.Information("Package: Serilog, version: {0}", SerilogVersion); |
|
||||
context.Information("Package: System.Reactive, version: {0}", SystemReactiveVersion); |
|
||||
context.Information("Package: reactiveui, version: {0}", ReactiveUIVersion); |
|
||||
context.Information("Package: System.ValueTuple, version: {0}", SystemValueTupleVersion); |
|
||||
context.Information("Package: SkiaSharp, version: {0}", SkiaSharpVersion); |
|
||||
context.Information("Package: Avalonia.Skia.Linux.Natives, version: {0}", SkiaSharpLinuxVersion); |
|
||||
context.Information("Package: SharpDX, version: {0}", SharpDXVersion); |
|
||||
context.Information("Package: SharpDX.Direct2D1, version: {0}", SharpDXDirect2D1Version); |
|
||||
context.Information("Package: SharpDX.Direct3D11, version: {0}", SharpDXDirect3D11Version); |
|
||||
context.Information("Package: SharpDX.Direct3D9, version: {0}", SharpDXDirect3D9Version); |
|
||||
context.Information("Package: SharpDX.DXGI, version: {0}", SharpDXDXGIVersion); |
|
||||
context.Information("Package: System.Memory, version: {0}", SystemMemoryVersion); |
|
||||
|
|
||||
var nugetPackagesDir = System.Environment.GetEnvironmentVariable("NUGET_HOME") |
|
||||
?? System.IO.Path.Combine(System.Environment.GetEnvironmentVariable("USERPROFILE") ?? System.Environment.GetEnvironmentVariable("HOME"), ".nuget"); |
|
||||
|
|
||||
NugetPackagesDir = System.IO.Path.Combine(nugetPackagesDir, "packages"); |
|
||||
|
|
||||
var SetNuGetNuspecCommonProperties = new Action<NuGetPackSettings> ((nuspec) => { |
|
||||
nuspec.Version = parameters.Version; |
|
||||
nuspec.Authors = new [] { "Avalonia Team" }; |
|
||||
nuspec.Owners = new [] { "stevenk" }; |
|
||||
nuspec.LicenseUrl = new Uri("http://opensource.org/licenses/MIT"); |
|
||||
nuspec.ProjectUrl = new Uri("https://github.com/AvaloniaUI/Avalonia/"); |
|
||||
nuspec.RequireLicenseAcceptance = false; |
|
||||
nuspec.Symbols = false; |
|
||||
nuspec.NoPackageAnalysis = true; |
|
||||
nuspec.Description = "The Avalonia UI framework"; |
|
||||
nuspec.Copyright = "Copyright 2015"; |
|
||||
nuspec.Tags = new [] { "Avalonia" }; |
|
||||
}); |
|
||||
|
|
||||
var coreLibraries = new string[][] |
|
||||
{ |
|
||||
new [] { "./src/", "Avalonia.Animation"}, |
|
||||
new [] { "./src/", "Avalonia.Base"}, |
|
||||
new [] { "./src/", "Avalonia.Controls"}, |
|
||||
new [] { "./src/", "Avalonia.DesignerSupport"}, |
|
||||
new [] { "./src/", "Avalonia.Diagnostics"}, |
|
||||
new [] { "./src/", "Avalonia.Input"}, |
|
||||
new [] { "./src/", "Avalonia.Interactivity"}, |
|
||||
new [] { "./src/", "Avalonia.Layout"}, |
|
||||
new [] { "./src/", "Avalonia.Logging.Serilog"}, |
|
||||
new [] { "./src/", "Avalonia.Visuals"}, |
|
||||
new [] { "./src/", "Avalonia.Styling"}, |
|
||||
new [] { "./src/", "Avalonia.Themes.Default"}, |
|
||||
new [] { "./src/Markup/", "Avalonia.Markup"}, |
|
||||
new [] { "./src/Markup/", "Avalonia.Markup.Xaml"}, |
|
||||
}; |
|
||||
|
|
||||
var extensionsToPack = new [] {".dll", ".xml", ".pdb"}; |
|
||||
|
|
||||
var coreLibrariesFiles = coreLibraries |
|
||||
.SelectMany(lib => extensionsToPack.Select(ext => new {lib, ext})) |
|
||||
.Select((lib) => { |
|
||||
return (FilePath)context.File(lib.lib[0] + lib.lib[1] + "/bin/" + parameters.DirSuffix + "/netstandard2.0/" + lib.lib[1] + lib.ext); |
|
||||
}).ToList(); |
|
||||
|
|
||||
var coreLibrariesNuSpecContent = coreLibrariesFiles.Select((file) => { |
|
||||
return new NuSpecContent { |
|
||||
Source = file.FullPath, Target = "lib/netstandard2.0" |
|
||||
}; |
|
||||
}); |
|
||||
|
|
||||
var netFrameworkCoreLibrariesNuSpecContent = coreLibrariesFiles.Select((file) => { |
|
||||
return new NuSpecContent { |
|
||||
Source = file.FullPath, Target = "lib/net461" |
|
||||
}; |
|
||||
}); |
|
||||
|
|
||||
var netcoreappCoreLibrariesNuSpecContent = coreLibrariesFiles.Select((file) => { |
|
||||
return new NuSpecContent { |
|
||||
Source = file.FullPath, Target = "lib/netcoreapp2.0" |
|
||||
}; |
|
||||
}); |
|
||||
|
|
||||
var netFrameworkRuntimePlatform = extensionsToPack.Select(libSuffix => { |
|
||||
return new NuSpecContent { |
|
||||
Source = ((FilePath)context.File("./src/Avalonia.DotNetFrameworkRuntime/bin/" + parameters.DirSuffix + "/net461/Avalonia.DotNetFrameworkRuntime" + libSuffix)).FullPath, |
|
||||
Target = "lib/net461" |
|
||||
}; |
|
||||
}); |
|
||||
|
|
||||
var netCoreRuntimePlatform = extensionsToPack.Select(libSuffix => { |
|
||||
return new NuSpecContent { |
|
||||
Source = ((FilePath)context.File("./src/Avalonia.DotNetCoreRuntime/bin/" + parameters.DirSuffix + "/netcoreapp2.0/Avalonia.DotNetCoreRuntime" + libSuffix)).FullPath, |
|
||||
Target = "lib/netcoreapp2.0" |
|
||||
}; |
|
||||
}); |
|
||||
|
|
||||
var toolHostApp = new NuSpecContent{ |
|
||||
Source = ((FilePath)context.File("./src/tools/Avalonia.Designer.HostApp/bin/" + parameters.DirSuffix + "/netcoreapp2.0/Avalonia.Designer.HostApp.dll")).FullPath, |
|
||||
Target = "tools/netcoreapp2.0/previewer" |
|
||||
}; |
|
||||
|
|
||||
var toolHostAppNetFx = new NuSpecContent{ |
|
||||
Source = ((FilePath)context.File("./src/tools/Avalonia.Designer.HostApp.NetFx/bin/" + parameters.DirSuffix + "/net461/Avalonia.Designer.HostApp.exe")).FullPath, |
|
||||
Target = "tools/net461/previewer" |
|
||||
}; |
|
||||
|
|
||||
var toolsContent = new[] { toolHostApp, toolHostAppNetFx }; |
|
||||
var coreFiles = coreLibrariesNuSpecContent |
|
||||
.Concat(netFrameworkCoreLibrariesNuSpecContent).Concat(netFrameworkRuntimePlatform) |
|
||||
.Concat(netcoreappCoreLibrariesNuSpecContent).Concat(netCoreRuntimePlatform) |
|
||||
.Concat(toolsContent) |
|
||||
.ToList(); |
|
||||
|
|
||||
var nuspecNuGetSettingsCore = new [] |
|
||||
{ |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
// Avalonia |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
new NuGetPackSettings() |
|
||||
{ |
|
||||
Id = "Avalonia", |
|
||||
Dependencies = new DependencyBuilder(this) |
|
||||
{ |
|
||||
new NuSpecDependency() { Id = "Avalonia.Remote.Protocol", Version = parameters.Version, TargetFramework="netstandard2.0" }, |
|
||||
new NuSpecDependency() { Id = "Avalonia.Remote.Protocol", Version = parameters.Version, TargetFramework="netcoreapp2.0" }, |
|
||||
new NuSpecDependency() { Id = "Avalonia.Remote.Protocol", Version = parameters.Version, TargetFramework="net461" }, |
|
||||
new NuSpecDependency() { Id = "System.ValueTuple", Version = SystemValueTupleVersion, TargetFramework="net461" }, |
|
||||
new NuSpecDependency() { Id = "System.ComponentModel.TypeConverter", Version = "4.3.0", TargetFramework="net461" }, |
|
||||
new NuSpecDependency() { Id = "NETStandard.Library", Version = "2.0.0", TargetFramework="net461"} |
|
||||
} |
|
||||
.Deps(new string[]{"netstandard2.0", "netcoreapp2.0", "net461"}, |
|
||||
"Serilog", "Serilog.Sinks.Debug", "Serilog.Sinks.Trace", |
|
||||
"System.Memory", "System.Reactive", "System.ComponentModel.Annotations") |
|
||||
.ToArray(), |
|
||||
Files = coreFiles, |
|
||||
BasePath = context.Directory("./"), |
|
||||
OutputDirectory = parameters.NugetRoot |
|
||||
}, |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
// Avalonia.ReactiveUI |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
new NuGetPackSettings() |
|
||||
{ |
|
||||
Id = "Avalonia.ReactiveUI", |
|
||||
Dependencies = new DependencyBuilder(this) |
|
||||
{ |
|
||||
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version }, |
|
||||
}.Deps(new string[] {null}, "reactiveui"), |
|
||||
Files = new [] |
|
||||
{ |
|
||||
new NuSpecContent { Source = "Avalonia.ReactiveUI.dll", Target = "lib/netstandard2.0" } |
|
||||
}, |
|
||||
BasePath = context.Directory("./src/Avalonia.ReactiveUI/bin/" + parameters.DirSuffix + "/netstandard2.0"), |
|
||||
OutputDirectory = parameters.NugetRoot |
|
||||
}, |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
// Avalonia.Remote.Protocol |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
new NuGetPackSettings() |
|
||||
{ |
|
||||
Id = "Avalonia.Remote.Protocol", |
|
||||
Files = new [] |
|
||||
{ |
|
||||
new NuSpecContent { Source = "Avalonia.Remote.Protocol.dll", Target = "lib/netstandard2.0" } |
|
||||
}, |
|
||||
BasePath = context.Directory("./src/Avalonia.Remote.Protocol/bin/" + parameters.DirSuffix + "/netstandard2.0"), |
|
||||
OutputDirectory = parameters.NugetRoot |
|
||||
}, |
|
||||
}; |
|
||||
|
|
||||
var nuspecNuGetSettingsMobile = new [] |
|
||||
{ |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
// Avalonia.Android |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
new NuGetPackSettings() |
|
||||
{ |
|
||||
Id = "Avalonia.Android", |
|
||||
Dependencies = new [] |
|
||||
{ |
|
||||
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version }, |
|
||||
new NuSpecDependency() { Id = "Avalonia.Skia", Version = parameters.Version } |
|
||||
}, |
|
||||
Files = new [] |
|
||||
{ |
|
||||
new NuSpecContent { Source = "Avalonia.Android.dll", Target = "lib/MonoAndroid10" } |
|
||||
}, |
|
||||
BasePath = context.Directory("./src/Android/Avalonia.Android/bin/" + parameters.DirSuffix + "/monoandroid44/MonoAndroid44/"), |
|
||||
OutputDirectory = parameters.NugetRoot |
|
||||
}, |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
// Avalonia.iOS |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
new NuGetPackSettings() |
|
||||
{ |
|
||||
Id = "Avalonia.iOS", |
|
||||
Dependencies = new [] |
|
||||
{ |
|
||||
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version }, |
|
||||
new NuSpecDependency() { Id = "Avalonia.Skia", Version = parameters.Version } |
|
||||
}, |
|
||||
Files = new [] |
|
||||
{ |
|
||||
new NuSpecContent { Source = "Avalonia.iOS.dll", Target = "lib/Xamarin.iOS10" } |
|
||||
}, |
|
||||
BasePath = context.Directory("./src/iOS/Avalonia.iOS/bin/" + parameters.DirSuffix + "/xamarin.ios10/"), |
|
||||
OutputDirectory = parameters.NugetRoot |
|
||||
} |
|
||||
}; |
|
||||
|
|
||||
var nuspecNuGetSettingsDesktop = new [] |
|
||||
{ |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
// Avalonia.Win32 |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
new NuGetPackSettings() |
|
||||
{ |
|
||||
Id = "Avalonia.Win32", |
|
||||
Dependencies = new DependencyBuilder(this) |
|
||||
{ |
|
||||
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version } |
|
||||
}.Deps(new string[]{null}, "System.Drawing.Common"), |
|
||||
Files = new [] |
|
||||
{ |
|
||||
new NuSpecContent { Source = "Avalonia.Win32/bin/" + parameters.DirSuffix + "/netstandard2.0/Avalonia.Win32.dll", Target = "lib/netstandard2.0" } |
|
||||
}, |
|
||||
BasePath = context.Directory("./src/Windows"), |
|
||||
OutputDirectory = parameters.NugetRoot |
|
||||
}, |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
// Avalonia.Direct2D1 |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
new NuGetPackSettings() |
|
||||
{ |
|
||||
Id = "Avalonia.Direct2D1", |
|
||||
Dependencies = new [] |
|
||||
{ |
|
||||
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version }, |
|
||||
new NuSpecDependency() { Id = "SharpDX", Version = SharpDXVersion }, |
|
||||
new NuSpecDependency() { Id = "SharpDX.Direct2D1", Version = SharpDXDirect2D1Version }, |
|
||||
new NuSpecDependency() { Id = "SharpDX.Direct3D11", Version = SharpDXDirect3D11Version }, |
|
||||
new NuSpecDependency() { Id = "SharpDX.DXGI", Version = SharpDXDXGIVersion } |
|
||||
}, |
|
||||
Files = new [] |
|
||||
{ |
|
||||
new NuSpecContent { Source = "Avalonia.Direct2D1.dll", Target = "lib/netstandard2.0" } |
|
||||
}, |
|
||||
BasePath = context.Directory("./src/Windows/Avalonia.Direct2D1/bin/" + parameters.DirSuffix + "/netstandard2.0"), |
|
||||
OutputDirectory = parameters.NugetRoot |
|
||||
}, |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
// Avalonia.Gtk3 |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
new NuGetPackSettings() |
|
||||
{ |
|
||||
Id = "Avalonia.Gtk3", |
|
||||
Dependencies = new [] |
|
||||
{ |
|
||||
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version } |
|
||||
}, |
|
||||
Files = new [] |
|
||||
{ |
|
||||
new NuSpecContent { Source = "Avalonia.Gtk3.dll", Target = "lib/netstandard2.0" } |
|
||||
}, |
|
||||
BasePath = context.Directory("./src/Gtk/Avalonia.Gtk3/bin/" + parameters.DirSuffix + "/netstandard2.0"), |
|
||||
OutputDirectory = parameters.NugetRoot |
|
||||
}, |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
// Avalonia.Skia |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
new NuGetPackSettings() |
|
||||
{ |
|
||||
Id = "Avalonia.Skia", |
|
||||
Dependencies = new [] |
|
||||
{ |
|
||||
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version }, |
|
||||
new NuSpecDependency() { Id = "SkiaSharp", Version = SkiaSharpVersion }, |
|
||||
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version, TargetFramework="netcoreapp2.0" }, |
|
||||
new NuSpecDependency() { Id = "SkiaSharp", Version = SkiaSharpVersion, TargetFramework="netcoreapp2.0" }, |
|
||||
new NuSpecDependency() { Id = "Avalonia.Skia.Linux.Natives", Version = SkiaSharpLinuxVersion, TargetFramework="netcoreapp2.0" }, |
|
||||
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version, TargetFramework="net461" }, |
|
||||
new NuSpecDependency() { Id = "SkiaSharp", Version = SkiaSharpVersion, TargetFramework="net461" }, |
|
||||
new NuSpecDependency() { Id = "Avalonia.Skia.Linux.Natives", Version = SkiaSharpLinuxVersion, TargetFramework="net461" } |
|
||||
}, |
|
||||
Files = new [] |
|
||||
{ |
|
||||
new NuSpecContent { Source = "Avalonia.Skia.dll", Target = "lib/netstandard2.0" } |
|
||||
}, |
|
||||
BasePath = context.Directory("./src/Skia/Avalonia.Skia/bin/" + parameters.DirSuffix + "/netstandard2.0"), |
|
||||
OutputDirectory = parameters.NugetRoot |
|
||||
}, |
|
||||
new NuGetPackSettings() |
|
||||
{ |
|
||||
Id = "Avalonia.MonoMac", |
|
||||
Dependencies = new DependencyBuilder(this) |
|
||||
{ |
|
||||
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version } |
|
||||
}.Dep("MonoMac.NetStandard").ToArray(), |
|
||||
Files = new [] |
|
||||
{ |
|
||||
new NuSpecContent { Source = "netstandard2.0/Avalonia.MonoMac.dll", Target = "lib/netstandard2.0" }, |
|
||||
}, |
|
||||
BasePath = context.Directory("./src/OSX/Avalonia.MonoMac/bin/" + parameters.DirSuffix), |
|
||||
OutputDirectory = parameters.NugetRoot |
|
||||
}, |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
// Avalonia.Desktop |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
new NuGetPackSettings() |
|
||||
{ |
|
||||
Id = "Avalonia.Desktop", |
|
||||
Dependencies = new [] |
|
||||
{ |
|
||||
new NuSpecDependency() { Id = "Avalonia.Direct2D1", Version = parameters.Version }, |
|
||||
new NuSpecDependency() { Id = "Avalonia.Win32", Version = parameters.Version }, |
|
||||
new NuSpecDependency() { Id = "Avalonia.Skia", Version = parameters.Version }, |
|
||||
new NuSpecDependency() { Id = "Avalonia.Gtk3", Version = parameters.Version }, |
|
||||
new NuSpecDependency() { Id = "Avalonia.MonoMac", Version = parameters.Version } |
|
||||
}, |
|
||||
Files = new NuSpecContent[] |
|
||||
{ |
|
||||
new NuSpecContent { Source = "licence.md", Target = "" } |
|
||||
}, |
|
||||
BasePath = context.Directory("./"), |
|
||||
OutputDirectory = parameters.NugetRoot |
|
||||
}, |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
// Avalonia.LinuxFramebuffer |
|
||||
/////////////////////////////////////////////////////////////////////////////// |
|
||||
new NuGetPackSettings() |
|
||||
{ |
|
||||
Id = "Avalonia.LinuxFramebuffer", |
|
||||
Dependencies = new [] |
|
||||
{ |
|
||||
new NuSpecDependency() { Id = "Avalonia", Version = parameters.Version }, |
|
||||
new NuSpecDependency() { Id = "Avalonia.Skia", Version = parameters.Version } |
|
||||
}, |
|
||||
Files = new [] |
|
||||
{ |
|
||||
new NuSpecContent { Source = "Avalonia.LinuxFramebuffer/bin/" + parameters.DirSuffix + "/netstandard2.0/Avalonia.LinuxFramebuffer.dll", Target = "lib/netstandard2.0" } |
|
||||
}, |
|
||||
BasePath = context.Directory("./src/Linux/"), |
|
||||
OutputDirectory = parameters.NugetRoot |
|
||||
} |
|
||||
}; |
|
||||
|
|
||||
var nuspecNuGetSettingInterop = new NuGetPackSettings() |
|
||||
{ |
|
||||
Id = "Avalonia.Win32.Interoperability", |
|
||||
Dependencies = new [] |
|
||||
{ |
|
||||
new NuSpecDependency() { Id = "Avalonia.Win32", Version = parameters.Version }, |
|
||||
new NuSpecDependency() { Id = "Avalonia.Direct2D1", Version = parameters.Version }, |
|
||||
new NuSpecDependency() { Id = "SharpDX.Direct3D9", Version = SharpDXDirect3D9Version }, |
|
||||
}, |
|
||||
Files = new [] |
|
||||
{ |
|
||||
new NuSpecContent { Source = "Avalonia.Win32.Interop/bin/" + parameters.DirSuffix + "/net461/Avalonia.Win32.Interop.dll", Target = "lib/net461" } |
|
||||
}, |
|
||||
BasePath = context.Directory("./src/Windows"), |
|
||||
OutputDirectory = parameters.NugetRoot |
|
||||
}; |
|
||||
|
|
||||
NuspecNuGetSettings = new List<NuGetPackSettings>(); |
|
||||
|
|
||||
NuspecNuGetSettings.AddRange(nuspecNuGetSettingsCore); |
|
||||
NuspecNuGetSettings.AddRange(nuspecNuGetSettingsDesktop); |
|
||||
|
|
||||
if (parameters.IsRunningOnWindows) { |
|
||||
NuspecNuGetSettings.Add(nuspecNuGetSettingInterop); |
|
||||
NuspecNuGetSettings.AddRange(nuspecNuGetSettingsMobile); |
|
||||
} |
|
||||
|
|
||||
NuspecNuGetSettings.ForEach((nuspec) => SetNuGetNuspecCommonProperties(nuspec)); |
|
||||
|
|
||||
NugetPackages = NuspecNuGetSettings.Select(nuspec => { |
|
||||
return nuspec.OutputDirectory.CombineWithFilePath(string.Concat(nuspec.Id, ".", nuspec.Version, ".nupkg")); |
|
||||
}).ToArray(); |
|
||||
|
|
||||
BinFiles = NuspecNuGetSettings.SelectMany(nuspec => { |
|
||||
return nuspec.Files.Select(file => { |
|
||||
return ((DirectoryPath)nuspec.BasePath).CombineWithFilePath(file.Source); |
|
||||
}); |
|
||||
}).GroupBy(f => f.FullPath).Select(g => g.First()).ToArray(); |
|
||||
} |
|
||||
} |
|
||||
@ -0,0 +1,41 @@ |
|||||
|
<Project Sdk="AggregatePackage.NuGet.Sdk"> |
||||
|
<PropertyGroup> |
||||
|
<TargetFrameworks>netstandard2.0;net461;netcoreapp2.0</TargetFrameworks> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<ProjectReference Include="../../src/Avalonia.Remote.Protocol/Avalonia.Remote.Protocol.csproj" EmbedReference="false" /> |
||||
|
</ItemGroup> |
||||
|
|
||||
|
<PropertyGroup> |
||||
|
<DesignerHostAppPath>../../src/tools</DesignerHostAppPath> |
||||
|
</PropertyGroup> |
||||
|
|
||||
|
<Target Name="AddDesignerHostAppsToPackage" BeforeTargets="GenerateNuspec"> |
||||
|
<MSBuild Projects="$(DesignerHostAppPath)/Avalonia.Designer.HostApp/Avalonia.Designer.HostApp.csproj" |
||||
|
Properties="Configuration=$(Configuration); |
||||
|
Platform=$(Platform)" /> |
||||
|
|
||||
|
<ItemGroup> |
||||
|
<_PackageFiles Include="$(DesignerHostAppPath)/Avalonia.Designer.HostApp/bin/$(Configuration)/netcoreapp2.0/Avalonia.Designer.HostApp.dll"> |
||||
|
<PackagePath>tools/netcoreapp2.0/designer</PackagePath> |
||||
|
<Visible>false</Visible> |
||||
|
<BuildAction>None</BuildAction> |
||||
|
</_PackageFiles> |
||||
|
<_PackageFiles Include="$(DesignerHostAppPath)/Avalonia.Designer.HostApp/bin/$(Configuration)/net461/Avalonia.Designer.HostApp.exe"> |
||||
|
<PackagePath>tools/net461/designer</PackagePath> |
||||
|
<Visible>false</Visible> |
||||
|
<BuildAction>None</BuildAction> |
||||
|
</_PackageFiles> |
||||
|
<_PackageFiles Include="Avalonia.props"> |
||||
|
<PackagePath>build/Avalonia.props</PackagePath> |
||||
|
<Visible>false</Visible> |
||||
|
<BuildAction>None</BuildAction> |
||||
|
</_PackageFiles> |
||||
|
</ItemGroup> |
||||
|
</Target> |
||||
|
|
||||
|
<Import Project="..\..\build\SharedVersion.props" /> |
||||
|
<Import Project="..\..\build\NetFX.props" /> |
||||
|
<Import Project="..\..\build\CoreLibraries.props" /> |
||||
|
</Project> |
||||
@ -0,0 +1,6 @@ |
|||||
|
<Project DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> |
||||
|
<PropertyGroup> |
||||
|
<AvaloniaPreviewerNetCoreToolPath>$(MSBuildThisFileDirectory)\..\tools\netcoreapp2.0\designer\Avalonia.Designer.HostApp.dll</AvaloniaPreviewerNetCoreToolPath> |
||||
|
<AvaloniaPreviewerNetFullToolPath>$(MSBuildThisFileDirectory)\..\tools\net461\designer\Avalonia.Designer.HostApp.exe</AvaloniaPreviewerNetFullToolPath> |
||||
|
</PropertyGroup> |
||||
|
</Project> |
||||
@ -1,22 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<configuration> |
|
||||
<startup> |
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/> |
|
||||
</startup> |
|
||||
<runtime> |
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="SharpDX" publicKeyToken="b4dcf0f35e5521f1" culture="neutral"/> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.1.1.0" newVersion="3.1.1.0"/> |
|
||||
</dependentAssembly> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="SharpDX.DXGI" publicKeyToken="b4dcf0f35e5521f1" culture="neutral"/> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.1.1.0" newVersion="3.1.1.0"/> |
|
||||
</dependentAssembly> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="Mono.Cairo" publicKeyToken="0738eb9f132ed756" culture="neutral"/> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/> |
|
||||
</dependentAssembly> |
|
||||
</assemblyBinding> |
|
||||
</runtime> |
|
||||
</configuration> |
|
||||
@ -1,22 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<configuration> |
|
||||
<startup> |
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/> |
|
||||
</startup> |
|
||||
<runtime> |
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="Mono.Cairo" publicKeyToken="0738eb9f132ed756" culture="neutral"/> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/> |
|
||||
</dependentAssembly> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="SharpDX" publicKeyToken="b4dcf0f35e5521f1" culture="neutral"/> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.1.1.0" newVersion="3.1.1.0"/> |
|
||||
</dependentAssembly> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="SharpDX.DXGI" publicKeyToken="b4dcf0f35e5521f1" culture="neutral"/> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.1.1.0" newVersion="3.1.1.0"/> |
|
||||
</dependentAssembly> |
|
||||
</assemblyBinding> |
|
||||
</runtime> |
|
||||
</configuration> |
|
||||
@ -1,22 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<configuration> |
|
||||
<startup> |
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" /> |
|
||||
</startup> |
|
||||
<runtime> |
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="Mono.Cairo" publicKeyToken="0738eb9f132ed756" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0" /> |
|
||||
</dependentAssembly> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="SharpDX" publicKeyToken="b4dcf0f35e5521f1" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.2.0" newVersion="3.0.2.0" /> |
|
||||
</dependentAssembly> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="SharpDX.DXGI" publicKeyToken="b4dcf0f35e5521f1" culture="neutral" /> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.0.2.0" newVersion="3.0.2.0" /> |
|
||||
</dependentAssembly> |
|
||||
</assemblyBinding> |
|
||||
</runtime> |
|
||||
</configuration> |
|
||||
@ -1,3 +1,6 @@ |
|||||
<Project> |
<Project> |
||||
|
<PropertyGroup> |
||||
|
<IsPackable>false</IsPackable> |
||||
|
</PropertyGroup> |
||||
<Import Project="..\build\SharedVersion.props" /> |
<Import Project="..\build\SharedVersion.props" /> |
||||
</Project> |
</Project> |
||||
|
|||||
@ -1,22 +0,0 @@ |
|||||
<?xml version="1.0" encoding="utf-8"?> |
|
||||
<configuration> |
|
||||
<startup> |
|
||||
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/> |
|
||||
</startup> |
|
||||
<runtime> |
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="Mono.Cairo" publicKeyToken="0738eb9f132ed756" culture="neutral"/> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-4.0.0.0" newVersion="4.0.0.0"/> |
|
||||
</dependentAssembly> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="SharpDX" publicKeyToken="b4dcf0f35e5521f1" culture="neutral"/> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.1.1.0" newVersion="3.1.1.0"/> |
|
||||
</dependentAssembly> |
|
||||
<dependentAssembly> |
|
||||
<assemblyIdentity name="SharpDX.DXGI" publicKeyToken="b4dcf0f35e5521f1" culture="neutral"/> |
|
||||
<bindingRedirect oldVersion="0.0.0.0-3.1.1.0" newVersion="3.1.1.0"/> |
|
||||
</dependentAssembly> |
|
||||
</assemblyBinding> |
|
||||
</runtime> |
|
||||
</configuration> |
|
||||
@ -0,0 +1,213 @@ |
|||||
|
using System; |
||||
|
using System.Linq; |
||||
|
using System.Reactive.Linq; |
||||
|
using Avalonia.Animation.Utils; |
||||
|
using Avalonia.Data; |
||||
|
using Avalonia.Reactive; |
||||
|
|
||||
|
namespace Avalonia.Animation |
||||
|
{ |
||||
|
/// <summary>
|
||||
|
/// Handles interpolation and time-related functions
|
||||
|
/// for keyframe animations.
|
||||
|
/// </summary>
|
||||
|
internal class AnimationInstance<T> : SingleSubscriberObservableBase<T> |
||||
|
{ |
||||
|
private T _lastInterpValue; |
||||
|
private T _firstKFValue; |
||||
|
private long _repeatCount; |
||||
|
private double _currentIteration; |
||||
|
private bool _isLooping; |
||||
|
private bool _gotFirstKFValue; |
||||
|
private bool _iterationDelay; |
||||
|
private FillMode _fillMode; |
||||
|
private PlaybackDirection _animationDirection; |
||||
|
private Animator<T> _parent; |
||||
|
private Animatable _targetControl; |
||||
|
private T _neutralValue; |
||||
|
private double _speedRatio; |
||||
|
private TimeSpan _delay; |
||||
|
private TimeSpan _duration; |
||||
|
private Easings.Easing _easeFunc; |
||||
|
private Action _onCompleteAction; |
||||
|
private Func<double, T, T> _interpolator; |
||||
|
private IDisposable _timerSubscription; |
||||
|
private readonly IClock _baseClock; |
||||
|
private IClock _clock; |
||||
|
|
||||
|
public AnimationInstance(Animation animation, Animatable control, Animator<T> animator, IClock baseClock, Action OnComplete, Func<double, T, T> Interpolator) |
||||
|
{ |
||||
|
if (animation.SpeedRatio <= 0) |
||||
|
throw new InvalidOperationException("Speed ratio cannot be negative or zero."); |
||||
|
|
||||
|
if (animation.Duration.TotalSeconds <= 0) |
||||
|
throw new InvalidOperationException("Duration cannot be negative or zero."); |
||||
|
|
||||
|
_parent = animator; |
||||
|
_easeFunc = animation.Easing; |
||||
|
_targetControl = control; |
||||
|
_neutralValue = (T)_targetControl.GetValue(_parent.Property); |
||||
|
|
||||
|
_speedRatio = animation.SpeedRatio; |
||||
|
|
||||
|
_delay = animation.Delay; |
||||
|
_duration = animation.Duration; |
||||
|
_iterationDelay = animation.DelayBetweenIterations; |
||||
|
|
||||
|
switch (animation.RepeatCount.RepeatType) |
||||
|
{ |
||||
|
case RepeatType.None: |
||||
|
_repeatCount = 1; |
||||
|
break; |
||||
|
case RepeatType.Loop: |
||||
|
_isLooping = true; |
||||
|
break; |
||||
|
case RepeatType.Repeat: |
||||
|
_repeatCount = (long)animation.RepeatCount.Value; |
||||
|
break; |
||||
|
} |
||||
|
|
||||
|
_animationDirection = animation.PlaybackDirection; |
||||
|
_fillMode = animation.FillMode; |
||||
|
_onCompleteAction = OnComplete; |
||||
|
_interpolator = Interpolator; |
||||
|
_baseClock = baseClock; |
||||
|
} |
||||
|
|
||||
|
protected override void Unsubscribed() |
||||
|
{ |
||||
|
//Animation may have been stopped before it has finished
|
||||
|
ApplyFinalFill(); |
||||
|
|
||||
|
_timerSubscription?.Dispose(); |
||||
|
_clock.PlayState = PlayState.Stop; |
||||
|
} |
||||
|
|
||||
|
protected override void Subscribed() |
||||
|
{ |
||||
|
_clock = new Clock(_baseClock); |
||||
|
_timerSubscription = _clock.Subscribe(Step); |
||||
|
} |
||||
|
|
||||
|
public void Step(TimeSpan frameTick) |
||||
|
{ |
||||
|
try |
||||
|
{ |
||||
|
InternalStep(frameTick); |
||||
|
} |
||||
|
catch (Exception e) |
||||
|
{ |
||||
|
PublishError(e); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void ApplyFinalFill() |
||||
|
{ |
||||
|
if (_fillMode == FillMode.Forward || _fillMode == FillMode.Both) |
||||
|
_targetControl.SetValue(_parent.Property, _lastInterpValue, BindingPriority.LocalValue); |
||||
|
} |
||||
|
|
||||
|
private void DoComplete() |
||||
|
{ |
||||
|
ApplyFinalFill(); |
||||
|
_onCompleteAction?.Invoke(); |
||||
|
PublishCompleted(); |
||||
|
} |
||||
|
|
||||
|
private void DoDelay() |
||||
|
{ |
||||
|
if (_fillMode == FillMode.Backward || _fillMode == FillMode.Both) |
||||
|
if (_currentIteration == 0) |
||||
|
PublishNext(_firstKFValue); |
||||
|
else |
||||
|
PublishNext(_lastInterpValue); |
||||
|
} |
||||
|
|
||||
|
private void DoPlayStates() |
||||
|
{ |
||||
|
if (_clock.PlayState == PlayState.Stop || _baseClock.PlayState == PlayState.Stop) |
||||
|
DoComplete(); |
||||
|
|
||||
|
if (!_gotFirstKFValue) |
||||
|
{ |
||||
|
_firstKFValue = (T)_parent.First().Value; |
||||
|
_gotFirstKFValue = true; |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
private void InternalStep(TimeSpan time) |
||||
|
{ |
||||
|
DoPlayStates(); |
||||
|
var delayEndpoint = _delay; |
||||
|
var iterationEndpoint = delayEndpoint + _duration; |
||||
|
var iterationTime = time; |
||||
|
|
||||
|
//determine if time is currently in the first iteration.
|
||||
|
if (time >= TimeSpan.Zero & time <= iterationEndpoint) |
||||
|
{ |
||||
|
_currentIteration = 1; |
||||
|
} |
||||
|
else if (time > iterationEndpoint) |
||||
|
{ |
||||
|
//Subtract first iteration to properly get the subsequent iteration time
|
||||
|
iterationTime -= iterationEndpoint; |
||||
|
|
||||
|
if (!_iterationDelay & delayEndpoint > TimeSpan.Zero) |
||||
|
{ |
||||
|
delayEndpoint = TimeSpan.Zero; |
||||
|
iterationEndpoint = _duration; |
||||
|
} |
||||
|
|
||||
|
//Calculate the current iteration number
|
||||
|
_currentIteration = Math.Min(_repeatCount,(int)Math.Floor((double)((double)iterationTime.Ticks / iterationEndpoint.Ticks)) + 2); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
return; |
||||
|
} |
||||
|
|
||||
|
// Determine if the current iteration should have its normalized time inverted.
|
||||
|
bool isCurIterReverse = _animationDirection == PlaybackDirection.Normal ? false : |
||||
|
_animationDirection == PlaybackDirection.Alternate ? (_currentIteration % 2 == 0) ? false : true : |
||||
|
_animationDirection == PlaybackDirection.AlternateReverse ? (_currentIteration % 2 == 0) ? true : false : |
||||
|
_animationDirection == PlaybackDirection.Reverse ? true : false; |
||||
|
|
||||
|
if (!_isLooping) |
||||
|
{ |
||||
|
var totalTime = _iterationDelay ? _repeatCount * ( _duration.Ticks + _delay.Ticks) : _repeatCount * _duration.Ticks + _delay.Ticks; |
||||
|
if (time.Ticks >= totalTime) |
||||
|
{ |
||||
|
var easedTime = _easeFunc.Ease(isCurIterReverse ? 0.0 : 1.0); |
||||
|
_lastInterpValue = _interpolator(easedTime, _neutralValue); |
||||
|
|
||||
|
DoComplete(); |
||||
|
return; |
||||
|
} |
||||
|
} |
||||
|
iterationTime = TimeSpan.FromTicks((long)(iterationTime.Ticks % iterationEndpoint.Ticks)); |
||||
|
|
||||
|
if (delayEndpoint > TimeSpan.Zero & iterationTime < delayEndpoint) |
||||
|
{ |
||||
|
DoDelay(); |
||||
|
} |
||||
|
else |
||||
|
{ |
||||
|
// Offset the delay time
|
||||
|
iterationTime -= delayEndpoint; |
||||
|
iterationEndpoint -= delayEndpoint; |
||||
|
|
||||
|
// Normalize time
|
||||
|
var interpVal = (double)iterationTime.Ticks / iterationEndpoint.Ticks; |
||||
|
|
||||
|
if (isCurIterReverse) |
||||
|
interpVal = 1 - interpVal; |
||||
|
|
||||
|
// Ease and interpolate
|
||||
|
var easedTime = _easeFunc.Ease(interpVal); |
||||
|
_lastInterpValue = _interpolator(easedTime, _neutralValue); |
||||
|
|
||||
|
PublishNext(_lastInterpValue); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
|
} |
||||
@ -1,273 +0,0 @@ |
|||||
using System; |
|
||||
using System.Linq; |
|
||||
using Avalonia.Data; |
|
||||
|
|
||||
namespace Avalonia.Animation |
|
||||
{ |
|
||||
/// <summary>
|
|
||||
/// Provides statefulness for an iteration of a keyframe animation.
|
|
||||
/// </summary>
|
|
||||
internal class AnimatorStateMachine<T> : IObservable<object>, IDisposable |
|
||||
{ |
|
||||
object _lastInterpValue; |
|
||||
object _firstKFValue; |
|
||||
|
|
||||
private ulong _delayTotalFrameCount; |
|
||||
private ulong _durationTotalFrameCount; |
|
||||
private ulong _delayFrameCount; |
|
||||
private ulong _durationFrameCount; |
|
||||
private ulong _repeatCount; |
|
||||
private ulong _currentIteration; |
|
||||
|
|
||||
private bool _isLooping; |
|
||||
private bool _isRepeating; |
|
||||
private bool _isReversed; |
|
||||
private bool _checkLoopAndRepeat; |
|
||||
private bool _gotFirstKFValue; |
|
||||
|
|
||||
private FillMode _fillMode; |
|
||||
private PlaybackDirection _animationDirection; |
|
||||
private KeyFramesStates _currentState; |
|
||||
private KeyFramesStates _savedState; |
|
||||
private Animator<T> _parent; |
|
||||
private Animation _targetAnimation; |
|
||||
private Animatable _targetControl; |
|
||||
private T _neutralValue; |
|
||||
internal bool _unsubscribe = false; |
|
||||
private IObserver<object> _targetObserver; |
|
||||
private readonly Action _onComplete; |
|
||||
|
|
||||
[Flags] |
|
||||
private enum KeyFramesStates |
|
||||
{ |
|
||||
Initialize, |
|
||||
DoDelay, |
|
||||
DoRun, |
|
||||
RunForwards, |
|
||||
RunBackwards, |
|
||||
RunApplyValue, |
|
||||
RunComplete, |
|
||||
Pause, |
|
||||
Stop, |
|
||||
Disposed |
|
||||
} |
|
||||
|
|
||||
public AnimatorStateMachine(Animation animation, Animatable control, Animator<T> animator, Action onComplete) |
|
||||
{ |
|
||||
_parent = animator; |
|
||||
_targetAnimation = animation; |
|
||||
_targetControl = control; |
|
||||
_neutralValue = (T)_targetControl.GetValue(_parent.Property); |
|
||||
|
|
||||
_delayTotalFrameCount = (ulong)(animation.Delay.Ticks / Timing.FrameTick.Ticks); |
|
||||
_durationTotalFrameCount = (ulong)(animation.Duration.Ticks / Timing.FrameTick.Ticks); |
|
||||
|
|
||||
switch (animation.RepeatCount.RepeatType) |
|
||||
{ |
|
||||
case RepeatType.Loop: |
|
||||
_isLooping = true; |
|
||||
_checkLoopAndRepeat = true; |
|
||||
break; |
|
||||
case RepeatType.Repeat: |
|
||||
_isRepeating = true; |
|
||||
_checkLoopAndRepeat = true; |
|
||||
_repeatCount = animation.RepeatCount.Value; |
|
||||
break; |
|
||||
} |
|
||||
|
|
||||
_isReversed = (animation.PlaybackDirection & PlaybackDirection.Reverse) != 0; |
|
||||
_animationDirection = _targetAnimation.PlaybackDirection; |
|
||||
_fillMode = _targetAnimation.FillMode; |
|
||||
|
|
||||
if (_durationTotalFrameCount > 0) |
|
||||
_currentState = KeyFramesStates.DoDelay; |
|
||||
else |
|
||||
_currentState = KeyFramesStates.DoRun; |
|
||||
_onComplete = onComplete; |
|
||||
} |
|
||||
|
|
||||
public void Step(PlayState _playState, Func<double, T, T> Interpolator) |
|
||||
{ |
|
||||
try |
|
||||
{ |
|
||||
InternalStep(_playState, Interpolator); |
|
||||
} |
|
||||
catch (Exception e) |
|
||||
{ |
|
||||
_targetObserver?.OnError(e); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
private void InternalStep(PlayState _playState, Func<double, T, T> Interpolator) |
|
||||
{ |
|
||||
if (!_gotFirstKFValue) |
|
||||
{ |
|
||||
_firstKFValue = _parent.First().Value; |
|
||||
_gotFirstKFValue = true; |
|
||||
} |
|
||||
|
|
||||
if (_currentState == KeyFramesStates.Disposed) |
|
||||
throw new InvalidProgramException("This KeyFrames Animation is already disposed."); |
|
||||
|
|
||||
if (_playState == PlayState.Stop) |
|
||||
_currentState = KeyFramesStates.Stop; |
|
||||
|
|
||||
// Save state and pause the machine
|
|
||||
if (_playState == PlayState.Pause && _currentState != KeyFramesStates.Pause) |
|
||||
{ |
|
||||
_savedState = _currentState; |
|
||||
_currentState = KeyFramesStates.Pause; |
|
||||
} |
|
||||
|
|
||||
// Resume the previous state
|
|
||||
if (_playState != PlayState.Pause && _currentState == KeyFramesStates.Pause) |
|
||||
_currentState = _savedState; |
|
||||
|
|
||||
double _tempDuration = 0d, _easedTime; |
|
||||
|
|
||||
bool handled = false; |
|
||||
|
|
||||
while (!handled) |
|
||||
{ |
|
||||
switch (_currentState) |
|
||||
{ |
|
||||
case KeyFramesStates.DoDelay: |
|
||||
|
|
||||
if (_fillMode == FillMode.Backward |
|
||||
|| _fillMode == FillMode.Both) |
|
||||
{ |
|
||||
if (_currentIteration == 0) |
|
||||
{ |
|
||||
_targetObserver.OnNext(_firstKFValue); |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
_targetObserver.OnNext(_lastInterpValue); |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
if (_delayFrameCount > _delayTotalFrameCount) |
|
||||
{ |
|
||||
_currentState = KeyFramesStates.DoRun; |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
handled = true; |
|
||||
_delayFrameCount++; |
|
||||
} |
|
||||
break; |
|
||||
|
|
||||
case KeyFramesStates.DoRun: |
|
||||
|
|
||||
if (_isReversed) |
|
||||
_currentState = KeyFramesStates.RunBackwards; |
|
||||
else |
|
||||
_currentState = KeyFramesStates.RunForwards; |
|
||||
|
|
||||
break; |
|
||||
|
|
||||
case KeyFramesStates.RunForwards: |
|
||||
|
|
||||
if (_durationFrameCount > _durationTotalFrameCount) |
|
||||
{ |
|
||||
_currentState = KeyFramesStates.RunComplete; |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
_tempDuration = (double)_durationFrameCount / _durationTotalFrameCount; |
|
||||
_currentState = KeyFramesStates.RunApplyValue; |
|
||||
|
|
||||
} |
|
||||
break; |
|
||||
|
|
||||
case KeyFramesStates.RunBackwards: |
|
||||
|
|
||||
if (_durationFrameCount > _durationTotalFrameCount) |
|
||||
{ |
|
||||
_currentState = KeyFramesStates.RunComplete; |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
_tempDuration = (double)(_durationTotalFrameCount - _durationFrameCount) / _durationTotalFrameCount; |
|
||||
_currentState = KeyFramesStates.RunApplyValue; |
|
||||
} |
|
||||
break; |
|
||||
|
|
||||
case KeyFramesStates.RunApplyValue: |
|
||||
|
|
||||
_easedTime = _targetAnimation.Easing.Ease(_tempDuration); |
|
||||
|
|
||||
_durationFrameCount++; |
|
||||
_lastInterpValue = Interpolator(_easedTime, _neutralValue); |
|
||||
_targetObserver.OnNext(_lastInterpValue); |
|
||||
_currentState = KeyFramesStates.DoRun; |
|
||||
handled = true; |
|
||||
break; |
|
||||
|
|
||||
case KeyFramesStates.RunComplete: |
|
||||
|
|
||||
if (_checkLoopAndRepeat) |
|
||||
{ |
|
||||
_delayFrameCount = 0; |
|
||||
_durationFrameCount = 0; |
|
||||
|
|
||||
if (_isLooping) |
|
||||
{ |
|
||||
_currentState = KeyFramesStates.DoRun; |
|
||||
} |
|
||||
else if (_isRepeating) |
|
||||
{ |
|
||||
if (_currentIteration >= _repeatCount) |
|
||||
{ |
|
||||
_currentState = KeyFramesStates.Stop; |
|
||||
} |
|
||||
else |
|
||||
{ |
|
||||
_currentState = KeyFramesStates.DoRun; |
|
||||
} |
|
||||
_currentIteration++; |
|
||||
} |
|
||||
|
|
||||
if (_animationDirection == PlaybackDirection.Alternate |
|
||||
|| _animationDirection == PlaybackDirection.AlternateReverse) |
|
||||
_isReversed = !_isReversed; |
|
||||
|
|
||||
break; |
|
||||
} |
|
||||
|
|
||||
_currentState = KeyFramesStates.Stop; |
|
||||
break; |
|
||||
|
|
||||
case KeyFramesStates.Stop: |
|
||||
|
|
||||
if (_fillMode == FillMode.Forward |
|
||||
|| _fillMode == FillMode.Both) |
|
||||
{ |
|
||||
_targetControl.SetValue(_parent.Property, _lastInterpValue, BindingPriority.LocalValue); |
|
||||
} |
|
||||
|
|
||||
_targetObserver.OnCompleted(); |
|
||||
_onComplete?.Invoke(); |
|
||||
Dispose(); |
|
||||
handled = true; |
|
||||
break; |
|
||||
default: |
|
||||
handled = true; |
|
||||
break; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
|
|
||||
public IDisposable Subscribe(IObserver<object> observer) |
|
||||
{ |
|
||||
_targetObserver = observer; |
|
||||
return this; |
|
||||
} |
|
||||
|
|
||||
public void Dispose() |
|
||||
{ |
|
||||
_unsubscribe = true; |
|
||||
_currentState = KeyFramesStates.Disposed; |
|
||||
} |
|
||||
} |
|
||||
} |
|
||||
@ -1,9 +1,10 @@ |
|||||
<Project Sdk="Microsoft.NET.Sdk"> |
<Project Sdk="Microsoft.NET.Sdk"> |
||||
<PropertyGroup> |
<PropertyGroup> |
||||
<TargetFramework>netstandard2.0</TargetFramework> |
<TargetFramework>netstandard2.0</TargetFramework> |
||||
|
<IsPackable>false</IsPackable> |
||||
</PropertyGroup> |
</PropertyGroup> |
||||
<ItemGroup> |
<ItemGroup> |
||||
<ProjectReference Include="..\Avalonia.Base\Avalonia.Base.csproj" /> |
<ProjectReference Include="..\Avalonia.Base\Avalonia.Base.csproj" /> |
||||
</ItemGroup> |
</ItemGroup> |
||||
<Import Project="..\..\build\Rx.props" /> |
<Import Project="..\..\build\Rx.props" /> |
||||
</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; |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Some files were not shown because too many files changed in this diff
Loading…
Reference in new issue