
John Torjo wrote:
I might go further and add units (maybe defaulting to pixels)
typedef gui::rect<px,int> rect 1; typedef gui::rect<pc,double> rect 2; typedef gui:rect<mm,int> rect 3;
That looks great :)!
I disagree. I think you should stick to only one type (probably float for now, and eventually allow overriding it -- but, use this consistently throughout the app).
Just think of the many places you'll need to deal with geometry (rectangle/point/size), and converting from one type of unit (px to cm, cm to in, etc) to another.
I agree. In particular, I'd strongly suggest to draw a clear distinction between physical dimension and resolution. Most current GUIs did get that wrong, I believe in that they conditioned us all to think of size when talking about number of pixels. The consequence is similar to the Y2K bug: applications won't easily adapt to displays with different resolutions (well, may be within a narrow range), and so a lot of efford is needed on a high (application) level to compensate for that lack of abstraction. Let's hope that in the not-so-distant future 'pixel' will be an artefact of graphic / video card drivers and not be exposed to an API at all. Regards, Stefan