mirror of
https://github.com/clockworkpi/launcher.git
synced 2025-12-13 18:28:50 +01:00
* Revert "Respond to user requests (#35)" This reverts commit dc1b7e007c24dfb7226ee02c41ab0af723229f5f. * Revert "image text" This reverts commit 968db78adb9c5404d5150f4dd467a9e58545be0d. * Revert "add restore in POWEROPT event" This reverts commit 88523224de7721f9563a5b1f8d83bf05c76e3c76. * Revert "off to OFF" This reverts commit 586aa75ae4a4c276af71c17246d202ae7dfc0eef. * Revert "text fix" This reverts commit 8e3a90589aeb2b115d6321edcfa08abad5f78d07. * Revert "ignore powerlevel" This reverts commit 164b55fb4bccf625aa378057908b7fcbac8d229f. * Revert "switch smalltext" This reverts commit 01a5f2ef9af19a7ed302c21ceb82531e087b014b. * Revert "text fix" This reverts commit e03a9da323ebd767550ed2c967f6ada1252f9e18. * Revert "text fix" This reverts commit b5603bcf7c91b3a4af8a32dbb6fbcf92122e09a9. * Revert "sudo rfkill" This reverts commit 2bbeba56654727fe634faeef99f36ba68cb3d7a5. * Revert "InspectionTeam" This reverts commit 3db3b0e8b3b8f46287eb7b9956d262b74b61b1f8. * Revert "move back CurKeySet" This reverts commit 10f7e35e2e7a75cd8b4ba0a3f463f3be805eb14c. * Revert "rm png" This reverts commit bfdb83683a1f13e469b24479a08b4ff47b7cd924. * Revert "airplane mode with animation" This reverts commit 6e19ad88a7d5797ab83567e0b79d80f849d4e194. * Revert "add detail on power mode" This reverts commit d66a0df823a05ef45485f9e0d6db0434af4e178e. * Revert "add PowerLevel options" This reverts commit 36c54a4f9d0b8c569253cde4b1003cf9532e3802. * Revert "TitleBar show airplane mode icon" This reverts commit 74e7f8ab69f1813da84f9c26ee917f0c29bf7ab0. * Revert "Toggle AirPlane Mode" This reverts commit 2d11df8c37f7ab6e30c87dd5730614126b2ef7ba. * Revert "start sheep" This reverts commit 8f965b3ba543c5a952ef65fd868721e5b1dbbe7c. * Revert "fix bug dosbox on rom_list_page and remove scalesmooth on sec level icons" This reverts commit b4e40d052a479732dab13cec0b9776c3a21c93dc. * Revert "fix fav display bug on dosbox" This reverts commit 40be34e30d1289473b06f7f54bb70611e9da51f9. * Revert "add dosbox on fav" This reverts commit 2cba2e580867dfab3065dff269a5fcca0c2f668e. * Revert "add dosbox" This reverts commit bd71c64a5c75c8fceabe6554242569807deffea6. * Revert "Move back to 10_Settings" This reverts commit 4acacaf7363def6e462d1d2ecec10d68a9208353. * Revert "change load modules checking in Settings list_page" This reverts commit 385b672eeb0afb6d80921af8ad96da1ed76d8e80. * Revert "develop branch commit" This reverts commit f604310bb2d0855ea409012f6e86c71d549d56f1.
312 lines
9.4 KiB
Python
312 lines
9.4 KiB
Python
# -*- coding: utf-8 -*-
|
|
import os
|
|
import pygame
|
|
import gobject
|
|
|
|
from libs.roundrects import aa_round_rect
|
|
|
|
## local UI import
|
|
from UI.constants import Width,Height,ICON_TYPES
|
|
from UI.page import Page,PageSelector
|
|
from UI.icon_item import IconItem
|
|
from UI.label import Label
|
|
from UI.fonts import fonts
|
|
from UI.util_funcs import midRect
|
|
from UI.keys_def import CurKeys
|
|
from UI.icon_pool import MyIconPool
|
|
|
|
from UI.scroller import ListScroller
|
|
|
|
from list_item import ListItem
|
|
|
|
import myvars
|
|
|
|
class ListPageSelector(PageSelector):
|
|
_BackgroundColor = pygame.Color(131,199,219)
|
|
|
|
def __init__(self):
|
|
self._PosX = 0
|
|
self._PosY = 0
|
|
self._Height = 0
|
|
self._Width = Width
|
|
|
|
def AnimateDraw(self,x2,y2):
|
|
pass
|
|
|
|
def Draw(self):
|
|
idx = self._Parent._PsIndex
|
|
if idx > (len(self._Parent._MyList)-1):
|
|
idx = len(self._Parent._MyList)
|
|
if idx > 0:
|
|
idx -=1
|
|
elif idx == 0: #Nothing
|
|
return
|
|
|
|
x = self._Parent._MyList[idx]._PosX+2
|
|
y = self._Parent._MyList[idx]._PosY+1
|
|
h = self._Parent._MyList[idx]._Height -3
|
|
|
|
self._PosX = x
|
|
self._PosY = y
|
|
self._Height = h
|
|
|
|
aa_round_rect(self._Parent._CanvasHWND,
|
|
(x,y,self._Width-4,h),self._BackgroundColor,4,0,self._BackgroundColor)
|
|
|
|
|
|
|
|
class PlayListPage(Page):
|
|
|
|
_Icons = {}
|
|
_Selector=None
|
|
_FootMsg = ["Nav","","Remove","Back","Play/Pause"]
|
|
_MyList = []
|
|
_ListFont = fonts["notosanscjk15"]
|
|
|
|
_Scroller = None
|
|
|
|
_BGpng = None
|
|
_BGwidth = 75
|
|
_BGheight = 70
|
|
|
|
_Scrolled = 0
|
|
|
|
def __init__(self):
|
|
self._Icons = {}
|
|
Page.__init__(self)
|
|
self._CanvasHWND = None
|
|
self._MyList = []
|
|
|
|
def SyncList(self):
|
|
self._MyList = []
|
|
start_x = 0
|
|
start_y = 0
|
|
if myvars.Poller == None:
|
|
return
|
|
|
|
play_list = myvars.Poller.playlist()
|
|
for i,v in enumerate(play_list):
|
|
li = ListItem()
|
|
li._Parent = self
|
|
li._PosX = start_x
|
|
li._PosY = start_y + i*ListItem._Height
|
|
li._Width = Width
|
|
li._Fonts["normal"] = self._ListFont
|
|
|
|
if "title" in v:
|
|
li.Init( v["title"])
|
|
if "file" in v:
|
|
li._Path = v["file"]
|
|
|
|
elif "file" in v:
|
|
li.Init(os.path.basename(v["file"]))
|
|
li._Path = v["file"]
|
|
else:
|
|
li.Init("NoName")
|
|
|
|
li._Labels["Text"]._PosX = 7
|
|
self._MyList.append(li)
|
|
|
|
|
|
self.SyncPlaying()
|
|
|
|
def GObjectInterval(self): ## 250 ms
|
|
if self._Screen.CurPage() == self:
|
|
self.SyncPlaying()
|
|
self._Screen.Draw()
|
|
self._Screen.SwapAndShow()
|
|
|
|
return True
|
|
|
|
def SyncPlaying(self):
|
|
if myvars.Poller == None:
|
|
return
|
|
|
|
current_song = myvars.Poller.poll()
|
|
|
|
for i ,v in enumerate(self._MyList):
|
|
self._MyList[i]._Playing = False
|
|
self._MyList[i]._PlayingProcess = 0
|
|
|
|
if current_song != None:
|
|
if "song" in current_song:
|
|
posid = int(current_song["song"])
|
|
if posid < len(self._MyList): # out of index
|
|
if "state" in current_song:
|
|
if current_song["state"] == "stop":
|
|
self._MyList[posid]._Playing = False
|
|
else:
|
|
self._MyList[posid]._Playing = True
|
|
if "time" in current_song:
|
|
times_ = current_song["time"].split(":")
|
|
if len(times_)> 1:
|
|
cur = float(times_[0])
|
|
end = float(times_[1])
|
|
pros = int((cur/end)*100.0)
|
|
self._MyList[posid]._PlayingProcess = pros
|
|
|
|
|
|
def InPlayList(self,path):
|
|
for i,v in enumerate(self._MyList):
|
|
if v._Path == path:
|
|
return True
|
|
|
|
def Init(self):
|
|
self._PosX = self._Index * self._Screen._Width
|
|
self._Width = self._Screen._Width
|
|
self._Height = self._Screen._Height
|
|
|
|
self._CanvasHWND = self._Screen._CanvasHWND
|
|
|
|
ps = ListPageSelector()
|
|
ps._Parent = self
|
|
self._Ps = ps
|
|
self._PsIndex = 0
|
|
|
|
self.SyncList()
|
|
gobject.timeout_add(850,self.GObjectInterval)
|
|
|
|
self._BGpng = IconItem()
|
|
self._BGpng._ImgSurf = MyIconPool._Icons["heart"]
|
|
self._BGpng._MyType = ICON_TYPES["STAT"]
|
|
self._BGpng._Parent = self
|
|
self._BGpng.AddLabel("my favourites", fonts["varela18"])
|
|
self._BGpng.SetLableColor(pygame.Color(204,204,204))
|
|
self._BGpng.Adjust(0,0,self._BGwidth,self._BGheight,0)
|
|
|
|
self._Scroller = ListScroller()
|
|
self._Scroller._Parent = self
|
|
self._Scroller._PosX = self._Width - 10
|
|
self._Scroller._PosY = 2
|
|
self._Scroller.Init()
|
|
|
|
|
|
def ScrollUp(self):
|
|
if len(self._MyList) == 0:
|
|
return
|
|
self._PsIndex -= 1
|
|
if self._PsIndex < 0:
|
|
self._PsIndex = 0
|
|
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
|
|
self._Scrolled +=1
|
|
|
|
def ScrollDown(self):
|
|
if len(self._MyList) == 0:
|
|
return
|
|
self._PsIndex +=1
|
|
if self._PsIndex >= len(self._MyList):
|
|
self._PsIndex = len(self._MyList) -1
|
|
|
|
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
|
|
self._Scrolled -=1
|
|
|
|
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
|
|
|
|
def Click(self):
|
|
if len(self._MyList) == 0:
|
|
return
|
|
|
|
cur_li = self._MyList[self._PsIndex]
|
|
play_pos_id = myvars.Poller.play(self._PsIndex)
|
|
|
|
self.SyncPlaying()
|
|
|
|
self._Screen.Draw()
|
|
self._Screen.SwapAndShow()
|
|
|
|
def OnReturnBackCb(self): # return from music_lib_list_page
|
|
self.SyncList()
|
|
self.SyncScroll()
|
|
|
|
def KeyDown(self,event):
|
|
if event.key == CurKeys["A"] or event.key == CurKeys["Menu"]:
|
|
if myvars.Poller != None:
|
|
myvars.Poller.stop()
|
|
|
|
self.ReturnToUpLevelPage()
|
|
self._Screen.Draw()
|
|
self._Screen.SwapAndShow()
|
|
|
|
if event.key == CurKeys["Up"]:
|
|
self.ScrollUp()
|
|
self._Screen.Draw()
|
|
self._Screen.SwapAndShow()
|
|
if event.key == CurKeys["Down"]:
|
|
self.ScrollDown()
|
|
self._Screen.Draw()
|
|
self._Screen.SwapAndShow()
|
|
|
|
if event.key == CurKeys["Right"]:#add
|
|
self._Screen.PushCurPage()
|
|
self._Screen.SetCurPage(myvars.MusicLibListPage)
|
|
self._Screen.Draw()
|
|
self._Screen.SwapAndShow()
|
|
|
|
if event.key == CurKeys["Y"]:# del selected songs
|
|
myvars.Poller.delete(self._PsIndex)
|
|
self.SyncList()
|
|
self._Screen.Draw()
|
|
self._Screen.SwapAndShow()
|
|
|
|
if event.key == CurKeys["Enter"]:
|
|
self.Click()
|
|
|
|
if event.key == CurKeys["Start"]: # start spectrum
|
|
self._Screen.PushPage(myvars.SpectrumPage)
|
|
self._Screen.Draw()
|
|
self._Screen.SwapAndShow()
|
|
|
|
def Draw(self):
|
|
self.ClearCanvas()
|
|
|
|
if len(self._MyList) == 0:
|
|
self._BGpng.NewCoord(self._Width/2,self._Height/2)
|
|
self._BGpng.Draw()
|
|
return
|
|
else:
|
|
if len(self._MyList) * ListItem._Height > self._Height:
|
|
self._Ps._Width = self._Width - 11
|
|
self._Ps.Draw()
|
|
for i in self._MyList:
|
|
if i._PosY > self._Height + self._Height/2:
|
|
break
|
|
|
|
if i._PosY < 0:
|
|
continue
|
|
|
|
i.Draw()
|
|
self._Scroller.UpdateSize( len(self._MyList)*ListItem._Height, self._PsIndex*ListItem._Height)
|
|
self._Scroller.Draw()
|
|
else:
|
|
self._Ps._Width = self._Width
|
|
self._Ps.Draw()
|
|
for i in self._MyList:
|
|
|
|
if i._PosY > self._Height + self._Height/2:
|
|
break
|
|
|
|
if i._PosY < 0:
|
|
continue
|
|
|
|
i.Draw()
|
|
|