mirror of
https://github.com/clockworkpi/launcher.git
synced 2025-12-13 10:18:51 +01:00
Allows for the rendering and rescaling of images to be used as a background to the launcher
This commit is contained in:
parent
a9220fc66e
commit
24d711e538
@ -6,13 +6,16 @@ from sys import exit
|
|||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
import math
|
import math
|
||||||
|
import fnmatch
|
||||||
|
import random
|
||||||
|
|
||||||
|
|
||||||
from libs import easing
|
from libs import easing
|
||||||
|
|
||||||
# import base64
|
# import base64
|
||||||
# from beeprint import pp
|
# from beeprint import pp
|
||||||
|
|
||||||
### local import
|
# local import
|
||||||
from constants import ALIGN, icon_width, icon_height, Width, Height, ICON_TYPES
|
from constants import ALIGN, icon_width, icon_height, Width, Height, ICON_TYPES
|
||||||
from util_funcs import midRect
|
from util_funcs import midRect
|
||||||
from keys_def import CurKeys, IsKeyStartOrA, IsKeyMenuOrB
|
from keys_def import CurKeys, IsKeyStartOrA, IsKeyMenuOrB
|
||||||
@ -20,6 +23,7 @@ from icon_pool import MyIconPool
|
|||||||
from lang_manager import MyLangManager
|
from lang_manager import MyLangManager
|
||||||
from widget import Widget
|
from widget import Widget
|
||||||
|
|
||||||
|
|
||||||
class PageStack:
|
class PageStack:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self.stack = list()
|
self.stack = list()
|
||||||
@ -38,12 +42,14 @@ class PageStack:
|
|||||||
def Length(self):
|
def Length(self):
|
||||||
return len(self.stack)
|
return len(self.stack)
|
||||||
|
|
||||||
|
|
||||||
class PageSelector(Widget):
|
class PageSelector(Widget):
|
||||||
|
|
||||||
_Parent = None
|
_Parent = None
|
||||||
_Alpha = 0
|
_Alpha = 0
|
||||||
_OnShow = True
|
_OnShow = True
|
||||||
_IconSurf = None
|
_IconSurf = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -68,9 +74,11 @@ class PageSelector(Widget):
|
|||||||
|
|
||||||
if idx < len(self._Parent._Icons):
|
if idx < len(self._Parent._Icons):
|
||||||
x = self._Parent._Icons[idx]._PosX+self._Parent._PosX
|
x = self._Parent._Icons[idx]._PosX+self._Parent._PosX
|
||||||
y = self._Parent._Icons[iconidx]._PosY ## only use current icon's PosY
|
# only use current icon's PosY
|
||||||
|
y = self._Parent._Icons[iconidx]._PosY
|
||||||
|
|
||||||
rect = midRect(x,y,self._Width,self._Height,self._Parent._Width,self._Parent._Height)
|
rect = midRect(x, y, self._Width, self._Height,
|
||||||
|
self._Parent._Width, self._Parent._Height)
|
||||||
if rect.width <= 0 or rect.height <= 0:
|
if rect.width <= 0 or rect.height <= 0:
|
||||||
return
|
return
|
||||||
|
|
||||||
@ -79,23 +87,24 @@ class PageSelector(Widget):
|
|||||||
if self._IconSurf != None:
|
if self._IconSurf != None:
|
||||||
self._Parent._CanvasHWND.blit(self._IconSurf, rect)
|
self._Parent._CanvasHWND.blit(self._IconSurf, rect)
|
||||||
|
|
||||||
|
|
||||||
class Page(Widget):
|
class Page(Widget):
|
||||||
_Icons = []
|
_Icons = []
|
||||||
_Ps = None
|
_Ps = None
|
||||||
_PsIndex = 0
|
_PsIndex = 0
|
||||||
_IconNumbers = 0
|
_IconNumbers = 0
|
||||||
_IconIndex = 0 ## shows which icon current selected, the Selector can not move here
|
_IconIndex = 0 # shows which icon current selected, the Selector can not move here
|
||||||
_PrevIconIndex = 0 ## for remember the Highlighted Icon ,restore it's PosY to average
|
_PrevIconIndex = 0 # for remember the Highlighted Icon ,restore it's PosY to average
|
||||||
_Index = 0
|
_Index = 0
|
||||||
_Align = ALIGN["SLeft"]
|
_Align = ALIGN["SLeft"]
|
||||||
_CanvasHWND = None #
|
_CanvasHWND = None
|
||||||
_HWND = None #
|
_HWND = None
|
||||||
_OnShow = False
|
_OnShow = False
|
||||||
_Name = ""
|
_Name = ""
|
||||||
_Screen = None ## Should be the Screen Class
|
_Screen = None # Should be the Screen Class
|
||||||
_PageIconMargin = 20
|
_PageIconMargin = 20
|
||||||
_FootMsg = ["Nav","","","","Enter"] ## Default Page Foot info
|
_FootMsg = ["Nav", "", "", "", "Enter"] # Default Page Foot info
|
||||||
|
_Wallpaper = None
|
||||||
_SelectedIconTopOffset = 20
|
_SelectedIconTopOffset = 20
|
||||||
_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
|
||||||
@ -104,6 +113,13 @@ class Page(Widget):
|
|||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._Icons = []
|
self._Icons = []
|
||||||
|
path = '/home/cpi/launcher/skin/default/Menu/GameShell/Wallpaper/'
|
||||||
|
|
||||||
|
if os.path.exists(path):
|
||||||
|
image = os.listdir(path)[0]
|
||||||
|
if image:
|
||||||
|
self._Wallpaper = pygame.transform.scale(pygame.image.load(path+image).convert(), (320,240))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def AdjustHLeftAlign(self): ## adjust coordinator and append the PageSelector
|
def AdjustHLeftAlign(self): ## adjust coordinator and append the PageSelector
|
||||||
@ -538,8 +554,12 @@ class Page(Widget):
|
|||||||
print("OnTopLevel ",self._Screen._PageIndex)
|
print("OnTopLevel ",self._Screen._PageIndex)
|
||||||
|
|
||||||
def ClearCanvas(self):
|
def ClearCanvas(self):
|
||||||
|
if self._Wallpaper:
|
||||||
|
self._CanvasHWND.blit(self._Wallpaper,(0,0))
|
||||||
|
else:
|
||||||
self._CanvasHWND.fill(self._Screen._SkinManager.GiveColor("White"))
|
self._CanvasHWND.fill(self._Screen._SkinManager.GiveColor("White"))
|
||||||
|
|
||||||
|
|
||||||
def ClearIcons(self):
|
def ClearIcons(self):
|
||||||
for i in range(0,self._IconNumbers):
|
for i in range(0,self._IconNumbers):
|
||||||
self._Icons[i].Clear()
|
self._Icons[i].Clear()
|
||||||
@ -548,7 +568,7 @@ class Page(Widget):
|
|||||||
for i in range(0,self._IconNumbers):
|
for i in range(0,self._IconNumbers):
|
||||||
self._Icons[i].Draw()
|
self._Icons[i].Draw()
|
||||||
|
|
||||||
##make sure the Class has the _MyList
|
# make sure the Class has the _MyList
|
||||||
def ScrollDown(self):
|
def ScrollDown(self):
|
||||||
if len(self._MyList) == 0:
|
if len(self._MyList) == 0:
|
||||||
return
|
return
|
||||||
@ -650,4 +670,3 @@ class Page(Widget):
|
|||||||
self.DrawIcons()
|
self.DrawIcons()
|
||||||
self.DrawPageSelector()
|
self.DrawPageSelector()
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user