Browse Source

Take any transforms that have been applied to a component into account in the Component::centreWithSize, ::setCentreRelative() and ::setCentrePosition() methods

tags/2021-05-28
ed 7 years ago
parent
commit
a9b74e54c7
1 changed files with 3 additions and 2 deletions
  1. +3
    -2
      modules/juce_gui_basics/components/juce_Component.cpp

+ 3
- 2
modules/juce_gui_basics/components/juce_Component.cpp View File

@@ -1257,7 +1257,7 @@ void Component::setBoundsRelative (const float x, const float y,
roundToInt (h * ph));
}
void Component::setCentrePosition (Point<int> p) { setBounds (getBounds().withCentre (p)); }
void Component::setCentrePosition (Point<int> p) { setBounds (getBounds().withCentre (p.transformedBy (getTransform().inverted()))); }
void Component::setCentrePosition (int x, int y) { setCentrePosition ({x, y}); }
void Component::setCentreRelative (float x, float y)
@@ -1268,7 +1268,8 @@ void Component::setCentreRelative (float x, float y)
void Component::centreWithSize (const int width, const int height)
{
auto parentArea = ComponentHelpers::getParentOrMainMonitorBounds (*this);
auto parentArea = ComponentHelpers::getParentOrMainMonitorBounds (*this)
.transformedBy (getTransform().inverted());
setBounds (parentArea.getCentreX() - width / 2,
parentArea.getCentreY() - height / 2,


Loading…
Cancel
Save