コード例 #1
0
    def addItem(self, item, func = None, placement = Placement.Below):
        self._items.append(item)
        if(self.width < item.width):
            self.width = item.width
            self.adjustSeps()

        #pdb.set_trace()
        if placement == Panel.Placement.Below:
            item.pos = self.belowPos
            self.rightPos = self.belowPos + point2(item.width + self.xgap, 0)
            self.belowPos = point2(0, self.belowPos.y + item.height + self.ygap)

        elif placement == Panel.Placement.Right:
            item.pos = self.rightPos
            self.rightPos = self.rightPos + point2(item.width + self.xgap, 0)

        if self.rightPos.x > self.width:
            self.width = self.rightPos.x

        if self.belowPos.y > self.height:
            self.height = self.belowPos.y
        #self.height += item.height

        #print 'Panel.addItem', self, item, placement, item.pos, self.belowPos, self.rightPos

        self.panel.addChild(item.getOverlayElementToAdd())

        self.panel.setDimensions(self.width, self.height)
        self.addSep(self.height)
コード例 #2
0
ファイル: widget.py プロジェクト: bgaunt/openEcslent
 def __init__(self, engine, name = "TopMenuItem", pos = (0, 0), size = (100, 15), func = None, material="ECSLENT/navy/material/rmenu"):
     MenuItem.__init__(self, engine, parent = None, name = name, pos = pos, size = size, func = func, material = material)
     # these should be generalized to respond to events
     self._subMenu.pos = point2(0, self.height + self.ygap + self.lheight)
     self.registerEventHandlers()
     self.hide()
     self.isActive = False
コード例 #3
0
ファイル: widget.py プロジェクト: bgaunt/openEcslent
    def __init__(self, engine, parent = None, pos=None, size=None):
        if pos is None: #if we default parameter these all objects will share a common instantiation which WILL cause nightmares
            pos = point2(0,0)
        if size is None: #if we default parameter these all objects will share a common instantiation which WILL cause nightmares
            size = point2(100,13)

        EngineObject.__init__(self, engine)
        assert engine is not None
        if type(pos) is tuple:
            pos = point2(*pos)
        if type(size) is tuple:
            size = point2(*size)

        self._pos = pos
        self._size = size
        self.engine = engine
        self.parent = parent
コード例 #4
0
    def __init__(self, engine, parent = None, pos=None, size=None):
        if pos is None: #if we default parameter these all objects will share a common instantiation which WILL cause nightmares
            pos = point2(0,0)
        if size is None: #if we default parameter these all objects will share a common instantiation which WILL cause nightmares
            #size = point2(100,13)
            size = point2(100,20)

        #EngineObject.__init__(self, engine)
        assert engine is not None
        if type(pos) is tuple:
            pos = point2(*pos)
        if type(size) is tuple:
            size = point2(*size)

        self._pos = pos
        self._size = size
        self.engine = engine
        self.parent = parent
コード例 #5
0
ファイル: widget.py プロジェクト: bgaunt/openEcslent
 def tick(self, dtime):
     ent = self.engine.inputSystem.entUnderMouse
     if ent:
         ms = self.engine.inputSystem.mouse.getMouseState()
         self.pos = point2(ms.X.abs + 20 , ms.Y.abs + 20)
         self.show()
         self.updateLabels(ent)
     else:
         self.hide()
