Skip to content
Merged
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 @@ -55,6 +55,25 @@ public void testDoNotScaleFontCorrectlyInNoAutoScaleSzenario() {
fontComparison.originalFontHeight, fontComparison.currentFontHeight);
}

@Test
public void testCorrectScaleUpUsingDifferentSetBoundsMethod() {
DPIUtil.setMonitorSpecificScaling(true);
Display display = Display.getDefault();
Shell shell = new Shell(display);
DPITestUtil.changeDPIZoom(shell, 175);

Button button = new Button(shell, SWT.PUSH);
button.setText("Widget Test");
button.setBounds(new Rectangle(0, 47, 200, 47));
shell.open();
assertEquals("Control::setBounds(Rectangle) doesn't scale up correctly",
new Rectangle(0, 82, 350, 83), button.getBoundsInPixels());

button.setBounds(0, 47, 200, 47);
assertEquals("Control::setBounds(int, int, int, int) doesn't scale up correctly",
new Rectangle(0, 82, 350, 83), button.getBoundsInPixels());
}

record FontComparison(int originalFontHeight, int currentFontHeight) {
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3168,13 +3168,7 @@ void setBackgroundPixel (int pixel) {
* </ul>
*/
public void setBounds(int x, int y, int width, int height) {
checkWidget ();
int zoom = getZoom();
x = DPIUtil.scaleUp(x, zoom);
y = DPIUtil.scaleUp(y, zoom);
width = DPIUtil.scaleUp(width, zoom);
height = DPIUtil.scaleUp(height, zoom);
setBoundsInPixels(x, y, width, height);
setBounds(new Rectangle(x, y, width, height));
}

void setBoundsInPixels (int x, int y, int width, int height) {
Expand Down
Loading