mirror of
https://github.com/colhountech/DarkUI.Net5.git
synced 2025-07-23 20:11:32 +03:00
Fixed splitter highlights
This commit is contained in:
parent
3c71944591
commit
99b405be39
@ -193,7 +193,7 @@ namespace DarkUI
|
||||
base.OnLayout(e);
|
||||
|
||||
if (_splitter != null)
|
||||
_splitter.UpdateBounds();
|
||||
_splitter.UpdateBounds(DockPanel);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
@ -48,8 +48,10 @@ namespace DarkUI
|
||||
|
||||
public void ShowOverlay()
|
||||
{
|
||||
_overlayForm.Show();
|
||||
UpdateOverlay(new Point(0, 0));
|
||||
|
||||
_overlayForm.Show();
|
||||
_overlayForm.BringToFront();
|
||||
}
|
||||
|
||||
public void HideOverlay()
|
||||
@ -59,7 +61,7 @@ namespace DarkUI
|
||||
|
||||
public void UpdateOverlay(Point difference)
|
||||
{
|
||||
var bounds = _control.RectangleToScreen(Bounds);
|
||||
var bounds = new Rectangle(Bounds.Location, Bounds.Size);
|
||||
|
||||
switch (_splitterType)
|
||||
{
|
||||
@ -89,10 +91,10 @@ 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;
|
||||
@ -100,21 +102,26 @@ namespace DarkUI
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateBounds()
|
||||
public void UpdateBounds(Control rootControl)
|
||||
{
|
||||
if (rootControl == null)
|
||||
rootControl = _control;
|
||||
|
||||
var bounds = rootControl.RectangleToScreen(_control.Bounds);
|
||||
|
||||
switch (_splitterType)
|
||||
{
|
||||
case DarkSplitterType.Left:
|
||||
Bounds = new Rectangle(_control.Left - 2, _control.Top, 5, _control.Height);
|
||||
Bounds = new Rectangle(bounds.Left - 2, bounds.Top, 5, bounds.Height);
|
||||
break;
|
||||
case DarkSplitterType.Right:
|
||||
Bounds = new Rectangle(_control.Right - 3, _control.Top, 5, _control.Height);
|
||||
Bounds = new Rectangle(bounds.Right - 3, bounds.Top, 5, bounds.Height);
|
||||
break;
|
||||
case DarkSplitterType.Top:
|
||||
Bounds = new Rectangle(_control.Left, _control.Top - 2, _control.Width, 5);
|
||||
Bounds = new Rectangle(bounds.Left, bounds.Top - 2, bounds.Width, 5);
|
||||
break;
|
||||
case DarkSplitterType.Bottom:
|
||||
Bounds = new Rectangle(_control.Left, _control.Bottom - 5, _control.Width, 5);
|
||||
Bounds = new Rectangle(bounds.Left, bounds.Bottom - 5, bounds.Width, 5);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -69,13 +69,11 @@ namespace DarkUI
|
||||
// Start drag.
|
||||
if (m.Msg == (int)WM.LBUTTONDOWN)
|
||||
{
|
||||
foreach (var splitter in _dockPanel.Splitters)
|
||||
var hotSplitter = HotSplitter();
|
||||
if (hotSplitter != null)
|
||||
{
|
||||
if (splitter.Bounds.Contains(_dockPanel.PointToClient(Cursor.Position)))
|
||||
{
|
||||
StartDrag(splitter);
|
||||
return true;
|
||||
}
|
||||
StartDrag(hotSplitter);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -90,11 +88,8 @@ namespace DarkUI
|
||||
}
|
||||
|
||||
// Stop events passing through if we're hovering over a splitter
|
||||
foreach (var splitter in _dockPanel.Splitters)
|
||||
{
|
||||
if (splitter.Bounds.Contains(_dockPanel.PointToClient(Cursor.Position)))
|
||||
return true;
|
||||
}
|
||||
if (HotSplitter() != null)
|
||||
return true;
|
||||
|
||||
// Stop all events from going through if we're dragging a splitter.
|
||||
if (_isDragging)
|
||||
@ -142,8 +137,8 @@ namespace DarkUI
|
||||
|
||||
private void StopDrag()
|
||||
{
|
||||
_activeSplitter.HideOverlay();
|
||||
_dragTimer.Stop();
|
||||
_activeSplitter.HideOverlay();
|
||||
|
||||
var difference = new Point(_initialContact.X - Cursor.Position.X, _initialContact.Y - Cursor.Position.Y);
|
||||
_activeSplitter.Move(difference);
|
||||
@ -151,19 +146,25 @@ namespace DarkUI
|
||||
_isDragging = false;
|
||||
}
|
||||
|
||||
private DarkDockSplitter HotSplitter()
|
||||
{
|
||||
foreach (var splitter in _dockPanel.Splitters)
|
||||
{
|
||||
if (splitter.Bounds.Contains(Cursor.Position))
|
||||
return splitter;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
private void CheckCursor()
|
||||
{
|
||||
if (_isDragging)
|
||||
return;
|
||||
|
||||
foreach (var splitter in _dockPanel.Splitters)
|
||||
{
|
||||
if (splitter.Bounds.Contains(_dockPanel.PointToClient(Cursor.Position)))
|
||||
{
|
||||
Cursor.Current = splitter.ResizeCursor;
|
||||
return;
|
||||
}
|
||||
}
|
||||
var hotSplitter = HotSplitter();
|
||||
if (hotSplitter != null)
|
||||
Cursor.Current = hotSplitter.ResizeCursor;
|
||||
}
|
||||
|
||||
private void ResetCursor()
|
||||
|
Loading…
x
Reference in New Issue
Block a user