def resetZoom(self):
        self.visualEditor["verticalScroll_range"] = (0, 1)
        self.visualEditor["horizontalScroll_range"] = (0, 1)
        if self.currentVisEditorParent != base.aspect2d:
            # we are in pixel2d
            self.getEditorRootCanvas().setScale(1,1,1)
            self.visualEditor.verticalScroll["value"] = 0
            self.visualEditor.horizontalScroll["value"] = 0

            posParentScaleX = DGH.getRealWidth(self.parent)
            self.minScale = DEFAULT_MIN_SCALE
            self.maxScale = DEFAULT_MAX_SCALE
            base.messenger.send("setZoomValeMinMax", [self.minScale, self.maxScale])
            base.messenger.send("setZoomValue", [1])
        else:
            # we are in aspect2d
            self.getEditorRootCanvas().setScale(self.canvasScale/2,1,self.canvasScale/2)
            self.visualEditor.verticalScroll["value"] = 0.5
            self.visualEditor.horizontalScroll["value"] = 0.5

            posParentScaleX = DGH.getRealWidth(self.parent)
            self.minScale = posParentScaleX * DEFAULT_MIN_SCALE
            self.maxScale = posParentScaleX * DEFAULT_MAX_SCALE
            base.messenger.send("setZoomValeMinMax", [self.minScale, self.maxScale])
            base.messenger.send("setZoomValue", [self.canvasScale/2])
    def __init__(self, parent, getEditorRootCanvas, elementDict,
                 selectedElement):
        height = DGH.getRealHeight(parent)
        self.collapsedElements = []

        self.parent = parent

        self.box = DirectBoxSizer(frameColor=(0.25, 0.25, 0.25, 1),
                                  autoUpdateFrameSize=False,
                                  orientation=DGG.VERTICAL)
        self.sizer = DirectAutoSizer(parent=parent,
                                     child=self.box,
                                     childUpdateSizeFunc=self.box.refresh)

        self.lblHeader = DirectLabel(
            text="Structure",
            text_scale=16,
            text_align=TextNode.ALeft,
            text_fg=(1, 1, 1, 1),
            frameColor=VBase4(0, 0, 0, 0),
        )
        self.box.addItem(self.lblHeader)

        color = (
            (0.8, 0.8, 0.8, 1),  # Normal
            (0.9, 0.9, 1, 1),  # Click
            (0.8, 0.8, 1, 1),  # Hover
            (0.5, 0.5, 0.5, 1))  # Disabled
        self.structureFrame = DirectScrolledFrame(
            # make the frame fit into our background frame
            frameSize=VBase4(
                self.parent["frameSize"][0], self.parent["frameSize"][1],
                self.parent["frameSize"][2] +
                DGH.getRealHeight(self.lblHeader),
                self.parent["frameSize"][3]),
            #canvasSize=VBase4(parent["frameSize"][0], parent["frameSize"][1]-20, height+30, 0),
            # set the frames color to transparent
            frameColor=VBase4(1, 1, 1, 1),
            scrollBarWidth=20,
            verticalScroll_scrollSize=20,
            verticalScroll_thumb_relief=DGG.FLAT,
            verticalScroll_incButton_relief=DGG.FLAT,
            verticalScroll_decButton_relief=DGG.FLAT,
            verticalScroll_thumb_frameColor=color,
            verticalScroll_incButton_frameColor=color,
            verticalScroll_decButton_frameColor=color,
            horizontalScroll_thumb_relief=DGG.FLAT,
            horizontalScroll_incButton_relief=DGG.FLAT,
            horizontalScroll_decButton_relief=DGG.FLAT,
            horizontalScroll_thumb_frameColor=color,
            horizontalScroll_incButton_frameColor=color,
            horizontalScroll_decButton_frameColor=color,
            state=DGG.NORMAL)
        self.box.addItem(self.structureFrame)
        self.structureFrame.bind(DGG.MWDOWN, self.scroll, [0.01])
        self.structureFrame.bind(DGG.MWUP, self.scroll, [-0.01])
        self.maxWidth = parent["frameSize"][1] - 20
        self.getEditorRootCanvas = getEditorRootCanvas
        self.refreshStructureTree(elementDict, selectedElement)
예제 #3
0
    def update(self):
        """Show all sockets and resize the frame to fit all sockets in"""
        z = 0

        fs = self.frame["frameSize"]
        maxWidth = fs[1]

        for socket in self.inputList + self.outputList:
            if socket.frame:
                maxWidth = max(maxWidth, DGH.getRealWidth(socket.frame))
        self.left = -maxWidth / 2
        self.right = maxWidth / 2

        for outSocket in self.outputList:
            outSocket.resize(maxWidth)
            outSocket.show(z, self.right)
            z -= outSocket.height

        for inSocket in self.inputList:
            inSocket.resize(maxWidth)
            inSocket.show(z, self.left)
            z -= inSocket.height

        self.frame["frameSize"] = (self.left, self.right, z, fs[3])
        self.frame["text_pos"] = (self.left, 0.12)

        base.messenger.send("NodeEditor_updateConnections")
 def resizeFrame(self):
     self.sizer.refresh()
     self.structureFrame["frameSize"] = (self.parent["frameSize"][0],
                                         self.parent["frameSize"][1],
                                         self.parent["frameSize"][2] +
                                         DGH.getRealHeight(self.lblHeader),
                                         self.parent["frameSize"][3])
