From e9d18f31deb7590cbd41460f16b1015b4f6975cd Mon Sep 17 00:00:00 2001 From: Sarika Sinha Date: Thu, 13 Apr 2017 10:05:22 +0530 Subject: Bug 515145 - [HiDPI] Composite Platform Debug icons should use high-resolution images Change-Id: I3d0b2ed0794e4da4ac30f74e57c06904ad824da6 --- .../internal/ui/CompositeDebugImageDescriptor.java | 19 ++- .../LaunchConfigurationTabImageDescriptor.java | 19 ++- .../viewers/breadcrumb/BreadcrumbItemDropDown.java | 128 ++++++++++----------- 3 files changed, 77 insertions(+), 89 deletions(-) diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/CompositeDebugImageDescriptor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/CompositeDebugImageDescriptor.java index 0dc0257a2..47e19a9b7 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/CompositeDebugImageDescriptor.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/CompositeDebugImageDescriptor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,7 +15,6 @@ import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.jface.resource.CompositeImageDescriptor; import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.Point; /** @@ -49,8 +48,8 @@ public class CompositeDebugImageDescriptor extends CompositeImageDescriptor { @Override protected Point getSize() { if (fSize == null) { - ImageData data= getBaseImage().getImageData(); - setSize(new Point(data.width, data.height)); + CachedImageDataProvider provider = createCachedImageDataProvider(getBaseImage()); + setSize(new Point(provider.getWidth(), provider.getHeight())); } return fSize; } @@ -80,11 +79,7 @@ public class CompositeDebugImageDescriptor extends CompositeImageDescriptor { */ @Override protected void drawCompositeImage(int width, int height) { - ImageData bg= getBaseImage().getImageData(); - if (bg == null) { - bg= DEFAULT_IMAGE_DATA; - } - drawImage(bg, 0, 0); + drawImage(createCachedImageDataProvider(getBaseImage()), 0, 0); drawOverlays(); } @@ -95,12 +90,12 @@ public class CompositeDebugImageDescriptor extends CompositeImageDescriptor { int flags= getFlags(); int x= 0; int y= 0; - ImageData data= null; + CachedImageDataProvider provider; if ((flags & SKIP_BREAKPOINT) != 0) { x= 0; y= 0; - data= DebugUITools.getImage(IDebugUIConstants.IMG_OVR_SKIP_BREAKPOINT).getImageData(); - drawImage(data, x, y); + provider = createCachedImageDataProvider(DebugUITools.getImage(IDebugUIConstants.IMG_OVR_SKIP_BREAKPOINT)); + drawImage(provider, x, y); } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabImageDescriptor.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabImageDescriptor.java index 765c496a6..21a7a4f8d 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabImageDescriptor.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/launchConfigurations/LaunchConfigurationTabImageDescriptor.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2000, 2005 IBM Corporation and others. + * Copyright (c) 2000, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -15,7 +15,6 @@ import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.jface.resource.CompositeImageDescriptor; import org.eclipse.swt.graphics.Image; -import org.eclipse.swt.graphics.ImageData; import org.eclipse.swt.graphics.Point; /** @@ -49,8 +48,8 @@ public class LaunchConfigurationTabImageDescriptor extends CompositeImageDescrip @Override protected Point getSize() { if (fSize == null) { - ImageData data= getBaseImage().getImageData(); - setSize(new Point(data.width, data.height)); + CachedImageDataProvider provider = createCachedImageDataProvider(getBaseImage()); + setSize(new Point(provider.getWidth(), provider.getHeight())); } return fSize; } @@ -81,11 +80,7 @@ public class LaunchConfigurationTabImageDescriptor extends CompositeImageDescrip */ @Override protected void drawCompositeImage(int width, int height) { - ImageData bg= getBaseImage().getImageData(); - if (bg == null) { - bg= DEFAULT_IMAGE_DATA; - } - drawImage(bg, 0, 0); + drawImage(createCachedImageDataProvider(getBaseImage()), 0, 0); drawOverlays(); } @@ -94,10 +89,10 @@ public class LaunchConfigurationTabImageDescriptor extends CompositeImageDescrip */ protected void drawOverlays() { int flags= getFlags(); - ImageData data= null; + CachedImageDataProvider provider; if ((flags & ERROR) != 0) { - data= DebugUITools.getImage(IDebugUIConstants.IMG_OVR_ERROR).getImageData(); - drawImage(data, 0, 0); + provider = createCachedImageDataProvider(DebugUITools.getImage(IDebugUIConstants.IMG_OVR_ERROR)); + drawImage(provider, 0, 0); } } diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItemDropDown.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItemDropDown.java index c29ac5500..76411f3de 100644 --- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItemDropDown.java +++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/breadcrumb/BreadcrumbItemDropDown.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2012 IBM Corporation and others. + * Copyright (c) 2008, 2017 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -36,6 +36,7 @@ import org.eclipse.swt.graphics.Color; import org.eclipse.swt.graphics.GC; import org.eclipse.swt.graphics.Image; import org.eclipse.swt.graphics.ImageData; +import org.eclipse.swt.graphics.ImageDataProvider; import org.eclipse.swt.graphics.Point; import org.eclipse.swt.graphics.RGB; import org.eclipse.swt.graphics.Rectangle; @@ -67,13 +68,13 @@ class BreadcrumbItemDropDown implements IBreadcrumbDropDownSite { * mode. If ltr is true the arrow points to the right, otherwise it * points to the left. */ - private final class AccessibelArrowImage extends CompositeImageDescriptor { + private final class AccessibleArrowImage extends CompositeImageDescriptor { private final static int ARROW_SIZE= 5; private final boolean fLTR; - public AccessibelArrowImage(boolean ltr) { + public AccessibleArrowImage(boolean ltr) { fLTR= ltr; } @@ -83,52 +84,36 @@ class BreadcrumbItemDropDown implements IBreadcrumbDropDownSite { @Override protected void drawCompositeImage(int width, int height) { Display display= fParentComposite.getDisplay(); - - Image image= new Image(display, ARROW_SIZE, ARROW_SIZE * 2); - - GC gc= new GC(image); - - Color triangle= createColor(SWT.COLOR_LIST_FOREGROUND, SWT.COLOR_LIST_BACKGROUND, 20, display); - Color aliasing= createColor(SWT.COLOR_LIST_FOREGROUND, SWT.COLOR_LIST_BACKGROUND, 30, display); - gc.setBackground(triangle); - - if (fLTR) { - gc.fillPolygon(new int[] { mirror(0), 0, mirror(ARROW_SIZE), ARROW_SIZE, mirror(0), ARROW_SIZE * 2 }); - } else { - gc.fillPolygon(new int[] { ARROW_SIZE, 0, 0, ARROW_SIZE, ARROW_SIZE, ARROW_SIZE * 2 }); - } - - gc.setForeground(aliasing); - gc.drawLine(mirror(0), 1, mirror(ARROW_SIZE - 1), ARROW_SIZE); - gc.drawLine(mirror(ARROW_SIZE - 1), ARROW_SIZE, mirror(0), ARROW_SIZE * 2 - 1); - - gc.dispose(); - triangle.dispose(); - aliasing.dispose(); - - ImageData imageData= image.getImageData(); - for (int y= 1; y < ARROW_SIZE; y++) { - for (int x= 0; x < y; x++) { - imageData.setAlpha(mirror(x), y, 255); + ImageDataProvider imageProvider = zoom -> { + Image image = new Image(display, ARROW_SIZE, ARROW_SIZE * 2); + + GC gc = new GC(image, fLTR ? SWT.LEFT_TO_RIGHT : SWT.RIGHT_TO_LEFT); + gc.setAntialias(SWT.ON); + + Color triangleColor = createColor(SWT.COLOR_LIST_FOREGROUND, SWT.COLOR_LIST_BACKGROUND, 20, display); + gc.setBackground(triangleColor); + gc.fillPolygon(new int[] { + 0, 0, ARROW_SIZE, ARROW_SIZE, 0, ARROW_SIZE * 2 }); + gc.dispose(); + triangleColor.dispose(); + + ImageData imageData = image.getImageData(zoom); + image.dispose(); + int zoomedArrowSize = ARROW_SIZE * zoom / 100; + for (int y1 = 0; y1 < zoomedArrowSize; y1++) { + for (int x1 = 0; x1 <= y1; x1++) { + imageData.setAlpha(fLTR ? x1 : zoomedArrowSize - x1 - 1, y1, 255); + } } - } - for (int y= 0; y < ARROW_SIZE; y++) { - for (int x= 0; x <= y; x++) { - imageData.setAlpha(mirror(x), ARROW_SIZE * 2 - y - 1, 255); + for (int y2 = 0; y2 < zoomedArrowSize; y2++) { + for (int x2 = 0; x2 <= y2; x2++) { + imageData.setAlpha(fLTR ? x2 : zoomedArrowSize - x2 - 1, zoomedArrowSize * 2 - y2 - 1, 255); + } } - } + return imageData; + }; + drawImage(imageProvider, (width / 2) - (ARROW_SIZE / 2), (height / 2) - ARROW_SIZE); - int offset= fLTR ? 0 : -1; - drawImage(imageData, (width / 2) - (ARROW_SIZE / 2) + offset, (height / 2) - ARROW_SIZE - 1); - - image.dispose(); - } - - private int mirror(int x) { - if (fLTR) - return x; - - return ARROW_SIZE - x - 1; } /* @@ -193,12 +178,14 @@ class BreadcrumbItemDropDown implements IBreadcrumbDropDownSite { @Override public void run() { Shell shell= fParent.getDropDownShell(); - if (shell != null) + if (shell != null) { return; + } shell= fParent.getViewer().getDropDownShell(); - if (shell != null && !shell.isDisposed()) + if (shell != null && !shell.isDisposed()) { shell.close(); + } showMenu(); @@ -206,7 +193,7 @@ class BreadcrumbItemDropDown implements IBreadcrumbDropDownSite { } }; - showDropDownMenuAction.setImageDescriptor(new AccessibelArrowImage(isLeft())); + showDropDownMenuAction.setImageDescriptor(new AccessibleArrowImage(isLeft())); showDropDownMenuAction.setToolTipText(BreadcrumbMessages.BreadcrumbItemDropDown_showDropDownMenu_action_toolTip); manager.add(showDropDownMenuAction); @@ -257,8 +244,9 @@ class BreadcrumbItemDropDown implements IBreadcrumbDropDownSite { * @return the drop down shell or null */ public Shell getDropDownShell() { - if (!isMenuShown()) + if (!isMenuShown()) { return null; + } return fShell; } @@ -271,8 +259,9 @@ class BreadcrumbItemDropDown implements IBreadcrumbDropDownSite { DebugUIPlugin.trace("BreadcrumbItemDropDown.showMenu()"); //$NON-NLS-1$ } - if (!fEnabled || fMenuIsShown) + if (!fEnabled || fMenuIsShown) { return; + } fMenuIsShown= true; @@ -287,8 +276,9 @@ class BreadcrumbItemDropDown implements IBreadcrumbDropDownSite { */ @Override public void controlResized(ControlEvent e) { - if (fIsResizingProgrammatically) - return; + if (fIsResizingProgrammatically) { + return; + } Point size= fShell.getSize(); fCurrentWidth = size.x; @@ -412,8 +402,9 @@ class BreadcrumbItemDropDown implements IBreadcrumbDropDownSite { if (DebugUIPlugin.DEBUG_BREADCRUMB) { DebugUIPlugin.trace("==> shellClosed"); //$NON-NLS-1$ } - if (!fMenuIsShown) + if (!fMenuIsShown) { return; + } fMenuIsShown= false; } @@ -435,8 +426,9 @@ class BreadcrumbItemDropDown implements IBreadcrumbDropDownSite { private IDialogSettings getDialogSettings() { IDialogSettings javaSettings= DebugUIPlugin.getDefault().getDialogSettings(); IDialogSettings settings= javaSettings.getSection(DIALOG_SETTINGS); - if (settings == null) - settings= javaSettings.addNewSection(DIALOG_SETTINGS); + if (settings == null) { + settings= javaSettings.addNewSection(DIALOG_SETTINGS); + } return settings; } @@ -477,24 +469,28 @@ class BreadcrumbItemDropDown implements IBreadcrumbDropDownSite { Rectangle trim= fShell.computeTrim(0, 0, width, height); int x= toolbarBounds.x + toolbarBounds.width + 2 + trim.x - imageBoundsX; - if (!isLeft()) + if (!isLeft()) { x+= width; + } int y = rect.y; - if (isTop()) - y+= rect.height; - else - y-= height; + if (isTop()) { + y+= rect.height; + } else { + y-= height; + } Point pt= new Point(x, y); pt= fParentComposite.toDisplay(pt); Rectangle monitor= getClosestMonitor(shell.getDisplay(), pt).getClientArea(); int overlap= (pt.x + width) - (monitor.x + monitor.width); - if (overlap > 0) + if (overlap > 0) { pt.x-= overlap; - if (pt.x < monitor.x) + } + if (pt.x < monitor.x) { pt.x= monitor.x; + } shell.setLocation(pt); fIsResizingProgrammatically= true; @@ -529,8 +525,9 @@ class BreadcrumbItemDropDown implements IBreadcrumbDropDownSite { Rectangle clientArea= current.getClientArea(); - if (clientArea.contains(point)) + if (clientArea.contains(point)) { return current; + } int distance= Geometry.distanceSquared(Geometry.centerPoint(clientArea), point); if (distance < closest) { @@ -552,8 +549,9 @@ class BreadcrumbItemDropDown implements IBreadcrumbDropDownSite { int maxHeight= getMaxHeight(); int maxWidth = getMaxWidth(); - if (fCurrentHeight >= maxHeight && fCurrentWidth >= maxWidth) + if (fCurrentHeight >= maxHeight && fCurrentWidth >= maxWidth) { return; + } Point preferedSize= shell.computeSize(SWT.DEFAULT, SWT.DEFAULT, true); -- cgit v1.2.3