Browse Source

Added support for inverted scrollbar, values descend from top to bottom

M. Ian Graham 18 years ago
parent
commit
0f403bca36
2 changed files with 20 additions and 1 deletions
  1. 1 0
      direct/src/gui/DirectGuiGlobals.py
  2. 19 1
      direct/src/gui/DirectScrollBar.py

+ 1 - 0
direct/src/gui/DirectGuiGlobals.py

@@ -45,6 +45,7 @@ FrameStyleDict = {'flat': FLAT, 'raised': RAISED, 'sunken': SUNKEN,
 # Orientation of DirectSlider and DirectScrollBar
 # Orientation of DirectSlider and DirectScrollBar
 HORIZONTAL = 'horizontal'
 HORIZONTAL = 'horizontal'
 VERTICAL = 'vertical'
 VERTICAL = 'vertical'
+VERTICAL_INVERTED = 'vertical_inverted'
 
 
 # Dialog button values
 # Dialog button values
 DIALOG_NO = 0
 DIALOG_NO = 0

+ 19 - 1
direct/src/gui/DirectScrollBar.py

@@ -38,7 +38,7 @@ class DirectScrollBar(DirectFrame):
             ('extraArgs',      [],                 None),
             ('extraArgs',      [],                 None),
             )
             )
 
 
-        if kw.get('orientation') == DGG.VERTICAL:
+        if kw.get('orientation') in (DGG.VERTICAL, DGG.VERTICAL_INVERTED):
             # These are the default options for a vertical layout.
             # These are the default options for a vertical layout.
             optiondefs += (
             optiondefs += (
                 ('frameSize',      (-0.04, 0.04, -0.5, 0.5),   None),
                 ('frameSize',      (-0.04, 0.04, -0.5, 0.5),   None),
@@ -68,6 +68,22 @@ class DirectScrollBar(DirectFrame):
             DirectButton, (self,),
             DirectButton, (self,),
             borderWidth = self['borderWidth'])
             borderWidth = self['borderWidth'])
 
 
+        if self.decButton['frameSize'] == None and \
+           self.decButton.bounds == [0.0, 0.0, 0.0, 0.0]:
+            f = self['frameSize']
+            if self['orientation'] == DGG.HORIZONTAL:
+                self.decButton['frameSize'] = (f[0]*0.05, f[1]*0.05, f[2], f[3])
+            else:
+                self.decButton['frameSize'] = (f[0], f[1], f[2]*0.05, f[3]*0.05)
+
+        if self.incButton['frameSize'] == None and \
+           self.incButton.bounds == [0.0, 0.0, 0.0, 0.0]:
+            f = self['frameSize']
+            if self['orientation'] == DGG.HORIZONTAL:
+                self.incButton['frameSize'] = (f[0]*0.05, f[1]*0.05, f[2], f[3])
+            else:
+                self.incButton['frameSize'] = (f[0], f[1], f[2]*0.05, f[3]*0.05)
+
         self.guiItem.setThumbButton(self.thumb.guiItem)
         self.guiItem.setThumbButton(self.thumb.guiItem)
         self.guiItem.setLeftButton(self.decButton.guiItem)
         self.guiItem.setLeftButton(self.decButton.guiItem)
         self.guiItem.setRightButton(self.incButton.guiItem)
         self.guiItem.setRightButton(self.incButton.guiItem)
@@ -123,6 +139,8 @@ class DirectScrollBar(DirectFrame):
             self.guiItem.setAxis(Vec3(1, 0, 0))
             self.guiItem.setAxis(Vec3(1, 0, 0))
         elif self['orientation'] == DGG.VERTICAL:
         elif self['orientation'] == DGG.VERTICAL:
             self.guiItem.setAxis(Vec3(0, 0, -1))
             self.guiItem.setAxis(Vec3(0, 0, -1))
+        elif self['orientation'] == DGG.VERTICAL_INVERTED:
+            self.guiItem.setAxis(Vec3(0, 0, 1))
         else:
         else:
             raise ValueError, 'Invalid value for orientation: %s' % (self['orientation'])
             raise ValueError, 'Invalid value for orientation: %s' % (self['orientation'])