diff --git a/Perspex.sln b/Perspex.sln index 1dc7c56517..2c4c334a9c 100644 --- a/Perspex.sln +++ b/Perspex.sln @@ -101,6 +101,7 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Perspex.Markup.UnitTests", "tests\Perspex.Markup.UnitTests\Perspex.Markup.UnitTests.csproj", "{8EF392D5-1416-45AA-9956-7CBBC3229E8A}" EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BindingTest", "samples\BindingTest\BindingTest.csproj", "{08B3E6B9-1CD5-443C-9F61-6D49D1C5F162}" +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "XamlTestApplicationPcl", "samples\XamlTestApplicationPcl\XamlTestApplicationPcl.csproj", "{EA113F1A-D8D7-4142-9948-353270E7EBAE}" EndProject Global GlobalSection(SharedMSBuildProjectFiles) = preSolution @@ -253,6 +254,10 @@ Global {08B3E6B9-1CD5-443C-9F61-6D49D1C5F162}.Debug|Any CPU.Build.0 = Debug|Any CPU {08B3E6B9-1CD5-443C-9F61-6D49D1C5F162}.Release|Any CPU.ActiveCfg = Release|Any CPU {08B3E6B9-1CD5-443C-9F61-6D49D1C5F162}.Release|Any CPU.Build.0 = Release|Any CPU + {EA113F1A-D8D7-4142-9948-353270E7EBAE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {EA113F1A-D8D7-4142-9948-353270E7EBAE}.Debug|Any CPU.Build.0 = Debug|Any CPU + {EA113F1A-D8D7-4142-9948-353270E7EBAE}.Release|Any CPU.ActiveCfg = Release|Any CPU + {EA113F1A-D8D7-4142-9948-353270E7EBAE}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -281,5 +286,6 @@ Global {6417E941-21BC-467B-A771-0DE389353CE6} = {8B6A8209-894F-4BA1-B880-965FD453982C} {8EF392D5-1416-45AA-9956-7CBBC3229E8A} = {C5A00AC3-B34C-4564-9BDD-2DA473EF4D8B} {08B3E6B9-1CD5-443C-9F61-6D49D1C5F162} = {9B9E3891-2366-4253-A952-D08BCEB71098} + {EA113F1A-D8D7-4142-9948-353270E7EBAE} = {9B9E3891-2366-4253-A952-D08BCEB71098} EndGlobalSection EndGlobal diff --git a/samples/TestApplication/Program.cs b/samples/TestApplication/Program.cs index 83e6fad5e1..0df84054fc 100644 --- a/samples/TestApplication/Program.cs +++ b/samples/TestApplication/Program.cs @@ -737,9 +737,7 @@ namespace TestApplication Header = "Animations", Content = new StackPanel { - HorizontalAlignment = HorizontalAlignment.Left, Orientation = Orientation.Vertical, - VerticalAlignment = VerticalAlignment.Top, Gap = 4, Margin = new Thickness(10), Children = new Controls @@ -767,6 +765,7 @@ namespace TestApplication }), new Canvas { + ClipToBounds = false, Children = new Controls { (border1 = new Border diff --git a/samples/XamlTestApplication/App.cs b/samples/XamlTestApplication/App.cs index d0c6f59040..463d6ecebf 100644 --- a/samples/XamlTestApplication/App.cs +++ b/samples/XamlTestApplication/App.cs @@ -7,13 +7,11 @@ using Perspex.Themes.Default; namespace XamlTestApplication { - public class App : Application + public class App : XamlTestApp { - public App() + protected override void RegisterPlatform() { - RegisterServices(); InitializeSubsystems((int)Environment.OSVersion.Platform); - Styles = new DefaultTheme(); } } } diff --git a/samples/XamlTestApplication/Program.cs b/samples/XamlTestApplication/Program.cs index c79fa68899..1f1517d1f6 100644 --- a/samples/XamlTestApplication/Program.cs +++ b/samples/XamlTestApplication/Program.cs @@ -13,23 +13,6 @@ using XamlTestApplication.Views; namespace XamlTestApplication { - internal class Item - { - public string Name { get; set; } - public string Value { get; set; } - } - - internal class Node - { - public Node() - { - Children = new PerspexList(); - } - - public string Name { get; set; } - public PerspexList Children { get; set; } - } - internal class Program { private static void Main() @@ -38,21 +21,12 @@ namespace XamlTestApplication App application = new App { - DataTemplates = new DataTemplates - { - new FuncTreeDataTemplate( - x => new TextBlock { Text = x.Name }, - x => x.Children, - x => true), - }, - }; - var testCommand = ReactiveCommand.Create(); - testCommand.Subscribe(_ => Debug.WriteLine("Test command executed.")); + }; var window = new MainWindow(); window.Show(); Application.Current.Run(window); } } -} +} \ No newline at end of file diff --git a/samples/XamlTestApplication/XamlTestApplication.csproj b/samples/XamlTestApplication/XamlTestApplication.csproj index 107df97bcc..d384db9372 100644 --- a/samples/XamlTestApplication/XamlTestApplication.csproj +++ b/samples/XamlTestApplication/XamlTestApplication.csproj @@ -79,10 +79,6 @@ - - - - @@ -148,17 +144,13 @@ {811A76CF-1CF6-440F-963B-BBE31BD72A82} Perspex.Win32 - - - - PreserveNewest - + + {ea113f1a-d8d7-4142-9948-353270e7ebae} + XamlTestApplicationPcl + - - Designer - diff --git a/samples/XamlTestApplicationPcl/Properties/AssemblyInfo.cs b/samples/XamlTestApplicationPcl/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..3614e93d10 --- /dev/null +++ b/samples/XamlTestApplicationPcl/Properties/AssemblyInfo.cs @@ -0,0 +1,30 @@ +using System.Resources; +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("XamlTestApplicationPcl")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("")] +[assembly: AssemblyProduct("XamlTestApplicationPcl")] +[assembly: AssemblyCopyright("Copyright © 2015")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] +[assembly: NeutralResourcesLanguage("en")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] diff --git a/samples/XamlTestApplication/ViewModels/MainWindowViewModel.cs b/samples/XamlTestApplicationPcl/ViewModels/MainWindowViewModel.cs similarity index 100% rename from samples/XamlTestApplication/ViewModels/MainWindowViewModel.cs rename to samples/XamlTestApplicationPcl/ViewModels/MainWindowViewModel.cs diff --git a/samples/XamlTestApplication/ViewModels/TestItem.cs b/samples/XamlTestApplicationPcl/ViewModels/TestItem.cs similarity index 100% rename from samples/XamlTestApplication/ViewModels/TestItem.cs rename to samples/XamlTestApplicationPcl/ViewModels/TestItem.cs diff --git a/samples/XamlTestApplication/ViewModels/TestNode.cs b/samples/XamlTestApplicationPcl/ViewModels/TestNode.cs similarity index 100% rename from samples/XamlTestApplication/ViewModels/TestNode.cs rename to samples/XamlTestApplicationPcl/ViewModels/TestNode.cs diff --git a/samples/XamlTestApplication/Views/MainWindow.cs b/samples/XamlTestApplicationPcl/Views/MainWindow.cs similarity index 100% rename from samples/XamlTestApplication/Views/MainWindow.cs rename to samples/XamlTestApplicationPcl/Views/MainWindow.cs diff --git a/samples/XamlTestApplication/Views/MainWindow.paml b/samples/XamlTestApplicationPcl/Views/MainWindow.paml similarity index 100% rename from samples/XamlTestApplication/Views/MainWindow.paml rename to samples/XamlTestApplicationPcl/Views/MainWindow.paml diff --git a/samples/XamlTestApplicationPcl/XamlTestApp.cs b/samples/XamlTestApplicationPcl/XamlTestApp.cs new file mode 100644 index 0000000000..5683213631 --- /dev/null +++ b/samples/XamlTestApplicationPcl/XamlTestApp.cs @@ -0,0 +1,22 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Perspex; +using Perspex.Themes.Default; + +namespace XamlTestApplication +{ + public abstract class XamlTestApp : Application + { + protected abstract void RegisterPlatform(); + + public XamlTestApp() + { + RegisterServices(); + RegisterPlatform(); + Styles = new DefaultTheme(); + } + } +} diff --git a/samples/XamlTestApplicationPcl/XamlTestApplicationPcl.csproj b/samples/XamlTestApplicationPcl/XamlTestApplicationPcl.csproj new file mode 100644 index 0000000000..3cc33712f7 --- /dev/null +++ b/samples/XamlTestApplicationPcl/XamlTestApplicationPcl.csproj @@ -0,0 +1,130 @@ + + + + + 10.0 + Debug + AnyCPU + {EA113F1A-D8D7-4142-9948-353270E7EBAE} + Library + Properties + XamlTestApplication + XamlTestApplicationPcl + en-US + 512 + {786C830F-07A1-408B-BD7F-6EE04809D6DB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + Profile7 + v4.5 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + + Designer + + + + + + + + + + + + + PreserveNewest + + + + + {3e53a01a-b331-47f3-b828-4a5717e77a24} + Perspex.Markup.Xaml + + + {d211e587-d8bc-45b9-95a4-f297c8fa5200} + Perspex.Animation + + + {799a7bb5-3c2c-48b6-85a7-406a12c420da} + Perspex.Application + + + {b09b78d8-9b26-48b0-9149-d64a2f120f3f} + Perspex.Base + + + {d2221c82-4a25-4583-9b43-d791e3f6820c} + Perspex.Controls + + + {7062ae20-5dcc-4442-9645-8195bdece63e} + Perspex.Diagnostics + + + {5fb2b005-0a7f-4dad-add4-3ed01444e63d} + Perspex.HtmlRenderer + + + {62024b2d-53eb-4638-b26b-85eeaa54866e} + Perspex.Input + + + {6b0ed19d-a08b-461c-a9d9-a9ee40b0c06b} + Perspex.Interactivity + + + {42472427-4774-4c81-8aff-9f27b8e31721} + Perspex.Layout + + + {6417b24e-49c2-4985-8db2-3ab9d898ec91} + Perspex.ReactiveUI + + + {eb582467-6abb-43a1-b052-e981ba910e3a} + Perspex.SceneGraph + + + {f1baa01a-f176-4c6a-b39d-5b40bb1b148f} + Perspex.Styling + + + {3e10a5fa-e8da-48b1-ad44-6a5b6cb7750f} + Perspex.Themes.Default + + + + + ..\..\packages\Splat.1.6.2\lib\Portable-net45+win+wpa81+wp80\Splat.dll + True + + + + + + + + \ No newline at end of file diff --git a/samples/XamlTestApplication/github_icon.png b/samples/XamlTestApplicationPcl/github_icon.png similarity index 100% rename from samples/XamlTestApplication/github_icon.png rename to samples/XamlTestApplicationPcl/github_icon.png diff --git a/samples/XamlTestApplicationPcl/packages.config b/samples/XamlTestApplicationPcl/packages.config new file mode 100644 index 0000000000..2115574cc5 --- /dev/null +++ b/samples/XamlTestApplicationPcl/packages.config @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/src/Gtk/Perspex.Cairo/CairoPlatform.cs b/src/Gtk/Perspex.Cairo/CairoPlatform.cs index 55da932a59..a4bf08c4ea 100644 --- a/src/Gtk/Perspex.Cairo/CairoPlatform.cs +++ b/src/Gtk/Perspex.Cairo/CairoPlatform.cs @@ -36,9 +36,13 @@ namespace Perspex.Cairo return new FormattedTextImpl(s_pangoContext, text, fontFamily, fontSize, fontStyle, textAlignment, fontWeight); } - public IRenderer CreateRenderer(IPlatformHandle handle, double width, double height) + public IRenderTarget CreateRenderer(IPlatformHandle handle, double width, double height) { - return new Renderer(handle, width, height); + if (handle.HandleDescriptor != "GtkWindow") + throw new NotSupportedException(string.Format( + "Don't know how to create a Cairo renderer from a '{0}' handle", + handle.HandleDescriptor)); + return new RenderTarget((Gtk.Window)handle, width, height); } public IRenderTargetBitmapImpl CreateRenderTargetBitmap(int width, int height) diff --git a/src/Gtk/Perspex.Cairo/Media/DrawingContext.cs b/src/Gtk/Perspex.Cairo/Media/DrawingContext.cs index f7524fad43..f8c74f3f8f 100644 --- a/src/Gtk/Perspex.Cairo/Media/DrawingContext.cs +++ b/src/Gtk/Perspex.Cairo/Media/DrawingContext.cs @@ -4,6 +4,7 @@ using System; using System.Linq; using System.Reactive.Disposables; +using System.Runtime.InteropServices; using Perspex.Cairo.Media.Imaging; using Perspex.Media; @@ -191,7 +192,7 @@ namespace Perspex.Cairo.Media /// /// The brush. /// The rectangle bounds. - public void FillRectange(Brush brush, Rect rect, float cornerRadius) + public void FillRectangle(Brush brush, Rect rect, float cornerRadius) { using (var b = SetBrush(brush, rect.Size)) { @@ -200,6 +201,8 @@ namespace Perspex.Cairo.Media } } + private static Random Random = new Random(); + /// /// Pushes a clip rectange. /// @@ -207,10 +210,11 @@ namespace Perspex.Cairo.Media /// A disposable used to undo the clip rectangle. public IDisposable PushClip(Rect clip) { + _context.Save(); _context.Rectangle(clip.ToCairo()); _context.Clip(); - return Disposable.Create(() => _context.ResetClip()); + return Disposable.Create(() => _context.Restore()); } /// @@ -238,11 +242,12 @@ namespace Perspex.Cairo.Media /// A disposable used to undo the transformation. public IDisposable PushTransform(Matrix matrix) { + _context.Save(); _context.Transform(matrix.ToCairo()); return Disposable.Create(() => { - _context.Transform(matrix.Invert().ToCairo()); + _context.Restore(); }); } diff --git a/src/Gtk/Perspex.Cairo/Media/Imaging/RenderTargetBitmapImpl.cs b/src/Gtk/Perspex.Cairo/Media/Imaging/RenderTargetBitmapImpl.cs index db35a22775..0b9183d928 100644 --- a/src/Gtk/Perspex.Cairo/Media/Imaging/RenderTargetBitmapImpl.cs +++ b/src/Gtk/Perspex.Cairo/Media/Imaging/RenderTargetBitmapImpl.cs @@ -2,7 +2,9 @@ // Licensed under the MIT license. See licence.md file in the project root for full license information. using System; +using Perspex.Media; using Perspex.Platform; +using Perspex.Rendering; namespace Perspex.Cairo.Media.Imaging { @@ -10,10 +12,12 @@ namespace Perspex.Cairo.Media.Imaging public class RenderTargetBitmapImpl : IRenderTargetBitmapImpl { + + private readonly RenderTarget _renderTarget; public RenderTargetBitmapImpl(Cairo.ImageSurface surface) { Surface = surface; - renderer = new Renderer(Surface); + _renderTarget = new RenderTarget(Surface); } public int PixelWidth => Surface.Width; @@ -22,7 +26,7 @@ namespace Perspex.Cairo.Media.Imaging public void Dispose() { - renderer.Dispose(); + _renderTarget.Dispose(); } public Cairo.ImageSurface Surface @@ -30,15 +34,19 @@ namespace Perspex.Cairo.Media.Imaging get; } - private Renderer renderer; - public void Render(IVisual visual) + public void Save(string fileName) { - renderer.Render(visual, new PlatformHandle(IntPtr.Zero, "RTB")); + Surface.WriteToPng(fileName); } - public void Save(string fileName) + public IDrawingContext CreateDrawingContext() { - Surface.WriteToPng(fileName); + return _renderTarget.CreateDrawingContext(); + } + + void IRenderTarget.Resize(int width, int height) + { + throw new NotSupportedException(); } } } \ No newline at end of file diff --git a/src/Gtk/Perspex.Cairo/Media/TileBrushes.cs b/src/Gtk/Perspex.Cairo/Media/TileBrushes.cs index e08565785a..94fb19ea0b 100644 --- a/src/Gtk/Perspex.Cairo/Media/TileBrushes.cs +++ b/src/Gtk/Perspex.Cairo/Media/TileBrushes.cs @@ -7,6 +7,7 @@ using Perspex.Cairo.Media.Imaging; using Perspex.Layout; using Perspex.Media; using Perspex.Platform; +using Perspex.Rendering; namespace Perspex.Cairo.Media { @@ -100,7 +101,7 @@ namespace Perspex.Cairo.Media var intermediateSize = CalculateIntermediateSize(tileMode, targetSize, destinationRect.Size); using (var intermediate = new ImageSurface(Format.ARGB32, (int)intermediateSize.Width, (int)intermediateSize.Height)) - using (var context = new Context(intermediate)) + using (var ctx = new RenderTarget(intermediate).CreateDrawingContext()) { Rect drawRect; var transform = CalculateIntermediateTransform( @@ -110,12 +111,12 @@ namespace Perspex.Cairo.Media scale, translate, out drawRect); - var renderer = new Renderer(intermediate); - context.Rectangle(drawRect.ToCairo()); - context.Clip(); - context.Transform(transform.ToCairo()); - renderer.Render(visual, new PlatformHandle(IntPtr.Zero, "RTB"), transform, drawRect); + using (ctx.PushClip(drawRect)) + using (ctx.PushTransform(transform)) + { + ctx.Render(visual); + } var result = new SurfacePattern(intermediate); diff --git a/src/Gtk/Perspex.Cairo/Perspex.Cairo.csproj b/src/Gtk/Perspex.Cairo/Perspex.Cairo.csproj index e389fac5b2..77deb8f6b3 100644 --- a/src/Gtk/Perspex.Cairo/Perspex.Cairo.csproj +++ b/src/Gtk/Perspex.Cairo/Perspex.Cairo.csproj @@ -61,7 +61,7 @@ - + diff --git a/src/Gtk/Perspex.Cairo/RenderTarget.cs b/src/Gtk/Perspex.Cairo/RenderTarget.cs new file mode 100644 index 0000000000..333c558e8a --- /dev/null +++ b/src/Gtk/Perspex.Cairo/RenderTarget.cs @@ -0,0 +1,63 @@ +// Copyright (c) The Perspex Project. All rights reserved. +// Licensed under the MIT license. See licence.md file in the project root for full license information. + +using System; +using System.Runtime.InteropServices; +using Perspex.Cairo.Media; +using Perspex.Media; +using Perspex.Platform; +using Perspex.Rendering; + +namespace Perspex.Cairo +{ + using global::Cairo; + + /// + /// A cairo render target. + /// + public class RenderTarget : IRenderTarget + { + private readonly Surface _surface; + private Gtk.Window _window; + + /// + /// Initializes a new instance of the class. + /// + /// The window. + /// The width of the window. + /// The height of the window. + public RenderTarget(Gtk.Window window, double width, double height) + { + _window = window; + } + + public RenderTarget(ImageSurface surface) + { + _surface = surface; + } + + /// + /// Resizes the renderer. + /// + /// The new width. + /// The new height. + public void Resize(int width, int height) + { + // Don't need to do anything here. + } + + + /// + /// Creates a cairo surface that targets a platform-specific resource. + /// + /// A surface wrapped in an . + public IDrawingContext CreateDrawingContext() + { + if(_surface != null) + return new DrawingContext(_surface); + return new DrawingContext(_window.GdkWindow); + } + + public void Dispose() => _surface?.Dispose(); + } +} diff --git a/src/Gtk/Perspex.Cairo/Renderer.cs b/src/Gtk/Perspex.Cairo/Renderer.cs deleted file mode 100644 index 13bb63445f..0000000000 --- a/src/Gtk/Perspex.Cairo/Renderer.cs +++ /dev/null @@ -1,81 +0,0 @@ -// Copyright (c) The Perspex Project. All rights reserved. -// Licensed under the MIT license. See licence.md file in the project root for full license information. - -using System; -using System.Runtime.InteropServices; -using Perspex.Cairo.Media; -using Perspex.Media; -using Perspex.Platform; -using Perspex.Rendering; - -namespace Perspex.Cairo -{ - using global::Cairo; - - /// - /// A cairo renderer. - /// - public class Renderer : RendererBase - { - private readonly Surface _surface; - private Gdk.Window _window; - - /// - /// Initializes a new instance of the class. - /// - /// The window handle. - /// The width of the window. - /// The height of the window. - public Renderer(IPlatformHandle handle, double width, double height) - { - } - - public Renderer(ImageSurface surface) - { - _surface = surface; - } - - /// - /// Resizes the renderer. - /// - /// The new width. - /// The new height. - public override void Resize(int width, int height) - { - // Don't need to do anything here. - } - - - /// - /// Creates a cairo surface that targets a platform-specific resource. - /// - /// The platform-specific handle. - /// A surface wrapped in an . - protected override IDrawingContext CreateDrawingContext(IPlatformHandle handle) - { - switch (handle.HandleDescriptor) - { - case "RTB": - return new DrawingContext(_surface); - case "GdkWindow": - if (_window == null) - _window = new Gdk.Window(handle.Handle); - - return new DrawingContext(_window); - default: - throw new NotSupportedException(string.Format( - "Don't know how to create a Cairo renderer from a '{0}' handle", - handle.HandleDescriptor)); - } - } - - [DllImport("user32.dll")] - private static extern IntPtr GetDC(IntPtr hwnd); - - public override void Dispose() - { - if (_surface != null) - _surface.Dispose(); - } - } -} diff --git a/src/Gtk/Perspex.Gtk/WindowImpl.cs b/src/Gtk/Perspex.Gtk/WindowImpl.cs index 1914207d08..503ca9266a 100644 --- a/src/Gtk/Perspex.Gtk/WindowImpl.cs +++ b/src/Gtk/Perspex.Gtk/WindowImpl.cs @@ -14,12 +14,10 @@ namespace Perspex.Gtk { using Gtk = global::Gtk; - public class WindowImpl : Gtk.Window, IWindowImpl + public class WindowImpl : Gtk.Window, IWindowImpl, IPlatformHandle { private IInputRoot _inputRoot; - - private IPlatformHandle _windowHandle; - + private Size _clientSize; private Gtk.IMContext _imContext; @@ -46,7 +44,6 @@ namespace Perspex.Gtk Events = EventMask.PointerMotionMask | EventMask.ButtonPressMask | EventMask.ButtonReleaseMask; - _windowHandle = new PlatformHandle(Handle, "GtkWindow"); _imContext = new Gtk.IMMulticontext(); _imContext.Commit += ImContext_Commit; } @@ -73,7 +70,8 @@ namespace Perspex.Gtk } } - IPlatformHandle ITopLevelImpl.Handle => _windowHandle; + IPlatformHandle ITopLevelImpl.Handle => this; + public string HandleDescriptor => "GtkWindow"; public Action Activated { get; set; } @@ -83,7 +81,7 @@ namespace Perspex.Gtk public Action Input { get; set; } - public Action Paint { get; set; } + public Action Paint { get; set; } public Action Resized { get; set; } @@ -94,7 +92,9 @@ namespace Perspex.Gtk public void Invalidate(Rect rect) { - base.GdkWindow.InvalidateRect (new Rectangle ((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height), true); + if (base.GdkWindow != null) + base.GdkWindow.InvalidateRect( + new Rectangle((int) rect.X, (int) rect.Y, (int) rect.Width, (int) rect.Height), true); } public Point PointToScreen(Point point) @@ -167,6 +167,23 @@ namespace Perspex.Gtk return true; } + protected override bool OnScrollEvent(EventScroll evnt) + { + double step = 1; + var delta = new Vector(); + if (evnt.Direction == ScrollDirection.Down) + delta = new Vector(0, -step); + else if (evnt.Direction == ScrollDirection.Up) + delta = new Vector(0, step); + else if (evnt.Direction == ScrollDirection.Right) + delta = new Vector(-step, 0); + if (evnt.Direction == ScrollDirection.Left) + delta = new Vector(step, 0); + var e = new RawMouseWheelEventArgs(GtkMouseDevice.Instance, evnt.Time, _inputRoot, new Point(evnt.X, evnt.Y), delta, GetModifierKeys(evnt.State)); + Input(e); + return base.OnScrollEvent(evnt); + } + protected override bool OnButtonReleaseEvent(EventButton evnt) { var e = new RawMouseEventArgs( @@ -223,7 +240,7 @@ namespace Perspex.Gtk protected override bool OnExposeEvent(EventExpose evnt) { - Paint(evnt.Area.ToPerspex(), GetHandle(evnt.Window)); + Paint(evnt.Area.ToPerspex()); return true; } diff --git a/src/Perspex.Application/Application.cs b/src/Perspex.Application/Application.cs index f0a3c1a8ee..88f3a23ffe 100644 --- a/src/Perspex.Application/Application.cs +++ b/src/Perspex.Application/Application.cs @@ -168,7 +168,7 @@ namespace Perspex .Bind().ToTransient() .Bind().ToConstant(_styler) .Bind().ToTransient() - .Bind().ToTransient(); + .Bind().ToTransient(); } /// diff --git a/src/Perspex.Controls/Border.cs b/src/Perspex.Controls/Border.cs index 1d8a3524d6..8a70987cb0 100644 --- a/src/Perspex.Controls/Border.cs +++ b/src/Perspex.Controls/Border.cs @@ -93,7 +93,7 @@ namespace Perspex.Controls if (background != null) { - context.FillRectange(background, rect, cornerRadius); + context.FillRectangle(background, rect, cornerRadius); } if (borderBrush != null && borderThickness > 0) diff --git a/src/Perspex.Controls/MenuItem.cs b/src/Perspex.Controls/MenuItem.cs index 0acc7ae20f..5a7eef3b28 100644 --- a/src/Perspex.Controls/MenuItem.cs +++ b/src/Perspex.Controls/MenuItem.cs @@ -29,7 +29,7 @@ namespace Perspex.Controls Button.CommandProperty.AddOwner(); public static readonly PerspexProperty HotKeyProperty = - HotKeyManager.HotKeyProperty.AddOwner