Browse Source

Implemented BeginResizeDrag

pull/372/head
Nikita Tsukanov 11 years ago
parent
commit
ec2a319049
  1. 6
      src/Android/Perspex.Android/Platform/SkiaPlatform/WindowImpl.cs
  2. 9
      src/Gtk/Perspex.Gtk/WindowImpl.cs
  3. 1
      src/Perspex.Controls/Perspex.Controls.csproj
  4. 9
      src/Perspex.Controls/Platform/ITopLevelImpl.cs
  5. 1
      src/Perspex.Controls/Platform/PlatformManager.cs
  6. 6
      src/Perspex.Controls/TopLevel.cs
  7. 17
      src/Perspex.Controls/WindowEdge.cs
  8. 28
      src/Windows/Perspex.Win32/Interop/UnmanagedMethods.cs
  9. 20
      src/Windows/Perspex.Win32/WindowImpl.cs
  10. 6
      src/iOS/Perspex.iOS/PerspexView.cs

6
src/Android/Perspex.Android/Platform/SkiaPlatform/WindowImpl.cs

@ -9,6 +9,7 @@ using Perspex.Input.Raw;
using Perspex.Platform;
using Perspex.Skia.Android;
using System;
using Perspex.Controls;
namespace Perspex.Android.Platform.SkiaPlatform
{
@ -131,6 +132,11 @@ namespace Perspex.Android.Platform.SkiaPlatform
//Not supported
}
public void BeginResizeDrag(WindowEdge edge)
{
//Not supported
}
public IDisposable ShowDialog()
{
throw new NotImplementedException();

9
src/Gtk/Perspex.Gtk/WindowImpl.cs

@ -11,6 +11,7 @@ using Perspex.Platform;
using Perspex.Input;
using Perspex.Threading;
using Action = System.Action;
using WindowEdge = Perspex.Controls.WindowEdge;
namespace Perspex.Gtk
{
@ -170,6 +171,14 @@ namespace Perspex.Gtk
BeginMoveDrag(1, x, y, 0);
}
public void BeginResizeDrag(WindowEdge edge)
{
int x, y;
ModifierType mod;
Screen.RootWindow.GetPointer(out x, out y, out mod);
BeginResizeDrag((Gdk.WindowEdge) (int) edge, 1, x, y, 0);
}
public IDisposable ShowDialog()
{
Modal = true;

1
src/Perspex.Controls/Perspex.Controls.csproj

@ -171,6 +171,7 @@
<Compile Include="TreeView.cs" />
<Compile Include="TreeViewItem.cs" />
<Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="WindowEdge.cs" />
<Compile Include="WrapPanel.cs" />
</ItemGroup>
<ItemGroup>

9
src/Perspex.Controls/Platform/ITopLevelImpl.cs

@ -2,6 +2,7 @@
// Licensed under the MIT license. See licence.md file in the project root for full license information.
using System;
using Perspex.Controls;
using Perspex.Input;
using Perspex.Input.Raw;
@ -90,8 +91,14 @@ namespace Perspex.Platform
void Show();
/// <summary>
/// Starts moving a window with left button being held. Should be called from left mouse button press event handler
/// Starts moving a window with left button being held. Should be called from left mouse button press event handler.
/// </summary>
void BeginMoveDrag();
/// <summary>
/// Starts resizing a window. This function is used if an application has window resizing controls.
/// Should be called from left mouse button press event handler
/// </summary>
void BeginResizeDrag(WindowEdge edge);
}
}

1
src/Perspex.Controls/Platform/PlatformManager.cs

@ -175,6 +175,7 @@ namespace Perspex.Controls.Platform
public void Show() => _tl.Show();
public void BeginMoveDrag() => _tl.BeginMoveDrag();
public void BeginResizeDrag(WindowEdge edge) => _tl.BeginResizeDrag(edge);
public IDisposable ShowDialog() => _window.ShowDialog();

6
src/Perspex.Controls/TopLevel.cs

