Merge pull request #86 from follower46/skin-cleanup

modify skin manager to allow instanced requests
This commit is contained in:
GNU 2018-08-12 18:43:04 +08:00 committed by GitHub
commit 97e9aa76d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
30 changed files with 144 additions and 104 deletions

View File

@ -19,11 +19,12 @@ from UI.scroller import ListScroller
from UI.icon_pool import MyIconPool from UI.icon_pool import MyIconPool
from UI.icon_item import IconItem from UI.icon_item import IconItem
from UI.multilabel import MultiLabel from UI.multilabel import MultiLabel
from UI.skin_manager import SkinManager
import config import config
class ListPageSelector(PageSelector): class ListPageSelector(PageSelector):
_BackgroundColor = pygame.Color(131,199,219) _BackgroundColor = SkinManager().GiveColor('Front')
def __init__(self): def __init__(self):
self._PosX = 0 self._PosX = 0
@ -102,7 +103,7 @@ class PageListItem(object):
self._Labels["Small"]._PosY = self._PosY + (self._Height- self._Labels["Small"]._Height)/2 self._Labels["Small"]._PosY = self._PosY + (self._Height- self._Labels["Small"]._Height)/2
self._Labels["Small"].Draw() self._Labels["Small"].Draw()
pygame.draw.line(self._Parent._CanvasHWND,(169,169,169),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1) pygame.draw.line(self._Parent._CanvasHWND,SkinManager().GiveColor('Line'),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)
class InfoPage(Page): class InfoPage(Page):

View File

@ -6,6 +6,7 @@ import os
## local UI import ## local UI import
from UI.page import Page from UI.page import Page
from UI.skin_manager import SkinManager
from UI.constants import ICON_TYPES,Width,Height from UI.constants import ICON_TYPES,Width,Height
from UI.icon_item import IconItem from UI.icon_item import IconItem
from UI.icon_pool import MyIconPool from UI.icon_pool import MyIconPool
@ -27,7 +28,7 @@ class StoragePage(Page):
_BGmsg = "%.1fGB of %.1fGB Used" _BGmsg = "%.1fGB of %.1fGB Used"
_DskUsg = None _DskUsg = None
_HighColor = pygame.Color(51,166,255) _HighColor = SkinManager().GiveColor('High')
_FootMsg = ["Nav.","","","Back",""] _FootMsg = ["Nav.","","","Back",""]
def __init__(self): def __init__(self):
@ -98,7 +99,7 @@ class StoragePage(Page):
rect_ = midRect(self._Width/2,self._Height-30,170,17, Width,Height) rect_ = midRect(self._Width/2,self._Height-30,170,17, Width,Height)
aa_round_rect(self._CanvasHWND,rect_, (193,193,193),5,0,(193,193,193)) aa_round_rect(self._CanvasHWND, rect_, SkinManager().GiveColor('Line'), 5, 0, SkinManager().GiveColor('Line'))
rect2 = midRect(self._Width/2,self._Height-30,int(170*(1.0-usage_percent)),17, Width,Height) rect2 = midRect(self._Width/2,self._Height-30,int(170*(1.0-usage_percent)),17, Width,Height)
@ -106,7 +107,7 @@ class StoragePage(Page):
rect2.left = rect_.left rect2.left = rect_.left
rect2.top = rect_.top rect2.top = rect_.top
aa_round_rect(self._CanvasHWND,rect2, (126,206,244),5,0,(126,206,244)) aa_round_rect(self._CanvasHWND,rect2, SkinManager().GiveColor('Front'),5,0,SkinManager().GiveColor('Front'))
class APIOBJ(object): class APIOBJ(object):

View File

@ -10,6 +10,7 @@ from UI.label import Label
from UI.fonts import fonts from UI.fonts import fonts
from UI.icon_item import IconItem from UI.icon_item import IconItem
from UI.util_funcs import midRect from UI.util_funcs import midRect
from UI.skin_manager import SkinManager
# a item for List # a item for List
# - - - - - - - - - - - -- # - - - - - - - - - - - --
@ -31,7 +32,7 @@ class ListItemIcon(IconItem):
class ListItemLabel(Label): class ListItemLabel(Label):
_ActiveColor = pygame.Color(175,90,0) _ActiveColor = SkinManager().GiveColor('Active')
_Active = False _Active = False
def Draw(self): def Draw(self):
@ -106,7 +107,7 @@ class ListItem(object):
self._Labels["Text"]._PosY = self._PosY + (self._Height - self._Labels["Text"]._Height)/2 self._Labels["Text"]._PosY = self._PosY + (self._Height - self._Labels["Text"]._Height)/2
pygame.draw.line(self._Parent._CanvasHWND,(169,169,169),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1) pygame.draw.line(self._Parent._CanvasHWND,SkinManager().GiveColor('Line'),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)
self._Labels["Text"].Draw() self._Labels["Text"].Draw()

View File

@ -17,6 +17,7 @@ from UI.keys_def import CurKeys
from UI.multi_icon_item import MultiIconItem from UI.multi_icon_item import MultiIconItem
from UI.icon_pool import MyIconPool from UI.icon_pool import MyIconPool
from UI.scroller import ListScroller from UI.scroller import ListScroller
from UI.skin_manager import SkinManager
from list_item import ListItem from list_item import ListItem
@ -50,7 +51,7 @@ class TimeLibStack:
return len(self.stack) return len(self.stack)
class ListPageSelector(PageSelector): class ListPageSelector(PageSelector):
_BackgroundColor = pygame.Color(131,199,219) _BackgroundColor = SkinManager().GiveColor('Front')
def __init__(self): def __init__(self):
self._PosX = 0 self._PosX = 0
@ -189,7 +190,7 @@ class TimezoneListPage(Page):
self._BGpng._MyType = ICON_TYPES["STAT"] self._BGpng._MyType = ICON_TYPES["STAT"]
self._BGpng._Parent = self self._BGpng._Parent = self
self._BGpng.AddLabel("No timezones found on system!", fonts["varela22"]) self._BGpng.AddLabel("No timezones found on system!", fonts["varela22"])
self._BGpng.SetLableColor(pygame.Color(204,204,204)) self._BGpng.SetLableColor(SkinManager().GiveColor('Disabled'))
self._BGpng.Adjust(0,0,self._BGwidth,self._BGheight,0) self._BGpng.Adjust(0,0,self._BGwidth,self._BGheight,0)

View File

@ -19,6 +19,7 @@ from UI.keys_def import CurKeys
from UI.confirm_page import ConfirmPage from UI.confirm_page import ConfirmPage
from UI.download import Download from UI.download import Download
from UI.download_process_page import DownloadProcessPage from UI.download_process_page import DownloadProcessPage
from UI.skin_manager import SkinManager
from libs.roundrects import aa_round_rect from libs.roundrects import aa_round_rect
from libs.DBUS import is_wifi_connected_now from libs.DBUS import is_wifi_connected_now
@ -194,7 +195,7 @@ class InfoPageListItem(object):
self._Labels["Small"]._PosY = self._PosY + (self._Height - self._Labels["Small"]._Height)/2 self._Labels["Small"]._PosY = self._PosY + (self._Height - self._Labels["Small"]._Height)/2
self._Labels["Small"].Draw() self._Labels["Small"].Draw()
pygame.draw.line(self._Parent._CanvasHWND,(169,169,169),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1) pygame.draw.line(self._Parent._CanvasHWND,SkinManager().GiveColor('Line'),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)
class UpdatePage(Page): class UpdatePage(Page):

View File

@ -13,6 +13,7 @@ from UI.util_funcs import midRect
from UI.keys_def import CurKeys from UI.keys_def import CurKeys
from UI.icon_item import IconItem from UI.icon_item import IconItem
from UI.icon_pool import MyIconPool from UI.icon_pool import MyIconPool
from UI.skin_manager import SkinManager
from libs.roundrects import aa_round_rect from libs.roundrects import aa_round_rect
@ -26,7 +27,7 @@ class KeyboardIcon(IconItem):
_PosY = 0 _PosY = 0
_Width = 0 _Width = 0
_Height = 0 _Height = 0
_Color = pygame.Color(83,83,83) _Color = SkinManager().GiveColor('Text')
_MyType = ICON_TYPES["NAV"] _MyType = ICON_TYPES["NAV"]
_Parent = None _Parent = None
_Str = "" _Str = ""

View File

@ -9,6 +9,7 @@ from UI.fonts import fonts
from UI.icon_item import IconItem from UI.icon_item import IconItem
from UI.multi_icon_item import MultiIconItem from UI.multi_icon_item import MultiIconItem
from UI.icon_pool import MyIconPool from UI.icon_pool import MyIconPool
from UI.skin_manager import SkinManager
class NetItemMultiIcon(MultiIconItem): class NetItemMultiIcon(MultiIconItem):
@ -194,6 +195,6 @@ class NetItem(object):
self._Icons["wifistatus"].NewCoord(self._Width-23,self._PosY) self._Icons["wifistatus"].NewCoord(self._Width-23,self._PosY)
self._Icons["wifistatus"].Draw() self._Icons["wifistatus"].Draw()
pygame.draw.line(self._Parent._CanvasHWND,(169,169,169),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1) pygame.draw.line(self._Parent._CanvasHWND,SkinManager().GiveColor('Line'),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)

View File

@ -3,6 +3,7 @@
from UI.constants import Width,Height,ICON_TYPES from UI.constants import Width,Height,ICON_TYPES
from UI.icon_item import IconItem from UI.icon_item import IconItem
from UI.util_funcs import midRect from UI.util_funcs import midRect
from UI.skin_manager import SkinManager
class TextItem(IconItem): class TextItem(IconItem):
_PosX = 0 _PosX = 0
@ -10,7 +11,7 @@ class TextItem(IconItem):
_Width = 0 _Width = 0
_Height = 0 _Height = 0
_Str = "" _Str = ""
_Color = (83,83,83) _Color = SkinManager().GiveColor('Text')
_FontObj = None _FontObj = None
_Bold = False _Bold = False
_MyType = ICON_TYPES["LETTER"] _MyType = ICON_TYPES["LETTER"]

View File

@ -10,13 +10,14 @@ from libs.roundrects import aa_round_rect
from UI.page import Page,PageStack,PageSelector from UI.page import Page,PageStack,PageSelector
from UI.label import Label from UI.label import Label
from UI.fonts import fonts from UI.fonts import fonts
from UI.skin_manager import SkinManager
class Textarea: class Textarea:
_PosX =0 _PosX =0
_PosY = 0 _PosY = 0
_Width = 0 _Width = 0
_Height = 0 _Height = 0
_BackgroundColor = pygame.Color(229,229,229) _BackgroundColor = SkinManager().GiveColor('TitleBg')
_CanvasHWND = None _CanvasHWND = None
_MyWords = [] _MyWords = []
_BlitWords = [] _BlitWords = []

View File

