DirectFrame questions

Is it possible to rescale a direct frame?

For example i rescale one so that the new origin becomes the (top,left) corner and the new (width,height) becomes (800,600). Then when i add an object to this direct frame i use this dimensions and this origin to facilitate things.

Can we use a DirectFrame to somehow clip the geometry it contains?

My last questions is that if we want to create a new gui class should we extend DirectFrame or is there a better choice?

DirectFrame has property name ‘frameSize’ of the form (left bound, right bound, bottom bound, top bound). So for your example you would say

dfObject['frameSize'] = (0,800,-600,0)
# make frame visible
dfObject['relief'] = 1 # DGG.FLAT
dfObject['frameColor'] = (1,1,1,0.5)

Keep in mind though that these values are not in pixel coordinates. See the DirectGui manual page for a clearer explanation.

Kind of. DirectScrolledFrame does this for its canvas layer. At the core of it, it uses ClipPlaneAttribs to define its viewable boundaries. This is the only DirectGui Object I know of that does anything in the way of clipping. So you may want to just use that and disable the scroll bars. There’s no reason why you can’t subclass DirectFrame to achieve a similar effect, though.

DirectFrame is a good place to start, especially if you’re defining a gui object that is pieced together from many other gui items (like menus or complex guis). If you’re talking about creating another low-level “component” gui object (on the level of a button or scrolled frame), you’ll still probably start with a DirectFrame, but you’ll want to familiarize yourself with the Panda level of gui objects too in “panda/src/pgui”.