예제 #1
0
 def __init__(self, title, util, listeners, voice_assistant):
     """ Initializer
     
     :param title: screen title
     :param util: utility object
     :param listener: screen menu event listener
     :param voice_assistant: voice assistant
     """
     Screen.__init__(self, util, None, PERCENT_TOP_HEIGHT, voice_assistant)
     self.screen_title.set_text(title)
     self.factory = Factory(util)
     self.abc_menu = LatinAbcMenu(util, listeners[KEY_CALLBACK], (0, 0, 0, 0), self.layout.CENTER)
     self.abc_menu.add_listener(listeners[KEY_CALLBACK]) 
     self.add_menu(self.abc_menu)
     
     layout = GridLayout(self.layout.BOTTOM)
     layout.set_pixel_constraints(1, 4, 1, 0)
     layout.current_constraints = 0
     d = util.config[BACKGROUND][FOOTER_BGR_COLOR]
     
     self.navigator = Container(util)
     self.buttons = []
     self.add_button(KEY_HOME, KEY_HOME, layout, listeners[KEY_HOME], d)
     self.add_button(KEY_BACK, KEY_BACK, layout, listeners[KEY_BACK], d)
     self.add_button(COLLECTION, KEY_PARENT, layout, listeners[COLLECTION], d)
     self.add_button(KEY_PLAYER, KEY_PLAY_PAUSE, layout, listeners[KEY_PLAYER], d)
     self.add_menu(self.navigator)
예제 #2
0
 def create_left_panel(self, layout, arrow_labels):
     """ Create left side buttons panel
     
     :param layout: panel layout 
     :param arrow_labels: show arrow label or not
     """
     panel_layout = self.get_panel_layout(layout, LOCATION_LEFT)
     panel_layout.set_percent_constraints(self.button_height,
                                          self.button_height, 0, 0)
     self.left_button = self.factory.create_left_button(
         panel_layout.CENTER, '', 40, 100, arrow_labels)
     self.left_button.add_release_listener(self.go_left)
     panel_layout.TOP.y += 1
     panel_layout.TOP.h -= 2
     self.shutdown_button = self.factory.create_shutdown_button(
         panel_layout.TOP)
     panel_layout.BOTTOM.h += 1
     self.home_button = self.factory.create_button(KEY_HOME,
                                                   KEY_HOME,
                                                   panel_layout.BOTTOM,
                                                   image_size_percent=36)
     panel = Container(self.util, layout.LEFT)
     panel.add_component(self.shutdown_button)
     panel.add_component(self.left_button)
     panel.add_component(self.home_button)
     self.add_component(panel)
예제 #3
0
    def add_key(self, x, y, name, key):
        """ Add the key indicating current focus position
        
        :param x: x coordinate
        :param y: y coordinate
        :param name: component name
        :param key: key image
        """
        size = key[1].get_size()
        w = size[0]
        h = size[1]

        cont = Container(self.util)
        cont.bgr = cont.fgr = (0, 0, 0, 0)
        cont.name = name + ".cont"
        c = Component(self.util)
        c.name = name
        c.content = key[1]
        c.bgr = c.fgr = (0, 0, 0, 0)
        c.content_x = x - w / 2
        c.content_y = y
        c.image_filename = key[0]
        c.bounding_box = pygame.Rect(0, 0, w, h)
        cont.bounding_box = pygame.Rect(c.content_x, c.content_y, w, h)

        cont.add_component(c)
        self.add_component(cont)
        return cont
예제 #4
0
 def create_right_panel(self, layout, listeners):
     """ Create Station Screen right panel. Include Genre button, right button and Play/Pause button
     
     :param layout: right panel layout
     :param listeners: event listeners
     """
     panel_layout = BorderLayout(layout.RIGHT)
     panel_layout.set_percent_constraints(PERCENT_SIDE_BOTTOM_HEIGHT,
                                          PERCENT_SIDE_BOTTOM_HEIGHT, 0, 0)
     if self.screen_mode == STATION:
         self.genres_button = self.factory.create_genre_button(
             panel_layout.BOTTOM, self.current_genre,
             PERCENT_GENRE_IMAGE_AREA)
     elif self.screen_mode == STREAM:
         self.genres_button = self.factory.create_stream_button(
             panel_layout.BOTTOM)
     right = 0
     if self.station_menu.is_button_defined():
         right = self.playlist.length - self.station_menu.button.state.index - 1
     self.right_button = self.factory.create_right_button(
         panel_layout.CENTER, str(right), 40, 100)
     self.page_up_button = self.factory.create_page_up_button(
         panel_layout.CENTER, str(right), 40, 100)
     self.page_up_button.set_visible(False)
     self.play_button = self.factory.create_play_pause_button(
         panel_layout.TOP, listeners[KEY_PLAY_PAUSE])
     panel = Container(self.util, layout.RIGHT)
     panel.add_component(self.genres_button)
     panel.add_component(self.right_button)
     panel.add_component(self.page_up_button)
     panel.add_component(self.play_button)
     Container.add_component(self, panel)
