mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-15 03:16:05 +12:00
Two point node dragging support
This commit is contained in:
parent
c4f7268106
commit
67643f5b0f
|
@ -284,16 +284,23 @@ protected new virtual void Update()
|
|||
|
||||
DrawableObject[] objects = DrawableObjects.OrderByDescending(x => x.Order).ToArray();
|
||||
|
||||
if (objects.All(x => x.Visible && !x.IsDragging))
|
||||
if (objects.All(x => !x.IsDragging))
|
||||
{
|
||||
for (int i = 0; i < objects.Count(); i++)
|
||||
{
|
||||
DrawableObject obj = objects[i];
|
||||
|
||||
if (obj.Visible)
|
||||
{
|
||||
obj.IsMouseHover = obj.Rectangle.Contains(InputManager.MousePosition0Based);
|
||||
|
||||
if (obj.IsMouseHover)
|
||||
{
|
||||
if (InputManager.IsMousePressed(MouseButtons.Left))
|
||||
{
|
||||
obj.IsDragging = true;
|
||||
}
|
||||
|
||||
for (int y = i + 1; y < objects.Count(); y++)
|
||||
{
|
||||
objects[y].IsMouseHover = false;
|
||||
|
@ -302,14 +309,6 @@ protected new virtual void Update()
|
|||
break;
|
||||
}
|
||||
}
|
||||
|
||||
foreach (DrawableObject obj in objects)
|
||||
{
|
||||
if (obj.IsMouseHover && InputManager.IsMousePressed(MouseButtons.Left))
|
||||
{
|
||||
obj.IsDragging = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
|
|
|
@ -60,6 +60,11 @@ public override void Draw(Graphics g)
|
|||
{
|
||||
Rectangle rect = new Rectangle((int)Rectangle.X, (int)Rectangle.Y, (int)Rectangle.Width - 1, (int)Rectangle.Height - 1);
|
||||
|
||||
if (IsMouseHover)
|
||||
{
|
||||
rect.Inflate(1, 1);
|
||||
}
|
||||
|
||||
switch (Shape)
|
||||
{
|
||||
case NodeShape.Square:
|
||||
|
|
|
@ -111,9 +111,13 @@ public ResizeManager(SurfaceForm surface, AreaManager areaManager)
|
|||
|
||||
public void Update()
|
||||
{
|
||||
if (Visible && nodes != null)
|
||||
BaseShape shape = areaManager.CurrentShape;
|
||||
|
||||
if (shape != null && Visible && nodes != null)
|
||||
{
|
||||
if (InputManager.IsMouseDown(MouseButtons.Left))
|
||||
{
|
||||
if (shape.NodeType == NodeType.Rectangle)
|
||||
{
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
|
@ -123,7 +127,7 @@ public void Update()
|
|||
|
||||
if (!InputManager.IsBeforeMouseDown(MouseButtons.Left))
|
||||
{
|
||||
tempRect = areaManager.CurrentRectangle;
|
||||
tempRect = shape.Rectangle;
|
||||
}
|
||||
|
||||
NodePosition nodePosition = (NodePosition)i;
|
||||
|
@ -162,12 +166,26 @@ public void Update()
|
|||
break;
|
||||
}
|
||||
|
||||
areaManager.CurrentRectangle = CaptureHelpers.FixRectangle(tempRect);
|
||||
shape.Rectangle = CaptureHelpers.FixRectangle(tempRect);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (shape.NodeType == NodeType.Line)
|
||||
{
|
||||
if (nodes[(int)NodePosition.TopLeft].IsDragging)
|
||||
{
|
||||
IsResizing = true;
|
||||
shape.StartPosition = new Point(InputManager.MousePosition0Based.X, InputManager.MousePosition0Based.Y);
|
||||
}
|
||||
else if (nodes[(int)NodePosition.BottomRight].IsDragging)
|
||||
{
|
||||
IsResizing = true;
|
||||
shape.EndPosition = new Point(InputManager.MousePosition0Based.X, InputManager.MousePosition0Based.Y);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IsResizing = false;
|
||||
|
@ -257,13 +275,10 @@ public void Hide()
|
|||
Visible = false;
|
||||
}
|
||||
|
||||
public void UpdateNodePositions()
|
||||
private void UpdateNodePositions()
|
||||
{
|
||||
UpdateNodePositions(areaManager.CurrentShape);
|
||||
}
|
||||
BaseShape shape = areaManager.CurrentShape;
|
||||
|
||||
private void UpdateNodePositions(BaseShape shape)
|
||||
{
|
||||
if (shape != null)
|
||||
{
|
||||
if (shape.NodeType == NodeType.Rectangle)
|
||||
|
|
Loading…
Reference in a new issue