Skip to content

Commit 9e112ba

Browse files
committed
Enable Draw2D auto-scaling by default
This renames the "draw2d.disableAutoscale" environment variable introduced with 1bd2883 to "draw2d.enableAutoscale". In addition, this property now needs to be explicitly disabled. By doing so, we drastically increase the visibility of this feature and reduce the changes that need to be done by consumer projects.
1 parent ba94913 commit 9e112ba

File tree

4 files changed

+16
-13
lines changed

4 files changed

+16
-13
lines changed

org.eclipse.draw2d/src/org/eclipse/draw2d/PopUpHelper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ protected PopUpHelper(Control c, int shellStyle) {
7777
* @since 2.0
7878
*/
7979
protected LightweightSystem createLightweightSystem() {
80-
return InternalDraw2dUtils.disableAutoscale ? new PopupHelperLightweightSystem() : new LightweightSystem();
80+
return InternalDraw2dUtils.isAutoScaleEnabled() ? new PopupHelperLightweightSystem() : new LightweightSystem();
8181
}
8282

8383
/**

org.eclipse.draw2d/src/org/eclipse/draw2d/internal/InternalDraw2dUtils.java

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,20 @@
1919

2020
public class InternalDraw2dUtils {
2121
/**
22-
* System property that controls the disablement of any autoScale functionality.
22+
* System property that controls the enabled of the Draw2D autoScale
23+
* functionality (replacing the native SWT autoScale functionality).
24+
* <p>
2325
* Currently it only has effects when executed on Windows.
26+
* </p>
2427
*
2528
* <ul>
26-
* <li><b>false</b>: autoScale functionality is enabled</li>
27-
* <li><b>true</b>: autoScale functionality is disabled<</li>
29+
* <li><b>true</b>: autoScale functionality is enabled</li>
30+
* <li><b>false</b>: autoScale functionality is disabled<</li>
2831
*
2932
* </ul>
30-
* The current default is "false".
33+
* The current default is "true".
3134
*/
32-
private static final String DRAW2D_DISABLE_AUTOSCALE = "draw2d.disableAutoscale"; //$NON-NLS-1$
35+
private static final String DRAW2D_ENABLE_AUTOSCALE = "draw2d.enableAutoscale"; //$NON-NLS-1$
3336

3437
/**
3538
* Internal flag for fetching the shell zoom
@@ -41,15 +44,15 @@ public class InternalDraw2dUtils {
4144
*/
4245
private static final String DATA_AUTOSCALE_DISABLED = "AUTOSCALE_DISABLED"; //$NON-NLS-1$
4346

44-
public static boolean disableAutoscale;
47+
private static final boolean enableAutoScale = "win32".equals(SWT.getPlatform()) //$NON-NLS-1$
48+
&& Boolean.parseBoolean(System.getProperty(DRAW2D_ENABLE_AUTOSCALE, Boolean.TRUE.toString()));
4549

46-
static {
47-
disableAutoscale = "win32".equals(SWT.getPlatform()) //$NON-NLS-1$
48-
&& Boolean.parseBoolean(System.getProperty(DRAW2D_DISABLE_AUTOSCALE));
50+
public static boolean isAutoScaleEnabled() {
51+
return enableAutoScale;
4952
}
5053

5154
public static void configureForAutoscalingMode(Control control, Consumer<Double> zoomConsumer) {
52-
if (control == null || !disableAutoscale) {
55+
if (control == null || !isAutoScaleEnabled()) {
5356
return;
5457
}
5558
control.setData(InternalDraw2dUtils.DATA_AUTOSCALE_DISABLED, true);

org.eclipse.gef/src/org/eclipse/gef/ui/parts/AbstractEditPartViewer.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,7 @@ protected void hookControl() {
486486
if (contextMenu != null) {
487487
control.setMenu(contextMenu.createContextMenu(getControl()));
488488
}
489-
if (InternalDraw2dUtils.disableAutoscale) {
489+
if (InternalDraw2dUtils.isAutoScaleEnabled()) {
490490
InternalDraw2dUtils.configureForAutoscalingMode(control,
491491
scale -> setProperty(InternalGEFPlugin.MONITOR_SCALE_PROPERTY, scale));
492492
}

org.eclipse.zest.core/src/org/eclipse/zest/core/widgets/Graph.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ public void dispatchMouseMoved(org.eclipse.swt.events.MouseEvent me) {
240240
this.zoomListener = new ZoomGestureListener();
241241
this.rotateListener = new RotateGestureListener();
242242

243-
if (InternalDraw2dUtils.disableAutoscale) {
243+
if (InternalDraw2dUtils.isAutoScaleEnabled()) {
244244
InternalDraw2dUtils.configureForAutoscalingMode(this, rootlayer::setScale);
245245
}
246246

0 commit comments

Comments
 (0)