|
Lines 71-77
Link Here
|
| 71 |
*/ |
71 |
*/ |
| 72 |
public class ScreenshotCreationPage extends WizardPage implements IImageCreator { |
72 |
public class ScreenshotCreationPage extends WizardPage implements IImageCreator { |
| 73 |
|
73 |
|
| 74 |
private IAction captureAction; |
74 |
private SelectCaptureAction captureAction; |
| 75 |
|
75 |
|
| 76 |
private IAction fitAction; |
76 |
private IAction fitAction; |
| 77 |
|
77 |
|
|
Lines 79-84
Link Here
|
| 79 |
|
79 |
|
| 80 |
private IAction markAction; |
80 |
private IAction markAction; |
| 81 |
|
81 |
|
|
|
82 |
private SelectDrawToolAction toolAction; |
| 83 |
|
| 82 |
private IAction colorAction; |
84 |
private IAction colorAction; |
| 83 |
|
85 |
|
| 84 |
private Image colorIcon; |
86 |
private Image colorIcon; |
|
Lines 99-104
Link Here
|
| 99 |
*/ |
101 |
*/ |
| 100 |
private Image workImage; |
102 |
private Image workImage; |
| 101 |
|
103 |
|
|
|
104 |
private Image previousImage; |
| 105 |
|
| 102 |
/** |
106 |
/** |
| 103 |
* Used to draw into {@link #workImage} |
107 |
* Used to draw into {@link #workImage} |
| 104 |
*/ |
108 |
*/ |
|
Lines 155-160
Link Here
|
| 155 |
*/ |
159 |
*/ |
| 156 |
private EditorAction currentAction = EditorAction.CROPPING; |
160 |
private EditorAction currentAction = EditorAction.CROPPING; |
| 157 |
|
161 |
|
|
|
162 |
private boolean isFirstCapture = true; |
| 163 |
|
| 158 |
public ScreenshotCreationPage() { |
164 |
public ScreenshotCreationPage() { |
| 159 |
super("ScreenShotAttachment"); //$NON-NLS-1$ |
165 |
super("ScreenShotAttachment"); //$NON-NLS-1$ |
| 160 |
setTitle(Messages.ScreenshotCreationPage_CAPTURE_SCRRENSHOT); |
166 |
setTitle(Messages.ScreenshotCreationPage_CAPTURE_SCRRENSHOT); |
|
Lines 173-185
Link Here
|
| 173 |
|
179 |
|
| 174 |
// TODO: need disabled versions of all toolbar icons |
180 |
// TODO: need disabled versions of all toolbar icons |
| 175 |
ToolBarManager tbm = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT); |
181 |
ToolBarManager tbm = new ToolBarManager(SWT.FLAT | SWT.HORIZONTAL | SWT.RIGHT); |
| 176 |
captureAction = new Action(Messages.ScreenshotCreationPage_Capture_Desktop_C, IAction.AS_PUSH_BUTTON) { |
|
|
| 177 |
|
182 |
|
| 178 |
private boolean isFirstCapture = true; |
183 |
captureAction = new SelectCaptureAction(getShell(), Messages.ScreenshotCreationPage_Capture_Desktop_C) { |
| 179 |
|
184 |
|
| 180 |
@Override |
185 |
@Override |
| 181 |
public void run() { |
186 |
public void run() { |
| 182 |
captureScreenshotContent(); |
187 |
if (captureAction.getKind() == SelectCaptureAction.Selection.CAPTURE) { |
|
|
188 |
captureScreenshotContent(); |
| 189 |
} else { |
| 190 |
captureScreenshotContent(captureAction.getScreenshotImage()); |
| 191 |
} |
| 192 |
captureAction.resetKind(); |
| 183 |
setErrorMessage(null); |
193 |
setErrorMessage(null); |
| 184 |
if (isFirstCapture) { |
194 |
if (isFirstCapture) { |
| 185 |
isFirstCapture = false; |
195 |
isFirstCapture = false; |
|
Lines 246-251
Link Here
|
| 246 |
currentAction = EditorAction.CROPPING; |
256 |
currentAction = EditorAction.CROPPING; |
| 247 |
cropAction.setChecked(true); |
257 |
cropAction.setChecked(true); |
| 248 |
markAction.setChecked(false); |
258 |
markAction.setChecked(false); |
|
|
259 |
toolAction.setEnabled(false); |
| 249 |
colorAction.setEnabled(false); |
260 |
colorAction.setEnabled(false); |
| 250 |
canvas.redraw(); |
261 |
canvas.redraw(); |
| 251 |
} |
262 |
} |
|
Lines 260-265
Link Here
|
| 260 |
currentAction = EditorAction.MARKING; |
271 |
currentAction = EditorAction.MARKING; |
| 261 |
cropAction.setChecked(false); |
272 |
cropAction.setChecked(false); |
| 262 |
markAction.setChecked(true); |
273 |
markAction.setChecked(true); |
|
|
274 |
toolAction.setEnabled(true); |
| 263 |
colorAction.setEnabled(true); |
275 |
colorAction.setEnabled(true); |
| 264 |
canvas.redraw(); |
276 |
canvas.redraw(); |
| 265 |
} |
277 |
} |
|
Lines 269-274
Link Here
|
| 269 |
// markAction.setDisabledImageDescriptor(ImageDescriptor.createFromFile(getClass(), "mark_disabled.gif")); |
281 |
// markAction.setDisabledImageDescriptor(ImageDescriptor.createFromFile(getClass(), "mark_disabled.gif")); |
| 270 |
markAction.setEnabled(false); |
282 |
markAction.setEnabled(false); |
| 271 |
|
283 |
|
|
|
284 |
toolAction = new SelectDrawToolAction(); |
| 285 |
toolAction.setEnabled(false); |
| 286 |
|
| 272 |
colorAction = new Action("", IAction.AS_DROP_DOWN_MENU) { //$NON-NLS-1$ |
287 |
colorAction = new Action("", IAction.AS_DROP_DOWN_MENU) { //$NON-NLS-1$ |
| 273 |
@Override |
288 |
@Override |
| 274 |
public void runWithEvent(final Event e) { |
289 |
public void runWithEvent(final Event e) { |
|
Lines 316-321
Link Here
|
| 316 |
tbm.add(new Separator()); |
331 |
tbm.add(new Separator()); |
| 317 |
tbm.add(createAndConfigureCI(cropAction)); |
332 |
tbm.add(createAndConfigureCI(cropAction)); |
| 318 |
tbm.add(createAndConfigureCI(markAction)); |
333 |
tbm.add(createAndConfigureCI(markAction)); |
|
|
334 |
tbm.add(createAndConfigureCI(toolAction)); |
| 319 |
tbm.add(createAndConfigureCI(colorAction)); |
335 |
tbm.add(createAndConfigureCI(colorAction)); |
| 320 |
tbm.add(new Separator()); |
336 |
tbm.add(new Separator()); |
| 321 |
tbm.add(createAndConfigureCI(clearAction)); |
337 |
tbm.add(createAndConfigureCI(clearAction)); |
|
Lines 455-460
Link Here
|
| 455 |
return isPageComplete(); |
471 |
return isPageComplete(); |
| 456 |
} |
472 |
} |
| 457 |
|
473 |
|
|
|
474 |
private void captureScreenshotContent(Image image) { |
| 475 |
final Display display = getShell().getDisplay(); |
| 476 |
disposeImageResources(); |
| 477 |
originalImage = image; |
| 478 |
Rectangle displayBounds = originalImage.getBounds(); |
| 479 |
workImage = new Image(display, displayBounds.width, displayBounds.height); |
| 480 |
GC gc = new GC(workImage); |
| 481 |
gc.drawImage(originalImage, 0, 0); |
| 482 |
gc.dispose(); |
| 483 |
|
| 484 |
workImageGC = new GC(workImage); |
| 485 |
workImageGC.setForeground(markColor); |
| 486 |
workImageGC.setLineWidth(4); |
| 487 |
workImageGC.setLineCap(SWT.CAP_ROUND); |
| 488 |
|
| 489 |
scrolledComposite.setEnabled(true); |
| 490 |
clearSelection(); |
| 491 |
refreshCanvasSize(); |
| 492 |
|
| 493 |
setPageComplete(true); |
| 494 |
} |
| 495 |
|
| 458 |
private void captureScreenshotContent() { |
496 |
private void captureScreenshotContent() { |
| 459 |
final Display display = getShell().getDisplay(); |
497 |
final Display display = getShell().getDisplay(); |
| 460 |
final Shell wizardShell = getWizard().getContainer().getShell(); |
498 |
final Shell wizardShell = getWizard().getContainer().getShell(); |
|
Lines 701-706
Link Here
|
| 701 |
} else if (currentAction == EditorAction.MARKING) { |
739 |
} else if (currentAction == EditorAction.MARKING) { |
| 702 |
startPoint = null; |
740 |
startPoint = null; |
| 703 |
setImageDirty(true); |
741 |
setImageDirty(true); |
|
|
742 |
|
| 743 |
if (toolAction.getKind() != SelectDrawToolAction.DrawKind.FREE) { |
| 744 |
previousImage.dispose(); |
| 745 |
previousImage = null; |
| 746 |
} |
| 704 |
} |
747 |
} |
| 705 |
} |
748 |
} |
| 706 |
|
749 |
|
|
Lines 713-718
Link Here
|
| 713 |
int scaledY = (int) (e.y / scaleFactor); |
756 |
int scaledY = (int) (e.y / scaleFactor); |
| 714 |
|
757 |
|
| 715 |
if (currentAction == EditorAction.MARKING) { |
758 |
if (currentAction == EditorAction.MARKING) { |
|
|
759 |
if (toolAction.getKind() != SelectDrawToolAction.DrawKind.FREE) { |
| 760 |
Display display = getShell().getDisplay(); |
| 761 |
previousImage = new Image(display, workImage.getBounds()); |
| 762 |
GC gc = new GC(previousImage); |
| 763 |
gc.drawImage(workImage, 0, 0); |
| 764 |
gc.dispose(); |
| 765 |
} |
| 766 |
|
| 716 |
startPoint = new Point(scaledX, scaledY); |
767 |
startPoint = new Point(scaledX, scaledY); |
| 717 |
drawMarkLine(scaledX, scaledY); |
768 |
drawMarkLine(scaledX, scaledY); |
| 718 |
canvas.setCursor(cursors.get(CURSOR_MARK_TOOL)); |
769 |
canvas.setCursor(cursors.get(CURSOR_MARK_TOOL)); |
|
Lines 850-863
Link Here
|
| 850 |
} |
901 |
} |
| 851 |
|
902 |
|
| 852 |
/** |
903 |
/** |
| 853 |
* Connects the previous mark point to the new reference point, by drawing a new line |
904 |
* Connects the previous mark point to the new reference point, by drawing a new line, rectangle or oval |
| 854 |
*/ |
905 |
*/ |
| 855 |
private void drawMarkLine(int x, int y) { |
906 |
private void drawMarkLine(int x, int y) { |
| 856 |
if (startPoint != null) { |
907 |
if (startPoint != null) { |
| 857 |
clearAction.setEnabled(true); |
908 |
clearAction.setEnabled(true); |
| 858 |
workImageGC.drawLine(startPoint.x, startPoint.y, x, y); |
909 |
if (toolAction.getKind() == SelectDrawToolAction.DrawKind.FREE) { |
| 859 |
startPoint.x = x; |
910 |
workImageGC.drawLine(startPoint.x, startPoint.y, x, y); |
| 860 |
startPoint.y = y; |
911 |
startPoint.x = x; |
|
|
912 |
startPoint.y = y; |
| 913 |
} else { |
| 914 |
workImageGC.drawImage(previousImage, 0, 0); |
| 915 |
if (startPoint.x == x && startPoint.y == y) { |
| 916 |
workImageGC.drawLine(startPoint.x, startPoint.y, x, y); |
| 917 |
} else { |
| 918 |
if (toolAction.getKind() == SelectDrawToolAction.DrawKind.LINE) { |
| 919 |
workImageGC.drawLine(startPoint.x, startPoint.y, x, y); |
| 920 |
} else if (toolAction.getKind() == SelectDrawToolAction.DrawKind.BOX) { |
| 921 |
workImageGC.drawRectangle(startPoint.x, startPoint.y, x - startPoint.x, y - startPoint.y); |
| 922 |
} else if (toolAction.getKind() == SelectDrawToolAction.DrawKind.OVAL) { |
| 923 |
workImageGC.drawOval(startPoint.x, startPoint.y, x - startPoint.x, y - startPoint.y); |
| 924 |
} |
| 925 |
} |
| 926 |
} |
| 861 |
canvas.redraw(); |
927 |
canvas.redraw(); |
| 862 |
} |
928 |
} |
| 863 |
} |
929 |
} |