예제 #5
0
    def add_page(self, page_num, page):
        """ Add lyrics page to the container
        
        :param page_num: lyrics page number
        :param page: lyrics page 
        """
        cont = Container(self.util, self.bounding_box, (0, 0, 0))
        max_line_length = self.get_max_line_length(page)
        s = self.f.size("W")
        page_height = self.lines * s[1]
        offset_y = (self.screen_h - page_height) / 2
        offset_x = (self.screen_w - max_line_length) / 2

        for n, line in enumerate(page):
            c = Component(self.util, bgr=(0, 0, 0))
            str_size = self.f.size(line)
            if page_num == 0 and n == 0:
                color = self.config[COLORS][COLOR_BRIGHT]
            else:
                color = self.config[COLORS][COLOR_CONTRAST]
            img = self.f.render(line, 1, color)
            name = GENERATED_IMAGE + str(n)
            c.content = (name, img)
            c.name = name
            c.image_filename = name
            c.content_y = offset_y + (str_size[1] * n)
            c.content_x = offset_x
            cont.add_component(c)
        self.add_component(cont)
예제 #6
0
    def refresh(self):
        """ Refresh screensaver """

        if self.saver_running:
            self.counter = self.counter + 1
            if int(self.counter *
                   self.one_cycle_period) == self.update_period * 1000:
                self.current_screensaver.refresh()
                self.counter = 0
                if self.config[SCREENSAVER][NAME] in WEB_SAVERS:
                    s = State()
                    if isinstance(self.current_screensaver, Component):
                        screen_savers = [WEATHER, CLOCK, LYRICS, LOGO]
                        if self.current_screensaver.name in screen_savers:
                            s.screen = self.current_screensaver
                        else:
                            s.screen = Container(self.util)
                            s.screen.components = [self.current_screensaver]
                    else:
                        s.screen = self.current_screensaver
                    self.notify_start_listeners(s)
        else:
            if self.current_delay == 0:
                return
            self.delay_counter = self.delay_counter + 1
            if int(self.delay_counter *
                   self.one_cycle_period) == self.current_delay * 1000:
                self.start_screensaver()
예제 #7
0
 def create_left_panel(self, layout, listeners):
     """ Create Station Screen left panel. Include Shutdown button, Left button and Home button.
     
     :param layout: left panel layout
     :param listeners: event listeners
     """
     panel_layout = BorderLayout(layout.LEFT)
     panel_layout.set_percent_constraints(PERCENT_SIDE_BOTTOM_HEIGHT,
                                          PERCENT_SIDE_BOTTOM_HEIGHT, 0, 0)
     left = 0
     if self.station_menu.is_button_defined():
         left = self.station_menu.button.state.index
     self.left_button = self.factory.create_left_button(
         panel_layout.CENTER, str(left), 40, 100)
     self.page_down_button = self.factory.create_page_down_button(
         panel_layout.CENTER, str(left), 40, 100)
     self.page_down_button.set_visible(False)
     self.shutdown_button = self.factory.create_shutdown_button(
         panel_layout.TOP)
     self.home_button = self.factory.create_button(KEY_HOME,
                                                   KEY_HOME,
                                                   panel_layout.BOTTOM,
                                                   image_size_percent=36)
     panel = Container(self.util, layout.LEFT)
     panel.add_component(self.shutdown_button)
     panel.add_component(self.left_button)
     panel.add_component(self.page_down_button)
     panel.add_component(self.home_button)
     Container.add_component(self, panel)
