mirror of
https://github.com/ShareX/ShareX.git
synced 2024-10-01 09:47:22 +13:00
Limit crop rectangle to inside canvas
This commit is contained in:
parent
8eaa3b198e
commit
91f203cd35
2 changed files with 19 additions and 3 deletions
|
@ -59,6 +59,8 @@ public Rectangle Rectangle
|
||||||
|
|
||||||
public bool IsInsideCanvas => !RectangleInsideCanvas.IsEmpty;
|
public bool IsInsideCanvas => !RectangleInsideCanvas.IsEmpty;
|
||||||
|
|
||||||
|
public virtual bool LimitRectangleToInsideCanvas { get; }
|
||||||
|
|
||||||
private Point startPosition;
|
private Point startPosition;
|
||||||
|
|
||||||
public Point StartPosition
|
public Point StartPosition
|
||||||
|
@ -219,6 +221,16 @@ public virtual void OnUpdate()
|
||||||
{
|
{
|
||||||
Move(InputManager.MouseVelocity);
|
Move(InputManager.MouseVelocity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckLimitRectangle();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void CheckLimitRectangle()
|
||||||
|
{
|
||||||
|
if (LimitRectangleToInsideCanvas)
|
||||||
|
{
|
||||||
|
Rectangle = RectangleInsideCanvas;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public virtual void OnShapePathRequested(GraphicsPath gp, Rectangle rect)
|
public virtual void OnShapePathRequested(GraphicsPath gp, Rectangle rect)
|
||||||
|
@ -379,6 +391,8 @@ public virtual void OnNodeUpdate()
|
||||||
|
|
||||||
Rectangle = newRect;
|
Rectangle = newRect;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CheckLimitRectangle();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,8 +32,10 @@ public class CropTool : BaseTool
|
||||||
{
|
{
|
||||||
public override ShapeType ShapeType { get; } = ShapeType.ToolCrop;
|
public override ShapeType ShapeType { get; } = ShapeType.ToolCrop;
|
||||||
|
|
||||||
|
public override bool LimitRectangleToInsideCanvas { get; } = true;
|
||||||
|
|
||||||
private ButtonObject confirmButton, cancelButton;
|
private ButtonObject confirmButton, cancelButton;
|
||||||
private int buttonOffset = 12;
|
private int buttonOffset = 15;
|
||||||
|
|
||||||
public override void OnUpdate()
|
public override void OnUpdate()
|
||||||
{
|
{
|
||||||
|
@ -53,7 +55,7 @@ public override void OnDraw(Graphics g)
|
||||||
{
|
{
|
||||||
if (IsValidShape)
|
if (IsValidShape)
|
||||||
{
|
{
|
||||||
Manager.DrawRegionArea(g, RectangleInsideCanvas, true);
|
Manager.DrawRegionArea(g, Rectangle, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,7 +84,7 @@ public override void OnCreated()
|
||||||
|
|
||||||
private void ConfirmButton_MousePressed(object sender, MouseEventArgs e)
|
private void ConfirmButton_MousePressed(object sender, MouseEventArgs e)
|
||||||
{
|
{
|
||||||
Manager.CropArea(RectangleInsideCanvas);
|
Manager.CropArea(Rectangle);
|
||||||
Remove();
|
Remove();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue