|
Lines 112-118
Link Here
|
| 112 |
*/ |
112 |
*/ |
| 113 |
private static enum Action { |
113 |
private static enum Action { |
| 114 |
|
114 |
|
| 115 |
IDLE, SELECTING, RESIZING_SELECTION, MOVING_SELECTION; |
115 |
IDLE, SELECTING, RESIZING_SELECTION, MOVING_SELECTION, MOVING_IMAGE; |
| 116 |
|
116 |
|
| 117 |
}; |
117 |
}; |
| 118 |
|
118 |
|
|
Lines 221-234
Link Here
|
| 221 |
e.gc.drawImage(screenshotImage, 0, 0); |
221 |
e.gc.drawImage(screenshotImage, 0, 0); |
| 222 |
} |
222 |
} |
| 223 |
|
223 |
|
| 224 |
if (currentAction == Action.IDLE) { |
224 |
if (currentSelection != null) { |
| 225 |
if (currentSelection != null) { |
225 |
if (currentAction == Action.SELECTING || currentAction == Action.RESIZING_SELECTION |
| 226 |
drawSelection(e.gc); |
226 |
|| currentAction == Action.MOVING_SELECTION) { |
| 227 |
} |
|
|
| 228 |
} else if (currentAction == Action.SELECTING || currentAction == Action.RESIZING_SELECTION |
| 229 |
|| currentAction == Action.MOVING_SELECTION) { |
| 230 |
if (currentSelection != null) { |
| 231 |
drawSelectionPreview(e.gc); |
227 |
drawSelectionPreview(e.gc); |
|
|
228 |
} else { |
| 229 |
drawSelection(e.gc); |
| 232 |
} |
230 |
} |
| 233 |
} |
231 |
} |
| 234 |
} else { |
232 |
} else { |
|
Lines 464-470
Link Here
|
| 464 |
* If a selection is in course, moving the mouse around refreshes the selection rectangle |
462 |
* If a selection is in course, moving the mouse around refreshes the selection rectangle |
| 465 |
*/ |
463 |
*/ |
| 466 |
public void mouseMove(MouseEvent e) { |
464 |
public void mouseMove(MouseEvent e) { |
| 467 |
if (currentAction == Action.SELECTING) { |
465 |
if (currentAction == Action.MOVING_IMAGE) { |
|
|
466 |
Point origin = scrolledComposite.getOrigin(); |
| 467 |
int diffx = (e.x - startPoint.x) / 2; |
| 468 |
int diffy = (e.y - startPoint.y) / 2; |
| 469 |
scrolledComposite.setOrigin(origin.x + diffx, origin.y + diffy); |
| 470 |
startPoint.x = e.x; |
| 471 |
startPoint.y = e.y; |
| 472 |
canvas.redraw(); |
| 473 |
} else if (currentAction == Action.SELECTING) { |
| 468 |
// Selection in course |
474 |
// Selection in course |
| 469 |
refreshCurrentSelection((int) Math.round(e.x / scaleFactor), (int) Math.round(e.y / scaleFactor)); |
475 |
refreshCurrentSelection((int) Math.round(e.x / scaleFactor), (int) Math.round(e.y / scaleFactor)); |
| 470 |
canvas.redraw(); |
476 |
canvas.redraw(); |
|
Lines 506-511
Link Here
|
| 506 |
* image |
512 |
* image |
| 507 |
*/ |
513 |
*/ |
| 508 |
public void mouseUp(MouseEvent e) { |
514 |
public void mouseUp(MouseEvent e) { |
|
|
515 |
if (currentAction == Action.MOVING_IMAGE) { |
| 516 |
currentAction = Action.IDLE; |
| 517 |
startPoint = null; |
| 518 |
return; |
| 519 |
} |
| 509 |
if (currentAction == Action.SELECTING || currentAction == Action.RESIZING_SELECTION |
520 |
if (currentAction == Action.SELECTING || currentAction == Action.RESIZING_SELECTION |
| 510 |
|| currentAction == Action.MOVING_SELECTION) { |
521 |
|| currentAction == Action.MOVING_SELECTION) { |
| 511 |
canvas.setCursor(cursors.get(SWT.CURSOR_ARROW)); |
522 |
canvas.setCursor(cursors.get(SWT.CURSOR_ARROW)); |
|
Lines 538-543
Link Here
|
| 538 |
return; |
549 |
return; |
| 539 |
} |
550 |
} |
| 540 |
|
551 |
|
|
|
552 |
if ((e.stateMask & SWT.MOD1) > 0) { |
| 553 |
startPoint = new Point(e.x, e.y); |
| 554 |
currentAction = Action.MOVING_IMAGE; |
| 555 |
return; |
| 556 |
} |
| 557 |
|
| 541 |
// Check the most appropriate action to follow; first check if I'm on some grab point |
558 |
// Check the most appropriate action to follow; first check if I'm on some grab point |
| 542 |
if (currentSelection != null) { |
559 |
if (currentSelection != null) { |
| 543 |
for (GrabPoint point : grabPoints) { |
560 |
for (GrabPoint point : grabPoints) { |