Package panamagl.canvas.swt
Class PixelScaleSupportSWT
java.lang.Object
panamagl.canvas.swt.PixelScaleSupportSWT
HiDPI plumbing for
GLCanvasSWT.
Reads the pixel scale platform by platform:
- cocoa:
MacOSBackingScaleFactor.read(org.eclipse.swt.widgets.Control), because SWT'sMonitor.getZoom()returns 100 on Retina; - gtk / win32:
canvas.getMonitor().getZoom() / 100.0.
Wires SWT.ZoomChanged on the display (available since SWT 4.24 / 3.122 — confirmed in
3.126.0). On macOS, additionally listens to SWT.Move on the canvas because cocoa does
not fire ZoomChanged when the window is moved between Retina and non-Retina monitors.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddListener(panamagl.canvas.PixelScaleListener l) panamagl.canvas.PixelScalecurrent()panamagl.canvas.PixelScaleread()Read the current pixel scale based on the platform-specific source.voidremoveListener(panamagl.canvas.PixelScaleListener l) voidstart()Install listeners.voidstop()
-
Constructor Details
-
PixelScaleSupportSWT
public PixelScaleSupportSWT(org.eclipse.swt.widgets.Canvas canvas)
-
-
Method Details
-
read
public panamagl.canvas.PixelScale read()Read the current pixel scale based on the platform-specific source. -
current
public panamagl.canvas.PixelScale current() -
start
public void start()Install listeners. Idempotent. Must be called from the SWT display thread. -
stop
public void stop() -
addListener
public void addListener(panamagl.canvas.PixelScaleListener l) -
removeListener
public void removeListener(panamagl.canvas.PixelScaleListener l)
-