mirror of
https://github.com/clockworkpi/launcher.git
synced 2025-12-21 14:18:50 +01:00
add SpeedScroll
This commit is contained in:
parent
f9a74d6579
commit
2e5ea437cd
@ -3,7 +3,7 @@
|
|||||||
import os
|
import os
|
||||||
import pygame
|
import pygame
|
||||||
import glob
|
import glob
|
||||||
|
import time
|
||||||
from libs.roundrects import aa_round_rect
|
from libs.roundrects import aa_round_rect
|
||||||
|
|
||||||
## local UI import
|
## local UI import
|
||||||
@ -255,30 +255,33 @@ class FavListPage(Page):
|
|||||||
if len(self._MyList) == 0:
|
if len(self._MyList) == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
self._PsIndex -= 1
|
tmp = self._PsIndex
|
||||||
|
self._PsIndex -= self._ScrollStep
|
||||||
|
|
||||||
if self._PsIndex < 0:
|
if self._PsIndex < 0:
|
||||||
self._PsIndex = 0
|
self._PsIndex = 0
|
||||||
|
dy = 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
|
self._MyList[i]._PosY += self._MyList[i]._Height*dy
|
||||||
|
self._Scrolled +=dy
|
||||||
self._Scrolled += 1
|
|
||||||
|
|
||||||
def ScrollDown(self):
|
def ScrollDown(self):
|
||||||
if len(self._MyList) == 0:
|
if len(self._MyList) == 0:
|
||||||
return
|
return
|
||||||
|
tmp = self._PsIndex
|
||||||
self._PsIndex +=1
|
self._PsIndex +=self._ScrollStep
|
||||||
if self._PsIndex >= len(self._MyList):
|
if self._PsIndex >= len(self._MyList):
|
||||||
self._PsIndex = len(self._MyList) -1
|
self._PsIndex = len(self._MyList) -1
|
||||||
|
|
||||||
|
dy = 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
|
self._MyList[i]._PosY -= self._MyList[i]._Height*dy
|
||||||
self._Scrolled -=1
|
self._Scrolled -= dy
|
||||||
|
|
||||||
def SyncScroll(self):
|
def SyncScroll(self):
|
||||||
##
|
##
|
||||||
if self._Scrolled == 0:
|
if self._Scrolled == 0:
|
||||||
@ -374,6 +377,19 @@ class FavListPage(Page):
|
|||||||
self._Screen.Draw()
|
self._Screen.Draw()
|
||||||
self._Screen.SwapAndShow()
|
self._Screen.SwapAndShow()
|
||||||
|
|
||||||
|
def SpeedScroll(self, thekey):
|
||||||
|
if self._Screen._LastKey == thekey:
|
||||||
|
self._ScrollStep+=1
|
||||||
|
if self._ScrollStep >=5:
|
||||||
|
self._ScrollStep = 5
|
||||||
|
else:
|
||||||
|
self._ScrollStep = 1
|
||||||
|
|
||||||
|
cur_time = time.time()
|
||||||
|
|
||||||
|
if cur_time - self._Screen._LastKeyDown > 0.3:
|
||||||
|
self._ScrollStep = 1
|
||||||
|
|
||||||
def KeyDown(self,event):
|
def KeyDown(self,event):
|
||||||
|
|
||||||
if event.key == CurKeys["Menu"] or event.key == CurKeys["Left"]:
|
if event.key == CurKeys["Menu"] or event.key == CurKeys["Left"]:
|
||||||
@ -383,10 +399,12 @@ class FavListPage(Page):
|
|||||||
|
|
||||||
|
|
||||||
if event.key == CurKeys["Up"]:
|
if event.key == CurKeys["Up"]:
|
||||||
|
self.SpeedScroll(event.key)
|
||||||
self.ScrollUp()
|
self.ScrollUp()
|
||||||
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.ScrollDown()
|
self.ScrollDown()
|
||||||
self._Screen.Draw()
|
self._Screen.Draw()
|
||||||
self._Screen.SwapAndShow()
|
self._Screen.SwapAndShow()
|
||||||
|
|||||||
@ -9,7 +9,7 @@ import shutil
|
|||||||
import gobject
|
import gobject
|
||||||
import validators
|
import validators
|
||||||
#from pySmartDL import SmartDL
|
#from pySmartDL import SmartDL
|
||||||
|
import time
|
||||||
|
|
||||||
from libs.roundrects import aa_round_rect
|
from libs.roundrects import aa_round_rect
|
||||||
|
|
||||||
@ -114,8 +114,8 @@ class RomListPage(Page):
|
|||||||
_BGheight = 70
|
_BGheight = 70
|
||||||
|
|
||||||
_RomSoConfirmDownloadPage = None
|
_RomSoConfirmDownloadPage = None
|
||||||
|
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
Page.__init__(self)
|
Page.__init__(self)
|
||||||
|
|
||||||
@ -289,28 +289,32 @@ class RomListPage(Page):
|
|||||||
if len(self._MyList) == 0:
|
if len(self._MyList) == 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
self._PsIndex -= 1
|
tmp = self._PsIndex
|
||||||
|
self._PsIndex -= self._ScrollStep
|
||||||
|
|
||||||
if self._PsIndex < 0:
|
if self._PsIndex < 0:
|
||||||
self._PsIndex = 0
|
self._PsIndex = 0
|
||||||
|
dy = 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
|
self._MyList[i]._PosY += self._MyList[i]._Height*dy
|
||||||
self._Scrolled +=1
|
self._Scrolled +=dy
|
||||||
|
|
||||||
def ScrollDown(self):
|
def ScrollDown(self):
|
||||||
if len(self._MyList) == 0:
|
if len(self._MyList) == 0:
|
||||||
return
|
return
|
||||||
|
tmp = self._PsIndex
|
||||||
self._PsIndex +=1
|
self._PsIndex +=self._ScrollStep
|
||||||
if self._PsIndex >= len(self._MyList):
|
if self._PsIndex >= len(self._MyList):
|
||||||
self._PsIndex = len(self._MyList) -1
|
self._PsIndex = len(self._MyList) -1
|
||||||
|
|
||||||
|
dy = 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
|
self._MyList[i]._PosY -= self._MyList[i]._Height*dy
|
||||||
self._Scrolled -= 1
|
self._Scrolled -= dy
|
||||||
|
|
||||||
def SyncScroll(self):
|
def SyncScroll(self):
|
||||||
##
|
##
|
||||||
@ -408,7 +412,20 @@ class RomListPage(Page):
|
|||||||
self.ReScan()
|
self.ReScan()
|
||||||
self._Screen.Draw()
|
self._Screen.Draw()
|
||||||
self._Screen.SwapAndShow()
|
self._Screen.SwapAndShow()
|
||||||
|
|
||||||
|
def SpeedScroll(self, thekey):
|
||||||
|
if self._Screen._LastKey == thekey:
|
||||||
|
self._ScrollStep+=1
|
||||||
|
if self._ScrollStep >=5:
|
||||||
|
self._ScrollStep = 5
|
||||||
|
else:
|
||||||
|
self._ScrollStep = 1
|
||||||
|
|
||||||
|
cur_time = time.time()
|
||||||
|
|
||||||
|
if cur_time - self._Screen._LastKeyDown > 0.3:
|
||||||
|
self._ScrollStep = 1
|
||||||
|
|
||||||
def KeyDown(self,event):
|
def KeyDown(self,event):
|
||||||
|
|
||||||
if event.key == CurKeys["Menu"] :
|
if event.key == CurKeys["Menu"] :
|
||||||
@ -423,11 +440,13 @@ class RomListPage(Page):
|
|||||||
self._Screen.SwapAndShow()
|
self._Screen.SwapAndShow()
|
||||||
|
|
||||||
if event.key == CurKeys["Up"]:
|
if event.key == CurKeys["Up"]:
|
||||||
|
self.SpeedScroll(event.key)
|
||||||
self.ScrollUp()
|
self.ScrollUp()
|
||||||
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.ScrollDown()
|
self.ScrollDown()
|
||||||
self._Screen.Draw()
|
self._Screen.Draw()
|
||||||
self._Screen.SwapAndShow()
|
self._Screen.SwapAndShow()
|
||||||
|
|||||||
@ -146,6 +146,7 @@ class MainScreen(Widget):
|
|||||||
_CounterScreen = None
|
_CounterScreen = None
|
||||||
|
|
||||||
_LastKey = -1
|
_LastKey = -1
|
||||||
|
_LastKeyDown = -1
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._Pages = []
|
self._Pages = []
|
||||||
|
|||||||
@ -100,7 +100,8 @@ class Page(Widget):
|
|||||||
_EasingDur = 30
|
_EasingDur = 30
|
||||||
_Padding = pygame.Rect(0,0,0,0)# x,y,w,h
|
_Padding = pygame.Rect(0,0,0,0)# x,y,w,h
|
||||||
_Margin = pygame.Rect(0,0,0,0)
|
_Margin = pygame.Rect(0,0,0,0)
|
||||||
|
_ScrollStep = 1
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._Icons = []
|
self._Icons = []
|
||||||
|
|
||||||
|
|||||||
@ -416,6 +416,7 @@ def event_process(event,main_screen):
|
|||||||
if callable( key_down_cb ):
|
if callable( key_down_cb ):
|
||||||
main_screen.KeyDown(event)
|
main_screen.KeyDown(event)
|
||||||
|
|
||||||
|
main_screen._LastKeyDown = everytime_keydown
|
||||||
return
|
return
|
||||||
|
|
||||||
def gobject_pygame_event_poll_timer(main_screen):
|
def gobject_pygame_event_poll_timer(main_screen):
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user