@ -15,6 +15,7 @@ from UI.util_funcs import midRect,SwapAndShow
from UI.keys_def import CurKeys from UI.keys_def import CurKeys
from UI.scroller import ListScroller from UI.scroller import ListScroller
from UI.confirm_page import ConfirmPage from UI.confirm_page import ConfirmPage
from UI.skin_manager import SkinManager
from net_item import NetItem from net_item import NetItem
@ -68,7 +69,7 @@ class InfoPageListItem(object):
self._Labels["Small"]._PosY = self._PosY + (self._Height - self._Labels["Small"]._Height)/2 self._Labels["Small"]._PosY = self._PosY + (self._Height - self._Labels["Small"]._Height)/2
self._Labels["Small"].Draw() self._Labels["Small"].Draw()
pygame.draw.line(self._Parent._CanvasHWND,(169,169,169),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1) pygame.draw.line(self._Parent._CanvasHWND,SkinManager().GiveColor('Line'),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)
@ -105,7 +106,7 @@ class WifiDisconnectConfirmPage(ConfirmPage):
self.Reset() self.Reset()
class WifiInfoPageSelector(PageSelector): class WifiInfoPageSelector(PageSelector):
_BackgroundColor = pygame.Color(131,199,219) _BackgroundColor = SkinManager().GiveColor('Front')
def __init__(self): def __init__(self):
self._PosX = 0 self._PosX = 0
@ -297,7 +298,7 @@ class WifiInfoPage(Page):
class WifiListSelector(PageSelector): class WifiListSelector(PageSelector):
_BackgroundColor = pygame.Color(131,199,219) _BackgroundColor = SkinManager().GiveColor('Front')
def __init__(self): def __init__(self):
self._PosX = 0 self._PosX = 0
@ -333,9 +334,9 @@ class WifiListMessageBox(Label):
x = (self._Parent._Width - w)/2 x = (self._Parent._Width - w)/2
y = (self._Parent._Height - h)/2 y = (self._Parent._Height - h)/2
padding = 10 padding = 10
pygame.draw.rect(self._CanvasHWND,(255,255,255),(x-padding,y-padding, w+padding*2,h+padding*2)) pygame.draw.rect(self._CanvasHWND,SkinManager().GiveColor('White'),(x-padding,y-padding, w+padding*2,h+padding*2))
pygame.draw.rect(self._CanvasHWND,(0,0,0),(x-padding,y-padding, w+padding*2,h+padding*2),1) pygame.draw.rect(self._CanvasHWND,SkinManager().GiveColor('Black'),(x-padding,y-padding, w+padding*2,h+padding*2),1)
self._CanvasHWND.blit(my_text,(x,y,w,h)) self._CanvasHWND.blit(my_text,(x,y,w,h))

View File

@ -13,13 +13,14 @@ from UI.fonts import fonts
from UI.util_funcs import midRect,FileExists from UI.util_funcs import midRect,FileExists
from UI.keys_def import CurKeys from UI.keys_def import CurKeys
from UI.scroller import ListScroller from UI.scroller import ListScroller
from UI.skin_manager import SkinManager
from list_item import ListItem from list_item import ListItem
import myvars import myvars
class ListPageSelector(PageSelector): class ListPageSelector(PageSelector):
_BackgroundColor = pygame.Color(131,199,219) _BackgroundColor = SkinManager().GiveColor('Front')
def __init__(self): def __init__(self):
self._PosX = 0 self._PosX = 0

View File

@ -10,6 +10,7 @@ from UI.label import Label
from UI.fonts import fonts from UI.fonts import fonts
from UI.icon_item import IconItem from UI.icon_item import IconItem
from UI.util_funcs import midRect from UI.util_funcs import midRect
from UI.skin_manager import SkinManager
# a item for List # a item for List
# - - - - - - - - - - - -- # - - - - - - - - - - - --
@ -31,7 +32,7 @@ class ListItemIcon(IconItem):
class ListItemLabel(Label): class ListItemLabel(Label):
_ActiveColor = pygame.Color(175,90,0) _ActiveColor = SkinManager().GiveColor('Active')
_Active = False _Active = False
def Draw(self): def Draw(self):
@ -116,7 +117,7 @@ class ListItem(object):
self._Labels["Text"]._PosY = self._PosY + (self._Height - self._Labels["Text"]._Height)/2 self._Labels["Text"]._PosY = self._PosY + (self._Height - self._Labels["Text"]._Height)/2
pygame.draw.line(self._Parent._CanvasHWND,(169,169,169),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1) pygame.draw.line(self._Parent._CanvasHWND,SkinManager().GiveColor('Line'),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)
if self._Playing == True: if self._Playing == True:
self._Labels["Text"]._Active =True self._Labels["Text"]._Active =True
@ -127,7 +128,7 @@ class ListItem(object):
if self._PlayingProcess > 0: if self._PlayingProcess > 0:
seek_posx = int(self._Width * self._PlayingProcess/100.0) seek_posx = int(self._Width * self._PlayingProcess/100.0)
pygame.draw.line(self._Parent._CanvasHWND,(255,169,169),(self._PosX,self._PosY+self._Height-2),(self._PosX+seek_posx,self._PosY+self._Height-2),2) pygame.draw.line(self._Parent._CanvasHWND,SkinManager().GiveColor('Active'),(self._PosX,self._PosY+self._Height-2),(self._PosX+seek_posx,self._PosY+self._Height-2),2)
else: else:
self._Labels["Text"].Draw() self._Labels["Text"].Draw()

View File

@ -20,6 +20,7 @@ from UI.util_funcs import midRect
from UI.keys_def import CurKeys from UI.keys_def import CurKeys
from UI.icon_item import IconItem from UI.icon_item import IconItem
from UI.icon_pool import MyIconPool from UI.icon_pool import MyIconPool
from UI.skin_manager import SkinManager
from threading import Thread from threading import Thread
@ -82,7 +83,7 @@ class MPDSpectrumPage(Page):
_SongFont = fonts["notosanscjk12"] _SongFont = fonts["notosanscjk12"]
_PIFI = None _PIFI = None
_FIFO = None _FIFO = None
_Color = pygame.Color(126,206,244) _Color = SkinManager().GiveColor('Front')
_GobjectIntervalId = -1 _GobjectIntervalId = -1
_Queue = None _Queue = None
_KeepReading = True _KeepReading = True
@ -162,21 +163,22 @@ class MPDSpectrumPage(Page):
self._song_title = Label() self._song_title = Label()
self._song_title.SetCanvasHWND(self._RollCanvas) self._song_title.SetCanvasHWND(self._RollCanvas)
self._song_title.Init("Untitled",self._SongFont,(255,255,255)) self._song_title.Init("Untitled",self._SongFont,SkinManager().GiveColor('White'))
self._title = Label() self._title = Label()
self._title.SetCanvasHWND(self._CanvasHWND) self._title.SetCanvasHWND(self._CanvasHWND)
self._title.Init("Title:",self._ListFont,(255,255,255)) self._title.Init("Title:",self._ListFont,SkinManager().GiveColor('White'))
self._time = Label() self._time = Label()
self._time.SetCanvasHWND(self._CanvasHWND) self._time.SetCanvasHWND(self._CanvasHWND)
self._time.Init("Time:",self._ListFont,(255,255,255)) self._time.Init("Time:",self._ListFont,SkinManager().GiveColor('White'))
self._time2 = Label() self._time2 = Label()
self._time2.SetCanvasHWND(self._CanvasHWND) self._time2.SetCanvasHWND(self._CanvasHWND)
self._time2.Init("00:00-00:00",self._ListFont,(255,255,255)) self._time2.Init("00:00-00:00", self._ListFont,
SkinManager().GiveColor('White'))
self.Start() self.Start()
@ -227,7 +229,7 @@ class MPDSpectrumPage(Page):
def ClearCanvas(self): def ClearCanvas(self):
self._CanvasHWND.fill((0,0,0)) self._CanvasHWND.fill(SkinManager().GiveColor('Black'))
def SgsSmooth(self): def SgsSmooth(self):
passes = 1 passes = 1
@ -341,7 +343,7 @@ class MPDSpectrumPage(Page):
if self._RollCanvas != None: if self._RollCanvas != None:
# self._RollCanvas.fill((111,22,33)) # self._RollCanvas.fill((111,22,33))
self._RollCanvas.fill((0,0,0)) self._RollCanvas.fill(SkinManager().GiveColor('Black'))
if self._song_title._Width > self._RollW: if self._song_title._Width > self._RollW:
if (self._song_title._PosX + self._song_title._Width) > self._RollW and self._frames % 30 == 0: if (self._song_title._PosX + self._song_title._Width) > self._RollW and self._frames % 30 == 0:
self._song_title._PosX -= 1 self._song_title._PosX -= 1
@ -415,9 +417,9 @@ class MPDSpectrumPage(Page):
else: else:
self._capYPositionArray[i] = value self._capYPositionArray[i] = value
pygame.draw.rect(self._CanvasHWND,(255,255,255),(i*(bw+gap)+margin_left,self._Height-gap-self._capYPositionArray[i]-margin_bottom,bw,gap),0) pygame.draw.rect(self._CanvasHWND,SkinManager().GiveColor('White'),(i*(bw+gap)+margin_left,self._Height-gap-self._capYPositionArray[i]-margin_bottom,bw,gap),0)
pygame.draw.rect(self._CanvasHWND,(255,255,255),(i*(bw+gap)+margin_left,self._Height-value-gap-margin_bottom,bw,value+gap),0) pygame.draw.rect(self._CanvasHWND,SkinManager().GiveColor('White'),(i*(bw+gap)+margin_left,self._Height-value-gap-margin_bottom,bw,value+gap),0)
self._vis_values[i] -= 2 self._vis_values[i] -= 2

View File

@ -15,6 +15,7 @@ from UI.keys_def import CurKeys
from UI.multi_icon_item import MultiIconItem from UI.multi_icon_item import MultiIconItem
from UI.icon_pool import MyIconPool from UI.icon_pool import MyIconPool
from UI.scroller import ListScroller from UI.scroller import ListScroller
from UI.skin_manager import SkinManager
from list_item import ListItem from list_item import ListItem
@ -48,7 +49,7 @@ class MusicLibStack:
return len(self.stack) return len(self.stack)
class ListPageSelector(PageSelector): class ListPageSelector(PageSelector):
_BackgroundColor = pygame.Color(131,199,219) _BackgroundColor = SkinManager().GiveColor('Front')
def __init__(self): def __init__(self):
self._PosX = 0 self._PosX = 0
@ -184,7 +185,7 @@ class MusicLibListPage(Page):
self._BGpng._MyType = ICON_TYPES["STAT"] self._BGpng._MyType = ICON_TYPES["STAT"]
self._BGpng._Parent = self self._BGpng._Parent = self
self._BGpng.AddLabel("Please upload data over Wi-Fi", fonts["varela22"]) self._BGpng.AddLabel("Please upload data over Wi-Fi", fonts["varela22"])
self._BGpng.SetLableColor(pygame.Color(204,204,204)) self._BGpng.SetLableColor(SkinManager().GiveColor('Disabled'))
self._BGpng.Adjust(0,0,self._BGwidth,self._BGheight,0) self._BGpng.Adjust(0,0,self._BGwidth,self._BGheight,0)

View File

@ -14,6 +14,7 @@ from UI.fonts import fonts
from UI.util_funcs import midRect from UI.util_funcs import midRect
from UI.keys_def import CurKeys from UI.keys_def import CurKeys
from UI.icon_pool import MyIconPool from UI.icon_pool import MyIconPool
from UI.skin_manager import SkinManager
from UI.scroller import ListScroller from UI.scroller import ListScroller
@ -22,7 +23,7 @@ from list_item import ListItem
import myvars import myvars
class ListPageSelector(PageSelector): class ListPageSelector(PageSelector):
_BackgroundColor = pygame.Color(131,199,219) _BackgroundColor = SkinManager().GiveColor('Front')
def __init__(self): def __init__(self):
self._PosX = 0 self._PosX = 0
@ -183,7 +184,7 @@ class PlayListPage(Page):
self._BGpng._MyType = ICON_TYPES["STAT"] self._BGpng._MyType = ICON_TYPES["STAT"]
self._BGpng._Parent = self self._BGpng._Parent = self
self._BGpng.AddLabel("my favourites", fonts["varela18"]) self._BGpng.AddLabel("my favourites", fonts["varela18"])
self._BGpng.SetLableColor(pygame.Color(204,204,204)) self._BGpng.SetLableColor(SkinManager().GiveColor('Disabled'))
self._BGpng.Adjust(0,0,self._BGwidth,self._BGheight,0) self._BGpng.Adjust(0,0,self._BGwidth,self._BGheight,0)
self._Scroller = ListScroller() self._Scroller = ListScroller()

View File

@ -10,6 +10,7 @@ from UI.fonts import fonts
from UI.icon_item import IconItem from UI.icon_item import IconItem
from UI.icon_pool import MyIconPool from UI.icon_pool import MyIconPool
from UI.keys_def import CurKeys from UI.keys_def import CurKeys
from UI.skin_manager import SkinManager
from libs.DBUS import is_wifi_connected_now,get_wifi_ip from libs.DBUS import is_wifi_connected_now,get_wifi_ip
@ -24,8 +25,8 @@ class TinyCloudPage(Page):
_Coords = {} _Coords = {}
_URLColor = pygame.Color(51,166,255) _URLColor = SkinManager().GiveColor('URL')
_TextColor = pygame.Color(83,83,83) _TextColor = SkinManager().GiveColor('Text')
_Scrolled = 0 _Scrolled = 0
_PngSize = {} _PngSize = {}
@ -197,7 +198,7 @@ class TinyCloudPage(Page):
self._DrawOnce = True self._DrawOnce = True
if self._HWND != None: if self._HWND != None:
self._HWND.fill((255,255,255)) self._HWND.fill(SkinManager().GiveColor('White'))
self._HWND.blit(self._CanvasHWND,(self._PosX,self._PosY,self._Width, self._Height ) ) self._HWND.blit(self._CanvasHWND,(self._PosX,self._PosY,self._Width, self._Height ) )

View File

@ -17,6 +17,7 @@ from UI.keys_def import CurKeys
from UI.multi_icon_item import MultiIconItem from UI.multi_icon_item import MultiIconItem
from UI.icon_pool import MyIconPool from UI.icon_pool import MyIconPool
from UI.scroller import ListScroller from UI.scroller import ListScroller
from UI.skin_manager import SkinManager
from rom_so_confirm_page import RomSoConfirmPage from rom_so_confirm_page import RomSoConfirmPage
@ -51,7 +52,7 @@ class FavStack:
return len(self.stack) return len(self.stack)
class ListPageSelector(PageSelector): class ListPageSelector(PageSelector):
_BackgroundColor = pygame.Color(131,199,219) _BackgroundColor = SkinManager().GiveColor('Front')
def __init__(self): def __init__(self):
self._PosX = 0 self._PosX = 0
@ -230,7 +231,7 @@ class FavListPage(Page):
bgpng._MyType = ICON_TYPES["STAT"] bgpng._MyType = ICON_TYPES["STAT"]
bgpng._Parent = self bgpng._Parent = self
bgpng.AddLabel("my favourites games", fonts["varela18"]) bgpng.AddLabel("my favourites games", fonts["varela18"])
bgpng.SetLableColor(pygame.Color(204,204,204)) bgpng.SetLableColor(SkinManager().GiveColor('Disabled'))
bgpng.Adjust(0,0,self._BGwidth,self._BGheight,0) bgpng.Adjust(0,0,self._BGwidth,self._BGheight,0)
self._Icons["bg"] = bgpng self._Icons["bg"] = bgpng

View File

@ -11,6 +11,7 @@ from UI.label import Label
from UI.fonts import fonts from UI.fonts import fonts
from UI.icon_item import IconItem from UI.icon_item import IconItem
from UI.util_funcs import midRect from UI.util_funcs import midRect
from UI.skin_manager import SkinManager
# a item for List # a item for List
# - - - - - - - - - - - -- # - - - - - - - - - - - --
@ -112,6 +113,6 @@ class ListItem(object):
self._Parent._Icons["sys"].NewCoord(self._PosX+12,self._PosY+ (self._Height - self._Parent._Icons["sys"]._Height)/2+self._Parent._Icons["sys"]._Height/2) self._Parent._Icons["sys"].NewCoord(self._PosX+12,self._PosY+ (self._Height - self._Parent._Icons["sys"]._Height)/2+self._Parent._Icons["sys"]._Height/2)
self._Parent._Icons["sys"].Draw() self._Parent._Icons["sys"].Draw()
pygame.draw.line(self._Parent._CanvasHWND,(169,169,169),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1) pygame.draw.line(self._Parent._CanvasHWND,SkinManager().GiveColor('Line'),(self._PosX,self._PosY+self._Height-1),(self._PosX+self._Width,self._PosY+self._Height-1),1)

View File

