mirror of
https://github.com/greenshot/greenshot
synced 2025-08-21 05:53:27 -07:00
BUG-1682: Keep the target gripper inside the surface
This commit is contained in:
parent
bba978c209
commit
469cfff275
2 changed files with 34 additions and 19 deletions
|
@ -85,11 +85,6 @@ namespace Greenshot.Drawing {
|
|||
AddField(GetType(), FieldType.TEXT_VERTICAL_ALIGNMENT, VerticalAlignment.CENTER);
|
||||
}
|
||||
|
||||
protected override void TargetGripperMove(int absX, int absY) {
|
||||
base.TargetGripperMove(absX, absY);
|
||||
Invalidate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Called from Surface (the _parent) when the drawing begins (mouse-down)
|
||||
/// </summary>
|
||||
|
@ -108,22 +103,23 @@ namespace Greenshot.Drawing {
|
|||
/// </summary>
|
||||
/// <param name="x"></param>
|
||||
/// <param name="y"></param>
|
||||
/// <returns></returns>
|
||||
/// <returns>base.HandleMouseMove</returns>
|
||||
public override bool HandleMouseMove(int x, int y) {
|
||||
bool returnValue = base.HandleMouseMove(x, y);
|
||||
|
||||
bool leftAligned = _boundsAfterResize.Right - _boundsAfterResize.Left >= 0;
|
||||
bool topAligned = _boundsAfterResize.Bottom - _boundsAfterResize.Top >= 0;
|
||||
|
||||
int xOffset = leftAligned ? -20 : 20;
|
||||
int yOffset = topAligned ? -20 : 20;
|
||||
|
||||
Point newGripperLocation = _initialGripperPoint;
|
||||
if (_boundsAfterResize.Right - _boundsAfterResize.Left >= 0) {
|
||||
newGripperLocation.Offset(-20, 0);
|
||||
} else {
|
||||
newGripperLocation.Offset(20, 0);
|
||||
}
|
||||
if (_boundsAfterResize.Bottom - _boundsAfterResize.Top >= 0) {
|
||||
newGripperLocation.Offset(0, -20);
|
||||
} else {
|
||||
newGripperLocation.Offset(0, 20);
|
||||
}
|
||||
newGripperLocation.Offset(xOffset, yOffset);
|
||||
|
||||
if (TargetGripper.Location != newGripperLocation) {
|
||||
Invalidate();
|
||||
TargetGripperMove(newGripperLocation.X, newGripperLocation.Y);
|
||||
Invalidate();
|
||||
}
|
||||
return returnValue;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue