Centering Widgets

pierceblaylock

18-08-2008 05:43:31

I'm trying to find a way to keep a widget centered on the screen. Similar problem as described in this thread.

http://www.ogre3d.org/phpBB2addons/viewtopic.php?t=7290

I'm not sure if this problem has been solved yet, but I was wondering if it could be solved with two additional anchor options. I would look into adding it myself, but I'm just too new to Ogre and QuickGUI to go down that path just yet.

Basically you could add two new anchoring types called ANCHOR_HORIZONTAL_CENTER and ANCHOR_VERTICAL_CENTER. These would work by ensuring that the widget always stays centered.

For example, ANCHOR_HORIZONTAL_CENTER would set the position of the widget to half the viewport width minus half the widget width. This would then need to be updated whenever the viewport size or widget size changes.

kungfoomasta

18-08-2008 16:06:43

Basically you could add two new anchoring types called ANCHOR_HORIZONTAL_CENTER and ANCHOR_VERTICAL_CENTER. These would work by ensuring that the widget always stays centered.

I have no idea why I never thought of this, that is a really great suggestion! :D. Easy to add, I will throw this in tonight.

kungfoomasta

18-08-2008 19:19:15

I was thinking about anchoring and how it allows for relative positioning, or growing/shrinking. The 2 new anchors do not say whether they will grow/shrink the widget relative to parent dimensions, so I think I'll need to cover these cases, since they're easy to add.

ANCHOR_VERTICAL_CENTER_DYNAMIC
ANCHOR_VERTICAL_CENTER

ANCHOR_HORIZONTAL_CENTER_DYNAMIC
ANCHOR_HORIZONTAL_CENTER

The 'DYNAMIC' ones imply growing and shrinking while also being centered. The non dynamic ones will not grow or shrink, but remain centered.

kungfoomasta

20-08-2008 01:21:37

Alright its added into the code base and will be there in the release. :)