@ -24,6 +24,7 @@ from UI.keys_def import CurKeys
from UI.multi_icon_item import MultiIconItem from UI.multi_icon_item import MultiIconItem
from UI.icon_pool import MyIconPool from UI.icon_pool import MyIconPool
from UI.scroller import ListScroller from UI.scroller import ListScroller
from UI.skin_manager import SkinManager
from rom_so_confirm_page import RomSoConfirmPage from rom_so_confirm_page import RomSoConfirmPage
@ -58,7 +59,7 @@ class RomStack:
return len(self.stack) return len(self.stack)
class ListPageSelector(PageSelector): class ListPageSelector(PageSelector):
_BackgroundColor = pygame.Color(131,199,219) _BackgroundColor = SkinManager().GiveColor('Front')
def __init__(self): def __init__(self):
self._PosX = 0 self._PosX = 0
@ -264,7 +265,7 @@ class RomListPage(Page):
bgpng._MyType = ICON_TYPES["STAT"] bgpng._MyType = ICON_TYPES["STAT"]
bgpng._Parent = self bgpng._Parent = self
bgpng.AddLabel("Please upload data over Wi-Fi", fonts["varela22"]) bgpng.AddLabel("Please upload data over Wi-Fi", fonts["varela22"])
bgpng.SetLableColor(pygame.Color(204,204,204)) bgpng.SetLableColor(SkinManager().GiveColor('Disabled'))
bgpng.Adjust(0,0,self._BGwidth,self._BGheight,0) bgpng.Adjust(0,0,self._BGwidth,self._BGheight,0)
self._Icons["bg"] = bgpng self._Icons["bg"] = bgpng

View File

@ -17,7 +17,7 @@ from util_funcs import midRect
from fonts import fonts from fonts import fonts
from keys_def import CurKeys from keys_def import CurKeys
from label import Label from label import Label
from skin_manager import SkinManager
@ -30,8 +30,8 @@ class AboveAllPatch(object):
_Text ="" _Text =""
_FontObj=fonts["veramono20"] _FontObj=fonts["veramono20"]
_Parent =None _Parent =None
_Color = pygame.Color(83,83,83) _Color = SkinManager().GiveColor('Text')
_ValColor= pygame.Color(0,0,255) _ValColor = SkinManager().GiveColor('URL')
_CanvasHWND = None _CanvasHWND = None
_TextSurf = None _TextSurf = None
_Icons = {} _Icons = {}
@ -130,5 +130,5 @@ class SoundPatch(AboveAllPatch):
#w = 10,h = 40 #w = 10,h = 40
vol_rect = pygame.Rect(80+i*20, self._Height/2+20,10, 40) vol_rect = pygame.Rect(80+i*20, self._Height/2+20,10, 40)
aa_round_rect(self._CanvasHWND,vol_rect, self._Parent._SkinManager.GiveColor("Front"),3,0, self._Parent._SkinManager.GiveColor("Front")) aa_round_rect(self._CanvasHWND,vol_rect,SkinManager().GiveColor("Front"),3,0,SkinManager().GiveColor("Front"))

View File

@ -12,11 +12,12 @@ from label import Label
from fonts import fonts from fonts import fonts
from util_funcs import midRect from util_funcs import midRect
from keys_def import CurKeys from keys_def import CurKeys
from skin_manager import SkinManager
class ListPageSelector(PageSelector): class ListPageSelector(PageSelector):
_BackgroundColor = pygame.Color(131,199,219) _BackgroundColor = SkinManager().GiveColor('Front')
def __init__(self): def __init__(self):
self._PosX = 0 self._PosX = 0
@ -129,8 +130,8 @@ class ConfirmPage(Page):
def DrawBG(self): def DrawBG(self):
_rect = pygame.Rect(self._BGPosX,self._BGPosY,self._BGWidth,self._BGHeight) _rect = pygame.Rect(self._BGPosX,self._BGPosY,self._BGWidth,self._BGHeight)
pygame.draw.rect(self._CanvasHWND,(255,255,255),_rect,0) pygame.draw.rect(self._CanvasHWND,SkinManager().GiveColor('White'),_rect,0)
pygame.draw.rect(self._CanvasHWND,(83,83,83),_rect,1) pygame.draw.rect(self._CanvasHWND,SkinManager().GiveColor('Text'),_rect,1)
def Draw(self): def Draw(self):
#self.ClearCanvas() #self.ClearCanvas()

View File

@ -11,10 +11,13 @@ from datetime import datetime
import base64 import base64
from beeprint import pp from beeprint import pp
#UI lib
from skin_manager import SkinManager
Width = 320 Width = 320
Height = 240 Height = 240
bg_color = pygame.Color(255,255,255) bg_color = SkinManager().GiveColor('White')
icon_width = 80 icon_width = 80
icon_height = 80 icon_height = 80

View File

@ -8,6 +8,7 @@ from constants import Width,Height,RUNSYS
from label import Label from label import Label
from fonts import fonts from fonts import fonts
from full_screen import FullScreen from full_screen import FullScreen
from skin_manager import SkinManager
import config import config
@ -21,8 +22,8 @@ class CounterScreen(FullScreen):
_BottomLabel = None _BottomLabel = None
_NumberLabel = None _NumberLabel = None
_BGColor = pygame.Color(0,0,0) _BGColor = SkinManager().GiveColor('Black')
_FGColor = pygame.Color(255,255,255) _FGColor = SkinManager().GiveColor('White')
_Counting = False _Counting = False
_Number = 10 _Number = 10

View File

