Ejemplo n.º 1
0
    def __init__(self, song):
        super(SongDetailScreen, self).__init__(
            clutter.BinLayout(clutter.BIN_ALIGNMENT_CENTER,
                              clutter.BIN_ALIGNMENT_CENTER))
        # Immediately store song information
        self.song = song
        self.set_name('song detail %s' % self.song.title)
        layout = self.get_layout_manager()

        self.header = Header('Song Details')
        self.header.set_width(self.get_width())
        layout.add(self.header, clutter.BIN_ALIGNMENT_CENTER,
                   clutter.BIN_ALIGNMENT_START)

        self.left_arrow = LeftArrow()
        self.play = PlaySymbol()

        self.box = clutter.Box(clutter.BoxLayout())
        box_layout = self.box.get_layout_manager()
        box_layout.set_vertical(True)
        box_layout.set_spacing(20)
        text = clutter.Text(settings.SONG_TITLE_FONT, self.song.title)
        text.set_line_alignment(ALIGN_CENTER)
        text.set_line_wrap(True)
        text.set_color(clutter.Color(230, 230, 230, 0xff))
        self.box.add(text)
        text = clutter.Text(settings.SONG_ARTIST_FONT,
                            "by %s" % self.song.artist.name)
        text.set_line_alignment(ALIGN_CENTER)
        text.set_line_wrap(True)
        text.set_color(clutter.Color(210, 210, 210, 0xff))
        self.box.add(text)
        self.box.set_width(self.get_width() - (self.left_arrow.get_width() +
                                               self.play.get_width()))

        layout.add(
            self.box,
            clutter.BIN_ALIGNMENT_CENTER,
            clutter.BIN_ALIGNMENT_CENTER,
        )

        layout.add(self.left_arrow, clutter.BIN_ALIGNMENT_START,
                   clutter.BIN_ALIGNMENT_CENTER)

        layout.add(self.play, clutter.BIN_ALIGNMENT_END,
                   clutter.BIN_ALIGNMENT_CENTER)
Ejemplo n.º 2
0
    def __init__(self, song):
        super(SongDetailScreen, self).__init__(clutter.BinLayout(
            clutter.BIN_ALIGNMENT_CENTER,
            clutter.BIN_ALIGNMENT_CENTER))
        # Immediately store song information
        self.song = song
        self.set_name('song detail %s' % self.song.title)
        layout = self.get_layout_manager()

        self.header = Header('Song Details')
        self.header.set_width(self.get_width())
        layout.add(self.header,
                   clutter.BIN_ALIGNMENT_CENTER,
                   clutter.BIN_ALIGNMENT_START)

        self.left_arrow = LeftArrow()
        self.play = PlaySymbol()

        self.box = clutter.Box(clutter.BoxLayout())
        box_layout = self.box.get_layout_manager()
        box_layout.set_vertical(True)
        box_layout.set_spacing(20)
        text = clutter.Text(settings.SONG_TITLE_FONT, self.song.title)
        text.set_line_alignment(ALIGN_CENTER)
        text.set_line_wrap(True)
        text.set_color(clutter.Color(230, 230, 230, 0xff))
        self.box.add(text)
        text = clutter.Text(
            settings.SONG_ARTIST_FONT, "by %s" % self.song.artist.name
            )
        text.set_line_alignment(ALIGN_CENTER)
        text.set_line_wrap(True)
        text.set_color(clutter.Color(210, 210, 210, 0xff))
        self.box.add(text)
        self.box.set_width(self.get_width() -
                           (self.left_arrow.get_width() +
                            self.play.get_width()))


        layout.add(self.box,
                   clutter.BIN_ALIGNMENT_CENTER,
                   clutter.BIN_ALIGNMENT_CENTER,)

        layout.add(self.left_arrow,
                   clutter.BIN_ALIGNMENT_START,
                   clutter.BIN_ALIGNMENT_CENTER)

        layout.add(self.play,
                   clutter.BIN_ALIGNMENT_END,
                   clutter.BIN_ALIGNMENT_CENTER)
