Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -154,25 +154,6 @@ public Cursor(Device device, ImageData source, ImageData mask, int hotspotX, int
this.device.registerResourceWithZoomSupport(this);
}

private static CursorHandle setupCursorFromImageData(ImageData source, ImageData mask, int hotspotX, int hotspotY) {
if (mask == null) {
mask = source.getTransparencyMask();
}
/* Convert depth to 1 */
mask = ImageData.convertMask(mask);
source = ImageData.convertMask(source);

/* Make sure source and mask scanline pad is 2 */
byte[] sourceData = ImageData.convertPad(source.data, source.width, source.height, source.depth, source.scanlinePad, 2);
byte[] maskData = ImageData.convertPad(mask.data, mask.width, mask.height, mask.depth, mask.scanlinePad, 2);

/* Create the cursor */
long hInst = OS.GetModuleHandle(null);
long handle = OS.CreateCursor(hInst, hotspotX, hotspotY, source.width, source.height, sourceData, maskData);
if (handle == 0) SWT.error(SWT.ERROR_NO_HANDLES);
return new CustomCursorHandle(handle);
}

/**
* Constructs a new cursor given a device, image data describing
* the desired cursor appearance, and the x and y coordinates of
Expand Down Expand Up @@ -209,7 +190,7 @@ public Cursor(Device device, ImageData source, int hotspotX, int hotspotY) {
this.device.registerResourceWithZoomSupport(this);
}

private static CursorHandle setupCursorFromImageData(Device device, ImageData source, int hotspotX, int hotspotY) {
private static CursorHandle setupCursorFromImageData(Device device, ImageData source, ImageData mask, int hotspotX, int hotspotY) {
if (source == null) SWT.error(SWT.ERROR_NULL_ARGUMENT);
long hBitmap = 0;
long hMask = 0;
Expand Down Expand Up @@ -258,7 +239,9 @@ private static CursorHandle setupCursorFromImageData(Device device, ImageData so
hMask = OS.CreateBitmap(source.width, source.height, 1, 1, new byte[(((source.width + 7) / 8) + 3) / 4 * 4 * source.height]);
if (hMask == 0) SWT.error(SWT.ERROR_NO_HANDLES);
} else {
ImageData mask = source.getTransparencyMask();
if (mask == null) {
mask = source.getTransparencyMask();
}
long [] result = Image.initIcon(device, source, mask);
hBitmap = result[0];
hMask = result[1];
Expand Down Expand Up @@ -649,7 +632,7 @@ public CursorHandle createHandle(Device device, int zoom) {
source = tempImage.getImageData(zoom);
tempImage.dispose();
}
return setupCursorFromImageData(device, source, getHotpotXInPixels(zoom), getHotpotYInPixels(zoom));
return setupCursorFromImageData(device, source, null, getHotpotXInPixels(zoom), getHotpotYInPixels(zoom));
}
}

Expand All @@ -667,7 +650,7 @@ public ImageDataCursorHandleProvider(ImageData source, int hotspotX, int hotspot
public CursorHandle createHandle(Device device, int zoom) {
int accessibilityFactor = getPointerSizeScaleFactor();
ImageData scaledSource = DPIUtil.scaleImageData(device, this.source, zoom * accessibilityFactor, DEFAULT_ZOOM);
return setupCursorFromImageData(device, scaledSource, getHotpotXInPixels(zoom),
return setupCursorFromImageData(device, scaledSource, null, getHotpotXInPixels(zoom),
getHotpotYInPixels(zoom));
}
}
Expand Down Expand Up @@ -697,10 +680,12 @@ private void validateMask(ImageData source, ImageData mask) {

@Override
public CursorHandle createHandle(Device device, int zoom) {
ImageData scaledSource = DPIUtil.scaleImageData(device, this.source, zoom, DEFAULT_ZOOM);
ImageData scaledMask = this.mask != null ? DPIUtil.scaleImageData(device, mask, zoom, DEFAULT_ZOOM)
ImageData scaledSource = DPIUtil.scaleImageData(device, this.source, getPointerSizeScaleFactor() * zoom, DEFAULT_ZOOM);
ImageData scaledMask = this.mask != null ? DPIUtil.scaleImageData(device, mask, getPointerSizeScaleFactor() * zoom, DEFAULT_ZOOM)
: null;
return setupCursorFromImageData(scaledSource, scaledMask, getHotpotXInPixels(zoom), getHotpotYInPixels(zoom));

return setupCursorFromImageData(device, scaledSource, scaledMask, getHotpotXInPixels(zoom),
getHotpotYInPixels(zoom));
}
}

Expand Down
Loading