Gui Coordinates ....

Return to Scripting Issues

Gui Coordinates ....

Postby Manakel » Wed Jun 29, 2005 5:57 am

Hello All ,

I'm figthing with GUI stuff actually. all my components (Entry, label....) are set into one DirectFrame. However i'm lost when trying to position this components on the frame. What i would like to do is an handy function:

user tells coordinate of the components inside Directframe on a 0-1 scale (0,0,0 to 1,1,1 or 0,0 to 1,1) (like a screen coordinate)
and the function convert this coordinates in real coordinates in DirectFrame coordinates system.

Before working on it , i would like to know if it exists somewhere in panda?

(i'm asking before i often discovered good idea are already implemented in panda ...)
Bold words are keyword to help you decide quickly if this post interest you or not....
(you should be able to understand the post by reading only bold words :-))
User avatar
Manakel
 
Posts: 318
Joined: Fri Jan 21, 2005 2:25 pm
Location: France

Postby drwr » Wed Jun 29, 2005 7:32 am

Do you mean convert screen-relative coordinates into frame-relative coordinates? That's easily answered using Panda's relative scene graph operations.
Code: Select all
framePos = frame.getRelativePoint(render2d, screenPos)

Note that screen coordinates, by convention, range from (-1, -1) to (1, 1).

But I can do you one better. When you are laying out your DirectGui elements, put the following in your Config.pp file:
Code: Select all
direct-gui-edit 1

With this in effect, you can drag your gui elements around onscreen with the middle mouse button. If you hold down the control key and the middle mouse button together, you can also rescale them. When you get your gui elements positioned where you want them, break into your Python process and print out their position and scale, e.g.:
Code: Select all
print myButton.getTransform()

and then hard-code those numbers into your program.

David
drwr
 
Posts: 11286
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA

Postby Manakel » Wed Jun 29, 2005 1:15 pm

Man asked a question, God provided a miracle ....
Bold words are keyword to help you decide quickly if this post interest you or not....
(you should be able to understand the post by reading only bold words :-))
User avatar
Manakel
 
Posts: 318
Joined: Fri Jan 21, 2005 2:25 pm
Location: France

Postby Ogel » Fri Sep 30, 2005 4:09 pm

I'm afraid I haven't been able to get the direct-edit functionality to work. I placed the 'direct-gui-edit' line in my Config.prc and made sure 'enableEdit' was set to 1 on my gui objects.

(I wasn't sure if the line was actually intended for Config.pp. I'm currently using the pre-packaged Panda and couldn't find it there. I did find Config.pp under '/dtools' in my full-source version, but I was hoping not to rebuild Panda just to activate this feature.)

The game loads fine, but I'm unable to move or resize things with the middle mouse button. Do anyone know what I might be doing wrong? Thanks.

-Ogel
Ogel
 
Posts: 19
Joined: Fri Jul 29, 2005 5:14 pm

Postby drwr » Fri Sep 30, 2005 4:30 pm

You might want to check to make sure that you are editing the correct Config.prc file. Maybe the game is loading a different one.

You can run this command:
Code: Select all
print cpMgr

to list all of the Config.prc files that are loaded. You can also type this:
Code: Select all
print ConfigVariableBool('direct-gui-edit')

to confirm that the variable is, indeed, being set to true.

David
drwr
 
Posts: 11286
Joined: Fri Feb 13, 2004 12:42 pm
Location: Glendale, CA


Return to Scripting Issues

Who is online

Users browsing this forum: No registered users and 0 guests