1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Workarounds to get Rectangle<int>::getSmallestIntegerContainer() to work in VC2010

This commit is contained in:
jules 2013-07-30 23:14:01 +01:00
parent ebc0b2b727
commit 69f75c344d

View file

@ -688,22 +688,12 @@ public:
*/
Rectangle<int> getSmallestIntegerContainer() const noexcept
{
return getSmallestIntegerContainerWithType<int>();
}
const int x1 = floorAsInt (pos.x);
const int y1 = floorAsInt (pos.y);
const int x2 = ceilAsInt (pos.x + w);
const int y2 = ceilAsInt (pos.y + h);
/** Returns the smallest integer-aligned rectangle that completely contains this one.
This is only relevent for floating-point rectangles, of course.
@see toFloat()
*/
template <typename IntType>
Rectangle<IntType> getSmallestIntegerContainerWithType() const noexcept
{
const IntType x1 = static_cast<IntType> (std::floor (pos.x));
const IntType y1 = static_cast<IntType> (std::floor (pos.y));
const IntType x2 = static_cast<IntType> (std::ceil (pos.x + w));
const IntType y2 = static_cast<IntType> (std::ceil (pos.y + h));
return Rectangle<IntType> (x1, y1, x2 - x1, y2 - y1);
return Rectangle<int> (x1, y1, x2 - x1, y2 - y1);
}
/** Casts this rectangle to a Rectangle<float>.
@ -828,6 +818,13 @@ private:
void copyWithRounding (Rectangle<int>& result) const noexcept { result = getSmallestIntegerContainer(); }
void copyWithRounding (Rectangle<float>& result) const noexcept { result = toFloat(); }
void copyWithRounding (Rectangle<double>& result) const noexcept { result = toDouble(); }
static int floorAsInt (int n) noexcept { return n; }
static int floorAsInt (float n) noexcept { return (int) std::floor (n); }
static int floorAsInt (double n) noexcept { return (int) std::floor (n); }
static int ceilAsInt (int n) noexcept { return n; }
static int ceilAsInt (float n) noexcept { return (int) std::ceil (n); }
static int ceilAsInt (double n) noexcept { return (int) std::ceil (n); }
};