- Loading screen for music

- Creation of image clone
This commit is contained in:
noisymime 2008-04-04 22:56:05 +00:00
parent f9f73c1962
commit e4db5ad53b
6 changed files with 91 additions and 60 deletions

View File

@ -161,7 +161,7 @@ class InputQueue(gobject.GObject):
self.accelerating = True
if self.current_acceleration_step < self.acceleration_steps:
self.current_acceleration_step +=1
print "accelerating: %s" % str(self.current_acceleration_step)
#print "accelerating: %s" % str(self.current_acceleration_step)
self.current_acceleration_factor = self.current_acceleration_step * (self.acceleration_factor_base / self.acceleration_steps)
fps = self.base_fps * self.current_acceleration_factor
@ -170,14 +170,14 @@ class InputQueue(gobject.GObject):
if self.current_acceleration_step == 1: gobject.timeout_add( (self.acceleration_time / self.acceleration_steps), self.accelerate)
return True
print "Acceleration finished"
#print "Acceleration finished"
return False
def decelerate(self, actor = None, event = None):
#print "Key released: %s" % str(gtk.gdk.keyval_name(event.keyval))
if self.current_acceleration_step > 0:
self.current_acceleration_step -= 1
print "decelerating: %s" % str(self.current_acceleration_step)
#print "decelerating: %s" % str(self.current_acceleration_step)
self.current_acceleration_factor = self.current_acceleration_step * (self.acceleration_factor_base / self.acceleration_steps)
fps = self.base_fps * self.current_acceleration_factor
@ -187,5 +187,5 @@ class InputQueue(gobject.GObject):
return True
self.accelerating = False
print "Deceleration finished"
#print "Deceleration finished"
return False

View File

@ -427,40 +427,6 @@ class MenuListItem (MenuItem):
def get_zoom_level(self):
return self.zoomLevel
def add_image_from_path(self, path, x, y):
self.tempTexture = clutter.Texture()
pixbuf = gtk.gdk.pixbuf_new_from_file(path)
tempTexture.set_pixbuf(pixbuf)
self.add_image_from_texture(tempTexture, x, y)
def add_image_from_texture(self, texture):
if texture is None:
print "NO TEXTURE!"
"""
Removing as this is currently already handled in individual module files
#Set the image to the size in the theme
if not self.menu.menu_image_height is None:
texture.set_height(self.menu.menu_image_height)
if not self.menu.menu_image_width is None:
texture.set_width(self.menu.menu_image_width)
"""
#Rotate appropriately
rotation = self.menu.menu_image_rotation
x_rotation = (texture.get_width())
texture.set_rotation(clutter.Y_AXIS, rotation, x_rotation, 0, 0)
self.itemTexturesGroup.add(texture)
#If reflection is turned on in the theme, add a reflection texture
if self.menu.useReflection:
self.reflectionTexture = Texture_Reflection(texture)
self.itemTexturesGroup.add(self.reflectionTexture)
self.itemTexturesGroup.show_all()
def set_data(self, data):
self.data = data

View File

