Ok, not a bug, although I also got confused for a moment. But this is just a misunderstanding on what the alignment is meant to do. Alignment is not a way to change the position of an element, but to define the behavior when the parent is resized.
And it does that already correctly:
Code: Select all
#include <irrlicht.h>
#include <iostream>
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
#ifdef _IRR_WINDOWS_
#pragma comment(lib, "Irrlicht.lib")
#endif
int main()
{
video::E_DRIVER_TYPE driverType = video::EDT_OPENGL;
IrrlichtDevice * device = createDevice(driverType, core::dimension2d<u32>(640, 480));
if (device == 0)
return 1; // could not create selected driver.
video::IVideoDriver* driver = device->getVideoDriver();
IGUIEnvironment* env = device->getGUIEnvironment();
IGUIElement *p = env->addStaticText( L"", irr::core::rect<s32>(0,0,50,50), true );
IGUIElement *e = env->addStaticText( L"Hello world!", irr::core::rect<s32>(0,0,50,50), true, true, p );
e->setAlignment( irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER, irr::gui::EGUIA_CENTER);
p->setRelativePosition( irr::core::rect<s32>(0,0,400,400) );
while(device->run() && driver)
{
if (device->isWindowActive())
{
driver->beginScene(true, true, SColor(0,200,200,200));
env->drawAll();
driver->endScene();
}
}
device->drop();
return 0;
}
That's also why updateAbsolutePosition is not needed there. Because just setting a new alignment won't affect the current positions and also should not do so.
edit: But I just noticed it has no documentation whatsoever. Which is certainly something which must be changed.