- More work on music player layout

- Fixes to image_row
- Inclusion of signals in label_list items
This commit is contained in:
noisymime 2008-03-25 11:00:45 +00:00
parent 62edc69faf
commit ed84bee2d3
4 changed files with 90 additions and 39 deletions

View File

@ -9,6 +9,8 @@ from ui_elements.image_frame import ImageFrame
from ui_elements.label_list import LabelList
class Module:
CONTEXT_HEADINGS, CONTEXT_ROW, CONTEXT_LIST1, CONTEXT_LIST2 = range(4)
title = "Music"
num_columns = 6
sleep_time = 0.2
@ -26,6 +28,9 @@ class Module:
self.artistImageRow = MusicObjectRow(self.glossMgr, self.stage.get_width(), 200, self.num_columns, self)
#This is the current input context
self.current_context = self.CONTEXT_ROW
self.lastFM = lastFM_interface()
self.base_dir = self.dbMgr.get_setting("MusicLocation")
self.images_dir = self.get_images_dir()
@ -70,25 +75,42 @@ class Module:
if event.keyval == clutter.keysyms.q:
clutter.main_quit()
if (event.keyval == clutter.keysyms.Left) or (event.keyval == clutter.keysyms.Right):
#calculate a period of time the loading threads should sleep for when a timline is in progress
#self.sleep_time = float(MusicObjectRow.frames) / float(MusicObjectRow.fps)
duration = float(MusicObjectRow.frames) / float(MusicObjectRow.fps)
self.artistImageRow.input_queue.input(event)
self.artistImageRow.sleep = True
#Just a little test code
artist = self.artistImageRow.get_current_object()
albums = self.backend.get_albums_by_artistID(artist.artistID)
self.list1.clear()
for album in albums:
self.list1.add_item(album.name)
#name_string += album.name
self.list1.display()
#self.tmpLabel.set_text(name_string)
pixbuf = albums[0].get_image()
if not pixbuf is None:
self.main_img.set_pixbuf(pixbuf)
#React based on the current input context
if self.current_context == self.CONTEXT_ROW:
if (event.keyval == clutter.keysyms.Left) or (event.keyval == clutter.keysyms.Right):
duration = float(MusicObjectRow.frames) / float(MusicObjectRow.fps)
self.artistImageRow.input_queue.input(event)
self.artistImageRow.sleep = True
#Just a little test code
artist = self.artistImageRow.get_current_object()
albums = self.backend.get_albums_by_artistID(artist.artistID)
self.list1.clear()
for album in albums:
tmpItem = self.list1.add_item(album.name)
tmpItem.connect("selected", self.process_songlist_from_album, album)
#name_string += album.name
self.list1.display()
#self.tmpLabel.set_text(name_string)
pixbuf = albums[0].get_image()
if not pixbuf is None:
self.main_img.set_pixbuf(pixbuf)
elif (event.keyval == clutter.keysyms.Down):
self.list1.select_first_elegant()
self.current_context = self.CONTEXT_LIST1
elif self.current_context == self.CONTEXT_LIST1:
if (event.keyval == clutter.keysyms.Down) or (event.keyval == clutter.keysyms.Up):
self.list1.input_queue.input(event)
#Fills self.list2 with songs from an album
def process_songlist_from_album(self, list_item, album):
#print "got album %s" % album.name
songs = self.backend.get_songs_by_albumID(album.albumID)
self.list2.clear()
for song in songs:
tmpItem = self.list2.add_item(song.name)
self.list2.display()
def begin(self, glossMgr):
@ -118,6 +140,10 @@ class Module:
self.list1 = LabelList(5)
self.list1.set_position(self.stage.get_width()/2, 350)
self.stage.add(self.list1)
self.list2 = LabelList(5)
self.list2.set_position( (self.list1.get_x() + self.list1.get_width()), 350)
self.stage.add(self.list2)
"""
self.tmpLabel = clutter.Label()
self.tmpLabel.set_color(clutter.color_parse('White'))
@ -138,6 +164,7 @@ class Module:
#Load the rest of the images
#thread.start_new_thread(self.load_image_range, (self.num_columns, len(self.artists)-1))
self.artistImageRow.sleep = True
self.timeline_backdrop.connect("completed", self.artistImageRow.load_image_range_cb)
#self.load_image_range(self.num_columns, len(self.artists)-1)

View File

@ -14,7 +14,7 @@ class MythBackendConnection(threading.Thread):
def __init__(self, videoPlayer, server, port):
threading.Thread.__init__(self)
self.protocolVersion = 31
self.protocolVersion = 40
self.localhost_name = "myhost" # Change this later
self.server = server #"192.168.0.8"
self.server_port = port #6543
@ -78,7 +78,7 @@ class MythBackendConnection(threading.Thread):
if not result == protRecvString:
#Protocol Version check failed
backend_protocol = result.rsplit("[]:[]")[1]
err_string = "Myth Protocol version failure. This client uses protocol %s however backend is using %s." % (self.protocolVersion, backend_protocol)
err_string = "Myth Protocol version failure. This client uses protocol version %s however backend is using %s." % (self.protocolVersion, backend_protocol)
raise RuntimeError(err_string)
#Perform the mandatory ANN

View File

@ -35,7 +35,7 @@ class ImageRow(clutter.Group):
self.image_size = int(self.images_width / self.num_columns) #A cover will be cover_size * cover_size (X * Y)
self.center = int(columns / 2) + 1
"""
#The viewer actually sits within another group that clips its size
self.images_group_clip = clutter.Group()
self.images_group_clip.add(self.images_group)
@ -47,6 +47,9 @@ class ImageRow(clutter.Group):
clip_width = (self.image_size*columns) + scale_amount #Width is the cover size by the number of colums, plus the additional amount required for scaling
clip_height = (height) + scale_amount
self.images_group_clip.set_clip(-(scale_amount/2), -(scale_amount/2), clip_width, clip_height)
"""
pos_x = int(self.image_size/2) + (self.image_size * (self.center-1))
self.images_group.set_position(pos_x, int(self.image_size/2))
#self.current_video_details = video_details_group(self.covers_width)
@ -66,14 +69,14 @@ class ImageRow(clutter.Group):
self.currentSelection = 0
self.add(self.images_group_clip)
#self.add(self.images_group)
#self.add(self.images_group_clip)
self.add(self.images_group)
covers_x = int(width * (1-self.images_size_percent)/2)
covers_y = int(height * (1-self.images_size_percent)/2)
#self.images_group.set_position(covers_x, covers_y)
#self.images_group.set_depth(1) #self.image_size)
self.images_group.show()
self.images_group_clip.show()
#self.images_group_clip.show()
def add_texture_group(self, tempGroup):
@ -94,6 +97,13 @@ class ImageRow(clutter.Group):
tempGroup.set_opacity(0)
else:
self.images_group.add(tempGroup)
#Set the gravity to the center
gap = (self.image_size - tempGroup.get_width())/2
anchor_x = (self.image_size - self.image_gap)/2
gap = (self.image_size - tempGroup.get_height())/2
anchor_y = (self.image_size - self.image_gap)/2
tempGroup.set_anchor_point(anchor_x, anchor_y)
tempGroup.show()
self.num_images += 1

View File

@ -26,6 +26,9 @@ class LabelList(clutter.Group):
self.displayMax = length
self.displaySize = self.displayMax - self.displayMin
#Selector bar image, moves with selections to show current item
self.selector_bar = None
def on_key_press_event (self, event):
self.input_queue.input(event)
return self.timeline
@ -72,7 +75,7 @@ class LabelList(clutter.Group):
if direction == self.DIRECTION_DOWN:
#Check if we're at the last item in the list
if (self.selected) == (len(self.menuItems)-1):
if (self.selected) == (len(self.items)-1):
return
else:
self.selected = self.selected+1
@ -98,7 +101,7 @@ class LabelList(clutter.Group):
elif (i == self.selected+1) and (i <= self.displayMax-1):
self.items[i].scaleLabel(ListItem.SCALE_MEDIUM, self.timeline)
else:
self.items[i].scaleLabel(ListItem.SCALE_None, self.timeline)
self.items[i].scaleLabel(ListItem.SCALE_NONE, self.timeline)
#Check we're at the top of the viewable list
if self.selected < (self.displayMin):
@ -107,8 +110,9 @@ class LabelList(clutter.Group):
#self.menuItems[self.selected].show()
self.rollList( self.menuItems[self.selected], self.menuItems[self.selected+self.displaySize], self.timeline)
else:
#move the selection bar
self.glossMgr.get_selector_bar().selectItem(self.menuItems[self.selected], self.timeline)
if not self.selector_bar is None:
#move the selection bar
self.selector_bar().selectItem(self.menuItems[self.selected], self.timeline)
self.timeline.start()
@ -118,11 +122,13 @@ class LabelList(clutter.Group):
def move_down(self):
self.move_selection(self.DIRECTION_DOWN)
def selectFirst(self, moveBar):
if self.timeline.is_playing:
def select_first(self, frames = 1, fps = 75):
if self.input_queue.is_in_queue():
"ERROR: Timeline should NOT be playing here!"
return
self.timeline = clutter.Timeline(1, 75)
self.timeline = clutter.Timeline(frames, fps)
self.input_queue.set_timeline(self.timeline)
self.selected = 0
for i in range(0,len(self.items)):
if i == 0:
@ -132,14 +138,12 @@ class LabelList(clutter.Group):
else:
self.items[i].scaleLabel(ListItem.SCALE_NONE, self.timeline)
#Show the current menu item's graphic
self.menuItems[self.selected].itemTexturesGroup.show()
if moveBar:
self.glossMgr.get_selector_bar().selectItem(self.menuItems[self.selected], self.timeline)
self.timeline.start()
#Just calls the above function with different arguements to result in the first item being selected in a 'prettier' manner
def select_first_elegant(self):
self.select_first(frames=self.frames, fps=self.fps)
#When the menu needs to display a new item from the top or bottom, it rolls
# The distance the menu moves is the distance (in pixels) between the incoming item and the selector bar
def rollList(self, incomingMenuItem, outgoingMenuItem, timeline):
@ -184,8 +188,16 @@ class LabelList(clutter.Group):
self.behaviour1.apply(self)
self.behaviour2.apply(outgoingMenuItem)
import gobject
class ListItem(clutter.Group):
#Setup signals
__gsignals__ = {
"selected": (
gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, []),
"deselected": (
gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, [])
}
SCALE_NONE, SCALE_MEDIUM, SCALE_FULL = range(3)
#Default values for zoom and opacity
@ -239,9 +251,11 @@ class ListItem(clutter.Group):
if level == self.SCALE_FULL:
zoomTo = self.scale_step_full #self.menu.zoomStep0
opacityTo = self.opacity_step_full #self.menu.opacityStep0
self.emit("selected")
if level == self.SCALE_MEDIUM:
zoomTo = self.scale_step_medium #self.menu.zoomStep1
opacityTo = self.opacity_step_medium #self.menu.opacityStep1
self.emit("deselected")
#self.itemTexturesGroup.hide_all()
if level == self.SCALE_NONE:
zoomTo = self.scale_step_none #self.menu.zoomStep2