mirror of
https://github.com/clockworkpi/launcher_deot.git
synced 2026-05-03 15:30:07 +02:00
add loop scroll
This commit is contained in:
@@ -115,6 +115,8 @@ class RomListPage(Page):
|
|||||||
_RomSoConfirmDownloadPage = None
|
_RomSoConfirmDownloadPage = None
|
||||||
|
|
||||||
_Backspace = False
|
_Backspace = False
|
||||||
|
|
||||||
|
_ItemsPerPage = 6
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Page.__init__(self)
|
Page.__init__(self)
|
||||||
@@ -294,7 +296,8 @@ class RomListPage(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:
|
||||||
|
if len(self._MyList) <= 1:
|
||||||
return
|
return
|
||||||
|
|
||||||
tmp = self._PsIndex
|
tmp = self._PsIndex
|
||||||
@@ -302,7 +305,7 @@ class RomListPage(Page):
|
|||||||
|
|
||||||
if self._PsIndex < 0:
|
if self._PsIndex < 0:
|
||||||
# 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 = tmp - self._PsIndex
|
||||||
dy = abs(tmp - self._PsIndex)
|
dy = abs(tmp - self._PsIndex)
|
||||||
@@ -313,15 +316,21 @@ class RomListPage(Page):
|
|||||||
self._Scrolled += dy
|
self._Scrolled += dy
|
||||||
|
|
||||||
# loop scroll, to end
|
# loop scroll, to end
|
||||||
# dy - 5: 6 items on screen, 6 - 1 = 5
|
|
||||||
if self._PsIndex == len(self._MyList) - 1:
|
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)):
|
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._Scrolled -= dy
|
||||||
|
self._ItemsPerPage = 6 # reset to 6
|
||||||
|
|
||||||
def ScrollDown(self):
|
def ScrollDown(self):
|
||||||
if len(self._MyList) == 0:
|
# if len(self._MyList) == 0:
|
||||||
|
if len(self._MyList) <= 1:
|
||||||
return
|
return
|
||||||
|
|
||||||
tmp = self._PsIndex
|
tmp = self._PsIndex
|
||||||
self._PsIndex +=self._ScrollStep
|
self._PsIndex +=self._ScrollStep
|
||||||
|
|
||||||
@@ -338,12 +347,16 @@ class RomListPage(Page):
|
|||||||
self._Scrolled -= dy
|
self._Scrolled -= dy
|
||||||
|
|
||||||
# loop scroll, to first
|
# loop scroll, to first
|
||||||
# dy - 5: 6 items on screen, 6 - 1 = 5
|
|
||||||
if self._PsIndex == 0:
|
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)):
|
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._Scrolled += dy
|
||||||
|
self._ItemsPerPage = 6 # reset to 6
|
||||||
|
|
||||||
def SyncScroll(self):
|
def SyncScroll(self):
|
||||||
##
|
##
|
||||||
if self._Scrolled == 0:
|
if self._Scrolled == 0:
|
||||||
@@ -452,7 +465,10 @@ class RomListPage(Page):
|
|||||||
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):
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user