Coordinates getting messed with drag container

For help with anything that CEGUI doesn't offer straight out-of-the-box, e.g.:
- Implementation of new features, such as new Core classes, widgets, WindowRenderers, etc. ...
- Modification of any existing features for specific purposes
- Integration of CEGUI in new engines or frameworks and writing of new plugins (Renderer, Parser, ...) or modules

Moderators: CEGUI MVP, CEGUI Team

User avatar
Tyn
Just popping in
Just popping in
Posts: 9
Joined: Thu Feb 17, 2005 20:27
Contact:

Coordinates getting messed with drag container

Postby Tyn » Tue Nov 22, 2005 16:40

Hey all

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?

User avatar
martignasse
Just can't stay away
Just can't stay away
Posts: 227
Joined: Thu Apr 14, 2005 08:10
Location: Lyon, FRANCE

Re: Coordinates getting messed with drag container

Postby martignasse » Tue Nov 22, 2005 19:06

Code: Select all

mDC->setWindowSize(CEGUI::UVector2(CEGUI::cegui_reldim(0.030f), CEGUI::cegui_reldim(0.026f)));
It's depend where you put you'r DragContainer but size like that could be very thin values... :roll:

other than that, please be more explicit about
The problem is that although the static image should be relative to the container but do not work out as expected

User avatar
Tyn
Just popping in
Just popping in
Posts: 9
Joined: Thu Feb 17, 2005 20:27
Contact:

Re: Coordinates getting messed with drag container

Postby Tyn » Tue Nov 22, 2005 19:21

Sure thing, what's happening is that the image that is a child of the drag container instead of aligning with the containers' top left hand corner, is aligning with the top left of the screen.

I don't think the fineness of the values are the problem, I'd expect this to be a problem when the values were less than one pixel but the display is 1024x768, I don't see a reason for there to be a problem.

User avatar
Tyn
Just popping in
Just popping in
Posts: 9
Joined: Thu Feb 17, 2005 20:27
Contact:

Re: Coordinates getting messed with drag container

Postby Tyn » Thu Nov 24, 2005 10:33

Solved now, thanks to CE on IRC. The problem was that the drag container wasn't a child of anything in the layout, adding this line fixed the problems:

Code: Select all

mWinMgr->getWindow("RegimentScreenWindow")->addChildWindow(mDC);

Cheers CE :pint:


Return to “Modifications / Integrations / Customisations”

Who is online

Users browsing this forum: No registered users and 7 guests