Skip to content
Draft
Show file tree
Hide file tree
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 @@ -3,7 +3,7 @@ Fragment-Host: org.eclipse.swt;bundle-version="[3.128.0,4.0.0)"
Bundle-Name: %fragmentName
Bundle-Vendor: %providerName
Bundle-SymbolicName: org.eclipse.swt.win32.win32.x86_64; singleton:=true
Bundle-Version: 3.133.0.qualifier
Bundle-Version: 3.132.0.qualifier
Bundle-ManifestVersion: 2
Bundle-Localization: fragment
Export-Package:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3527,6 +3527,13 @@ NSTouch findTouchWithId(NSArray touches, NSObject identity) {
return null;
}

/**
* @since 3.132
*/
public boolean setAutoscaleDisabled(boolean autoscaleDisabled) {
return false;
}

void setBackground () {
if (!drawsBackground()) return;
Control control = findBackgroundControl ();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@
import org.eclipse.swt.*;
import org.eclipse.swt.events.*;
import org.eclipse.swt.graphics.*;
import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.cocoa.*;
import org.eclipse.swt.internal.win32.*;

/**
* Instances of this class represent the "windows"
Expand Down Expand Up @@ -1976,6 +1978,10 @@ public void setModified (boolean modified) {
window.setDocumentEdited (modified);
}

public int getNativeZoom() {
return DPIUtil.getNativeDeviceZoom();
}

/**
* Sets the shape of the shell to the region specified
* by the argument. When the argument is null, the
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.eclipse.swt.graphics;

public enum AutoscalingMode {
ENABLED,
DISABLED,
DISABLED_INHERITED
}
Original file line number Diff line number Diff line change
Expand Up @@ -5143,6 +5143,13 @@ void gtk_label_set_align(long label, float xAlign, float yAlign) {
GTK.gtk_label_set_yalign(label, yAlign);
}

/**
* @since 3.132
*/
public boolean setAutoscaleDisabled(boolean autoscaleDisabled) {
return false;
}

void setBackground () {
if ((state & BACKGROUND) == 0 && backgroundImage == null) {
if ((state & PARENT_BACKGROUND) != 0) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2796,6 +2796,11 @@ public void setModified (boolean modified) {
this.modified = modified;
}


public int getNativeZoom() {
return DPIUtil.getNativeDeviceZoom();
}

/**
* Sets the shape of the shell to the region specified
* by the argument. When the argument is null, the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public abstract class Control extends Widget implements Drawable {
Region region;
Font font;
int drawCount, foreground, background, backgroundAlpha = 255;
boolean autoScaleDisabled = false;
AutoscalingMode autoscalingMode = AutoscalingMode.ENABLED;

private static final String DATA_SHELL_ZOOM = "SHELL_ZOOM";

Expand Down Expand Up @@ -123,11 +123,11 @@ public abstract class Control extends Widget implements Drawable {
public Control (Composite parent, int style) {
super (parent, style);
this.parent = parent;
Boolean parentPropagateAutoscaleDisabled = (Boolean) parent.getData(PROPOGATE_AUTOSCALE_DISABLED);
if (parentPropagateAutoscaleDisabled == null || parentPropagateAutoscaleDisabled) {
this.autoScaleDisabled = parent.autoScaleDisabled;
AutoscalingMode parentAutoscaleMode = parent.autoscalingMode;
if (parentAutoscaleMode == AutoscalingMode.DISABLED_INHERITED) {
this.autoscalingMode = parent.autoscalingMode;
}
if (!autoScaleDisabled) {
if (isAutoScalable()) {
this.nativeZoom = getShellZoom();
}
createWidget ();
Expand Down Expand Up @@ -1285,11 +1285,14 @@ public Object getData(String key) {
@Override
public void setData(String key, Object value) {
super.setData(key, value);
if (DATA_AUTOSCALE_DISABLED.equals(key)) {
autoScaleDisabled = Boolean.parseBoolean(value.toString());
if (DATA_AUTOSCALE_DISABLED.equals(key) || PROPOGATE_AUTOSCALE_DISABLED.equals(key)) {
boolean autoScaleDisabled = Boolean.parseBoolean(getData(DATA_AUTOSCALE_DISABLED).toString());
boolean propagateAutoscaleDisabled = Boolean.parseBoolean(getData(PROPOGATE_AUTOSCALE_DISABLED).toString());
if (autoScaleDisabled) {
autoscalingMode = propagateAutoscaleDisabled ? AutoscalingMode.DISABLED_INHERITED : AutoscalingMode.DISABLED;
this.nativeZoom = 100;
} else {
autoscalingMode = AutoscalingMode.ENABLED;
this.nativeZoom = getShellZoom();
}
}
Expand Down Expand Up @@ -1873,6 +1876,11 @@ boolean isActive () {
return shell.getEnabled ();
}

@Override
public boolean isAutoScalable() {
return autoscalingMode == AutoscalingMode.ENABLED;
}

/**
* Returns <code>true</code> if the receiver is enabled and all
* ancestors up to and including the receiver's nearest ancestor
Expand Down Expand Up @@ -3352,6 +3360,19 @@ private void fitInParentBounds(Rectangle boundsInPixels, int zoom) {
}
}

/**
* @since 3.132
*/
public boolean setAutoscalingMode(AutoscalingMode autoscalingMode) {
this.autoscalingMode = autoscalingMode;
if (!isAutoScalable()) {
this.nativeZoom = 100;
} else {
this.nativeZoom = getShellZoom();
}
return true;
}

void setBoundsInPixels (Rectangle rect) {
setBoundsInPixels (rect.x, rect.y, rect.width, rect.height);
}
Expand Down Expand Up @@ -4865,15 +4886,15 @@ public boolean setParent (Composite parent) {
@Override
GC createNewGC(long hDC, GCData data) {
data.nativeZoom = getNativeZoom();
if (autoScaleDisabled && data.font != null) {
if (!isAutoScalable() && data.font != null) {
data.font = SWTFontProvider.getFont(display, data.font.getFontData()[0], 100);
}
return GC.win32_new(hDC, data);
}

@Override
int getZoom() {
if (autoScaleDisabled) {
if (!isAutoScalable()) {
return 100;
}
return super.getZoom();
Expand All @@ -4887,7 +4908,7 @@ int getShellZoom() {
}

private int computeGetBoundsZoom() {
if (parent != null && !autoScaleDisabled) {
if (parent != null && isAutoScalable()) {
return parent.getZoom();
}
return getZoom();
Expand Down Expand Up @@ -6035,7 +6056,7 @@ void sendZoomChangedEvent(Event event, Shell shell) {
@Override
void handleDPIChange(Event event, float scalingFactor) {
super.handleDPIChange(event, scalingFactor);
if (this.autoScaleDisabled) {
if (!this.isAutoScalable()) {
this.nativeZoom = 100;
}
resizeFont(this, getNativeZoom());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1233,6 +1233,11 @@ public ToolBar getToolBar() {
return null;
}

@Override
public int getNativeZoom() {
return DPIUtil.mapDPIToZoom(OS.GetDpiForWindow(handle));
}

@Override
Composite findDeferredControl () {
return layoutCount > 0 ? this : null;
Expand Down