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

This commit is contained in:
M. Ian Graham 2007-10-24 05:43:49 +00:00
parent f87df647a8
commit 0f403bca36
2 changed files with 20 additions and 1 deletions

View File

@ -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

View File

@ -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'])