mirror of
https://github.com/greenshot/greenshot
synced 2025-08-19 13:10:00 -07:00
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.
This commit is contained in:
parent
d395c00f9d
commit
7fd0ce5037
2 changed files with 63 additions and 28 deletions
|
@ -72,6 +72,8 @@ namespace Greenshot.Forms {
|
||||||
private RectangleAnimator _windowAnimator;
|
private RectangleAnimator _windowAnimator;
|
||||||
private RectangleAnimator _zoomAnimator;
|
private RectangleAnimator _zoomAnimator;
|
||||||
private readonly bool _isZoomerTransparent = Conf.ZoomerOpacity < 1;
|
private readonly bool _isZoomerTransparent = Conf.ZoomerOpacity < 1;
|
||||||
|
private bool _isCtrlPressed = false;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Property to access the selected capture rectangle
|
/// Property to access the selected capture rectangle
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -192,8 +194,13 @@ namespace Greenshot.Forms {
|
||||||
|
|
||||||
#region key handling
|
#region key handling
|
||||||
void CaptureFormKeyUp(object sender, KeyEventArgs e) {
|
void CaptureFormKeyUp(object sender, KeyEventArgs e) {
|
||||||
if (e.KeyCode == Keys.ShiftKey) {
|
switch(e.KeyCode) {
|
||||||
|
case Keys.ShiftKey:
|
||||||
_fixMode = FixMode.None;
|
_fixMode = FixMode.None;
|
||||||
|
break;
|
||||||
|
case Keys.ControlKey:
|
||||||
|
_isCtrlPressed = false;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -203,18 +210,20 @@ namespace Greenshot.Forms {
|
||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
void CaptureFormKeyDown(object sender, KeyEventArgs e) {
|
void CaptureFormKeyDown(object sender, KeyEventArgs e) {
|
||||||
|
int step = _isCtrlPressed ? 10 : 1;
|
||||||
|
|
||||||
switch (e.KeyCode) {
|
switch (e.KeyCode) {
|
||||||
case Keys.Up:
|
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;
|
break;
|
||||||
case Keys.Down:
|
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;
|
break;
|
||||||
case Keys.Left:
|
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;
|
break;
|
||||||
case Keys.Right:
|
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;
|
break;
|
||||||
case Keys.ShiftKey:
|
case Keys.ShiftKey:
|
||||||
// Fixmode
|
// Fixmode
|
||||||
|
@ -222,6 +231,9 @@ namespace Greenshot.Forms {
|
||||||
_fixMode = FixMode.Initiated;
|
_fixMode = FixMode.Initiated;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
case Keys.ControlKey:
|
||||||
|
_isCtrlPressed = true;
|
||||||
|
break;
|
||||||
case Keys.Escape:
|
case Keys.Escape:
|
||||||
// Cancel
|
// Cancel
|
||||||
DialogResult = DialogResult.Cancel;
|
DialogResult = DialogResult.Cancel;
|
||||||
|
@ -280,6 +292,10 @@ namespace Greenshot.Forms {
|
||||||
// Confirm
|
// Confirm
|
||||||
if (_captureMode == CaptureMode.Window) {
|
if (_captureMode == CaptureMode.Window) {
|
||||||
DialogResult = DialogResult.OK;
|
DialogResult = DialogResult.OK;
|
||||||
|
} else if (!_mouseDown) {
|
||||||
|
HandleMouseDown();
|
||||||
|
} else if (_mouseDown) {
|
||||||
|
HandleMouseUp();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -294,22 +310,20 @@ namespace Greenshot.Forms {
|
||||||
/// <param name="e"></param>
|
/// <param name="e"></param>
|
||||||
void OnMouseDown(object sender, MouseEventArgs e) {
|
void OnMouseDown(object sender, MouseEventArgs e) {
|
||||||
if (e.Button == MouseButtons.Left) {
|
if (e.Button == MouseButtons.Left) {
|
||||||
|
HandleMouseDown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void HandleMouseDown() {
|
||||||
Point tmpCursorLocation = WindowCapture.GetCursorLocationRelativeToScreenBounds();
|
Point tmpCursorLocation = WindowCapture.GetCursorLocationRelativeToScreenBounds();
|
||||||
_mX = tmpCursorLocation.X;
|
_mX = tmpCursorLocation.X;
|
||||||
_mY = tmpCursorLocation.Y;
|
_mY = tmpCursorLocation.Y;
|
||||||
_mouseDown = true;
|
_mouseDown = true;
|
||||||
OnMouseMove(this, e);
|
OnMouseMove(this, null);
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
private void HandleMouseUp() {
|
||||||
/// The mouse up handler of the capture form
|
|
||||||
/// </summary>
|
|
||||||
/// <param name="sender"></param>
|
|
||||||
/// <param name="e"></param>
|
|
||||||
void OnMouseUp(object sender, MouseEventArgs e) {
|
|
||||||
if (_mouseDown) {
|
|
||||||
// If the mouse goes up we set down to false (nice logic!)
|
// If the mouse goes up we set down to false (nice logic!)
|
||||||
_mouseDown = false;
|
_mouseDown = false;
|
||||||
// Check if anything is selected
|
// Check if anything is selected
|
||||||
|
@ -327,6 +341,17 @@ namespace Greenshot.Forms {
|
||||||
} else {
|
} else {
|
||||||
Invalidate();
|
Invalidate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The mouse up handler of the capture form
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="sender"></param>
|
||||||
|
/// <param name="e"></param>
|
||||||
|
void OnMouseUp(object sender, MouseEventArgs e) {
|
||||||
|
if (_mouseDown) {
|
||||||
|
HandleMouseUp();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,16 @@ CHANGE LOG:
|
||||||
|
|
||||||
@DETAILVERSION@
|
@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
|
All details to our tickets can be found here: https://greenshot.atlassian.net
|
||||||
|
|
||||||
Features:
|
Features:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue