airplane mode with animation

This commit is contained in:
cuu 2018-07-03 18:33:48 +08:00
parent 63c78a5f15
commit 208c1eeb55
6 changed files with 104 additions and 8 deletions

View File

@ -18,6 +18,8 @@ from UI.keys_def import CurKeys
from UI.scroller import ListScroller
from UI.icon_pool import MyIconPool
from UI.icon_item import IconItem
from UI.multi_icon_item import MultiIconItem
from UI.multilabel import MultiLabel
class InfoPageListItem(object):
@ -88,6 +90,11 @@ class AirplanePage(Page):
_DrawOnce = False
_Scroller = None
_EasingDur = 30
_airwire_y = 0
_dialog_index = 0
def __init__(self):
Page.__init__(self)
@ -109,8 +116,34 @@ class AirplanePage(Page):
self._Width = self._Screen._Width ## equal to screen width
self._Height = self._Screen._Height
airwire = IconItem()
airwire._ImgSurf = MyIconPool._Icons["airwire"]
airwire._MyType = ICON_TYPES["STAT"]
airwire._Parent = self
airwire.Adjust(0,0,5,43,0)
self._Icons["airwire"] = airwire
GS = IconItem()
GS._ImgSurf = MyIconPool._Icons["GS"]
GS._MyType = ICON_TYPES["STAT"]
GS._Parent = self
GS.Adjust(0,0,72,95,0)
self._Icons["GS"] = GS
DialogBoxs = MultiIconItem()
DialogBoxs._ImgSurf = MyIconPool._Icons["DialogBoxs"]
DialogBoxs._MyType = ICON_TYPES["STAT"]
DialogBoxs._Parent = self
DialogBoxs._IconWidth = 134
DialogBoxs._IconHeight = 93
DialogBoxs.Adjust(0,0,134,372,0)
self._Icons["DialogBoxs"] = DialogBoxs
"""
bgpng = IconItem()
bgpng = MultiIconItem()
bgpng._ImgSurf = MyIconPool._Icons["about_bg"]
bgpng._MyType = ICON_TYPES["STAT"]
bgpng._Parent = self
@ -140,6 +173,34 @@ class AirplanePage(Page):
self._PosY += dis
self._Scrolled += dis
def ToggleModeAni(self): ## with animation
out = commands.getstatusoutput('rfkill list | grep yes | cut -d " " -f3')
if out[1] == "yes":
data = self.EasingData(0,43)
for _,v in enumerate(data):
self._airwire_y -= v
self._dialog_index = 2
pygame.time.delay(40)
self._Screen.Draw()
self._Screen.SwapAndShow()
commands.getstatusoutput("rfkill unblock all")
self._Screen._TitleBar._InAirPlaneMode = False
else:
data = self.EasingData(0,43)
for _,v in enumerate(data):
self._airwire_y += v
self._dialog_index = 3
pygame.time.delay(40)
self._Screen.Draw()
self._Screen.SwapAndShow()
commands.getstatusoutput("rfkill block all")
self._Screen._TitleBar._InAirPlaneMode = True
def ToggleMode(self):
out = commands.getstatusoutput('rfkill list | grep yes | cut -d " " -f3')
print out
@ -163,7 +224,11 @@ class AirplanePage(Page):
out = commands.getstatusoutput('rfkill list | grep yes | cut -d " " -f3')
if out[1] == "yes":
self._Screen._TitleBar._InAirPlaneMode = True
self._airwire_y = 50+43
self._dialog_index = 1
else:
self._airwire_y = 50
self._dialog_index = 0
self._Screen._TitleBar._InAirPlaneMode = False
@ -179,6 +244,8 @@ class AirplanePage(Page):
self._Screen.SwapAndShow()
if event.key == CurKeys["B"]:
self.ToggleModeAni()
"""
self.ToggleMode()
self._Screen.SwapAndShow()
@ -186,7 +253,7 @@ class AirplanePage(Page):
self._Screen.Draw()
self._Screen.SwapAndShow()
"""
"""
if event.key == CurKeys["Up"]:
self.ScrollUp()
@ -200,12 +267,18 @@ class AirplanePage(Page):
def Draw(self):
self.ClearCanvas()
self._Icons["DialogBoxs"].NewCoord(145,23)
self._Icons["airwire"].NewCoord(80,self._airwire_y)
self._Icons["DialogBoxs"]._IconIndex = self._dialog_index
self._Icons["DialogBoxs"].DrawTopLeft()
self._Icons["airwire"].Draw()
self._Icons["GS"].NewCoord(98,118)
self._Icons["GS"].Draw()
if "bg" in self._Icons:
self._Icons["bg"].NewCoord(self._Width/2,self._Height/2 + (self._BGheight - Height)/2 + self._Screen._TitleBar._Height)
self._Icons["bg"].Draw()
if self._HWND != None:
self._HWND.fill((255,255,255))

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 599 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 B

View File

@ -23,6 +23,27 @@ class MultiIconItem(IconItem):
self._ImgSurf = pygame.image.load( self._ImageName ).convert_alpha()
def DrawTopLeft(self):
if self._Align==ALIGN["VCenter"]: #default
if self._Label != None:
self._Label._PosX = self._PosX - self._Label._Width/2 + self._Parent._PosX
self._Label._PosY = self._PosY + self._Height/2 +6 + self._Parent._PosY
elif self._Align ==ALIGN["HLeft"]:
if self._Label != None:
self._Label._PosX = self._PosX + self._Width/2 + 3 + self._Parent._PosX
self._Label._PosY = self._PosY - self._Label._Height/2 + self._Parent._PosY
if self._Label!=None:
self._Label.Draw()
if self._ImgSurf != None:
self._Parent._CanvasHWND.blit(self._ImgSurf,pygame.Rect(self._PosX+self._Parent._PosX,
self._PosY+self._Parent._PosY,
self._Width,self._Height),
(0,self._IconIndex*self._IconHeight,self._IconWidth,self._IconHeight))
def Draw(self):
if self._Align==ALIGN["VCenter"]: #default
if self._Label != None:
@ -36,9 +57,11 @@ class MultiIconItem(IconItem):
if self._Label!=None:
self._Label.Draw()
if self._ImgSurf != None:
self._Parent._CanvasHWND.blit(self._ImgSurf,midRect(self._PosX+self._Parent._PosX,
self._PosY+self._Parent._PosY,
self._Width,self._Height,Width,Height),
(0,self._IconIndex*self._IconHeight,self._IconWidth,self._IconHeight))