-
Notifications
You must be signed in to change notification settings - Fork 3
1.1 DirectAutoSizer
The auto sizer will enlarge the frameSize of a widget to the size (frameSize or bounds) of the given parent item. This can currently be either a gui widget or NodePath.
from direct.gui.DirectFrame import DirectFrame
from DirectGuiExtension.DirectAutoSizer import DirectAutoSizer
myFrame = DirectFrame()
# stretch myFrame to the windows bounds
DirectAutoSizer(child=myFrame)extendHorizontal: Boolean
Determines if the sizer should extend on the horizontal or keep the frameSize in this direction.
extendVertical: Boolean
Determines if the sizer should extend on the vertical or keep the frameSize in this direction.
minSize: Tuple of 4 or LVecBase4f
The minimum size the sizer should be able to scale to.
maxSize: None, Tuple of 4 or LVecBase4f
The maximum size the sizer should be able to scale to. If None, the sizer can grow indefinitely.
updateOnWindowResize: Boolean
If set to True, the sizer will be resized when the window is resized. This should be enabled if the sizer is parented to None or the default gui parent to keep it at the same size of the window even if the aspect ratio changes.
childUpdateSizeFunc: Function pointer
A function that will be called whenever the sizers' size gets changed. This usually will be a function of the child element to refresh it accordingly. Some of the widgets provided by this extension, like the DirectBoxSizer, should pass their refresh function to update correctly.
E.g.:
DirectAutoSizer(child=myBoxSizer, childUpdateSizeFunc=myBoxSizer.refresh)parentGetSizeFunction: None or Function pointer
A function that will be used to determine the size of the parent to set the sizers size correctly. This function should be used for any elements that can't be determined automatically or have special sizing functions applied to them. One such example would be the canvas of a DirectScrolledFrame which uses the canvasSize option to set the size of the space within.
E.g.:
frm = DirectScrolledFrame(canvasSize=(-2,2,-2,2))
autoSizer = DirectAutoSizer(parent=frm.canvas, parentGetSizeFunction=frm.cget, parentGetSizeExtraArgs=["canvasSize"])parentGetSizeExtraArgs: None or List of arguments
This list of arguments will be passed to the function which has been set with the parentGetSizeFunction argument. Just as seen in the example above.