[Closed/Unconstructive] setPosition does not work

For help with general CEGUI usage:
- Questions about the usage of CEGUI and its features, if not explained in the documentation.
- Problems with the CMAKE configuration or problems occuring during the build process/compilation.
- Errors or unexpected behaviour.

Moderators: CEGUI MVP, CEGUI Team

codeMonkey
Not too shy to talk
Not too shy to talk
Posts: 21
Joined: Tue Aug 12, 2014 06:10

[Closed/Unconstructive] setPosition does not work

Postby codeMonkey » Tue Aug 12, 2014 06:26

hello everyone , today i write my first cegui program,but in my program the function "setPostion" seem to be not in effect,here is my code:

Code: Select all

using namespace CEGUI;
   SchemeManager::getSingleton().createFromFile("TaharezLook.scheme");
   System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage("TaharezLook/MouseArrow");
   WindowManager& winMgr = WindowManager::getSingleton();
   DefaultWindow* d_root = (DefaultWindow*)winMgr.createWindow("DefaultWindow", "Root");
   Font& defaultFont = FontManager::getSingleton().createFromFile("DejaVuSans-10.font");
   System::getSingleton().getDefaultGUIContext().setDefaultFont(&defaultFont);
   System::getSingleton().getDefaultGUIContext().setRootWindow(d_root);
   FrameWindow* wnd = (FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "DemoWindow");
   d_root->addChild(wnd);
   wnd->setPosition(UVector2(cegui_reldim(0.25f),cegui_reldim(0.25f)));
   wnd->setSize(USize(cegui_reldim(0.5f), cegui_reldim( 0.5f)));
   wnd->setMaxSize(USize(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
   wnd->setMinSize(USize(cegui_reldim(0.1f), cegui_reldim( 0.1f)));
   wnd->setText("Hello World!");

I want to render in the center,but it is on the top-left corner of the display,who can tell why?

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: setPosition does not work

Postby Ident » Tue Aug 12, 2014 06:40

CrazyEddie: "I don't like GUIs"

codeMonkey
Not too shy to talk
Not too shy to talk
Posts: 21
Joined: Tue Aug 12, 2014 06:10

Re: setPosition does not work

Postby codeMonkey » Tue Aug 12, 2014 06:54

Ident wrote:http://static.cegui.org.uk/docs/0.8.4/classCEGUI_1_1Element.html#a583c97a5d79e2189538705ef532cf5a6

can you tell how to set the setHorizontalAlignment ? parent window or child window or others?

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: setPosition does not work

Postby Ident » Tue Aug 12, 2014 07:01

The window you want to align. So the "child window" as you refer to it.

I recommend you to download CEED and play with a layout in order to learn how positioning works.
CrazyEddie: "I don't like GUIs"

codeMonkey
Not too shy to talk
Not too shy to talk
Posts: 21
Joined: Tue Aug 12, 2014 06:10

Re: setPosition does not work

Postby codeMonkey » Tue Aug 12, 2014 07:12

Code: Select all

wnd->setHorizontalAlignment(HA_CENTRE);

it seems to be not in effect

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: setPosition does not work

Postby Ident » Tue Aug 12, 2014 07:42

There is no question about this function having an effect. It definitely does.

I can't help you because you do not give us enough information.
CrazyEddie: "I don't like GUIs"

codeMonkey
Not too shy to talk
Not too shy to talk
Posts: 21
Joined: Tue Aug 12, 2014 06:10

Re: setPosition does not work

Postby codeMonkey » Tue Aug 12, 2014 07:55

Code: Select all

FrameWindow* wnd = (FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "DemoWindow");
   d_root->addChild(wnd);
   wnd->setHorizontalAlignment(HA_LEFT);
   wnd->setVerticalAlignment(VA_TOP);
   wnd->setPosition(UVector2(cegui_reldim(0.25f),cegui_reldim(0.25f)));
   wnd->setSize(USize(cegui_reldim(0.5f), cegui_reldim( 0.5f)));
   wnd->setMaxSize(USize(cegui_reldim(1.0f), cegui_reldim( 1.0f)));
   wnd->setMinSize(USize(cegui_reldim(0.1f), cegui_reldim( 0.1f)));
   wnd->setText("Hello World!");

I write like this ,but the window deos not change, I don't where i am wrong

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: setPosition does not work

Postby Ident » Tue Aug 12, 2014 08:17

And you tried HA_CENTRE instead of HA_LEFT?

Well, looking at the code the position would be at 1/4th of the width and the size is half of the width. So the window will be centered if you got HA_LEFT chosen wont it?
CrazyEddie: "I don't like GUIs"

codeMonkey
Not too shy to talk
Not too shy to talk
Posts: 21
Joined: Tue Aug 12, 2014 06:10

Re: setPosition does not work

Postby codeMonkey » Tue Aug 12, 2014 08:23

I did , still not in effect, wnd is still on the top-left corner of the display

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: setPosition does not work

Postby Ident » Tue Aug 12, 2014 08:24

Thats impossible because the position set to neither the very left nor the very top. Screenshot and CEGUI log please.
CrazyEddie: "I don't like GUIs"

codeMonkey
Not too shy to talk
Not too shy to talk
Posts: 21
Joined: Tue Aug 12, 2014 06:10

Re: setPosition does not work

Postby codeMonkey » Tue Aug 12, 2014 08:34

I don't know how to upload the image ,so I give you a network disk link http://pan.baidu.com/s/1gdgRk23

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: setPosition does not work

Postby Ident » Tue Aug 12, 2014 08:44

What happens if you set the position to

Code: Select all

   wnd->setPosition(UVector2(cegui_reldim(0.0f),cegui_reldim(0.0f)));

and also what happens if you set it to

Code: Select all

wnd->setPosition(UVector2(cegui_reldim(1.0f),cegui_reldim(1.0f)));
CrazyEddie: "I don't like GUIs"

codeMonkey
Not too shy to talk
Not too shy to talk
Posts: 21
Joined: Tue Aug 12, 2014 06:10

Re: setPosition does not work

Postby codeMonkey » Tue Aug 12, 2014 09:03

still on the corner ,all the code I referenced hand not set the aligment, but there window seemed to be on the center

User avatar
Ident
CEGUI Team
Posts: 1998
Joined: Sat Oct 31, 2009 13:57
Location: Austria

Re: setPosition does not work

Postby Ident » Tue Aug 12, 2014 09:18

I dont understand what you are saying.

Did you even recompile your project after making changes to your code?
CrazyEddie: "I don't like GUIs"

codeMonkey
Not too shy to talk
Not too shy to talk
Posts: 21
Joined: Tue Aug 12, 2014 06:10

Re: setPosition does not work

Postby codeMonkey » Tue Aug 12, 2014 10:03

sorry , my english is pool , I mean to say that my window is still in the corner , did not change


Return to “Help”

Who is online

Users browsing this forum: No registered users and 5 guests