I found myself in the peculiar condition of having to distinguish when a Rectangle has zero area (i.e. one of its dimensions is zero) vs. when the Rectangle has both dimensions equal to zero, not just one.
The Rectangle::isEmpty() method covers in the first case (while I was expecting it to be more fitting for the latter, but anyway…), and there seem to be no method for the latter.
I know this can be easily added with a free function, and that’s what I’m doing with:
template <typename ValueType>
inline bool hasZeroDimensions (const juce::Rectangle <ValueType> r)
{
return (r.getWidth () <= ValueType()) && (r.getHeight () <= ValueType());
}
but with this I’m suggesting to include it in Rectangle’s features, either with a method (probably better) or adding a default argument to isEmpty() to trigger either behavior, (probably worse).
P.S. I’m not a native english speaker and I can’t tell if “hasZeroDimensions” suffices to convey the meaning of “both dimensions have to be zero”, or if there’s a better naming for it. “hasBothZeroDimensions” perhaps?
