def Initialize(self): self.DefaultContent = Core.CntMng.ContentManager() self.DefaultContent = UI.SystemResources self.IntroSoundPlayed = False self.SetVideoMode(False, (350, 320)) self.CenterWindow() self.SetTitle("Task Manager") self.ICON = UI.SystemResources.GetImage("/task_manager.png") self.TaskList = UI.VerticalListWithDescription((0, 25, 350, 320 - 25), self.DefaultContent) self.SelectedTask = "" self.SelectedTaskPID = -1 self.FirstCycleRefresh = False self.TopOptionsBar = Widget.Widget_Controller(self.DefaultContent, (0, 0, 350, 25)) self.TopOptionsBar.BackgroundColor = UI.ThemesManager_GetProperty( "WidgetControllerBackground1") self.TopOptionsBar.Append( Widget.Widget_Button(self.DefaultContent, "Reload", 12, 5, 5, 0)) self.TopOptionsBar.Append( Widget.Widget_Button(self.DefaultContent, "End Task", 12, 50, 5, 1)) self.TopOptionsBar.Append( Widget.Widget_Label(self.DefaultContent, "/Ubuntu_Bold.ttf", "No process selected", 12, (230, 230, 230), 105, 5, 2)) self.ProcessNameLabel = self.TopOptionsBar.GetWidget(2)
def __init__(self, pContentManager, Text, FontSize, X, Y, WidgetID): if WidgetID == -1: raise ValueError("WidgetID cannot be -1") self.ID = WidgetID self.InteractionType = None self.Content = pContentManager self.Active = True self.EventUpdateable = True self.AwaysUpdate = False self.IsVisible = True self.X = X self.Y = Y self.Text = Text self.FontSize = FontSize self.TextWidth = self.Content.GetFont_width("/Ubuntu_Bold.ttf", self.FontSize, self.Text) self.TextHeight = self.Content.GetFont_height("/Ubuntu_Bold.ttf", self.FontSize, self.Text) self.Rectangle = Convert.List_PygameRect( (X, Y, self.TextWidth + 2, self.TextHeight + 2)) self.Surface = pygame.Surface((self.Rectangle[2], self.Rectangle[3])) self.Centred_X = self.Rectangle[2] / 2 - self.Content.GetFont_width( "/Ubuntu_Bold.ttf", self.FontSize - 2, self.Text) / 2 self.Centred_Y = self.Rectangle[3] / 2 - self.Content.GetFont_height( "/Ubuntu_Bold.ttf", self.FontSize - 2, self.Text) / 2 self.ButtonState = 0 self.CursorOffset = (0, 0) self.BgColor = UI.ThemesManager_GetProperty("Button_BackgroundColor") self.IndicatorColor = UI.ThemesManager_GetProperty( "Button_Inactive_IndicatorColor") self.UpdateRectangle() self.ColideRect = pygame.Rect(0, 0, 5, 5)
def Render(self, DISPLAY): # -- Render Background -- # BGColor = UI.ThemesManager_GetProperty("Button_Active_BackgroundColor") LineColor = UI.ThemesManager_GetProperty( "Button_Active_IndicatorColor") if not self.Active: BGColor = UI.ThemesManager_GetProperty( "Button_Inactive_BackgroundColor") LineColor = UI.ThemesManager_GetProperty( "Button_Active_IndicatorColor") Shape.Shape_Rectangle(DISPLAY, BGColor, self.Rectangle) Shape.Shape_Rectangle(DISPLAY, LineColor, self.Rectangle, 1) # -- Render Change Title -- # TitleX = self.Rectangle[ 0] + self.Rectangle[2] / 2 - self.Content.GetFont_width( "/Ubuntu_Bold.ttf", 12, self.TitleName) / 2 self.Content.FontRender(DISPLAY, "/Ubuntu_Bold.ttf", 12, self.TitleName, (230, 230, 230), TitleX, self.Rectangle[1]) # -- Render EditableNumberView -- # self.Changer.Render(DISPLAY)
def __init__(self, pDefaultContent, pRootObj): self.DefaultContent = pDefaultContent self.RootObj = pRootObj self.ApplicationSelector = UI.ApplicationSelector( pDefaultContent, Core.MAIN.ScreenWidth / 2 - 550 / 2, Core.MAIN.ScreenHeight / 2 - 120 / 2) self.NoFoldersFound = False self.LoadApplicationsList() self.BottomButtonsList = Widget.Widget_Controller( pDefaultContent, (5, Core.MAIN.ScreenHeight - 50 - 5, Core.MAIN.ScreenWidth - 10, 50)) VersionText = "Taiyou Framework v" + CoreUtils.FormatNumber(Core.TaiyouGeneralVersion) + \ "\nTaiyou UI/Taskbar v" + Core.Get_TaiyouUIVersion() self.BottomButtonsList.Append( Widget.Widget_Label(pDefaultContent, "/Ubuntu_Bold.ttf", VersionText, 14, (200, 200, 200), 5, 5, 0)) self.ApplicationManagerBarAnimatorDisableToggle = True self.ApplicationManagerBarAnimator = CoreUtils.AnimationController(2) self.ApplicationManagerBarAnimator.Enabled = False self.ApplicationManagerBar = Widget.Widget_Controller( pDefaultContent, (5, 650, Core.MAIN.ScreenWidth - 10, 50)) self.ApplicationManagerBar.Append( Widget.Widget_Button(pDefaultContent, "Open Application", 14, 5, 5, 0)) self.ApplicationManagerEnabled = False self.TextsBaseX = 0 self.DisableInput = False
def Draw(self): self.DISPLAY.fill(UI.ThemesManager_GetProperty("DefaultBackground")) self.TaskList.Render(self.DISPLAY) self.TopOptionsBar.Draw(self.DISPLAY) self.LAST_SURFACE = self.DISPLAY.copy()
def Update(self): if not self.IsVisible: return self.BgColor = UI.ThemesManager_GetProperty("Button_BackgroundColor") self.IndicatorColor = UI.ThemesManager_GetProperty( "Button_Inactive_IndicatorColor") if not self.Active: self.IndicatorColor = UI.ThemesManager_GetProperty( "Button_Inactive_IndicatorColor") return if self.ButtonState == 0: self.IndicatorColor = UI.ThemesManager_GetProperty( "Button_Inactive_IndicatorColor") elif self.ButtonState == 1: self.IndicatorColor = UI.ThemesManager_GetProperty( "Button_Active_IndicatorColor")
def Draw(self): self.DISPLAY.fill(UI.ThemesManager_GetProperty("DefaultBackground")) BGIconOpacity = 100 if self.NoPackpagesFoundMode: BGIconOpacity = 190 self.ContentManager.ImageRender(self.DISPLAY, "/app_icon.png", self.DISPLAY.get_width() / 2 - self.ContentManager.GetImage("/app_icon.png").get_width() / 2, self.DISPLAY.get_height() / 2 - self.ContentManager.GetImage("/app_icon.png").get_height() / 2, Opacity=BGIconOpacity) if not self.NoPackpagesFoundMode: self.PackpageVerticalList.Render(self.DISPLAY) self.DownToolbar.Draw(self.DISPLAY)
def __init__(self, pDefaultContent, pRootObj): self.DefaultContent = pDefaultContent self.RootObj = pRootObj self.Tools = pygame.Rect(0, 0, 300, 25) self.WindowList = UI.VerticalListWithDescription( pygame.Rect(0, 0, 300, 400), self.DefaultContent) self.Tools_WidgetController = UI.Widget.Widget_Controller( self.DefaultContent, self.Tools) self.Tools_WidgetController.Append( UI.Widget.Widget_Button(self.DefaultContent, "End Task", 17, 3, 3, 0)) self.Tools_WidgetController.Append( UI.Widget.Widget_Button(self.DefaultContent, "Switch", 17, 90, 3, 1))
def Initialize(self): # Initialize Content Manager self.SetVideoMode(False, (400, 340)) self.CenterWindow() self.SetTitle("Packpage Installer") self.ContentManager = CntMng.ContentManager() self.ContentManager.SetSourceFolder("PackpageInstaller/") self.ContentManager.SetFontPath("fonts/") self.ContentManager.SetImageFolder("img/") self.ContentManager.SetRegKeysPath("reg/") self.ContentManager.LoadImagesInFolder() self.ContentManager.LoadRegKeysInFolder() self.PackpageVerticalList = UI.VerticalListWithDescription(pygame.Rect(0, 0, self.DISPLAY.get_width(), self.DISPLAY.get_height() - 40), self.ContentManager) self.PackpageInstalationEnabled = False self.PackpageInstalationStep = 0 self.PackpageInstalationStepMax = 8 self.PackpageInstalationStepNextDelay = 0 self.PackpageReplaceWarning = False self.BackFromPackpageReplaceWarning = False self.InstalationCompleteDeletePackpage = False self.NoPackpagesFoundMode = False self.IgnorePackpageReplace = False self.SelectedPackpage = "" self.ExtractPath = "" self.AppFolderPath = "" self.DataFolderPath = "" self.LastSelectedPackpage = "" self.DownToolbar = UI.Widget.Widget_Controller(self.ContentManager, pygame.Rect(0, self.DISPLAY.get_height() - 40, self.DISPLAY.get_width(), 40)) self.DownToolbar.Append(UI.Widget.Widget_Label(self.ContentManager, "/Ubuntu_Bold.ttf", self.ContentManager.Get_RegKey("/strings/select_app_list"), 12, (255, 255, 255), 2, 2, 0)) self.DownToolbar.Append(UI.Widget.Widget_Button(self.ContentManager, self.ContentManager.Get_RegKey("/strings/install_button"), 14, 4, 20, 1)) self.DownToolbar.Append(UI.Widget.Widget_ProgressBar(self.ContentManager, 0, self.PackpageInstalationStepMax, (5, 25, 200, 15), 2)) self.DownToolbar.Append(UI.Widget.Widget_Button(self.ContentManager, self.ContentManager.Get_RegKey("/strings/no_button"), 14, 34, 20, 3)) self.DownToolbar.Append(UI.Widget.Widget_Button(self.ContentManager, self.ContentManager.Get_RegKey("/strings/yes_button"), 14, 4, 20, 4)) # Set Invisible Objects self.DownToolbar.GetWidget(2).IsVisible = False self.DownToolbar.GetWidget(3).IsVisible = False self.DownToolbar.GetWidget(4).IsVisible = False self.ICON = self.ContentManager.GetImage("/app_icon.png") self.UpdatePackpageList()
def Draw(self): try: self.DISPLAY.fill( UI.ThemesManager_GetProperty("DefaultBackground")) except: self.DISPLAY.fill((0, 0, 0)) self.DefaultContent.ImageRender(self.DISPLAY, "/error.png", 5, 5, 128, 128, SmoothScaling=True) self.DefaultContent.FontRender(self.DISPLAY, "/Ubuntu_Bold.ttf", 14, self.CrashText, (215, 224, 223), 145, 5) self.LAST_SURFACE = self.DISPLAY.copy()
def __init__(self, pContentManager, Position, TitleName, ChangerInitialValue, WidgetID): if WidgetID == -1: raise ValueError("WidgetID cannot be -1") self.Rectangle = UTILS.Convert.List_PygameRect( (Position[0], Position[1], 48, 34)) self.TitleName = TitleName self.ID = WidgetID self.Content = pContentManager self.Changer = UI.EditableNumberView( pygame.Rect(self.Rectangle[0], self.Rectangle[1] + 17, self.Rectangle[2], self.Rectangle[3] - 17), ChangerInitialValue) self.LastValue = ChangerInitialValue self.InteractionType = None self.Active = False self.EventUpdateable = True self.AwaysUpdate = False self.CursorOffset = (0, 0)
def LoadingSteps(self, CurrentProgres): print("Taiyou.Bootloader.LoadingSteps : Running Step {0}.".format( CurrentProgres)) # Load default UI Resources if CurrentProgres == 0: # Load the default Theme File UI.ThemesManager_LoadTheme( UI.SystemResources, UI.SystemResources.Get_RegKey("UI/selected_theme")) if CurrentProgres == 1: # Start the SystemUI CoreAccess.CreateProcess( "System{0}SystemApps{0}TaiyouUI".format( CorePaths.TaiyouPath_CorrectSlash), "system_ui") self.InterruptDrawing = False if CurrentProgres >= self.ProgressMax: # Finish the Loading self.FinishLoadingScreen()
def DrawWindow(self, pSurface, process): WindowGeometry = [ process.POSITION[0], process.POSITION[1], process.DISPLAY.get_width() + 1, process.DISPLAY.get_height() ] if process.WINDOW_SURFACE is None: process.WINDOW_SURFACE = pygame.Surface( (WindowGeometry[2] + 1, WindowGeometry[3] + process.TITLEBAR_RECTANGLE[3] + 1)) process.TITLEBAR_RECTANGLE = pygame.Rect(WindowGeometry[0], WindowGeometry[1], WindowGeometry[2], 15) # Draw the title bar TitleBarColor = UI.ThemesManager_GetProperty("WM_TitlebarActiveColor") WindowBorderColor = UI.ThemesManager_GetProperty( "WM_BorderActiveColor") TextColor = UI.ThemesManager_GetProperty("WM_TitlebarTextActiveColor") FontSmoothEnabled = True if not process.APPLICATION_HAS_FOCUS: TitleBarColor = UI.ThemesManager_GetProperty( "WM_TitlebarInactiveColor") TextColor = UI.ThemesManager_GetProperty( "WM_TitlebarTextInactiveColor") WindowBorderColor = UI.ThemesManager_GetProperty( "WM_BorderInactiveColor") FontSmoothEnabled = False # Draw window titlebar only when needded. if process.WINDOW_SURFACE_LAST_DRAG_STATE != process.WINDOW_DRAG_ENABLED or process.WINDOW_SURFACE_LAST_DRAG_STATE_LAST_GEOMETRY != WindowGeometry: process.WINDOW_SURFACE_LAST_DRAG_STATE_LAST_GEOMETRY = WindowGeometry process.WINDOW_SURFACE_LAST_DRAG_STATE = process.WINDOW_DRAG_ENABLED process.WINDOW_SURFACE.fill(TitleBarColor) # Draw the Window Borders Shape.Shape_Rectangle(process.WINDOW_SURFACE, WindowBorderColor, (0, 0, process.WINDOW_SURFACE.get_width(), process.WINDOW_SURFACE.get_height()), 1) # Draw titlebar background Shape.Shape_Rectangle(process.WINDOW_SURFACE, TitleBarColor, (1, 1, process.TITLEBAR_RECTANGLE[2] - 1, process.TITLEBAR_RECTANGLE[3] - 1)) # Draw Title Bar Text TitleBarText = process.TITLEBAR_TEXT FontSize = UI.ThemesManager_GetProperty( "WM_WINDOWDRAG_TITLEBAR_FONTSIZE") Font = UI.ThemesManager_GetProperty("WM_WINDOWDRAG_TITLEBAR_FONTFILE") process.LAST_TITLEBAR_TEXT = process.TITLEBAR_TEXT # Draw Titlebar Text self.DefaultContent.FontRender( process.WINDOW_SURFACE, Font, FontSize, TitleBarText, TextColor, WindowGeometry[2] / 2 - self.DefaultContent.GetFont_width(Font, FontSize, TitleBarText) / 2, 0, FontSmoothEnabled) # Draw the Window Contents process.WINDOW_SURFACE.blit(pSurface, (1, process.TITLEBAR_RECTANGLE[3])) return process.WINDOW_SURFACE
def DrawProcess(self, process): if process is None: return try: # Set Cursor self.CurrentCursor = process.CURSOR # If is fullscreen process, just draw at max resolution at 0, 0 if process.FULLSCREEN: # If application has focus, draw again it's content if process.APPLICATION_HAS_FOCUS: self.DrawFullscreenProcess(process) # If not, just draw a copy of its screen self.DrawFullscreenProcess(process) if not process.APPLICATION_HAS_FOCUS: WindowGeometry = [ process.POSITION[0], process.POSITION[1], process.DISPLAY.get_width() + 1, process.DISPLAY.get_height() ] process.TITLEBAR_RECTANGLE = pygame.Rect( WindowGeometry[0], WindowGeometry[1], DISPLAY.get_width(), 15) # Draw the title bar TitleBarColor = UI.ThemesManager_GetProperty( "WM_FullscreenWindowTitleBarColor") TextColor = UI.ThemesManager_GetProperty( "WM_FullscreenWindowTitleBarTextColor") Shape.Shape_Rectangle( DISPLAY, TitleBarColor, (0, 0, process.TITLEBAR_RECTANGLE[2] + 1, process.TITLEBAR_RECTANGLE[3])) # Draw Title Bar Text TitleBarText = process.TITLEBAR_TEXT FontSize = 12 Font = "/Ubuntu.ttf" self.DefaultContent.FontRender( DISPLAY, Font, FontSize, TitleBarText, TextColor, DISPLAY.get_width() / 2 - self.DefaultContent.GetFont_width( Font, FontSize, TitleBarText) / 2, 0) return # If not, draw window decoration if not process.FRAMELESS: DISPLAY.blit(self.DrawWindow(process.LAST_SURFACE, process), (process.POSITION[0], process.POSITION[1])) else: DISPLAY.blit(process.LAST_SURFACE, (process.POSITION[0], process.POSITION[1])) except: Core.MAIN.SystemFault_Trigger = True Core.MAIN.SystemFault_Traceback = traceback.format_exc() Core.MAIN.SystemFault_ProcessObject = process self.FocusedProcess = None self.TaskBarInstance.SetMode(1) WmControl.WindowManagerSignal(None, 4) self.UI_Call_Request() print( "TaiyouApplicationDrawLoop : Process Error Detected\nin Process PID({0})" .format(process.PID)) print("Traceback:\n" + Core.MAIN.SystemFault_Traceback) # Kill the Process try: Core.MAIN.KillProcessByPID(process.PID) except: print("Error while killing process") # Generate the Crash Log Core.MAIN.GenerateCrashLog() return
def DrawScreen(self): # Draw the Applications Window if self.DefaultContent.Get_RegKey( "UI/dynamic_bg/enabled").lower() == "true": if self.EnableBackground and not self.TaskBarInstance.Enabled: self.BackgroundGenerator() else: DISPLAY.fill(UI.ThemesManager_GetProperty("BackgroundFillColor")) self.EnableBackground = True if not self.TaskBarInstance.Enabled and not self.TaskBarSystemFault: # Restart cursor next time enters to TaskBar self.TaskbarActiveCursorReseted = False # Draw the Unfocused Process for process in CoreAccess.ProcessAccess: # Check if current process is not TaiyouUI itself if process.PID == self.PID: continue # Skip Non-Graphical Process if not process.IS_GRAPHICAL: continue if process.FULLSCREEN: self.EnableBackground = False if process.APPLICATION_HAS_FOCUS: self.FocusedProcess = process continue try: self.DrawProcess(process) except: print( "TaiyouUI.ApplicationError at (Non-Active application rendering)." ) print(traceback.format_exc()) # Draw the focused process try: if not self.FocusedProcess is None: try: ProcessExists = CoreAccess.ProcessAccess_PID.index( self.FocusedProcess.PID) self.DrawProcess(self.FocusedProcess) except ValueError: pass else: if len(CoreAccess.ProcessAccess_PID) > 1: self.FocusedProcess = CoreAccess.ProcessAccess[len( CoreAccess.ProcessAccess)] except Exception: print( "TaiyouUI.ApplicationError at (Active application rendering)." ) print(traceback.format_exc()) self.FocusedProcess = None self.CurrentCursor = 0 self.TaskBarInstance.Set_LastDisplayFrame(DISPLAY) # WORKAROUND: Fix rendering bug # Update Process Events for process in CoreAccess.ProcessAccess: if self.FocusedProcess is None: break # Check if current process is not TaiyouUI itself if process.PID == self.PID: continue if process.PID != self.FocusedProcess.PID: process.APPLICATION_HAS_FOCUS = False elif self.TaskBarInstance.Enabled and not self.TaskbarActiveCursorReseted: self.TaskbarActiveCursorReseted = True self.CurrentCursor = 0 for process in CoreAccess.ProcessAccess: # Check if current process is not TaiyouUI itself if process.PID == self.PID: continue # Skip Non-Graphical Process if not process.IS_GRAPHICAL: continue process.DRAW_STOP = True # Draw and update the Taskbar UI self.TaskBarInstance.Update() self.TaskBarInstance.Draw(DISPLAY) self.DrawCursor() self.DrawZoom()