-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[Win] Disallow autoscale mode "integer" for monitor-specific scaling #1721
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -650,11 +650,49 @@ public static int getZoomForAutoscaleProperty (int nativeDeviceZoom) { | |
return zoom; | ||
} | ||
|
||
public static boolean isAutoScaleOnRuntimeActive() { | ||
public static boolean isMonitorSpecificScalingActive() { | ||
boolean updateOnRuntimeValue = Boolean.getBoolean (SWT_AUTOSCALE_UPDATE_ON_RUNTIME); | ||
return updateOnRuntimeValue; | ||
} | ||
|
||
public static void setAutoScaleForMonitorSpecificScaling() { | ||
boolean isDefaultAutoScale = autoScaleValue == null; | ||
if (isDefaultAutoScale) { | ||
autoScaleValue = "quarter"; | ||
} else if (!isSupportedAutoScaleForMonitorSpecificScaling()) { | ||
throw new SWTError(SWT.ERROR_NOT_IMPLEMENTED, | ||
"monitor-specific scaling is only implemented for auto-scale values \"quarter\", \"exact\", \"false\" or a concrete zoom value, but \"" | ||
+ autoScaleValue + "\" has been specified"); | ||
} | ||
} | ||
|
||
/** | ||
* Monitor-specific scaling on Windows only supports auto-scale modes in which | ||
* all elements (font, images, control bounds etc.) are scaled equally or almost | ||
* equally. The previously default mode "integer"/"integer200", which rounded | ||
* the scale factor for everything but fonts to multiples of 100, is complex and | ||
* difficult to realize with monitor-specific rescaling of UI elements. Since a | ||
* uniform scale factor for everything should perspectively be used anyway, | ||
* there will be support for complex auto-scale modes for monitor-specific | ||
* scaling. | ||
* | ||
* The supported modes are "quarter" and "exact" or explicit zoom values given | ||
* by the value itself or "false". Every other value will be treated as | ||
* "integer"/"integer200" and is thus not supported. | ||
*/ | ||
private static boolean isSupportedAutoScaleForMonitorSpecificScaling() { | ||
switch (autoScaleValue) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Other parts of the class work with I though about using: |
||
case "false", "quarter", "exact": return true; | ||
} | ||
try { | ||
Integer.parseInt(autoScaleValue); | ||
return true; | ||
} catch (NumberFormatException e) { | ||
// unsupported value, use default | ||
} | ||
return false; | ||
} | ||
|
||
/** | ||
* AutoScale ImageDataProvider. | ||
*/ | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just thought about: should we have a comment here, why only those values are supported?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, that's a good idea. I added some documentation about why only those values are supported. @akoch-yatta can you have a look whether you think the description is okay?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I think is explanation is good