예제 #5
0
    def resizeFrame(self):
        self.sizer.refresh()
        self.toolboxFrame["frameSize"] = (self.parent["frameSize"][0],
                                          self.parent["frameSize"][1],
                                          self.parent["frameSize"][2] +
                                          DGH.getRealHeight(self.lblHeader),
                                          self.parent["frameSize"][3])

        self.createEntries()
예제 #6
0
    def logic(self):
        """Simply write the value in the nodes textfield"""
        if self.inputList[0].value is None:
            self.inputList[0].text["text"] = "In 1"
            self.inputList[0].text.resetFrameSize()
            self.inputList[0].resize(1)
            self.update()
            return
        self.inputList[0].text["text"] = str(self.inputList[0].getValue())
        self.inputList[0].text["frameSize"] = None
        self.inputList[0].text.resetFrameSize()

        newSize = max(1, DGH.getRealWidth(self.inputList[0].text) + 0.2)
        self.inputList[0].resize(newSize)

        self.update()
예제 #7
0
def updateEntry(arg):
    if arg == "=":
        entry.set(str(eval(entry.get())))
    elif arg == "c":
        entry.set(entry.get()[:-1])
    elif arg == "CE":
        entry.set("")
    else:
        entry.set(entry.get() + arg)


app.accept("updateEntry", updateEntry)

leftBox.addItem(entry)
leftBox.addItem(gridSizer)
leftBox.setX(-DGH.getRealWidth(leftBox) / 2)
leftBox.setZ(DGH.getRealHeight(leftBox) / 2)

# SPINNER
spinBox = DirectSpinBox(pos=(0.8, 0, 0.25),
                        value=0,
                        minValue=-10,
                        maxValue=10,
                        repeatdelay=0.125,
                        buttonOrientation=DGG.HORIZONTAL,
                        valueEntry_text_align=TextNode.ACenter,
                        borderWidth=(.1, .1))
spinBox.setScale(0.1)
spinBox["relief"] = 2
spinBoxSizer = DirectBoxSizer(
    orientation=DGG.VERTICAL,
예제 #8
0
    def __init__(self, parent):
        height = DGH.getRealHeight(parent)
        self.parent = parent

        self.box = DirectBoxSizer(frameColor=(0.25, 0.25, 0.25, 1),
                                  autoUpdateFrameSize=False,
                                  orientation=DGG.VERTICAL)
        self.sizer = DirectAutoSizer(parent=parent,
                                     child=self.box,
                                     childUpdateSizeFunc=self.box.refresh)

        self.lblHeader = DirectLabel(
            text="Toolbox",
            text_scale=16,
            text_align=TextNode.ALeft,
            text_fg=(1, 1, 1, 1),
            frameColor=VBase4(0, 0, 0, 0),
        )
        self.box.addItem(self.lblHeader)

        color = (
            (0.8, 0.8, 0.8, 1),  # Normal
            (0.9, 0.9, 1, 1),  # Click
            (0.8, 0.8, 1, 1),  # Hover
            (0.5, 0.5, 0.5, 1))  # Disabled
        self.toolboxFrame = DirectScrolledFrame(
            # make the frame fit into our background frame
            frameSize=VBase4(
                self.parent["frameSize"][0], self.parent["frameSize"][1],
                self.parent["frameSize"][2] +
                DGH.getRealHeight(self.lblHeader),
                self.parent["frameSize"][3]),
            scrollBarWidth=20,
            verticalScroll_scrollSize=20,
            verticalScroll_thumb_relief=DGG.FLAT,
            verticalScroll_incButton_relief=DGG.FLAT,
            verticalScroll_decButton_relief=DGG.FLAT,
            verticalScroll_thumb_frameColor=color,
            verticalScroll_incButton_frameColor=color,
            verticalScroll_decButton_frameColor=color,
            horizontalScroll_thumb_relief=DGG.FLAT,
            horizontalScroll_incButton_relief=DGG.FLAT,
            horizontalScroll_decButton_relief=DGG.FLAT,
            horizontalScroll_thumb_frameColor=color,
            horizontalScroll_incButton_frameColor=color,
            horizontalScroll_decButton_frameColor=color,
            state=DGG.NORMAL)
        self.box.addItem(self.toolboxFrame)
        self.toolboxFrame.bind(DGG.MWDOWN, self.scroll, [0.01])
        self.toolboxFrame.bind(DGG.MWUP, self.scroll, [-0.01])
        self.toolboxEntries = [
            ["~Interactive Elements~"],
            ["Button", "DirectButton"],
            ["Entry", "DirectEntry"],
            ["Scrolled Entry", "DirectEntryScroll"],
            ["Check Box", "DirectCheckBox"],
            ["Check Button", "DirectCheckButton"],
            ["Option Menu", "DirectOptionMenu"],
            ["Radio Button", "DirectRadioButton"],
            ["Slider", "DirectSlider"],
            ["Scroll Bar", "DirectScrollBar"],
            ["Scrolled List Item", "DirectScrolledListItem"],
            ["~Display Elements~"],
            ["Label", "DirectLabel"],
            ["Wait Bar", "DirectWaitBar"],
            ["~Container~"],
            ["Frame", "DirectFrame"],
            ["Scrolled Frame", "DirectScrolledFrame"],
            ["Scrolled List", "DirectScrolledList"],
            ["~Dialogs~"],
            ["OK Dialog", "OkDialog"],
            ["OK Cancel Dialog", "OkCancelDialog"],
            ["Yes No Dialog", "YesNoDialog"],
            ["Yes No Cancel Dialog", "YesNoCancelDialog"],
            ["Retry Cancel Dialog", "RetryCancelDialog"],
        ]
        self.createEntries()