예제 #1
0
        self.set_highlightable(True)
        # FIXME. zoomable is required to make highlightable work because of the
        # collision mask. It shouldn't be.
        self.set_zoomable(True)


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)
예제 #2
0
    def __init__(self,function):

        self.function = function
        
        ZNode.__init__(self,geomnode=card(), magnification=.8)        
        self.np.setColor(1,1,1,1)
                
        Draggable.__init__(self)
        Highlightable.__init__(self)

        # Uncomment to apply a texture to the card.
        #tex = loader.loadTexture('card.png')
        #self.np.setTexture(tex)

        # Now to add the DirectGUI widgets onto the card. A StoryCard has two
        # VBoxes containing DirectGUI objects, one that is shown when the card
        # is far from the viewport and displaying itself in low detail, and one
        # that is shown when the viewport is focused on the card and the card is
        # showing itself in high detail.
        self.lowDetailVBox = VBoxList()
        self.highDetailVBox = VBoxList()
        self.lowDetailVBox.reparentTo(self.np)
        self.highDetailVBox.reparentTo(self.np)

        # The title of the function of this card.
        font = 'storymaps/data/TypeWritersSubstitute-Black.ttf'

        title = DirectLabel(text=self.function.name,
                            text_font=loader.loadFont(font),
                            text_bg=(1,1,1,0),
                            frameColor=(1,1,1,1),
                            scale=.7,
                            suppressMouse=0)
        b = Box()
        b.fill(title)                            
        self.lowDetailVBox.append(b)

        title = DirectLabel(text=self.function.name,
                            text_font=loader.loadFont(font),
                            text_bg=(1,1,1,0),
                            frameColor=(1,1,1,1),
                            scale=.7,
                            suppressMouse=0)
        b = Box()
        b.fill(title)                            
        self.highDetailVBox.append(b)

        # The icon of the function of this card. Use Panda's mipmapping
        # to handle scaling the image efficiently.
        tex = loader.loadTexture(function.image)
        tex.setMagfilter(Texture.FTLinearMipmapLinear)
        tex.setMinfilter(Texture.FTLinearMipmapLinear)

        icon = DirectLabel(image=tex)
        icon.setScale(2.5)
        b = Box()
        b.fill(icon)                            
        self.lowDetailVBox.append(b)

        icon = DirectLabel(image=tex)
        b = Box()
        b.fill(icon)                                    
        self.highDetailVBox.append(b)

        # The longer description of the Propp function.
        self.entry  = DirectEntry(initialText=self.function.desc,
                                 text_font=loader.loadFont('storymaps/data/WritersFont.ttf'),
                                 scale=.4,
                                 width=13,
                                 numLines=7,
                                 suppressMouse=0,
                                 frameColor = (1,1,1,1))
        self.entry['state'] = DGG.DISABLED

        b = Box()
        b.setColor(1,1,1,0)
        b.fill(self.entry)                            
        self.highDetailVBox.append(b)

        self.lowDetailVBox.setPos(self.lowDetailVBox.np,-2.6,0,4)
        self.highDetailVBox.setPos(self.lowDetailVBox.getPos())

        self.highDetailVBox.hide()

        # A place for subclasses to put buttons.
        self.buttons = HBoxList()             
        self.buttons.reparentTo(self.np)   
        self.buttons.setScale(.6)
        self.buttons.setPos(-1.8,0,-1.6)
        self.buttons.hide()

        self.disabled = False