瀏覽代碼

*** empty log message ***

David Rose 25 年之前
父節點
當前提交
98c7ea7507
共有 3 個文件被更改,包括 26 次插入3 次删除
  1. 19 0
      direct/src/gui/Button.py
  2. 1 1
      direct/src/gui/Label.py
  3. 6 2
      direct/src/gui/OnscreenPanel.py

+ 19 - 0
direct/src/gui/Button.py

@@ -16,16 +16,22 @@ class Button(DirectObject):
                  pos = (0, 0),
                  pos = (0, 0),
                  geomRect = None,
                  geomRect = None,
                  supportInactive = 0,
                  supportInactive = 0,
+                 inactive = 0,
                  upStyle = Label.ButtonUp,
                  upStyle = Label.ButtonUp,
                  litStyle = Label.ButtonLit,
                  litStyle = Label.ButtonLit,
                  downStyle = Label.ButtonDown,
                  downStyle = Label.ButtonDown,
                  inactiveStyle = Label.ButtonInactive):
                  inactiveStyle = Label.ButtonInactive):
         self.name = name
         self.name = name
         self.width = width
         self.width = width
+        
         # if no label given, use the button name
         # if no label given, use the button name
         if (label == None):
         if (label == None):
             label = self.name
             label = self.name
 
 
+        self.inactive = inactive
+        if inactive:
+            supportInactive = 1
+
         # check to see if this is an actual guiLabel or just text
         # check to see if this is an actual guiLabel or just text
         if (type(label) == type('')):
         if (type(label) == type('')):
             # text label, make text button
             # text label, make text button
@@ -125,6 +131,15 @@ class Button(DirectObject):
         self.lDown.setWidth(width)
         self.lDown.setWidth(width)
         self.lInactive.setWidth(width)
         self.lInactive.setWidth(width)
 
 
+    def setInactive(self, inactive):
+        self.inactive = inactive
+        if self.managed:
+            self.button.exit()
+            if self.inactive:
+                self.button.inactive()
+            else:
+                self.button.up()
+
     def manage(self, nodepath = aspect2d):
     def manage(self, nodepath = aspect2d):
         if nodepath:
         if nodepath:
             self.button.manage(guiMgr, base.eventMgr.eventHandler,
             self.button.manage(guiMgr, base.eventMgr.eventHandler,
@@ -133,6 +148,10 @@ class Button(DirectObject):
             self.button.manage(guiMgr, base.eventMgr.eventHandler)
             self.button.manage(guiMgr, base.eventMgr.eventHandler)
         self.managed = 1
         self.managed = 1
 
 
+        if self.inactive:
+            self.button.exit()
+            self.button.inactive()
+
     def unmanage(self):
     def unmanage(self):
         self.button.unmanage()
         self.button.unmanage()
         self.managed = 0
         self.managed = 0

+ 1 - 1
direct/src/gui/Label.py

@@ -92,7 +92,7 @@ def textLabelAndText(string, style,
     elif style == ButtonInactive:
     elif style == ButtonInactive:
         # When the button is inactive, it's gray on gray.
         # When the button is inactive, it's gray on gray.
         text.setTextColor(0.4, 0.4, 0.4, 1.0)
         text.setTextColor(0.4, 0.4, 0.4, 1.0)
-        text.setCardColor(0.6, 0.6, 0.6, 1.0)
+        text.setCardColor(0.9, 0.9, 0.9, 1.0)
         
         
     elif style == Sign:
     elif style == Sign:
         # For a sign, we want red text with no background card.
         # For a sign, we want red text with no background card.

+ 6 - 2
direct/src/gui/OnscreenPanel.py

@@ -240,7 +240,9 @@ class OnscreenPanel(PandaObject.PandaObject, NodePath):
                    drawOrder = None,
                    drawOrder = None,
                    font = None,
                    font = None,
                    pos = (0, 0),
                    pos = (0, 0),
-                   geomRect = None):
+                   geomRect = None,
+                   supportInactive = 0,
+                   inactive = 0):
         """makeButton(self, ...)
         """makeButton(self, ...)
 
 
         Creates a button on the panel.  The return value is the button
         Creates a button on the panel.  The return value is the button
@@ -274,7 +276,9 @@ class OnscreenPanel(PandaObject.PandaObject, NodePath):
                                drawOrder = drawOrder,
                                drawOrder = drawOrder,
                                font = font,
                                font = font,
                                pos = pos,
                                pos = pos,
-                               geomRect = geomRect)
+                               geomRect = geomRect,
+                               supportInactive = supportInactive,
+                               inactive = inactive)
 
 
         self.panelButtons.append(button)
         self.panelButtons.append(button)