Added the new mac sample
|
@ -0,0 +1,21 @@
|
|||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio 2012
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SkiaSharpSample.MacSample", "SkiaSharpSample.MacSample\SkiaSharpSample.MacSample.csproj", "{1BCAB142-0AEF-4ED1-A9A2-271D0A84C56A}"
|
||||
EndProject
|
||||
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SkiaSharpSample.Platform.Shared", "..\SkiaSharpSample.Platform.Shared\SkiaSharpSample.Platform.Shared.shproj", "{0CC41AB0-0C4C-4DAA-8F10-A249725EBF5D}"
|
||||
EndProject
|
||||
Project("{D954291E-2A0B-460D-934E-DC6B0785DB48}") = "SkiaSharpSample.Shared", "..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.shproj", "{509B233A-35A0-41CA-A585-0B1A9F79D470}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|x86 = Debug|x86
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{1BCAB142-0AEF-4ED1-A9A2-271D0A84C56A}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{1BCAB142-0AEF-4ED1-A9A2-271D0A84C56A}.Debug|x86.Build.0 = Debug|x86
|
||||
{1BCAB142-0AEF-4ED1-A9A2-271D0A84C56A}.Release|x86.ActiveCfg = Release|x86
|
||||
{1BCAB142-0AEF-4ED1-A9A2-271D0A84C56A}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
EndGlobal
|
|
@ -0,0 +1,147 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text.RegularExpressions;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using AppKit;
|
||||
using Foundation;
|
||||
|
||||
namespace SkiaSharpSample.MacSample
|
||||
{
|
||||
[Register("AppDelegate")]
|
||||
public partial class AppDelegate : NSApplicationDelegate
|
||||
{
|
||||
private MainViewController controller;
|
||||
private CancellationTokenSource cancellations;
|
||||
private IList<SampleBase> samples;
|
||||
private IList<GroupedSamples> sampleGroups;
|
||||
|
||||
public AppDelegate()
|
||||
{
|
||||
samples = SamplesManager.GetSamples(SamplePlatforms.iOS).ToList();
|
||||
sampleGroups = Enum.GetValues(typeof(SampleCategories))
|
||||
.Cast<SampleCategories>()
|
||||
.Select(c => new GroupedSamples(c, samples.Where(s => s.Category.HasFlag(c))))
|
||||
.Where(g => g.Samples.Count > 0)
|
||||
.OrderBy(g => g.Category == SampleCategories.Showcases ? string.Empty : g.Name)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public MainViewController Controller
|
||||
{
|
||||
get { return controller; }
|
||||
set
|
||||
{
|
||||
controller = value;
|
||||
controller?.SetSample(samples.First(s => s.Category.HasFlag(SampleCategories.Showcases)));
|
||||
}
|
||||
}
|
||||
|
||||
public override bool ApplicationShouldTerminateAfterLastWindowClosed(NSApplication sender) => true;
|
||||
|
||||
public override void DidFinishLaunching(NSNotification notification)
|
||||
{
|
||||
SamplesInitializer.Init();
|
||||
|
||||
foreach (var category in sampleGroups)
|
||||
{
|
||||
// create the menu item
|
||||
var menu = new NSMenuItem(category.Name);
|
||||
menu.Submenu = new NSMenu(category.Name);
|
||||
foreach (var sample in category.Samples)
|
||||
{
|
||||
// create the sample item
|
||||
var tag = samples.IndexOf(sample);
|
||||
menu.Submenu.AddItem(new NSMenuItem(sample.Title, OnSampleSelected) { Tag = tag });
|
||||
}
|
||||
// add to the menu bar
|
||||
samplesMenu.Submenu.AddItem(menu);
|
||||
}
|
||||
}
|
||||
|
||||
public override void WillTerminate(NSNotification notification)
|
||||
{
|
||||
cancellations?.Cancel();
|
||||
cancellations = null;
|
||||
}
|
||||
|
||||
private void OnSampleSelected(object sender, EventArgs e)
|
||||
{
|
||||
var menu = sender as NSMenuItem;
|
||||
if (menu?.Tag >= 0)
|
||||
{
|
||||
Controller?.SetSample(samples[(int)menu.Tag]);
|
||||
}
|
||||
}
|
||||
|
||||
partial void OnBackendChanged(NSObject sender)
|
||||
{
|
||||
var menu = sender as NSMenuItem;
|
||||
Controller?.ChangeBackend((SampleBackends)(int)menu.Tag);
|
||||
}
|
||||
|
||||
partial void OnPlaySamples(NSObject sender)
|
||||
{
|
||||
if (cancellations != null)
|
||||
{
|
||||
// cancel the old loop
|
||||
cancellations.Cancel();
|
||||
cancellations = null;
|
||||
}
|
||||
else if (Controller != null)
|
||||
{
|
||||
// start a new loop
|
||||
cancellations = new CancellationTokenSource();
|
||||
var token = cancellations.Token;
|
||||
Task.Run(async delegate
|
||||
{
|
||||
try
|
||||
{
|
||||
// get the samples in a list
|
||||
var sortedSamples = sampleGroups.SelectMany(g => g.Samples).Distinct().ToList();
|
||||
var lastSample = sortedSamples.First();
|
||||
while (!token.IsCancellationRequested)
|
||||
{
|
||||
// display the sample
|
||||
InvokeOnMainThread(() => Controller?.SetSample(lastSample));
|
||||
|
||||
// wait a bit
|
||||
await Task.Delay(3000, token);
|
||||
|
||||
// select the next one
|
||||
var idx = sortedSamples.IndexOf(lastSample) + 1;
|
||||
if (idx >= sortedSamples.Count)
|
||||
{
|
||||
idx = 0;
|
||||
}
|
||||
lastSample = sortedSamples[idx];
|
||||
}
|
||||
}
|
||||
catch (TaskCanceledException)
|
||||
{
|
||||
// we are expecting this
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public class GroupedSamples
|
||||
{
|
||||
private static readonly Regex EnumSplitRexeg = new Regex("(?<!^)([A-Z][a-z]|(?<=[a-z])[A-Z])");
|
||||
|
||||
public GroupedSamples(SampleCategories category, IEnumerable<SampleBase> samples)
|
||||
{
|
||||
Category = category;
|
||||
Name = EnumSplitRexeg.Replace(category.ToString(), " $1");
|
||||
Samples = samples.OrderBy(s => s.Title).ToList();
|
||||
}
|
||||
|
||||
public SampleCategories Category { get; private set; }
|
||||
|
||||
public string Name { get; private set; }
|
||||
|
||||
public IList<SampleBase> Samples { get; private set; }
|
||||
}
|
||||
}
|
||||
}
|
32
samples/SkiaSharpSample.MacSample/SkiaSharpSample.MacSample/AppDelegate.designer.cs
сгенерированный
Normal file
|
@ -0,0 +1,32 @@
|
|||
// WARNING
|
||||
//
|
||||
// This file has been generated automatically by Xamarin Studio to store outlets and
|
||||
// actions made in the UI designer. If it is removed, they will be lost.
|
||||
// Manual changes to this file may not be handled correctly.
|
||||
//
|
||||
using Foundation;
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
namespace SkiaSharpSample.MacSample
|
||||
{
|
||||
partial class AppDelegate
|
||||
{
|
||||
[Outlet]
|
||||
AppKit.NSMenuItem samplesMenu { get; set; }
|
||||
|
||||
[Action("OnBackendChanged:")]
|
||||
partial void OnBackendChanged(Foundation.NSObject sender);
|
||||
|
||||
[Action("OnPlaySamples:")]
|
||||
partial void OnPlaySamples(Foundation.NSObject sender);
|
||||
|
||||
void ReleaseDesignerOutlets()
|
||||
{
|
||||
if (samplesMenu != null)
|
||||
{
|
||||
samplesMenu.Dispose();
|
||||
samplesMenu = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,242 @@
|
|||
{
|
||||
"images" : [
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "20x20",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "20x20",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "29x29",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "29x29",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "29x29",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "40x40",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "40x40",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "57x57",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "57x57",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "60x60",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "iphone",
|
||||
"size" : "60x60",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "20x20",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "20x20",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "29x29",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "29x29",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "40x40",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "40x40",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "50x50",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "50x50",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "72x72",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "72x72",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "76x76",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "76x76",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"idiom" : "ipad",
|
||||
"size" : "83.5x83.5",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "24x24",
|
||||
"idiom" : "watch",
|
||||
"scale" : "2x",
|
||||
"role" : "notificationCenter",
|
||||
"subtype" : "38mm"
|
||||
},
|
||||
{
|
||||
"size" : "27.5x27.5",
|
||||
"idiom" : "watch",
|
||||
"scale" : "2x",
|
||||
"role" : "notificationCenter",
|
||||
"subtype" : "42mm"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "watch",
|
||||
"role" : "companionSettings",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "29x29",
|
||||
"idiom" : "watch",
|
||||
"role" : "companionSettings",
|
||||
"scale" : "3x"
|
||||
},
|
||||
{
|
||||
"size" : "40x40",
|
||||
"idiom" : "watch",
|
||||
"scale" : "2x",
|
||||
"role" : "appLauncher",
|
||||
"subtype" : "38mm"
|
||||
},
|
||||
{
|
||||
"size" : "44x44",
|
||||
"idiom" : "watch",
|
||||
"scale" : "2x",
|
||||
"role" : "longLook",
|
||||
"subtype" : "42mm"
|
||||
},
|
||||
{
|
||||
"size" : "86x86",
|
||||
"idiom" : "watch",
|
||||
"scale" : "2x",
|
||||
"role" : "quickLook",
|
||||
"subtype" : "38mm"
|
||||
},
|
||||
{
|
||||
"size" : "98x98",
|
||||
"idiom" : "watch",
|
||||
"scale" : "2x",
|
||||
"role" : "quickLook",
|
||||
"subtype" : "42mm"
|
||||
},
|
||||
{
|
||||
"size" : "16x16",
|
||||
"idiom" : "mac",
|
||||
"filename" : "skia_16x16.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "16x16",
|
||||
"idiom" : "mac",
|
||||
"filename" : "skia_32x32.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "32x32",
|
||||
"idiom" : "mac",
|
||||
"filename" : "skia_32x32.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "32x32",
|
||||
"idiom" : "mac",
|
||||
"filename" : "skia_64x64.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "128x128",
|
||||
"idiom" : "mac",
|
||||
"filename" : "skia_128x128.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "128x128",
|
||||
"idiom" : "mac",
|
||||
"filename" : "skia_256x256.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "256x256",
|
||||
"idiom" : "mac",
|
||||
"filename" : "skia_256x256.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "256x256",
|
||||
"idiom" : "mac",
|
||||
"filename" : "skia_512x512.png",
|
||||
"scale" : "2x"
|
||||
},
|
||||
{
|
||||
"size" : "512x512",
|
||||
"idiom" : "mac",
|
||||
"filename" : "skia_512x512.png",
|
||||
"scale" : "1x"
|
||||
},
|
||||
{
|
||||
"size" : "512x512",
|
||||
"idiom" : "mac",
|
||||
"filename" : "skia_1024x1024.png",
|
||||
"scale" : "2x"
|
||||
}
|
||||
],
|
||||
"info" : {
|
||||
"version" : 1,
|
||||
"author" : "xcode"
|
||||
}
|
||||
}
|
После Ширина: | Высота: | Размер: 28 KiB |
Двоичные данные
samples/SkiaSharpSample.MacSample/SkiaSharpSample.MacSample/Assets.xcassets/AppIcon.appiconset/skia_128x128.png
Normal file
После Ширина: | Высота: | Размер: 3.1 KiB |
Двоичные данные
samples/SkiaSharpSample.MacSample/SkiaSharpSample.MacSample/Assets.xcassets/AppIcon.appiconset/skia_16x16.png
Normal file
После Ширина: | Высота: | Размер: 935 B |
Двоичные данные
samples/SkiaSharpSample.MacSample/SkiaSharpSample.MacSample/Assets.xcassets/AppIcon.appiconset/skia_256x256.png
Normal file
После Ширина: | Высота: | Размер: 5.9 KiB |
Двоичные данные
samples/SkiaSharpSample.MacSample/SkiaSharpSample.MacSample/Assets.xcassets/AppIcon.appiconset/skia_32x32.png
Normal file
После Ширина: | Высота: | Размер: 1.5 KiB |
Двоичные данные
samples/SkiaSharpSample.MacSample/SkiaSharpSample.MacSample/Assets.xcassets/AppIcon.appiconset/skia_512x512.png
Normal file
После Ширина: | Высота: | Размер: 13 KiB |
Двоичные данные
samples/SkiaSharpSample.MacSample/SkiaSharpSample.MacSample/Assets.xcassets/AppIcon.appiconset/skia_64x64.png
Normal file
После Ширина: | Высота: | Размер: 2.7 KiB |
|
@ -0,0 +1,34 @@
|
|||
<?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>SkiaSharp for MacOS</string>
|
||||
<key>CFBundleIdentifier</key>
|
||||
<string>com.companyname.skiasharpsample-macsample</string>
|
||||
<key>CFBundleShortVersionString</key>
|
||||
<string>1.54.1.0</string>
|
||||
<key>CFBundleVersion</key>
|
||||
<string>1</string>
|
||||
<key>LSMinimumSystemVersion</key>
|
||||
<string>10.10</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>NSMainStoryboardFile</key>
|
||||
<string>Main</string>
|
||||
<key>XSAppIconAssets</key>
|
||||
<string>Assets.xcassets/AppIcon.appiconset</string>
|
||||
<key>LSApplicationCategoryType</key>
|
||||
<string>public.app-category.developer-tools</string>
|
||||
</dict>
|
||||
</plist>
|
|
@ -0,0 +1,13 @@
|
|||
using AppKit;
|
||||
|
||||
namespace SkiaSharpSample.MacSample
|
||||
{
|
||||
static class MainClass
|
||||
{
|
||||
static void Main(string[] args)
|
||||
{
|
||||
NSApplication.Init();
|
||||
NSApplication.Main(args);
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,142 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<document type="com.apple.InterfaceBuilder3.Cocoa.Storyboard.XIB" version="3.0" toolsVersion="11201" systemVersion="15G31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" initialViewController="B8D-0N-5wS">
|
||||
<dependencies>
|
||||
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="11201"/>
|
||||
</dependencies>
|
||||
<scenes>
|
||||
<!--Application-->
|
||||
<scene sceneID="JPo-4y-FX3">
|
||||
<objects>
|
||||
<application id="hnw-xV-0zn" sceneMemberID="viewController">
|
||||
<menu key="mainMenu" title="Main Menu" systemMenu="main" id="AYu-sK-qS6">
|
||||
<items>
|
||||
<menuItem title="SkiaSharp for MacOS" id="1Xt-HY-uBw">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="SkiaSharp for MacOS" systemMenu="apple" id="uQy-DD-JDr">
|
||||
<items>
|
||||
<menuItem title="About SkiaSharp for MacOS" id="5kV-Vb-QxS">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="orderFrontStandardAboutPanel:" target="Ady-hI-5gd" id="Exp-CZ-Vem"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="VOq-y0-SEH"/>
|
||||
<menuItem title="Configure Backend" id="rbQ-pD-dGv">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Configure Backend" id="YMg-n9-a3A">
|
||||
<items>
|
||||
<menuItem title="Memory" tag="1" id="BUa-1K-eIo">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="OnBackendChanged:" target="Voe-Tx-rLC" id="doD-1P-5wM"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="OpenGL" tag="2" id="Ief-eY-MtZ">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="OnBackendChanged:" target="Voe-Tx-rLC" id="LWv-DI-4Sw"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem title="Vulkan" tag="4" id="Jb6-2h-Xas">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="OnBackendChanged:" target="Voe-Tx-rLC" id="0Lj-Wq-LAi"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="kCx-OE-vgT"/>
|
||||
<menuItem title="Quit SkiaSharp for MacOS" keyEquivalent="q" id="4sb-4s-VLi">
|
||||
<connections>
|
||||
<action selector="terminate:" target="Ady-hI-5gd" id="Te7-pn-YzF"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
<menuItem title="Samples" id="fd7-2g-9z7">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<menu key="submenu" title="Samples" id="YCg-AC-LaP">
|
||||
<items>
|
||||
<menuItem title="Toggle Sample Slideshow" id="vY6-Zp-iQd">
|
||||
<modifierMask key="keyEquivalentModifierMask"/>
|
||||
<connections>
|
||||
<action selector="OnPlaySamples:" target="Voe-Tx-rLC" id="loX-7g-UQy"/>
|
||||
</connections>
|
||||
</menuItem>
|
||||
<menuItem isSeparatorItem="YES" id="Qai-dY-Zxv"/>
|
||||
</items>
|
||||
</menu>
|
||||
</menuItem>
|
||||
</items>
|
||||
</menu>
|
||||
<connections>
|
||||
<outlet property="delegate" destination="Voe-Tx-rLC" id="PrD-fu-P6m"/>
|
||||
</connections>
|
||||
</application>
|
||||
<customObject id="Voe-Tx-rLC" customClass="AppDelegate">
|
||||
<connections>
|
||||
<outlet property="samplesMenu" destination="fd7-2g-9z7" id="2QI-Dx-7aE"/>
|
||||
</connections>
|
||||
</customObject>
|
||||
<customObject id="Ady-hI-5gd" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-582" y="-230"/>
|
||||
</scene>
|
||||
<!--Window Controller-->
|
||||
<scene sceneID="R2V-B0-nI4">
|
||||
<objects>
|
||||
<windowController id="B8D-0N-5wS" sceneMemberID="viewController">
|
||||
<window key="window" title="SkiaSharp for MacOS" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" oneShot="NO" releasedWhenClosed="NO" showsToolbarButton="NO" visibleAtLaunch="NO" animationBehavior="default" id="IQv-IB-iLA">
|
||||
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
|
||||
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
|
||||
<rect key="contentRect" x="196" y="240" width="480" height="270"/>
|
||||
<rect key="screenRect" x="0.0" y="0.0" width="1680" height="1027"/>
|
||||
</window>
|
||||
<connections>
|
||||
<outlet property="window" destination="IQv-IB-iLA" id="Edp-l2-piX"/>
|
||||
<segue destination="XfG-lQ-9wD" kind="relationship" relationship="window.shadowedContentViewController" id="cq2-FE-JQM"/>
|
||||
</connections>
|
||||
</windowController>
|
||||
<customObject id="Oky-zY-oP4" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-582" y="4"/>
|
||||
</scene>
|
||||
<!--Main View Controller-->
|
||||
<scene sceneID="hIz-AP-VOD">
|
||||
<objects>
|
||||
<viewController id="XfG-lQ-9wD" customClass="MainViewController" sceneMemberID="viewController">
|
||||
<view key="view" id="m2S-Jp-Qdl">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
|
||||
<autoresizingMask key="autoresizingMask"/>
|
||||
<subviews>
|
||||
<customView hidden="YES" translatesAutoresizingMaskIntoConstraints="NO" id="dja-Py-1qV" customClass="SKGLView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
|
||||
</customView>
|
||||
<customView translatesAutoresizingMaskIntoConstraints="NO" id="we8-ZJ-fYa" customClass="SKCanvasView">
|
||||
<rect key="frame" x="0.0" y="0.0" width="480" height="270"/>
|
||||
</customView>
|
||||
</subviews>
|
||||
<constraints>
|
||||
<constraint firstAttribute="trailing" secondItem="we8-ZJ-fYa" secondAttribute="trailing" id="C6C-zb-E3T"/>
|
||||
<constraint firstAttribute="bottom" secondItem="dja-Py-1qV" secondAttribute="bottom" id="Ksp-s8-Obk"/>
|
||||
<constraint firstItem="dja-Py-1qV" firstAttribute="leading" secondItem="m2S-Jp-Qdl" secondAttribute="leading" id="OW2-U9-5Pu"/>
|
||||
<constraint firstAttribute="trailing" secondItem="dja-Py-1qV" secondAttribute="trailing" id="Xzf-kX-O4j"/>
|
||||
<constraint firstItem="we8-ZJ-fYa" firstAttribute="top" secondItem="m2S-Jp-Qdl" secondAttribute="top" id="Ysd-UN-fqm"/>
|
||||
<constraint firstItem="dja-Py-1qV" firstAttribute="top" secondItem="m2S-Jp-Qdl" secondAttribute="top" id="jZ7-h4-FXO"/>
|
||||
<constraint firstAttribute="bottom" secondItem="we8-ZJ-fYa" secondAttribute="bottom" id="oOC-pJ-JMT"/>
|
||||
<constraint firstItem="we8-ZJ-fYa" firstAttribute="leading" secondItem="m2S-Jp-Qdl" secondAttribute="leading" id="w6V-zL-Hlc"/>
|
||||
</constraints>
|
||||
</view>
|
||||
<connections>
|
||||
<outlet property="canvas" destination="we8-ZJ-fYa" id="VTf-Hb-A1A"/>
|
||||
<outlet property="glview" destination="dja-Py-1qV" id="db8-C7-qze"/>
|
||||
</connections>
|
||||
</viewController>
|
||||
<customObject id="rPt-NT-nkU" userLabel="First Responder" customClass="NSResponder" sceneMemberID="firstResponder"/>
|
||||
</objects>
|
||||
<point key="canvasLocation" x="-582" y="424"/>
|
||||
</scene>
|
||||
</scenes>
|
||||
</document>
|
|
@ -0,0 +1,115 @@
|
|||
using System;
|
||||
using AppKit;
|
||||
using SkiaSharp;
|
||||
using SkiaSharp.Views;
|
||||
|
||||
namespace SkiaSharpSample.MacSample
|
||||
{
|
||||
public partial class MainViewController : NSViewController
|
||||
{
|
||||
public static AppDelegate App => (AppDelegate)NSApplication.SharedApplication.Delegate;
|
||||
|
||||
private SampleBase sample;
|
||||
|
||||
public MainViewController(IntPtr handle)
|
||||
: base(handle)
|
||||
{
|
||||
}
|
||||
|
||||
public void SetSample(SampleBase newSample)
|
||||
{
|
||||
sample = newSample;
|
||||
|
||||
// set the title
|
||||
var title = sample?.Title ?? "SkiaSharp for MacOS";
|
||||
Title = title;
|
||||
var window = View?.Window;
|
||||
if (window != null)
|
||||
{
|
||||
window.Title = title;
|
||||
}
|
||||
|
||||
// prepare the sample
|
||||
sample?.Init(() =>
|
||||
{
|
||||
// refresh the view
|
||||
canvas.SetNeedsDisplayInRect(canvas.Bounds);
|
||||
glview.SetNeedsDisplayInRect(glview.Bounds);
|
||||
});
|
||||
|
||||
// refresh the view
|
||||
canvas.SetNeedsDisplayInRect(canvas.Bounds);
|
||||
glview.SetNeedsDisplayInRect(glview.Bounds);
|
||||
}
|
||||
|
||||
public override void ViewDidLoad()
|
||||
{
|
||||
base.ViewDidLoad();
|
||||
View.AddGestureRecognizer(new NSClickGestureRecognizer(OnSampleClicked));
|
||||
|
||||
SetSample(sample);
|
||||
}
|
||||
|
||||
public override void ViewWillAppear()
|
||||
{
|
||||
base.ViewWillAppear();
|
||||
|
||||
canvas.PaintSurface += OnPaintCanvas;
|
||||
glview.PaintSurface += OnPaintGL;
|
||||
|
||||
App.Controller = this;
|
||||
}
|
||||
|
||||
public override void ViewWillDisappear()
|
||||
{
|
||||
base.ViewWillDisappear();
|
||||
|
||||
canvas.PaintSurface -= OnPaintCanvas;
|
||||
glview.PaintSurface -= OnPaintGL;
|
||||
|
||||
App.Controller = null;
|
||||
}
|
||||
|
||||
private void OnPaintCanvas(object sender, SKPaintSurfaceEventArgs e)
|
||||
{
|
||||
OnPaintSurface(e.Surface.Canvas, e.Info.Width, e.Info.Height);
|
||||
}
|
||||
|
||||
private void OnPaintGL(object sender, SKPaintGLSurfaceEventArgs e)
|
||||
{
|
||||
OnPaintSurface(e.Surface.Canvas, e.RenderTarget.Width, e.RenderTarget.Height);
|
||||
}
|
||||
|
||||
public void OnSampleClicked()
|
||||
{
|
||||
sample?.Tap();
|
||||
}
|
||||
|
||||
public void OnPaintSurface(SKCanvas canvas, int width, int height)
|
||||
{
|
||||
sample?.DrawSample(canvas, width, height);
|
||||
}
|
||||
|
||||
public void ChangeBackend(SampleBackends backend)
|
||||
{
|
||||
switch (backend)
|
||||
{
|
||||
case SampleBackends.Memory:
|
||||
glview.Hidden = true;
|
||||
canvas.Hidden = false;
|
||||
break;
|
||||
case SampleBackends.OpenGL:
|
||||
glview.Hidden = false;
|
||||
canvas.Hidden = true;
|
||||
break;
|
||||
default:
|
||||
var alert = new NSAlert();
|
||||
alert.MessageText = "Configure Backend";
|
||||
alert.AddButton("OK");
|
||||
alert.InformativeText = "This functionality is not yet implemented.";
|
||||
alert.RunSheetModal(View.Window);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
34
samples/SkiaSharpSample.MacSample/SkiaSharpSample.MacSample/MainViewController.designer.cs
сгенерированный
Normal file
|
@ -0,0 +1,34 @@
|
|||
// WARNING
|
||||
//
|
||||
// This file has been generated automatically by Xamarin Studio to store outlets and
|
||||
// actions made in the UI designer. If it is removed, they will be lost.
|
||||
// Manual changes to this file may not be handled correctly.
|
||||
//
|
||||
using Foundation;
|
||||
using System.CodeDom.Compiler;
|
||||
|
||||
namespace SkiaSharpSample.MacSample
|
||||
{
|
||||
[Register ("MainViewController")]
|
||||
partial class MainViewController
|
||||
{
|
||||
[Outlet]
|
||||
SkiaSharp.Views.SKCanvasView canvas { get; set; }
|
||||
|
||||
[Outlet]
|
||||
SkiaSharp.Views.SKGLView glview { get; set; }
|
||||
|
||||
void ReleaseDesignerOutlets ()
|
||||
{
|
||||
if (canvas != null) {
|
||||
canvas.Dispose ();
|
||||
canvas = null;
|
||||
}
|
||||
|
||||
if (glview != null) {
|
||||
glview.Dispose ();
|
||||
glview = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,122 @@
|
|||
<?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>{1BCAB142-0AEF-4ED1-A9A2-271D0A84C56A}</ProjectGuid>
|
||||
<ProjectTypeGuids>{A3F8F2AB-B479-4A4A-A458-A89E7DC349F1};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
|
||||
<OutputType>Exe</OutputType>
|
||||
<RootNamespace>SkiaSharpSample.MacSample</RootNamespace>
|
||||
<AssemblyName>SkiaSharpSample.MacSample</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>__UNIFIED__;DEBUG;__MAC__</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>
|
||||
<PackageSigningKey>3rd Party Mac Developer Installer</PackageSigningKey>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x86' ">
|
||||
<DebugType></DebugType>
|
||||
<Optimize>true</Optimize>
|
||||
<OutputPath>bin\Release</OutputPath>
|
||||
<DefineConstants>__UNIFIED__;__MAC__</DefineConstants>
|
||||
<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>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|x64' ">
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\x64\Debug</OutputPath>
|
||||
<DefineConstants></DefineConstants>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<IncludeMonoRuntime>false</IncludeMonoRuntime>
|
||||
<UseSGen>false</UseSGen>
|
||||
<XamMacArch></XamMacArch>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|x64' ">
|
||||
<Optimize>false</Optimize>
|
||||
<OutputPath>bin\x64\Release</OutputPath>
|
||||
<DefineConstants></DefineConstants>
|
||||
<WarningLevel>4</WarningLevel>
|
||||
<IncludeMonoRuntime>false</IncludeMonoRuntime>
|
||||
<UseSGen>false</UseSGen>
|
||||
<XamMacArch></XamMacArch>
|
||||
<PlatformTarget>x64</PlatformTarget>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
<Reference Include="Xamarin.Mac" />
|
||||
<Reference Include="SkiaSharp">
|
||||
<HintPath>..\packages\SkiaSharp.1.54.1\lib\XamarinMac\SkiaSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SkiaSharp.Views.Mac">
|
||||
<HintPath>..\packages\SkiaSharp.Views.1.54.1-beta1\lib\XamarinMac\SkiaSharp.Views.Mac.dll</HintPath>
|
||||
</Reference>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\Contents.json" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\skia_16x16.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\skia_32x32.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\skia_64x64.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\skia_128x128.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\skia_256x256.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\skia_512x512.png" />
|
||||
<ImageAsset Include="Assets.xcassets\AppIcon.appiconset\skia_1024x1024.png" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="Info.plist" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Compile Include="Main.cs" />
|
||||
<Compile Include="MainViewController.cs" />
|
||||
<Compile Include="MainViewController.designer.cs">
|
||||
<DependentUpon>MainViewController.cs</DependentUpon>
|
||||
</Compile>
|
||||
<Compile Include="AppDelegate.cs" />
|
||||
<Compile Include="AppDelegate.designer.cs">
|
||||
<DependentUpon>AppDelegate.cs</DependentUpon>
|
||||
</Compile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<InterfaceDefinition Include="Main.storyboard" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Resources\" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<BundleResource Include="..\..\SkiaSharpSample.Shared\Media\content-font.ttf">
|
||||
<Link>Resources\content-font.ttf</Link>
|
||||
</BundleResource>
|
||||
</ItemGroup>
|
||||
<Import Project="..\..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems" Label="Shared" Condition="Exists('..\..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems')" />
|
||||
<Import Project="..\..\SkiaSharpSample.Platform.Shared\SkiaSharpSample.Platform.Shared.projitems" Label="Shared" Condition="Exists('..\..\SkiaSharpSample.Platform.Shared\SkiaSharpSample.Platform.Shared.projitems')" />
|
||||
<Import Project="$(MSBuildExtensionsPath)\Xamarin\Mac\Xamarin.Mac.CSharp.targets" />
|
||||
<Import Project="..\packages\SkiaSharp.1.54.1\build\XamarinMac\SkiaSharp.targets" Condition="Exists('..\packages\SkiaSharp.1.54.1\build\XamarinMac\SkiaSharp.targets')" />
|
||||
</Project>
|
|
@ -0,0 +1,5 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="SkiaSharp" version="1.54.1" targetFramework="xamarinmac20" />
|
||||
<package id="SkiaSharp.Views" version="1.54.1-beta1" targetFramework="xamarinmac20" />
|
||||
</packages>
|
|
@ -1,4 +1,4 @@
|
|||
#if __TVOS__
|
||||
#if __TVOS__ || __MAC__
|
||||
using System;
|
||||
using System.IO;
|
||||
using System.Threading.Tasks;
|
||||
|
@ -12,9 +12,7 @@ namespace PCLStorage
|
|||
static Current()
|
||||
{
|
||||
var documents = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);
|
||||
var path = Path.Combine(documents, "..", "Library");
|
||||
|
||||
LocalStorage = new FileSystemFolder(path);
|
||||
LocalStorage = new FileSystemFolder(documents);
|
||||
}
|
||||
|
||||
public static FileSystemFolder LocalStorage { get; private set; }
|
||||
|
|
|
@ -4,6 +4,10 @@ using System.IO;
|
|||
using Windows.ApplicationModel;
|
||||
using Windows.Storage;
|
||||
using Windows.System;
|
||||
#elif __MAC__
|
||||
using System.IO;
|
||||
using AppKit;
|
||||
using Foundation;
|
||||
#elif __IOS__ || __TVOS__
|
||||
using System.IO;
|
||||
using Foundation;
|
||||
|
@ -27,7 +31,7 @@ namespace SkiaSharpSample
|
|||
#if WINDOWS_UWP
|
||||
var pkg = Package.Current.InstalledLocation.Path;
|
||||
var path = Path.Combine(pkg, "Assets", "Media", fontName);
|
||||
#elif __IOS__ || __TVOS__
|
||||
#elif __IOS__ || __TVOS__ || __MAC__
|
||||
var path = NSBundle.MainBundle.PathForResource(Path.GetFileNameWithoutExtension(fontName), Path.GetExtension(fontName));
|
||||
#elif __ANDROID__
|
||||
var path = Path.Combine(Application.Context.CacheDir.AbsolutePath, fontName);
|
||||
|
@ -46,6 +50,15 @@ namespace SkiaSharpSample
|
|||
#if WINDOWS_UWP
|
||||
var file = await StorageFile.GetFileFromPathAsync(path);
|
||||
await Launcher.LaunchFileAsync(file);
|
||||
#elif __MAC__
|
||||
if (!NSWorkspace.SharedWorkspace.OpenFile(path))
|
||||
{
|
||||
var alert = new NSAlert();
|
||||
alert.AddButton("OK");
|
||||
alert.MessageText = "SkiaSharp";
|
||||
alert.InformativeText = "Unable to open file.";
|
||||
alert.RunSheetModal(NSApplication.SharedApplication.MainWindow);
|
||||
}
|
||||
#elif __TVOS__
|
||||
#elif __IOS__
|
||||
// the external / shared location
|
||||
|
|