Skip to content

Commit

Permalink
[win32] different coordinate system strategie
Browse files Browse the repository at this point in the history
This contributes extracts two different strategies to provide a consistent coordinate system in the win32 implemenentation for a single-zoom and a multi-zoom environment. The existing logic remains unchanged in this commit. It is only moved and consolidated in the new inner classes in Display

Contributes to eclipse-platform#62 and eclipse-platform#131
  • Loading branch information
akoch-yatta committed Dec 10, 2024
1 parent f3e2582 commit 7d0ba65
Show file tree
Hide file tree
Showing 5 changed files with 370 additions and 33 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3970,7 +3970,9 @@ void subclass () {
public Point toControl (int x, int y) {
checkWidget ();
int zoom = getZoom();
return DPIUtil.scaleDown(toControlInPixels(DPIUtil.scaleUp(x, zoom), DPIUtil.scaleUp(y, zoom)), zoom);
Point displayPointInPixels = getDisplay().translateToDisplayCoordinates(new Point(x, y), zoom);
final Point controlPointInPixels = toControlInPixels(displayPointInPixels.x, displayPointInPixels.y);
return DPIUtil.scaleDown(controlPointInPixels, zoom);
}

Point toControlInPixels (int x, int y) {
Expand Down Expand Up @@ -4003,9 +4005,7 @@ Point toControlInPixels (int x, int y) {
public Point toControl (Point point) {
checkWidget ();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
int zoom = getZoom();
point = DPIUtil.scaleUp(point, zoom);
return DPIUtil.scaleDown(toControlInPixels(point.x, point.y), zoom);
return toControl(point.x, point.y);
}

/**
Expand All @@ -4031,7 +4031,8 @@ public Point toControl (Point point) {
public Point toDisplay (int x, int y) {
checkWidget ();
int zoom = getZoom();
return DPIUtil.scaleDown(toDisplayInPixels(DPIUtil.scaleUp(x, zoom), DPIUtil.scaleUp(y, zoom)), zoom);
Point displayPointInPixels = toDisplayInPixels(DPIUtil.scaleUp(x, zoom), DPIUtil.scaleUp(y, zoom));
return getDisplay().translateFromDisplayCoordinates(displayPointInPixels, zoom);
}

Point toDisplayInPixels (int x, int y) {
Expand Down Expand Up @@ -4064,9 +4065,7 @@ Point toDisplayInPixels (int x, int y) {
public Point toDisplay (Point point) {
checkWidget ();
if (point == null) error (SWT.ERROR_NULL_ARGUMENT);
int zoom = getZoom();
point = DPIUtil.scaleUp(point, zoom);
return DPIUtil.scaleDown(toDisplayInPixels(point.x, point.y), zoom);
return toDisplay(point.x, point.y);
}

long topHandle () {
Expand Down
Loading

0 comments on commit 7d0ba65

Please sign in to comment.