Skip to content

Conversation

laeubi
Copy link
Contributor

@laeubi laeubi commented Sep 12, 2025

When converting pixels to point there can be depending on the zoom level be a fractional result.
Currently in all cases these result is converted into an integer using Math.round() that will make values +/-0.5 resulting in small values to be round towards a smaller value (see here).

While it is maybe valid for a location, when using points to express a dimension this is not okay as it will result in the reported (integer) value to be to small leading to errors when the SWT API is then used after performing additional computations maybe.

This now makes the following adjustments:

  1. Introduce a rounding mode that allows different ways of rounding and adds as a first step ROUND (the previous default) and UP (for always round towards the largest integer)
  2. Adjust the Control class to decide what mode is best in what situation.

See

When converting pixels to point there can be depending on the zoom level
be a fractional result.
Currently in all cases these result is converted into an integer using
`Math.round()` that will make values `+/-0.5` resulting in small values
to be round towards a smaller value.

While it is maybe valid for a _location_, when using points to express a
_dimension_ this is not okay as it will result in the reported (integer)
value to be to small leading to errors when the SWT API is then used
after performing additional computations maybe.

This now makes the following adjustments:

1. Introduce a rounding mode that allows different ways of rounding and
adds as a first step ROUND (the previous default) and UP (for always
round towards the largest integer)
2. Adjust the `Control` class to decide what mode is best in what
situation.

See
- eclipse-platform#2381
- eclipse-platform#2166
@laeubi laeubi marked this pull request as draft September 12, 2025 07:31
@laeubi laeubi mentioned this pull request Sep 12, 2025
Copy link
Contributor

Test Results

0 files   -    546  0 suites   - 546   0s ⏱️ - 32m 24s
0 tests  -  4 431  0 ✅  -  4 414  0 💤  -  17  0 ❌ ±0 
0 runs   - 16 764  0 ✅  - 16 637  0 💤  - 127  0 ❌ ±0 

Results for commit 1a75066. ± Comparison against base commit d39363c.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant