Browse Source

update scroll func

hi80482 3 years ago
parent
commit
0f2f4688f0
1 changed files with 22 additions and 80 deletions
  1. 22 80
      Menu/GameShell/95_Music Player/play_list_page.py

+ 22 - 80
Menu/GameShell/95_Music Player/play_list_page.py

@@ -71,14 +71,12 @@ class PlayListPage(Page):
     _BGwidth = 75
     _BGheight = 70
 
-    _Scrolled = 0
+    # _Scrolled = 0
 
     _CurSongName = ""
 
     _Backspace = False
 
-    _ItemsPerPage = 6
-
     def __init__(self):
         self._Icons = {}
         Page.__init__(self)
@@ -223,74 +221,20 @@ class PlayListPage(Page):
                 # self._MyList[i]._PosY -= self._MyList[i]._Height
             # self._Scrolled -=1
 
-    def ScrollUp(self):
-        if len(self._MyList) <= 1:
-            return
-        
-        tmp = self._PsIndex
-        self._PsIndex -= self._ScrollStep
-        
-        if self._PsIndex < 0:
-            self._PsIndex = len(self._MyList) - 1   # to end
-
-        dy = abs(tmp - self._PsIndex)
-        cur_li = self._MyList[self._PsIndex]
-        if cur_li._PosY < 0:
-            for i in range(0, len(self._MyList)):
-                self._MyList[i]._PosY += self._MyList[i]._Height * dy
-            self._Scrolled += dy
-
-        # loop scroll, to end
-        if self._PsIndex == len(self._MyList) - 1:
-            # check items per page
-            if len(self._MyList) > self._ItemsPerPage:
-                self._ItemsPerPage -= 1                 # not include current item
-                for i in range(0, len(self._MyList)):
-                    self._MyList[i]._PosY -= self._MyList[i]._Height * (dy - self._ItemsPerPage)
-            self._Scrolled -= dy
-            self._ItemsPerPage = 6                      # reset to 6
-
-    def ScrollDown(self):
-        if len(self._MyList) <= 1:
-            return
-
-        tmp = self._PsIndex
-        self._PsIndex +=self._ScrollStep
-
-        if self._PsIndex >= len(self._MyList):
-            self._PsIndex = 0   # to first
-
-        dy = abs(self._PsIndex - tmp)
-        cur_li = self._MyList[self._PsIndex]
-        if cur_li._PosY + cur_li._Height > self._Height:
-            for i in range(0,len(self._MyList)):
-                self._MyList[i]._PosY -= self._MyList[i]._Height * dy
-            self._Scrolled -= dy
-
-        # loop scroll, to first
-        if self._PsIndex == 0:
-            # check items per page
-            if len(self._MyList) > self._ItemsPerPage:
-                self._ItemsPerPage -= 1                 # not include current item
-                for i in range(0, len(self._MyList)):
-                    self._MyList[i]._PosY += self._MyList[i]._Height * (dy - self._ItemsPerPage)
-            self._Scrolled += dy
-            self._ItemsPerPage = 6                      # reset to 6
-
-    def SyncScroll(self):# show where it left
-        if self._Scrolled == 0:
-            return
+    # def SyncScroll(self):# show where it left
+        # if self._Scrolled == 0:
+            # return
 
-        if self._PsIndex < len(self._MyList):
-            cur_li = self._MyList[self._PsIndex]
-            if self._Scrolled > 0:
-                if cur_li._PosY < 0:
-                    for i in range(0, len(self._MyList)):
-                        self._MyList[i]._PosY += self._Scrolled * self._MyList[i]._Height
-            elif self._Scrolled < 0:
-                if cur_li._PosY +cur_li._Height > self._Height:
-                    for i in range(0,len(self._MyList)):
-                        self._MyList[i]._PosY += self._Scrolled * self._MyList[i]._Height
+        # if self._PsIndex < len(self._MyList):
+            # cur_li = self._MyList[self._PsIndex]
+            # if self._Scrolled > 0:
+                # if cur_li._PosY < 0:
+                    # for i in range(0, len(self._MyList)):
+                        # self._MyList[i]._PosY += self._Scrolled * self._MyList[i]._Height
+            # elif self._Scrolled < 0:
+                # if cur_li._PosY +cur_li._Height > self._Height:
+                    # for i in range(0,len(self._MyList)):
+                        # self._MyList[i]._PosY += self._Scrolled * self._MyList[i]._Height
             
     def Click(self):
         if len(self._MyList) == 0:
@@ -320,12 +264,16 @@ class PlayListPage(Page):
             self._Screen.SwapAndShow()
         
         if event.key == CurKeys["Up"]:
-            self.ScrollUp()
+            # self.ScrollUp()
+            self.SpeedScroll(event.key)
+            self.ScrollUp(self._ScrollStep)
             self._Screen.Draw()
             self._Screen.SwapAndShow()
 
         if event.key == CurKeys["Down"]:
-            self.ScrollDown()
+            # self.ScrollDown()
+            self.SpeedScroll(event.key)
+            self.ScrollDown(self._ScrollStep)
             self._Screen.Draw()
             self._Screen.SwapAndShow()
 
@@ -336,20 +284,14 @@ class PlayListPage(Page):
                 self._Screen.PushCurPage()
                 self._Screen.SetCurPage(myvars.MusicLibListPage)
             else:
-                move = 6
-
-                for i in range(move):
-                    self.ScrollDown()
+                self.ScrollDown(5)
 
             self._Screen.Draw()
             self._Screen.SwapAndShow()
 
         if event.key == CurKeys["Left"]:
             if self._Backspace:
-                move = 6
-
-                for i in range(move):
-                    self.ScrollUp()
+                self.ScrollUp(5)
 
             self._Screen.Draw()
             self._Screen.SwapAndShow()