storage theme

This commit is contained in:
cuu 2019-04-27 16:46:13 +08:00
parent e38521e9c7
commit 8bca1166df
4 changed files with 60 additions and 29 deletions

View File

@ -13,8 +13,6 @@ from UI.icon_pool import MyIconPool
from UI.label import Label
from UI.util_funcs import midRect
from libs.roundrects import aa_round_rect
class StoragePage(Page):
_Icons = {}
@ -24,10 +22,10 @@ class StoragePage(Page):
_BGlabel = None
_FreeLabel = None
_BGmsg = "%.1fGB of %.1fGB Used"
_GBmsg = "%.1fGB of %.1fGB Used"
_DskUsg = None
_HighColor = MySkinManager.GiveColor('High')
_TextColor = MySkinManager.GiveColor('Text')
_FootMsg = ["Nav.","","","Back",""]
def __init__(self):
@ -53,60 +51,83 @@ class StoragePage(Page):
self._Width = self._Screen._Width
self._Height = self._Screen._Height
self._BGpng = IconItem()
self._BGpng._ImgSurf = MyIconPool._Icons["icon_sd"]
self._BGpng._MyType = ICON_TYPES["STAT"]
self._BGpng._Parent = self
self._GBLabel = Label()
self._GBLabel.SetCanvasHWND(self._CanvasHWND)
self._GBLabel.Init(self._GBmsg % (self._DskUsg[1]-self._DskUsg[0], self._DskUsg[1]),MySkinManager.GiveFont("varela11") )
self._GBLabel.SetColor(self._TextColor)
self._BGpng.AddLabel(self._BGmsg % (self._DskUsg[1]-self._DskUsg[0], self._DskUsg[1]), MySkinManager.GiveFont("varela15"))
self._BGpng.Adjust(0,0,self._BGwidth,self._BGheight,0)
self._BGlabel = Label()
self._BGlabel.SetCanvasHWND(self._CanvasHWND)
self._PctLabel = Label()
self._PctLabel.SetCanvasHWND(self._CanvasHWND)
usage_percent = (self._DskUsg[0]/self._DskUsg[1] )*100.0
self._BGlabel.Init("%d%%"% int(usage_percent),MySkinManager.GiveFont("varela25"))
self._BGlabel.SetColor( self._HighColor )
self._PctLabel.Init("%d%%"% int(usage_percent),MySkinManager.GiveFont("EurostileBold30"))
self._PctLabel.SetColor( self._TextColor )
self._FreeLabel = Label()
self._FreeLabel.SetCanvasHWND(self._CanvasHWND)
self._FreeLabel.Init("Free",MySkinManager.GiveFont("varela13"))
self._FreeLabel.SetColor(self._BGlabel._Color)
self._FreeLabel.Init("FREE",MySkinManager.GiveFont("Eurostile12"))
self._FreeLabel.SetColor(self._PctLabel._Color)
def OnLoadCb(self):
pass
def DrawCross(self,topleft,top):
start_x = topleft
start_y = top
width = 2
height = 10
padding = 4
rect1 = pygame.Rect(start_x+padding,start_y,width,height)
rect2 = pygame.Rect(start_x,start_y+padding,height,width)
pygame.draw.rect(self._CanvasHWND,MySkinManager.GiveColor('Text'),rect1, 0)
pygame.draw.rect(self._CanvasHWND,MySkinManager.GiveColor('Text'),rect2, 0)
def Draw(self):
self.ClearCanvas()
self._BGpng.NewCoord(self._Width/2,self._Height/2-10)
self._BGpng.Draw()
self._BGlabel.NewCoord(self._Width/2-28,self._Height/2-30)
self._BGlabel.Draw()
self._PctLabel.NewCoord(32,102- 33)
self._PctLabel.Draw()
self._FreeLabel.NewCoord(self._BGlabel._PosX+10 ,self._Height/2)
self._FreeLabel.NewCoord(33 ,130-25)
self._FreeLabel.Draw()
self._GBLabel.NewCoord(145,103-29)
self._GBLabel.Draw()
#bgcolor = (238,238,238), fgcolor = (126,206,244)
#aa_round_rect
usage_percent = (self._DskUsg[0]/self._DskUsg[1] )
if usage_percent < 0.1:
usage_percent = 0.1
rect_ = midRect(self._Width/2,self._Height-30,170,17, Width,Height)
rect_ = pygame.Rect(144,118-25, 283-144,139-117)
aa_round_rect(self._CanvasHWND, rect_, MySkinManager.GiveColor('Line'), 5, 0, MySkinManager.GiveColor('Line'))
pygame.draw.rect(self._CanvasHWND,MySkinManager.GiveColor('Text'), rect_, 1)
rect2 = midRect(self._Width/2,self._Height-30,int(170*(1.0-usage_percent)),17, Width,Height)
rect2 = pygame.Rect(144,118-25,int((283-144)*(1.0-usage_percent)),139-117)
rect2.left = rect_.left
rect2.top = rect_.top
aa_round_rect(self._CanvasHWND,rect2, MySkinManager.GiveColor('Front'),5,0,MySkinManager.GiveColor('Front'))
pygame.draw.rect(self._CanvasHWND,MySkinManager.GiveColor('Text'),rect2, 0)
sep_rect = pygame.Rect(129,99-25,2,42)
pygame.draw.rect(self._CanvasHWND,MySkinManager.GiveColor('Inactive'),sep_rect, 0)
##4 cross
self.DrawCross(10,10)
self.DrawCross(self._Screen._Width-20,10)
self.DrawCross(10,self._Screen._Height-20)
self.DrawCross(self._Screen._Width-20,self._Screen._Height-20)
class APIOBJ(object):

Binary file not shown.

Binary file not shown.

View File

@ -51,7 +51,16 @@ class SkinManager(object):
fonts_path["veramono"] = "%s/VeraMono.ttf" % skinpath
fonts_path["noto"] = "%s/NotoSansMono-Regular.ttf" % skinpath
fonts_path["notocjk"] = "%s/NotoSansCJK-Regular.ttf" % skinpath
fonts_path["Eurostile"] = "%s/EurostileMN-Medium.pfb.ttf" %skinpath
fonts_path["EurostileBold"] = "%s/EurostileMN-ExtendedBold.pfb.ttf" % skinpath
self._Fonts["Eurostile10"] = pygame.font.Font(fonts_path["Eurostile"],10)
self._Fonts["Eurostile11"] = pygame.font.Font(fonts_path["Eurostile"],11)
self._Fonts["Eurostile12"] = pygame.font.Font(fonts_path["Eurostile"],12)
self._Fonts["Eurostile13"] = pygame.font.Font(fonts_path["Eurostile"],13)
self._Fonts["EurostileBold30"] = pygame.font.Font(fonts_path["EurostileBold"],30)
for i in range(10,29):
self._Fonts["varela%d"%i] = pygame.font.Font(fonts_path["varela"],i)
@ -80,6 +89,7 @@ class SkinManager(object):
Colors["Line"] = pygame.Color(169, 169, 169)
Colors["TitleBg"] = pygame.Color(11, 16, 22)
Colors["Active"] = pygame.Color(175, 90, 0)
Colors["Inactive"] = pygame.Color(27,78,72)
Colors["Disabled"] = pygame.Color(204, 204, 204)
Colors["White"] = pygame.Color(11, 16, 22)
Colors["Black"] = pygame.Color(0, 0, 0)