From 0d727069a3c99bd4b61e20ada1b9469aa5b34ab5 Mon Sep 17 00:00:00 2001 From: dongkyu6 lee Date: Tue, 16 Feb 2016 17:50:25 +0900 Subject: [PATCH] Changed screenshot popup event to 'MouseDown' Change-Id: I3b88ef8742d51fb834b1ef88a1fdb4f29525725f --- .../ui/info/screenshot/ImageViewer.java | 96 +++++++--------------- 1 file changed, 28 insertions(+), 68 deletions(-) mode change 100644 => 100755 org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/screenshot/ImageViewer.java diff --git a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/screenshot/ImageViewer.java b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/screenshot/ImageViewer.java old mode 100644 new mode 100755 index 182c837..6483dc1 --- a/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/screenshot/ImageViewer.java +++ b/org.tizen.dynamicanalyzer/src/org/tizen/dynamicanalyzer/ui/info/screenshot/ImageViewer.java @@ -36,6 +36,7 @@ import org.eclipse.swt.SWTError; import org.eclipse.swt.SWTException; import org.eclipse.swt.events.PaintEvent; import org.eclipse.swt.events.PaintListener; +import org.eclipse.swt.graphics.Cursor; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.Point; @@ -112,6 +113,7 @@ public class ImageViewer extends Composite { private Canvas canvas; private Canvas popup; private Shell childShell; + private Shell imageShell; private Composite parent; int childShellWidth = 0; int childShellHeight = 0; @@ -134,6 +136,7 @@ public class ImageViewer extends Composite { private int childHeight = 0; private Timer timer = null; + private boolean popupOpened; public ImageViewer(Composite parent, int style) { super(parent, style); @@ -141,11 +144,12 @@ public class ImageViewer extends Composite { this.setLayout(new FillLayout()); canvas = new Canvas(this, SWT.NONE); + this.imageShell = parent.getShell(); setImage(ImageResources.NO_IMAGE); + popupOpened = false; + canvas.addListener(SWT.MouseEnter, mouseListener); canvas.addListener(SWT.MouseExit, mouseListener); - canvas.addListener(SWT.MouseUp, mouseListener); - canvas.addListener(SWT.MouseMove, mouseListener); canvas.addListener(SWT.MouseDown, mouseListener); canvas.addPaintListener(new PaintListener() { @Override @@ -313,13 +317,13 @@ public class ImageViewer extends Composite { @Override public void handleEvent(Event event) { if (event.type == SWT.MouseEnter) { - setButtonCondition(); - - if (childShell == null) { - openChildShell(true); - } + Cursor startCursor = new Cursor(imageShell.getDisplay(), SWT.CURSOR_HAND); + imageShell.setCursor(startCursor); } else if (event.type == SWT.MouseExit) { + Cursor arrowCursor = new Cursor(imageShell.getDisplay(), SWT.CURSOR_ARROW); + imageShell.setCursor(arrowCursor); if (childShell != null) { + popupOpened = false; if (timer != null) { timer.cancel(); timer = null; @@ -329,69 +333,25 @@ public class ImageViewer extends Composite { } state = MOUSE_EXIT; canvas.redraw(); - } else if (event.type == SWT.MouseMove) { - if (!mouseDown) { - Rectangle rect = canvas.getBounds(); - Rectangle leftImageBounds = ImageResources.SNAPSHOT_LEFT_HOVER.getBounds(); - Rectangle rightImageBounds = ImageResources.SNAPSHOT_RIGHT_HOVER.getBounds(); - int prevState = state; - if (event.x < rect.x + leftImageBounds.width) { - state = MOUSE_LEFT; - } else if (event.x > rect.x + (rect.width - rightImageBounds.width)) { - state = MOUSE_RIGHT; - } else if (event.x > rect.x && event.x < event.x + rect.width) { - state = MOUSE_HOVER; - } else { - state = MOUSE_EXIT; - } - - if (prevState != state) { - canvas.redraw(); - } - } } else if (event.type == SWT.MouseDown) { - mouseDown = true; - Rectangle rect = canvas.getBounds(); - Rectangle leftImageBounds = ImageResources.SNAPSHOT_LEFT_HOVER.getBounds(); - Rectangle rightImageBounds = ImageResources.SNAPSHOT_RIGHT_HOVER.getBounds(); - int prevState = state; - if (event.x < rect.x + leftImageBounds.width) { - state = MOUSE_DOWN_LEFT; - } else if (event.x > rect.x + (rect.width - rightImageBounds.width)) { - state = MOUSE_DOWN_RIGHT; - } else if (event.x > rect.x && event.x < event.x + rect.width) { - state = MOUSE_HOVER; - } else { - state = MOUSE_EXIT; + if (popupOpened == false) { + popupOpened = true; + + if (childShell == null) { + openChildShell(true); + } } + else { + popupOpened = false; - if (prevState != state) { - canvas.redraw(); - } - } else if (event.type == SWT.MouseUp) { - mouseDown = false; - Rectangle rect = canvas.getBounds(); - Rectangle leftImageBounds = ImageResources.SNAPSHOT_LEFT_HOVER.getBounds(); - Rectangle rightImageBounds = ImageResources.SNAPSHOT_RIGHT_HOVER.getBounds(); - int prevState = state; - if (event.x < rect.x + leftImageBounds.width) { - if (state == MOUSE_DOWN_LEFT && leftEnable) { - leftArrowAction(); - setButtonCondition(); - } - state = MOUSE_LEFT; - } else if (event.x > rect.x + (rect.width - rightImageBounds.width)) { - if (state == MOUSE_DOWN_RIGHT && rightEnable) { - rightArrowAction(); - setButtonCondition(); + if (childShell != null) { + if (timer != null) { + timer.cancel(); + timer = null; + } + childShell.close(); + childShell = null; } - state = MOUSE_RIGHT; - } else if (event.x > rect.x && event.x < event.x + rect.width) { - state = MOUSE_HOVER; - } else { - state = MOUSE_EXIT; - } - if (prevState != state) { canvas.redraw(); } } @@ -490,7 +450,7 @@ public class ImageViewer extends Composite { Point p = canvas.toDisplay(0, 0); childShell.setSize(childShellWidth, childShellHeight); - childShell.setLocation(p.x - childShellWidth, p.y); + childShell.setLocation(p.x - childShellWidth, p.y - 90); popup = new Canvas(childShell, SWT.DOUBLE_BUFFERED | SWT.TRANSPARENCY_ALPHA); @@ -569,7 +529,7 @@ public class ImageViewer extends Composite { childShell.setSize(childShellWidth, childShellHeight); Point p = canvas.toDisplay(0, 0); - childShell.setLocation(p.x - childShellWidth, p.y); + childShell.setLocation(p.x - childShellWidth, p.y - 90); childShell.redraw(); } }); -- 2.7.4