| @@ -46,35 +46,34 @@ public: | |||||
| The default co-ordinates will be (0, 0, 0, 0). | The default co-ordinates will be (0, 0, 0, 0). | ||||
| */ | */ | ||||
| Rectangle() noexcept | Rectangle() noexcept | ||||
| : x(), y(), w(), h() | |||||
| : w(), h() | |||||
| { | { | ||||
| } | } | ||||
| /** Creates a copy of another rectangle. */ | /** Creates a copy of another rectangle. */ | ||||
| Rectangle (const Rectangle& other) noexcept | 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. */ | /** Creates a rectangle with a given position and size. */ | ||||
| Rectangle (const ValueType initialX, const ValueType initialY, | Rectangle (const ValueType initialX, const ValueType initialY, | ||||
| const ValueType width, const ValueType height) noexcept | const ValueType width, const ValueType height) noexcept | ||||
| : x (initialX), y (initialY), | |||||
| : pos (initialX, initialY), | |||||
| w (width), h (height) | w (width), h (height) | ||||
| { | { | ||||
| } | } | ||||
| /** Creates a rectangle with a given size, and a position of (0, 0). */ | /** Creates a rectangle with a given size, and a position of (0, 0). */ | ||||
| Rectangle (const ValueType width, const ValueType height) noexcept | 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. */ | /** Creates a Rectangle from the positions of two opposite corners. */ | ||||
| Rectangle (const Point<ValueType>& corner1, const Point<ValueType>& corner2) noexcept | Rectangle (const Point<ValueType>& corner1, const Point<ValueType>& 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), | w (corner1.x - corner2.x), | ||||
| h (corner1.y - corner2.y) | h (corner1.y - corner2.y) | ||||
| { | { | ||||
| @@ -94,7 +93,7 @@ public: | |||||
| Rectangle& operator= (const Rectangle& other) noexcept | Rectangle& operator= (const Rectangle& other) noexcept | ||||
| { | { | ||||
| x = other.x; y = other.y; | |||||
| pos = other.pos; | |||||
| w = other.w; h = other.h; | w = other.w; h = other.h; | ||||
| return *this; | return *this; | ||||
| } | } | ||||
| @@ -107,10 +106,10 @@ public: | |||||
| bool isEmpty() const noexcept { return w <= ValueType() || h <= ValueType(); } | bool isEmpty() const noexcept { return w <= ValueType() || h <= ValueType(); } | ||||
| /** Returns the x co-ordinate of the rectangle's left-hand-side. */ | /** 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. */ | /** 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. */ | /** Returns the width of the rectangle. */ | ||||
| inline ValueType getWidth() const noexcept { return w; } | inline ValueType getWidth() const noexcept { return w; } | ||||
| @@ -119,19 +118,20 @@ public: | |||||
| inline ValueType getHeight() const noexcept { return h; } | inline ValueType getHeight() const noexcept { return h; } | ||||
| /** Returns the x co-ordinate of the rectangle's right-hand-side. */ | /** 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. */ | /** 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. */ | /** 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. */ | /** 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. */ | /** Returns the centre point of the rectangle. */ | ||||
| Point<ValueType> getCentre() const noexcept { return Point<ValueType> (x + w / (ValueType) 2, y + h / (ValueType) 2); } | |||||
| Point<ValueType> getCentre() const noexcept { return Point<ValueType> (pos.x + w / (ValueType) 2, | |||||
| pos.y + h / (ValueType) 2); } | |||||
| /** Returns the aspect ratio of the rectangle's width / height. | /** Returns the aspect ratio of the rectangle's width / height. | ||||
| If widthOverHeight is true, it returns width / height; if widthOverHeight is false, | 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. */ | /** Returns the rectangle's top-left position as a Point. */ | ||||
| Point<ValueType> getPosition() const noexcept { return Point<ValueType> (x, y); } | |||||
| const Point<ValueType>& getPosition() const noexcept { return pos; } | |||||
| /** Changes the position of the rectangle's top-left corner (leaving its size unchanged). */ | /** Changes the position of the rectangle's top-left corner (leaving its size unchanged). */ | ||||
| void setPosition (const Point<ValueType>& newPos) noexcept { x = newPos.x; y = newPos.y; } | |||||
| void setPosition (const Point<ValueType>& newPos) noexcept { pos = newPos; } | |||||
| /** Changes the position of the rectangle's top-left corner (leaving its size unchanged). */ | /** 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. */ | /** 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); } | 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<ValueType>& newPos) const noexcept { return Rectangle (newPos.x, newPos.y, w, h); } | Rectangle withPosition (const Point<ValueType>& newPos) const noexcept { return Rectangle (newPos.x, newPos.y, w, h); } | ||||
| /** Returns the rectangle's top-left position as a Point. */ | /** Returns the rectangle's top-left position as a Point. */ | ||||
| Point<ValueType> getTopLeft() const noexcept { return getPosition(); } | |||||
| const Point<ValueType>& getTopLeft() const noexcept { return pos; } | |||||
| /** Returns the rectangle's top-right position as a Point. */ | /** Returns the rectangle's top-right position as a Point. */ | ||||
| Point<ValueType> getTopRight() const noexcept { return Point<ValueType> (x + w, y); } | |||||
| Point<ValueType> getTopRight() const noexcept { return Point<ValueType> (pos.x + w, pos.y); } | |||||
| /** Returns the rectangle's bottom-left position as a Point. */ | /** Returns the rectangle's bottom-left position as a Point. */ | ||||
| Point<ValueType> getBottomLeft() const noexcept { return Point<ValueType> (x, y + h); } | |||||
| Point<ValueType> getBottomLeft() const noexcept { return Point<ValueType> (pos.x, pos.y + h); } | |||||
| /** Returns the rectangle's bottom-right position as a Point. */ | /** Returns the rectangle's bottom-right position as a Point. */ | ||||
| Point<ValueType> getBottomRight() const noexcept { return Point<ValueType> (x + w, y + h); } | |||||
| Point<ValueType> getBottomRight() const noexcept { return Point<ValueType> (pos.x + w, pos.y + h); } | |||||
| /** Changes the rectangle's size, leaving the position of its top-left corner unchanged. */ | /** 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; } | 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. */ | /** 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. */ | /** Changes all the rectangle's co-ordinates. */ | ||||
| void setBounds (const ValueType newX, const ValueType newY, | void setBounds (const ValueType newX, const ValueType newY, | ||||
| const ValueType newWidth, const ValueType newHeight) noexcept | 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 */ | /** 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 */ | /** 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 */ | /** Changes the rectangle's width */ | ||||
| void setWidth (const ValueType newWidth) noexcept { w = newWidth; } | void setWidth (const ValueType newWidth) noexcept { w = newWidth; } | ||||
| @@ -192,16 +192,16 @@ public: | |||||
| void setHeight (const ValueType newHeight) noexcept { h = newHeight; } | 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. */ | /** 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. */ | /** 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. */ | /** 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. */ | /** 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. | /** 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. | 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 | 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. | /** 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. | If the new x is beyond the right of the current right-hand edge, the width will be set to zero. | ||||
| @see setLeft | @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. | /** 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. | 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 | 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. | /** 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. | If the new y is beyond the bottom of the current rectangle, the height will be set to zero. | ||||
| @see setTop | @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. | /** 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. | 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 | 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. | /** 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. | If the new right edge is below the current left-hand edge, the width will be set to zero. | ||||
| @see setRight | @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. | /** 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. | 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 | 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. | /** 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. | If the new y is beyond the bottom of the current rectangle, the height will be set to zero. | ||||
| @see setBottom | @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. */ | /** Moves the rectangle's position by adding amount to its x and y co-ordinates. */ | ||||
| void translate (const ValueType deltaX, | void translate (const ValueType deltaX, | ||||
| const ValueType deltaY) noexcept | 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. */ | /** Returns a rectangle which is the same as this one moved by a given amount. */ | ||||
| Rectangle translated (const ValueType deltaX, | Rectangle translated (const ValueType deltaX, | ||||
| const ValueType deltaY) const noexcept | 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. */ | /** Returns a rectangle which is the same as this one moved by a given amount. */ | ||||
| Rectangle operator+ (const Point<ValueType>& deltaPosition) const noexcept | Rectangle operator+ (const Point<ValueType>& 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. */ | /** Moves this rectangle by a given amount. */ | ||||
| Rectangle& operator+= (const Point<ValueType>& deltaPosition) noexcept | Rectangle& operator+= (const Point<ValueType>& deltaPosition) noexcept | ||||
| { | { | ||||
| x += deltaPosition.x; y += deltaPosition.y; | |||||
| pos += deltaPosition; | |||||
| return *this; | return *this; | ||||
| } | } | ||||
| /** Returns a rectangle which is the same as this one moved by a given amount. */ | /** Returns a rectangle which is the same as this one moved by a given amount. */ | ||||
| Rectangle operator- (const Point<ValueType>& deltaPosition) const noexcept | Rectangle operator- (const Point<ValueType>& 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. */ | /** Moves this rectangle by a given amount. */ | ||||
| Rectangle& operator-= (const Point<ValueType>& deltaPosition) noexcept | Rectangle& operator-= (const Point<ValueType>& deltaPosition) noexcept | ||||
| { | { | ||||
| x -= deltaPosition.x; y -= deltaPosition.y; | |||||
| pos -= deltaPosition; | |||||
| return *this; | return *this; | ||||
| } | } | ||||
| @@ -319,7 +319,7 @@ public: | |||||
| { | { | ||||
| const ValueType nw = jmax (ValueType(), w + deltaX * 2); | const ValueType nw = jmax (ValueType(), w + deltaX * 2); | ||||
| const ValueType nh = jmax (ValueType(), h + deltaY * 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. | /** 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 nw = jmax (ValueType(), w + deltaX * 2); | ||||
| const ValueType nh = jmax (ValueType(), h + deltaY * 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. | /** Shrinks the rectangle by a given amount. | ||||
| @@ -368,8 +368,8 @@ public: | |||||
| */ | */ | ||||
| Rectangle removeFromTop (const ValueType amountToRemove) noexcept | 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; | return r; | ||||
| } | } | ||||
| @@ -384,8 +384,8 @@ public: | |||||
| */ | */ | ||||
| Rectangle removeFromLeft (const ValueType amountToRemove) noexcept | 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; | return r; | ||||
| } | } | ||||
| @@ -401,7 +401,7 @@ public: | |||||
| Rectangle removeFromRight (ValueType amountToRemove) noexcept | Rectangle removeFromRight (ValueType amountToRemove) noexcept | ||||
| { | { | ||||
| amountToRemove = jmin (amountToRemove, w); | 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; | w -= amountToRemove; | ||||
| return r; | return r; | ||||
| } | } | ||||
| @@ -418,7 +418,7 @@ public: | |||||
| Rectangle removeFromBottom (ValueType amountToRemove) noexcept | Rectangle removeFromBottom (ValueType amountToRemove) noexcept | ||||
| { | { | ||||
| amountToRemove = jmin (amountToRemove, h); | 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; | h -= amountToRemove; | ||||
| return r; | return r; | ||||
| } | } | ||||
| @@ -427,50 +427,48 @@ public: | |||||
| /** Returns true if the two rectangles are identical. */ | /** Returns true if the two rectangles are identical. */ | ||||
| bool operator== (const Rectangle& other) const noexcept | 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. */ | /** Returns true if the two rectangles are not identical. */ | ||||
| bool operator!= (const Rectangle& other) const noexcept | 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. */ | /** Returns true if this co-ordinate is inside the rectangle. */ | ||||
| bool contains (const ValueType xCoord, const ValueType yCoord) const noexcept | 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. */ | /** Returns true if this co-ordinate is inside the rectangle. */ | ||||
| bool contains (const Point<ValueType>& point) const noexcept | bool contains (const Point<ValueType>& 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. */ | /** Returns true if this other rectangle is completely inside this one. */ | ||||
| bool contains (const Rectangle& other) const noexcept | 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. */ | /** Returns the nearest point to the specified point that lies within this rectangle. */ | ||||
| Point<ValueType> getConstrainedPoint (const Point<ValueType>& point) const noexcept | Point<ValueType> getConstrainedPoint (const Point<ValueType>& point) const noexcept | ||||
| { | { | ||||
| return Point<ValueType> (jlimit (x, x + w, point.x), | |||||
| jlimit (y, y + h, point.y)); | |||||
| return Point<ValueType> (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. */ | /** Returns true if any part of another rectangle overlaps this one. */ | ||||
| bool intersects (const Rectangle& other) const noexcept | 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(); | && w > ValueType() && h > ValueType(); | ||||
| } | } | ||||
| @@ -480,10 +478,10 @@ public: | |||||
| */ | */ | ||||
| Rectangle getIntersection (const Rectangle& other) const noexcept | 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()) | if (nw >= ValueType() && nh >= ValueType()) | ||||
| return Rectangle (nx, ny, nw, nh); | return Rectangle (nx, ny, nw, nh); | ||||
| @@ -499,13 +497,13 @@ public: | |||||
| */ | */ | ||||
| bool intersectRectangle (ValueType& otherX, ValueType& otherY, ValueType& otherW, ValueType& otherH) const noexcept | 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()) | 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()) | if (otherH > ValueType()) | ||||
| { | { | ||||
| @@ -527,12 +525,12 @@ public: | |||||
| if (other.isEmpty()) return *this; | if (other.isEmpty()) return *this; | ||||
| if (isEmpty()) return other; | 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, | 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 | /** If this rectangle merged with another one results in a simple rectangle, this | ||||
| @@ -543,20 +541,20 @@ public: | |||||
| */ | */ | ||||
| bool enlargeIfAdjacent (const Rectangle& other) noexcept | 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; | h = jmax (getBottom(), other.getBottom()) - newY; | ||||
| y = newY; | |||||
| pos.y = newY; | |||||
| return true; | 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; | w = jmax (getRight(), other.getRight()) - newX; | ||||
| x = newX; | |||||
| pos.x = newX; | |||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -573,20 +571,20 @@ public: | |||||
| { | { | ||||
| int inside = 0; | int inside = 0; | ||||
| const int otherR = other.getRight(); | 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(); | 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) | 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; | return false; | ||||
| @@ -599,10 +597,10 @@ public: | |||||
| */ | */ | ||||
| Rectangle transformed (const AffineTransform& transform) const noexcept | 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 (x1, y1, x2, y2); | ||||
| transform.transformPoints (x3, y3, x4, y4); | transform.transformPoints (x3, y3, x4, y4); | ||||
| @@ -621,10 +619,10 @@ public: | |||||
| */ | */ | ||||
| Rectangle<int> getSmallestIntegerContainer() const noexcept | Rectangle<int> getSmallestIntegerContainer() const noexcept | ||||
| { | { | ||||
| const int x1 = (int) std::floor (static_cast<float> (x)); | |||||
| const int y1 = (int) std::floor (static_cast<float> (y)); | |||||
| const int x2 = (int) std::ceil (static_cast<float> (x + w)); | |||||
| const int y2 = (int) std::ceil (static_cast<float> (y + h)); | |||||
| const int x1 = (int) std::floor (static_cast<float> (pos.x)); | |||||
| const int y1 = (int) std::floor (static_cast<float> (pos.y)); | |||||
| const int x2 = (int) std::ceil (static_cast<float> (pos.x + w)); | |||||
| const int y2 = (int) std::ceil (static_cast<float> (pos.y + h)); | |||||
| return Rectangle<int> (x1, y1, x2 - x1, y2 - y1); | return Rectangle<int> (x1, y1, x2 - x1, y2 - y1); | ||||
| } | } | ||||
| @@ -657,8 +655,8 @@ public: | |||||
| */ | */ | ||||
| Rectangle<float> toFloat() const noexcept | Rectangle<float> toFloat() const noexcept | ||||
| { | { | ||||
| return Rectangle<float> (static_cast<float> (x), static_cast<float> (y), | |||||
| static_cast<float> (w), static_cast<float> (h)); | |||||
| return Rectangle<float> (static_cast<float> (pos.x), static_cast<float> (pos.y), | |||||
| static_cast<float> (w), static_cast<float> (h)); | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| @@ -703,7 +701,7 @@ public: | |||||
| { | { | ||||
| String s; | String s; | ||||
| s.preallocateBytes (32); | s.preallocateBytes (32); | ||||
| s << x << ' ' << y << ' ' << w << ' ' << h; | |||||
| s << pos.x << ' ' << pos.y << ' ' << w << ' ' << h; | |||||
| return s; | return s; | ||||
| } | } | ||||
| @@ -730,7 +728,8 @@ public: | |||||
| private: | private: | ||||
| friend class RectangleList; | friend class RectangleList; | ||||
| ValueType x, y, w, h; | |||||
| Point<ValueType> pos; | |||||
| ValueType w, h; | |||||
| }; | }; | ||||
| @@ -182,8 +182,8 @@ void RectangleList::subtract (const Rectangle<int>& rect) | |||||
| if (originalNumRects > 0) | 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 x2 = x1 + rect.w; | ||||
| const int y2 = y1 + rect.h; | const int y2 = y1 + rect.h; | ||||
| @@ -191,8 +191,8 @@ void RectangleList::subtract (const Rectangle<int>& rect) | |||||
| { | { | ||||
| Rectangle<int>& r = rects.getReference (i); | Rectangle<int>& 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 rx2 = rx1 + r.w; | ||||
| const int ry2 = ry1 + r.h; | const int ry2 = ry1 + r.h; | ||||
| @@ -206,7 +206,7 @@ void RectangleList::subtract (const Rectangle<int>& rect) | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| r.x = x1; | |||||
| r.pos.x = x1; | |||||
| r.w = rx2 - x1; | r.w = rx2 - x1; | ||||
| rects.insert (++i, Rectangle<int> (rx1, ry1, x1 - rx1, ry2 - ry1)); | rects.insert (++i, Rectangle<int> (rx1, ry1, x1 - rx1, ry2 - ry1)); | ||||
| @@ -215,7 +215,7 @@ void RectangleList::subtract (const Rectangle<int>& rect) | |||||
| } | } | ||||
| else if (x2 > rx1 && x2 < rx2) | else if (x2 > rx1 && x2 < rx2) | ||||
| { | { | ||||
| r.x = x2; | |||||
| r.pos.x = x2; | |||||
| r.w = rx2 - x2; | r.w = rx2 - x2; | ||||
| if (y1 > ry1 || y2 < ry2 || x1 > rx1) | if (y1 > ry1 || y2 < ry2 || x1 > rx1) | ||||
| @@ -232,7 +232,7 @@ void RectangleList::subtract (const Rectangle<int>& rect) | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| r.y = y1; | |||||
| r.pos.y = y1; | |||||
| r.h = ry2 - y1; | r.h = ry2 - y1; | ||||
| rects.insert (++i, Rectangle<int> (rx1, ry1, rx2 - rx1, y1 - ry1)); | rects.insert (++i, Rectangle<int> (rx1, ry1, rx2 - rx1, y1 - ry1)); | ||||
| @@ -241,7 +241,7 @@ void RectangleList::subtract (const Rectangle<int>& rect) | |||||
| } | } | ||||
| else if (y2 > ry1 && y2 < ry2) | else if (y2 > ry1 && y2 < ry2) | ||||
| { | { | ||||
| r.y = y2; | |||||
| r.pos.y = y2; | |||||
| r.h = ry2 - y2; | r.h = ry2 - y2; | ||||
| if (x1 > rx1 || x2 < rx2 || y1 > ry1) | if (x1 > rx1 || x2 < rx2 || y1 > ry1) | ||||
| @@ -281,7 +281,7 @@ bool RectangleList::clipTo (const Rectangle<int>& rect) | |||||
| { | { | ||||
| Rectangle<int>& r = rects.getReference (i); | Rectangle<int>& 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); | rects.remove (i); | ||||
| else | else | ||||
| notEmpty = true; | notEmpty = true; | ||||
| @@ -306,7 +306,7 @@ bool RectangleList::clipTo (const RectangleList& other) | |||||
| { | { | ||||
| Rectangle<int> r (other.rects.getReference (i)); | Rectangle<int> 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); | result.rects.add (r); | ||||
| } | } | ||||
| } | } | ||||
| @@ -326,7 +326,7 @@ bool RectangleList::getIntersectionWith (const Rectangle<int>& rect, RectangleLi | |||||
| { | { | ||||
| Rectangle<int> r (rects.getReference (i)); | Rectangle<int> 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); | destRegion.rects.add (r); | ||||
| } | } | ||||
| } | } | ||||
| @@ -347,16 +347,16 @@ void RectangleList::consolidate() | |||||
| for (i = 0; i < getNumRectangles() - 1; ++i) | for (i = 0; i < getNumRectangles() - 1; ++i) | ||||
| { | { | ||||
| Rectangle<int>& r = rects.getReference (i); | Rectangle<int>& 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 rx2 = rx1 + r.w; | ||||
| const int ry2 = ry1 + r.h; | const int ry2 = ry1 + r.h; | ||||
| for (int j = rects.size(); --j > i;) | for (int j = rects.size(); --j > i;) | ||||
| { | { | ||||
| Rectangle<int>& r2 = rects.getReference (j); | Rectangle<int>& 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 jrx2 = jrx1 + r2.w; | ||||
| const int jry2 = jry1 + r2.h; | const int jry2 = jry1 + r2.h; | ||||
| @@ -476,8 +476,8 @@ Rectangle<int> RectangleList::getBounds() const noexcept | |||||
| { | { | ||||
| const Rectangle<int>& r = rects.getReference (0); | const Rectangle<int>& 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 maxX = minX + r.w; | ||||
| int maxY = minY + r.h; | int maxY = minY + r.h; | ||||
| @@ -485,8 +485,8 @@ Rectangle<int> RectangleList::getBounds() const noexcept | |||||
| { | { | ||||
| const Rectangle<int>& r2 = rects.getReference (i); | const Rectangle<int>& 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()); | maxX = jmax (maxX, r2.getRight()); | ||||
| maxY = jmax (maxY, r2.getBottom()); | maxY = jmax (maxY, r2.getBottom()); | ||||
| } | } | ||||
| @@ -501,8 +501,8 @@ void RectangleList::offsetAll (const int dx, const int dy) noexcept | |||||
| { | { | ||||
| Rectangle<int>& r = rects.getReference (i); | Rectangle<int>& r = rects.getReference (i); | ||||
| r.x += dx; | |||||
| r.y += dy; | |||||
| r.pos.x += dx; | |||||
| r.pos.y += dy; | |||||
| } | } | ||||
| } | } | ||||
| @@ -693,15 +693,11 @@ void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo) | |||||
| if (wasMinimised) | if (wasMinimised) | ||||
| peer->setMinimised (true); | peer->setMinimised (true); | ||||
| if (isAlwaysOnTop()) | |||||
| peer->setAlwaysOnTop (true); | |||||
| peer->setConstrainer (currentConstainer); | peer->setConstrainer (currentConstainer); | ||||
| repaint(); | repaint(); | ||||
| internalHierarchyChanged(); | |||||
| } | } | ||||
| internalHierarchyChanged(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -2031,7 +2027,6 @@ void Component::setLookAndFeel (LookAndFeel* const newLookAndFeel) | |||||
| if (lookAndFeel != newLookAndFeel) | if (lookAndFeel != newLookAndFeel) | ||||
| { | { | ||||
| lookAndFeel = newLookAndFeel; | lookAndFeel = newLookAndFeel; | ||||
| sendLookAndFeelChange(); | sendLookAndFeelChange(); | ||||
| } | } | ||||
| } | } | ||||
| @@ -2418,20 +2413,14 @@ void Component::internalMouseDown (MouseInputSource& source, const Point<int>& 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; | |||||
| } | } | ||||
| } | } | ||||
| @@ -298,7 +298,7 @@ public: | |||||
| int getRight() const noexcept { return bounds.getRight(); } | int getRight() const noexcept { return bounds.getRight(); } | ||||
| /** Returns the component's top-left position as a Point. */ | /** Returns the component's top-left position as a Point. */ | ||||
| Point<int> getPosition() const noexcept { return bounds.getPosition(); } | |||||
| const Point<int>& getPosition() const noexcept { return bounds.getPosition(); } | |||||
| /** Returns the y coordinate of the bottom edge of this component. | /** 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. | 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 | If includeSiblings is true, it will also take into account any siblings | ||||
| that may be overlapping the component. | 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. | /** Returns this component's x coordinate relative the the screen's top-left origin. | ||||
| @@ -85,13 +85,13 @@ int Desktop::getNumDisplayMonitors() const noexcept | |||||
| return monitorCoordsClipped.size(); | return monitorCoordsClipped.size(); | ||||
| } | } | ||||
| const Rectangle<int> Desktop::getDisplayMonitorCoordinates (const int index, const bool clippedToWorkArea) const noexcept | |||||
| Rectangle<int> Desktop::getDisplayMonitorCoordinates (const int index, const bool clippedToWorkArea) const noexcept | |||||
| { | { | ||||
| return clippedToWorkArea ? monitorCoordsClipped [index] | return clippedToWorkArea ? monitorCoordsClipped [index] | ||||
| : monitorCoordsUnclipped [index]; | : monitorCoordsUnclipped [index]; | ||||
| } | } | ||||
| const RectangleList Desktop::getAllMonitorDisplayAreas (const bool clippedToWorkArea) const | |||||
| RectangleList Desktop::getAllMonitorDisplayAreas (const bool clippedToWorkArea) const | |||||
| { | { | ||||
| RectangleList rl; | RectangleList rl; | ||||
| @@ -101,12 +101,12 @@ const RectangleList Desktop::getAllMonitorDisplayAreas (const bool clippedToWork | |||||
| return rl; | return rl; | ||||
| } | } | ||||
| const Rectangle<int> Desktop::getMainMonitorArea (const bool clippedToWorkArea) const noexcept | |||||
| Rectangle<int> Desktop::getMainMonitorArea (const bool clippedToWorkArea) const noexcept | |||||
| { | { | ||||
| return getDisplayMonitorCoordinates (0, clippedToWorkArea); | return getDisplayMonitorCoordinates (0, clippedToWorkArea); | ||||
| } | } | ||||
| const Rectangle<int> Desktop::getMonitorAreaContaining (const Point<int>& position, const bool clippedToWorkArea) const | |||||
| Rectangle<int> Desktop::getMonitorAreaContaining (const Point<int>& position, const bool clippedToWorkArea) const | |||||
| { | { | ||||
| Rectangle<int> best (getMainMonitorArea (clippedToWorkArea)); | Rectangle<int> best (getMainMonitorArea (clippedToWorkArea)); | ||||
| double bestDistance = 1.0e10; | double bestDistance = 1.0e10; | ||||
| @@ -223,12 +223,12 @@ void Desktop::componentBroughtToFront (Component* const c) | |||||
| } | } | ||||
| //============================================================================== | //============================================================================== | ||||
| const Point<int> Desktop::getMousePosition() | |||||
| Point<int> Desktop::getMousePosition() | |||||
| { | { | ||||
| return getInstance().getMainMouseSource().getScreenPosition(); | return getInstance().getMainMouseSource().getScreenPosition(); | ||||
| } | } | ||||
| const Point<int> Desktop::getLastMouseDownPosition() | |||||
| Point<int> Desktop::getLastMouseDownPosition() | |||||
| { | { | ||||
| return getInstance().getMainMouseSource().getLastMouseDownPosition(); | return getInstance().getMainMouseSource().getLastMouseDownPosition(); | ||||
| } | } | ||||
| @@ -74,14 +74,14 @@ public: | |||||
| If clippedToWorkArea is true, it will exclude any areas like the taskbar on Windows, | 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. | 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. | /** Returns the position and size of the main monitor. | ||||
| If clippedToWorkArea is true, it will exclude any areas like the taskbar on Windows, | 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. | or the menu bar on Mac. If clippedToWorkArea is false, the entire monitor area is returned. | ||||
| */ | */ | ||||
| const Rectangle<int> getMainMonitorArea (bool clippedToWorkArea = true) const noexcept; | |||||
| Rectangle<int> getMainMonitorArea (bool clippedToWorkArea = true) const noexcept; | |||||
| /** Returns the position and size of the monitor which contains this co-ordinate. | /** 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, | 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. | or the menu bar on Mac. If clippedToWorkArea is false, the entire monitor area is returned. | ||||
| */ | */ | ||||
| const Rectangle<int> getMonitorAreaContaining (const Point<int>& position, bool clippedToWorkArea = true) const; | |||||
| Rectangle<int> getMonitorAreaContaining (const Point<int>& 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 | 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. | way to get the coordinates via a mouse event callback instead. | ||||
| */ | */ | ||||
| static const Point<int> getMousePosition(); | |||||
| static Point<int> getMousePosition(); | |||||
| /** Makes the mouse pointer jump to a given location. | /** Makes the mouse pointer jump to a given location. | ||||
| @@ -118,7 +118,7 @@ public: | |||||
| get this information via other means, such as MouseEvent::getMouseDownScreenPosition() | get this information via other means, such as MouseEvent::getMouseDownScreenPosition() | ||||
| if possible, and only ever call this as a last resort. | if possible, and only ever call this as a last resort. | ||||
| */ | */ | ||||
| static const Point<int> getLastMouseDownPosition(); | |||||
| static Point<int> getLastMouseDownPosition(); | |||||
| /** Returns the number of times the mouse button has been clicked since the | /** Returns the number of times the mouse button has been clicked since the | ||||
| app started. | app started. | ||||
| @@ -390,7 +390,7 @@ private: | |||||
| ListenerList <MouseListener>& getMouseListeners(); | ListenerList <MouseListener>& getMouseListeners(); | ||||
| int getNumDisplayMonitors() const noexcept; | int getNumDisplayMonitors() const noexcept; | ||||
| const Rectangle<int> getDisplayMonitorCoordinates (int index, bool clippedToWorkArea) const noexcept; | |||||
| Rectangle<int> getDisplayMonitorCoordinates (int index, bool clippedToWorkArea) const noexcept; | |||||
| static void getCurrentMonitorPositions (Array <Rectangle<int> >&, const bool clipToWorkArea); | static void getCurrentMonitorPositions (Array <Rectangle<int> >&, const bool clipToWorkArea); | ||||
| void addDesktopComponent (Component*); | void addDesktopComponent (Component*); | ||||
| @@ -297,7 +297,7 @@ void ComponentAnimator::cancelAnimation (Component* const component, | |||||
| } | } | ||||
| } | } | ||||
| const Rectangle<int> ComponentAnimator::getComponentDestination (Component* const component) | |||||
| Rectangle<int> ComponentAnimator::getComponentDestination (Component* const component) | |||||
| { | { | ||||
| jassert (component != nullptr); | jassert (component != nullptr); | ||||
| AnimationTask* const at = findTaskFor (component); | AnimationTask* const at = findTaskFor (component); | ||||
| @@ -140,7 +140,7 @@ public: | |||||
| If the specified component isn't currently being animated, this method will just | If the specified component isn't currently being animated, this method will just | ||||
| return its current position. | return its current position. | ||||
| */ | */ | ||||
| const Rectangle<int> getComponentDestination (Component* component); | |||||
| Rectangle<int> getComponentDestination (Component* component); | |||||
| /** Returns true if the specified component is currently being animated. */ | /** Returns true if the specified component is currently being animated. */ | ||||
| bool isAnimating (Component* component) const noexcept; | bool isAnimating (Component* component) const noexcept; | ||||
| @@ -186,7 +186,7 @@ void ResizableBorderComponent::setBorderThickness (const BorderSize<int>& newBor | |||||
| } | } | ||||
| } | } | ||||
| const BorderSize<int> ResizableBorderComponent::getBorderThickness() const | |||||
| BorderSize<int> ResizableBorderComponent::getBorderThickness() const | |||||
| { | { | ||||
| return borderSize; | return borderSize; | ||||
| } | } | ||||
| @@ -84,7 +84,7 @@ public: | |||||
| @see setBorderThickness | @see setBorderThickness | ||||
| */ | */ | ||||
| const BorderSize<int> getBorderThickness() const; | |||||
| BorderSize<int> getBorderThickness() const; | |||||
| //============================================================================== | //============================================================================== | ||||
| @@ -104,7 +104,7 @@ int TabBarButton::getBestTabLength (const int depth) | |||||
| getLookAndFeel().getTabButtonBestWidth (getIndex(), getButtonText(), depth, *this)); | getLookAndFeel().getTabButtonBestWidth (getIndex(), getButtonText(), depth, *this)); | ||||
| } | } | ||||
| const Rectangle<int> TabBarButton::getActiveArea() | |||||
| Rectangle<int> TabBarButton::getActiveArea() | |||||
| { | { | ||||
| Rectangle<int> r (getLocalBounds()); | Rectangle<int> r (getLocalBounds()); | ||||
| const int spaceAroundImage = getLookAndFeel().getTabButtonSpaceAroundImage(); | const int spaceAroundImage = getLookAndFeel().getTabButtonSpaceAroundImage(); | ||||
| @@ -75,7 +75,7 @@ protected: | |||||
| This deals with the orientation of the tabs, which affects which side is | This deals with the orientation of the tabs, which affects which side is | ||||
| touching the tabbed box's content component. | touching the tabbed box's content component. | ||||
| */ | */ | ||||
| const Rectangle<int> getActiveArea(); | |||||
| Rectangle<int> getActiveArea(); | |||||
| /** Returns this tab's index in its tab bar. */ | /** Returns this tab's index in its tab bar. */ | ||||
| int getIndex() const; | int getIndex() const; | ||||
| @@ -36,8 +36,8 @@ namespace TabbedComponentHelpers | |||||
| delete comp; | delete comp; | ||||
| } | } | ||||
| const Rectangle<int> getTabArea (Rectangle<int>& content, BorderSize<int>& outline, | |||||
| const TabbedButtonBar::Orientation orientation, const int tabDepth) | |||||
| Rectangle<int> getTabArea (Rectangle<int>& content, BorderSize<int>& outline, | |||||
| const TabbedButtonBar::Orientation orientation, const int tabDepth) | |||||
| { | { | ||||
| switch (orientation) | switch (orientation) | ||||
| { | { | ||||
| @@ -136,7 +136,7 @@ public: | |||||
| /** Returns the position within the child component of the top-left of its visible area. | /** Returns the position within the child component of the top-left of its visible area. | ||||
| */ | */ | ||||
| const Point<int> getViewPosition() const noexcept { return lastVisibleArea.getPosition(); } | |||||
| const Point<int>& getViewPosition() const noexcept { return lastVisibleArea.getPosition(); } | |||||
| /** Returns the position within the child component of the top-left of its visible area. | /** Returns the position within the child component of the top-left of its visible area. | ||||
| @see getViewWidth, setViewPosition | @see getViewWidth, setViewPosition | ||||
| @@ -215,7 +215,7 @@ public: | |||||
| } | } | ||||
| } | } | ||||
| const Rectangle<int> getBounds() const | |||||
| Rectangle<int> getBounds() const | |||||
| { | { | ||||
| return Rectangle<int> (view.callIntMethod (ComponentPeerView.getLeft), | return Rectangle<int> (view.callIntMethod (ComponentPeerView.getLeft), | ||||
| view.callIntMethod (ComponentPeerView.getTop), | view.callIntMethod (ComponentPeerView.getTop), | ||||
| @@ -223,18 +223,18 @@ public: | |||||
| view.callIntMethod (ComponentPeerView.getHeight)); | view.callIntMethod (ComponentPeerView.getHeight)); | ||||
| } | } | ||||
| const Point<int> getScreenPosition() const | |||||
| Point<int> getScreenPosition() const | |||||
| { | { | ||||
| return Point<int> (view.callIntMethod (ComponentPeerView.getLeft), | return Point<int> (view.callIntMethod (ComponentPeerView.getLeft), | ||||
| view.callIntMethod (ComponentPeerView.getTop)); | view.callIntMethod (ComponentPeerView.getTop)); | ||||
| } | } | ||||
| const Point<int> localToGlobal (const Point<int>& relativePosition) | |||||
| Point<int> localToGlobal (const Point<int>& relativePosition) | |||||
| { | { | ||||
| return relativePosition + getScreenPosition(); | return relativePosition + getScreenPosition(); | ||||
| } | } | ||||
| const Point<int> globalToLocal (const Point<int>& screenPosition) | |||||
| Point<int> globalToLocal (const Point<int>& screenPosition) | |||||
| { | { | ||||
| return screenPosition - getScreenPosition(); | return screenPosition - getScreenPosition(); | ||||
| } | } | ||||
| @@ -282,7 +282,7 @@ public: | |||||
| position.x, position.y)); | position.x, position.y)); | ||||
| } | } | ||||
| const BorderSize<int> getFrameSize() const | |||||
| BorderSize<int> getFrameSize() const | |||||
| { | { | ||||
| // TODO | // TODO | ||||
| return BorderSize<int>(); | return BorderSize<int>(); | ||||
| @@ -100,18 +100,18 @@ public: | |||||
| void setSize (int w, int h); | void setSize (int w, int h); | ||||
| void setBounds (int x, int y, int w, int h, bool isNowFullScreen); | void setBounds (int x, int y, int w, int h, bool isNowFullScreen); | ||||
| const Rectangle<int> getBounds() const; | |||||
| const Rectangle<int> getBounds (const bool global) const; | |||||
| const Point<int> getScreenPosition() const; | |||||
| const Point<int> localToGlobal (const Point<int>& relativePosition); | |||||
| const Point<int> globalToLocal (const Point<int>& screenPosition); | |||||
| Rectangle<int> getBounds() const; | |||||
| Rectangle<int> getBounds (const bool global) const; | |||||
| Point<int> getScreenPosition() const; | |||||
| Point<int> localToGlobal (const Point<int>& relativePosition); | |||||
| Point<int> globalToLocal (const Point<int>& screenPosition); | |||||
| void setAlpha (float newAlpha); | void setAlpha (float newAlpha); | ||||
| void setMinimised (bool shouldBeMinimised); | void setMinimised (bool shouldBeMinimised); | ||||
| bool isMinimised() const; | bool isMinimised() const; | ||||
| void setFullScreen (bool shouldBeFullScreen); | void setFullScreen (bool shouldBeFullScreen); | ||||
| bool isFullScreen() const; | bool isFullScreen() const; | ||||
| bool contains (const Point<int>& position, bool trueIfInAChildWindow) const; | bool contains (const Point<int>& position, bool trueIfInAChildWindow) const; | ||||
| const BorderSize<int> getFrameSize() const; | |||||
| BorderSize<int> getFrameSize() const; | |||||
| bool setAlwaysOnTop (bool alwaysOnTop); | bool setAlwaysOnTop (bool alwaysOnTop); | ||||
| void toFront (bool makeActiveWindow); | void toFront (bool makeActiveWindow); | ||||
| void toBehind (ComponentPeer* other); | void toBehind (ComponentPeer* other); | ||||
| @@ -498,7 +498,7 @@ void UIViewComponentPeer::setBounds (int x, int y, int w, int h, const bool isNo | |||||
| } | } | ||||
| } | } | ||||
| const Rectangle<int> UIViewComponentPeer::getBounds (const bool global) const | |||||
| Rectangle<int> UIViewComponentPeer::getBounds (const bool global) const | |||||
| { | { | ||||
| CGRect r = view.frame; | CGRect r = view.frame; | ||||
| @@ -516,22 +516,22 @@ const Rectangle<int> UIViewComponentPeer::getBounds (const bool global) const | |||||
| return convertToRectInt (r); | return convertToRectInt (r); | ||||
| } | } | ||||
| const Rectangle<int> UIViewComponentPeer::getBounds() const | |||||
| Rectangle<int> UIViewComponentPeer::getBounds() const | |||||
| { | { | ||||
| return getBounds (! isSharedWindow); | return getBounds (! isSharedWindow); | ||||
| } | } | ||||
| const Point<int> UIViewComponentPeer::getScreenPosition() const | |||||
| Point<int> UIViewComponentPeer::getScreenPosition() const | |||||
| { | { | ||||
| return getBounds (true).getPosition(); | return getBounds (true).getPosition(); | ||||
| } | } | ||||
| const Point<int> UIViewComponentPeer::localToGlobal (const Point<int>& relativePosition) | |||||
| Point<int> UIViewComponentPeer::localToGlobal (const Point<int>& relativePosition) | |||||
| { | { | ||||
| return relativePosition + getScreenPosition(); | return relativePosition + getScreenPosition(); | ||||
| } | } | ||||
| const Point<int> UIViewComponentPeer::globalToLocal (const Point<int>& screenPosition) | |||||
| Point<int> UIViewComponentPeer::globalToLocal (const Point<int>& screenPosition) | |||||
| { | { | ||||
| return screenPosition - getScreenPosition(); | return screenPosition - getScreenPosition(); | ||||
| } | } | ||||
| @@ -668,7 +668,7 @@ bool UIViewComponentPeer::contains (const Point<int>& position, bool trueIfInACh | |||||
| return v == view; | return v == view; | ||||
| } | } | ||||
| const BorderSize<int> UIViewComponentPeer::getFrameSize() const | |||||
| BorderSize<int> UIViewComponentPeer::getFrameSize() const | |||||
| { | { | ||||
| return BorderSize<int>(); | return BorderSize<int>(); | ||||
| } | } | ||||
| @@ -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<int> getBounds() const { return Rectangle<int> (wx, wy, ww, wh); } | |||||
| const Point<int> getScreenPosition() const { return Point<int> (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<int> getBounds() const { return Rectangle<int> (wx, wy, ww, wh); } | |||||
| Point<int> getScreenPosition() const { return Point<int> (wx, wy); } | |||||
| const Point<int> localToGlobal (const Point<int>& relativePosition) | |||||
| Point<int> localToGlobal (const Point<int>& relativePosition) | |||||
| { | { | ||||
| return relativePosition + getScreenPosition(); | return relativePosition + getScreenPosition(); | ||||
| } | } | ||||
| const Point<int> globalToLocal (const Point<int>& screenPosition) | |||||
| Point<int> globalToLocal (const Point<int>& screenPosition) | |||||
| { | { | ||||
| return screenPosition - getScreenPosition(); | return screenPosition - getScreenPosition(); | ||||
| } | } | ||||
| @@ -1033,7 +1033,7 @@ public: | |||||
| return child == None; | return child == None; | ||||
| } | } | ||||
| const BorderSize<int> getFrameSize() const | |||||
| BorderSize<int> getFrameSize() const | |||||
| { | { | ||||
| return BorderSize<int>(); | return BorderSize<int>(); | ||||
| } | } | ||||
| @@ -164,11 +164,11 @@ public: | |||||
| void setPosition (int x, int y); | void setPosition (int x, int y); | ||||
| void setSize (int w, int h); | void setSize (int w, int h); | ||||
| void setBounds (int x, int y, int w, int h, const bool isNowFullScreen); | void setBounds (int x, int y, int w, int h, const bool isNowFullScreen); | ||||
| const Rectangle<int> getBounds (const bool global) const; | |||||
| const Rectangle<int> getBounds() const; | |||||
| const Point<int> getScreenPosition() const; | |||||
| const Point<int> localToGlobal (const Point<int>& relativePosition); | |||||
| const Point<int> globalToLocal (const Point<int>& screenPosition); | |||||
| Rectangle<int> getBounds (const bool global) const; | |||||
| Rectangle<int> getBounds() const; | |||||
| Point<int> getScreenPosition() const; | |||||
| Point<int> localToGlobal (const Point<int>& relativePosition); | |||||
| Point<int> globalToLocal (const Point<int>& screenPosition); | |||||
| void setAlpha (float newAlpha); | void setAlpha (float newAlpha); | ||||
| void setMinimised (bool shouldBeMinimised); | void setMinimised (bool shouldBeMinimised); | ||||
| bool isMinimised() const; | bool isMinimised() const; | ||||
| @@ -177,7 +177,7 @@ public: | |||||
| void updateFullscreenStatus(); | void updateFullscreenStatus(); | ||||
| bool contains (const Point<int>& position, bool trueIfInAChildWindow) const; | bool contains (const Point<int>& position, bool trueIfInAChildWindow) const; | ||||
| bool hasNativeTitleBar() const { return (getStyleFlags() & windowHasTitleBar) != 0; } | bool hasNativeTitleBar() const { return (getStyleFlags() & windowHasTitleBar) != 0; } | ||||
| const BorderSize<int> getFrameSize() const; | |||||
| BorderSize<int> getFrameSize() const; | |||||
| bool setAlwaysOnTop (bool alwaysOnTop); | bool setAlwaysOnTop (bool alwaysOnTop); | ||||
| void toFront (bool makeActiveWindow); | void toFront (bool makeActiveWindow); | ||||
| void toBehind (ComponentPeer* other); | void toBehind (ComponentPeer* other); | ||||
| @@ -273,7 +273,7 @@ public: | |||||
| + (int64) ([e timestamp] * 1000.0); | + (int64) ([e timestamp] * 1000.0); | ||||
| } | } | ||||
| static const Point<int> getMousePos (NSEvent* e, NSView* view) | |||||
| static Point<int> getMousePos (NSEvent* e, NSView* view) | |||||
| { | { | ||||
| NSPoint p = [view convertPoint: [e locationInWindow] fromView: nil]; | NSPoint p = [view convertPoint: [e locationInWindow] fromView: nil]; | ||||
| return Point<int> (roundToInt (p.x), roundToInt ([view frame].size.height - p.y)); | return Point<int> (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<int> NSViewComponentPeer::getBounds (const bool global) const | |||||
| Rectangle<int> NSViewComponentPeer::getBounds (const bool global) const | |||||
| { | { | ||||
| NSRect r = [view frame]; | NSRect r = [view frame]; | ||||
| @@ -1154,22 +1154,22 @@ const Rectangle<int> NSViewComponentPeer::getBounds (const bool global) const | |||||
| return Rectangle<int> (convertToRectInt (r)); | return Rectangle<int> (convertToRectInt (r)); | ||||
| } | } | ||||
| const Rectangle<int> NSViewComponentPeer::getBounds() const | |||||
| Rectangle<int> NSViewComponentPeer::getBounds() const | |||||
| { | { | ||||
| return getBounds (! isSharedWindow); | return getBounds (! isSharedWindow); | ||||
| } | } | ||||
| const Point<int> NSViewComponentPeer::getScreenPosition() const | |||||
| Point<int> NSViewComponentPeer::getScreenPosition() const | |||||
| { | { | ||||
| return getBounds (true).getPosition(); | return getBounds (true).getPosition(); | ||||
| } | } | ||||
| const Point<int> NSViewComponentPeer::localToGlobal (const Point<int>& relativePosition) | |||||
| Point<int> NSViewComponentPeer::localToGlobal (const Point<int>& relativePosition) | |||||
| { | { | ||||
| return relativePosition + getScreenPosition(); | return relativePosition + getScreenPosition(); | ||||
| } | } | ||||
| const Point<int> NSViewComponentPeer::globalToLocal (const Point<int>& screenPosition) | |||||
| Point<int> NSViewComponentPeer::globalToLocal (const Point<int>& screenPosition) | |||||
| { | { | ||||
| return screenPosition - getScreenPosition(); | return screenPosition - getScreenPosition(); | ||||
| } | } | ||||
| @@ -1308,7 +1308,7 @@ bool NSViewComponentPeer::contains (const Point<int>& position, bool trueIfInACh | |||||
| return v == view; | return v == view; | ||||
| } | } | ||||
| const BorderSize<int> NSViewComponentPeer::getFrameSize() const | |||||
| BorderSize<int> NSViewComponentPeer::getFrameSize() const | |||||
| { | { | ||||
| BorderSize<int> b; | BorderSize<int> b; | ||||
| @@ -612,7 +612,7 @@ public: | |||||
| repaintNowIfTransparent(); | repaintNowIfTransparent(); | ||||
| } | } | ||||
| const Rectangle<int> getBounds() const | |||||
| Rectangle<int> getBounds() const | |||||
| { | { | ||||
| RECT r; | RECT r; | ||||
| GetWindowRect (hwnd, &r); | GetWindowRect (hwnd, &r); | ||||
| @@ -629,7 +629,7 @@ public: | |||||
| return windowBorder.subtractedFrom (bounds); | return windowBorder.subtractedFrom (bounds); | ||||
| } | } | ||||
| const Point<int> getScreenPosition() const | |||||
| Point<int> getScreenPosition() const | |||||
| { | { | ||||
| RECT r; | RECT r; | ||||
| GetWindowRect (hwnd, &r); | GetWindowRect (hwnd, &r); | ||||
| @@ -637,12 +637,12 @@ public: | |||||
| r.top + windowBorder.getTop()); | r.top + windowBorder.getTop()); | ||||
| } | } | ||||
| const Point<int> localToGlobal (const Point<int>& relativePosition) | |||||
| Point<int> localToGlobal (const Point<int>& relativePosition) | |||||
| { | { | ||||
| return relativePosition + getScreenPosition(); | return relativePosition + getScreenPosition(); | ||||
| } | } | ||||
| const Point<int> globalToLocal (const Point<int>& screenPosition) | |||||
| Point<int> globalToLocal (const Point<int>& screenPosition) | |||||
| { | { | ||||
| return screenPosition - getScreenPosition(); | return screenPosition - getScreenPosition(); | ||||
| } | } | ||||
| @@ -752,7 +752,7 @@ public: | |||||
| return w == hwnd || (trueIfInAChildWindow && (IsChild (hwnd, w) != 0)); | return w == hwnd || (trueIfInAChildWindow && (IsChild (hwnd, w) != 0)); | ||||
| } | } | ||||
| const BorderSize<int> getFrameSize() const | |||||
| BorderSize<int> getFrameSize() const | |||||
| { | { | ||||
| return windowBorder; | return windowBorder; | ||||
| } | } | ||||
| @@ -1153,6 +1153,9 @@ private: | |||||
| const float alpha = component->getAlpha(); | const float alpha = component->getAlpha(); | ||||
| if (alpha < 1.0f) | if (alpha < 1.0f) | ||||
| setAlpha (alpha); | setAlpha (alpha); | ||||
| if (component->isAlwaysOnTop()) | |||||
| setAlwaysOnTop (true); | |||||
| } | } | ||||
| else | else | ||||
| { | { | ||||
| @@ -631,8 +631,8 @@ int ListBox::getRowNumberOfComponent (Component* const rowComponent) const noexc | |||||
| return viewport->getRowNumberOfComponent (rowComponent); | return viewport->getRowNumberOfComponent (rowComponent); | ||||
| } | } | ||||
| const Rectangle<int> ListBox::getRowPosition (const int rowNumber, | |||||
| const bool relativeToComponentTopLeft) const noexcept | |||||
| Rectangle<int> ListBox::getRowPosition (const int rowNumber, | |||||
| const bool relativeToComponentTopLeft) const noexcept | |||||
| { | { | ||||
| int y = viewport->getY() + rowHeight * rowNumber; | int y = viewport->getY() + rowHeight * rowNumber; | ||||
| @@ -400,8 +400,8 @@ public: | |||||
| This may be off-screen, and the range of the row number that is passed-in is | 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. | not checked to see if it's a valid row. | ||||
| */ | */ | ||||
| const Rectangle<int> getRowPosition (int rowNumber, | |||||
| bool relativeToComponentTopLeft) const noexcept; | |||||
| Rectangle<int> getRowPosition (int rowNumber, | |||||
| bool relativeToComponentTopLeft) const noexcept; | |||||
| /** Finds the row component for a given row in the list. | /** Finds the row component for a given row in the list. | ||||
| @@ -240,7 +240,7 @@ int TableHeaderComponent::getColumnIdOfIndex (int index, const bool onlyCountVis | |||||
| return (ci != nullptr) ? ci->id : 0; | return (ci != nullptr) ? ci->id : 0; | ||||
| } | } | ||||
| const Rectangle<int> TableHeaderComponent::getColumnPosition (const int index) const | |||||
| Rectangle<int> TableHeaderComponent::getColumnPosition (const int index) const | |||||
| { | { | ||||
| int x = 0, width = 0, n = 0; | int x = 0, width = 0, n = 0; | ||||
| @@ -231,7 +231,7 @@ public: | |||||
| ones are not counted). It returns a rectangle showing the position of the column relative | 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. | to this component's top-left. If the index is out-of-range, an empty rectangle is retrurned. | ||||
| */ | */ | ||||
| const Rectangle<int> getColumnPosition (int index) const; | |||||
| Rectangle<int> getColumnPosition (int index) const; | |||||
| /** Finds the column ID at a given x-position in the component. | /** Finds the column ID at a given x-position in the component. | ||||
| @@ -1480,7 +1480,7 @@ void TextEditor::setBorder (const BorderSize<int>& border) | |||||
| resized(); | resized(); | ||||
| } | } | ||||
| const BorderSize<int> TextEditor::getBorder() const | |||||
| BorderSize<int> TextEditor::getBorder() const | |||||
| { | { | ||||
| return borderSize; | return borderSize; | ||||
| } | } | ||||
| @@ -485,7 +485,7 @@ public: | |||||
| @see setBorder | @see setBorder | ||||
| */ | */ | ||||
| const BorderSize<int> getBorder() const; | |||||
| BorderSize<int> getBorder() const; | |||||
| /** Used to disable the auto-scrolling which keeps the caret visible. | /** Used to disable the auto-scrolling which keeps the caret visible. | ||||
| @@ -74,7 +74,7 @@ public: | |||||
| /** Returns the item type ID that this component represents. | /** Returns the item type ID that this component represents. | ||||
| This value is in the constructor. | 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 | /** Returns the toolbar that contains this component, or 0 if it's not currently | ||||
| inside one. | inside one. | ||||
| @@ -91,7 +91,7 @@ public: | |||||
| Styles are listed in the Toolbar::ToolbarItemStyle enum. | Styles are listed in the Toolbar::ToolbarItemStyle enum. | ||||
| @see setStyle, Toolbar::getStyle | @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. | /** Changes the current style setting of this item. | ||||
| @@ -110,7 +110,7 @@ public: | |||||
| @see contentAreaChanged | @see contentAreaChanged | ||||
| */ | */ | ||||
| const Rectangle<int> getContentArea() const noexcept { return contentArea; } | |||||
| const Rectangle<int>& getContentArea() const noexcept { return contentArea; } | |||||
| //============================================================================== | //============================================================================== | ||||
| /** This method must return the size criteria for this item, based on a given toolbar | /** This method must return the size criteria for this item, based on a given toolbar | ||||
| @@ -393,12 +393,12 @@ const Rectangle<int>& ComponentPeer::getNonFullScreenBounds() const noexcept | |||||
| return lastNonFullscreenBounds; | return lastNonFullscreenBounds; | ||||
| } | } | ||||
| const Rectangle<int> ComponentPeer::localToGlobal (const Rectangle<int>& relativePosition) | |||||
| Rectangle<int> ComponentPeer::localToGlobal (const Rectangle<int>& relativePosition) | |||||
| { | { | ||||
| return relativePosition.withPosition (localToGlobal (relativePosition.getPosition())); | return relativePosition.withPosition (localToGlobal (relativePosition.getPosition())); | ||||
| } | } | ||||
| const Rectangle<int> ComponentPeer::globalToLocal (const Rectangle<int>& screenPosition) | |||||
| Rectangle<int> ComponentPeer::globalToLocal (const Rectangle<int>& screenPosition) | |||||
| { | { | ||||
| return screenPosition.withPosition (globalToLocal (screenPosition.getPosition())); | return screenPosition.withPosition (globalToLocal (screenPosition.getPosition())); | ||||
| } | } | ||||
| @@ -149,22 +149,22 @@ public: | |||||
| If the native window is contained in another window, then the co-ordinates are | 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. | relative to the parent window's origin, not the screen origin. | ||||
| */ | */ | ||||
| virtual const Rectangle<int> getBounds() const = 0; | |||||
| virtual Rectangle<int> getBounds() const = 0; | |||||
| /** Returns the x-position of this window, relative to the screen's origin. */ | /** Returns the x-position of this window, relative to the screen's origin. */ | ||||
| virtual const Point<int> getScreenPosition() const = 0; | |||||
| virtual Point<int> getScreenPosition() const = 0; | |||||
| /** Converts a position relative to the top-left of this component to screen co-ordinates. */ | /** Converts a position relative to the top-left of this component to screen co-ordinates. */ | ||||
| virtual const Point<int> localToGlobal (const Point<int>& relativePosition) = 0; | |||||
| virtual Point<int> localToGlobal (const Point<int>& relativePosition) = 0; | |||||
| /** Converts a rectangle relative to the top-left of this component to screen co-ordinates. */ | /** Converts a rectangle relative to the top-left of this component to screen co-ordinates. */ | ||||
| virtual const Rectangle<int> localToGlobal (const Rectangle<int>& relativePosition); | |||||
| virtual Rectangle<int> localToGlobal (const Rectangle<int>& relativePosition); | |||||
| /** Converts a screen co-ordinate to a position relative to the top-left of this component. */ | /** Converts a screen co-ordinate to a position relative to the top-left of this component. */ | ||||
| virtual const Point<int> globalToLocal (const Point<int>& screenPosition) = 0; | |||||
| virtual Point<int> globalToLocal (const Point<int>& screenPosition) = 0; | |||||
| /** Converts a screen area to a position relative to the top-left of this component. */ | /** Converts a screen area to a position relative to the top-left of this component. */ | ||||
| virtual const Rectangle<int> globalToLocal (const Rectangle<int>& screenPosition); | |||||
| virtual Rectangle<int> globalToLocal (const Rectangle<int>& screenPosition); | |||||
| /** Minimises the window. */ | /** Minimises the window. */ | ||||
| virtual void setMinimised (bool shouldBeMinimised) = 0; | 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 | 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() | that were set when the window was created by Component::addToDesktop() | ||||
| */ | */ | ||||
| virtual const BorderSize<int> getFrameSize() const = 0; | |||||
| virtual BorderSize<int> getFrameSize() const = 0; | |||||
| /** This is called when the window's bounds change. | /** This is called when the window's bounds change. | ||||
| @@ -258,13 +258,13 @@ void DocumentWindow::resized() | |||||
| titleBarArea.getWidth(), menuBarHeight); | titleBarArea.getWidth(), menuBarHeight); | ||||
| } | } | ||||
| const BorderSize<int> DocumentWindow::getBorderThickness() | |||||
| BorderSize<int> DocumentWindow::getBorderThickness() | |||||
| { | { | ||||
| return BorderSize<int> ((isFullScreen() || isUsingNativeTitleBar()) | return BorderSize<int> ((isFullScreen() || isUsingNativeTitleBar()) | ||||
| ? 0 : (resizableBorder != nullptr ? 4 : 1)); | ? 0 : (resizableBorder != nullptr ? 4 : 1)); | ||||
| } | } | ||||
| const BorderSize<int> DocumentWindow::getContentComponentBorder() | |||||
| BorderSize<int> DocumentWindow::getContentComponentBorder() | |||||
| { | { | ||||
| BorderSize<int> border (getBorderThickness()); | BorderSize<int> border (getBorderThickness()); | ||||
| @@ -280,7 +280,7 @@ int DocumentWindow::getTitleBarHeight() const | |||||
| return isUsingNativeTitleBar() ? 0 : jmin (titleBarHeight, getHeight() - 4); | return isUsingNativeTitleBar() ? 0 : jmin (titleBarHeight, getHeight() - 4); | ||||
| } | } | ||||
| const Rectangle<int> DocumentWindow::getTitleBarArea() | |||||
| Rectangle<int> DocumentWindow::getTitleBarArea() | |||||
| { | { | ||||
| const BorderSize<int> border (getBorderThickness()); | const BorderSize<int> border (getBorderThickness()); | ||||
| @@ -237,9 +237,9 @@ public: | |||||
| /** @internal */ | /** @internal */ | ||||
| void lookAndFeelChanged(); | void lookAndFeelChanged(); | ||||
| /** @internal */ | /** @internal */ | ||||
| const BorderSize<int> getBorderThickness(); | |||||
| BorderSize<int> getBorderThickness(); | |||||
| /** @internal */ | /** @internal */ | ||||
| const BorderSize<int> getContentComponentBorder(); | |||||
| BorderSize<int> getContentComponentBorder(); | |||||
| /** @internal */ | /** @internal */ | ||||
| void mouseDoubleClick (const MouseEvent& e); | void mouseDoubleClick (const MouseEvent& e); | ||||
| /** @internal */ | /** @internal */ | ||||
| @@ -251,7 +251,7 @@ public: | |||||
| /** @internal */ | /** @internal */ | ||||
| void parentHierarchyChanged(); | void parentHierarchyChanged(); | ||||
| /** @internal */ | /** @internal */ | ||||
| const Rectangle<int> getTitleBarArea(); | |||||
| Rectangle<int> getTitleBarArea(); | |||||
| #endif | #endif | ||||
| private: | private: | ||||
| @@ -175,12 +175,12 @@ void ResizableWindow::setContentComponentSize (int width, int height) | |||||
| height + border.getTopAndBottom()); | height + border.getTopAndBottom()); | ||||
| } | } | ||||
| const BorderSize<int> ResizableWindow::getBorderThickness() | |||||
| BorderSize<int> ResizableWindow::getBorderThickness() | |||||
| { | { | ||||
| return BorderSize<int> (isUsingNativeTitleBar() ? 0 : ((resizableBorder != nullptr && ! isFullScreen()) ? 5 : 3)); | return BorderSize<int> (isUsingNativeTitleBar() ? 0 : ((resizableBorder != nullptr && ! isFullScreen()) ? 5 : 3)); | ||||
| } | } | ||||
| const BorderSize<int> ResizableWindow::getContentComponentBorder() | |||||
| BorderSize<int> ResizableWindow::getContentComponentBorder() | |||||
| { | { | ||||
| return getBorderThickness(); | return getBorderThickness(); | ||||
| } | } | ||||
| @@ -292,12 +292,12 @@ public: | |||||
| /** Returns the width of the frame to use around the window. | /** Returns the width of the frame to use around the window. | ||||
| @see getContentComponentBorder | @see getContentComponentBorder | ||||
| */ | */ | ||||
| virtual const BorderSize<int> getBorderThickness(); | |||||
| virtual BorderSize<int> getBorderThickness(); | |||||
| /** Returns the insets to use when positioning the content component. | /** Returns the insets to use when positioning the content component. | ||||
| @see getBorderThickness | @see getBorderThickness | ||||
| */ | */ | ||||
| virtual const BorderSize<int> getContentComponentBorder(); | |||||
| virtual BorderSize<int> getContentComponentBorder(); | |||||
| //============================================================================== | //============================================================================== | ||||
| /** A set of colour IDs to use to change the colour of various aspects of the window. | /** A set of colour IDs to use to change the colour of various aspects of the window. | ||||