RFC: Sane rectangle class

Luboš Luňák l.lunak at collabora.com
Fri Mar 20 12:12:04 UTC 2020


On Thursday 19 of March 2020, Noel Grandin wrote:
> On Thu, 19 Mar 2020 at 17:14, Luboš Luňák <l.lunak at collabora.com> wrote:
> > - internal representation will be whatever sane thing will work, e.g.
> > x,y,width,height , and it won't matter for the API
> > - empty rectangle is simply width == 0 || height == 0
>
> +1 on this part.
>
> FWIW, the Java Rectangle API is pretty much this.

 UNO Rectangle is like that too, I missed that one.

> One important thing - we will need to choose a fundamental type i.e
> float32/float64/int32/int64 for the co-ords.
>
> All of these have the normal pro's and con's when it comes to graphics
> APIs.

 My intention here is fill in the role that tools::Rectangle currently fills, 
so the obvious choice seems to be to use integers just as that one does.

> With one extra wrinkle: the current tools::Rectangle uses long, and lots of
> places that work with tools::Rectangle also use long, which is particularly
> pernicious because long is a different bit-size on Windows and Linux.

 Do you know a specific case where that actually matters? My personal position 
on integers is "use int, unless you explicitly need something else".


-- 
 Luboš Luňák
 l.lunak at collabora.com


More information about the LibreOffice mailing list