Set GUI alignment to center

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
aeronmike
Posts: 45
Joined: Thu May 24, 2012 5:00 am
Location: Rio de Janeiro, Brazil

Set GUI alignment to center

Post by aeronmike »

Hey

My app creates a window and a child button.

I want to center the window according to the resolution AND the child button centered according to the window resolution.

How would I do that?
Is that any function within Irrlicht that let me do such thing?

Thanks.
CuteAlien
Admin
Posts: 9734
Joined: Mon Mar 06, 2006 2:25 pm
Location: Tübingen, Germany
Contact:

Re: Set GUI alignment to center

Post by CuteAlien »

You can make sure that gui-elements are aligned when their parents are resized with the setAlignment function.
So you can create the gui in one resolution and for example set a gui-element with that size as parent which does draw nothing (for example a IGUIWindow without titlebar and removed buttons or a IGUIStaticText without border and text). Now when you resize that parent it's childs will all align correctly - for example to the center.

You can not center the application window itself, at least not with Irrlicht functions. You can use platform API functions for that.
IRC: #irrlicht on irc.libera.chat
Code snippet repository: https://github.com/mzeilfelder/irr-playground-micha
Free racer made with Irrlicht: http://www.irrgheist.com/hcraftsource.htm
aeronmike
Posts: 45
Joined: Thu May 24, 2012 5:00 am
Location: Rio de Janeiro, Brazil

Re: Set GUI alignment to center

Post by aeronmike »

Thanks.
My app has a fixed resolution, so I just had to calculate the positioning of the Irrlitch window against the internal resolution.
Simple math. That worked. :)
Post Reply