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
Z
Y _ /\
| \ |
\ |
\|
(0.0)----->X
|----------------------|
| |
| 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):
size=frame['frameSize']
frame.setPos(-size[0], 0, -size[3])
frame.flattenLight()
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)
_resetPivot(myFrame)
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