CEGUI 0.6.2 v 0.7.5: Frame/Button Padding and Mouseover

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

Senzin
Just popping in
Just popping in
Posts: 8
Joined: Sat Apr 23, 2011 01:13

CEGUI 0.6.2 v 0.7.5: Frame/Button Padding and Mouseover

Postby Senzin » Sat Apr 23, 2011 21:21

I'm using Ogre with CEGUI and I'm developing with 0.7.5. But for various reasons, I also need my app to run on a machine with CEGUI 0.6.2. Initially this was easy, just a few minor changes in initialization. But I've ran into a couple snags.

The big problem:
In CEGUI 0.6.2, the position of a button in a frame is relative to the frame's true top left corner. For most frame's, especially those with title bars, putting a button at 0,0 would hide it behind the borders of the frame. So you have to move the button down and to the right until it is revealed. In 0.7.5, however, position 0,0 is at the top left corner of the visible area, meaning as up and to the left as the button can go before it starts getting clipped by the frame's borders. This is arguably a better method, but obviously creates a big compatibility problem between the two versions because layouts will look different.

So is there a way to compensate for this in code? Is there a method I can call to get the clipping area? Is there something I can do to the layout file to adjust for this?

The small problem:
In CEGUI 0.6.2, when you call injectMouseButtonDown, the returned bool tells you if your mouse was over a CEGUI widget at the time. The root did not count. So in the mouse listener, I could simply use this bool to determine if the user clicked on a CEGUI widget or on something in the Ogre scene. In 0.7.5, however, the root does seem to count, and so injectMouseButtonDown always returns true. The workaround I found was to call this immediately after injectMouseButtonDown:

Code: Select all

bool handledByCegui = CEGUI::System::getSingleton().getWindowContainingMouse()->getName() != "root";

That seems to work, but I wonder if that's really the best way to do this? Perhaps there is a more straight forward method?

User avatar
Kulik
CEGUI Team
Posts: 1382
Joined: Mon Jul 26, 2010 18:47
Location: Czech Republic
Contact:

Re: CEGUI 0.6.2 v 0.7.5: Frame/Button Padding and Mouseover

Postby Kulik » Sat Apr 23, 2011 21:36

The rect you are talking about can be retrieved via Window::getChildWindowContentArea

I definitely wouln't want to be in your spot, having to disable 0.7 improvements to get a consistent look in both CEGUI major versions.

As for the other problem, do you have MousePassThroughEnabled enabled on the root window?

Senzin
Just popping in
Just popping in
Posts: 8
Joined: Sat Apr 23, 2011 01:13

Re: CEGUI 0.6.2 v 0.7.5: Frame/Button Padding and Mouseover

Postby Senzin » Sun Apr 24, 2011 02:12

Thanks, Kulik! You were dead on with MousePassThrough. Seems in 0.6.2 it is enabled by default.

As for the bigger problem, 0.6.2 doesn't have getChildWindowContentArea. However, getUnclippedInnerRect exists in both versions and gives the same result as getChildWindowContentArea. So I tried using getUnclippedInnerRect, which works, but I've found that the two versions also have different clipping rects for the same window. In 0.7.5, the top left is at (7.5, 41.625). In 0.6.2 it's at (3.75, 45.375). I've tested this by putting a button at (-1, -1) and using those offsets, and sure enough, they really do clip the button at different positions.

So for now, I've simply made an offset vector:

Code: Select all

CEGUI::UVector2 offset = CEGUI::UVector2(CEGUI::UDim(0, 7.5), CEGUI::UDim(0, 41.625));

This way the layout I see when I run CEGUI 0.6.2 is the same as in CEGUI 0.7.5 and (very importantly) the same I see when making the layout in CELE2. Yes, in 0.6.2, I shortened the y offset from 45.375 to 41.625, but I'll never place a widget that close to the very top of a window, and I think it's more important they all look the same.

Since most widgets in a window will need to subscribe to an event, I have to get at those widgets in code at one point or another. So it's not a lot of effort to have one more line of code conditionally update their position, e.g.:

Code: Select all

CEGUI::Window* win;
win = myWindow->getChild("myWindow/myButton");
win->subscribeEvent(CEGUI::PushButton::EventClicked, CEGUI::Event::Subscriber(&IntermediateTutorial3::mode, this));
if (mLegacy) win->setPosition(win->getPosition() + offset);


Return to “Help”

Who is online

Users browsing this forum: No registered users and 6 guests