예제 #8
0
 def create_right_panel(self, layout, listeners):
     """ Create right side buttons panel
     
     :param layout: panel layout 
     :param listeners: button listeners 
     """
     panel_layout = BorderLayout(layout.RIGHT)
     panel_layout.set_percent_constraints(PERCENT_SIDE_BOTTOM_HEIGHT,
                                          PERCENT_SIDE_BOTTOM_HEIGHT, 0, 0)
     self.play_button = self.factory.create_play_pause_button(
         panel_layout.TOP, listeners[KEY_PLAY_PAUSE])
     self.right_button = self.factory.create_right_button(
         panel_layout.CENTER, '', 40, 100)
     self.time_volume_button = self.factory.create_time_volume_button(
         panel_layout.BOTTOM, self.toggle_time_volume)
     panel = Container(self.util, layout.RIGHT)
     panel.add_component(self.play_button)
     panel.add_component(self.right_button)
     panel.add_component(self.time_volume_button)
     Container.add_component(self, panel)
예제 #9
0
 def create_left_panel(self, layout, listeners):
     """ Create left side buttons panel
     
     :param layout: panel layout 
     :param listeners: button listeners 
     """
     panel_layout = BorderLayout(layout.LEFT)
     panel_layout.set_percent_constraints(PERCENT_SIDE_BOTTOM_HEIGHT,
                                          PERCENT_SIDE_BOTTOM_HEIGHT, 0, 0)
     self.left_button = self.factory.create_left_button(
         panel_layout.CENTER, '', 40, 100)
     self.shutdown_button = self.factory.create_shutdown_button(
         panel_layout.TOP)
     self.home_button = self.factory.create_button(KEY_HOME,
                                                   KEY_HOME,
                                                   panel_layout.BOTTOM,
                                                   image_size_percent=36)
     panel = Container(self.util, layout.LEFT)
     panel.add_component(self.shutdown_button)
     panel.add_component(self.left_button)
     panel.add_component(self.home_button)
     Container.add_component(self, panel)
예제 #10
0
    def create_left_panel(self, layout, listeners):
        """ Create Station Screen left panel. Include Shutdown button, Left button and Home button.
        
        :param layout: left panel layout
        :param listeners: event listeners
        """
        panel_layout = self.get_panel_layout(layout, LOCATION_LEFT)
        panel_layout.set_percent_constraints(self.button_height,
                                             self.button_height, 0, 0)
        left = 0
        if self.station_menu.is_button_defined():
            left = self.station_menu.button.state.index
        self.left_button = self.factory.create_left_button(
            panel_layout.CENTER, str(left), 40, 100)
        self.page_down_button = self.factory.create_page_down_button(
            panel_layout.CENTER, str(left), 40, 100)
        self.page_down_button.set_visible(False)
        panel_layout.TOP.y += 1
        panel_layout.TOP.h -= 2
        self.shutdown_button = self.factory.create_shutdown_button(
            panel_layout.TOP)
        panel_layout.BOTTOM.h += 1
        self.home_button = self.factory.create_button(KEY_HOME,
                                                      KEY_HOME,
                                                      panel_layout.BOTTOM,
                                                      image_size_percent=36)

        self.shutdown_button.parent_screen = self
        self.home_button.parent_screen = self
        self.left_button.parent_screen = self
        self.page_down_button.parent_screen = self

        panel = Container(self.util, layout.LEFT)
        panel.add_component(self.shutdown_button)
        panel.add_component(self.left_button)
        panel.add_component(self.page_down_button)
        panel.add_component(self.home_button)
        Container.add_component(self, panel)
예제 #11
0
 def create_right_panel(self, layout, arrow_labels):
     """ Create right side buttons panel
     
     :param layout: panel layout 
     :param arrow_labels: show arrow label or not
     """
     panel_layout = self.get_panel_layout(layout, LOCATION_RIGHT)
     panel_layout.set_percent_constraints(self.button_height,
                                          self.button_height, 0, 0)
     panel_layout.TOP.y += 1
     panel_layout.TOP.h -= 2
     self.play_button = self.factory.create_play_pause_button(
         panel_layout.TOP, self.listeners[KEY_PLAY_PAUSE])
     self.right_button = self.factory.create_right_button(
         panel_layout.CENTER, '', 40, 100, arrow_labels)
     self.right_button.add_release_listener(self.go_right)
     panel_layout.BOTTOM.h += 1
     self.custom_button_layout = panel_layout.BOTTOM
     panel = Container(self.util, layout.RIGHT)
     panel.add_component(self.play_button)
     panel.add_component(self.right_button)
     self.right_panel = panel
     self.add_component(panel)
