static void setVerticalRotatedWithBounds(Component * component,
bool clockWiseRotation,
Rectangle<int> verticalBounds)
{
auto angle = float_Pi / 2.0f;
if (! clockWiseRotation)
angle *= -1.0f;
component->setSize(verticalBounds.getHeight(), verticalBounds.getWidth()); // this line is a bit ugly... and could just look like a typo (it's not, honest)
component->setCentrePosition(0, 0);
component->setTransform(AffineTransform::rotation(angle)
.translated(verticalBounds.getCentreX(), verticalBounds.getCentreY()));
}
It’s not really much of a saving on what you have but maybe a good compromise. The setSize line isn’t very nice and only works as you’ve specified PI/2. You could do it all ‘properly’ by translating to zero then doing a
Oh yeah - I figured I was making a bit of a meal of that translationX/Y stuff ;_) Should have drawn a diagram… and no doubt it’d have been more obvious.
Sorry for bumping a super old thread, but this function should actually be as follows. As it is posted it will only work once, the second time you call it, the component will be in the wrong place.