Ejemplo n.º 3
0
class SongDetailScreen(Screen):
    def __init__(self, song):
        super(SongDetailScreen, self).__init__(
            clutter.BinLayout(clutter.BIN_ALIGNMENT_CENTER,
                              clutter.BIN_ALIGNMENT_CENTER))
        # Immediately store song information
        self.song = song
        self.set_name('song detail %s' % self.song.title)
        layout = self.get_layout_manager()

        self.header = Header('Song Details')
        self.header.set_width(self.get_width())
        layout.add(self.header, clutter.BIN_ALIGNMENT_CENTER,
                   clutter.BIN_ALIGNMENT_START)

        self.left_arrow = LeftArrow()
        self.play = PlaySymbol()

        self.box = clutter.Box(clutter.BoxLayout())
        box_layout = self.box.get_layout_manager()
        box_layout.set_vertical(True)
        box_layout.set_spacing(20)
        text = clutter.Text(settings.SONG_TITLE_FONT, self.song.title)
        text.set_line_alignment(ALIGN_CENTER)
        text.set_line_wrap(True)
        text.set_color(clutter.Color(230, 230, 230, 0xff))
        self.box.add(text)
        text = clutter.Text(settings.SONG_ARTIST_FONT,
                            "by %s" % self.song.artist.name)
        text.set_line_alignment(ALIGN_CENTER)
        text.set_line_wrap(True)
        text.set_color(clutter.Color(210, 210, 210, 0xff))
        self.box.add(text)
        self.box.set_width(self.get_width() - (self.left_arrow.get_width() +
                                               self.play.get_width()))

        layout.add(
            self.box,
            clutter.BIN_ALIGNMENT_CENTER,
            clutter.BIN_ALIGNMENT_CENTER,
        )

        layout.add(self.left_arrow, clutter.BIN_ALIGNMENT_START,
                   clutter.BIN_ALIGNMENT_CENTER)

        layout.add(self.play, clutter.BIN_ALIGNMENT_END,
                   clutter.BIN_ALIGNMENT_CENTER)

    def on_press(self, actor, event):
        """
        """
        if event.keyval == clutter.keysyms.Left:
            self.get_parent().remove_screen(self)
        elif event.keyval == clutter.keysyms.Return:
            if can_buy_song():
                logging.info('User bought song %s.' % self.song)
                queue_song(self.song)
                credits_decrement()
                transient_message.message('Bought song %s' % self.song,
                                          color=clutter.Color(40, 250, 40))
                self.header.update()
            else:
                transient_message.message('Insert Quarter!',
                                          color=clutter.Color(250, 40, 40))

    def update(self):
        """
        """
        self.header.update()
Ejemplo n.º 4
0
class SongDetailScreen(Screen):

    def __init__(self, song):
        super(SongDetailScreen, self).__init__(clutter.BinLayout(
            clutter.BIN_ALIGNMENT_CENTER,
            clutter.BIN_ALIGNMENT_CENTER))
        # Immediately store song information
        self.song = song
        self.set_name('song detail %s' % self.song.title)
        layout = self.get_layout_manager()

        self.header = Header('Song Details')
        self.header.set_width(self.get_width())
        layout.add(self.header,
                   clutter.BIN_ALIGNMENT_CENTER,
                   clutter.BIN_ALIGNMENT_START)

        self.left_arrow = LeftArrow()
        self.play = PlaySymbol()

        self.box = clutter.Box(clutter.BoxLayout())
        box_layout = self.box.get_layout_manager()
        box_layout.set_vertical(True)
        box_layout.set_spacing(20)
        text = clutter.Text(settings.SONG_TITLE_FONT, self.song.title)
        text.set_line_alignment(ALIGN_CENTER)
        text.set_line_wrap(True)
        text.set_color(clutter.Color(230, 230, 230, 0xff))
        self.box.add(text)
        text = clutter.Text(
            settings.SONG_ARTIST_FONT, "by %s" % self.song.artist.name
            )
        text.set_line_alignment(ALIGN_CENTER)
        text.set_line_wrap(True)
        text.set_color(clutter.Color(210, 210, 210, 0xff))
        self.box.add(text)
        self.box.set_width(self.get_width() -
                           (self.left_arrow.get_width() +
                            self.play.get_width()))


        layout.add(self.box,
                   clutter.BIN_ALIGNMENT_CENTER,
                   clutter.BIN_ALIGNMENT_CENTER,)

        layout.add(self.left_arrow,
                   clutter.BIN_ALIGNMENT_START,
                   clutter.BIN_ALIGNMENT_CENTER)

        layout.add(self.play,
                   clutter.BIN_ALIGNMENT_END,
                   clutter.BIN_ALIGNMENT_CENTER)


    def on_press(self, actor, event):
        """
        """
        if event.keyval == clutter.keysyms.Left:
            self.get_parent().remove_screen(self)
        elif event.keyval == clutter.keysyms.Return:
            if can_buy_song():
                logging.info('User bought song %s.' % self.song)
                queue_song(self.song)
                credits_decrement()
                transient_message.message('Bought song %s' % self.song,
                                          color=clutter.Color(40, 250, 40))
                self.header.update()
            else:
                transient_message.message('Insert Quarter!',
                                          color=clutter.Color(250, 40, 40))

    def update(self):
        """
        """
        self.header.update()