Skip to content

Commit bd3357c

Browse files
akoch-yattaHeikoKlare
authored andcommitted
[win32] Unify up-scaling bounds using Rectangle
This commit unifies scale up results in different places. With zoom values not dividable by 100 scaling up via rectangle or scaling up all values separately can give different result. Scaling always as rectangle solves this limitation.
1 parent cfbd282 commit bd3357c

File tree

4 files changed

+8
-20
lines changed

4 files changed

+8
-20
lines changed

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Canvas.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,8 @@ public void scroll (int destX, int destY, int x, int y, int width, int height, b
200200
int zoom = getZoom();
201201
destX = DPIUtil.scaleUp(destX, zoom);
202202
destY = DPIUtil.scaleUp(destY, zoom);
203-
x = DPIUtil.scaleUp(x, zoom);
204-
y = DPIUtil.scaleUp(y, zoom);
205-
width = DPIUtil.scaleUp(width, zoom);
206-
height = DPIUtil.scaleUp(height, zoom);
207-
scrollInPixels(destX, destY, x, y, width, height, all);
203+
Rectangle rectangle = DPIUtil.scaleUp(new Rectangle(x, y, width, height), zoom);
204+
scrollInPixels(destX, destY, rectangle.x, rectangle.y, rectangle.width, rectangle.height, all);
208205
}
209206

210207
void scrollInPixels (int destX, int destY, int x, int y, int width, int height, boolean all) {

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Composite.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -356,13 +356,10 @@ int applyThemeBackground () {
356356
public void drawBackground (GC gc, int x, int y, int width, int height, int offsetX, int offsetY) {
357357
checkWidget ();
358358
int zoom = getZoom();
359-
x = DPIUtil.scaleUp(x, zoom);
360-
y = DPIUtil.scaleUp(y, zoom);
361-
width = DPIUtil.scaleUp(width, zoom);
362-
height = DPIUtil.scaleUp(height, zoom);
359+
Rectangle rectangle = DPIUtil.scaleUp(new Rectangle(x, y, width, height), zoom);
363360
offsetX = DPIUtil.scaleUp(offsetX, zoom);
364361
offsetY = DPIUtil.scaleUp(offsetY, zoom);
365-
drawBackgroundInPixels(gc, x, y, width, height, offsetX, offsetY);
362+
drawBackgroundInPixels(gc, rectangle.x, rectangle.y, rectangle.width, rectangle.height, offsetX, offsetY);
366363
}
367364

368365
void drawBackgroundInPixels(GC gc, int x, int y, int width, int height, int offsetX, int offsetY) {

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Control.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -2434,14 +2434,11 @@ public void redraw () {
24342434
public void redraw (int x, int y, int width, int height, boolean all) {
24352435
checkWidget ();
24362436
int zoom = getZoom();
2437-
x = DPIUtil.scaleUp(x, zoom);
2438-
y = DPIUtil.scaleUp(y, zoom);
2439-
width = DPIUtil.scaleUp(width, zoom);
2440-
height = DPIUtil.scaleUp(height, zoom);
24412437
if (width <= 0 || height <= 0) return;
2438+
Rectangle rectangle = DPIUtil.scaleUp(new Rectangle(x, y, width, height), zoom);
24422439

24432440
RECT rect = new RECT ();
2444-
OS.SetRect (rect, x, y, x + width, y + height);
2441+
OS.SetRect (rect, rectangle.x, rectangle.y, rectangle.x + rectangle.width, rectangle.y + rectangle.height);
24452442

24462443
redrawInPixels(rect, all);
24472444
}

bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/widgets/Scrollable.java

+2-5
Original file line numberDiff line numberDiff line change
@@ -121,11 +121,8 @@ long callWindowProc (long hwnd, int msg, long wParam, long lParam) {
121121
public Rectangle computeTrim (int x, int y, int width, int height) {
122122
checkWidget ();
123123
int zoom = getZoom();
124-
x = DPIUtil.scaleUp(x, zoom);
125-
y = DPIUtil.scaleUp(y, zoom);
126-
width = DPIUtil.scaleUp(width, zoom);
127-
height = DPIUtil.scaleUp(height, zoom);
128-
return DPIUtil.scaleDown(computeTrimInPixels(x, y, width, height), zoom);
124+
Rectangle rectangle = DPIUtil.scaleUp(new Rectangle(x, y, width, height), zoom);
125+
return DPIUtil.scaleDown(computeTrimInPixels(rectangle.x, rectangle.y, rectangle.width, rectangle.height), zoom);
129126
}
130127

131128
Rectangle computeTrimInPixels (int x, int y, int width, int height) {

0 commit comments

Comments
 (0)