diff --git a/src/Skia/Perspex.Skia.iOS.TestApp/Perspex.Skia.iOS.TestApp.csproj b/src/Skia/Perspex.Skia.iOS.TestApp/Perspex.Skia.iOS.TestApp.csproj index 950a0e729a..54375b013a 100644 --- a/src/Skia/Perspex.Skia.iOS.TestApp/Perspex.Skia.iOS.TestApp.csproj +++ b/src/Skia/Perspex.Skia.iOS.TestApp/Perspex.Skia.iOS.TestApp.csproj @@ -20,7 +20,7 @@ 4 false i386 - None + SdkOnly true diff --git a/src/Skia/Perspex.Skia.iOS/Perspex.Skia.iOS.csproj b/src/Skia/Perspex.Skia.iOS/Perspex.Skia.iOS.csproj index 23a677272f..572d466de5 100644 --- a/src/Skia/Perspex.Skia.iOS/Perspex.Skia.iOS.csproj +++ b/src/Skia/Perspex.Skia.iOS/Perspex.Skia.iOS.csproj @@ -2,7 +2,7 @@ Debug - iPhoneSimulator + AnyCPU 8.0.30703 2.0 {47BE08A7-5985-410B-9FFC-2264B8EA595F} @@ -36,15 +36,9 @@ true - - - - libperspesk_standalone.a - - ..\..\..\packages\SkiaSharp.1.49.2.0-beta\lib\XamariniOS\SkiaSharp.dll diff --git a/src/Skia/Perspex.Skia.iOS/SkiaView.cs b/src/Skia/Perspex.Skia.iOS/SkiaView.cs index d60df20aa7..7542a18afe 100644 --- a/src/Skia/Perspex.Skia.iOS/SkiaView.cs +++ b/src/Skia/Perspex.Skia.iOS/SkiaView.cs @@ -21,7 +21,7 @@ namespace Perspex.Skia.iOS //static extern IntPtr GetPerspexEAGLContext(); bool _drawQueued; - CADisplayLink _link; + //CADisplayLink _link; static EAGLContext GetContext() { /* No longer needed with SkiaSharp @@ -43,7 +43,7 @@ namespace Perspex.Skia.iOS protected SkiaView() : base(UIScreen.MainScreen.ApplicationFrame) //, GetContext()) { - (_link = CADisplayLink.Create(() => OnFrame())).AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode); + //(_link = CADisplayLink.Create(() => OnFrame())).AddToRunLoop(NSRunLoop.Main, NSRunLoop.NSDefaultRunLoopMode); } protected void OnFrame() @@ -54,6 +54,8 @@ namespace Perspex.Skia.iOS // GLKView //Display(); + + this.SetNeedsDisplay(); } } diff --git a/src/Skia/Perspex.Skia/RenderTarget.cs b/src/Skia/Perspex.Skia/RenderTarget.cs index cc911cae3f..941e46d08c 100644 --- a/src/Skia/Perspex.Skia/RenderTarget.cs +++ b/src/Skia/Perspex.Skia/RenderTarget.cs @@ -50,6 +50,25 @@ namespace Perspex.Skia FixSize(); } +#if __IOS__ + private CGRect GetApplicationFrame() + { + // if we are excluding Status Bar then we use ApplicationFrame + // otherwise we use full screen bounds. Note that this must also match + // the Skia/PerspexView!!! + // + bool excludeStatusArea = false; // TODO: make this configurable later + if (excludeStatusArea) + { + return UIScreen.MainScreen.ApplicationFrame; + } + else + { + return UIScreen.MainScreen.Bounds; + } + } +#endif + void FixSize() { int width, height; @@ -83,7 +102,7 @@ namespace Perspex.Skia void GetPlatformWindowSize(IntPtr hwnd, out int w, out int h) { #if __IOS__ - var bounds = UIScreen.MainScreen.ApplicationFrame; + var bounds = GetApplicationFrame(); w = (int) bounds.Width; h = (int)bounds.Height; @@ -126,7 +145,8 @@ namespace Perspex.Skia #if __IOS__ const int bitmapInfo = ((int)CGBitmapFlags.ByteOrder32Big) | ((int)CGImageAlphaInfo.PremultipliedLast); - var bounds = UIScreen.MainScreen.ApplicationFrame; + var bounds = GetApplicationFrame(); + var statusBarOffset = UIScreen.MainScreen.Bounds.Height - bounds.Height; using (var colorSpace = CGColorSpace.CreateDeviceRGB()) using (var bContext = new CGBitmapContext(pixels, _bitmap.Width, _bitmap.Height, 8, _bitmap.Width * 4, colorSpace, (CGImageAlphaInfo)bitmapInfo)) @@ -134,7 +154,7 @@ namespace Perspex.Skia using (var context = UIGraphics.GetCurrentContext()) { // flip the image for CGContext.DrawImage - context.TranslateCTM(0, bounds.Height); // Frame.Height); + context.TranslateCTM(0, bounds.Height + statusBarOffset); context.ScaleCTM(1, -1); context.DrawImage(bounds, image); } diff --git a/src/Windows/Perspex.Win32/SystemDialogImpl.cs b/src/Windows/Perspex.Win32/SystemDialogImpl.cs index 84aa78a2a7..5cdcb0fac7 100644 --- a/src/Windows/Perspex.Win32/SystemDialogImpl.cs +++ b/src/Windows/Perspex.Win32/SystemDialogImpl.cs @@ -40,17 +40,20 @@ namespace Perspex.Win32 var filterBuffer = new char[filters.Length]; filters.CopyTo(0, filterBuffer, 0, filterBuffer.Length); - var defExt = (dialog as SaveFileDialog)?.DefaultExtension; + var defExt = (dialog as SaveFileDialog)?.DefaultExtension.ToArray(); var fileBuffer = new char[256]; dialog.InitialFileName?.CopyTo(0, fileBuffer, 0, dialog.InitialFileName.Length); string userSelectedExt = null; - - fixed (char* pFileBuffer = fileBuffer) + + var title = dialog.Title.ToArray(); + var initialDir = dialog.InitialDirectory.ToArray(); + + fixed (char* pFileBuffer = fileBuffer) fixed (char* pFilterBuffer = filterBuffer) fixed (char* pDefExt = defExt) - fixed (char* pInitDir = dialog.InitialDirectory) - fixed (char* pTitle = dialog.Title) + fixed (char* pInitDir = initialDir) + fixed (char* pTitle = title) { var ofn = new UnmanagedMethods.OpenFileName() { diff --git a/src/iOS/Perspex.iOS/PerspexView.cs b/src/iOS/Perspex.iOS/PerspexView.cs index e1df45192d..ef54a0ebc5 100644 --- a/src/iOS/Perspex.iOS/PerspexView.cs +++ b/src/iOS/Perspex.iOS/PerspexView.cs @@ -57,7 +57,8 @@ namespace Perspex.iOS (_controller.InterfaceOrientation == UIInterfaceOrientation.LandscapeLeft || _controller.InterfaceOrientation == UIInterfaceOrientation.LandscapeRight); - var frame = UIScreen.MainScreen.Bounds; + // Bounds here (if top level) needs to correspond with the rendertarget + var frame = UIScreen.MainScreen.Bounds; if (needFlip) Frame = new CGRect(frame.Y, frame.X, frame.Height, frame.Width); else diff --git a/src/iOS/Perspex.iOSTestApplication/AppDelegate.cs b/src/iOS/Perspex.iOSTestApplication/AppDelegate.cs index 9227062b13..1148796f3a 100644 --- a/src/iOS/Perspex.iOSTestApplication/AppDelegate.cs +++ b/src/iOS/Perspex.iOSTestApplication/AppDelegate.cs @@ -3,7 +3,9 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; using Foundation; +using Perspex.Controls; using Perspex.iOS; +using Perspex.Media; using Perspex.Threading; using TestApplication; using UIKit; @@ -29,12 +31,42 @@ namespace Perspex.iOSTestApplication var app = new App(); - MainWindow.RootNamespace = "Perspex.iOSTestApplication"; - var window = MainWindow.Create(); + MainWindow.RootNamespace = "Perspex.iOSTestApplication"; + var window = MainWindow.Create(); window.Show(); app.Run(window); return true; } + + // This provides a simple UI tree for testing input handling + public static Window Create() + { + Window window = new Window + { + Title = "Perspex Test Application", + //Width = 900, + //Height = 480, + Background = Brushes.Red, + Content = new Grid + { + Margin = new Thickness(100), + Background = Brushes.Yellow, + Children = new Controls.Controls + { + new Button + { + Content = "Hello World!", + Width = 200, + Height = 200 + } + } + } + }; + + return window; + } } + + } \ No newline at end of file diff --git a/src/iOS/Perspex.iOSTestApplication/Perspex.iOSTestApplication.csproj b/src/iOS/Perspex.iOSTestApplication/Perspex.iOSTestApplication.csproj index 63a5fc4e96..e7535d2212 100644 --- a/src/iOS/Perspex.iOSTestApplication/Perspex.iOSTestApplication.csproj +++ b/src/iOS/Perspex.iOSTestApplication/Perspex.iOSTestApplication.csproj @@ -20,7 +20,7 @@ 4 false i386 - None + SdkOnly true