def __init__(self, storyCardClass, title, num_columns=8): self.num_columns = num_columns self.storyCardClass = storyCardClass # Controls the behaviour of the added method. # None : does nothing # 'disable' : disables the StoryCard # 'remove' : removes the StoryCard from the box. self.added_behaviour = None # Whether or not the StoryMap automatically keeps its StoryCards in the # correct order. (StoryCards will be sorted whenever one is added to or # removed from the StoryMap.) self.keep_sorted = False GridBoxList.__init__(self, columns=num_columns, margin=1) for i in range(len(functions)): b = StoryMapBox(storyCardClass, geomnode=card()) b.setPythonTag('storymap', self) self.append(b) self.initial_size = len(self) self.storyCardClass = storyCardClass self.title = DirectEntry( initialText=title, text_font=loader.loadFont('storymaps/data/WritersFont.ttf'), width=13, numLines=1, suppressMouse=0, frameColor=(0, 0, 0, 0)) self.title['state'] = DGG.DISABLED self.title.setScale(5) self.title.setPos(self.left(), 0, self.top()) self.title.setZ(self.top() + 2) self.title.reparentTo(self.np) # The add_row_button/remove_row_button is not being used anymore. #icon = loader.loadTexture('storymaps/data/actions/remove.svg.png') #icon.setMagfilter(Texture.FTLinearMipmapLinear) #icon.setMinfilter(Texture.FTLinearMipmapLinear) #rollover_icon = loader.loadTexture('storymaps/data/actions/remove_rollover.svg.png') #rollover_icon.setMagfilter(Texture.FTLinearMipmapLinear) #rollover_icon.setMinfilter(Texture.FTLinearMipmapLinear) #self.remove_row_button = DirectButton(image= (icon, rollover_icon, rollover_icon, icon), command = self.remove_row, suppressMouse=0) #self.remove_row_button.reparentTo(self.np) #self._position_remove_button() #self.remove_row_button.hide() # Task for automatically growing and shrinking the storymap as cards are # added and removed. self.auto_grow = False taskMgr.add(self.add_row_task, 'StoryMap.add_row_task')
def __init__(self, storyCardClass, title, num_columns=8): self.num_columns = num_columns self.storyCardClass = storyCardClass # Controls the behaviour of the added method. # None : does nothing # 'disable' : disables the StoryCard # 'remove' : removes the StoryCard from the box. self.added_behaviour = None # Whether or not the StoryMap automatically keeps its StoryCards in the # correct order. (StoryCards will be sorted whenever one is added to or # removed from the StoryMap.) self.keep_sorted = False GridBoxList.__init__(self,columns=num_columns,margin=1) for i in range(len(functions)): b = StoryMapBox(storyCardClass, geomnode=card()) b.setPythonTag('storymap',self) self.append(b) self.initial_size = len(self) self.storyCardClass = storyCardClass self.title = DirectEntry(initialText=title, text_font=loader.loadFont('storymaps/data/WritersFont.ttf'), width=13, numLines=1, suppressMouse=0, frameColor = (0,0,0,0)) self.title['state'] = DGG.DISABLED self.title.setScale(5) self.title.setPos(self.left(),0,self.top()) self.title.setZ(self.top()+2) self.title.reparentTo(self.np) # The add_row_button/remove_row_button is not being used anymore. #icon = loader.loadTexture('storymaps/data/actions/remove.svg.png') #icon.setMagfilter(Texture.FTLinearMipmapLinear) #icon.setMinfilter(Texture.FTLinearMipmapLinear) #rollover_icon = loader.loadTexture('storymaps/data/actions/remove_rollover.svg.png') #rollover_icon.setMagfilter(Texture.FTLinearMipmapLinear) #rollover_icon.setMinfilter(Texture.FTLinearMipmapLinear) #self.remove_row_button = DirectButton(image= (icon, rollover_icon, rollover_icon, icon), command = self.remove_row, suppressMouse=0) #self.remove_row_button.reparentTo(self.np) #self._position_remove_button() #self.remove_row_button.hide() # Task for automatically growing and shrinking the storymap as cards are # added and removed. self.auto_grow = False taskMgr.add(self.add_row_task,'StoryMap.add_row_task')
hbox = HBoxList() hbox.setPos(-.5, 0, .4) hbox.reparentTo(zcanvas.home) for i in range(5): b = Box(geomnode=DemoItem.cm.generate()) hbox.append(b) i = DemoItem() b.fill(i) vbox = VBoxList() vbox.setPos(-.5, 0, .25) vbox.reparentTo(zcanvas.home) for i in range(5): b = Box(geomnode=DemoItem.cm.generate()) vbox.append(b) gbox = GridBoxList(columns=3) gbox.setPos(.1, 0, .1) gbox.reparentTo(zcanvas.home) for i in range(9): b = Box(geomnode=DemoItem.cm.generate()) gbox.append(b) base.accept('mouse1', zcanvas.drag) base.accept('mouse1-up', zcanvas.drop) zcanvas.message("""Drag the demo items (in white) and drop them onto the boxes (in black).""") run()
"""Demo of boxlists class using different subclasses of BoxList and drag & drop. """ import sys,os,random sys.path.append(os.path.join(sys.path[0],'../zui/')) from box import Box from gridboxlist import GridBoxList from zcanvas import zcanvas from pandac.PandaModules import * import direct.directbase.DirectStart from direct.gui.DirectGui import * gbox = GridBoxList(columns=3,margin=0) gbox.setPos(-.3,0,.3) gbox.reparentTo(zcanvas.home) cm = CardMaker('cm') cm.setFrame(-.1,.1,-.1,.1) for i in range(9): b = Box(geomnode=cm.generate()) gbox.append(b) label = DirectButton(text="Hello.") label.setScale(0.2) b.fill(label) base.accept('mouse1',zcanvas.drag) base.accept('mouse1-up',zcanvas.drop) zcanvas.message( """You can put DirectGUI widgets in boxlists too.""" )
"""Demo of boxlists class using different subclasses of BoxList and drag & drop. """ import sys, os, random sys.path.append(os.path.join(sys.path[0], '../zui/')) from box import Box from gridboxlist import GridBoxList from zcanvas import zcanvas from pandac.PandaModules import * import direct.directbase.DirectStart from direct.gui.DirectGui import * gbox = GridBoxList(columns=3, margin=0) gbox.setPos(-.3, 0, .3) gbox.reparentTo(zcanvas.home) cm = CardMaker('cm') cm.setFrame(-.1, .1, -.1, .1) for i in range(9): b = Box(geomnode=cm.generate()) gbox.append(b) label = DirectButton(text="Hello.") label.setScale(0.2) b.fill(label) base.accept('mouse1', zcanvas.drag) base.accept('mouse1-up', zcanvas.drop) zcanvas.message("""You can put DirectGUI widgets in boxlists too.""") run()
def layout(self): if self.keep_sorted == True: self.sort() GridBoxList.layout(self)
hbox.setPos(-.5,0,.4) hbox.reparentTo(zcanvas.home) for i in range(5): b = Box(geomnode=DemoItem.cm.generate()) hbox.append(b) i = DemoItem() b.fill(i) vbox = VBoxList() vbox.setPos(-.5,0,.25) vbox.reparentTo(zcanvas.home) for i in range(5): b = Box(geomnode=DemoItem.cm.generate()) vbox.append(b) gbox = GridBoxList(columns=3) gbox.setPos(.1,0,.1) gbox.reparentTo(zcanvas.home) for i in range(9): b = Box(geomnode=DemoItem.cm.generate()) gbox.append(b) base.accept('mouse1',zcanvas.drag) base.accept('mouse1-up',zcanvas.drop) zcanvas.message( """Drag the demo items (in white) and drop them onto the boxes (in black).""" ) run()