No setScreenBounds()


#1

Hi, I’d have thought there’d have been a setScreenBounds() to go with getScreenBounds() if we’re wanting to just work in raw screen coordinates rather than being concerned with transforms that have been applied?

Am I missing something?

thx


#2

Nothing works in raw screen coordinates - getScreenBounds is really just a convenience function for quickly converting its bounds to screen coords. Look at its implementation:

Rectangle<int> Component::getScreenBounds() const     { return localAreaToGlobal (getLocalBounds()); }

And it doesn’t really work the other way round. Think about it: if you have a comp that’s nested inside e.g. several transformed parents, it could be rotated and skewed, so if you asked for its screen rectangle to be set to a given target, it can’t actually achieve that, so how would it decide what to change it to?


#3

yeah, which was what I was thinking last night was is there any way to work out the applied transform to a nested component :slight_smile:


#4

Yes, there is. But there are multiple combinations of bounds + transform that would give the same end-result. So if you just have a target area that you want to be the end result, it’s impossible to know whether it should get there by only adjusting the transform to achieve that, or to only change the bounds, or to use some combination of changes to both.


#5

got ya. i’m only dealing with a fairly simple scenario of a few nested scalings so should be able to do the calcs. thx