コード例 #6
0
ファイル: widgetMgr.py プロジェクト: lukefrasera/minecraft
    def __init__(self,
                 engine,
                 parent=None,
                 name="ex.Panel",
                 pos=(0.0, 0.0),
                 size=UIDefaults.PANEL_SIZE,
                 material=None):
        Widget.__init__(self, engine, parent=parent, pos=pos, size=size)
        self.overlayManager = ogre.OverlayManager.getSingleton()

        self.pid = name + str(engine.widgetMgr.getNextId())
        self.panel = self.overlayManager.createOverlayElement(
            "Panel", self.pid)
        self.panel.setMetricsMode(ogre.GMM_PIXELS)  #RELATIVE_ASPECT_ADJUSTED)
        self.panel.setPosition(self.pos.x, self.pos.y)
        #self.panel.setDimensions(self.width, self.height)
        self.height = 0  # otherwise, the panel has extra height when using as a parent for labels and other widgets.
        self.panel.setDimensions(self.width, self.height)
        if material:
            self.panel.setMaterialName(material)

        self.panel.show()

        if not self.parent:
            self.id = name
            self.overlayName = name + str(engine.widgetMgr.getNextId())
            self.overlay = self.overlayManager.create(self.overlayName)
            self.overlay.add2D(self.panel)
            self.overlay.show()
            #print "---------> Created overlay and added panel to overlay: ",  self.overlayName

        self.panel.show()

        self.belowPos = point2(0, 0)
        self.rightPos = point2(0, 0)
        self.xgap = 0
        self.ygap = 0
        self._items = []

        self.lheight = 1
        self._linePanels = []  # used by menu items
        self.addSep(0)
        pass
コード例 #7
0
ファイル: widgetMgr.py プロジェクト: martinsg88/pyogregame
    def __init__(self, engine, parent = None, name = "ex.Panel", pos = (0.0, 0.0), size = UIDefaults.PANEL_SIZE, material = None):
        Widget.__init__(self, engine, parent = parent, pos = pos, size = size)
        self.overlayManager = ogre.OverlayManager.getSingleton()

        self.pid         = name + str(engine.widgetMgr.getNextId())
        self.panel       = self.overlayManager.createOverlayElement("Panel", self.pid)
        self.panel.setMetricsMode(ogre.GMM_PIXELS)#RELATIVE_ASPECT_ADJUSTED)
        self.panel.setPosition(self.pos.x, self.pos.y)
        #self.panel.setDimensions(self.width, self.height)
        self.height = 50 # otherwise, the panel has extra height when using as a parent for labels and other widgets.
        self.panel.setDimensions(self.width, self.height)
        if material:
            self.panel.setMaterialName(material)

        self.panel.show()        

        if not self.parent:
            self.id = name
            self.overlayName = name + str(engine.widgetMgr.getNextId())
            self.overlay     = self.overlayManager.create(self.overlayName)
            self.overlay.add2D(self.panel)
            self.overlay.show()
            #print "---------> Created overlay and added panel to overlay: ",  self.overlayName

        self.panel.show()

        self.belowPos = point2(0,0)
        self.rightPos = point2(0,0)
        self.xgap = 0
        self.ygap = 0
        self._items = []

        self.lheight = 1
        self._linePanels = [] # used by menu items
        self.addSep(0)
        pass
コード例 #8
0
ファイル: widget.py プロジェクト: bgaunt/openEcslent
    def __init__(self, engine, parent = None, name = "ex.MenuItem", pos = (0, 0), size = (100, 15), func = None, material="ECSLENT/navy/material/rmenu"):
        Panel.__init__(self, engine, parent = parent, name = name+"Panel", pos = pos, size = size, material = material)
        self.label = Label(engine, parent = None, caption = name, pos = (0, 0), size = size)
        self.height = 15
        self.label.show()
        self.panel.addChild(self.label.textArea)
        self.name = name
        self.func = func
        self.isSelected = False

        self._subMenu = Panel(engine, parent = self, pos = (0, 0), size = (0, 0), material = material)
        self._subMenu.pos = point2(self.width + self.xgap, 0)
        self.panel.addChild(self._subMenu.panel)
        self._subMenu.hide()

        self.registerEventHandlers()
        self.isActive = False
コード例 #9
0
 def height(self, val):
     self.size = point2(self.size.x, val)
コード例 #10
0
 def width(self, val):
     self.size = point2(val, self.size.y)
コード例 #11
0
ファイル: widget.py プロジェクト: bgaunt/openEcslent
 def handleRightMousePress(self, ms):
     self.pos = point2(ms.X.abs, ms.Y.abs)
     self.clearSelection() # clear selection