Fixed PointToScreen issues with splitters

This commit is contained in:
Robin 2015-09-19 17:56:37 +01:00
parent 99b405be39
commit a463149ad7
3 changed files with 27 additions and 35 deletions

View File

@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Windows.Forms;
@ -169,13 +170,13 @@ namespace DarkUI
switch (DockArea)
{
case DarkDockArea.Left:
_splitter = new DarkDockSplitter(this, DarkSplitterType.Right);
_splitter = new DarkDockSplitter(DockPanel, this, DarkSplitterType.Right);
break;
case DarkDockArea.Right:
_splitter = new DarkDockSplitter(this, DarkSplitterType.Left);
_splitter = new DarkDockSplitter(DockPanel, this, DarkSplitterType.Left);
break;
case DarkDockArea.Bottom:
_splitter = new DarkDockSplitter(this, DarkSplitterType.Top);
_splitter = new DarkDockSplitter(DockPanel, this, DarkSplitterType.Top);
break;
default:
return;
@ -193,7 +194,7 @@ namespace DarkUI
base.OnLayout(e);
if (_splitter != null)
_splitter.UpdateBounds(DockPanel);
_splitter.UpdateBounds();
}
#endregion

View File

@ -1,4 +1,5 @@
using System.Drawing;
using System;
using System.Drawing;
using System.Windows.Forms;
namespace DarkUI
@ -7,6 +8,7 @@ namespace DarkUI
{
#region Field Region
private Control _parentControl;
private Control _control;
private DarkSplitterType _splitterType;
private DarkTranslucentForm _overlayForm;
@ -23,8 +25,9 @@ namespace DarkUI
#region Constructor Region
public DarkDockSplitter(Control control, DarkSplitterType splitterType)
public DarkDockSplitter(Control parentControl, Control control, DarkSplitterType splitterType)
{
_parentControl = parentControl;
_control = control;
_splitterType = splitterType;
_overlayForm = new DarkTranslucentForm(Color.Black);
@ -91,23 +94,22 @@ namespace DarkUI
_control.Width += difference.X;
break;
case DarkSplitterType.Right:
_control.Width += difference.X;
_control.Width -= difference.X;
break;
case DarkSplitterType.Top:
_control.Height -= difference.Y;
_control.Height += difference.Y;
break;
case DarkSplitterType.Bottom:
_control.Height -= difference.Y;
break;
}
UpdateBounds();
}
public void UpdateBounds(Control rootControl)
public void UpdateBounds()
{
if (rootControl == null)
rootControl = _control;
var bounds = rootControl.RectangleToScreen(_control.Bounds);
var bounds = _parentControl.RectangleToScreen(_control.Bounds);
switch (_splitterType)
{

View File

@ -40,6 +40,16 @@ namespace DarkUI
m.Msg == (int)WM.RBUTTONDOWN || m.Msg == (int)WM.RBUTTONUP || m.Msg == (int)WM.RBUTTONDBLCLK))
return false;
// Stop drag.
if (m.Msg == (int)WM.LBUTTONUP)
{
if (_isDragging)
{
StopDrag();
return true;
}
}
// Exit out early if we're simply releasing a non-splitter drag over the area
if (m.Msg == (int)WM.LBUTTONUP && !_isDragging)
return false;
@ -77,16 +87,6 @@ namespace DarkUI
}
}
// Stop drag.
if (m.Msg == (int)WM.LBUTTONUP)
{
if (_isDragging)
{
StopDrag();
return true;
}
}
// Stop events passing through if we're hovering over a splitter
if (HotSplitter() != null)
return true;
@ -104,17 +104,6 @@ namespace DarkUI
private void DragTimer_Tick(object sender, EventArgs e)
{
if (_dockPanel.MouseButtonState != MouseButtons.Left)
_isDragging = false;
if (!_isDragging)
{
_activeSplitter.HideOverlay();
_dragTimer.Stop();
ResetCursor();
return;
}
var difference = new Point(_initialContact.X - Cursor.Position.X, _initialContact.Y - Cursor.Position.Y);
_activeSplitter.UpdateOverlay(difference);
}