def __init__(self, parent=None, x=0, y=0, callback=None, extra_args=None, radio=False, expand_width=100, checked=False, enabled=True): RPObject.__init__(self) prefix = "checkbox" if not radio else "radiobox" if enabled: checked_img = RPLoader.load_texture("/$$rp/data/gui/" + prefix + "_checked.png") unchecked_img = RPLoader.load_texture("/$$rp/data/gui/" + prefix + "_default.png") else: checked_img = RPLoader.load_texture("/$$rp/data/gui/" + prefix + "_disabled.png") unchecked_img = checked_img # Set near filter, otherwise textures look like crap for tex in [checked_img, unchecked_img]: tex.set_minfilter(SamplerState.FT_linear) tex.set_magfilter(SamplerState.FT_linear) tex.set_wrap_u(SamplerState.WM_clamp) tex.set_wrap_v(SamplerState.WM_clamp) tex.set_anisotropic_degree(0) self._node = DirectCheckBox(parent=parent, pos=(x + 11, 1, -y - 8), scale=(10 / 2.0, 1, 10 / 2.0), checkedImage=checked_img, uncheckedImage=unchecked_img, image=unchecked_img, extraArgs=extra_args, state=DGG.NORMAL, relief=DGG.FLAT, command=self._update_status) self._node["frameColor"] = (0, 0, 0, 0) self._node["frameSize"] = (-2.6, 2 + expand_width / 7.5, -2.35, 2.5) self._node.set_transparency(TransparencyAttrib.M_alpha) self._callback = callback self._extra_args = extra_args self._collection = None if checked: self.set_checked(True, False)
def createDirectCheckBox(self, parent=None): parent = self.getEditorRootCanvas() if parent is None else parent pos = self.editorCenter if parent == self.getEditorRootCanvas() else (0,0,0) if self.visEditorInAspect2D: element = DirectCheckBox( #image="icons/minusnode.gif", #uncheckedImage="icons/minusnode.gif", #checkedImage="icons/plusnode.gif", parent=parent, scale=0.1) else: element = DirectCheckBox( pos=pos, borderWidth=(2, 2), #image="icons/minusnode.gif", #uncheckedImage="icons/minusnode.gif", #checkedImage="icons/plusnode.gif", parent=parent, scale=1) elementInfo = ElementInfo(element, "DirectCheckBox") self.setupBind(elementInfo) return elementInfo
def __init__(self, parent=None, x=0, y=0, callback=None, extraArgs=None, radio=False, expandW=100, checked=False): DebugObject.__init__(self, "BetterCheckbox") prefix = "Checkbox" if not radio else "Radiobox" checkedImg = Globals.loader.loadTexture("Data/GUI/" + prefix + "Active.png") uncheckedImg = Globals.loader.loadTexture("Data/GUI/" + prefix + "Empty.png") # Set near filter, otherwise textures look like crap for tex in [checkedImg, uncheckedImg]: tex.setMinfilter(Texture.FTNearest) tex.setMagfilter(Texture.FTNearest) tex.setAnisotropicDegree(0) tex.setWrapU(Texture.WMClamp) tex.setWrapV(Texture.WMClamp) self._node = DirectCheckBox(parent=parent, pos=(x + 7.5, 1, -y - 7.5), scale=(15 / 2.0, 1, 15 / 2.0), checkedImage=checkedImg, uncheckedImage=uncheckedImg, image=uncheckedImg, extraArgs=extraArgs, state=DGG.NORMAL, relief=DGG.FLAT, command=self._updateStatus) self._node["frameColor"] = (0, 0, 0, 0.0) self._node["frameSize"] = (-2, 2 + expandW / 7.5, -1.6, 1.6) self._node.setTransparency(TransparencyAttrib.MAlpha) self.callback = callback self.extraArgs = extraArgs self.collection = None if checked: self._setChecked(True)
def __init__(self): self.frameMain = DirectFrame(image="optionsmenu.png", image_scale=(1.7778, 1, 1), frameSize=(base.a2dLeft, base.a2dRight, base.a2dBottom, base.a2dTop), frameColor=(0, 0, 0, 0)) self.frameMain.setTransparency(True) volume = base.musicManager.getVolume() self.sliderMusicVolume = DirectSlider( scale=0.5, pos=(0, 0, -0.1), range=(0, 1), scrollSize=0.01, text="Music Volume: %d%%" % volume * 100, text_scale=0.15, text_align=TextNode.ACenter, text_pos=(.0, 0.15), text_fg=(240 / 255.0, 255 / 255.0, 240 / 255.0, 1), thumb_frameColor=(0.8, 0, 1, 0.75), thumb_relief=DGG.FLAT, frameColor=(0.25, 0.25, 0.55, 1), value=volume, command=self.sliderMusicVolume_ValueChanged) self.sliderMusicVolume.reparentTo(self.frameMain) volume = base.sfxManagerList[0].getVolume() self.sliderSFXVolume = DirectSlider( scale=0.5, pos=(0, 0, -0.3), range=(0, 1), scrollSize=0.01, text="SFX Volume: %d%%" % volume * 100, text_scale=0.15, text_align=TextNode.ACenter, text_pos=(.0, 0.15), text_fg=(240 / 255.0, 255 / 255.0, 240 / 255.0, 1), thumb_frameColor=(0.8, 0, 1, 0.75), thumb_relief=DGG.FLAT, frameColor=(0.25, 0.25, 0.55, 1), value=volume, command=self.sliderSFXVolume_ValueChanged) self.sliderSFXVolume.reparentTo(self.frameMain) isChecked = not base.AppHasAudioFocus img = None imgON = "AudioSwitch_on.png" imgOFF = "AudioSwitch_off.png" if base.AppHasAudioFocus: img = imgON else: img = imgOFF self.cbVolumeMute = DirectCheckBox( scale=0.5, text="Mute Audio", text_scale=0.15, text_align=TextNode.ACenter, text_pos=(0.0, 0.15), text_fg=(240 / 255.0, 255 / 255.0, 240 / 255.0, 1), pos=(0, 0, -0.5), command=self.cbVolumeMute_CheckedChanged, rolloverSound=None, clickSound=None, relief=None, pressEffect=False, isChecked=isChecked, image=img, image_scale=0.1, checkedImage=imgOFF, uncheckedImage=imgON) self.cbVolumeMute.setTransparency(True) self.cbVolumeMute.setImage() self.cbVolumeMute.reparentTo(self.frameMain) radio = base.loader.loadModel("radioBtn") radioGeom = (radio.find("**/RadioButtonReady"), radio.find("**/RadioButtonChecked")) self.lblDifficulty = DirectLabel(text="Difficulty", text_fg=(240 / 255.0, 255 / 255.0, 240 / 255.0, 1), text_scale=0.6, scale=0.15, frameColor=(0, 0, 0, 0), pos=(-0.5, 0, -0.6)) self.lblDifficulty.reparentTo(self.frameMain) self.difficulty = [base.difficulty] def createDifficultyDRB(self, text, value, initialValue, xPos): drb = DirectRadioButton( text=text, text_fg=(240 / 255.0, 255 / 255.0, 240 / 255.0, 1), variable=self.difficulty, value=value, indicatorValue=initialValue, boxGeom=radioGeom, boxGeomScale=0.5, #indicator_pad = (0.1, 0.1), scale=0.05, frameColor=(0.5, 0.5, 0.5, 1), pressEffect=False, relief=1, pad=(0.5, 0, 0.5, 0.5), pos=(xPos, 0, -0.6), command=self.rbDifficulty_ValueChanged) drb.indicator.setX(drb.indicator.getX() + 0.1) drb.indicator.setZ(drb.indicator.getZ() + 0.1) drb.reparentTo(self.frameMain) return drb self.difficultyButtons = [ createDifficultyDRB(self, "Easy", [0], 1 if base.difficulty == 0 else 0, 0.5 - 0.3), createDifficultyDRB(self, "Medium", [1], 1 if base.difficulty == 1 else 0, 0.5), createDifficultyDRB(self, "Hard", [2], 1 if base.difficulty == 2 else 0, 0.5 + 0.3) ] for button in self.difficultyButtons: button.setOthers(self.difficultyButtons) self.btnBack = DirectButton(text="Back", scale=0.15, text_pos=(-0.3, -0.2), text_scale=0.6, text_fg=(240 / 255.0, 255 / 255.0, 240 / 255.0, 1), frameColor=(0, 0, 0, 0), image=("btnExit.png", "btnExit_hover.png", "btnExit_hover.png", "btnExit_hover.png"), image_scale=(1, 1, 0.5), pos=(0, 0, -0.8), command=base.messenger.send, extraArgs=["menu_Back"]) self.btnBack.setTransparency(True) self.btnBack.reparentTo(self.frameMain) self.hide()
def __init__(self): self.frameMain = DirectFrame( image="gui/MenuBackground.png", image_scale=(1.7778, 1, 1), #image_pos=(0, 0, 0.25), frameSize=( base.a2dLeft, base.a2dRight, base.a2dTop, base.a2dBottom), frameColor=(0,0,0,0)) self.frameMain.setTransparency(True) self.logo = DirectFrame( image="Logo.png", image_scale=0.25, image_pos=(0, 0, 0.55), frameSize=( base.a2dLeft, base.a2dRight, base.a2dTop, base.a2dBottom), frameColor=(0,0,0,0)) self.logo.reparentTo(self.frameMain) btnGeom = "gui/button" self.btnBack = menuHelper.createButton(_("Back"), btnGeom, 0, -0.7, ["options_back"]) self.btnBack.reparentTo(self.frameMain) volume = base.musicManager.getVolume() self.sliderVolume = DirectSlider( scale=0.5, pos=(-0.5, 0, 0), range=(0, 1), scrollSize=0.01, text=_("Volume %d%%") % volume*100, text_scale=0.1, text_pos=(0, 0.15), text_fg=(1, 1, 1, 1), thumb_frameColor=(0,0.75, 0.25, 1), frameColor=(0.35, 0.15, 0.05, 1), value=volume, command=self.sliderVolume_ValueChanged) self.sliderVolume.reparentTo(self.frameMain) isChecked = not base.AppHasAudioFocus img = None imgON = "gui/AudioSwitch_on.png" imgOFF = "gui/AudioSwitch_off.png" if base.AppHasAudioFocus: img = imgON else: img = imgOFF self.cbVolumeMute = DirectCheckBox( text=_("Mute Audio"), text_scale=0.5, text_align=TextNode.ACenter, text_pos=(0, 0.65), text_fg=(1, 1, 1, 1), scale=0.105, pos=(0.5, 0, 0), command=self.cbVolumeMute_CheckedChanged, relief=None, pressEffect=False, isChecked=isChecked, image=img, image_scale=0.5, checkedImage=imgOFF, uncheckedImage=imgON) self.cbVolumeMute.setTransparency(True) self.cbVolumeMute.setImage() self.cbVolumeMute.reparentTo(self.frameMain) prcPath = os.path.join(basedir, "%s.prc"%appName) self.advancedOptions = DirectLabel( text=_("Advanced options can be made in the following text file\n%s")%prcPath, text_scale=0.5, text_fg=(1, 1, 1, 1), scale=0.1, pos=(0, 0, -0.25), frameColor=(0, 0, 0, 0)) self.advancedOptions.setTransparency(True) self.advancedOptions.reparentTo(self.frameMain) self.hide()
def __makeStructureFrameTreeItem(self, elementNP, elementInfo, parentsLevel, z): if elementInfo is None: lbl = DirectLabel(text=elementNP.getName(), text_align=TextNode.ALeft, frameColor=(0, 0, 0, 0), relief=DGG.FLAT, pos=(self.structureFrame["frameSize"][0] + 20 * parentsLevel, 0, z), scale=16, parent=self.structureFrame.getCanvas()) self.maxWidth = max( self.maxWidth, lbl.getX() + lbl.getWidth() * lbl.getScale()[0]) else: margin = 5 shift = 6 if hasattr(elementNP, "getChildren"): if len(elementNP.getChildren()) > 0: # Collapse Button btnC = DirectCheckBox( relief=DGG.FLAT, pos=(self.structureFrame["frameSize"][0] + 20 * parentsLevel - 16 + margin, 0, z + shift), frameSize=(-8, 8, -8, 8), frameColor=(0, 0, 0, 0), command=self.__collapseElement, extraArgs=[elementInfo], image="icons/Collapsed.png" if elementInfo in self.collapsedElements else "icons/Collapse.png", uncheckedImage="icons/Collapse.png", checkedImage="icons/Collapsed.png", image_scale=8, isChecked=elementInfo in self.collapsedElements, parent=self.structureFrame.getCanvas()) btnC.setTransparency(TransparencyAttrib.M_alpha) btnC.bind(DGG.MWDOWN, self.scroll, [0.01]) btnC.bind(DGG.MWUP, self.scroll, [-0.01]) # Element Name btn = DirectButton( frameColor=( VBase4(1, 1, 1, 1), #normal VBase4(0.9, 0.9, 0.9, 1), #click VBase4(0.8, 0.8, 0.8, 1), #hover VBase4(0.5, 0.5, 0.5, 1)), #disabled text=elementInfo.name, text_align=TextNode.ALeft, relief=DGG.FLAT, pos=(self.structureFrame["frameSize"][0] + 20 * parentsLevel, 0, z), scale=16, command=self.__selectElement, extraArgs=[elementInfo], parent=self.structureFrame.getCanvas()) btn.bind(DGG.MWDOWN, self.scroll, [0.01]) btn.bind(DGG.MWUP, self.scroll, [-0.01]) if self.selectedElement is not None and self.selectedElement == elementInfo: btn.setColorScale(1, 1, 0, 1) # Delete Button btnX = DirectButton( relief=DGG.FLAT, pos=(self.structureFrame["frameSize"][0] + 8 + margin + 20 * parentsLevel + btn.getWidth() * btn.getScale()[0], 0, z + shift), frameSize=(-8, 8, -8, 8), frameColor=(0, 0, 0, 0), command=self.__removeElement, extraArgs=[elementInfo], image="icons/DeleteSmall.png", image_scale=8, parent=self.structureFrame.getCanvas()) btnX.setTransparency(TransparencyAttrib.M_multisample) btnX.bind(DGG.MWDOWN, self.scroll, [0.01]) btnX.bind(DGG.MWUP, self.scroll, [-0.01]) # Visibility Button btnV = DirectCheckBox( relief=DGG.FLAT, pos=(self.structureFrame["frameSize"][0] + 8 + margin * 2 + 20 * parentsLevel + btn.getWidth() * btn.getScale()[0] + btnX.getWidth(), 0, z + shift), frameSize=(-8, 8, -8, 8), frameColor=(0, 0, 0, 0), command=self.__toggleElementVisibility, extraArgs=[elementInfo], image="icons/VisibilityOffSmall.png" if elementInfo.element.isHidden() else "icons/VisibilityOnSmall.png", uncheckedImage="icons/VisibilityOffSmall.png", checkedImage="icons/VisibilityOnSmall.png", image_scale=8, isChecked=not elementInfo.element.isHidden(), parent=self.structureFrame.getCanvas()) btnV.setTransparency(TransparencyAttrib.M_multisample) btnV.bind(DGG.MWDOWN, self.scroll, [0.01]) btnV.bind(DGG.MWUP, self.scroll, [-0.01]) self.maxWidth = max(self.maxWidth, btnV.getX() + 8)
def __init__(self): """Default constructor""" # create a main frame as big as the window self.frameMain = DirectFrame( # set framesize the same size as the window frameSize=(base.a2dLeft, base.a2dRight, base.a2dTop, base.a2dBottom), image="LogoTextGlow.png", image_scale=(1.06 / 2.0, 1, 0.7 / 2.0), image_pos=(0, 0, 0.7), # position center pos=(0, 0, 0), # set tramsparent background color frameColor=(0, 0, 0, 0)) self.frameMain.setTransparency(1) self.frameMain.setBin("fixed", 100) sliderscale = 0.5 buttonScale = 0.25 textscale = 0.1 checkboxscale = 0.05 left = -0.5 right = 0.5 self.sliderTextspeed = DirectSlider( scale=sliderscale, pos=(left, 0, 0.2), range=(0.2, 0.01), scrollSize=0.01, text=_("Textspeed %0.1f%%") % (base.textWriteSpeed * 10), text_scale=textscale, text_align=TextNode.ACenter, text_pos=(0.0, 0.15), text_fg=(1, 1, 1, 1), thumb_frameColor=(0.65, 0.65, 0.0, 1), thumb_relief=DGG.FLAT, frameColor=(0.15, 0.15, 0.15, 1), value=base.textWriteSpeed, command=self.sliderTextspeed_ValueChanged) self.sliderTextspeed.reparentTo(self.frameMain) self.cbParticles = DirectCheckButton( text=_(" Enable Particles"), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 0.35), pos=(left, 0, -0.0), scale=checkboxscale, frameColor=(0, 0, 0, 0), command=self.cbParticles_CheckedChanged, rolloverSound=None, clickSound=None, pressEffect=False, boxPlacement="below", boxBorder=0.8, boxRelief=DGG.FLAT, indicator_scale=1.5, indicator_text_fg=(0.65, 0.65, 0.0, 1), indicator_text_shadow=(0, 0, 0, 0.35), indicator_frameColor=(0.15, 0.15, 0.15, 1), indicatorValue=base.particleMgrEnabled) self.cbParticles.indicator['text'] = (' ', 'x') self.cbParticles.indicator['text_pos'] = (0, 0.1) #self.cbParticles.indicator.setX(self.cbParticles.indicator, -0.5) #self.cbParticles.indicator.setZ(self.cbParticles.indicator, -0.1) #self.cbParticles.setFrameSize() self.cbParticles.setTransparency(1) self.cbParticles.reparentTo(self.frameMain) volume = base.musicManager.getVolume() self.sliderVolume = DirectSlider( scale=sliderscale, pos=(left, 0, -0.35), range=(0, 1), scrollSize=0.01, text=_("Volume %d%%") % volume * 100, text_scale=textscale, text_align=TextNode.ACenter, text_pos=(.0, 0.15), text_fg=(1, 1, 1, 1), thumb_frameColor=(0.65, 0.65, 0.0, 1), thumb_relief=DGG.FLAT, frameColor=(0.15, 0.15, 0.15, 1), value=volume, command=self.sliderVolume_ValueChanged) self.sliderVolume.reparentTo(self.frameMain) self.lblControltype = DirectLabel(text=_("Control type"), text_fg=(1, 1, 1, 1), text_shadow=(0, 0, 0, 0.35), frameColor=(0, 0, 0, 0), scale=textscale / 2, pos=(right, 0, 0.27)) self.lblControltype.setTransparency(1) self.lblControltype.reparentTo(self.frameMain) selectedControlType = 0 if base.controlType == "MouseAndKeyboard": selectedControlType = 1 self.controltype = DirectOptionMenu( pos=(right, 0, 0.18), text_fg=(1, 1, 1, 1), scale=0.1, items=[_("Keyboard"), _("Keyboard + Mouse")], initialitem=selectedControlType, frameColor=(0.15, 0.15, 0.15, 1), popupMarker_frameColor=(0.65, 0.65, 0.0, 1), popupMarker_relief=DGG.FLAT, highlightColor=(0.65, 0.65, 0.0, 1), relief=DGG.FLAT, command=self.controlType_Changed) self.controltype.reparentTo(self.frameMain) b = self.controltype.getBounds() xPos = right - ((b[1] - b[0]) / 2.0 * 0.1) self.controltype.setX(xPos) setItems(self.controltype) self.controltype.setItems = setItems self.controltype.showPopupMenu = showPopupMenu self.controltype.popupMarker.unbind(DGG.B1PRESS) self.controltype.popupMarker.bind(DGG.B1PRESS, showPopupMenu) self.controltype.unbind(DGG.B1PRESS) self.controltype.bind(DGG.B1PRESS, showPopupMenuExtra, [self.controltype]) isChecked = not base.AppHasAudioFocus img = None if base.AppHasAudioFocus: img = "AudioSwitch_on.png" else: img = "AudioSwitch_off.png" self.cbVolumeMute = DirectCheckBox( text=_("Mute Audio"), text_scale=0.5, text_align=TextNode.ACenter, text_pos=(0.0, 0.65), text_fg=(1, 1, 1, 1), pos=(right, 0, -0.35), scale=0.21 / 2.0, command=self.cbVolumeMute_CheckedChanged, rolloverSound=None, clickSound=None, relief=None, pressEffect=False, isChecked=isChecked, image=img, image_scale=0.5, checkedImage="AudioSwitch_off.png", uncheckedImage="AudioSwitch_on.png") self.cbVolumeMute.setTransparency(1) self.cbVolumeMute.setImage() self.cbVolumeMute.reparentTo(self.frameMain) sensitivity = base.mouseSensitivity self.sliderSensitivity = DirectSlider( scale=sliderscale, pos=(right, 0, -0.075), range=(0.5, 2), scrollSize=0.01, text=_("Mouse Sensitivity %0.1fx") % sensitivity, text_scale=textscale, text_align=TextNode.ACenter, text_pos=(.0, 0.15), text_fg=(1, 1, 1, 1), thumb_frameColor=(0.65, 0.65, 0.0, 1), thumb_relief=DGG.FLAT, frameColor=(0.15, 0.15, 0.15, 1), value=sensitivity, command=self.sliderSensitivity_ValueChanged) self.sliderSensitivity.reparentTo(self.frameMain) if base.controlType == "Gamepad": self.sliderSensitivity.hide() # create the back button self.btnBack = DirectButton( scale=buttonScale, # position on the window pos=(0, 0, base.a2dBottom + 0.15), frameColor=(0, 0, 0, 0), # text properties text=_("Back"), text_scale=0.5, text_fg=(1, 1, 1, 1), text_pos=(0.0, -0.15), text_shadow=(0, 0, 0, 0.35), text_shadowOffset=(-0.05, -0.05), # sounds that should be played rolloverSound=None, clickSound=None, pressEffect=False, relief=None, # the event which is thrown on clickSound command=lambda: base.messenger.send("options_back")) self.btnBack.setTransparency(1) self.btnBack.reparentTo(self.frameMain) self.hide()
def __init__(self, tooltip, grid): self.tt = tooltip self.grid = grid screenWidthPx = base.getSize()[0] left = screenWidthPx * 0.25 barWidth = screenWidthPx * 0.75 color = ( (0.25, 0.25, 0.25, 1), # Normal (0.35, 0.35, 1, 1), # Click (0.25, 0.25, 1, 1), # Hover (0.1, 0.1, 0.1, 1)) # Disabled # # Toolbar # self.toolBar = DirectBoxSizer(frameColor=(0.25, 0.25, 0.25, 1), frameSize=(0, barWidth, -24, 24), autoUpdateFrameSize=False, pos=(0, 0, 0), parent=base.pixel2d) buttonColor = ( (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 btn = DirectButton(frameSize=(-24, 24, -24, 24), frameColor=buttonColor, relief=DGG.FLAT, command=base.messenger.send, extraArgs=["newProject"], image="icons/New.png", image_scale=24) btn.setTransparency(TransparencyAttrib.M_multisample) btn.bind(DGG.ENTER, self.tt.show, ["Create New GUI (Ctrl-N)"]) btn.bind(DGG.EXIT, self.tt.hide) self.toolBar.addItem(btn) btn = DirectButton(frameSize=(-24, 24, -24, 24), frameColor=buttonColor, relief=DGG.FLAT, command=base.messenger.send, extraArgs=["saveProject"], image="icons/Save.png", image_scale=24) btn.setTransparency(TransparencyAttrib.M_multisample) btn.bind(DGG.ENTER, self.tt.show, ["Save GUI as gui Project (Ctrl-S)"]) btn.bind(DGG.EXIT, self.tt.hide) self.toolBar.addItem(btn) btn = DirectButton(frameSize=(-24, 24, -24, 24), frameColor=buttonColor, text_scale=0.33, relief=DGG.FLAT, command=base.messenger.send, extraArgs=["exportProject"], image="icons/Export.png", image_scale=24) btn.setTransparency(TransparencyAttrib.M_multisample) btn.bind(DGG.ENTER, self.tt.show, ["Export GUI as python script (Ctrl-E)"]) btn.bind(DGG.EXIT, self.tt.hide) self.toolBar.addItem(btn) btn = DirectButton(frameSize=(-24, 24, -24, 24), frameColor=buttonColor, relief=DGG.FLAT, text_scale=0.33, command=base.messenger.send, extraArgs=["loadProject"], image="icons/Load.png", image_scale=24) btn.setTransparency(TransparencyAttrib.M_multisample) btn.bind(DGG.ENTER, self.tt.show, ["Load GUI project (Ctrl-O)"]) btn.bind(DGG.EXIT, self.tt.hide) self.toolBar.addItem(btn) placeholder = DirectFrame(text="|", frameSize=(-1, 1, -24, 24), pad=(4, 0), frameColor=(0, 0, 0, 1)) self.toolBar.addItem(placeholder) btn = DirectButton(frameSize=(-24, 24, -24, 24), frameColor=buttonColor, relief=DGG.FLAT, text_scale=0.33, command=base.messenger.send, extraArgs=["undo"], image="icons/Undo.png", image_scale=24) btn.setTransparency(TransparencyAttrib.M_multisample) btn.bind(DGG.ENTER, self.tt.show, ["Undo last action (Ctrl-Z)"]) btn.bind(DGG.EXIT, self.tt.hide) self.toolBar.addItem(btn) btn = DirectButton(frameSize=(-24, 24, -24, 24), frameColor=buttonColor, relief=DGG.FLAT, text_scale=0.33, command=base.messenger.send, extraArgs=["redo"], image="icons/Redo.png", image_scale=24) btn.setTransparency(TransparencyAttrib.M_multisample) btn.bind(DGG.ENTER, self.tt.show, ["Redo last action (Ctrl-Y)"]) btn.bind(DGG.EXIT, self.tt.hide) self.toolBar.addItem(btn) btn = DirectButton(frameSize=(-24, 24, -24, 24), frameColor=buttonColor, relief=DGG.FLAT, text_scale=0.33, command=base.messenger.send, extraArgs=["cycleRedo"], image="icons/CycleRedo.png", image_scale=24) btn.setTransparency(TransparencyAttrib.M_multisample) btn.bind(DGG.ENTER, self.tt.show, ["Cycle through redo branches (Ctrl-Shift-Y)"]) btn.bind(DGG.EXIT, self.tt.hide) self.toolBar.addItem(btn) placeholder = DirectFrame(text="|", frameSize=(-1, 1, -24, 24), pad=(4, 0), frameColor=(0, 0, 0, 1)) self.toolBar.addItem(placeholder) btn = DirectButton(frameSize=(-24, 24, -24, 24), frameColor=buttonColor, relief=DGG.FLAT, text_scale=0.33, command=base.messenger.send, extraArgs=["removeElement"], image="icons/Delete.png", image_scale=24) btn.setTransparency(TransparencyAttrib.M_multisample) btn.bind(DGG.ENTER, self.tt.show, ["Delete selected element (Del)"]) btn.bind(DGG.EXIT, self.tt.hide) self.toolBar.addItem(btn) placeholder = DirectFrame(text="|", frameSize=(-1, 1, -24, 24), pad=(4, 0), frameColor=(0, 0, 0, 1)) self.toolBar.addItem(placeholder) self.cb_grid = DirectCheckBox( frameSize=(-24, 24, -24, 24), frameColor=buttonColor, relief=DGG.FLAT, text_scale=12, image="icons/GridOff.png" if self.grid.isHidden() else "icons/GridOn.png", uncheckedImage="icons/GridOff.png", checkedImage="icons/GridOn.png", image_scale=24, isChecked=not self.grid.isHidden(), command=self.toggleGrid) self.cb_grid.setTransparency(TransparencyAttrib.M_multisample) self.cb_grid.bind(DGG.ENTER, self.tt.show, ["Toggle Grid (Ctrl-G)"]) self.cb_grid.bind(DGG.EXIT, self.tt.hide) self.toolBar.addItem(self.cb_grid) self.cb_scale = DirectCheckBox(frameSize=(-24, 24, -24, 24), frameColor=buttonColor, relief=DGG.FLAT, text_scale=12, image="icons/Scale1.png", uncheckedImage="icons/Scale2.png", checkedImage="icons/Scale1.png", image_scale=24, isChecked=True, command=self.toggleVisualEditorParent) self.cb_scale.setTransparency(TransparencyAttrib.M_alpha) self.cb_scale.bind(DGG.ENTER, self.tt.show, ["Toggle editor scale (Aspect/Pixel)"]) self.cb_scale.bind(DGG.EXIT, self.tt.hide) self.toolBar.addItem(self.cb_scale) placeholder = DirectFrame(text="|", frameSize=(-1, 1, -24, 24), pad=(4, 0), frameColor=(0, 0, 0, 1)) self.toolBar.addItem(placeholder) zoomHolder = DirectFrame( frameSize=(-48, 48, -24, 24), #pad=(4, 0), frameColor=(0, 0, 0, 0)) self.toolBar.addItem(zoomHolder) self.zoomSlider = DirectSlider(zoomHolder, scale=(48, 1, 96), pos=(0, 0, 0), range=(0.1, 1.5), command=self.zoomSliderChanged) self.zoomSlider.bind(DGG.ENTER, self.tt.show, ["Zoom"]) self.zoomSlider.bind(DGG.EXIT, self.tt.hide) #self.toolBar.addItem(self.zoomSlider) placeholder = DirectFrame(text="|", frameSize=(-1, 1, -24, 24), pad=(4, 0), frameColor=(0, 0, 0, 1)) self.toolBar.addItem(placeholder) btn = DirectButton(frameSize=(-24, 24, -24, 24), frameColor=buttonColor, relief=DGG.FLAT, text_scale=0.33, command=base.messenger.send, extraArgs=["quitApp"], image="icons/Quit.png", image_scale=24) btn.setTransparency(TransparencyAttrib.M_alpha) btn.bind(DGG.ENTER, self.tt.show, ["Quit Direct GUI Designer (Ctrl-Q)"]) btn.bind(DGG.EXIT, self.tt.hide) self.toolBar.addItem(btn) placeholder = DirectFrame(text="|", frameSize=(-1, 1, -24, 24), pad=(4, 0), frameColor=(0, 0, 0, 1)) self.toolBar.addItem(placeholder) btn = DirectButton(frameSize=(-24, 24, -24, 24), frameColor=buttonColor, relief=DGG.FLAT, text_scale=0.33, command=base.messenger.send, extraArgs=["showHelp"], image="icons/Help.png", image_scale=24) btn.setTransparency(TransparencyAttrib.M_multisample) btn.bind(DGG.ENTER, self.tt.show, ["Show a help Dialog (F1)"]) btn.bind(DGG.EXIT, self.tt.hide) self.toolBar.addItem(btn) btn = DirectButton(frameSize=(-24, 24, -24, 24), frameColor=buttonColor, relief=DGG.FLAT, text_scale=0.33, command=base.messenger.send, extraArgs=["showSettings"], image="icons/Settings.png", image_scale=24) btn.setTransparency(TransparencyAttrib.M_multisample) btn.bind(DGG.ENTER, self.tt.show, ["Show Designer Settings"]) btn.bind(DGG.EXIT, self.tt.hide) self.toolBar.addItem(btn) if not ConfigVariableBool("show-toolbar", True).getValue(): self.toolBar.hide() self.accept("setVisualEditorParent", self.setVisualEditorParent) self.accept("toggleGrid", self.setGrid)