Added basic Mac sample
|
@ -0,0 +1,19 @@
|
|||
using AppKit;
|
||||
using Foundation;
|
||||
|
||||
namespace BasicSkiaSharp
|
||||
{
|
||||
[Register("AppDelegate")]
|
||||
public class AppDelegate : NSApplicationDelegate
|
||||
{
|
||||
MainWindowController mainWindowController;
|
||||
|
||||
public override void DidFinishLaunching(NSNotification notification)
|
||||
{
|
||||
mainWindowController = new MainWindowController();
|
||||
mainWindowController.Window.MakeKeyAndOrderFront(this);
|
||||
}
|
||||
|
||||
public override bool ApplicationShouldTerminateAfterLastWindowClosed(NSApplication sender) => true;
|
||||
}
|
||||
}
|
Двоичные данные
samples/BasicSamples/BasicSkiaSharp-Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-128.png
Normal file
После Ширина: | Высота: | Размер: 7.9 KiB |
Двоичные данные
samples/BasicSamples/BasicSkiaSharp-Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-128@2x.png
Normal file
После Ширина: | Высота: | Размер: 20 KiB |
Двоичные данные
samples/BasicSamples/BasicSkiaSharp-Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-16.png
Normal file
После Ширина: | Высота: | Размер: 711 B |
Двоичные данные
samples/BasicSamples/BasicSkiaSharp-Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-16@2x.png
Normal file
После Ширина: | Высота: | Размер: 1.4 KiB |
Двоичные данные
samples/BasicSamples/BasicSkiaSharp-Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-256.png
Normal file
После Ширина: | Высота: | Размер: 20 KiB |
Двоичные данные
samples/BasicSamples/BasicSkiaSharp-Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-256@2x.png
Normal file
После Ширина: | Высота: | Размер: 58 KiB |
Двоичные данные
samples/BasicSamples/BasicSkiaSharp-Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-32.png
Normal file
После Ширина: | Высота: | Размер: 1.4 KiB |
Двоичные данные
samples/BasicSamples/BasicSkiaSharp-Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-32@2x.png
Normal file
После Ширина: | Высота: | Размер: 3.3 KiB |
Двоичные данные
samples/BasicSamples/BasicSkiaSharp-Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-512.png
Normal file
После Ширина: | Высота: | Размер: 58 KiB |
Двоичные данные
samples/BasicSamples/BasicSkiaSharp-Mac/Assets.xcassets/AppIcon.appiconset/AppIcon-512@2x.png
Normal file
После Ширина: | Высота: | Размер: 174 KiB |
|
@ -0,0 +1,68 @@
|
|||
{
|
||||
"images": [
|
||||
{
|
||||
"filename": "AppIcon-16.png",
|
||||
"size": "16x16",
|
||||
"scale": "1x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"filename": "AppIcon-16@2x.png",
|
||||
"size": "16x16",
|
||||
"scale": "2x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"filename": "AppIcon-32.png",
|
||||
"size": "32x32",
|
||||
"scale": "1x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"filename": "AppIcon-32@2x.png",
|
||||
"size": "32x32",
|
||||
"scale": "2x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"filename": "AppIcon-128.png",
|
||||
"size": "128x128",
|
||||
"scale": "1x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"filename": "AppIcon-128@2x.png",
|
||||
"size": "128x128",
|
||||
"scale": "2x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"filename": "AppIcon-256.png",
|
||||
"size": "256x256",
|
||||
"scale": "1x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"filename": "AppIcon-256@2x.png",
|
||||
"size": "256x256",
|
||||
"scale": "2x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"filename": "AppIcon-512.png",
|
||||
"size": "512x512",
|
||||
"scale": "1x",
|
||||
"idiom": "mac"
|
||||
},
|
||||
{
|
||||
"filename": "AppIcon-512@2x.png",
|
||||
"size": "512x512",
|
||||
"scale": "2x",
|
||||
"idiom": "mac"
|
||||
}
|
||||
],
|
||||
"info": {
|
||||
"version": 1,
|
||||
"author": "xcode"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
|
@ -0,0 +1,99 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup>
|
||||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
|
||||
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
|
||||
<ProjectGuid>{9DBE1586-4312-4BAE-83F4-28AD9947369F}</ProjectGuid>
|
||||
<ProjectTypeGuids>{A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>BasicSkiaSharp</RootNamespace>
|
||||
<AssemblyName>BasicSkiaSharp</AssemblyName>
|
||||
<TargetFrameworkVersion>v2.0</TargetFrameworkVersion>
|
||||
<TargetFrameworkIdentifier>Xamarin.Mac</TargetFrameworkIdentifier>
|
||||
<MonoMacResourcePrefix>Resources</MonoMacResourcePrefix>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x86' ">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<DebugType>full</DebugType>
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\Debug</OutputPath>
|
||||
<DefineConstants>DEBUG;</DefineConstants>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<EnableCodeSigning>false</EnableCodeSigning>
|
||||
<CodeSigningKey>Mac Developer</CodeSigningKey>
|
||||
<CreatePackage>false</CreatePackage>
|
||||
<EnablePackageSigning>false</EnablePackageSigning>
|
||||
<IncludeMonoRuntime>false</IncludeMonoRuntime>
|
||||
<UseSGen>true</UseSGen>
|
||||
<UseRefCounting>true</UseRefCounting>
|
||||
<Profiling>true</Profiling>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<EnableCodeSigning>true</EnableCodeSigning>
|
||||
<CodeSigningKey>Developer ID Application</CodeSigningKey>
|
||||
<CreatePackage>true</CreatePackage>
|
||||
<EnablePackageSigning>false</EnablePackageSigning>
|
||||
<IncludeMonoRuntime>true</IncludeMonoRuntime>
|
||||
<UseSGen>true</UseSGen>
|
||||
<UseRefCounting>true</UseRefCounting>
|
||||
<LinkMode>SdkOnly</LinkMode>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Xamarin.Mac" />
|
||||
<Reference Include="SkiaSharp">
|
||||
<HintPath>packages\SkiaSharp.1.54.0\lib\XamarinMac\SkiaSharp.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Contents.json" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-128.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-128%402x.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-16.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-16%402x.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-256.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-256%402x.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-32.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-32%402x.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-512.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\AppIcon-512%402x.png" />
|
||||
<ImageAsset Include="Assets.xcassets\Contents.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Info.plist" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="MainWindow.cs" />
|
||||
<Compile Include="MainWindow.designer.cs">
|
||||
<DependentUpon>MainWindow.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="MainWindowController.cs" />
|
||||
<Compile Include="MainWindowController.designer.cs">
|
||||
<DependentUpon>MainWindowController.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<InterfaceDefinition Include="MainMenu.xib" />
|
||||
<InterfaceDefinition Include="MainWindow.xib" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\views\SkiaSharp.Views.Mac\SkiaSharp.Views.Mac.csproj">
|
||||
<Project>{809A15DC-E675-4A24-83FA-DF13160F7E4C}</Project>
|
||||
<Name>SkiaSharp.Views.Mac</Name>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.CSharp.targets" />
|
||||
<Import Project="packages\SkiaSharp.1.54.0\build\XamarinMac\SkiaSharp.targets" Condition="Exists('packages\SkiaSharp.1.54.0\build\XamarinMac\SkiaSharp.targets')" />
|
||||
</Project>
|
|
@ -0,0 +1,25 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BasicSkiaSharp", "BasicSkiaSharp.csproj", "{9DBE1586-4312-4BAE-83F4-28AD9947369F}"
|
||||
EndProject
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkiaSharp.Views.Mac", "..\..\..\views\SkiaSharp.Views.Mac\SkiaSharp.Views.Mac.csproj", "{809A15DC-E675-4A24-83FA-DF13160F7E4C}"
|
||||
EndProject
|
||||
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SkiaSharp.Views.Apple", "..\..\..\views\SkiaSharp.Views.Apple\SkiaSharp.Views.Apple.shproj", "{CBCA14E7-96C9-4697-909C-19B1EF7298F7}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{9DBE1586-4312-4BAE-83F4-28AD9947369F}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{9DBE1586-4312-4BAE-83F4-28AD9947369F}.Debug|x86.Build.0 = Debug|x86
|
||||
{9DBE1586-4312-4BAE-83F4-28AD9947369F}.Release|x86.ActiveCfg = Release|x86
|
||||
{9DBE1586-4312-4BAE-83F4-28AD9947369F}.Release|x86.Build.0 = Release|x86
|
||||
{809A15DC-E675-4A24-83FA-DF13160F7E4C}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{809A15DC-E675-4A24-83FA-DF13160F7E4C}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{809A15DC-E675-4A24-83FA-DF13160F7E4C}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{809A15DC-E675-4A24-83FA-DF13160F7E4C}.Release|x86.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,33 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>CFBundleName</key>
|
||||
<string>BasicSkiaSharp</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.companyname.basicskiasharp</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.8</string>
|
||||
<key>CFBundleDevelopmentRegion</key>
|
||||
<string>en</string>
|
||||
<key>CFBundleInfoDictionaryVersion</key>
|
||||
<string>6.0</string>
|
||||
<key>CFBundlePackageType</key>
|
||||
<string>APPL</string>
|
||||
<key>CFBundleSignature</key>
|
||||
<string>????</string>
|
||||
<key>NSHumanReadableCopyright</key>
|
||||
<string>(c) Matthew Leibowitz</string>
|
||||
<key>NSPrincipalClass</key>
|
||||
<string>NSApplication</string>
|
||||
<key>NSMainNibFile</key>
|
||||
<string>MainMenu</string>
|
||||
<key>XSAppIconAssets</key>
|
||||
<string>Assets.xcassets/AppIcon.appiconset</string>
|
||||
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,13 @@
|
|||
using AppKit;
|
||||
|
||||
namespace BasicSkiaSharp
|
||||
{
|
||||
static class MainClass
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
NSApplication.Init();
|
||||
NSApplication.Main(args);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11198.2" systemVersion="15G31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11198.2"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
|
||||
<connections>
|
||||
<outlet property="delegate" destination="Voe-Tx-rLC" id="GzC-gU-4Uq"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<customObject id="Voe-Tx-rLC" customClass="AppDelegate"/>
|
||||
<customObject id="YLy-65-1bz" customClass="NSFontManager"/>
|
||||
<menu title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
|
||||
<items>
|
||||
<menuItem title="BasicSkiaSharp" id="1Xt-HY-uBw">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="BasicSkiaSharp" systemMenu="apple" id="uQy-DD-JDr">
|
||||
<items>
|
||||
<menuItem title="About BasicSkiaSharp" id="5kV-Vb-QxS">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="orderFrontStandardAboutPanel:" target="-1" id="Exp-CZ-Vem"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
|
||||
<menuItem title="Quit BasicSkiaSharp" keyEquivalent="q" id="4sb-4s-VLi">
|
||||
<connections>
|
||||
<action selector="terminate:" target="-1" id="Te7-pn-YzF"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="File" id="dMs-cI-mzQ">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="Edit" id="5QF-Oa-p0T">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="Format" id="jxT-CU-nIS">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="View" id="H8h-7b-M4v">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="Window" id="aUF-d1-5bR">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
<menuItem title="Help" id="wpr-3q-Mcd">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</objects>
|
||||
</document>
|
|
@ -0,0 +1,224 @@
|
|||
using System;
|
||||
using AppKit;
|
||||
using CoreGraphics;
|
||||
using Foundation;
|
||||
using SkiaSharp;
|
||||
using SkiaSharp.Views;
|
||||
|
||||
namespace BasicSkiaSharp
|
||||
{
|
||||
public partial class MainWindow : NSWindow, ISKLayerDelegate //, ISKGLLayerDelegate
|
||||
{
|
||||
private MySoftwareView softwareSkiaView;
|
||||
|
||||
private NSView softwareSkiaLayerView;
|
||||
|
||||
//private MyHardwareView hardwareSkiaView;
|
||||
|
||||
//private SKGLLayer hardwareSkiaLayer;
|
||||
//private NSView hardwareSkiaLayerView;
|
||||
|
||||
private NSTextField softwareLabel;
|
||||
private NSTextField hardwareLabel;
|
||||
private NSTextField layerLabel;
|
||||
private NSTextField viewLabel;
|
||||
|
||||
public MainWindow(IntPtr handle)
|
||||
: base(handle)
|
||||
{
|
||||
}
|
||||
|
||||
[Export("initWithCoder:")]
|
||||
public MainWindow(NSCoder coder)
|
||||
: base(coder)
|
||||
{
|
||||
}
|
||||
|
||||
public override void AwakeFromNib()
|
||||
{
|
||||
base.AwakeFromNib();
|
||||
|
||||
// create the labels
|
||||
var font = NSFont.BoldSystemFontOfSize(18);
|
||||
softwareLabel = new NSTextField
|
||||
{
|
||||
StringValue = "Software",
|
||||
Alignment = NSTextAlignment.Center,
|
||||
Font = font,
|
||||
Bezeled = false,
|
||||
DrawsBackground = false,
|
||||
Editable = false,
|
||||
Selectable = false,
|
||||
};
|
||||
ContentView.AddSubview(softwareLabel);
|
||||
hardwareLabel = new NSTextField
|
||||
{
|
||||
StringValue = "Hardware",
|
||||
Alignment = NSTextAlignment.Center,
|
||||
Font = font,
|
||||
Bezeled = false,
|
||||
DrawsBackground = false,
|
||||
Editable = false,
|
||||
Selectable = false,
|
||||
};
|
||||
ContentView.AddSubview(hardwareLabel);
|
||||
layerLabel = new NSTextField
|
||||
{
|
||||
StringValue = "Layer",
|
||||
Alignment = NSTextAlignment.Center,
|
||||
Font = font,
|
||||
Bezeled = false,
|
||||
DrawsBackground = false,
|
||||
Editable = false,
|
||||
Selectable = false,
|
||||
};
|
||||
layerLabel.RotateByAngle(-90);
|
||||
ContentView.AddSubview(layerLabel);
|
||||
viewLabel = new NSTextField
|
||||
{
|
||||
StringValue = "View",
|
||||
Alignment = NSTextAlignment.Center,
|
||||
Font = font,
|
||||
Bezeled = false,
|
||||
DrawsBackground = false,
|
||||
Editable = false,
|
||||
Selectable = false,
|
||||
};
|
||||
viewLabel.RotateByAngle(-90);
|
||||
ContentView.AddSubview(viewLabel);
|
||||
|
||||
// create a custom software view
|
||||
softwareSkiaView = new MySoftwareView();
|
||||
ContentView.AddSubview(softwareSkiaView);
|
||||
|
||||
//// create a custom hardware view
|
||||
//hardwareSkiaView = new MyHardwareView();
|
||||
//hardwareSkiaView.EnableSetNeedsDisplay = true;
|
||||
//ContentView.AddSubview(hardwareSkiaView);
|
||||
|
||||
// add a software layer
|
||||
softwareSkiaLayerView = new NSView();
|
||||
softwareSkiaLayerView.Layer = new SKLayer
|
||||
{
|
||||
ContentsScale = BackingScaleFactor,
|
||||
SKDelegate = this
|
||||
};
|
||||
softwareSkiaLayerView.WantsLayer = true;
|
||||
ContentView.AddSubview(softwareSkiaLayerView);
|
||||
|
||||
//// add a hardware layer
|
||||
//hardwareSkiaLayerView = new NSView();
|
||||
//ContentView.AddSubview(hardwareSkiaLayerView);
|
||||
//hardwareSkiaLayer = new SKGLLayer
|
||||
//{
|
||||
// ContentsScale = BackingScaleFactor,
|
||||
// SKDelegate = this
|
||||
//};
|
||||
//hardwareSkiaLayerView.Layer.AddSublayer(hardwareSkiaLayer);
|
||||
|
||||
DidResize += delegate { LayoutSubviews(); };
|
||||
LayoutSubviews();
|
||||
}
|
||||
|
||||
private void LayoutSubviews()
|
||||
{
|
||||
var headerHeight = 32f;
|
||||
var topHeader = new CGRect(headerHeight, 0, ContentView.Bounds.Width - headerHeight, headerHeight);
|
||||
var leftHeader = new CGRect(0, headerHeight, headerHeight, ContentView.Bounds.Height - headerHeight);
|
||||
var availableSpace = CGRect.FromLTRB(leftHeader.Right, topHeader.Bottom, ContentView.Bounds.Width, ContentView.Bounds.Height);
|
||||
var colWidth = availableSpace.Width / 2f;
|
||||
var rowHeight = availableSpace.Height / 2f;
|
||||
var inset = 12;
|
||||
|
||||
// layout the various views
|
||||
|
||||
// the labels
|
||||
softwareLabel.Frame = new CGRect(topHeader.X, topHeader.Y, colWidth, topHeader.Height);
|
||||
hardwareLabel.Frame = new CGRect(topHeader.X + colWidth, topHeader.Y, colWidth, topHeader.Height);
|
||||
viewLabel.Frame = new CGRect(leftHeader.X, topHeader.Bottom, leftHeader.Width, rowHeight);
|
||||
layerLabel.Frame = new CGRect(leftHeader.X, topHeader.Bottom + rowHeight, leftHeader.Width, rowHeight);
|
||||
|
||||
// the software view
|
||||
softwareSkiaView.Frame = new CGRect(availableSpace.X, availableSpace.Y, colWidth, rowHeight).Inset(inset, inset);
|
||||
|
||||
// the software layer
|
||||
softwareSkiaLayerView.Frame = new CGRect(availableSpace.X, availableSpace.Y + rowHeight, colWidth, rowHeight).Inset(inset, inset);
|
||||
|
||||
//// the hardware view
|
||||
//hardwareSkiaView.Frame = new CGRect(availableSpace.X + colWidth, availableSpace.Y, colWidth, rowHeight).Inset(inset, inset);
|
||||
|
||||
//// the hardware layer
|
||||
//hardwareSkiaLayerView.Frame = new CGRect(availableSpace.X + colWidth, availableSpace.Y + rowHeight, colWidth, rowHeight).Inset(inset, inset);
|
||||
//hardwareSkiaLayer.Frame = hardwareSkiaLayerView.Bounds;
|
||||
}
|
||||
|
||||
// the real draw method
|
||||
private static void Draw(SKSurface surface, SKSize size)
|
||||
{
|
||||
const int stroke = 4;
|
||||
const int curve = 20;
|
||||
const int textSize = 60;
|
||||
const int shrink = stroke / -2;
|
||||
|
||||
var canvas = surface.Canvas;
|
||||
|
||||
canvas.Clear(SKColors.Transparent);
|
||||
|
||||
using (var paint = new SKPaint())
|
||||
{
|
||||
paint.IsAntialias = true;
|
||||
paint.TextSize = textSize;
|
||||
|
||||
paint.Color = SKColors.Orchid;
|
||||
var r = SKRect.Create(SKPoint.Empty, size);
|
||||
canvas.DrawRoundRect(r, curve, curve, paint);
|
||||
|
||||
paint.Color = SKColors.GreenYellow;
|
||||
canvas.DrawText("Hello MacOS World!", 30, textSize + 10, paint);
|
||||
|
||||
paint.Color = SKColors.Orange.WithAlpha(100);
|
||||
canvas.DrawOval(SKRect.Create(50, 50, 100, 100), paint);
|
||||
|
||||
paint.IsStroke = true;
|
||||
paint.StrokeWidth = stroke;
|
||||
paint.Color = SKColors.Black;
|
||||
r.Inflate(shrink, shrink);
|
||||
canvas.DrawRoundRect(r, curve - stroke, curve - stroke, paint);
|
||||
}
|
||||
}
|
||||
|
||||
// drawing for the software layer
|
||||
public void DrawInSurface(SKSurface surface, SKImageInfo info)
|
||||
{
|
||||
Draw(surface, info.Size);
|
||||
}
|
||||
|
||||
//// drawing for the hardware layer
|
||||
//public void DrawInSurface(SKSurface surface, GRBackendRenderTargetDesc renderTarget)
|
||||
//{
|
||||
// Draw(surface, new SKSize(renderTarget.Width, renderTarget.Height));
|
||||
//}
|
||||
|
||||
// the custom view
|
||||
private class MySoftwareView : SKView
|
||||
{
|
||||
public override void Draw(SKSurface surface, SKImageInfo info)
|
||||
{
|
||||
base.Draw(surface, info);
|
||||
|
||||
MainWindow.Draw(surface, info.Size);
|
||||
}
|
||||
}
|
||||
|
||||
//// the custom view
|
||||
//private class MyHardwareView : SKGLView
|
||||
//{
|
||||
// public override void DrawInSurface(SKSurface surface, GRBackendRenderTargetDesc renderTarget)
|
||||
// {
|
||||
// base.DrawInSurface(surface, renderTarget);
|
||||
|
||||
// ViewController.Draw(surface, new SKSize(renderTarget.Width, renderTarget.Height));
|
||||
// }
|
||||
//}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,7 @@
|
|||
namespace BasicSkiaSharp
|
||||
{
|
||||
[global::Foundation.Register("MainWindow")]
|
||||
public partial class MainWindow
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="11198.2" systemVersion="15G31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none">
|
||||
<dependencies>
|
||||
<deployment identifier="macosx"/>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11198.2"/>
|
||||
</dependencies>
|
||||
<objects>
|
||||
<customObject id="-2" userLabel="File's Owner" customClass="MainWindowController">
|
||||
<connections>
|
||||
<outlet property="window" destination="2" id="6"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/>
|
||||
<customObject id="-3" userLabel="Application" customClass="NSObject"/>
|
||||
<window title="Window" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" animationBehavior="default" id="2" customClass="MainWindow">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<rect key="contentRect" x="131" y="74" width="606" height="354"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1280" height="778"/>
|
||||
<view key="contentView" id="3">
|
||||
<rect key="frame" x="0.0" y="0.0" width="606" height="354"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
</view>
|
||||
</window>
|
||||
</objects>
|
||||
</document>
|
|
@ -0,0 +1,27 @@
|
|||
using System;
|
||||
using AppKit;
|
||||
using Foundation;
|
||||
|
||||
namespace BasicSkiaSharp
|
||||
{
|
||||
public partial class MainWindowController : NSWindowController
|
||||
{
|
||||
public MainWindowController(IntPtr handle)
|
||||
: base(handle)
|
||||
{
|
||||
}
|
||||
|
||||
[Export("initWithCoder:")]
|
||||
public MainWindowController(NSCoder coder)
|
||||
: base(coder)
|
||||
{
|
||||
}
|
||||
|
||||
public MainWindowController()
|
||||
: base("MainWindow")
|
||||
{
|
||||
}
|
||||
|
||||
public new MainWindow Window => (MainWindow)base.Window;
|
||||
}
|
||||
}
|
7
samples/BasicSamples/BasicSkiaSharp-Mac/MainWindowController.designer.cs
сгенерированный
Normal file
|
@ -0,0 +1,7 @@
|
|||
namespace BasicSkiaSharp
|
||||
{
|
||||
[global::Foundation.Register("MainWindowController")]
|
||||
public partial class MainWindowController
|
||||
{
|
||||
}
|
||||
}
|
|
@ -0,0 +1,4 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="SkiaSharp" version="1.54.0" targetFramework="xamarinmac20" />
|
||||
</packages>
|