Browse Source

Fixing popup placement

pull/68/head
Nelson Carrillo 11 years ago
parent
commit
6ea6afe81d
  1. 8
      Gtk/Perspex.Gtk/PopupImpl.cs
  2. 9
      Gtk/Perspex.Gtk/WindowImpl.cs
  3. 4
      Perspex.Controls/ToolTip.cs

8
Gtk/Perspex.Gtk/PopupImpl.cs

@ -14,13 +14,9 @@ namespace Perspex.Gtk
{ {
public PopupImpl() public PopupImpl()
: base(WindowType.Popup) : 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) public void SetPosition(Point p)
{ {
this.Move((int)p.X, (int)p.Y); this.Move((int)p.X, (int)p.Y);

9
Gtk/Perspex.Gtk/WindowImpl.cs

@ -35,13 +35,12 @@ namespace Perspex.Gtk
public WindowImpl(Gtk.WindowType type) public WindowImpl(Gtk.WindowType type)
: base(type) : base(type)
{ {
this.DefaultSize = new Gdk.Size(640, 480);
this.Events = Gdk.EventMask.PointerMotionMask | this.Events = Gdk.EventMask.PointerMotionMask |
Gdk.EventMask.ButtonPressMask | Gdk.EventMask.ButtonPressMask |
Gdk.EventMask.ButtonReleaseMask; Gdk.EventMask.ButtonReleaseMask;
this.windowHandle = new PlatformHandle(this.Handle, "GtkWindow"); this.windowHandle = new PlatformHandle(this.Handle, "GtkWindow");
} }
public Size ClientSize public Size ClientSize
{ {
get; get;
@ -79,8 +78,10 @@ namespace Perspex.Gtk
public Point PointToScreen(Point point) public Point PointToScreen(Point point)
{ {
// TODO: Implement. int x, y;
return new Point(); this.GdkWindow.GetDeskrelativeOrigin(out x, out y);
return new Point(point.X + x, point.Y + y);
} }
public void SetOwner(TopLevel owner) public void SetOwner(TopLevel owner)

4
Perspex.Controls/ToolTip.cs

@ -116,8 +116,8 @@ namespace Perspex.Controls
((ISetLogicalParent)popup).SetParent(control); ((ISetLogicalParent)popup).SetParent(control);
} }
var cp = MouseDevice.Instance.GetPosition(control); var cp = MouseDevice.Instance?.GetPosition(control);
var position = control.PointToScreen(cp) + new Vector(0, 22); var position = control.PointToScreen(cp.HasValue ? cp.Value : new Point(0, 0)) + new Vector(0, 22);
((ToolTip)popup.Content).Content = GetTip(control); ((ToolTip)popup.Content).Content = GetTip(control);
popup.SetPosition(position); popup.SetPosition(position);

Loading…
Cancel
Save