Skip to content

Conversation

@HeikoKlare
Copy link
Contributor

@HeikoKlare HeikoKlare commented Nov 10, 2025

With a recent change (#2720), the rounding of rectangles width/height was adapted to be based on the precise (float) coordinates of the top left and bottom right corner of the rectangle instead of rounding top left location and width/height individually in the rectangle. The reason was that otherwise two rectangles placed next to each other and scaled from pixel to point or vice versa could overlap or have a gap between them when the resulting values were rounded. So the change was beneficial (i.e., improved precision) when scaling values from pixel to point or vice versa if they are all defined in the same coordinate system (with the same origin), as then equal coordinates are rounded equally.
However, the coordinates used in SWT are usually in different coordinate systems with the origin often being the position of the parent control. So one consequence of the change was that a parent with a child, both of the same size, may not fit into each other anymore if the parent has an offset (with respect to its parent) that is taken into account when rounding the Rectangle values.

For that reason, this change reverts the behavior change of Rectangle and the point/pixel conversion logic to the previous state.

Fixes #2746

@github-actions
Copy link
Contributor

github-actions bot commented Nov 10, 2025

Test Results

  118 files  ±0    118 suites  ±0   18m 46s ⏱️ + 1m 21s
4 651 tests ±0  4 633 ✅ +1  18 💤  - 1  0 ❌ ±0 
  330 runs  ±0    326 ✅ ±0   4 💤 ±0  0 ❌ ±0 

Results for commit 4ffa135. ± Comparison against base commit 2df129f.

♻️ This comment has been updated with latest results.

@HeikoKlare HeikoKlare force-pushed the revert-rectangle-size-rounding branch 2 times, most recently from 7f79292 to 7ae4b43 Compare November 10, 2025 21:27
@HeikoKlare HeikoKlare marked this pull request as ready for review November 10, 2025 21:41
@akoch-yatta akoch-yatta force-pushed the revert-rectangle-size-rounding branch from 7ae4b43 to c3111ae Compare November 11, 2025 07:51
With a recent change, the rounding of rectangles width/height was
adapted to be based on the precise (float) coordinates of the top left
and bottom right corner of the rectangle instead of rounding top left
location and width/height individually in the rectangle. The reason was
that otherwise two rectangles placed next to each other and scaled from
pixel to point or vice versa could overlap or have a gap between them
when the resulting values were rounded. So the change was beneficial
(i.e., improved precision) when scaling values from pixel to point or
vice versa if they are all defined in the same coordinate system (with
the same origin), as then equal coordinates are rounded equally.
However, the coordinates used in SWT are usually in different coordinate
systems with the origin often being the position of the parent control.
So one consequence of the change was that a parent with a child, both of
the same size, may not fit into each other anymore if the parent has an
offset (with respect to its parent) that is taken into account when
rounding the Rectangle values.

For that reason, this change reverts the behavioral change of Rectangle
and the point/pixel conversion logic to the previous state.

Fixes eclipse-platform#2746
@akoch-yatta akoch-yatta force-pushed the revert-rectangle-size-rounding branch from c3111ae to 4ffa135 Compare November 11, 2025 08:48
Copy link
Contributor

@akoch-yatta akoch-yatta left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code change looks fine and in itself consistent and it fixes the regression.

@akoch-yatta akoch-yatta merged commit f627f8a into eclipse-platform:master Nov 11, 2025
17 checks passed
@akoch-yatta akoch-yatta deleted the revert-rectangle-size-rounding branch November 11, 2025 13:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

2 participants