Dimension or Size class


#1

Hi Jules,
I’m working a lot with Point class lately, and happened to use it sometimes to store a width and a height rather than actual x and y coordinates. It worked, but I think that having a Dimension (or Size) template class with get/setWidth and get/setHeight would be more elegant.

What do you think about it?

In addition, I’ve noticed that Component::getComponentAt exists both for integer coordinates and a Point argument, while contains () only accepts integer coordinates (the same for hitTest and some other virtual functions). What do you think about adding non-virtual functions that accepts Points and call the integer arguments counterparts?


#2

I’ve certainly thought about adding a Size class, and probably will do in the future.

As for the component methods, I’ve been gradually adding new methods that take points and rectangles, though I’m a little reluctant to do so for virtual methods, because it could be confusing if there was a non-virtual hitTest(Point), as it’d give the impression that you could choose to override it to do your hit testing, which obviously wouldn’t work. And making both versions virtual would create even more confusing problems unless you always overrode both versions.

Ideally I’d like to replace all the old methods with Point/Rectangle ones, but will probably leave that for a future release, as it’d be annoying for everyone to update their code.