Merge pull request #323 from cuu/master

add GlobalScale
This commit is contained in:
GNU 2020-01-14 18:24:10 +08:00 committed by GitHub
commit 661250f7b1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 37 additions and 11 deletions

View File

@ -20,7 +20,7 @@ from page import Page,PageStack
from title_bar import TitleBar from title_bar import TitleBar
from foot_bar import FootBar from foot_bar import FootBar
from constants import Width,Height from constants import Width,Height
from util_funcs import midRect,FileExists,ReplaceSuffix,ReadTheFileContent,CmdClean,MakeExecutable from util_funcs import midRect,FileExists,ReplaceSuffix,ReadTheFileContent,CmdClean,MakeExecutable,SwapAndShow
from keys_def import CurKeys from keys_def import CurKeys
from label import Label from label import Label
from untitled_icon import UntitledIcon from untitled_icon import UntitledIcon
@ -361,7 +361,7 @@ class MainScreen(Widget):
return return
if self._HWND != None: if self._HWND != None:
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))
pygame.display.update() SwapAndShow()
def ExtraName(self,name): def ExtraName(self,name):
## extra name like 1_xxx to be => xxx, ## extra name like 1_xxx to be => xxx,

View File

@ -106,7 +106,7 @@ class Page(Widget):
_FootMsg = ["Nav", "", "", "", "Enter"] # Default Page Foot info _FootMsg = ["Nav", "", "", "", "Enter"] # Default Page Foot info
_Wallpaper = None _Wallpaper = None
_SelectedIconTopOffset = 20 _SelectedIconTopOffset = 20
_EasingDur = 30 _EasingDur = 20/config.GlobalScale
_Padding = pygame.Rect(0, 0, 0, 0) # x,y,w,h _Padding = pygame.Rect(0, 0, 0, 0) # x,y,w,h
_Margin = pygame.Rect(0, 0, 0, 0) _Margin = pygame.Rect(0, 0, 0, 0)
_ScrollStep = 1 _ScrollStep = 1

View File

@ -12,6 +12,7 @@ import subprocess
import string import string
from Xlib import X,display from Xlib import X,display
import config import config
from constants import Width,Height
def get_git_revision_hash(): def get_git_revision_hash():
return subprocess.check_output(['git', 'rev-parse', 'HEAD']) return subprocess.check_output(['git', 'rev-parse', 'HEAD'])
@ -109,6 +110,13 @@ def DrawText(canvas,text, x,y,width,height,canWidth,canHeight,fontObj):# text fo
def SwapAndShow(): def SwapAndShow():
screen = pygame.display.get_surface()
if config.GlobalScale > 1:
pygame.transform.scale(config.GlobalCanvas,(Width*config.GlobalScale,Height*config.GlobalScale),config.GlobalCanvas2)
screen.blit(config.GlobalCanvas2,(0,0,Width*config.GlobalScale,Height*config.GlobalScale))
elif config.GlobalScale == 1:
screen.blit(config.GlobalCanvas,(0,0,Width,Height))
pygame.display.update() pygame.display.update()
def ArmSystem(cmd): def ArmSystem(cmd):

View File

@ -1,7 +1,7 @@
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
import os import os
import platform import platform
from UI.util_funcs import FileExists,ArmSystem from UI.util_funcs import FileExists,ArmSystem,ReadTheFileContent
from pyaria2_rpc.pyaria2 import Xmlrpc from pyaria2_rpc.pyaria2 import Xmlrpc
CurKeySet = "GameShell" ## >>> PC or GameShell <<< CurKeySet = "GameShell" ## >>> PC or GameShell <<<
@ -10,6 +10,7 @@ DontLeave = False
BackLight = "/proc/driver/backlight" BackLight = "/proc/driver/backlight"
Battery = "/sys/class/power_supply/axp20x-battery/uevent" Battery = "/sys/class/power_supply/axp20x-battery/uevent"
FB_Modes = "/sys/class/graphics/fb0/modes"
MPD_socket = "/tmp/mpd.socket" MPD_socket = "/tmp/mpd.socket"
@ -32,8 +33,12 @@ PowerLevels["balance_saving"] = [40,0,0]
PowerLevel = "balance_saving" PowerLevel = "balance_saving"
GlobalCanvas=None
GlobalCanvas2=None
GlobalScale = 1
def PreparationInAdv(): def PreparationInAdv():
global SKIN,ButtonsLayout global SKIN,ButtonsLayout,FB_Modes,GlobalScale
global PowerLevel global PowerLevel
global RPC global RPC
if SKIN != None: if SKIN != None:
@ -73,6 +78,17 @@ def PreparationInAdv():
else: else:
ArmSystem("sudo iw wlan0 set power_save off >/dev/null") ArmSystem("sudo iw wlan0 set power_save off >/dev/null")
if FileExists(FB_Modes):
modes = ReadTheFileContent(FB_Modes)
if "320x240" in modes:
GlobalScale = 1
if "640x480" in modes:
GlobalScale = 2
if "480x640" in modes:
GlobalScale = 2
else:
GlobalScale = 1
RPC = Xmlrpc('localhost', 6800) RPC = Xmlrpc('localhost', 6800)
PreparationInAdv() PreparationInAdv()
##sys.py/.powerlevel ##sys.py/.powerlevel

View File

@ -585,7 +585,7 @@ def socket_thread(main_screen):
main_screen._TitleBar.Redraw() main_screen._TitleBar.Redraw()
def big_loop(): def big_loop(screen):
global sound_patch,gobject_flash_led1 global sound_patch,gobject_flash_led1
title_bar = TitleBar() title_bar = TitleBar()
@ -639,8 +639,8 @@ if __name__ == '__main__':
os.chdir( os.path.dirname(os.path.realpath(__file__)) ) os.chdir( os.path.dirname(os.path.realpath(__file__)) )
SCREEN_SIZE = (Width,Height) SCREEN_SIZE = (Width*config.GlobalScale,Height*config.GlobalScale)
screen = pygame.display.set_mode(SCREEN_SIZE, 0, 32) screen = pygame.display.set_mode(SCREEN_SIZE,pygame.DOUBLEBUF | pygame.HWSURFACE, 32)
pygame.event.set_allowed(None) pygame.event.set_allowed(None)
pygame.event.set_allowed([pygame.KEYDOWN,pygame.KEYUP,RUNEVT,RUNSYS,POWEROPT,RESTARTUI,RUNSH]) pygame.event.set_allowed([pygame.KEYDOWN,pygame.KEYUP,RUNEVT,RUNSYS,POWEROPT,RESTARTUI,RUNSH])
@ -662,10 +662,12 @@ if __name__ == '__main__':
print("This pygame does not support PNG") print("This pygame does not support PNG")
exit() exit()
config.GlobalCanvas = pygame.Surface((Width,Height),0,32)
config.GlobalCanvas2 = pygame.Surface(SCREEN_SIZE ,0,32)
crt_screen = CreateByScreen() crt_screen = CreateByScreen()
crt_screen.Init() crt_screen.Init()
crt_screen._HWND = screen crt_screen._HWND = config.GlobalCanvas
big_loop() big_loop(config.GlobalCanvas)