CEGUI 0.6.2 v 0.7.5: Frame/Button Padding and Mouseover
Posted: 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:
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?
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?