diff --git a/.mvn/extensions.xml b/.mvn/extensions.xml
index 5f188e157a5..a10e798528a 100644
--- a/.mvn/extensions.xml
+++ b/.mvn/extensions.xml
@@ -4,6 +4,6 @@
org.eclipse.tycho
tycho-build
- 5.0.1
+ 5.0.2
\ No newline at end of file
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
index 64ad85edbd4..c762cbce982 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/gtk/org/eclipse/swt/widgets/Control.java
@@ -5091,6 +5091,7 @@ boolean sendMouseEvent (int type, int button, int count, int detail, boolean sen
flushQueueOnDnd();
} else {
dragDetectionQueue.add(event);
+ return true;
}
break;
case SWT.MouseUp:
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
index c9336d0925e..bd6373392ab 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics/Image.java
@@ -238,8 +238,7 @@ private boolean isReusable(int width, int height) {
private Optional createHandleAtExactSize(int width, int height) {
Optional imageData = imageProvider.loadImageDataAtExactSize(width, height);
if (imageData.isPresent()) {
- ImageData adaptedData = adaptImageDataIfDisabledOrGray(imageData.get());
- temporaryHandleContainer = init(adaptedData, -1);
+ temporaryHandleContainer = init(imageData.get(), -1);
return Optional.of(temporaryHandleContainer);
}
return Optional.empty();
@@ -253,8 +252,7 @@ private InternalImageHandle getOrCreateImageHandleAtClosestSize(int widthHint, i
InternalImageHandle bestFittingHandle = imageHandleManager.get(imageZoom);
if (bestFittingHandle == null) {
ImageData bestFittingImageData = imageProvider.loadImageData(imageZoom).element();
- ImageData adaptedData = adaptImageDataIfDisabledOrGray(bestFittingImageData);
- bestFittingHandle = temporaryHandleContainer = init(adaptedData, -1);
+ bestFittingHandle = temporaryHandleContainer = init(bestFittingImageData, -1);
}
return bestFittingHandle;
}
@@ -771,6 +769,10 @@ public Image(Device device, ImageGcDrawer imageGcDrawer, int width, int height)
init();
}
+private ElementAtZoom adaptImageDataIfDisabledOrGray(ElementAtZoom dataAtZoom) {
+ return new ElementAtZoom<>(adaptImageDataIfDisabledOrGray(dataAtZoom.element()), dataAtZoom.zoom());
+}
+
private ImageData adaptImageDataIfDisabledOrGray(ImageData data) {
ImageData returnImageData = null;
switch (this.styleFlag) {
@@ -2058,6 +2060,10 @@ protected boolean isPersistentImageHandleRequriedForImageData() {
return false;
}
+ /**
+ * Returns image data at the best-fitting available zoom for the given zoom.
+ * The returned data will have a potential gray/disable style applied.
+ */
protected abstract ElementAtZoom loadImageData(int zoom);
abstract ImageData newImageData(int zoom);
@@ -2071,6 +2077,10 @@ ElementAtZoom getClosestAvailableImageData(int zoom) {
return new ElementAtZoom<>(imageData, closestZoom);
}
+ /**
+ * Returns image data at the exact requested size if available.
+ * The returned data will have a potential gray/disable style applied.
+ */
protected Optional loadImageDataAtExactSize(int width, int height) {
return Optional.empty(); // exact size not available
}
@@ -2174,7 +2184,6 @@ protected DestroyableImageHandle newImageHandle(ZoomContext zoomContext) {
private DestroyableImageHandle initializeHandleFromSource(ZoomContext zoomContext) {
ElementAtZoom imageDataAtZoom = loadImageData(zoomContext.targetZoom());
ImageData imageData = DPIUtil.scaleImageData(device, imageDataAtZoom.element(), zoomContext.targetZoom(), imageDataAtZoom.zoom());
- imageData = adaptImageDataIfDisabledOrGray(imageData);
return newImageHandle(imageData, zoomContext);
}
}
@@ -2202,7 +2211,8 @@ protected Rectangle getBounds(int zoom) {
@Override
protected ElementAtZoom loadImageData(int zoom) {
- return new ElementAtZoom<>(imageDataAtBaseZoom, baseZoom);
+ ImageData adaptedImageData = adaptImageDataIfDisabledOrGray(imageDataAtBaseZoom);
+ return new ElementAtZoom<>(adaptedImageData, baseZoom);
}
@Override
@@ -2233,7 +2243,8 @@ protected ElementAtZoom loadImageData(int zoom) {
ImageData scaledMask = DPIUtil.scaleImageData(device, maskAt100, zoom, 100);
scaledMask = ImageData.convertMask(scaledMask);
ImageData mergedData = applyMask(scaledSource, scaledMask);
- return new ElementAtZoom<>(mergedData, zoom);
+ ImageData adaptedData = adaptImageDataIfDisabledOrGray(mergedData);
+ return new ElementAtZoom<>(adaptedData, zoom);
}
@Override
@@ -2260,7 +2271,8 @@ private ImageDataLoaderStreamProviderWrapper(byte[] inputStreamData) {
@Override
protected ElementAtZoom loadImageData(int zoom) {
- return ImageDataLoader.loadByZoom(new ByteArrayInputStream(inputStreamData), FileFormat.DEFAULT_ZOOM, zoom);
+ ElementAtZoom imageDataAtZoom = ImageDataLoader.loadByZoom(new ByteArrayInputStream(inputStreamData), FileFormat.DEFAULT_ZOOM, zoom);
+ return adaptImageDataIfDisabledOrGray(imageDataAtZoom);
}
@Override
@@ -2278,7 +2290,8 @@ AbstractImageProviderWrapper createCopy(Image image) {
protected Optional loadImageDataAtExactSize(int targetWidth, int targetHeight) {
if (ImageDataLoader.isDynamicallySizable(new ByteArrayInputStream(this.inputStreamData))) {
ImageData imageDataAtSize = ImageDataLoader.loadBySize(new ByteArrayInputStream(this.inputStreamData), targetWidth, targetHeight);
- return Optional.of(imageDataAtSize);
+ ImageData adaptedImageDataAtSize = adaptImageDataIfDisabledOrGray(imageDataAtSize);
+ return Optional.of(adaptedImageDataAtSize);
}
return Optional.empty();
}
@@ -2470,7 +2483,6 @@ protected DestroyableImageHandle newImageHandle(ZoomContext zoomContext) {
private DestroyableImageHandle initializeHandleFromSource(int zoom) {
ElementAtZoom imageDataAtZoom = loadImageData(zoom);
ImageData imageData = DPIUtil.scaleImageData (device, imageDataAtZoom.element(), zoom, imageDataAtZoom.zoom());
- imageData = adaptImageDataIfDisabledOrGray(imageData);
return init(imageData, zoom);
}
@@ -2497,7 +2509,8 @@ protected ElementAtZoom loadImageData(int zoom) {
// Load at appropriate zoom via loader
if (fileForZoom.zoom() != zoom && ImageDataLoader.canLoadAtZoom(fileForZoom.element(), fileForZoom.zoom(), zoom)) {
ElementAtZoom imageDataAtZoom = ImageDataLoader.loadByZoom(fileForZoom.element(), fileForZoom.zoom(), zoom);
- return new ElementAtZoom<>(imageDataAtZoom.element(), zoom);
+ ImageData adaptedImageData = adaptImageDataIfDisabledOrGray(imageDataAtZoom.element());
+ return new ElementAtZoom<>(adaptedImageData, zoom);
}
// Load at file zoom (native or via loader) and rescale
@@ -2517,7 +2530,7 @@ protected ElementAtZoom loadImageData(int zoom) {
temporaryImageHandle.destroy();
}
}
- return imageDataAtZoom;
+ return adaptImageDataIfDisabledOrGray(imageDataAtZoom);
}
@Override
@@ -2727,7 +2740,8 @@ protected Optional loadImageDataAtExactSize(int targetWidth, int targ
String fileName = DPIUtil.validateAndGetImagePathAtZoom(this.provider, 100).element();
if (ImageDataLoader.isDynamicallySizable(fileName)) {
ImageData imageDataAtSize = ImageDataLoader.loadBySize(fileName, targetWidth, targetHeight);
- return Optional.of(imageDataAtSize);
+ ImageData adaptedImageDataAtSize = adaptImageDataIfDisabledOrGray(imageDataAtSize);
+ return Optional.of(adaptedImageDataAtSize);
}
return Optional.empty();
}
@@ -2740,7 +2754,8 @@ private class ImageDataProviderWrapper extends BaseImageProviderWrapper loadImageData(int zoom) {
- return DPIUtil.validateAndGetImageDataAtZoom (provider, zoom);
+ ElementAtZoom imageDataAtZoom = DPIUtil.validateAndGetImageDataAtZoom (provider, zoom);
+ return adaptImageDataIfDisabledOrGray(imageDataAtZoom);
}
@Override
@@ -2756,7 +2771,8 @@ protected Optional loadImageDataAtExactSize(int targetWidth, int targ
SWT.error(SWT.ERROR_INVALID_ARGUMENT, null,
" ImageDataAtSizeProvider returned null for width=" + targetWidth + ", height=" + targetHeight);
}
- return Optional.of(imageData);
+ ImageData adaptedImageData = adaptImageDataIfDisabledOrGray(imageData);
+ return Optional.of(adaptedImageData);
}
return Optional.empty();
}
diff --git a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ImageList.java b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ImageList.java
index b21c849346f..b6da1704a08 100644
--- a/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ImageList.java
+++ b/bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/internal/ImageList.java
@@ -331,10 +331,6 @@ public Image get (int index) {
return images [index];
}
-public int getStyle () {
- return style;
-}
-
public long getHandle(int targetZoom) {
if (!zoomToHandle.containsKey(targetZoom)) {
int scaledWidth = DPIUtil.pointToPixel(DPIUtil.pixelToPoint(width, this.zoom), targetZoom);
@@ -374,6 +370,11 @@ public Point getImageSize() {
return Win32DPIUtils.pixelToPointAsSize(new Point (cx [0], cy [0]), zoom);
}
+public boolean isFittingFor(int style, int width, int height, int zoom) {
+ Point imageSize = getImageSize();
+ return this.style == style && imageSize.x == width && imageSize.y == height && this.zoom == zoom;
+}
+
public int indexOf (Image image) {
int count = OS.ImageList_GetImageCount (handle);
for (int i=0; i