mirror of
https://github.com/greenshot/greenshot
synced 2025-08-22 22:34:27 -07:00
Small fix for the capture form, this removes some artifacts on the start
This commit is contained in:
parent
441169342a
commit
fad25c023e
1 changed files with 22 additions and 9 deletions
|
@ -70,7 +70,7 @@ namespace Greenshot.Forms
|
||||||
private FixMode _fixMode = FixMode.None;
|
private FixMode _fixMode = FixMode.None;
|
||||||
private bool _isCtrlPressed;
|
private bool _isCtrlPressed;
|
||||||
private bool _mouseDown;
|
private bool _mouseDown;
|
||||||
private NativePoint _mouseMovePos = NativePoint.Empty;
|
private NativePoint _mouseMovePos;
|
||||||
|
|
||||||
private int _mX;
|
private int _mX;
|
||||||
private int _mY;
|
private int _mY;
|
||||||
|
@ -120,7 +120,7 @@ namespace Greenshot.Forms
|
||||||
FormClosing += ClosingHandler;
|
FormClosing += ClosingHandler;
|
||||||
|
|
||||||
// set cursor location
|
// set cursor location
|
||||||
_cursorPos = WindowCapture.GetCursorLocationRelativeToScreenBounds();
|
_cursorPos = _mouseMovePos = WindowCapture.GetCursorLocationRelativeToScreenBounds();
|
||||||
|
|
||||||
// Initialize the animations, the window capture zooms out from the cursor to the window under the cursor
|
// Initialize the animations, the window capture zooms out from the cursor to the window under the cursor
|
||||||
if (UsedCaptureMode == CaptureMode.Window)
|
if (UsedCaptureMode == CaptureMode.Window)
|
||||||
|
@ -186,8 +186,11 @@ namespace Greenshot.Forms
|
||||||
{
|
{
|
||||||
if (isOn)
|
if (isOn)
|
||||||
{
|
{
|
||||||
|
var screenBounds = DisplayInfo.GetBounds(MousePosition);
|
||||||
|
var zoomerSize = CalculateZoomSize(screenBounds);
|
||||||
|
|
||||||
// Initialize the zoom with a invalid position
|
// Initialize the zoom with a invalid position
|
||||||
_zoomAnimator = new RectangleAnimator(NativeRect.Empty, new NativeRect(int.MaxValue, int.MaxValue, NativeSize.Empty), FramesForMillis(1000), EasingTypes.Quintic, EasingModes.EaseOut);
|
_zoomAnimator = new RectangleAnimator(new NativeRect(_cursorPos, NativeSize.Empty), new NativeRect(_cursorPos, zoomerSize), FramesForMillis(1000), EasingTypes.Quintic, EasingModes.EaseOut);
|
||||||
VerifyZoomAnimation(_cursorPos, false);
|
VerifyZoomAnimation(_cursorPos, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -712,6 +715,21 @@ namespace Greenshot.Forms
|
||||||
// Ignore the event, to reduct painting
|
// Ignore the event, to reduct painting
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Calculate the zoom size
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="screenBounds">NativeRect with the screenbounds</param>
|
||||||
|
/// <returns>NativeSize</returns>
|
||||||
|
private NativeSize CalculateZoomSize(NativeRect screenBounds)
|
||||||
|
{
|
||||||
|
// convert to be relative to top left corner of all screen bounds
|
||||||
|
screenBounds = screenBounds.MoveTo(WindowCapture.GetLocationRelativeToScreenBounds(screenBounds.Location));
|
||||||
|
var relativeZoomSize = Math.Min(screenBounds.Width, screenBounds.Height) / 5;
|
||||||
|
// Make sure the final size is a plural of 4, this makes it look better
|
||||||
|
relativeZoomSize = relativeZoomSize - relativeZoomSize % 4;
|
||||||
|
return new NativeSize(relativeZoomSize, relativeZoomSize);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Checks if the Zoom area can move there where it wants to go, change direction if not.
|
/// Checks if the Zoom area can move there where it wants to go, change direction if not.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -723,12 +741,7 @@ namespace Greenshot.Forms
|
||||||
private void VerifyZoomAnimation(NativePoint pos, bool allowZoomOverCaptureRect)
|
private void VerifyZoomAnimation(NativePoint pos, bool allowZoomOverCaptureRect)
|
||||||
{
|
{
|
||||||
var screenBounds = DisplayInfo.GetBounds(MousePosition);
|
var screenBounds = DisplayInfo.GetBounds(MousePosition);
|
||||||
// convert to be relative to top left corner of all screen bounds
|
var zoomSize = CalculateZoomSize(screenBounds);
|
||||||
screenBounds = screenBounds.MoveTo(WindowCapture.GetLocationRelativeToScreenBounds(screenBounds.Location));
|
|
||||||
var relativeZoomSize = Math.Min(screenBounds.Width, screenBounds.Height) / 5;
|
|
||||||
// Make sure the final size is a plural of 4, this makes it look better
|
|
||||||
relativeZoomSize = relativeZoomSize - relativeZoomSize % 4;
|
|
||||||
var zoomSize = new NativeSize(relativeZoomSize, relativeZoomSize);
|
|
||||||
var zoomOffset = new NativePoint(20, 20);
|
var zoomOffset = new NativePoint(20, 20);
|
||||||
|
|
||||||
var targetRectangle = _zoomAnimator.Final.Offset(pos);
|
var targetRectangle = _zoomAnimator.Final.Offset(pos);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue