Skip to content

Commit

Permalink
Merge branch 'eclipse-platform:master' into bugs/magic_number
Browse files Browse the repository at this point in the history
  • Loading branch information
jakub-suliga authored Jul 17, 2024
2 parents 44f3ae5 + 51e85e0 commit be7c7fd
Show file tree
Hide file tree
Showing 50 changed files with 1,217 additions and 495 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/junit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ jobs:
done
- name: Publish Unit Test Results
uses: EnricoMi/publish-unit-test-result-action@30eadd5010312f995f0d3b3cff7fe2984f69409e # v2.16.1
uses: EnricoMi/publish-unit-test-result-action@567cc7f8dcea3eba5da355f6ebc95663310d8a07 # v2.17.0
id: test-results
with:
commit: ${{ github.event.workflow_run.head_sha }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Upload
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
with:
name: Event File
path: ${{ github.event_path }}
Expand Down Expand Up @@ -90,7 +90,7 @@ jobs:
working-directory: tests/org.eclipse.swt.tests
- name: Upload Test Results for ${{ matrix.config.name }} / Java-${{ matrix.java }}
if: always()
uses: actions/upload-artifact@65462800fd760344b1a7b4382951275a0abb4808 # v4.3.3
uses: actions/upload-artifact@0b2256b8c012f0828dc542b3febcab082c67f72b # v4.3.4
with:
name: test-results-${{ matrix.config.native }}-java${{ matrix.java }}
if-no-files-found: warn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4892,7 +4892,7 @@ public Rectangle getTextBounds(int start, int end) {
Rectangle rect;
int y = getLinePixel(lineStart);
int height = 0;
int left = 0x7fffffff, right = 0;
int left = Integer.MAX_VALUE, right = 0;
for (int i = lineStart; i <= lineEnd; i++) {
int lineOffset = content.getOffsetAtLine(i);
TextLayout layout = renderer.getTextLayout(i);
Expand All @@ -4918,6 +4918,9 @@ public Rectangle getTextBounds(int start, int end) {
}
renderer.disposeTextLayout(layout);
}
if (left == Integer.MAX_VALUE) {
left = 0;
}
rect = new Rectangle (left, y, right-left, height);
rect.x += leftMargin - horizontalScrollOffset;
return rect;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*******************************************************************************
* 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.assertEquals;

import org.eclipse.swt.internal.*;
import org.eclipse.swt.internal.win32.*;
import org.junit.jupiter.api.*;

class RegionWin32Tests extends Win32AutoscaleTestBase {

@Test
public void testRegionMustBeScaledOnHandleOfScaledZoomLevel() {
int zoom = DPIUtil.getDeviceZoom();
int scalingFactor = 2;

Region region = new Region(display);
region.add(0, 0, 5, 10);
region.subtract(0,0,1,1);
region.translate(0, 5);
region.intersect(1,1,1,1);

long handle = Region.win32_getHandle(region, zoom);
long scaledRegionHandle = Region.win32_getHandle(region, zoom * scalingFactor);

RECT rect = new RECT();
OS.GetRgnBox(handle, rect);
Rectangle bounds = new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);

rect = new RECT();
OS.GetRgnBox(scaledRegionHandle, rect);
Rectangle scaledBounds = new Rectangle(rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);

assertEquals("scaled region's height should be double of unscaled region", bounds.height * scalingFactor, scaledBounds.height);
assertEquals("scaled region's width should be double of unscaled region", bounds.width * scalingFactor, scaledBounds.width);
assertEquals("scaled region's x position should be double of unscaled region", bounds.x * scalingFactor, scaledBounds.x);
assertEquals("scaled region's y position should be double of unscaled region", bounds.y * scalingFactor, scaledBounds.y);
}

}
Loading

0 comments on commit be7c7fd

Please sign in to comment.