mirror of
https://github.com/clockworkpi/launcher_deot.git
synced 2026-01-02 09:48:57 +01:00
add loop scroll
This commit is contained in:
parent
fe601a0696
commit
bfc849dbc4
@ -115,6 +115,8 @@ class RomListPage(Page):
|
||||
_RomSoConfirmDownloadPage = None
|
||||
|
||||
_Backspace = False
|
||||
|
||||
_ItemsPerPage = 6
|
||||
|
||||
def __init__(self):
|
||||
Page.__init__(self)
|
||||
@ -294,7 +296,8 @@ class RomListPage(Page):
|
||||
self._RomSoConfirmDownloadPage = rom_so_confirm_page
|
||||
|
||||
def ScrollUp(self):
|
||||
if len(self._MyList) == 0:
|
||||
# if len(self._MyList) == 0:
|
||||
if len(self._MyList) <= 1:
|
||||
return
|
||||
|
||||
tmp = self._PsIndex
|
||||
@ -302,7 +305,7 @@ class RomListPage(Page):
|
||||
|
||||
if self._PsIndex < 0:
|
||||
# self._PsIndex = 0
|
||||
self._PsIndex = len(self._MyList) -1 # to end
|
||||
self._PsIndex = len(self._MyList) - 1 # to end
|
||||
|
||||
# dy = tmp - self._PsIndex
|
||||
dy = abs(tmp - self._PsIndex)
|
||||
@ -313,15 +316,21 @@ class RomListPage(Page):
|
||||
self._Scrolled += dy
|
||||
|
||||
# loop scroll, to end
|
||||
# dy - 5: 6 items on screen, 6 - 1 = 5
|
||||
if self._PsIndex == len(self._MyList) - 1:
|
||||
# check items per page
|
||||
if len(self._MyList) < self._ItemsPerPage:
|
||||
self._ItemsPerPage = len(self._MyList)
|
||||
self._ItemsPerPage -= 1 # not include current item
|
||||
for i in range(0, len(self._MyList)):
|
||||
self._MyList[i]._PosY -= self._MyList[i]._Height * (dy - 5)
|
||||
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:
|
||||
# if len(self._MyList) == 0:
|
||||
if len(self._MyList) <= 1:
|
||||
return
|
||||
|
||||
tmp = self._PsIndex
|
||||
self._PsIndex +=self._ScrollStep
|
||||
|
||||
@ -338,12 +347,16 @@ class RomListPage(Page):
|
||||
self._Scrolled -= dy
|
||||
|
||||
# loop scroll, to first
|
||||
# dy - 5: 6 items on screen, 6 - 1 = 5
|
||||
if self._PsIndex == 0:
|
||||
# check items per page
|
||||
if len(self._MyList) < self._ItemsPerPage:
|
||||
self._ItemsPerPage = len(self._MyList)
|
||||
self._ItemsPerPage -= 1 # not include current item
|
||||
for i in range(0, len(self._MyList)):
|
||||
self._MyList[i]._PosY += self._MyList[i]._Height * (dy - 5)
|
||||
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._Scrolled == 0:
|
||||
@ -452,7 +465,10 @@ class RomListPage(Page):
|
||||
cur_time = time.time()
|
||||
|
||||
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):
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user