From 0f403bca3675ca140512e7d3c0134c3a50b08314 Mon Sep 17 00:00:00 2001 From: "M. Ian Graham" Date: Wed, 24 Oct 2007 05:43:49 +0000 Subject: [PATCH] Added support for inverted scrollbar, values descend from top to bottom --- direct/src/gui/DirectGuiGlobals.py | 1 + direct/src/gui/DirectScrollBar.py | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/direct/src/gui/DirectGuiGlobals.py b/direct/src/gui/DirectGuiGlobals.py index c26220a6b5..d4a42f1e33 100644 --- a/direct/src/gui/DirectGuiGlobals.py +++ b/direct/src/gui/DirectGuiGlobals.py @@ -45,6 +45,7 @@ FrameStyleDict = {'flat': FLAT, 'raised': RAISED, 'sunken': SUNKEN, # Orientation of DirectSlider and DirectScrollBar HORIZONTAL = 'horizontal' VERTICAL = 'vertical' +VERTICAL_INVERTED = 'vertical_inverted' # Dialog button values DIALOG_NO = 0 diff --git a/direct/src/gui/DirectScrollBar.py b/direct/src/gui/DirectScrollBar.py index 2eb50e5816..f69896568b 100644 --- a/direct/src/gui/DirectScrollBar.py +++ b/direct/src/gui/DirectScrollBar.py @@ -38,7 +38,7 @@ class DirectScrollBar(DirectFrame): ('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. optiondefs += ( ('frameSize', (-0.04, 0.04, -0.5, 0.5), None), @@ -68,6 +68,22 @@ class DirectScrollBar(DirectFrame): DirectButton, (self,), 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.setLeftButton(self.decButton.guiItem) self.guiItem.setRightButton(self.incButton.guiItem) @@ -123,6 +139,8 @@ class DirectScrollBar(DirectFrame): self.guiItem.setAxis(Vec3(1, 0, 0)) elif self['orientation'] == DGG.VERTICAL: self.guiItem.setAxis(Vec3(0, 0, -1)) + elif self['orientation'] == DGG.VERTICAL_INVERTED: + self.guiItem.setAxis(Vec3(0, 0, 1)) else: raise ValueError, 'Invalid value for orientation: %s' % (self['orientation'])