예제 #12
0
 def create_right_panel(self, layout, listeners, arrow_labels):
     """ Create right side buttons panel
     
     :param layout: panel layout 
     :param listeners: button listeners
     :param arrow_labels: show arrow label or not
     """
     panel_layout = self.get_panel_layout(layout, LOCATION_RIGHT)
     panel_layout.set_percent_constraints(self.button_height,
                                          self.button_height, 0, 0)
     panel_layout.TOP.y += 1
     panel_layout.TOP.h -= 2
     self.play_button = self.factory.create_play_pause_button(
         panel_layout.TOP, self.get_listener(listeners, KEY_PLAY_PAUSE))
     self.right_button = self.factory.create_right_button(
         panel_layout.CENTER, '', 40, 100, arrow_labels)
     panel_layout.BOTTOM.h += 1
     self.time_volume_button = self.factory.create_time_volume_button(
         panel_layout.BOTTOM, self.toggle_time_volume)
     panel = Container(self.util, layout.RIGHT)
     panel.add_component(self.play_button)
     panel.add_component(self.right_button)
     panel.add_component(self.time_volume_button)
     self.add_component(panel)
예제 #13
0
    def __init__(self, util, listeners, voice_assistant):
        """ Initializer

        :param util: utility object
        :param listeners: listeners
        :param voice_assistant: voice assistant
        """
        self.util = util
        self.config = util.config
        self.factory = Factory(util)
        self.check_internet_connectivity = listeners[KEY_CHECK_INTERNET]
        self.go_home = listeners[KEY_HOME]
        self.set_modes = listeners[KEY_SET_MODES]
        self.linux = self.config[LINUX_PLATFORM]

        self.wifi_util = WiFiUtil(util)
        self.bluetooth_util = self.util.get_bluetooth_util()

        self.bounding_box = util.screen_rect
        layout = BorderLayout(self.bounding_box)
        layout.set_percent_constraints(PERCENT_TOP_HEIGHT,
                                       PERCENT_BOTTOM_HEIGHT, 0, 0)

        rows = 7
        if self.linux and self.config[USAGE][USE_BLUETOOTH]:
            rows = 7
        else:
            rows = 6

        columns = 1
        d = [rows, columns]
        MenuScreen.__init__(self,
                            util,
                            listeners,
                            rows,
                            columns,
                            voice_assistant,
                            d,
                            None,
                            page_in_title=False,
                            show_loading=False)
        self.title = self.config[LABELS]["network"]
        self.set_title(1)

        center_layout = BorderLayout(self.menu_layout)
        center_layout.set_percent_constraints(0, 0, 47, 0)

        left_layout = center_layout.LEFT
        right_layout = center_layout.CENTER

        label_layout = GridLayout(left_layout)
        label_layout.set_pixel_constraints(rows, columns)
        label_layout.get_next_constraints()

        value_layout = GridLayout(right_layout)
        value_layout.set_pixel_constraints(rows, columns)
        value_layout.get_next_constraints()

        self.network_panel = Container(util, self.menu_layout)

        rect = pygame.Rect(self.menu_layout.x, self.menu_layout.y + 1,
                           self.menu_layout.w, self.menu_layout.h - 1)
        b = util.config[BACKGROUND][MENU_BGR_COLOR]
        bgr = Component(util, rect, 0, 0, self.menu_layout, bgr=b)
        bgr.name = "network.panel.bgr"
        self.network_panel.add_component(bgr)

        self.internet_label = self.add_label(label_layout, self.network_panel,
                                             1)
        self.ethernet_label = self.add_label(label_layout, self.network_panel,
                                             2)
        self.wifi_network_label = self.add_label(label_layout,
                                                 self.network_panel, 3)
        self.wifi_ip_label = self.add_label(label_layout, self.network_panel,
                                            4)
        if self.linux and self.config[USAGE][USE_BLUETOOTH]:
            self.bluetooth_label = self.add_label(label_layout,
                                                  self.network_panel, 5)

        self.internet = self.add_value(value_layout, self.network_panel, 1)
        self.ethernet_ip = self.add_value(value_layout, self.network_panel, 2)
        self.wifi_network = self.add_value(value_layout, self.network_panel, 3)
        self.wifi_ip = self.add_value(value_layout, self.network_panel, 4)
        if self.linux and self.config[USAGE][USE_BLUETOOTH]:
            self.bluetooth = self.add_value(value_layout, self.network_panel,
                                            5)

        self.add_component(self.network_panel)

        listeners[KEY_REFRESH] = self.set_current
        listeners[KEY_DISCONNECT] = self.disconnect_wifi
        listeners[KEY_BLUETOOTH_REMOVE] = self.remove_bluetooth_devices

        self.navigator = NetworkNavigator(self.util, self.layout.BOTTOM,
                                          listeners)
        self.navigator.components[0].set_selected(True)
        self.add_navigator(self.navigator)
        self.original_networks = None
        self.networks = None
        self.current_network = None
        self.current_wifi_network = None
        self.clicked = False
        Screen.link_borders(self, False)
