Browse Source

Fixes/cleanups to the Gtk/Cairo platforms

- Added PopupImpl support in Perspex.Gtk
- Added ShowDialog support to WindowImpl in Perspex.Gtk
- Fixed resize issues in Perspex.Gtk
- Renamed Centered to Center to match WPF in Cairo
- Removed old Serilog references breaking compile
pull/58/head
Nelson Carrillo 11 years ago
parent
commit
daf771ba2c
  1. 2
      Cairo/Perspex.Cairo/CairoExtensions.cs
  2. 1
      Gtk/Perspex.Gtk/GtkPlatform.cs
  3. 1
      Gtk/Perspex.Gtk/Perspex.Gtk.csproj
  4. 29
      Gtk/Perspex.Gtk/PopupImpl.cs
  5. 29
      Gtk/Perspex.Gtk/WindowImpl.cs
  6. 3
      TestApplication/Program.cs

2
Cairo/Perspex.Cairo/CairoExtensions.cs

@ -76,7 +76,7 @@ namespace Perspex.Cairo
return Pango.Alignment.Left;
}
if (alignment == Perspex.Media.TextAlignment.Centered)
if (alignment == Perspex.Media.TextAlignment.Center)
{
return Pango.Alignment.Center;
}

1
Gtk/Perspex.Gtk/GtkPlatform.cs

@ -40,6 +40,7 @@ namespace Perspex.Gtk
{
var locator = Locator.CurrentMutable;
locator.Register(() => new WindowImpl(), typeof(IWindowImpl));
locator.Register(() => new PopupImpl(), typeof(IPopupImpl));
locator.Register(() => GtkKeyboardDevice.Instance, typeof(IKeyboardDevice));
locator.Register(() => instance, typeof(IPlatformSettings));
locator.Register(() => instance, typeof(IPlatformThreadingInterface));

1
Gtk/Perspex.Gtk/Perspex.Gtk.csproj

@ -59,6 +59,7 @@
</ItemGroup>
<ItemGroup>
<Compile Include="GtkExtensions.cs" />
<Compile Include="PopupImpl.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="GtkPlatform.cs" />
<Compile Include="WindowImpl.cs" />

29
Gtk/Perspex.Gtk/PopupImpl.cs

@ -0,0 +1,29 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Perspex.Gtk
{
using System;
using Perspex.Platform;
using global::Gtk;
public class PopupImpl : WindowImpl, IPopupImpl
{
public PopupImpl()
: base(WindowType.Popup)
{
this.DefaultSize = new Gdk.Size(640, 480);
this.Events = Gdk.EventMask.PointerMotionMask |
Gdk.EventMask.ButtonPressMask |
Gdk.EventMask.ButtonReleaseMask;
}
public void SetPosition(Point p)
{
this.Move((int)p.X, (int)p.Y);
}
}
}

29
Gtk/Perspex.Gtk/WindowImpl.cs

@ -12,6 +12,7 @@ namespace Perspex.Gtk
using Perspex.Input.Raw;
using Perspex.Platform;
using Gtk = global::Gtk;
using System.Reactive.Disposables;
public class WindowImpl : Gtk.Window, IWindowImpl
{
@ -31,10 +32,20 @@ namespace Perspex.Gtk
this.windowHandle = new PlatformHandle(this.Handle, "GtkWindow");
}
public WindowImpl(Gtk.WindowType type)
: base(type)
{
this.DefaultSize = new Gdk.Size(640, 480);
this.Events = Gdk.EventMask.PointerMotionMask |
Gdk.EventMask.ButtonPressMask |
Gdk.EventMask.ButtonReleaseMask;
this.windowHandle = new PlatformHandle(this.Handle, "GtkWindow");
}
public Size ClientSize
{
get { return this.clientSize; }
set { this.Resize((int)value.Width, (int)value.Height); }
get;
set;
}
IPlatformHandle ITopLevelImpl.Handle
@ -56,12 +67,14 @@ namespace Perspex.Gtk
public IPopupImpl CreatePopup()
{
throw new NotImplementedException();
return new PopupImpl();
}
public void Invalidate(Rect rect)
{
this.QueueDraw();
#pragma warning disable CS0612 // Type or member is obsolete
this.Draw(new Gdk.Rectangle { X = (int)rect.X, Y = (int)rect.Y, Width = (int)rect.Width, Height = (int)rect.Height });
#pragma warning restore CS0612 // Type or member is obsolete
}
public Point PointToScreen(Point point)
@ -82,7 +95,10 @@ namespace Perspex.Gtk
public IDisposable ShowDialog()
{
throw new NotImplementedException();
this.Modal = true;
this.Show();
return Disposable.Empty;
}
void ITopLevelImpl.Activate()
@ -120,8 +136,7 @@ namespace Perspex.Gtk
if (newSize != this.clientSize)
{
this.clientSize = newSize;
this.Resized(this.clientSize);
this.Resized(newSize);
}
return true;

3
TestApplication/Program.cs

@ -17,9 +17,6 @@ using Perspex.Gtk;
#endif
using ReactiveUI;
using Splat;
using Serilog;
using Serilog.Filters;
using Serilog.Events;
namespace TestApplication
{

Loading…
Cancel
Save