@ -369,5 +369,11 @@ namespace Perspex.Controls
/// Starts moving a window with left button being held. Should be called from left mouse button press event handler
/// </summary>
public void BeginMoveDrag() => PlatformImpl.BeginMoveDrag();
/// <summary>
/// Starts resizing a window. This function is used if an application has window resizing controls.
/// Should be called from left mouse button press event handler
/// </summary>
public void BeginResizeDrag(WindowEdge edge) => PlatformImpl.BeginResizeDrag(edge);
}
}

17
src/Perspex.Controls/WindowEdge.cs

@ -0,0 +1,17 @@
namespace Perspex.Controls
{
public enum WindowEdge
{
//Please don't reorder stuff here, I was lazy to write proper conversion code
//so the order of values is matching one from GTK
NorthWest = 0,
North,
NorthEast,
West,
East,
SouthWest,
South,
SouthEast,
}
}

28
src/Windows/Perspex.Win32/Interop/UnmanagedMethods.cs

@ -217,6 +217,34 @@ namespace Perspex.Win32.Interop
WA_CLICKACTIVE,
}
public enum HitTestValues
{
HTERROR = -2,
HTTRANSPARENT = -1,
HTNOWHERE = 0,
HTCLIENT = 1,
HTCAPTION = 2,
HTSYSMENU = 3,
HTGROWBOX = 4,
HTMENU = 5,
HTHSCROLL = 6,
HTVSCROLL = 7,
HTMINBUTTON = 8,
HTMAXBUTTON = 9,
HTLEFT = 10,
HTRIGHT = 11,
HTTOP = 12,
HTTOPLEFT = 13,
HTTOPRIGHT = 14,
HTBOTTOM = 15,
HTBOTTOMLEFT = 16,
HTBOTTOMRIGHT = 17,
HTBORDER = 18,
HTOBJECT = 19,
HTCLOSE = 20,
HTHELP = 21
}
[Flags]
public enum WindowStyles : uint
{

20
src/Windows/Perspex.Win32/WindowImpl.cs

@ -226,7 +226,25 @@ namespace Perspex.Win32
public void BeginMoveDrag()
{
UnmanagedMethods.DefWindowProc(_hwnd, (int) UnmanagedMethods.WindowsMessage.WM_NCLBUTTONDOWN,
new IntPtr(2), IntPtr.Zero);
new IntPtr((int)UnmanagedMethods.HitTestValues.HTCAPTION), IntPtr.Zero);
}
static readonly Dictionary<WindowEdge, UnmanagedMethods.HitTestValues> EdgeDic = new Dictionary<WindowEdge, UnmanagedMethods.HitTestValues>
{
{WindowEdge.East, UnmanagedMethods.HitTestValues.HTRIGHT},
{WindowEdge.North, UnmanagedMethods.HitTestValues.HTTOP },
{WindowEdge.NorthEast, UnmanagedMethods.HitTestValues.HTTOPRIGHT },
{WindowEdge.NorthWest, UnmanagedMethods.HitTestValues.HTTOPLEFT },
{WindowEdge.South, UnmanagedMethods.HitTestValues.HTBOTTOM },
{WindowEdge.SouthEast, UnmanagedMethods.HitTestValues.HTBOTTOMRIGHT },
{WindowEdge.SouthWest, UnmanagedMethods.HitTestValues.HTBOTTOMLEFT },
{WindowEdge.West, UnmanagedMethods.HitTestValues.HTLEFT}
};
public void BeginResizeDrag(WindowEdge edge)
{
UnmanagedMethods.DefWindowProc(_hwnd, (int) UnmanagedMethods.WindowsMessage.WM_NCLBUTTONDOWN,
new IntPtr((int) EdgeDic[edge]), IntPtr.Zero);
}
public virtual IDisposable ShowDialog()

6
src/iOS/Perspex.iOS/PerspexView.cs

@ -16,6 +16,7 @@ using Perspex.Skia.iOS;
using UIKit;
using Perspex.iOS.Specific;
using ObjCRuntime;
using Perspex.Controls;
namespace Perspex.iOS
{
@ -112,6 +113,11 @@ namespace Perspex.iOS
//Not supported
}
public void BeginResizeDrag(WindowEdge edge)
{
//Not supported
}
public Size MaxClientSize => Bounds.Size.ToPerspex();
public void SetTitle(string title)
{

Loading…
Cancel
Save