예제 #14
0
    def __init__(self, util, listeners, voice_assistant):
        """ Initializer

        :param util: utility object
        :param listeners: listeners
        :param voice_assistant: voice assistant
        """
        self.util = util
        self.config = util.config
        self.factory = Factory(util)
        self.check_internet_connectivity = listeners[KEY_CHECK_INTERNET]
        self.go_home = listeners[KEY_HOME]
        self.set_modes = listeners[KEY_SET_MODES]

        self.wifi_util = WiFiUtil(util)
        self.bounding_box = util.screen_rect
        layout = BorderLayout(self.bounding_box)
        layout.set_percent_constraints(PERCENT_TOP_HEIGHT,
                                       PERCENT_BOTTOM_HEIGHT, 0, 0)

        d = [6, 1]
        MenuScreen.__init__(self,
                            util,
                            listeners,
                            6,
                            1,
                            voice_assistant,
                            d,
                            None,
                            page_in_title=False,
                            show_loading=False)
        self.title = self.config[LABELS]["network"]
        self.set_title(1)

        center_layout = BorderLayout(self.menu_layout)
        center_layout.set_percent_constraints(0, 0, 47, 0)

        left_layout = center_layout.LEFT
        right_layout = center_layout.CENTER

        label_layout = GridLayout(left_layout)
        label_layout.set_pixel_constraints(6, 1)
        label_layout.get_next_constraints()

        value_layout = GridLayout(right_layout)
        value_layout.set_pixel_constraints(6, 1)
        value_layout.get_next_constraints()

        self.network_panel = Container(util, self.menu_layout, (100, 0, 0))

        rect = pygame.Rect(self.menu_layout.x, self.menu_layout.y + 1,
                           self.menu_layout.w, self.menu_layout.h - 1)
        bgr = Component(util, rect, 0, 0, self.menu_layout, (0, 0, 0),
                        self.util.config[COLORS][COLOR_DARK])
        bgr.name = "network.panel.bgr"
        self.network_panel.add_component(bgr)

        self.internet_label = self.add_label(label_layout, self.network_panel,
                                             1)
        self.ethernet_label = self.add_label(label_layout, self.network_panel,
                                             2)
        self.wifi_network_label = self.add_label(label_layout,
                                                 self.network_panel, 3)
        self.wifi_ip_label = self.add_label(label_layout, self.network_panel,
                                            4)

        self.internet = self.add_value(value_layout, self.network_panel, 1)
        self.ethernet_ip = self.add_value(value_layout, self.network_panel, 2)
        self.wifi_network = self.add_value(value_layout, self.network_panel, 3)
        self.wifi_ip = self.add_value(value_layout, self.network_panel, 4)

        self.set_menu(self.network_panel)

        listeners[KEY_REFRESH] = self.set_current
        listeners[KEY_DISCONNECT] = self.disconnect_wifi

        self.navigator = NetworkNavigator(self.util, self.layout.BOTTOM,
                                          listeners)
        self.components.append(self.navigator)
        self.original_networks = None
        self.networks = None
        self.current_network = None
        self.current_wifi_network = None
        self.clicked = False