@ -19,6 +19,7 @@ from UI.keys_def import CurKeys
from UI.multi_icon_item import MultiIconItem from UI.multi_icon_item import MultiIconItem
from UI.icon_pool import MyIconPool from UI.icon_pool import MyIconPool
from UI.download import Download from UI.download import Download
from UI.skin_manager import SkinManager
from libs.DBUS import is_wifi_connected_now from libs.DBUS import is_wifi_connected_now
@ -38,8 +39,8 @@ class DownloadProcessPage(Page):
_FileNameLabel = None _FileNameLabel = None
_SizeLabel = None _SizeLabel = None
_URLColor = pygame.Color(51,166,255) _URLColor = SkinManager().GiveColor('URL')
_TextColor = pygame.Color(83,83,83) _TextColor = SkinManager().GiveColor('Text')
def __init__(self): def __init__(self):
Page.__init__(self) Page.__init__(self)
@ -205,12 +206,12 @@ class DownloadProcessPage(Page):
rect_ = midRect(self._Width/2,self._Height/2+33,170,17, Width,Height) rect_ = midRect(self._Width/2,self._Height/2+33,170,17, Width,Height)
aa_round_rect(self._CanvasHWND,rect_, (238,238,238),5,0,(238,238,238)) aa_round_rect(self._CanvasHWND,rect_,SkinManager().GiveColor('TitleBg'),5,0,SkinManager().GiveColor('TitleBg'))
rect2 = midRect(self._Width/2,self._Height/2+33,int(170*(percent/100.0)),17, Width,Height) rect2 = midRect(self._Width/2,self._Height/2+33,int(170*(percent/100.0)),17, Width,Height)
rect2.left = rect_.left rect2.left = rect_.left
rect2.top = rect_.top rect2.top = rect_.top
aa_round_rect(self._CanvasHWND,rect2, (126,206,244),5,0,(126,206,244)) aa_round_rect(self._CanvasHWND,rect2,SkinManager().GiveColor('Front'),5,0,SkinManager().GiveColor('Front'))
rect3 = midRect(self._Width/2,self._Height/2+53,self._FileNameLabel._Width, self._FileNameLabel._Height,Width,Height) rect3 = midRect(self._Width/2,self._Height/2+53,self._FileNameLabel._Width, self._FileNameLabel._Height,Width,Height)

View File

@ -7,6 +7,9 @@ import pygame
from constants import Width,Height from constants import Width,Height
from util_funcs import midRect from util_funcs import midRect
#UI lib
from skin_manager import SkinManager
class Label: class Label:
_PosX=0 _PosX=0
_PosY=0 _PosY=0
@ -14,13 +17,13 @@ class Label:
_Height=0 _Height=0
_Text="" _Text=""
_FontObj=None _FontObj=None
_Color = pygame.Color(83,83,83) _Color = SkinManager().GiveColor('Text')
_CanvasHWND = None _CanvasHWND = None
_TextSurf = None _TextSurf = None
def __init__(self): def __init__(self):
pass pass
def Init(self,text,font_obj,color=pygame.Color(83,83,83)): def Init(self, text, font_obj, color=SkinManager().GiveColor('Text')):
self._Color = color self._Color = color
self._FontObj = font_obj self._FontObj = font_obj
self._Text = text self._Text = text

View File

@ -34,7 +34,7 @@ class MessageBox(Label):
def __init__(self): def __init__(self):
pass pass
def Init(self,text,font_obj,color=pygame.Color(83,83,83)): def Init(self,text,font_obj,color=SkinManager().GiveColor('Text')):
self._Color = color self._Color = color
self._FontObj = font_obj self._FontObj = font_obj
self._Text = text self._Text = text
@ -50,7 +50,7 @@ class MessageBox(Label):
def PreDraw(self): def PreDraw(self):
self._Width = 0 self._Width = 0
self._Height = 0 self._Height = 0
self._CanvasHWND.fill( (255,255,255)) self._CanvasHWND.fill(SkinManager().GiveColor('White'))
words = self._Text.split(' ') words = self._Text.split(' ')
space = self._FontObj.size(' ')[0] space = self._FontObj.size(' ')[0]
@ -97,7 +97,7 @@ class MessageBox(Label):
padding = 5 padding = 5
pygame.draw.rect(self._HWND,(255,255,255),(x_-padding,y_-padding, self._Width+padding*2,self._Height+padding*2)) pygame.draw.rect(self._HWND,SkinManager().GiveColor('White'),(x_-padding,y_-padding, self._Width+padding*2,self._Height+padding*2))
if self._HWND != None: if self._HWND != None:
rect = pygame.Rect(x_,y_,self._Width,self._Height) rect = pygame.Rect(x_,y_,self._Width,self._Height)
@ -105,7 +105,7 @@ class MessageBox(Label):
#self._HWND.blit(self._CanvasHWND,rect) #self._HWND.blit(self._CanvasHWND,rect)
if withborder == True: if withborder == True:
pygame.draw.rect(self._HWND,(0,0,0),(x_-padding,y_-padding, self._Width+padding*2,self._Height+padding*2),1) pygame.draw.rect(self._HWND,SkinManager().GiveColor('Black'),(x_-padding,y_-padding, self._Width+padding*2,self._Height+padding*2),1)
def Draw(self): def Draw(self):
x = (self._Parent._Width)/2 x = (self._Parent._Width)/2
@ -347,7 +347,7 @@ class MainScreen(object):
self._Pages.append(Page) self._Pages.append(Page)
def ClearCanvas(self): def ClearCanvas(self):
self._CanvasHWND.fill((255,255,255)) self._CanvasHWND.fill(SkinManager().GiveColor('White'))
def SwapAndShow(self): def SwapAndShow(self):
if self._Closed == True: if self._Closed == True:

View File

@ -2,6 +2,8 @@
import pygame import pygame
from skin_manager import SkinManager
class MultiLabel: ##Multi Line Label class MultiLabel: ##Multi Line Label
_PosX=0 _PosX=0
@ -10,7 +12,7 @@ class MultiLabel: ##Multi Line Label
_Height=100 _Height=100
_Text="" _Text=""
_FontObj=None _FontObj=None
_Color = pygame.Color(83,83,83) _Color = SkinManager().GiveColor('Text')
_CanvasHWND = None _CanvasHWND = None
_TextSurf = None _TextSurf = None
_MaxWidth = 0 _MaxWidth = 0
@ -18,7 +20,7 @@ class MultiLabel: ##Multi Line Label
def __init__(self): def __init__(self):
pass pass
def Init(self,text,font_obj,color=pygame.Color(83,83,83)): def Init(self,text,font_obj,color=SkinManager().GiveColor('Text')):
self._Color = color self._Color = color
self._FontObj = font_obj self._FontObj = font_obj
self._Text = text self._Text = text

