def __init__(self, util, listeners, voice_assistant): """ Initializer :param util: utility object :param listener: screen menu event listener """ self.util = util config = util.config screen_layout = BorderLayout(util.screen_rect) top = int((util.screen_rect.h * PERCENT_SAVERS) / 100) bottom = util.screen_rect.h - top screen_layout.set_pixel_constraints(top, bottom, 0, 0) layout = BorderLayout(screen_layout.TOP) layout.set_percent_constraints(PERCENT_TOP_HEIGHT, 0, 0, 0) Screen.__init__(self, util, "", PERCENT_TOP_HEIGHT, voice_assistant, "saver_title", title_layout=layout.TOP) factory = Factory(util) self.bounding_box = util.screen_rect self.saver_menu = SaverMenu(util, None, layout.CENTER) self.add_component(self.saver_menu) b = config[BACKGROUND][HEADER_BGR_COLOR] c = config[COLORS][COLOR_CONTRAST] font_size = (layout.TOP.h * PERCENT_TITLE_FONT) / 100.0 label = config[LABELS][SCREENSAVER] self.screen_title.set_text(label) layout = BorderLayout(screen_layout.BOTTOM) layout.set_percent_constraints(PERCENT_DELAY_TITLE, PERCENT_DELAY_TITLE, 0, 0) self.delay_menu = SaverDelayMenu(util, None, layout.CENTER) self.add_component(self.delay_menu) layout.TOP.y += 2 layout.TOP.h -= 2 self.saver_delay_title = factory.create_output_text( "saver_delay_title", layout.TOP, b, c, int(font_size)) label = config[LABELS][DELAY] self.saver_delay_title.set_text(label) self.add_component(self.saver_delay_title) b = self.config[BACKGROUND][FOOTER_BGR_COLOR] self.navigator = SaverNavigator(util, listeners, b, layout.BOTTOM) self.add_component(self.navigator) self.top_menu_enabled = True
def __init__(self, util, listeners, voice_assistant): """ Initializer :param util: utility object :param listener: screen menu event listener """ self.util = util config = util.config screen_layout = BorderLayout(config[SCREEN_RECT]) top = int((config[SCREEN_RECT].h * PERCENT_SAVERS) / 100) bottom = config[SCREEN_RECT].h - top screen_layout.set_pixel_constraints(top, bottom, 0, 0) layout = BorderLayout(screen_layout.TOP) layout.set_percent_constraints(PERCENT_TOP_HEIGHT, 0, 0, 0) Screen.__init__(self, util, "", PERCENT_TOP_HEIGHT, voice_assistant, "saver_title", title_layout=layout.TOP) factory = Factory(util) self.bounding_box = config[SCREEN_RECT] self.bgr = (0, 0, 0) self.saver_menu = SaverMenu(util, (0, 0, 0), layout.CENTER) self.add_component(self.saver_menu) d = config[COLORS][COLOR_DARK_LIGHT] c = config[COLORS][COLOR_CONTRAST] font_size = (layout.TOP.h * PERCENT_TITLE_FONT)/100.0 label = config[LABELS][SCREENSAVER] self.screen_title.set_text(label) layout = BorderLayout(screen_layout.BOTTOM) layout.set_percent_constraints(PERCENT_DELAY_TITLE, PERCENT_DELAY_TITLE, 0, 0) self.delay_menu = SaverDelayMenu(util, (0, 0, 0), layout.CENTER) self.add_component(self.delay_menu) layout.TOP.y += 1 layout.TOP.h -= 1 self.saver_delay_title = factory.create_output_text("saver_delay_title", layout.TOP, d, c, int(font_size)) label = config[LABELS][DELAY] self.saver_delay_title.set_text(label) self.add_component(self.saver_delay_title) buttons = factory.create_home_player_buttons(self, layout.BOTTOM, listeners) self.home_button = buttons[0] self.player_button = buttons[1] self.top_menu_enabled = True
def get_layout(self): """ Get the layout of the center area of the screen for image and buttons :return: layout rectangle """ layout = BorderLayout(self.bounding_box) top = int(self.bounding_box.h * self.top_height / 100) bottom = int(self.bounding_box.h * self.bottom_height / 100) center = self.bounding_box.h - top - bottom if center % 2 != 0: top -= 1 center += 1 left = right = (self.bounding_box.w - center) / 2 if self.image_location == LOCATION_CENTER: layout.set_pixel_constraints(top, bottom, left, right) elif self.image_location == LOCATION_LEFT: layout.set_pixel_constraints(top, bottom, 0, right * 2) elif self.image_location == LOCATION_RIGHT: layout.set_pixel_constraints(top, bottom, right * 2, 0) return layout