disable scroll func

This commit is contained in:
hi80482 2020-07-31 18:34:26 +08:00 committed by GitHub
parent ca1e4cfe91
commit 50bbed5691
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -98,14 +98,13 @@ class FavListPage(Page):
_Emulator = None _Emulator = None
_Parent = None _Parent = None
_Scroller = None _Scroller = None
_Scrolled = 0 # _Scrolled = 0
_BGwidth = 75 _BGwidth = 75
_BGheight = 73 _BGheight = 73
_RomSoConfirmDownloadPage = None _RomSoConfirmDownloadPage = None
_Backspace = False _Backspace = False
_ItemsPerPage = 6
def __init__(self): def __init__(self):
Page.__init__(self) Page.__init__(self)
@ -260,78 +259,52 @@ class FavListPage(Page):
self._RomSoConfirmDownloadPage = rom_so_confirm_page self._RomSoConfirmDownloadPage = rom_so_confirm_page
def ScrollUp(self): # def ScrollUp(self):
if len(self._MyList) == 0: # if len(self._MyList) == 0:
return # return
tmp = self._PsIndex # tmp = self._PsIndex
self._PsIndex -= self._ScrollStep # self._PsIndex -= self._ScrollStep
if self._PsIndex < 0: # if self._PsIndex < 0:
# self._PsIndex = 0 # self._PsIndex = 0
self._PsIndex = len(self._MyList) -1 # to end
# dy = tmp - self._PsIndex # dy = tmp - self._PsIndex
dy = abs(tmp - self._PsIndex) # cur_li = self._MyList[self._PsIndex]
cur_li = self._MyList[self._PsIndex] # if cur_li._PosY < 0:
if cur_li._PosY < 0: # for i in range(0, len(self._MyList)):
for i in range(0, len(self._MyList)): # self._MyList[i]._PosY += self._MyList[i]._Height*dy
self._MyList[i]._PosY += self._MyList[i]._Height * dy # self._Scrolled +=dy
self._Scrolled += dy
# loop scroll, to end # def ScrollDown(self):
if self._PsIndex == len(self._MyList) - 1: # if len(self._MyList) == 0:
# check items per page # return
if len(self._MyList) > self._ItemsPerPage: # tmp = self._PsIndex
self._ItemsPerPage -= 1 # not include current item # self._PsIndex +=self._ScrollStep
for i in range(0, len(self._MyList)): # if self._PsIndex >= 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) == 0:
return
tmp = self._PsIndex
self._PsIndex +=self._ScrollStep
if self._PsIndex >= len(self._MyList):
# self._PsIndex = len(self._MyList) -1 # self._PsIndex = len(self._MyList) -1
self._PsIndex = 0 # to first
# dy = self._PsIndex - tmp # dy = self._PsIndex - tmp
dy = abs(self._PsIndex - tmp) # cur_li = self._MyList[self._PsIndex]
cur_li = self._MyList[self._PsIndex] # if cur_li._PosY +cur_li._Height > self._Height:
if cur_li._PosY + cur_li._Height > self._Height: # for i in range(0,len(self._MyList)):
for i in range(0,len(self._MyList)): # self._MyList[i]._PosY -= self._MyList[i]._Height*dy
self._MyList[i]._PosY -= self._MyList[i]._Height * dy # self._Scrolled -= dy
self._Scrolled -= dy
# loop scroll, to first # def SyncScroll(self):
if self._PsIndex == 0: #
# check items per page # if self._Scrolled == 0:
if len(self._MyList) > self._ItemsPerPage: # return
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): # if self._PsIndex < len(self._MyList):
## # cur_li = self._MyList[self._PsIndex]
if self._Scrolled == 0: # if self._Scrolled > 0:
return # if cur_li._PosY < 0:
# for i in range(0, len(self._MyList)):
if self._PsIndex < len(self._MyList): # self._MyList[i]._PosY += self._Scrolled * self._MyList[i]._Height
cur_li = self._MyList[self._PsIndex] # elif self._Scrolled < 0:
if self._Scrolled > 0: # if cur_li._PosY +cur_li._Height > self._Height:
if cur_li._PosY < 0: # for i in range(0,len(self._MyList)):
for i in range(0, len(self._MyList)): # self._MyList[i]._PosY += self._Scrolled * self._MyList[i]._Height
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): def Click(self):
@ -412,21 +385,18 @@ class FavListPage(Page):
self._Screen.Draw() self._Screen.Draw()
self._Screen.SwapAndShow() self._Screen.SwapAndShow()
def SpeedScroll(self, thekey): # def SpeedScroll(self, thekey):
if self._Screen._LastKey == thekey: # if self._Screen._LastKey == thekey:
self._ScrollStep+=1 # self._ScrollStep+=1
if self._ScrollStep >=5: # if self._ScrollStep >=5:
self._ScrollStep = 5 # self._ScrollStep = 5
else: # else:
self._ScrollStep = 1 # self._ScrollStep = 1
cur_time = time.time() # cur_time = time.time()
if cur_time - self._Screen._LastKeyDown > 0.3: # if cur_time - self._Screen._LastKeyDown > 0.3:
self._ScrollStep = 1 # self._ScrollStep = 1
if len(self._MyList) < self._ItemsPerPage:
self._ScrollStep = 1
def KeyDown(self,event): def KeyDown(self,event):
@ -442,10 +412,7 @@ class FavListPage(Page):
if event.key == CurKeys["Right"]: if event.key == CurKeys["Right"]:
if self._Backspace: if self._Backspace:
move = 6 self.ScrollDown(5)
for i in range(move):
self.ScrollDown()
self._Screen.Draw() self._Screen.Draw()
self._Screen.SwapAndShow() self._Screen.SwapAndShow()
@ -454,23 +421,22 @@ class FavListPage(Page):
if not self._Backspace: if not self._Backspace:
self.ReturnToUpLevelPage() self.ReturnToUpLevelPage()
else: else:
move = 6 self.ScrollUp(5)
for i in range(move):
self.ScrollUp()
self._Screen.Draw() self._Screen.Draw()
self._Screen.SwapAndShow() self._Screen.SwapAndShow()
if event.key == CurKeys["Up"]: if event.key == CurKeys["Up"]:
self.SpeedScroll(event.key) self.SpeedScroll(event.key)
self.ScrollUp() # self.ScrollUp()
self.ScrollUp(self._ScrollStep)
self._Screen.Draw() self._Screen.Draw()
self._Screen.SwapAndShow() self._Screen.SwapAndShow()
if event.key == CurKeys["Down"]: if event.key == CurKeys["Down"]:
self.SpeedScroll(event.key) self.SpeedScroll(event.key)
self.ScrollDown() # self.ScrollDown()
self.ScrollDown(self._ScrollStep)
self._Screen.Draw() self._Screen.Draw()
self._Screen.SwapAndShow() self._Screen.SwapAndShow()