Download
Getting Started
Members
Projects
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
More
Community
Marketplace
Events
Planet Eclipse
Newsletter
Videos
Participate
Report a Bug
Forums
Mailing Lists
Wiki
IRC
How to Contribute
Working Groups
Automotive
Internet of Things
LocationTech
Long-Term Support
PolarSys
Science
OpenMDM
Toggle navigation
Bugzilla – Attachment 75089 Details for
Bug 160572
[new eux] add ability to attach images to tasks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
Log In
[x]
|
Terms of Use
|
Copyright Agent
Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read
this important communication.
[patch]
crop picture aspect
160572-crop-aspect.txt (text/plain), 11.16 KB, created by
Balazs Brinkus
on 2007-07-31 20:56:27 EDT
(
hide
)
Description:
crop picture aspect
Filename:
MIME Type:
Creator:
Balazs Brinkus
Created:
2007-07-31 20:56:27 EDT
Size:
11.16 KB
patch
obsolete
>### Eclipse Workspace Patch 1.0 >#P org.eclipse.mylyn.tasks.ui >Index: src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenShotAttachmentPage.java >=================================================================== >RCS file: /cvsroot/tools/org.eclipse.mylyn/org.eclipse.mylyn.tasks.ui/src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenShotAttachmentPage.java,v >retrieving revision 1.1 >diff -u -r1.1 ScreenShotAttachmentPage.java >--- src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenShotAttachmentPage.java 6 Jul 2007 18:50:44 -0000 1.1 >+++ src/org/eclipse/mylyn/internal/tasks/ui/wizards/ScreenShotAttachmentPage.java 1 Aug 2007 00:48:52 -0000 >@@ -14,16 +14,18 @@ > import org.eclipse.mylyn.internal.tasks.core.LocalAttachment; > import org.eclipse.swt.SWT; > import org.eclipse.swt.custom.ScrolledComposite; >+import org.eclipse.swt.events.MouseEvent; >+import org.eclipse.swt.events.MouseListener; >+import org.eclipse.swt.events.MouseMoveListener; > import org.eclipse.swt.events.PaintEvent; > import org.eclipse.swt.events.PaintListener; > import org.eclipse.swt.events.SelectionEvent; > import org.eclipse.swt.events.SelectionListener; >+import org.eclipse.swt.graphics.Cursor; > import org.eclipse.swt.graphics.GC; > import org.eclipse.swt.graphics.Image; > import org.eclipse.swt.graphics.Point; > import org.eclipse.swt.graphics.Rectangle; >-import org.eclipse.swt.layout.FillLayout; >-import org.eclipse.swt.layout.GridData; > import org.eclipse.swt.layout.GridLayout; > import org.eclipse.swt.widgets.Button; > import org.eclipse.swt.widgets.Canvas; >@@ -44,12 +46,14 @@ > > private Button makeShotButton; > >- private Button showShotButton; >+ private Button cropShotButton; > > private Image screenshotImage; > > private Canvas canvas; > >+ private ScrolledComposite scrolledComposite; >+ > protected ScreenShotAttachmentPage(LocalAttachment attachment) { > super("ScreenShotAttachment"); > setTitle("Create a screenshot"); >@@ -58,23 +62,21 @@ > } > > public void createControl(Composite parent) { >+ > Composite composite = new Composite(parent, SWT.NONE); >- GridLayout gridLayout = new GridLayout(); >- gridLayout.numColumns = 2; >- composite.setLayout(gridLayout); >+ composite.setLayout(new GridLayout()); > setControl(composite); > >- composite.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); >- composite.setLayout(new GridLayout(3, false)); >- >- makeShotButton = new Button(composite, SWT.PUSH); >- makeShotButton.setText("Take a screenshot"); >+ Composite buttonsComposite = new Composite(composite, SWT.NONE); >+ buttonsComposite.setLayout(new GridLayout(2, false)); >+ makeShotButton = new Button(buttonsComposite, SWT.PUSH); >+ makeShotButton.setText("Capture full screen"); > makeShotButton.addSelectionListener(new SelectionListener() { > > public void widgetSelected(SelectionEvent e) { > storeScreenshotContent(); > page.setErrorMessage(null); >- showShotButton.setEnabled(true); >+ cropShotButton.setEnabled(true); > } > > public void widgetDefaultSelected(SelectionEvent e) { >@@ -82,36 +84,35 @@ > > }); > >- showShotButton = new Button(composite, SWT.PUSH); >- showShotButton.setText("Show the screenshot"); >- showShotButton.addSelectionListener(new SelectionListener() { >+ cropShotButton = new Button(buttonsComposite, SWT.PUSH); >+ cropShotButton.setText("Crop a region"); >+ cropShotButton.addSelectionListener(new SelectionListener() { > > public void widgetSelected(SelectionEvent e) { >- showScreenshotContent(); >+ cropScreenshotContent(); > } > > public void widgetDefaultSelected(SelectionEvent e) { > } > > }); >+ cropShotButton.setEnabled(false); > >- canvas = new Canvas(composite, SWT.BORDER); >- canvas.setLayoutData(GridDataFactory.fillDefaults() >+ scrolledComposite = new ScrolledComposite(composite, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); >+ scrolledComposite.setLayoutData(GridDataFactory.fillDefaults() > .align(SWT.FILL, SWT.FILL) > .grab(true, true) >- .span(2, 1) > .create()); > >+ canvas = new Canvas(scrolledComposite, SWT.DOUBLE_BUFFERED | SWT.NONE); >+ scrolledComposite.setContent(canvas); > canvas.addPaintListener(new PaintListener() { > public void paintControl(PaintEvent e) { > if (screenshotImage != null) { >- Rectangle screenBounds = screenshotImage.getBounds(); >- Rectangle canvasBounds = canvas.getBounds(); >- e.gc.drawImage(screenshotImage, 0, 0, screenBounds.width, screenBounds.height, 0, 0, >- canvasBounds.width, canvasBounds.height); >+ e.gc.drawImage(screenshotImage, 0, 0); > } else { > page.setErrorMessage("Screenshot required"); >- showShotButton.setEnabled(false); >+ cropShotButton.setEnabled(false); > } > } > }); >@@ -148,9 +149,13 @@ > display.asyncExec(new Runnable() { > public void run() { > GC gc = new GC(display); >- screenshotImage = new Image(display, display.getBounds()); >+ Rectangle displayBounds = display.getBounds(); >+ screenshotImage = new Image(display, displayBounds); > gc.copyArea(screenshotImage, 0, 0); >+ gc.drawRectangle(0, 0, displayBounds.width - 1, displayBounds.height - 1); > gc.dispose(); >+ canvas.setBounds(screenshotImage.getBounds()); >+ scrolledComposite.redraw(); > canvas.redraw(); > wizardShell.setVisible(true); > if (screenshotImage != null) >@@ -159,34 +164,160 @@ > }); > } > >- private void showScreenshotContent() { >- Display display = Display.getDefault(); >+ private void cropScreenshotContent() { >+ >+ final Point downPoint = new Point(-1, -1); >+ final Rectangle newImageBounds = new Rectangle(-1, -1, -1, -1); > >- Shell popup = new Shell(display.getActiveShell(), SWT.SHELL_TRIM); >- popup.setLayout(new FillLayout()); >- popup.setText("Screenshot Image"); >+ final Display display = Display.getDefault(); >+ final Rectangle displayBounds = display.getBounds(); >+ >+ final Shell popup = new Shell(display.getActiveShell(), SWT.SHELL_TRIM); >+ popup.setLayout(new GridLayout()); >+ popup.setText("Crop a region of the screenshot"); > >- Rectangle displayBounds = Display.getDefault().getBounds(); > Point dialogSize = new Point(0, 0); >- dialogSize.x = displayBounds.width / 2; >- dialogSize.y = displayBounds.height / 2; >+ dialogSize.x = displayBounds.width - 100; >+ dialogSize.y = displayBounds.height - 100; > Point dialoglocation = new Point(0, 0); > dialoglocation.x = displayBounds.x + displayBounds.width / 2 - dialogSize.x / 2; > dialoglocation.y = displayBounds.y + displayBounds.height / 2 - dialogSize.y / 2; > popup.setSize(dialogSize); > popup.setLocation(dialoglocation); > >- ScrolledComposite sc = new ScrolledComposite(popup, SWT.V_SCROLL | SWT.H_SCROLL); >- Canvas canvas = new Canvas(sc, SWT.NONE); >- sc.setContent(canvas); >- canvas.setBounds(display.getBounds()); >- canvas.addPaintListener(new PaintListener() { >+ final Rectangle originalBounds = screenshotImage.getBounds(); >+ final Image bufferedImage = new Image(display, originalBounds); >+ GC gc = new GC(bufferedImage); >+ gc.setBackground(popup.getBackground()); >+ gc.fillRectangle(originalBounds); >+ gc.drawImage(screenshotImage, 0, 0); >+ gc.dispose(); >+ >+ Composite bc = new Composite(popup, SWT.NONE); >+ bc.setLayout(new GridLayout(2, false)); >+ >+ final Button saveButton = new Button(bc, SWT.PUSH); >+ saveButton.setText("Save"); >+ saveButton.addSelectionListener(new SelectionListener() { >+ public void widgetSelected(SelectionEvent e) { >+ if (newImageBounds.x != -1 && newImageBounds.y != -1) { >+ screenshotImage = new Image(display, newImageBounds); >+ GC drawGc = new GC(screenshotImage); >+ drawGc.drawImage(bufferedImage, newImageBounds.x, newImageBounds.y, newImageBounds.width, >+ newImageBounds.height, 0, 0, newImageBounds.width, newImageBounds.height); >+ drawGc.drawRectangle(0, 0, newImageBounds.width - 1, newImageBounds.height - 1); >+ drawGc.dispose(); >+ canvas.setBounds(screenshotImage.getBounds()); >+ scrolledComposite.redraw(); >+ canvas.redraw(); >+ popup.close(); >+ } >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ // ignore >+ } >+ }); >+ saveButton.setEnabled(false); >+ >+ final Button cancelButton = new Button(bc, SWT.PUSH); >+ cancelButton.setText("Cancel"); >+ cancelButton.addSelectionListener(new SelectionListener() { >+ public void widgetSelected(SelectionEvent e) { >+ popup.close(); >+ } >+ >+ public void widgetDefaultSelected(SelectionEvent e) { >+ // ignore >+ } >+ }); >+ >+ final ScrolledComposite sc = new ScrolledComposite(popup, SWT.V_SCROLL | SWT.H_SCROLL | SWT.BORDER); >+ sc.setLayoutData(GridDataFactory.fillDefaults().align(SWT.FILL, SWT.FILL).grab(true, true).create()); >+ final Canvas scCanvas = new Canvas(sc, SWT.DOUBLE_BUFFERED | SWT.NONE); >+ scCanvas.setBounds(originalBounds); >+ scCanvas.addPaintListener(new PaintListener() { > public void paintControl(PaintEvent e) { > if (screenshotImage != null) >- e.gc.drawImage(screenshotImage, 0, 0); >+ e.gc.drawImage(bufferedImage, 0, 0); > } > }); >+ sc.setContent(scCanvas); >+ >+ final GC selectionGc = new GC(scCanvas); >+ >+ final MouseMoveListener mouseMoveListener = new MouseMoveListener() { >+ public void mouseMove(MouseEvent e) { >+ if (downPoint.x != -1 && downPoint.y != -1) { >+ int width = e.x - downPoint.x; >+ int height = e.y - downPoint.y; >+ scCanvas.redraw(); >+ selectionGc.drawRectangle(downPoint.x, downPoint.y, width, height); >+ } >+ } >+ }; >+ >+ final MouseListener mouseListener = new MouseListener() { >+ public void mouseUp(MouseEvent e) { >+ if (downPoint.x != -1 && downPoint.y != -1) { >+ >+ int width; >+ if (e.x > originalBounds.width) { >+ width = originalBounds.width - downPoint.x; >+ } else if (e.x < 0) { >+ width = downPoint.x; >+ downPoint.x = 0; >+ } else { >+ width = e.x - downPoint.x; >+ } >+ >+ int height; >+ if (e.y > originalBounds.height) { >+ height = originalBounds.height - downPoint.y; >+ } else if (e.y < 0) { >+ height = downPoint.y; >+ downPoint.y = 0; >+ } else { >+ height = e.y - downPoint.y; >+ } >+ >+ display.getActiveShell().setCursor(new Cursor(null, SWT.CURSOR_ARROW)); >+ >+ selectionGc.drawRectangle(downPoint.x, downPoint.y, width, height); >+ >+ newImageBounds.x = downPoint.x; >+ newImageBounds.y = downPoint.y; >+ newImageBounds.width = width; >+ newImageBounds.height = height; >+ >+ sc.removeMouseMoveListener(mouseMoveListener); >+ sc.removeMouseListener(this); >+ downPoint.x = -1; >+ downPoint.y = -1; >+ >+ saveButton.setEnabled(true); >+ } >+ } >+ >+ public void mouseDown(MouseEvent e) { >+ if (downPoint.x == -1 && downPoint.y == -1) { >+ display.getActiveShell().setCursor(new Cursor(null, SWT.CURSOR_CROSS)); >+ downPoint.x = e.x; >+ downPoint.y = e.y; >+ selectionGc.setLineStyle(SWT.LINE_DASH); >+ scCanvas.addMouseMoveListener(mouseMoveListener); >+ } >+ } >+ >+ public void mouseDoubleClick(MouseEvent e) { >+ // ignore >+ } >+ }; >+ >+ scCanvas.addMouseListener(mouseListener); >+ > popup.open(); >+ > } > > public Image getScreenshotImage() {
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 160572
:
72353
|
72354
|
72683
|
74874
|
75088
| 75089 |
75449
|
75450
|
75466
|
75467
|
75931
|
76061
|
76356
|
76357
|
77091