Re: KRect and KRectF proposal
Thiago Macieira <[email protected]> Wed, 08 Apr 2026 21:43:08 -0700
| Newsgroups | gmane.comp.kde.devel.general |
|---|---|
| Message-ID | <177770680.VBMTVartND@tjmaciei-mobl5> |
On Wednesday, 8 April 2026 07:29:11 Pacific Daylight Time Vlad Zahorodnii wrote: > Negative width and height are a corner case. I'm sure you can encounter > them, e.g. in some drawing applications when the user presses and drags > the pointer to draw a rectangle, but I don't think they are so common > that the core abstraction needs to handle that. For example, in KWin, we > have no valid case where rectangles with negative sizes are okay, and it > is a project that uses rectangles heavily. I don't know why they were added to QRect/QRectF. It was before the public history. But regardless, it's API now and may be in use. So unless you declare it broken/misfeature, it should be supported. > > Consider: > > top() = -0.4999 > > left() = -0.4999 > > bottom() = 0.4999 > > right() = 0.4999 > > > > width() and height() are 0.9998, which clearly rounds to 1.0. But all of > > the four coordinates round to 0. > > Correct, whether it's fine depends on the context though. And I'm arguing it shouldn't be context-dependent. You can easily round in such a way that it prevents becoming empty. Just round towards positive infinity. -- Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org Principal Engineer - Intel Data Center - Platform & Sys. Eng.
signature.asc
(application/pgp-signature, 870 B)
-----BEGIN PGP SIGNATURE----- iQJPBAABCAA5FiEECozPt7VWsJgFlTT/jR/izwvmghcFAmnXLlwbFIAAAAAABAAO bWFudTIsMi41KzEuMTIsMiwyAAoJEI0f4s8L5oIXDdAP/0uooYo9j8HyHQ6p9rfY 0fi3wWZAVL4K71DnJKE50aVMurm0OxFRDH5reo5d2oOVD0FsvpgbcnmZPC93GCnx 9N633IqYz8KKD2oFXHtAqnhLqZd/tfH1BMDHvTqbBvJVdepMazWpGHmrLQBE6OHB RrGhqFwlEkwNSTIhOVVxAbPdmdm+BWmoXSj6jSl1LmsxMTS1pmVLmtTogSw47kqo fKR9YLagrANQQGA4cbgUXWQg4qRFb774hQhHpE6n2ruE00YLJxJVXgTL0ww+opsN mjS/DBgxdYHSO3eQTHv8hcirqt3nmkeUv/hvWRekKrTXD5m6MPENJDQlv9UFkqdo xOHMYcIXJAmnww0YipwT/I33f/2wb5zRmuziVfpxZ7zVNWYlSGrgLYYprT0OLZBu 0V6IV7V8pmj7cTJeLQhxwC4GgLIQxagwDTawSxmG1QZPkQhYDvo2LxB/GPtccqfe prdZstG9CrzBZT/GaElIkVIzphPfjZWVrdXVUwLg9Cb7F6bMm2rDSbQnU1mZ7bs2 da5zCyg1R9122XC+cHEC5jMmkUd5U8hvtJjJYkkFCTixpGqYJBTB1MzAHVKfMTrs OK3+vMtd2yBLb6fMqMMw4uKkV5Xqmb9u32irl8qFNB2KXFBpmPMPBnEwi+vCK73W 8g63cYf5KQiJP6ozufXUogUg =5enk -----END PGP SIGNATURE-----