Very basic DirectGUI question - resolutions

Been away from coding for a while and looking to get my feet wet again.
Have an app that throws up a title “Screen” which is just a DirectFrame.

Worked fine before I switched to a new wide-screen monitor :smiley:

So my very simple question (which I think I should know the answer to but can’'t remember) - what’s the best way to create a DirectFrame that will fill the screen , no matter what resolution you’re set to?

my current code is basically:

		x = DirectFrame(image = base.GAME_STORY_GUI + text + ".png", 
			frameSize = (-1.33, 1.33, -1.0, 1.0), image_scale = (1.34, 0, 1) , parent = aspect2d)

Parent it to render2d instead of aspect2d, and set it to range from -1 to 1 in X.

Thanks, that fixed the resolution.

However, now the DirectButtons I had on the screen don’t seem to do anything.

They were being created with code like this:

xx = DirectButton(text = "Start Story", pos=(0,0,0), command = self.playGame, parent = self.scrTitle,
			relief = DGG.RAISED, text_font = base.GAME_FONT, text_scale = .04, text0_fg = (0,0,1,1), text1_fg = (1,0,0,1), 
			text2_fg = (1,1,0,1), text3_fg = (0,1,1,1))

I don’t see the button shape , just the text, on some buttons. And clicking any of them doesn’t do anything.
They are parented to the frame (“self.scrTitle” in the code above). Mayeb they’re somehow “behind” the frame? IS there something I need to do to force them in front?

Hmm, no, only aspect2d watches for mouse events by default. You can parent your frame to render2d but your buttons to a node under aspect2d.

I would suggest using pixel2d as the root of all gui elements. I imagine that sooner or later you will want to put some textures on the buttons and/or have the text crisp-sharp - in that case pixel2d is the way to go.

If you use pixel2d then you need to resize all the texts (scale =1.0 if 1 pixel). Some DGui (sliders, scrollbars) elements will have parts smaller then 1 pixel using the default setting, you may need to experiment with the settings to get something visible on the screen in some cases.

Also the coordinates of pixel2d are a bit …em… specific

   Y _   /\
   | \   |
      \  |
         |                      |
         |        SCREEN        |
         |                      |

When using pixel2d I alway use these helper functions:

def _pos2d(x,y):
    return Point3(x,0,-y)
def _rec2d(width, height):
    return (-width, 0, 0, height)
def _resetPivot(frame):
    frame.setPos(-size[0], 0, -size[3])        

So to make a frame that is 127pixels width 13 pixels high, and position it 20pixels from the left edge and 60 pixels from the top edge you’d do:

myFrame=DirectFrame(frameSize=_rec2d(127,13), parent=pixel2d) 
myFrame.setPos(_pos2d(20, 60))

_resetPivot can break some compound elements, but I don’t have a list of what exactly.

EDIT: I think I got the axis wrong myself on the first go, should be more correct now

Thanks to you both.
And I’ll definitely try out pixel2d , wezu. Hopefully will make everything work OK.

One other thing - would pixel2d respond to mouse events ?
If not - how Do I go about adding this? Thx!

Yes, the default mouse watcher is associated with both aspect2d and pixel2d.