Is setTransform the right tool for Zoom and Scroll?

I have a graph (ala Max/Pd) that is a bunch of Component all childs of the same Component.
I want to allow the user to Zoom In/Out and Scroll freely the content.
Is the best approach is to use an AffineTransform / setTransform for each of the component?
Is there another obvious approach i didn’t think of?
What are the pitfalls?

It seems that my first attempt to have just one main component transformed was the proper way.
Don’t know why it failed. :thinking:

Ok with one more level of indirection it doesn’t solve my problem.
Hence it seems i really need to apply an affine transform onto all the child objects?
Is there an handy setTransformForAllChilds feature?

I can’t think of a reason why applying a transform on the parent-component shouldn’t work.

1 Like

But it doesn’t! There’s probably something i understand wrongly. :laughing:
Is the transform only change the bounds of the component (or anything rendered in it also)?
I clearly didn’t grasp what the affine transform is supposed to do in that case…

After few test (with one more indirection) it appears that the affine is applied to the result.
Notice that it was not very clear for me at first. I’m probably dumb.
I should have a look onto juce::Viewport to see how it is done.

Identity:

view_.setTransform (juce::AffineTransform::scale (2.0f));

view_.setTransform (juce::AffineTransform::translation (50, 50));

For future readers :

1/ I added an arbitrary constant offset to avoid negative values.
2/ AFAIK, using a global affine is not possible in order to get a neat (unblurry) result.