View File

@ -5,6 +5,8 @@ from util_funcs import midRect
from libs.roundrects import aa_round_rect from libs.roundrects import aa_round_rect
from skin_manager import SkinManager
class ListScroller(object): class ListScroller(object):
_PosX = 0 _PosX = 0
_PosY = 0 _PosY = 0
@ -12,7 +14,7 @@ class ListScroller(object):
_Height = 0 _Height = 0
_MinHeight = 6 ## tested _MinHeight = 6 ## tested
_Parent = None _Parent = None
_Color = pygame.Color(131,199,219) _Color = SkinManager().GiveColor('Front')
_StartX = 0 _StartX = 0
_StartY = 0 _StartY = 0

View File

@ -23,7 +23,7 @@ class SkinManager(object):
_Config = None _Config = None
def __init__(self): def __init__(self):
pass self.Init()
def ConvertToRGB(self,hexstr): def ConvertToRGB(self,hexstr):
@ -31,18 +31,23 @@ class SkinManager(object):
return tuple(int(h[i:i+2], 16) for i in (0, 2 ,4)) return tuple(int(h[i:i+2], 16) for i in (0, 2 ,4))
def Init(self): def Init(self):
if not SkinManager._Colors:
self.SetColors()
def SetColors(self):
Colors = {} Colors = {}
Colors["High"] = pygame.Color(51,166,255) Colors["High"] = pygame.Color(51, 166, 255)
Colors["Text"] = pygame.Color(83,83,83) Colors["Text"] = pygame.Color(83, 83, 83)
Colors["Front"] = pygame.Color(131,199,219) Colors["Front"] = pygame.Color(131, 199, 219)
Colors["URL"] = pygame.Color(51,166,255) Colors["URL"] = pygame.Color(51, 166, 255)
Colors["Line"] = pygame.Color(169,169,169) Colors["Line"] = pygame.Color(169, 169, 169)
Colors["TitleBg"] = pygame.Color(228,228,228) Colors["TitleBg"] = pygame.Color(228, 228, 228)
Colors["Active"] = pygame.Color(175,90,0) Colors["Active"] = pygame.Color(175, 90, 0)
Colors["White"] = pygame.Color(255,255,255) Colors["Disabled"] = pygame.Color(204, 204, 204)
Colors["White"] = pygame.Color(255, 255, 255)
Colors["Black"] = pygame.Color(0, 0, 0)
self._Colors = Colors SkinManager._Colors = Colors
self._Config = CaseConfigParser() self._Config = CaseConfigParser()
@ -50,25 +55,25 @@ class SkinManager(object):
try: try:
self._Config.read(fname) self._Config.read(fname)
except Exception,e: except Exception, e:
print("read skin config.cfg error %s" % str(e)) print("read skin config.cfg error %s" % str(e))
return return
else: else:
if "Colors" in self._Config.sections(): if "Colors" in self._Config.sections():
colour_opts = self._Config.options("Colors") colour_opts = self._Config.options("Colors")
# print(colour_opts) # print(colour_opts)
for i in self._Colors: for i in SkinManager._Colors:
if i in colour_opts: if i in colour_opts:
try: try:
self._Colors[i] = self.ConvertToRGB(self._Config.get("Colors",i)) SkinManager._Colors[i] = self.ConvertToRGB(
except Exception,e: self._Config.get("Colors", i))
except Exception, e:
print("error in ConvertToRGB %s" % str(e)) print("error in ConvertToRGB %s" % str(e))
continue continue
def GiveColor(self,name): def GiveColor(self,name):
if name in self._Colors: if name in SkinManager._Colors:
return self._Colors[name] return SkinManager._Colors[name]
else: else:
return pygame.Color(255,0,0) return pygame.Color(255,0,0)

View File

@ -11,34 +11,36 @@ from datetime import datetime
import base64 import base64
from beeprint import pp from beeprint import pp
from util_funcs import midRect,SkinMap from util_funcs import midRect, SkinMap
from fonts import fonts from fonts import fonts
BlankPng = SkinMap("gameshell/blank.png") ## 80x80 from skin_manager import SkinManager
BlankPng = SkinMap("gameshell/blank.png") # 80x80
## use blank circle as bg, Two alpha As Icon Label ## use blank circle as bg, Two alpha As Icon Label
#Upper and Lower #Upper and Lower
class UntitledIcon(object): class UntitledIcon(object):
_PosX = 0 _PosX = 0
_PosY = 0 _PosY = 0
_Width = 80 _Width = 80
_Height = 80 _Height = 80
_Words = ["G","s"] _Words = ["G", "s"]
_FontObj= fonts["varela40"] _FontObj = fonts["varela40"]
_BG = None ## initial surface _BG = None # initial surface
_Color = pygame.Color(83,83,83)
_Color = SkinManager().GiveColor('Text')
def __init__(self): def __init__(self):
self._Words = ["G","s"] self._Words = ["G", "s"]
def Init(self): def Init(self):
self._BG = pygame.image.load(BlankPng).convert_alpha() self._BG = pygame.image.load(BlankPng).convert_alpha()
def SetWords(self, TwoWords):
def SetWords(self,TwoWords):
if len(TwoWords) == 1: if len(TwoWords) == 1:
self._Words[0] = TwoWords[0].upper() self._Words[0] = TwoWords[0].upper()