Go to the documentation of this file.00001 import BigWorld, GUI, Math, Keys
00002
00003 from PyGUIBase import PyGUIBase
00004
00005 """
00006 This class implements a smooth moving gui control. The gui
00007 control must have a matrix shader attached called transform
00008 since we refer directly to "self.component.transfor" in the SmoothMover.
00009 """
00010 class SmoothMover( PyGUIBase ):
00011
00012 factoryString="PyGUI.SmoothMover"
00013
00014 def __init__( self, component ):
00015 PyGUIBase.__init__( self, component )
00016 self.minScroll = [0,0]
00017 self.maxScroll = [0,0]
00018 self.scroll = [0,0]
00019 self.scrollSpeed = 0.5
00020 self.scrollTransform = Math.Matrix()
00021 self.scrollTransform.setIdentity()
00022
00023 def scrollTo( self, x, y, animate=True ):
00024 self.scroll[0] = max( x, self.minScroll[0] )
00025 self.scroll[0] = min( self.scroll[0], self.maxScroll[0] )
00026 self.scroll[1] = max( y, self.minScroll[1] )
00027 self.scroll[1] = min( self.scroll[1], self.maxScroll[1] )
00028 self.scrollTransform.setTranslate((self.scroll[0],self.scroll[1],0))
00029 self.component.transform.target = self.scrollTransform
00030 self.component.transform.eta = self.scrollSpeed if animate else 0.0
00031
00032 def scrollBy( self, x, y ):
00033 self.scrollTo( self.scroll[0] + x, self.scroll[1] + y )
00034
00035 def canScrollUp( self ):
00036 return (self.scroll[1] > self.minScroll[1]+0.0001)
00037
00038 def canScrollDown( self ):
00039 return (self.scroll[1] < self.maxScroll[1]-0.0001)
00040
00041 def canScrollLeft( self ):
00042 return (self.scroll[0] > self.minScroll[0]+0.0001)
00043
00044 def canScrollRight( self ):
00045 return (self.scroll[0] < self.maxScroll[0]-0.0001)
00046