I'm trying to attach a static image that has already been defined in the layout file to a drag container, with the container being defined in code. The problem is that although the static image should be relative to the container but do not work out as expected, it has been created to the correct size of the image and the image having dimensions of 0,0,1,1. Here's the code:
Code: Select all
CEGUI::WindowManager *mWinMgr = CEGUI::WindowManager::getSingletonPtr();
// Set up drag container
CEGUI::DragContainer* mDC =
(CEGUI::DragContainer*)mWinMgr->createWindow(
"DragContainer", "RegimentScreen/SoldierFireTeamDragCtr1");
mDC->setWindowPosition(CEGUI::UVector2(CEGUI::cegui_reldim(0.230f), CEGUI::cegui_reldim(0.664f)));
mDC->setWindowSize(CEGUI::UVector2(CEGUI::cegui_reldim(0.030f), CEGUI::cegui_reldim(0.026f)));
// Set up the contained static image
CEGUI::StaticImage* mSI =
(CEGUI::StaticImage*)mWinMgr->getWindow("RegimentScreen/SoldierFireTeamSel1");
mDC->addChildWindow(mSI);
mSI->setWindowPosition(CEGUI::UVector2(CEGUI::cegui_reldim(0.0f), CEGUI::cegui_reldim(0.0f)));
mSI->setWindowSize(CEGUI::UVector2(CEGUI::cegui_reldim(1.0f), CEGUI::cegui_reldim(1.0f)));
CEGUI::Rect mSIPos = mSI->getRect(CEGUI::Absolute);
CEGUI::Rect mSIPosRel = mSI->getRect(CEGUI::Relative);
CEGUI::Rect mDCPos = mDC->getRect(CEGUI::Absolute);
CEGUI::Rect mDCPosRel = mDC->getRect(CEGUI::Relative);
The last four lines are me testing the relative and absolute positions of both the drag container (mDC) and the image (mSI). These are the results ( in format Left,Top,Right,Bottom ):
Static image: Absolute ( 0, 0, 20, 31) Relative (0,0,1,1)
Container: Absolute (510,236,530,267) Relative (0.664,0.230,0.690,0.253)
As you can see, the container is in the right place, and although the relative coords of 0,0,1,1 should place the image in the right place, it seems to be taking the top left corner of the screen as the position to derive it's coords from. Can anyone see anything wrong with how I'm lining up the image?