def unbind(self, event):
        gEvent = event + self.guiId
        self.ignore(gEvent)



def toggleGuiGridSnap():
    DirectGuiWidget.snapToGrid = 1 - DirectGuiWidget.snapToGrid


def setGuiGridSpacing(spacing):
    DirectGuiWidget.gridSpacing = spacing

if config.GetBool('record-gui-creation-stack', 0):
    DirectGuiBase = recordCreationStackStr(DirectGuiBase)


class DirectGuiWidget(DirectGuiBase, NodePath):
    snapToGrid = 0
    gridSpacing = 0.050000000000000003
    guiEdit = config.GetBool('direct-gui-edit', 0)
    if guiEdit:
        inactiveInitState = DGG.NORMAL
    else:
        inactiveInitState = DGG.DISABLED
    guiDict = { }
    
    def __init__(self, parent = None, **kw):
        optiondefs = (('pgFunc', PGItem, None), ('numStates', 1, None), ('invertedFrames', (), None), ('sortOrder', 0, None), ('state', DGG.NORMAL, self.setState), ('relief', DGG.FLAT, self.setRelief), ('borderWidth', (0.10000000000000001, 0.10000000000000001), self.setBorderWidth), ('borderUvWidth', (0.10000000000000001, 0.10000000000000001), self.setBorderUvWidth), ('frameSize', None, self.setFrameSize), ('frameColor', (0.80000000000000004, 0.80000000000000004, 0.80000000000000004, 1), self.setFrameColor), ('frameTexture', None, self.setFrameTexture), ('frameVisibleScale', (1, 1), self.setFrameVisibleScale), ('pad', (0, 0), self.resetFrameSize), ('guiId', None, DGG.INITOPT), ('pos', None, DGG.INITOPT), ('hpr', None, DGG.INITOPT), ('scale', None, DGG.INITOPT), ('color', None, DGG.INITOPT), ('suppressMouse', 1, DGG.INITOPT), ('suppressKeys', 0, DGG.INITOPT), ('enableEdit', 1, DGG.INITOPT))
        self.defineoptions(kw, optiondefs)
Esempio n. 2
0
        gEvent = event + self.guiId
        self.ignore(gEvent)

def toggleGuiGridSnap():
    DirectGuiWidget.snapToGrid = 1 - DirectGuiWidget.snapToGrid

def setGuiGridSpacing(spacing):
    DirectGuiWidget.gridSpacing = spacing

# this should trigger off of __dev__, but it's not available at this point.
# __debug__ works because the production client is not __debug__ and the
# production AI doesn't create any GUI.
if config.GetBool('record-gui-creation-stack', __debug__):
    # this will help track down the code that created DirectGui objects
    # call obj.printCreationStackTrace() to figure out what code created it
    DirectGuiBase = recordCreationStackStr(DirectGuiBase)

class DirectGuiWidget(DirectGuiBase, NodePath):
    # Toggle if you wish widget's to snap to grid when draggin
    snapToGrid = 0
    gridSpacing = 0.05

    # Determine the default initial state for inactive (or
    # unclickable) components.  If we are in edit mode, these are
    # actually clickable by default.
    #guiEdit = base.config.GetBool('direct-gui-edit', 0)
    guiEdit = config.GetBool('direct-gui-edit', 0)
    if guiEdit:
        inactiveInitState = DGG.NORMAL
    else:
        inactiveInitState = DGG.DISABLED