Widget rotation


17-04-2009 17:55:27

Hello everybody,

I'd like to implement rotation to MyGUI widgets, and as I'm new to MyGUI, I'm wondering if you could give me some advice so I can do the right thing from the beginning :D

I already adapted an opengl gui recently and those were the changes required:
1. Stored rotation on each widget
2. When rendering, applied 2d rotation to x and y and used glRotate
3. For mouse picking, used the rotated x and y for the intersects and rotated the mouse coordinates on the container widgets for the children component picking tests.
4. For clipping, switched from scissoring to stencil patterns to support irregular shapes - could also have used render to texture.

Any suggestion will be much appreciated. :wink:
Thanks a bunch!


17-04-2009 19:13:03

All MyGUI widgets is made through SubWidgets. SubWIdget with texture is MyGUI::SubSkin class. It have all stuff with vertex buffers.
Mainly in SubSkin::_drawItem , void SubSkin::_updateView and in SubSkin::_setUVSet. For picking you should make bool _checkPoint(int _left, int _top) virtual function and reimplement it in your class. So what you should do: copy this class and change it's geometry.
But there's one problem that can't be solved fast - cropping by parent: with rectangular widgets we just changing UV and verticies, but if rotated widget is cropped it's not rectangular any more. So I suggest to ignore cropping for now, so you should ignore all margins. After finishing first working prototype you can start working with cropping.


17-04-2009 19:24:38

So to add new SubWidget type you need:
1) create new class with inherited from ISubWidgetRect with code mainly copy-pasted from SubSkin;
2) add new factory to SubWidgetManager (one line in header and three lines in cpp);
To test it you choud create skin with your new SubWidget type: look at RawRect as example skin (in core_skin.xml) and Demo_ColourRect as example how this custom SubWidget used (in ColourPanel.cpp find mRawColourView).


17-04-2009 23:38:41

Hi Altren,

Thank you so much for your help.
I'll try to work on it on the weekend.

Congrats for the GUI, very nice stuff!


22-04-2009 02:04:11

Do you have any progress with it?


24-04-2009 09:16:15


I didn't have much time, so I decided to go with Qt for now as it already supports this kind of stuff. :roll: