class Header(clutter.Box): def __init__(self, title): super(Header, self).__init__( clutter.BinLayout(clutter.BIN_ALIGNMENT_CENTER, clutter.BIN_ALIGNMENT_START,) ) layout = self.get_layout_manager() #layout.set_vertical(False) # Setup default header elements. self.logo = LogoSmall() self.title = clutter.Text(settings.HEADER_TITLE_FONT, title) self.title.set_color(FONT_COLOR) self.credits = Credits() layout.add(self.logo, clutter.BIN_ALIGNMENT_START, clutter.BIN_ALIGNMENT_START) layout.add(self.title, clutter.BIN_ALIGNMENT_CENTER, clutter.BIN_ALIGNMENT_START) layout.add(self.credits, clutter.BIN_ALIGNMENT_END, clutter.BIN_ALIGNMENT_START) def update(self): """ Update the contents of oneself, specifically the credits information. """ self.credits.update()
class Header(clutter.Box): def __init__(self, title): super(Header, self).__init__( clutter.BinLayout( clutter.BIN_ALIGNMENT_CENTER, clutter.BIN_ALIGNMENT_START, )) layout = self.get_layout_manager() #layout.set_vertical(False) # Setup default header elements. self.logo = LogoSmall() self.title = clutter.Text(settings.HEADER_TITLE_FONT, title) self.title.set_color(FONT_COLOR) self.credits = Credits() layout.add(self.logo, clutter.BIN_ALIGNMENT_START, clutter.BIN_ALIGNMENT_START) layout.add(self.title, clutter.BIN_ALIGNMENT_CENTER, clutter.BIN_ALIGNMENT_START) layout.add(self.credits, clutter.BIN_ALIGNMENT_END, clutter.BIN_ALIGNMENT_START) def update(self): """ Update the contents of oneself, specifically the credits information. """ self.credits.update()
class FrontScreen(Screen): def __init__(self): super(FrontScreen, self).__init__( clutter.BinLayout(clutter.BIN_ALIGNMENT_CENTER, clutter.BIN_ALIGNMENT_CENTER) ) layout = self.get_layout_manager() self.credits = Credits() layout.add(self.credits, clutter.BIN_ALIGNMENT_START, clutter.BIN_ALIGNMENT_END) self.right_arrow = RightArrow() layout.add(self.right_arrow, clutter.BIN_ALIGNMENT_END, clutter.BIN_ALIGNMENT_CENTER) self.boxed_contents = clutter.Box(clutter.BoxLayout()) box_layout = self.boxed_contents.get_layout_manager() box_layout.set_use_animations(True) box_layout.set_vertical(True) box_layout.set_spacing(100) self.header = LogoLarge() box_layout.pack(self.header, True, False, False, clutter.BOX_ALIGNMENT_CENTER, clutter.BOX_ALIGNMENT_CENTER) self.labels = ( clutter.Text(settings.FRONT_SCREEN_FONT, 'songs'), clutter.Text(settings.FRONT_SCREEN_FONT, 'artists'), ) self.selected = self.labels[0] for label in self.labels: label.set_color(FONT_COLOR) label.set_opacity(FONT_OPACITY) label.set_property('scale-gravity', clutter.GRAVITY_CENTER) box_layout.pack(label, True, False, False, clutter.BOX_ALIGNMENT_CENTER, clutter.BOX_ALIGNMENT_CENTER) layout.add(self.boxed_contents, clutter.BIN_ALIGNMENT_CENTER, clutter.BIN_ALIGNMENT_START) self.highlight(self.selected) def on_timeline_completed(self, timeline, behaviour): """ """ behaviour.remove_all() def get_selected(self): """ """ return self.selected.get_text() def highlight(self, actor): """ """ actor.animate(clutter.LINEAR, HIGHLIGHT_RATE, "opacity", 255, "scale-x", 1.3, "scale-y", 1.3, ) def blink(self, actor): animation = actor.animate(clutter.LINEAR, BLINK_RATE, 'color', clutter.Color(255, 0, 0, 255)) animation.connect_after('completed', self.on_blink_completed, actor) #animation.set_loop(True) def unhighlight(self, actor): """ """ actor.animate(clutter.LINEAR, HIGHLIGHT_RATE, "scale-x", 1, "scale-y", 1, "opacity", FONT_OPACITY, ) def on_blink_completed(self, animation, actor): if actor.get_color() == clutter.Color(255, 0, 0, 255): animation = actor.animate(clutter.LINEAR, BLINK_RATE, 'color', clutter.Color(0, 255, 0, 255)) elif actor.get_color() == clutter.Color(0, 255, 0, 255): animation = actor.animate(clutter.LINEAR, BLINK_RATE, 'color', clutter.Color(0, 0, 255, 255)) elif actor.get_color() == clutter.Color(0, 0, 255, 255): animation = actor.animate(clutter.LINEAR, BLINK_RATE, 'color', clutter.Color(255, 0, 0, 255)) animation.connect_after('completed', self.on_blink_completed, actor) def on_press(self, actor, event): """ Keyboard button press callback. """ if event.keyval == clutter.keysyms.Up: index = self.labels.index(self.selected) if index > 0: self.unhighlight(self.selected) self.selected = self.labels[index - 1] self.highlight(self.selected) elif event.keyval == clutter.keysyms.Down: index = self.labels.index(self.selected) if index < len(self.labels) - 1: self.unhighlight(self.selected) self.selected = self.labels[index + 1] self.highlight(self.selected) elif event.keyval == clutter.keysyms.Right: if self.selected.get_text() == 'songs': self.get_parent().new_screen(SongListScreen()) elif self.selected.get_text() == 'artists': self.get_parent().new_screen(ArtistListScreen()) def update(self): """ Update the contents of oneself, specifically the credits information. """ self.credits.update()