diff --git a/modules/juce_graphics/geometry/juce_Rectangle.h b/modules/juce_graphics/geometry/juce_Rectangle.h index 6c89c76d19..444b2527e6 100644 --- a/modules/juce_graphics/geometry/juce_Rectangle.h +++ b/modules/juce_graphics/geometry/juce_Rectangle.h @@ -46,35 +46,34 @@ public: The default co-ordinates will be (0, 0, 0, 0). */ Rectangle() noexcept - : x(), y(), w(), h() + : w(), h() { } /** Creates a copy of another rectangle. */ Rectangle (const Rectangle& other) noexcept - : x (other.x), y (other.y), - w (other.w), h (other.h) + : pos (other.pos), w (other.w), h (other.h) { } /** Creates a rectangle with a given position and size. */ Rectangle (const ValueType initialX, const ValueType initialY, const ValueType width, const ValueType height) noexcept - : x (initialX), y (initialY), + : pos (initialX, initialY), w (width), h (height) { } /** Creates a rectangle with a given size, and a position of (0, 0). */ Rectangle (const ValueType width, const ValueType height) noexcept - : x(), y(), w (width), h (height) + : w (width), h (height) { } /** Creates a Rectangle from the positions of two opposite corners. */ Rectangle (const Point& corner1, const Point& corner2) noexcept - : x (jmin (corner1.x, corner2.x)), - y (jmin (corner1.y, corner2.y)), + : pos (jmin (corner1.x, corner2.x), + jmin (corner1.y, corner2.y)), w (corner1.x - corner2.x), h (corner1.y - corner2.y) { @@ -94,7 +93,7 @@ public: Rectangle& operator= (const Rectangle& other) noexcept { - x = other.x; y = other.y; + pos = other.pos; w = other.w; h = other.h; return *this; } @@ -107,10 +106,10 @@ public: bool isEmpty() const noexcept { return w <= ValueType() || h <= ValueType(); } /** Returns the x co-ordinate of the rectangle's left-hand-side. */ - inline ValueType getX() const noexcept { return x; } + inline ValueType getX() const noexcept { return pos.x; } /** Returns the y co-ordinate of the rectangle's top edge. */ - inline ValueType getY() const noexcept { return y; } + inline ValueType getY() const noexcept { return pos.y; } /** Returns the width of the rectangle. */ inline ValueType getWidth() const noexcept { return w; } @@ -119,19 +118,20 @@ public: inline ValueType getHeight() const noexcept { return h; } /** Returns the x co-ordinate of the rectangle's right-hand-side. */ - inline ValueType getRight() const noexcept { return x + w; } + inline ValueType getRight() const noexcept { return pos.x + w; } /** Returns the y co-ordinate of the rectangle's bottom edge. */ - inline ValueType getBottom() const noexcept { return y + h; } + inline ValueType getBottom() const noexcept { return pos.y + h; } /** Returns the x co-ordinate of the rectangle's centre. */ - ValueType getCentreX() const noexcept { return x + w / (ValueType) 2; } + ValueType getCentreX() const noexcept { return pos.x + w / (ValueType) 2; } /** Returns the y co-ordinate of the rectangle's centre. */ - ValueType getCentreY() const noexcept { return y + h / (ValueType) 2; } + ValueType getCentreY() const noexcept { return pos.y + h / (ValueType) 2; } /** Returns the centre point of the rectangle. */ - Point getCentre() const noexcept { return Point (x + w / (ValueType) 2, y + h / (ValueType) 2); } + Point getCentre() const noexcept { return Point (pos.x + w / (ValueType) 2, + pos.y + h / (ValueType) 2); } /** Returns the aspect ratio of the rectangle's width / height. If widthOverHeight is true, it returns width / height; if widthOverHeight is false, @@ -140,13 +140,13 @@ public: //============================================================================== /** Returns the rectangle's top-left position as a Point. */ - Point getPosition() const noexcept { return Point (x, y); } + const Point& getPosition() const noexcept { return pos; } /** Changes the position of the rectangle's top-left corner (leaving its size unchanged). */ - void setPosition (const Point& newPos) noexcept { x = newPos.x; y = newPos.y; } + void setPosition (const Point& newPos) noexcept { pos = newPos; } /** Changes the position of the rectangle's top-left corner (leaving its size unchanged). */ - void setPosition (const ValueType newX, const ValueType newY) noexcept { x = newX; y = newY; } + void setPosition (const ValueType newX, const ValueType newY) noexcept { pos.setXY (newX, newY); } /** Returns a rectangle with the same size as this one, but a new position. */ Rectangle withPosition (const ValueType newX, const ValueType newY) const noexcept { return Rectangle (newX, newY, w, h); } @@ -155,35 +155,35 @@ public: Rectangle withPosition (const Point& newPos) const noexcept { return Rectangle (newPos.x, newPos.y, w, h); } /** Returns the rectangle's top-left position as a Point. */ - Point getTopLeft() const noexcept { return getPosition(); } + const Point& getTopLeft() const noexcept { return pos; } /** Returns the rectangle's top-right position as a Point. */ - Point getTopRight() const noexcept { return Point (x + w, y); } + Point getTopRight() const noexcept { return Point (pos.x + w, pos.y); } /** Returns the rectangle's bottom-left position as a Point. */ - Point getBottomLeft() const noexcept { return Point (x, y + h); } + Point getBottomLeft() const noexcept { return Point (pos.x, pos.y + h); } /** Returns the rectangle's bottom-right position as a Point. */ - Point getBottomRight() const noexcept { return Point (x + w, y + h); } + Point getBottomRight() const noexcept { return Point (pos.x + w, pos.y + h); } /** Changes the rectangle's size, leaving the position of its top-left corner unchanged. */ void setSize (const ValueType newWidth, const ValueType newHeight) noexcept { w = newWidth; h = newHeight; } /** Returns a rectangle with the same position as this one, but a new size. */ - Rectangle withSize (const ValueType newWidth, const ValueType newHeight) const noexcept { return Rectangle (x, y, newWidth, newHeight); } + Rectangle withSize (const ValueType newWidth, const ValueType newHeight) const noexcept { return Rectangle (pos.x, pos.y, newWidth, newHeight); } /** Changes all the rectangle's co-ordinates. */ void setBounds (const ValueType newX, const ValueType newY, const ValueType newWidth, const ValueType newHeight) noexcept { - x = newX; y = newY; w = newWidth; h = newHeight; + pos.x = newX; pos.y = newY; w = newWidth; h = newHeight; } /** Changes the rectangle's X coordinate */ - void setX (const ValueType newX) noexcept { x = newX; } + void setX (const ValueType newX) noexcept { pos.x = newX; } /** Changes the rectangle's Y coordinate */ - void setY (const ValueType newY) noexcept { y = newY; } + void setY (const ValueType newY) noexcept { pos.y = newY; } /** Changes the rectangle's width */ void setWidth (const ValueType newWidth) noexcept { w = newWidth; } @@ -192,16 +192,16 @@ public: void setHeight (const ValueType newHeight) noexcept { h = newHeight; } /** Returns a rectangle which has the same size and y-position as this one, but with a different x-position. */ - Rectangle withX (const ValueType newX) const noexcept { return Rectangle (newX, y, w, h); } + Rectangle withX (const ValueType newX) const noexcept { return Rectangle (newX, pos.y, w, h); } /** Returns a rectangle which has the same size and x-position as this one, but with a different y-position. */ - Rectangle withY (const ValueType newY) const noexcept { return Rectangle (x, newY, w, h); } + Rectangle withY (const ValueType newY) const noexcept { return Rectangle (pos.x, newY, w, h); } /** Returns a rectangle which has the same position and height as this one, but with a different width. */ - Rectangle withWidth (const ValueType newWidth) const noexcept { return Rectangle (x, y, newWidth, h); } + Rectangle withWidth (const ValueType newWidth) const noexcept { return Rectangle (pos.x, pos.y, newWidth, h); } /** Returns a rectangle which has the same position and width as this one, but with a different height. */ - Rectangle withHeight (const ValueType newHeight) const noexcept { return Rectangle (x, y, w, newHeight); } + Rectangle withHeight (const ValueType newHeight) const noexcept { return Rectangle (pos.x, pos.y, w, newHeight); } /** Moves the x position, adjusting the width so that the right-hand edge remains in the same place. If the x is moved to be on the right of the current right-hand edge, the width will be set to zero. @@ -209,15 +209,15 @@ public: */ void setLeft (const ValueType newLeft) noexcept { - w = jmax (ValueType(), x + w - newLeft); - x = newLeft; + w = jmax (ValueType(), pos.x + w - newLeft); + pos.x = newLeft; } /** Returns a new rectangle with a different x position, but the same right-hand edge as this one. If the new x is beyond the right of the current right-hand edge, the width will be set to zero. @see setLeft */ - Rectangle withLeft (const ValueType newLeft) const noexcept { return Rectangle (newLeft, y, jmax (ValueType(), x + w - newLeft), h); } + Rectangle withLeft (const ValueType newLeft) const noexcept { return Rectangle (newLeft, pos.y, jmax (ValueType(), pos.x + w - newLeft), h); } /** Moves the y position, adjusting the height so that the bottom edge remains in the same place. If the y is moved to be below the current bottom edge, the height will be set to zero. @@ -225,15 +225,15 @@ public: */ void setTop (const ValueType newTop) noexcept { - h = jmax (ValueType(), y + h - newTop); - y = newTop; + h = jmax (ValueType(), pos.y + h - newTop); + pos.y = newTop; } /** Returns a new rectangle with a different y position, but the same bottom edge as this one. If the new y is beyond the bottom of the current rectangle, the height will be set to zero. @see setTop */ - Rectangle withTop (const ValueType newTop) const noexcept { return Rectangle (x, newTop, w, jmax (ValueType(), y + h - newTop)); } + Rectangle withTop (const ValueType newTop) const noexcept { return Rectangle (pos.x, newTop, w, jmax (ValueType(), pos.y + h - newTop)); } /** Adjusts the width so that the right-hand edge of the rectangle has this new value. If the new right is below the current X value, the X will be pushed down to match it. @@ -241,15 +241,15 @@ public: */ void setRight (const ValueType newRight) noexcept { - x = jmin (x, newRight); - w = newRight - x; + pos.x = jmin (pos.x, newRight); + w = newRight - pos.x; } /** Returns a new rectangle with a different right-hand edge position, but the same left-hand edge as this one. If the new right edge is below the current left-hand edge, the width will be set to zero. @see setRight */ - Rectangle withRight (const ValueType newRight) const noexcept { return Rectangle (jmin (x, newRight), y, jmax (ValueType(), newRight - x), h); } + Rectangle withRight (const ValueType newRight) const noexcept { return Rectangle (jmin (pos.x, newRight), pos.y, jmax (ValueType(), newRight - pos.x), h); } /** Adjusts the height so that the bottom edge of the rectangle has this new value. If the new bottom is lower than the current Y value, the Y will be pushed down to match it. @@ -257,55 +257,55 @@ public: */ void setBottom (const ValueType newBottom) noexcept { - y = jmin (y, newBottom); - h = newBottom - y; + pos.y = jmin (pos.y, newBottom); + h = newBottom - pos.y; } /** Returns a new rectangle with a different bottom edge position, but the same top edge as this one. If the new y is beyond the bottom of the current rectangle, the height will be set to zero. @see setBottom */ - Rectangle withBottom (const ValueType newBottom) const noexcept { return Rectangle (x, jmin (y, newBottom), w, jmax (ValueType(), newBottom - y)); } + Rectangle withBottom (const ValueType newBottom) const noexcept { return Rectangle (pos.x, jmin (pos.y, newBottom), w, jmax (ValueType(), newBottom - pos.y)); } //============================================================================== /** Moves the rectangle's position by adding amount to its x and y co-ordinates. */ void translate (const ValueType deltaX, const ValueType deltaY) noexcept { - x += deltaX; - y += deltaY; + pos.x += deltaX; + pos.y += deltaY; } /** Returns a rectangle which is the same as this one moved by a given amount. */ Rectangle translated (const ValueType deltaX, const ValueType deltaY) const noexcept { - return Rectangle (x + deltaX, y + deltaY, w, h); + return Rectangle (pos.x + deltaX, pos.y + deltaY, w, h); } /** Returns a rectangle which is the same as this one moved by a given amount. */ Rectangle operator+ (const Point& deltaPosition) const noexcept { - return Rectangle (x + deltaPosition.x, y + deltaPosition.y, w, h); + return Rectangle (pos.x + deltaPosition.x, pos.y + deltaPosition.y, w, h); } /** Moves this rectangle by a given amount. */ Rectangle& operator+= (const Point& deltaPosition) noexcept { - x += deltaPosition.x; y += deltaPosition.y; + pos += deltaPosition; return *this; } /** Returns a rectangle which is the same as this one moved by a given amount. */ Rectangle operator- (const Point& deltaPosition) const noexcept { - return Rectangle (x - deltaPosition.x, y - deltaPosition.y, w, h); + return Rectangle (pos.x - deltaPosition.x, pos.y - deltaPosition.y, w, h); } /** Moves this rectangle by a given amount. */ Rectangle& operator-= (const Point& deltaPosition) noexcept { - x -= deltaPosition.x; y -= deltaPosition.y; + pos -= deltaPosition; return *this; } @@ -319,7 +319,7 @@ public: { const ValueType nw = jmax (ValueType(), w + deltaX * 2); const ValueType nh = jmax (ValueType(), h + deltaY * 2); - setBounds (x - deltaX, y - deltaY, nw, nh); + setBounds (pos.x - deltaX, pos.y - deltaY, nw, nh); } /** Returns a rectangle that is larger than this one by a given amount. @@ -332,7 +332,7 @@ public: { const ValueType nw = jmax (ValueType(), w + deltaX * 2); const ValueType nh = jmax (ValueType(), h + deltaY * 2); - return Rectangle (x - deltaX, y - deltaY, nw, nh); + return Rectangle (pos.x - deltaX, pos.y - deltaY, nw, nh); } /** Shrinks the rectangle by a given amount. @@ -368,8 +368,8 @@ public: */ Rectangle removeFromTop (const ValueType amountToRemove) noexcept { - const Rectangle r (x, y, w, jmin (amountToRemove, h)); - y += r.h; h -= r.h; + const Rectangle r (pos.x, pos.y, w, jmin (amountToRemove, h)); + pos.y += r.h; h -= r.h; return r; } @@ -384,8 +384,8 @@ public: */ Rectangle removeFromLeft (const ValueType amountToRemove) noexcept { - const Rectangle r (x, y, jmin (amountToRemove, w), h); - x += r.w; w -= r.w; + const Rectangle r (pos.x, pos.y, jmin (amountToRemove, w), h); + pos.x += r.w; w -= r.w; return r; } @@ -401,7 +401,7 @@ public: Rectangle removeFromRight (ValueType amountToRemove) noexcept { amountToRemove = jmin (amountToRemove, w); - const Rectangle r (x + w - amountToRemove, y, amountToRemove, h); + const Rectangle r (pos.x + w - amountToRemove, pos.y, amountToRemove, h); w -= amountToRemove; return r; } @@ -418,7 +418,7 @@ public: Rectangle removeFromBottom (ValueType amountToRemove) noexcept { amountToRemove = jmin (amountToRemove, h); - const Rectangle r (x, y + h - amountToRemove, w, amountToRemove); + const Rectangle r (pos.x, pos.y + h - amountToRemove, w, amountToRemove); h -= amountToRemove; return r; } @@ -427,50 +427,48 @@ public: /** Returns true if the two rectangles are identical. */ bool operator== (const Rectangle& other) const noexcept { - return x == other.x && y == other.y - && w == other.w && h == other.h; + return pos == other.pos && w == other.w && h == other.h; } /** Returns true if the two rectangles are not identical. */ bool operator!= (const Rectangle& other) const noexcept { - return x != other.x || y != other.y - || w != other.w || h != other.h; + return pos != other.pos || w != other.w || h != other.h; } /** Returns true if this co-ordinate is inside the rectangle. */ bool contains (const ValueType xCoord, const ValueType yCoord) const noexcept { - return xCoord >= x && yCoord >= y && xCoord < x + w && yCoord < y + h; + return xCoord >= pos.x && yCoord >= pos.y && xCoord < pos.x + w && yCoord < pos.y + h; } /** Returns true if this co-ordinate is inside the rectangle. */ bool contains (const Point& point) const noexcept { - return point.x >= x && point.y >= y && point.x < x + w && point.y < y + h; + return point.x >= pos.x && point.y >= pos.y && point.x < pos.x + w && point.y < pos.y + h; } /** Returns true if this other rectangle is completely inside this one. */ bool contains (const Rectangle& other) const noexcept { - return x <= other.x && y <= other.y - && x + w >= other.x + other.w && y + h >= other.y + other.h; + return pos.x <= other.pos.x && pos.y <= other.pos.y + && pos.x + w >= other.pos.x + other.w && pos.y + h >= other.pos.y + other.h; } /** Returns the nearest point to the specified point that lies within this rectangle. */ Point getConstrainedPoint (const Point& point) const noexcept { - return Point (jlimit (x, x + w, point.x), - jlimit (y, y + h, point.y)); + return Point (jlimit (pos.x, pos.x + w, point.x), + jlimit (pos.y, pos.y + h, point.y)); } /** Returns true if any part of another rectangle overlaps this one. */ bool intersects (const Rectangle& other) const noexcept { - return x + w > other.x - && y + h > other.y - && x < other.x + other.w - && y < other.y + other.h + return pos.x + w > other.pos.x + && pos.y + h > other.pos.y + && pos.x < other.pos.x + other.w + && pos.y < other.pos.y + other.h && w > ValueType() && h > ValueType(); } @@ -480,10 +478,10 @@ public: */ Rectangle getIntersection (const Rectangle& other) const noexcept { - const ValueType nx = jmax (x, other.x); - const ValueType ny = jmax (y, other.y); - const ValueType nw = jmin (x + w, other.x + other.w) - nx; - const ValueType nh = jmin (y + h, other.y + other.h) - ny; + const ValueType nx = jmax (pos.x, other.pos.x); + const ValueType ny = jmax (pos.y, other.pos.y); + const ValueType nw = jmin (pos.x + w, other.pos.x + other.w) - nx; + const ValueType nh = jmin (pos.y + h, other.pos.y + other.h) - ny; if (nw >= ValueType() && nh >= ValueType()) return Rectangle (nx, ny, nw, nh); @@ -499,13 +497,13 @@ public: */ bool intersectRectangle (ValueType& otherX, ValueType& otherY, ValueType& otherW, ValueType& otherH) const noexcept { - const int maxX = jmax (otherX, x); - otherW = jmin (otherX + otherW, x + w) - maxX; + const int maxX = jmax (otherX, pos.x); + otherW = jmin (otherX + otherW, pos.x + w) - maxX; if (otherW > ValueType()) { - const int maxY = jmax (otherY, y); - otherH = jmin (otherY + otherH, y + h) - maxY; + const int maxY = jmax (otherY, pos.y); + otherH = jmin (otherY + otherH, pos.y + h) - maxY; if (otherH > ValueType()) { @@ -527,12 +525,12 @@ public: if (other.isEmpty()) return *this; if (isEmpty()) return other; - const ValueType newX = jmin (x, other.x); - const ValueType newY = jmin (y, other.y); + const ValueType newX = jmin (pos.x, other.pos.x); + const ValueType newY = jmin (pos.y, other.pos.y); return Rectangle (newX, newY, - jmax (x + w, other.x + other.w) - newX, - jmax (y + h, other.y + other.h) - newY); + jmax (pos.x + w, other.pos.x + other.w) - newX, + jmax (pos.y + h, other.pos.y + other.h) - newY); } /** If this rectangle merged with another one results in a simple rectangle, this @@ -543,20 +541,20 @@ public: */ bool enlargeIfAdjacent (const Rectangle& other) noexcept { - if (x == other.x && getRight() == other.getRight() - && (other.getBottom() >= y && other.y <= getBottom())) + if (pos.x == other.pos.x && getRight() == other.getRight() + && (other.getBottom() >= pos.y && other.pos.y <= getBottom())) { - const ValueType newY = jmin (y, other.y); + const ValueType newY = jmin (pos.y, other.pos.y); h = jmax (getBottom(), other.getBottom()) - newY; - y = newY; + pos.y = newY; return true; } - else if (y == other.y && getBottom() == other.getBottom() - && (other.getRight() >= x && other.x <= getRight())) + else if (pos.y == other.pos.y && getBottom() == other.getBottom() + && (other.getRight() >= pos.x && other.pos.x <= getRight())) { - const ValueType newX = jmin (x, other.x); + const ValueType newX = jmin (pos.x, other.pos.x); w = jmax (getRight(), other.getRight()) - newX; - x = newX; + pos.x = newX; return true; } @@ -573,20 +571,20 @@ public: { int inside = 0; const int otherR = other.getRight(); - if (x >= other.x && x < otherR) inside = 1; + if (pos.x >= other.pos.x && pos.x < otherR) inside = 1; const int otherB = other.getBottom(); - if (y >= other.y && y < otherB) inside |= 2; - const int r = x + w; - if (r >= other.x && r < otherR) inside |= 4; - const int b = y + h; - if (b >= other.y && b < otherB) inside |= 8; + if (pos.y >= other.pos.y && pos.y < otherB) inside |= 2; + const int r = pos.x + w; + if (r >= other.pos.x && r < otherR) inside |= 4; + const int b = pos.y + h; + if (b >= other.pos.y && b < otherB) inside |= 8; switch (inside) { - case 1 + 2 + 8: w = r - otherR; x = otherR; return true; - case 1 + 2 + 4: h = b - otherB; y = otherB; return true; - case 2 + 4 + 8: w = other.x - x; return true; - case 1 + 4 + 8: h = other.y - y; return true; + case 1 + 2 + 8: w = r - otherR; pos.x = otherR; return true; + case 1 + 2 + 4: h = b - otherB; pos.y = otherB; return true; + case 2 + 4 + 8: w = other.pos.x - pos.x; return true; + case 1 + 4 + 8: h = other.pos.y - pos.y; return true; } return false; @@ -599,10 +597,10 @@ public: */ Rectangle transformed (const AffineTransform& transform) const noexcept { - float x1 = x, y1 = y; - float x2 = x + w, y2 = y; - float x3 = x, y3 = y + h; - float x4 = x2, y4 = y3; + float x1 = pos.x, y1 = pos.y; + float x2 = pos.x + w, y2 = pos.y; + float x3 = pos.x, y3 = pos.y + h; + float x4 = x2, y4 = y3; transform.transformPoints (x1, y1, x2, y2); transform.transformPoints (x3, y3, x4, y4); @@ -621,10 +619,10 @@ public: */ Rectangle getSmallestIntegerContainer() const noexcept { - const int x1 = (int) std::floor (static_cast (x)); - const int y1 = (int) std::floor (static_cast (y)); - const int x2 = (int) std::ceil (static_cast (x + w)); - const int y2 = (int) std::ceil (static_cast (y + h)); + const int x1 = (int) std::floor (static_cast (pos.x)); + const int y1 = (int) std::floor (static_cast (pos.y)); + const int x2 = (int) std::ceil (static_cast (pos.x + w)); + const int y2 = (int) std::ceil (static_cast (pos.y + h)); return Rectangle (x1, y1, x2 - x1, y2 - y1); } @@ -657,8 +655,8 @@ public: */ Rectangle toFloat() const noexcept { - return Rectangle (static_cast (x), static_cast (y), - static_cast (w), static_cast (h)); + return Rectangle (static_cast (pos.x), static_cast (pos.y), + static_cast (w), static_cast (h)); } //============================================================================== @@ -703,7 +701,7 @@ public: { String s; s.preallocateBytes (32); - s << x << ' ' << y << ' ' << w << ' ' << h; + s << pos.x << ' ' << pos.y << ' ' << w << ' ' << h; return s; } @@ -730,7 +728,8 @@ public: private: friend class RectangleList; - ValueType x, y, w, h; + Point pos; + ValueType w, h; }; diff --git a/modules/juce_graphics/geometry/juce_RectangleList.cpp b/modules/juce_graphics/geometry/juce_RectangleList.cpp index 61d2708d85..0efddf02d3 100644 --- a/modules/juce_graphics/geometry/juce_RectangleList.cpp +++ b/modules/juce_graphics/geometry/juce_RectangleList.cpp @@ -182,8 +182,8 @@ void RectangleList::subtract (const Rectangle& rect) if (originalNumRects > 0) { - const int x1 = rect.x; - const int y1 = rect.y; + const int x1 = rect.pos.x; + const int y1 = rect.pos.y; const int x2 = x1 + rect.w; const int y2 = y1 + rect.h; @@ -191,8 +191,8 @@ void RectangleList::subtract (const Rectangle& rect) { Rectangle& r = rects.getReference (i); - const int rx1 = r.x; - const int ry1 = r.y; + const int rx1 = r.pos.x; + const int ry1 = r.pos.y; const int rx2 = rx1 + r.w; const int ry2 = ry1 + r.h; @@ -206,7 +206,7 @@ void RectangleList::subtract (const Rectangle& rect) } else { - r.x = x1; + r.pos.x = x1; r.w = rx2 - x1; rects.insert (++i, Rectangle (rx1, ry1, x1 - rx1, ry2 - ry1)); @@ -215,7 +215,7 @@ void RectangleList::subtract (const Rectangle& rect) } else if (x2 > rx1 && x2 < rx2) { - r.x = x2; + r.pos.x = x2; r.w = rx2 - x2; if (y1 > ry1 || y2 < ry2 || x1 > rx1) @@ -232,7 +232,7 @@ void RectangleList::subtract (const Rectangle& rect) } else { - r.y = y1; + r.pos.y = y1; r.h = ry2 - y1; rects.insert (++i, Rectangle (rx1, ry1, rx2 - rx1, y1 - ry1)); @@ -241,7 +241,7 @@ void RectangleList::subtract (const Rectangle& rect) } else if (y2 > ry1 && y2 < ry2) { - r.y = y2; + r.pos.y = y2; r.h = ry2 - y2; if (x1 > rx1 || x2 < rx2 || y1 > ry1) @@ -281,7 +281,7 @@ bool RectangleList::clipTo (const Rectangle& rect) { Rectangle& r = rects.getReference (i); - if (! rect.intersectRectangle (r.x, r.y, r.w, r.h)) + if (! rect.intersectRectangle (r.pos.x, r.pos.y, r.w, r.h)) rects.remove (i); else notEmpty = true; @@ -306,7 +306,7 @@ bool RectangleList::clipTo (const RectangleList& other) { Rectangle r (other.rects.getReference (i)); - if (rect.intersectRectangle (r.x, r.y, r.w, r.h)) + if (rect.intersectRectangle (r.pos.x, r.pos.y, r.w, r.h)) result.rects.add (r); } } @@ -326,7 +326,7 @@ bool RectangleList::getIntersectionWith (const Rectangle& rect, RectangleLi { Rectangle r (rects.getReference (i)); - if (rect.intersectRectangle (r.x, r.y, r.w, r.h)) + if (rect.intersectRectangle (r.pos.x, r.pos.y, r.w, r.h)) destRegion.rects.add (r); } } @@ -347,16 +347,16 @@ void RectangleList::consolidate() for (i = 0; i < getNumRectangles() - 1; ++i) { Rectangle& r = rects.getReference (i); - const int rx1 = r.x; - const int ry1 = r.y; + const int rx1 = r.pos.x; + const int ry1 = r.pos.y; const int rx2 = rx1 + r.w; const int ry2 = ry1 + r.h; for (int j = rects.size(); --j > i;) { Rectangle& r2 = rects.getReference (j); - const int jrx1 = r2.x; - const int jry1 = r2.y; + const int jrx1 = r2.pos.x; + const int jry1 = r2.pos.y; const int jrx2 = jrx1 + r2.w; const int jry2 = jry1 + r2.h; @@ -476,8 +476,8 @@ Rectangle RectangleList::getBounds() const noexcept { const Rectangle& r = rects.getReference (0); - int minX = r.x; - int minY = r.y; + int minX = r.pos.x; + int minY = r.pos.y; int maxX = minX + r.w; int maxY = minY + r.h; @@ -485,8 +485,8 @@ Rectangle RectangleList::getBounds() const noexcept { const Rectangle& r2 = rects.getReference (i); - minX = jmin (minX, r2.x); - minY = jmin (minY, r2.y); + minX = jmin (minX, r2.pos.x); + minY = jmin (minY, r2.pos.y); maxX = jmax (maxX, r2.getRight()); maxY = jmax (maxY, r2.getBottom()); } @@ -501,8 +501,8 @@ void RectangleList::offsetAll (const int dx, const int dy) noexcept { Rectangle& r = rects.getReference (i); - r.x += dx; - r.y += dy; + r.pos.x += dx; + r.pos.y += dy; } } diff --git a/modules/juce_gui_basics/components/juce_Component.cpp b/modules/juce_gui_basics/components/juce_Component.cpp index 8fd56577a0..271ba8379c 100644 --- a/modules/juce_gui_basics/components/juce_Component.cpp +++ b/modules/juce_gui_basics/components/juce_Component.cpp @@ -693,15 +693,11 @@ void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo) if (wasMinimised) peer->setMinimised (true); - if (isAlwaysOnTop()) - peer->setAlwaysOnTop (true); - peer->setConstrainer (currentConstainer); repaint(); + internalHierarchyChanged(); } - - internalHierarchyChanged(); } } @@ -2031,7 +2027,6 @@ void Component::setLookAndFeel (LookAndFeel* const newLookAndFeel) if (lookAndFeel != newLookAndFeel) { lookAndFeel = newLookAndFeel; - sendLookAndFeelChange(); } } @@ -2418,20 +2413,14 @@ void Component::internalMouseDown (MouseInputSource& source, const Point& r } } + for (Component* c = this; c != nullptr; c = c->parentComponent) { - Component* c = this; - - while (c != nullptr) + if (c->isBroughtToFrontOnMouseClick()) { - if (c->isBroughtToFrontOnMouseClick()) - { - c->toFront (true); - - if (checker.shouldBailOut()) - return; - } + c->toFront (true); - c = c->parentComponent; + if (checker.shouldBailOut()) + return; } } diff --git a/modules/juce_gui_basics/components/juce_Component.h b/modules/juce_gui_basics/components/juce_Component.h index feb4774dd3..933a5de707 100644 --- a/modules/juce_gui_basics/components/juce_Component.h +++ b/modules/juce_gui_basics/components/juce_Component.h @@ -298,7 +298,7 @@ public: int getRight() const noexcept { return bounds.getRight(); } /** Returns the component's top-left position as a Point. */ - Point getPosition() const noexcept { return bounds.getPosition(); } + const Point& getPosition() const noexcept { return bounds.getPosition(); } /** Returns the y coordinate of the bottom edge of this component. This is a distance in pixels from the top edge of the component's parent. @@ -341,8 +341,7 @@ public: If includeSiblings is true, it will also take into account any siblings that may be overlapping the component. */ - void getVisibleArea (RectangleList& result, - bool includeSiblings) const; + void getVisibleArea (RectangleList& result, bool includeSiblings) const; //============================================================================== /** Returns this component's x coordinate relative the the screen's top-left origin. diff --git a/modules/juce_gui_basics/components/juce_Desktop.cpp b/modules/juce_gui_basics/components/juce_Desktop.cpp index 4977d6b480..337d677b21 100644 --- a/modules/juce_gui_basics/components/juce_Desktop.cpp +++ b/modules/juce_gui_basics/components/juce_Desktop.cpp @@ -85,13 +85,13 @@ int Desktop::getNumDisplayMonitors() const noexcept return monitorCoordsClipped.size(); } -const Rectangle Desktop::getDisplayMonitorCoordinates (const int index, const bool clippedToWorkArea) const noexcept +Rectangle Desktop::getDisplayMonitorCoordinates (const int index, const bool clippedToWorkArea) const noexcept { return clippedToWorkArea ? monitorCoordsClipped [index] : monitorCoordsUnclipped [index]; } -const RectangleList Desktop::getAllMonitorDisplayAreas (const bool clippedToWorkArea) const +RectangleList Desktop::getAllMonitorDisplayAreas (const bool clippedToWorkArea) const { RectangleList rl; @@ -101,12 +101,12 @@ const RectangleList Desktop::getAllMonitorDisplayAreas (const bool clippedToWork return rl; } -const Rectangle Desktop::getMainMonitorArea (const bool clippedToWorkArea) const noexcept +Rectangle Desktop::getMainMonitorArea (const bool clippedToWorkArea) const noexcept { return getDisplayMonitorCoordinates (0, clippedToWorkArea); } -const Rectangle Desktop::getMonitorAreaContaining (const Point& position, const bool clippedToWorkArea) const +Rectangle Desktop::getMonitorAreaContaining (const Point& position, const bool clippedToWorkArea) const { Rectangle best (getMainMonitorArea (clippedToWorkArea)); double bestDistance = 1.0e10; @@ -223,12 +223,12 @@ void Desktop::componentBroughtToFront (Component* const c) } //============================================================================== -const Point Desktop::getMousePosition() +Point Desktop::getMousePosition() { return getInstance().getMainMouseSource().getScreenPosition(); } -const Point Desktop::getLastMouseDownPosition() +Point Desktop::getLastMouseDownPosition() { return getInstance().getMainMouseSource().getLastMouseDownPosition(); } diff --git a/modules/juce_gui_basics/components/juce_Desktop.h b/modules/juce_gui_basics/components/juce_Desktop.h index 48f990d70b..7be50d5b6a 100644 --- a/modules/juce_gui_basics/components/juce_Desktop.h +++ b/modules/juce_gui_basics/components/juce_Desktop.h @@ -74,14 +74,14 @@ public: If clippedToWorkArea is true, it will exclude any areas like the taskbar on Windows, or the menu bar on Mac. If clippedToWorkArea is false, the entire monitor area is returned. */ - const RectangleList getAllMonitorDisplayAreas (bool clippedToWorkArea = true) const; + RectangleList getAllMonitorDisplayAreas (bool clippedToWorkArea = true) const; /** Returns the position and size of the main monitor. If clippedToWorkArea is true, it will exclude any areas like the taskbar on Windows, or the menu bar on Mac. If clippedToWorkArea is false, the entire monitor area is returned. */ - const Rectangle getMainMonitorArea (bool clippedToWorkArea = true) const noexcept; + Rectangle getMainMonitorArea (bool clippedToWorkArea = true) const noexcept; /** Returns the position and size of the monitor which contains this co-ordinate. @@ -91,7 +91,7 @@ public: If clippedToWorkArea is true, it will exclude any areas like the taskbar on Windows, or the menu bar on Mac. If clippedToWorkArea is false, the entire monitor area is returned. */ - const Rectangle getMonitorAreaContaining (const Point& position, bool clippedToWorkArea = true) const; + Rectangle getMonitorAreaContaining (const Point& position, bool clippedToWorkArea = true) const; //============================================================================== @@ -103,7 +103,7 @@ public: you should only resort to grabbing the global mouse position if there's really no way to get the coordinates via a mouse event callback instead. */ - static const Point getMousePosition(); + static Point getMousePosition(); /** Makes the mouse pointer jump to a given location. @@ -118,7 +118,7 @@ public: get this information via other means, such as MouseEvent::getMouseDownScreenPosition() if possible, and only ever call this as a last resort. */ - static const Point getLastMouseDownPosition(); + static Point getLastMouseDownPosition(); /** Returns the number of times the mouse button has been clicked since the app started. @@ -390,7 +390,7 @@ private: ListenerList & getMouseListeners(); int getNumDisplayMonitors() const noexcept; - const Rectangle getDisplayMonitorCoordinates (int index, bool clippedToWorkArea) const noexcept; + Rectangle getDisplayMonitorCoordinates (int index, bool clippedToWorkArea) const noexcept; static void getCurrentMonitorPositions (Array >&, const bool clipToWorkArea); void addDesktopComponent (Component*); diff --git a/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp b/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp index c4dff5426a..6a5aa12318 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp +++ b/modules/juce_gui_basics/layout/juce_ComponentAnimator.cpp @@ -297,7 +297,7 @@ void ComponentAnimator::cancelAnimation (Component* const component, } } -const Rectangle ComponentAnimator::getComponentDestination (Component* const component) +Rectangle ComponentAnimator::getComponentDestination (Component* const component) { jassert (component != nullptr); AnimationTask* const at = findTaskFor (component); diff --git a/modules/juce_gui_basics/layout/juce_ComponentAnimator.h b/modules/juce_gui_basics/layout/juce_ComponentAnimator.h index 27e0c5df32..ae979e595e 100644 --- a/modules/juce_gui_basics/layout/juce_ComponentAnimator.h +++ b/modules/juce_gui_basics/layout/juce_ComponentAnimator.h @@ -140,7 +140,7 @@ public: If the specified component isn't currently being animated, this method will just return its current position. */ - const Rectangle getComponentDestination (Component* component); + Rectangle getComponentDestination (Component* component); /** Returns true if the specified component is currently being animated. */ bool isAnimating (Component* component) const noexcept; diff --git a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp index cc21cc6a1b..30c18fc36d 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp +++ b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.cpp @@ -186,7 +186,7 @@ void ResizableBorderComponent::setBorderThickness (const BorderSize& newBor } } -const BorderSize ResizableBorderComponent::getBorderThickness() const +BorderSize ResizableBorderComponent::getBorderThickness() const { return borderSize; } diff --git a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h index 4968ce5c0e..546de30121 100644 --- a/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h +++ b/modules/juce_gui_basics/layout/juce_ResizableBorderComponent.h @@ -84,7 +84,7 @@ public: @see setBorderThickness */ - const BorderSize getBorderThickness() const; + BorderSize getBorderThickness() const; //============================================================================== diff --git a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp index 5123085520..eb79a84152 100644 --- a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp +++ b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.cpp @@ -104,7 +104,7 @@ int TabBarButton::getBestTabLength (const int depth) getLookAndFeel().getTabButtonBestWidth (getIndex(), getButtonText(), depth, *this)); } -const Rectangle TabBarButton::getActiveArea() +Rectangle TabBarButton::getActiveArea() { Rectangle r (getLocalBounds()); const int spaceAroundImage = getLookAndFeel().getTabButtonSpaceAroundImage(); diff --git a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h index cfe0700dfa..9cb41f0aeb 100644 --- a/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h +++ b/modules/juce_gui_basics/layout/juce_TabbedButtonBar.h @@ -75,7 +75,7 @@ protected: This deals with the orientation of the tabs, which affects which side is touching the tabbed box's content component. */ - const Rectangle getActiveArea(); + Rectangle getActiveArea(); /** Returns this tab's index in its tab bar. */ int getIndex() const; diff --git a/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp b/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp index 420b5be227..ca4769c98c 100644 --- a/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp +++ b/modules/juce_gui_basics/layout/juce_TabbedComponent.cpp @@ -36,8 +36,8 @@ namespace TabbedComponentHelpers delete comp; } - const Rectangle getTabArea (Rectangle& content, BorderSize& outline, - const TabbedButtonBar::Orientation orientation, const int tabDepth) + Rectangle getTabArea (Rectangle& content, BorderSize& outline, + const TabbedButtonBar::Orientation orientation, const int tabDepth) { switch (orientation) { diff --git a/modules/juce_gui_basics/layout/juce_Viewport.h b/modules/juce_gui_basics/layout/juce_Viewport.h index 70d61bf1cf..a3b7dbd738 100644 --- a/modules/juce_gui_basics/layout/juce_Viewport.h +++ b/modules/juce_gui_basics/layout/juce_Viewport.h @@ -136,7 +136,7 @@ public: /** Returns the position within the child component of the top-left of its visible area. */ - const Point getViewPosition() const noexcept { return lastVisibleArea.getPosition(); } + const Point& getViewPosition() const noexcept { return lastVisibleArea.getPosition(); } /** Returns the position within the child component of the top-left of its visible area. @see getViewWidth, setViewPosition diff --git a/modules/juce_gui_basics/native/juce_android_Windowing.cpp b/modules/juce_gui_basics/native/juce_android_Windowing.cpp index 5e129cc033..a377503b00 100644 --- a/modules/juce_gui_basics/native/juce_android_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_android_Windowing.cpp @@ -215,7 +215,7 @@ public: } } - const Rectangle getBounds() const + Rectangle getBounds() const { return Rectangle (view.callIntMethod (ComponentPeerView.getLeft), view.callIntMethod (ComponentPeerView.getTop), @@ -223,18 +223,18 @@ public: view.callIntMethod (ComponentPeerView.getHeight)); } - const Point getScreenPosition() const + Point getScreenPosition() const { return Point (view.callIntMethod (ComponentPeerView.getLeft), view.callIntMethod (ComponentPeerView.getTop)); } - const Point localToGlobal (const Point& relativePosition) + Point localToGlobal (const Point& relativePosition) { return relativePosition + getScreenPosition(); } - const Point globalToLocal (const Point& screenPosition) + Point globalToLocal (const Point& screenPosition) { return screenPosition - getScreenPosition(); } @@ -282,7 +282,7 @@ public: position.x, position.y)); } - const BorderSize getFrameSize() const + BorderSize getFrameSize() const { // TODO return BorderSize(); diff --git a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm index b8418af2d0..deacfb3b3c 100644 --- a/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_ios_UIViewComponentPeer.mm @@ -100,18 +100,18 @@ public: void setSize (int w, int h); void setBounds (int x, int y, int w, int h, bool isNowFullScreen); - const Rectangle getBounds() const; - const Rectangle getBounds (const bool global) const; - const Point getScreenPosition() const; - const Point localToGlobal (const Point& relativePosition); - const Point globalToLocal (const Point& screenPosition); + Rectangle getBounds() const; + Rectangle getBounds (const bool global) const; + Point getScreenPosition() const; + Point localToGlobal (const Point& relativePosition); + Point globalToLocal (const Point& screenPosition); void setAlpha (float newAlpha); void setMinimised (bool shouldBeMinimised); bool isMinimised() const; void setFullScreen (bool shouldBeFullScreen); bool isFullScreen() const; bool contains (const Point& position, bool trueIfInAChildWindow) const; - const BorderSize getFrameSize() const; + BorderSize getFrameSize() const; bool setAlwaysOnTop (bool alwaysOnTop); void toFront (bool makeActiveWindow); void toBehind (ComponentPeer* other); @@ -498,7 +498,7 @@ void UIViewComponentPeer::setBounds (int x, int y, int w, int h, const bool isNo } } -const Rectangle UIViewComponentPeer::getBounds (const bool global) const +Rectangle UIViewComponentPeer::getBounds (const bool global) const { CGRect r = view.frame; @@ -516,22 +516,22 @@ const Rectangle UIViewComponentPeer::getBounds (const bool global) const return convertToRectInt (r); } -const Rectangle UIViewComponentPeer::getBounds() const +Rectangle UIViewComponentPeer::getBounds() const { return getBounds (! isSharedWindow); } -const Point UIViewComponentPeer::getScreenPosition() const +Point UIViewComponentPeer::getScreenPosition() const { return getBounds (true).getPosition(); } -const Point UIViewComponentPeer::localToGlobal (const Point& relativePosition) +Point UIViewComponentPeer::localToGlobal (const Point& relativePosition) { return relativePosition + getScreenPosition(); } -const Point UIViewComponentPeer::globalToLocal (const Point& screenPosition) +Point UIViewComponentPeer::globalToLocal (const Point& screenPosition) { return screenPosition - getScreenPosition(); } @@ -668,7 +668,7 @@ bool UIViewComponentPeer::contains (const Point& position, bool trueIfInACh return v == view; } -const BorderSize UIViewComponentPeer::getFrameSize() const +BorderSize UIViewComponentPeer::getFrameSize() const { return BorderSize(); } diff --git a/modules/juce_gui_basics/native/juce_linux_Windowing.cpp b/modules/juce_gui_basics/native/juce_linux_Windowing.cpp index 7d4eb88ea6..646ba41e05 100644 --- a/modules/juce_gui_basics/native/juce_linux_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_linux_Windowing.cpp @@ -857,17 +857,17 @@ public: } } - void setPosition (int x, int y) { setBounds (x, y, ww, wh, false); } - void setSize (int w, int h) { setBounds (wx, wy, w, h, false); } - const Rectangle getBounds() const { return Rectangle (wx, wy, ww, wh); } - const Point getScreenPosition() const { return Point (wx, wy); } + void setPosition (int x, int y) { setBounds (x, y, ww, wh, false); } + void setSize (int w, int h) { setBounds (wx, wy, w, h, false); } + Rectangle getBounds() const { return Rectangle (wx, wy, ww, wh); } + Point getScreenPosition() const { return Point (wx, wy); } - const Point localToGlobal (const Point& relativePosition) + Point localToGlobal (const Point& relativePosition) { return relativePosition + getScreenPosition(); } - const Point globalToLocal (const Point& screenPosition) + Point globalToLocal (const Point& screenPosition) { return screenPosition - getScreenPosition(); } @@ -1033,7 +1033,7 @@ public: return child == None; } - const BorderSize getFrameSize() const + BorderSize getFrameSize() const { return BorderSize(); } diff --git a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm index 4afa9cd801..2cc65a6a8a 100644 --- a/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm +++ b/modules/juce_gui_basics/native/juce_mac_NSViewComponentPeer.mm @@ -164,11 +164,11 @@ public: void setPosition (int x, int y); void setSize (int w, int h); void setBounds (int x, int y, int w, int h, const bool isNowFullScreen); - const Rectangle getBounds (const bool global) const; - const Rectangle getBounds() const; - const Point getScreenPosition() const; - const Point localToGlobal (const Point& relativePosition); - const Point globalToLocal (const Point& screenPosition); + Rectangle getBounds (const bool global) const; + Rectangle getBounds() const; + Point getScreenPosition() const; + Point localToGlobal (const Point& relativePosition); + Point globalToLocal (const Point& screenPosition); void setAlpha (float newAlpha); void setMinimised (bool shouldBeMinimised); bool isMinimised() const; @@ -177,7 +177,7 @@ public: void updateFullscreenStatus(); bool contains (const Point& position, bool trueIfInAChildWindow) const; bool hasNativeTitleBar() const { return (getStyleFlags() & windowHasTitleBar) != 0; } - const BorderSize getFrameSize() const; + BorderSize getFrameSize() const; bool setAlwaysOnTop (bool alwaysOnTop); void toFront (bool makeActiveWindow); void toBehind (ComponentPeer* other); @@ -273,7 +273,7 @@ public: + (int64) ([e timestamp] * 1000.0); } - static const Point getMousePos (NSEvent* e, NSView* view) + static Point getMousePos (NSEvent* e, NSView* view) { NSPoint p = [view convertPoint: [e locationInWindow] fromView: nil]; return Point (roundToInt (p.x), roundToInt ([view frame].size.height - p.y)); @@ -1134,7 +1134,7 @@ void NSViewComponentPeer::setBounds (int x, int y, int w, int h, bool isNowFullS } } -const Rectangle NSViewComponentPeer::getBounds (const bool global) const +Rectangle NSViewComponentPeer::getBounds (const bool global) const { NSRect r = [view frame]; @@ -1154,22 +1154,22 @@ const Rectangle NSViewComponentPeer::getBounds (const bool global) const return Rectangle (convertToRectInt (r)); } -const Rectangle NSViewComponentPeer::getBounds() const +Rectangle NSViewComponentPeer::getBounds() const { return getBounds (! isSharedWindow); } -const Point NSViewComponentPeer::getScreenPosition() const +Point NSViewComponentPeer::getScreenPosition() const { return getBounds (true).getPosition(); } -const Point NSViewComponentPeer::localToGlobal (const Point& relativePosition) +Point NSViewComponentPeer::localToGlobal (const Point& relativePosition) { return relativePosition + getScreenPosition(); } -const Point NSViewComponentPeer::globalToLocal (const Point& screenPosition) +Point NSViewComponentPeer::globalToLocal (const Point& screenPosition) { return screenPosition - getScreenPosition(); } @@ -1308,7 +1308,7 @@ bool NSViewComponentPeer::contains (const Point& position, bool trueIfInACh return v == view; } -const BorderSize NSViewComponentPeer::getFrameSize() const +BorderSize NSViewComponentPeer::getFrameSize() const { BorderSize b; diff --git a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp index e892ac4d8d..a01ce6eb87 100644 --- a/modules/juce_gui_basics/native/juce_win32_Windowing.cpp +++ b/modules/juce_gui_basics/native/juce_win32_Windowing.cpp @@ -612,7 +612,7 @@ public: repaintNowIfTransparent(); } - const Rectangle getBounds() const + Rectangle getBounds() const { RECT r; GetWindowRect (hwnd, &r); @@ -629,7 +629,7 @@ public: return windowBorder.subtractedFrom (bounds); } - const Point getScreenPosition() const + Point getScreenPosition() const { RECT r; GetWindowRect (hwnd, &r); @@ -637,12 +637,12 @@ public: r.top + windowBorder.getTop()); } - const Point localToGlobal (const Point& relativePosition) + Point localToGlobal (const Point& relativePosition) { return relativePosition + getScreenPosition(); } - const Point globalToLocal (const Point& screenPosition) + Point globalToLocal (const Point& screenPosition) { return screenPosition - getScreenPosition(); } @@ -752,7 +752,7 @@ public: return w == hwnd || (trueIfInAChildWindow && (IsChild (hwnd, w) != 0)); } - const BorderSize getFrameSize() const + BorderSize getFrameSize() const { return windowBorder; } @@ -1153,6 +1153,9 @@ private: const float alpha = component->getAlpha(); if (alpha < 1.0f) setAlpha (alpha); + + if (component->isAlwaysOnTop()) + setAlwaysOnTop (true); } else { diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.cpp b/modules/juce_gui_basics/widgets/juce_ListBox.cpp index 393853308b..76aa8cbaff 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.cpp +++ b/modules/juce_gui_basics/widgets/juce_ListBox.cpp @@ -631,8 +631,8 @@ int ListBox::getRowNumberOfComponent (Component* const rowComponent) const noexc return viewport->getRowNumberOfComponent (rowComponent); } -const Rectangle ListBox::getRowPosition (const int rowNumber, - const bool relativeToComponentTopLeft) const noexcept +Rectangle ListBox::getRowPosition (const int rowNumber, + const bool relativeToComponentTopLeft) const noexcept { int y = viewport->getY() + rowHeight * rowNumber; diff --git a/modules/juce_gui_basics/widgets/juce_ListBox.h b/modules/juce_gui_basics/widgets/juce_ListBox.h index d308be9adf..b9ee370811 100644 --- a/modules/juce_gui_basics/widgets/juce_ListBox.h +++ b/modules/juce_gui_basics/widgets/juce_ListBox.h @@ -400,8 +400,8 @@ public: This may be off-screen, and the range of the row number that is passed-in is not checked to see if it's a valid row. */ - const Rectangle getRowPosition (int rowNumber, - bool relativeToComponentTopLeft) const noexcept; + Rectangle getRowPosition (int rowNumber, + bool relativeToComponentTopLeft) const noexcept; /** Finds the row component for a given row in the list. diff --git a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp index 5e409d9cf0..7b13e11031 100644 --- a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp +++ b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.cpp @@ -240,7 +240,7 @@ int TableHeaderComponent::getColumnIdOfIndex (int index, const bool onlyCountVis return (ci != nullptr) ? ci->id : 0; } -const Rectangle TableHeaderComponent::getColumnPosition (const int index) const +Rectangle TableHeaderComponent::getColumnPosition (const int index) const { int x = 0, width = 0, n = 0; diff --git a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h index ea8f58b21a..32d7b347ce 100644 --- a/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h +++ b/modules/juce_gui_basics/widgets/juce_TableHeaderComponent.h @@ -231,7 +231,7 @@ public: ones are not counted). It returns a rectangle showing the position of the column relative to this component's top-left. If the index is out-of-range, an empty rectangle is retrurned. */ - const Rectangle getColumnPosition (int index) const; + Rectangle getColumnPosition (int index) const; /** Finds the column ID at a given x-position in the component. diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp index 9d5932ffea..0c11b56dee 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.cpp +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.cpp @@ -1480,7 +1480,7 @@ void TextEditor::setBorder (const BorderSize& border) resized(); } -const BorderSize TextEditor::getBorder() const +BorderSize TextEditor::getBorder() const { return borderSize; } diff --git a/modules/juce_gui_basics/widgets/juce_TextEditor.h b/modules/juce_gui_basics/widgets/juce_TextEditor.h index 309b695520..e9a65596b5 100644 --- a/modules/juce_gui_basics/widgets/juce_TextEditor.h +++ b/modules/juce_gui_basics/widgets/juce_TextEditor.h @@ -485,7 +485,7 @@ public: @see setBorder */ - const BorderSize getBorder() const; + BorderSize getBorder() const; /** Used to disable the auto-scrolling which keeps the caret visible. diff --git a/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h b/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h index bd544f13f0..a5112dfd54 100644 --- a/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h +++ b/modules/juce_gui_basics/widgets/juce_ToolbarItemComponent.h @@ -74,7 +74,7 @@ public: /** Returns the item type ID that this component represents. This value is in the constructor. */ - int getItemId() const noexcept { return itemId; } + int getItemId() const noexcept { return itemId; } /** Returns the toolbar that contains this component, or 0 if it's not currently inside one. @@ -91,7 +91,7 @@ public: Styles are listed in the Toolbar::ToolbarItemStyle enum. @see setStyle, Toolbar::getStyle */ - Toolbar::ToolbarItemStyle getStyle() const noexcept { return toolbarStyle; } + Toolbar::ToolbarItemStyle getStyle() const noexcept { return toolbarStyle; } /** Changes the current style setting of this item. @@ -110,7 +110,7 @@ public: @see contentAreaChanged */ - const Rectangle getContentArea() const noexcept { return contentArea; } + const Rectangle& getContentArea() const noexcept { return contentArea; } //============================================================================== /** This method must return the size criteria for this item, based on a given toolbar diff --git a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp index 7a1bb32c22..0acc702404 100644 --- a/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp +++ b/modules/juce_gui_basics/windows/juce_ComponentPeer.cpp @@ -393,12 +393,12 @@ const Rectangle& ComponentPeer::getNonFullScreenBounds() const noexcept return lastNonFullscreenBounds; } -const Rectangle ComponentPeer::localToGlobal (const Rectangle& relativePosition) +Rectangle ComponentPeer::localToGlobal (const Rectangle& relativePosition) { return relativePosition.withPosition (localToGlobal (relativePosition.getPosition())); } -const Rectangle ComponentPeer::globalToLocal (const Rectangle& screenPosition) +Rectangle ComponentPeer::globalToLocal (const Rectangle& screenPosition) { return screenPosition.withPosition (globalToLocal (screenPosition.getPosition())); } diff --git a/modules/juce_gui_basics/windows/juce_ComponentPeer.h b/modules/juce_gui_basics/windows/juce_ComponentPeer.h index e2bc1ab5ae..0e9b0db796 100644 --- a/modules/juce_gui_basics/windows/juce_ComponentPeer.h +++ b/modules/juce_gui_basics/windows/juce_ComponentPeer.h @@ -149,22 +149,22 @@ public: If the native window is contained in another window, then the co-ordinates are relative to the parent window's origin, not the screen origin. */ - virtual const Rectangle getBounds() const = 0; + virtual Rectangle getBounds() const = 0; /** Returns the x-position of this window, relative to the screen's origin. */ - virtual const Point getScreenPosition() const = 0; + virtual Point getScreenPosition() const = 0; /** Converts a position relative to the top-left of this component to screen co-ordinates. */ - virtual const Point localToGlobal (const Point& relativePosition) = 0; + virtual Point localToGlobal (const Point& relativePosition) = 0; /** Converts a rectangle relative to the top-left of this component to screen co-ordinates. */ - virtual const Rectangle localToGlobal (const Rectangle& relativePosition); + virtual Rectangle localToGlobal (const Rectangle& relativePosition); /** Converts a screen co-ordinate to a position relative to the top-left of this component. */ - virtual const Point globalToLocal (const Point& screenPosition) = 0; + virtual Point globalToLocal (const Point& screenPosition) = 0; /** Converts a screen area to a position relative to the top-left of this component. */ - virtual const Rectangle globalToLocal (const Rectangle& screenPosition); + virtual Rectangle globalToLocal (const Rectangle& screenPosition); /** Minimises the window. */ virtual void setMinimised (bool shouldBeMinimised) = 0; @@ -210,7 +210,7 @@ public: Whether or not the window has a normal window frame depends on the flags that were set when the window was created by Component::addToDesktop() */ - virtual const BorderSize getFrameSize() const = 0; + virtual BorderSize getFrameSize() const = 0; /** This is called when the window's bounds change. diff --git a/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp b/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp index 063bc5f3a6..1addacd18d 100644 --- a/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_DocumentWindow.cpp @@ -258,13 +258,13 @@ void DocumentWindow::resized() titleBarArea.getWidth(), menuBarHeight); } -const BorderSize DocumentWindow::getBorderThickness() +BorderSize DocumentWindow::getBorderThickness() { return BorderSize ((isFullScreen() || isUsingNativeTitleBar()) ? 0 : (resizableBorder != nullptr ? 4 : 1)); } -const BorderSize DocumentWindow::getContentComponentBorder() +BorderSize DocumentWindow::getContentComponentBorder() { BorderSize border (getBorderThickness()); @@ -280,7 +280,7 @@ int DocumentWindow::getTitleBarHeight() const return isUsingNativeTitleBar() ? 0 : jmin (titleBarHeight, getHeight() - 4); } -const Rectangle DocumentWindow::getTitleBarArea() +Rectangle DocumentWindow::getTitleBarArea() { const BorderSize border (getBorderThickness()); diff --git a/modules/juce_gui_basics/windows/juce_DocumentWindow.h b/modules/juce_gui_basics/windows/juce_DocumentWindow.h index 57a5470eaa..4ea516f737 100644 --- a/modules/juce_gui_basics/windows/juce_DocumentWindow.h +++ b/modules/juce_gui_basics/windows/juce_DocumentWindow.h @@ -237,9 +237,9 @@ public: /** @internal */ void lookAndFeelChanged(); /** @internal */ - const BorderSize getBorderThickness(); + BorderSize getBorderThickness(); /** @internal */ - const BorderSize getContentComponentBorder(); + BorderSize getContentComponentBorder(); /** @internal */ void mouseDoubleClick (const MouseEvent& e); /** @internal */ @@ -251,7 +251,7 @@ public: /** @internal */ void parentHierarchyChanged(); /** @internal */ - const Rectangle getTitleBarArea(); + Rectangle getTitleBarArea(); #endif private: diff --git a/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp b/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp index e0e5678e22..4b7974360d 100644 --- a/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp +++ b/modules/juce_gui_basics/windows/juce_ResizableWindow.cpp @@ -175,12 +175,12 @@ void ResizableWindow::setContentComponentSize (int width, int height) height + border.getTopAndBottom()); } -const BorderSize ResizableWindow::getBorderThickness() +BorderSize ResizableWindow::getBorderThickness() { return BorderSize (isUsingNativeTitleBar() ? 0 : ((resizableBorder != nullptr && ! isFullScreen()) ? 5 : 3)); } -const BorderSize ResizableWindow::getContentComponentBorder() +BorderSize ResizableWindow::getContentComponentBorder() { return getBorderThickness(); } diff --git a/modules/juce_gui_basics/windows/juce_ResizableWindow.h b/modules/juce_gui_basics/windows/juce_ResizableWindow.h index 3b082d9d17..0644294352 100644 --- a/modules/juce_gui_basics/windows/juce_ResizableWindow.h +++ b/modules/juce_gui_basics/windows/juce_ResizableWindow.h @@ -292,12 +292,12 @@ public: /** Returns the width of the frame to use around the window. @see getContentComponentBorder */ - virtual const BorderSize getBorderThickness(); + virtual BorderSize getBorderThickness(); /** Returns the insets to use when positioning the content component. @see getBorderThickness */ - virtual const BorderSize getContentComponentBorder(); + virtual BorderSize getContentComponentBorder(); //============================================================================== /** A set of colour IDs to use to change the colour of various aspects of the window.