Skip to content

Commit

Permalink
[win32] different coordinate system strategies
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 2, 2024
1 parent cfa74b4 commit d633d6b
Show file tree
Hide file tree
Showing 4 changed files with 250 additions and 137 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3970,12 +3970,9 @@ void subclass () {
public Point toControl (int x, int y) {
checkWidget ();
int zoom = getZoom();
if (getDisplay().isRescalingAtRuntime()) {
Point displayPointInPixels = getDisplay().translateLocationInPixelsInDisplayCoordinateSystem(x, y);
final Point controlPointInPixels = toControlInPixels(displayPointInPixels.x, displayPointInPixels.y);
return DPIUtil.scaleDown(controlPointInPixels, zoom);
}
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 @@ -4034,11 +4031,8 @@ public Point toControl (Point point) {
public Point toDisplay (int x, int y) {
checkWidget ();
int zoom = getZoom();
if (getDisplay().isRescalingAtRuntime()) {
Point displayPointInPixels = toDisplayInPixels(DPIUtil.scaleUp(x, zoom), DPIUtil.scaleUp(y, zoom));
return getDisplay().translateLocationInPointInDisplayCoordinateSystem(displayPointInPixels.x, displayPointInPixels.y);
}
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
Loading

0 comments on commit d633d6b

Please sign in to comment.