@ -17,6 +17,8 @@ class MenuItem (clutter.Label):
self.itemTexturesGroup = clutter.Group()
self.itemTexturesGroup.set_position(menu.menu_image_x, menu.menu_image_y)
#The main texture is the first one that is added to the item
self.main_texture = None
#setup the label
font = menu.font
@ -52,12 +54,15 @@ class MenuItem (clutter.Label):
pixbuf = gtk.gdk.pixbuf_new_from_file(path)
tempTexture.set_pixbuf(pixbuf)
self.add_image_from_texture(tempTexture)
def add_image_from_texture(self, texture):
if texture is None:
print "NO TEXTURE!"
if texture is None: print "NO TEXTURE!"
if self.main_texture is None:
self.main_texture = texture
"""
Removing as this is currently already handled in individual module files
#Set the image to the size in the theme
@ -86,6 +91,9 @@ class MenuItem (clutter.Label):
def get_data(self):
return self.data
def get_main_texture(self):
return self.main_texture
def setAction(self, newAction):
self.action = newAction

View File

@ -25,6 +25,8 @@ class MusicObjectRow(ImageRow):
def add_object(self, object):
self.objectLibrary.append(object)
def load_image_range_cb(self, timeline, start, end, as_thread = False, thread_data = None):
self.load_image_range(start, end, as_thread, thread_data)
def load_image_range(self, start, end, as_thread = False, thread_data = None):
#External timeline can be set by other objects as a form of 'lock'. If external timeline is running, thread will be paused
@ -36,7 +38,7 @@ class MusicObjectRow(ImageRow):
print "loading: " + object.name
pixbuf = object.get_image()
#If there is currently motion, we need to pause this work
while self.should_sleep():
if self.should_sleep():
time.sleep(0.1)
#if self.sleep:
#self.timeline.connect('completed', self.restart_cb)

View File

@ -7,6 +7,7 @@ from modules.music_player.backends.myth_music import Backend
from modules.music_player.lastFM_interface import lastFM_interface
from modules.music_player.music_object_row import MusicObjectRow
from ui_elements.image_frame import ImageFrame
from ui_elements.image_clone import ImageClone
from ui_elements.label_list import LabelList
class Module:
@ -156,36 +157,56 @@ class Module:
clutter.threads_leave()
def begin(self, glossMgr):
#self.display("blah", glossMgr)
#return
self.artistImageRow.objectLibrary = self.artists
#thread.start_new_thread(self.artistImageRow.load_image_range, (0, len(self.artists)-1, True))
gobject.idle_add(self.artistImageRow.load_image_range, 0, len(self.artists)-1, True)
self.artistImageRow.connect("load-complete", self.display, glossMgr)
self.timeline_loading = clutter.Timeline(10,40)
self.alpha = clutter.Alpha(self.timeline_loading, clutter.ramp_inc_func)
self.opacity_behaviour = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=self.alpha)
def display(self, data, glossMgr):
#Create a backdrop for the player. In this case we just use the same background as the menus
self.backdrop = glossMgr.get_themeMgr().get_texture("background", None, None)
self.backdrop.set_size(self.stage.get_width(), self.stage.get_height())
self.backdrop.set_opacity(0)
self.backdrop.show()
self.stage.add(self.backdrop)
#Fade the backdrop in
self.timeline_backdrop = clutter.Timeline(10,40)
self.alpha = clutter.Alpha(self.timeline_backdrop, clutter.ramp_inc_func)
self.backdrop_behaviour = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=self.alpha)
self.backdrop_behaviour.apply(self.backdrop)
self.opacity_behaviour.apply(self.backdrop)
#Load in the initial images:
#self.artistImageRow.objectLibrary = self.artists
#self.artistImageRow.load_image_range(0, self.num_columns)
self.loading_img = ImageClone(glossMgr.get_current_menu().get_current_item().get_main_texture())
self.loading_img.show()
self.stage.add(self.loading_img)
x = int( (self.stage.get_width() - self.loading_img.get_width()) / 2 )
y = int( (self.stage.get_height() - self.loading_img.get_height()) / 2 )
knots = (\
(int(self.loading_img.get_x()), int(self.loading_img.get_y()) ),\
(x, y)\
)
self.path_behaviour = clutter.BehaviourPath(knots = knots, alpha = self.alpha)
self.path_behaviour.apply(self.loading_img)
self.timeline_loading.start()
self.artistImageRow.objectLibrary = self.artists
self.artistImageRow.connect("load-complete", self.display, glossMgr)
self.timeline_loading.connect("completed", self.artistImageRow.load_image_range_cb, 0, len(self.artists)-1, False)
#thread.start_new_thread(self.artistImageRow.load_image_range, (0, len(self.artists)-1, True))
#gobject.idle_add(self.artistImageRow.load_image_range, 0, len(self.artists)-1, True)
def display(self, data, glossMgr):
self.timeline_display = clutter.Timeline(10,40)
self.alpha = clutter.Alpha(self.timeline_display, clutter.ramp_inc_func)
self.opacity_behaviour_incoming = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=self.alpha)
self.opacity_behaviour_outgoing = clutter.BehaviourOpacity(opacity_start=255, opacity_end=0, alpha=self.alpha)
#Fade the backdrop in
self.opacity_behaviour_outgoing.apply(self.loading_img)
self.stage.add(self.artistImageRow)
self.artistImageRow.set_opacity(0)
self.artistImageRow.select_first()
self.artistImageRow.show()
self.backdrop_behaviour.apply(self.artistImageRow)
self.opacity_behaviour_incoming.apply(self.artistImageRow)
#Just a nasty temp label for outputting stuff
self.list1 = LabelList(5)
@ -203,7 +224,7 @@ class Module:
self.main_img.show()
self.stage.add(self.main_img)
self.timeline_backdrop.start()
self.timeline_display.start()
def stop(self):

View File

@ -0,0 +1,34 @@
import pygtk
import gtk
import clutter
########################################################
# A simple class that copies all of an images properties
# and returns a clone texture.
########################################################
class ImageClone(clutter.CloneTexture):
def __init__(self, texture):
clutter.CloneTexture.__init__(self, texture)
self.set_size(texture.get_x(), texture.get_y())
self.set_opacity(texture.get_opacity())
(abs_x, abs_y) = texture.get_abs_position()
self.set_position(abs_x, abs_y)
"""
ang_y = texture.get_rotation(clutter.Y_AXIS)
self.set_rotation(clutter.Y_AXIS, ang_y[0], (texture.get_width()), 0, 0)
ang_x = texture.get_rotation(clutter.X_AXIS)
self.set_rotation(clutter.X_AXIS, ang_x[0], 0, (texture.get_height()), 0)
#ang_z = origTexture.get_rotation(clutter.Z_AXIS)
#self.set_rotation(clutter.Z_AXIS, ang_z[0], 0, 0, 0
"""
self.set_depth(texture.get_depth())
(anchor_x, anchor_y) = texture.get_anchor_point()
self.set_anchor_point(anchor_x, anchor_y)
#if texture.has_clip(): self.set_clip(texture.get_clip())