Search code examples
apache-flexlayout

Force containers to do layout after children are rotated?


My problem is pretty simple: Flex containers do layout based on un-transformed children, and so rotated children are positioned as if there were no rotation, but then they're rotated around the top-left of that position. I've attached an image to show what I mean.

Does anybody know how to get around this? Can I wrap the components in something? Or do I have to resort to custom components or fixed layouts?


Solution

  • If the containers doesn't handle rotational transformations in the layout code then unfortunately you're stuck with adding this functionality yourself. To add insult to injury, Flex 3 and below doesn't really seperate layout and logic very well so you usually end up with components that solve a very specific problem which might have been better solved with a seperate layout class implementing a layouting interface. These components can grow big pretty quickly and generally also makes component design brittle in that there's too much subclassing going on.

    This issue has been adressed in Flex 4 (to be released) but I can't really vouch for it. In theory it's a good idea, but in practice I haven't had time to go in depth with Adobe's implementation of that design.

    To make a long story short: you're probably screwed and have to implement this functionality yourself. Fortunately it's usually pretty easy to hack it in. Unfortunately it's usually pretty difficult to implement a nice non-brittle solution since it more often than not requires the use of subclassing and intimate knowledge of the super class internals, something which may or may not require monkey patching.