Hi there,
I want to place a widget, let’s say using AddChild(createWidget(…)), but I want to have it added at an arbitrary rotation.
Is this possible?
I do not want to animate it afterwards (though it would be cool), just want it to be rotated on the panel.
If there’s a way, a simple example would be awesome.
Thanks,
Marcelo.
Vortico
(VCV - Andrew)
November 3, 2019, 8:05pm
2
Just pass your vector position to createWidget()
. If you want rotations, put your widget inside a TransformWidget
.
Hmmm… I am missing some point here … Not sure yet how to “put the widget inside a TransformWidget”.
Still trying to wrap my head around it. Do you have any hints?
Vortico
(VCV - Andrew)
November 4, 2019, 1:27am
4
Widgets live in a hierarchical scene graph.
TransformWidget* tw = new TransformWidget;
tw->addChild(myWidget);
tw->rotate(2 * M_PI / 8);
addChild(tw);
AH! got it…
I understand now. Thanks man!
Just to be sure: The rotation happens around the upper left corner of the widget, not its center, right?
Vortico
(VCV - Andrew)
November 4, 2019, 2:35am
7
I think so. Since rotations are just linear transformations, you can rotate around any origin with
tw->translate(offset.neg());
tw->rotate(theta);
tw->translate(offset);
Yup … that’s my plan … I will test and verify what’s the actual origin and then apply modifications as needed … thanks man.