From 7fd0ce5037d4a2ae89c34ad3e0b72cd1906afd45 Mon Sep 17 00:00:00 2001 From: RKrom Date: Wed, 22 Oct 2014 16:18:01 +0200 Subject: [PATCH] FEATURE-766: Region capture: When keeping the Ctrl key pressed, and using the cursor keys, the cursor is now moved 10 pixels. Also added the possibility to start / end the region selection with the enter key. --- Greenshot/Forms/CaptureForm.cs | 81 ++++++++++++------- .../additional_files/readme.txt.template | 10 +++ 2 files changed, 63 insertions(+), 28 deletions(-) diff --git a/Greenshot/Forms/CaptureForm.cs b/Greenshot/Forms/CaptureForm.cs index 003b52977..7a05d7ec7 100644 --- a/Greenshot/Forms/CaptureForm.cs +++ b/Greenshot/Forms/CaptureForm.cs @@ -72,6 +72,8 @@ namespace Greenshot.Forms { private RectangleAnimator _windowAnimator; private RectangleAnimator _zoomAnimator; private readonly bool _isZoomerTransparent = Conf.ZoomerOpacity < 1; + private bool _isCtrlPressed = false; + /// /// Property to access the selected capture rectangle /// @@ -192,8 +194,13 @@ namespace Greenshot.Forms { #region key handling void CaptureFormKeyUp(object sender, KeyEventArgs e) { - if (e.KeyCode == Keys.ShiftKey) { - _fixMode = FixMode.None; + switch(e.KeyCode) { + case Keys.ShiftKey: + _fixMode = FixMode.None; + break; + case Keys.ControlKey: + _isCtrlPressed = false; + break; } } @@ -203,18 +210,20 @@ namespace Greenshot.Forms { /// /// void CaptureFormKeyDown(object sender, KeyEventArgs e) { + int step = _isCtrlPressed ? 10 : 1; + switch (e.KeyCode) { case Keys.Up: - Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y - 1); + Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y - step); break; case Keys.Down: - Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y + 1); + Cursor.Position = new Point(Cursor.Position.X, Cursor.Position.Y + step); break; case Keys.Left: - Cursor.Position = new Point(Cursor.Position.X - 1, Cursor.Position.Y); + Cursor.Position = new Point(Cursor.Position.X - step, Cursor.Position.Y); break; case Keys.Right: - Cursor.Position = new Point(Cursor.Position.X + 1, Cursor.Position.Y); + Cursor.Position = new Point(Cursor.Position.X + step, Cursor.Position.Y); break; case Keys.ShiftKey: // Fixmode @@ -222,6 +231,9 @@ namespace Greenshot.Forms { _fixMode = FixMode.Initiated; } break; + case Keys.ControlKey: + _isCtrlPressed = true; + break; case Keys.Escape: // Cancel DialogResult = DialogResult.Cancel; @@ -280,6 +292,10 @@ namespace Greenshot.Forms { // Confirm if (_captureMode == CaptureMode.Window) { DialogResult = DialogResult.OK; + } else if (!_mouseDown) { + HandleMouseDown(); + } else if (_mouseDown) { + HandleMouseUp(); } break; } @@ -294,13 +310,38 @@ namespace Greenshot.Forms { /// void OnMouseDown(object sender, MouseEventArgs e) { if (e.Button == MouseButtons.Left) { - Point tmpCursorLocation = WindowCapture.GetCursorLocationRelativeToScreenBounds(); - _mX = tmpCursorLocation.X; - _mY = tmpCursorLocation.Y; - _mouseDown = true; - OnMouseMove(this, e); + HandleMouseDown(); + } + } + + private void HandleMouseDown() { + Point tmpCursorLocation = WindowCapture.GetCursorLocationRelativeToScreenBounds(); + _mX = tmpCursorLocation.X; + _mY = tmpCursorLocation.Y; + _mouseDown = true; + OnMouseMove(this, null); + Invalidate(); + } + + private void HandleMouseUp() { + // If the mouse goes up we set down to false (nice logic!) + _mouseDown = false; + // Check if anything is selected + if (_captureMode == CaptureMode.Window && _selectedCaptureWindow != null) { + // Go and process the capture + DialogResult = DialogResult.OK; + } else if (_captureRect.Height > 0 && _captureRect.Width > 0) { + // correct the GUI width to real width if Region mode + if (_captureMode == CaptureMode.Region) { + _captureRect.Width += 1; + _captureRect.Height += 1; + } + // Go and process the capture + DialogResult = DialogResult.OK; + } else { Invalidate(); } + } /// @@ -310,23 +351,7 @@ namespace Greenshot.Forms { /// void OnMouseUp(object sender, MouseEventArgs e) { if (_mouseDown) { - // If the mouse goes up we set down to false (nice logic!) - _mouseDown = false; - // Check if anything is selected - if (_captureMode == CaptureMode.Window && _selectedCaptureWindow != null) { - // Go and process the capture - DialogResult = DialogResult.OK; - } else if (_captureRect.Height > 0 && _captureRect.Width > 0) { - // correct the GUI width to real width if Region mode - if (_captureMode == CaptureMode.Region) { - _captureRect.Width += 1; - _captureRect.Height += 1; - } - // Go and process the capture - DialogResult = DialogResult.OK; - } else { - Invalidate(); - } + HandleMouseUp(); } } diff --git a/Greenshot/releases/additional_files/readme.txt.template b/Greenshot/releases/additional_files/readme.txt.template index ace648982..812cc14bd 100644 --- a/Greenshot/releases/additional_files/readme.txt.template +++ b/Greenshot/releases/additional_files/readme.txt.template @@ -7,6 +7,16 @@ CHANGE LOG: @DETAILVERSION@ +Features: +* Due to BUG-1667 we had to remove the horizontal text alignment, this afflicts the textbox and the speech bubble. +* Added the possibility to select the region to capture by using the keyboard, use the cursor keys to move the cursor (ctrl-key speeds up the movement) and the enter key to mark the start and ending. + +Bugs Resolved: +* BUG-1667 removed horizontal alignment of textbox in input mode, as it caused problems with textbox focus and could not be implemented consistently anyway (no vertical alignment possible) + + +1.2.1.2-af946cf RC1 + All details to our tickets can be found here: https://greenshot.atlassian.net Features: