Browse Source

Renamed bounds member variable in Component to "boundsRelativeToParent" to avoid shadowing warnings when using a local variable nambed "bounds"

tags/2021-05-28
hogliux 9 years ago
parent
commit
75ea6db250
3 changed files with 18 additions and 18 deletions
  1. +8
    -8
      modules/juce_gui_basics/components/juce_Component.cpp
  2. +9
    -9
      modules/juce_gui_basics/components/juce_Component.h
  3. +1
    -1
      modules/juce_gui_basics/windows/juce_ComponentPeer.cpp

+ 8
- 8
modules/juce_gui_basics/components/juce_Component.cpp View File

@@ -409,7 +409,7 @@ struct Component::ComponentHelpers
if (child.isVisible() && ! child.isTransformed()) if (child.isVisible() && ! child.isTransformed())
{ {
const Rectangle<int> newClip (clipRect.getIntersection (child.bounds));
const Rectangle<int> newClip (clipRect.getIntersection (child.boundsRelativeToParent));
if (! newClip.isEmpty()) if (! newClip.isEmpty())
{ {
@@ -665,7 +665,7 @@ void Component::addToDesktop (int styleWanted, void* nativeWindowToAttachTo)
Desktop::getInstance().addDesktopComponent (this); Desktop::getInstance().addDesktopComponent (this);
bounds.setPosition (topLeft);
boundsRelativeToParent.setPosition (topLeft);
peer->updateBounds(); peer->updateBounds();
if (oldRenderingEngine >= 0) if (oldRenderingEngine >= 0)
@@ -1031,8 +1031,8 @@ bool Component::isAlwaysOnTop() const noexcept
} }
//============================================================================== //==============================================================================
int Component::proportionOfWidth (const float proportion) const noexcept { return roundToInt (proportion * bounds.getWidth()); }
int Component::proportionOfHeight (const float proportion) const noexcept { return roundToInt (proportion * bounds.getHeight()); }
int Component::proportionOfWidth (const float proportion) const noexcept { return roundToInt (proportion * boundsRelativeToParent.getWidth()); }
int Component::proportionOfHeight (const float proportion) const noexcept { return roundToInt (proportion * boundsRelativeToParent.getHeight()); }
int Component::getParentWidth() const noexcept int Component::getParentWidth() const noexcept
{ {
@@ -1135,7 +1135,7 @@ void Component::setBounds (const int x, const int y, int w, int h)
repaintParent(); repaintParent();
} }
bounds.setBounds (x, y, w, h);
boundsRelativeToParent.setBounds (x, y, w, h);
if (showing) if (showing)
{ {
@@ -2249,13 +2249,13 @@ void Component::setPositioner (Positioner* newPositioner)
//============================================================================== //==============================================================================
Rectangle<int> Component::getLocalBounds() const noexcept Rectangle<int> Component::getLocalBounds() const noexcept
{ {
return bounds.withZeroOrigin();
return boundsRelativeToParent.withZeroOrigin();
} }
Rectangle<int> Component::getBoundsInParent() const noexcept Rectangle<int> Component::getBoundsInParent() const noexcept
{ {
return affineTransform == nullptr ? bounds
: bounds.transformedBy (*affineTransform);
return affineTransform == nullptr ? boundsRelativeToParent
: boundsRelativeToParent.transformedBy (*affineTransform);
} }
//============================================================================== //==============================================================================


+ 9
- 9
modules/juce_gui_basics/components/juce_Component.h View File

@@ -253,7 +253,7 @@ public:
bounds will no longer be a direct reflection of the position at which it appears within bounds will no longer be a direct reflection of the position at which it appears within
its parent, as the transform will be applied to its bounding box. its parent, as the transform will be applied to its bounding box.
*/ */
int getX() const noexcept { return bounds.getX(); }
int getX() const noexcept { return boundsRelativeToParent.getX(); }
/** Returns the y coordinate of the top of this component. /** Returns the y coordinate of the top 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.
@@ -262,13 +262,13 @@ public:
bounds will no longer be a direct reflection of the position at which it appears within bounds will no longer be a direct reflection of the position at which it appears within
its parent, as the transform will be applied to its bounding box. its parent, as the transform will be applied to its bounding box.
*/ */
int getY() const noexcept { return bounds.getY(); }
int getY() const noexcept { return boundsRelativeToParent.getY(); }
/** Returns the component's width in pixels. */ /** Returns the component's width in pixels. */
int getWidth() const noexcept { return bounds.getWidth(); }
int getWidth() const noexcept { return boundsRelativeToParent.getWidth(); }
/** Returns the component's height in pixels. */ /** Returns the component's height in pixels. */
int getHeight() const noexcept { return bounds.getHeight(); }
int getHeight() const noexcept { return boundsRelativeToParent.getHeight(); }
/** Returns the x coordinate of the component's right-hand edge. /** Returns the x coordinate of the component's right-hand edge.
This is a distance in pixels from the left edge of the component's parent. This is a distance in pixels from the left edge of the component's parent.
@@ -277,10 +277,10 @@ public:
bounds will no longer be a direct reflection of the position at which it appears within bounds will no longer be a direct reflection of the position at which it appears within
its parent, as the transform will be applied to its bounding box. its parent, as the transform will be applied to its bounding box.
*/ */
int getRight() const noexcept { return bounds.getRight(); }
int getRight() const noexcept { return boundsRelativeToParent.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(); }
Point<int> getPosition() const noexcept { return boundsRelativeToParent.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.
@@ -289,7 +289,7 @@ public:
bounds will no longer be a direct reflection of the position at which it appears within bounds will no longer be a direct reflection of the position at which it appears within
its parent, as the transform will be applied to its bounding box. its parent, as the transform will be applied to its bounding box.
*/ */
int getBottom() const noexcept { return bounds.getBottom(); }
int getBottom() const noexcept { return boundsRelativeToParent.getBottom(); }
/** Returns this component's bounding box. /** Returns this component's bounding box.
The rectangle returned is relative to the top-left of the component's parent. The rectangle returned is relative to the top-left of the component's parent.
@@ -298,7 +298,7 @@ public:
bounds will no longer be a direct reflection of the position at which it appears within bounds will no longer be a direct reflection of the position at which it appears within
its parent, as the transform will be applied to its bounding box. its parent, as the transform will be applied to its bounding box.
*/ */
const Rectangle<int>& getBounds() const noexcept { return bounds; }
const Rectangle<int>& getBounds() const noexcept { return boundsRelativeToParent; }
/** Returns the component's bounds, relative to its own origin. /** Returns the component's bounds, relative to its own origin.
This is like getBounds(), but returns the rectangle in local coordinates, In practice, it'll This is like getBounds(), but returns the rectangle in local coordinates, In practice, it'll
@@ -2244,7 +2244,7 @@ private:
//============================================================================== //==============================================================================
String componentName, componentID; String componentName, componentID;
Component* parentComponent; Component* parentComponent;
Rectangle<int> bounds;
Rectangle<int> boundsRelativeToParent;
ScopedPointer<Positioner> positioner; ScopedPointer<Positioner> positioner;
ScopedPointer<AffineTransform> affineTransform; ScopedPointer<AffineTransform> affineTransform;
Array<Component*> childComponentList; Array<Component*> childComponentList;


+ 1
- 1
modules/juce_gui_basics/windows/juce_ComponentPeer.cpp View File

@@ -320,7 +320,7 @@ void ComponentPeer::handleMovedOrResized()
if (wasMoved || wasResized) if (wasMoved || wasResized)
{ {
component.bounds = newBounds;
component.boundsRelativeToParent = newBounds;
if (wasResized) if (wasResized)
component.repaint(); component.repaint();


Loading…
Cancel
Save