CVS head - how do I get window-rel mouse pos?

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

shalinor
Just popping in
Just popping in
Posts: 11
Joined: Fri Apr 14, 2006 23:57

CVS head - how do I get window-rel mouse pos?

Postby shalinor » Fri May 05, 2006 06:06

I've been fighting this for an hour, and it's getting me... irritated. All I want is relative coordinates, relative to the window - that is, 0.0 at left side, 1.0 at right side. Totally, 100% standard thing for a GUI, no?

It seems that you've totally removed window metrics, any Window methods that can convert between relative and absolute, AND made the mouse position ALWAYS return absolute? How is that sane?

I can't even get absolute width/height data on the window to convert the mouse pos into relative? The CoordConverter craps out (ie. returns NAN on precisely one out of the four values I need consistently - the lower right X coord if it matters) trying to convert window coords to screen when I set 1.0, 1.0 as the scale in the UVector (which is me trying to find the lower righthand corner in screen/absolute coords). Brilliant!


Surely I'm missing something?
Last edited by shalinor on Fri May 05, 2006 14:26, edited 1 time in total.

User avatar
vinny_the_true
Just popping in
Just popping in
Posts: 7
Joined: Wed Aug 10, 2005 10:11

Postby vinny_the_true » Fri May 05, 2006 08:16

Once you have the mouse absolute screen position, do some screenToWindow() Window method with that point, so you'll have the position relative to your window.

The result will be automatically in the Window Metrics mode. I used this method succesfully with param in absolute and windows either in absolute or relative metrics modes.

shalinor
Just popping in
Just popping in
Posts: 11
Joined: Fri Apr 14, 2006 23:57

Postby shalinor » Fri May 05, 2006 14:21

vinny_the_true wrote:Once you have the mouse absolute screen position, do some screenToWindow() Window method with that point, so you'll have the position relative to your window.

The result will be automatically in the Window Metrics mode. I used this method succesfully with param in absolute and windows either in absolute or relative metrics modes.


That's my problem. I can't see any setting for windows metric mode in CVS head. The window itself (CEGUI::Window) no longer has that method, and I can't find anything likely-looking in the properties for the Window either. Thus, the mouse cursor always returns absolute, as far as I can tell.

Furthermore, without a metrics mode settings to change it, the getWindowPosition/Size methods are always going to give me whatever I specified to them originally - which is, typically, scale, but at times I use offset instead. The only way to convert that 100% consistently to absolute appears to be UDim::asAbsolute(), but that requires a "base" value (screen size) which I may or may not have available - where is that data located in CEGUI?


I have a bit of a "hack" I can use, since this code can see my engine's renderer and get the width/height of the render window (which I can use as the base in UDim::asAbsolute()), but that won't always be the case. I need an entirely in-GUI way of doing it.


Return to “Help”

Who is online

Users browsing this forum: No registered users and 32 guests