-
Notifications
You must be signed in to change notification settings - Fork 143
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Multiple zoom level support to path for win 32
This commit contributes to the obtaining the path as per the zoom level of the monitor. A method win32_getPAth is used in place wherever path.handle was used earlier by the clients. The preferred zoom level has to be passed by the clients as a parameter to the mthod in order to get the handle for the scaled path. contributes to #62 and #127
- Loading branch information
1 parent
f708ac3
commit 1a7c8fc
Showing
3 changed files
with
156 additions
and
80 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
bundles/org.eclipse.swt/Eclipse SWT Tests/win32/org/eclipse/swt/graphics/PathWin32Tests.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
/******************************************************************************* | ||
* Copyright (c) 2024 Yatta Solutions | ||
* | ||
* This program and the accompanying materials | ||
* are made available under the terms of the Eclipse Public License 2.0 | ||
* which accompanies this distribution, and is available at | ||
* https://www.eclipse.org/legal/epl-2.0/ | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
* | ||
* Contributors: | ||
* Yatta Solutions - initial API and implementation | ||
*******************************************************************************/ | ||
package org.eclipse.swt.graphics; | ||
|
||
import static org.junit.Assert.assertTrue; | ||
|
||
import java.util.*; | ||
|
||
import org.eclipse.swt.internal.*; | ||
import org.eclipse.swt.internal.gdip.*; | ||
import org.junit.*; | ||
|
||
public class PathWin32Tests extends Win32AutoscaleTestBase { | ||
|
||
int zoom = 100; | ||
int scaledZoom = 200; | ||
|
||
@Test | ||
public void testPathMustBeScaledOnZoomLevelChange() { | ||
Path path = new Path(display); | ||
path.addArc(0, 0, 10, 10, 0, 90); | ||
PathData pathData = path.getPathData(); | ||
DPIUtil.setDeviceZoom(scaledZoom); | ||
Path scaledPath = new Path(display, pathData); | ||
PathData scaledPathData = scaledPath.getPathData(); | ||
assertTrue("PathData types don't change on zoom level change", Arrays.equals(pathData.types, scaledPathData.types)); | ||
assertTrue("PathData types don't change on zoom level change", Arrays.equals(pathData.points, scaledPathData.points)); | ||
} | ||
|
||
@Test | ||
public void testHandlesExistForEachZoomLevelInHashMap() { | ||
DPIUtil.setDeviceZoom(zoom); | ||
Path path = new Path(display); | ||
path.addArc(0, 0, 10, 10, 0, 90); | ||
path.getHandle(scaledZoom); | ||
assertTrue("zoomLevelToHandle contains scaled handle", path.toString().contains(scaledZoom + "=")); | ||
assertTrue("zoomLevelToHandle contains initial zoom's handle", path.toString().contains(zoom + "=")); | ||
} | ||
|
||
@Test | ||
public void testBoundsAreScaledWRTZoomLevel() { | ||
DPIUtil.setDeviceZoom(zoom); | ||
int scalingFactor = scaledZoom/zoom; | ||
Path path = new Path(display); | ||
path.addArc(0, 0, 10, 10, 0, 90); | ||
RectF bounds = new RectF(); | ||
RectF scaledBounds = new RectF(); | ||
Gdip.GraphicsPath_GetBounds(path.getHandle(zoom), bounds, 0, 0); | ||
Gdip.GraphicsPath_GetBounds(path.getHandle(scaledZoom), scaledBounds, 0, 0); | ||
assertTrue("X coordinate is scaled up wrt the scalingFactor", bounds.X * scalingFactor == scaledBounds.X); | ||
assertTrue("X coordinate is scaled up wrt the scalingFactor", bounds.Y * scalingFactor == scaledBounds.Y); | ||
assertTrue("Height is scaled up wrt the scalingFactor", bounds.Height * scalingFactor == scaledBounds.Height); | ||
assertTrue("Height is scaled up wrt the scalingFactor", bounds.Width * scalingFactor == scaledBounds.Width); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.