From 518e302d4a80c26509bdf78898802184ab90191f Mon Sep 17 00:00:00 2001 From: jules Date: Thu, 4 Jul 2013 20:51:27 +0100 Subject: [PATCH] Avoided some VC warnings. --- modules/juce_graphics/geometry/juce_Point.h | 16 ++++++++++------ modules/juce_graphics/geometry/juce_Rectangle.h | 4 ++-- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/modules/juce_graphics/geometry/juce_Point.h b/modules/juce_graphics/geometry/juce_Point.h index 40e0f7f948..3c5498b556 100644 --- a/modules/juce_graphics/geometry/juce_Point.h +++ b/modules/juce_graphics/geometry/juce_Point.h @@ -101,16 +101,20 @@ public: Point& operator-= (Point other) noexcept { x -= other.x; y -= other.y; return *this; } /** Returns a point whose coordinates are multiplied by a given value. */ - Point operator* (const ValueType multiplier) const noexcept { return Point (x * multiplier, y * multiplier); } - - /** Multiplies the point's co-ordinates by a value. */ - Point& operator*= (const ValueType multiplier) noexcept { x *= multiplier; y *= multiplier; return *this; } + template + Point operator* (const FloatType multiplier) const noexcept { return Point ((ValueType) (x * multiplier), (ValueType) (y * multiplier)); } /** Returns a point whose coordinates are divided by a given value. */ - Point operator/ (const ValueType divisor) const noexcept { return Point (x / divisor, y / divisor); } + template + Point operator/ (const FloatType divisor) const noexcept { return Point ((ValueType) (x / divisor), (ValueType) (y / divisor)); } + + /** Multiplies the point's co-ordinates by a value. */ + template + Point& operator*= (const FloatType multiplier) noexcept { x = (ValueType) (x * multiplier); y = (ValueType) (y * multiplier); return *this; } /** Divides the point's co-ordinates by a value. */ - Point& operator/= (const ValueType divisor) noexcept { x /= divisor; y /= divisor; return *this; } + template + Point& operator/= (const FloatType divisor) noexcept { x = (ValueType) (x / divisor); y = (ValueType) (y / divisor); return *this; } /** Returns the inverse of this point. */ Point operator-() const noexcept { return Point (-x, -y); } diff --git a/modules/juce_graphics/geometry/juce_Rectangle.h b/modules/juce_graphics/geometry/juce_Rectangle.h index 4fcd8793bd..0f53346e1b 100644 --- a/modules/juce_graphics/geometry/juce_Rectangle.h +++ b/modules/juce_graphics/geometry/juce_Rectangle.h @@ -305,8 +305,8 @@ public: Rectangle operator*= (FloatType scaleFactor) noexcept { pos *= scaleFactor; - w *= scaleFactor; - h *= scaleFactor; + w = (ValueType) (w * scaleFactor); + h = (ValueType) (h * scaleFactor); return *this; }