Multiple fixes for updated Clutter 0.5 BehaviourScale

This commit is contained in:
noisymime 2008-01-22 11:40:48 +00:00
parent c9a2b7076d
commit 5985ce3908
7 changed files with 123 additions and 86 deletions

View File

@ -65,6 +65,9 @@ class GlossMgr:
self.currentMenu.show_all()
self.currentMenu.show()
self.stage.add(self.currentMenu)
self.stage.add(self.currentMenu.getItemGroup())
#This is a bit hacky, but we set the selector bar size based on the font size
tmpLabel = clutter.Label()
tmpLabel.set_text("AAA")
@ -123,6 +126,7 @@ class GlossMgr:
else:
#hide any unnecesary actors
self.currentMenu.hide()
#self.stage.remove(self.currentMenu.getItemGroup())
#And begin the plugin
action.begin( self )

11
Menu.py
View File

@ -32,12 +32,10 @@ class Menu(clutter.Group):
self.displaySize = self.displayMax - self.displayMin
self.displayPosition = (0, 0)
self.stage.add(self.itemGroup)
self.timeline = clutter.Timeline(15, 75) #This timeline is used on any movements that occur when changing items
self.input_queue.set_timeline(self.timeline)
self.timeline_completed=True
self.glossMgr.addMenu(self)
self.stage.add(self)
def addItem(self, itemLabel):
if len(self.menuItems) == 0:
@ -225,6 +223,7 @@ class Menu(clutter.Group):
self.menuItems[i].scaleLabel(1, self.timeline)
else:
self.menuItems[i].scaleLabel(2, self.timeline)
#Show the current menu item's graphic
self.menuItems[self.selected].itemTexturesGroup.show()
@ -359,11 +358,9 @@ class ListItem (clutter.Label):
return None
alpha = clutter.Alpha(timeline, clutter.ramp_inc_func)
self.behaviour1 = clutter.BehaviourScale(scale_start=self.currentZoom, scale_end=zoomTo, alpha=alpha) #scale_gravity=clutter.GRAVITY_WEST,
#self.behaviour1 = clutter.BehaviourScale(x_scale_start=self.currentZoom, y_scale_start=self.currentZoom, x_scale_end=zoomTo, y_scale_end=zoomTo, alpha=alpha) #scale_gravity=clutter.GRAVITY_WEST,
#self.behaviour1 = clutter.BehaviourScale(x_scale_start=1, y_scale_start=1, x_scale_end=1, y_scale_end=1, alpha=alpha) #scale_gravity=clutter.GRAVITY_WEST,
#self.set_scale(self.currentZoom, zoomTo)
self.set_anchor_point_from_gravity(clutter.GRAVITY_WEST)
#self.behaviour1 = clutter.BehaviourScale(scale_start=self.currentZoom, scale_end=zoomTo, alpha=alpha) #scale_gravity=clutter.GRAVITY_WEST,
self.behaviour1 = clutter.BehaviourScale(x_scale_start=self.currentZoom, y_scale_start=self.currentZoom, x_scale_end=zoomTo, y_scale_end=zoomTo, alpha=alpha) #scale_gravity=clutter.GRAVITY_WEST,
#self.set_anchor_point_from_gravity(clutter.GRAVITY_WEST)
self.behaviour1.set_property("scale-gravity", clutter.GRAVITY_WEST) #As at Clutter r1807 you cannot set the gravity on the line above.
self.behaviour2 = clutter.BehaviourOpacity(opacity_start=self.currentOpacity, opacity_end=opacityTo, alpha=alpha)
self.behaviour1.apply(self)

View File

@ -25,6 +25,9 @@ class Module:
if self.isPlaying:
self.videoController.on_key_press_event(event)
if event.keyval == clutter.keysyms.Escape:
self.videoController.stop_video()
if event.keyval == clutter.keysyms.p:
if self.paused:
self.unpause()
@ -38,13 +41,14 @@ class Module:
def begin(self, glossMgr):
uri = "dvd://1"
#glossMgr.background.hide()
self.videoController = VideoController(glossMgr)
self.video = self.videoController.play_video(uri, self)
self.isPlaying = True
def stop(self):
if self.video.get_playing():
self.videoController.stop_video()
#self.videoController.stop_video()
timeline = clutter.Timeline(15, 25)
timeline.connect('completed', self.end_video_event)
@ -53,9 +57,13 @@ class Module:
behaviour.apply(self.video)
timeline.start()
def end_video_event(self, data):
self.stage.remove(self.video)
def stop_video(self):
self.stop()
def pause(self):
self.paused = True
self.videoController.pause_video()

View File

@ -22,7 +22,6 @@ class Module:
def __init__(self, glossMgr, dbMgr):
self.glossMgr = glossMgr
self.setup_ui()
self.currentTexture = clutter.Texture()
self.currentSong = None
self.paused = False
self.textures = []
@ -100,6 +99,7 @@ class Module:
def begin(self, glossMgr):
self.stage = self.glossMgr.get_stage()
self.currentTexture = clutter.Texture()
#Check for an empty baseDir, this means there are no slideshows or no db connection. We simply tell the menuMgr to go back a menu level when this occurs
if self.baseDir is None:
@ -140,6 +140,10 @@ class Module:
self.currentFilename = self.textures[self.rand1]
pixbuf = gtk.gdk.pixbuf_new_from_file(self.currentFilename)
self.currentTexture.set_pixbuf(pixbuf)
(x_pos, y_pos) = self.get_random_coords(self.currentTexture)
self.currentTexture.set_position(x_pos, y_pos)
self.stage.add(self.currentTexture)
#Make sure its visible
self.currentTexture.set_opacity(255)
@ -185,7 +189,7 @@ class Module:
#Zooming stuff
rand_zoom = random.uniform(1,1.3) # Zoom somewhere between 1 and 1.3 times
self.behaviour1 = clutter.BehaviourScale(scale_start=1, scale_end=rand_zoom, alpha=self.alpha)
self.behaviour1 = clutter.BehaviourScale(x_scale_start=1, y_scale_start=1, x_scale_end=rand_zoom, y_scale_end=rand_zoom, alpha=self.alpha)
#self.behaviour1.set_property("scale-gravity", clutter.GRAVITY_CENTER) #As at Clutter r1807 you cannot set the gravity on the line above.
#panning stuff
@ -220,13 +224,16 @@ class Module:
self.behaviour4.apply(self.nextTexture)
#Pick a random spot for the next image
x_pos = random.randint(0, abs(self.stage.get_width() - self.nextTexture.get_width()) ) #Somewhere between 0 and (stage_width-image_width)
y_pos = random.randint(0, abs(self.stage.get_height() - self.nextTexture.get_height()) )
#x_pos = random.randint(0, abs(self.stage.get_width() - self.nextTexture.get_width()) ) #Somewhere between 0 and (stage_width-image_width)
#y_pos = random.randint(0, abs(self.stage.get_height() - self.nextTexture.get_height()) )
#Messy stuff because of damned gravity messup in 0.5
(x_pos, y_pos) = self.get_random_coords(self.nextTexture)
#print "pic pos: " + str(x_pos) + ":" + str(y_pos)
self.oldTexture = self.currentTexture
self.currentTexture = self.nextTexture
self.currentTexture.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER)
self.currentFilename = self.newFilename
self.stage.add(self.currentTexture)
self.nextTexture.set_position(x_pos, y_pos)
@ -234,6 +241,12 @@ class Module:
self.timeline_dissolve.start()
self.nextImage(self.currentTexture)
def get_random_coords(self, texture):
x_pos = random.randint(texture.get_width()/2, abs(self.stage.get_width() - texture.get_width()/2) ) #Somewhere between 0 and (stage_width-image_width)
y_pos = random.randint(texture.get_height()/2, abs(self.stage.get_height() - texture.get_height()/2) )
return (x_pos, y_pos)
def dissolve_timeline_end_event(self, data):
self.stage.remove(self.oldTexture)

View File

@ -37,7 +37,6 @@ class cover_item(clutter.Group):
self.main_pic.set_pixbuf(pixbuf)
self.main_pic.show()
(x, y) = (0, 0)
if self.main_pic.get_height() > self.main_pic.get_width():
@ -54,13 +53,20 @@ class cover_item(clutter.Group):
self.main_pic.set_height(height)
y = y + (cover_size - height)/2
#y = y + (cover_size - height)
anchor_x = cover_size/2 #self.main_pic.get_width()/2
anchor_y = cover_size/2 #self.main_pic.get_height()/2
self.set_anchor_point(anchor_x, anchor_y)
self.main_pic.set_position(x, y)
#This just seems to keep changing in Clutter so I'll leave it here
gap = (cover_size - self.main_pic.get_width())/2
anchor_x = (cover_size - gap)/2 #cover_size/2
gap = (cover_size - self.main_pic.get_height())/2
anchor_y = (cover_size - gap)/2 #cover_size/2 #self.main_pic.get_height()/2
self.set_anchor_point(anchor_x, anchor_y)
#self.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER)
self.main_pic.set_position(x, y)

View File

@ -129,7 +129,8 @@ class coverViewer(clutter.Group):
incomingTexture = self.textureLibrary[incomingItem]
alpha = clutter.Alpha(self.timeline, clutter.smoothstep_inc_func)# clutter.ramp_inc_func)
self.behaviourNew_scale = clutter.BehaviourScale(scale_start=1, scale_end=self.scaleFactor, alpha=alpha) #clutter.GRAVITY_CENTER)
self.behaviourNew_scale = clutter.BehaviourScale(x_scale_start=1, y_scale_start=1, x_scale_end=self.scaleFactor, y_scale_end=self.scaleFactor, alpha=alpha) #clutter.GRAVITY_CENTER)
self.behaviourNew_scale.set_property("scale-gravity", clutter.GRAVITY_CENTER)
self.behaviourNew_z = clutter.BehaviourDepth(depth_start=1, depth_end=2, alpha=alpha)
#If we're performing a roll (See above) then the incoming opacity should start at 0 rather than the normal inactive opacity
if rolling:
@ -137,7 +138,7 @@ class coverViewer(clutter.Group):
else:
self.behaviourNew_opacity = clutter.BehaviourOpacity(opacity_start=self.inactiveOpacity, opacity_end=255, alpha=alpha)
self.behaviourOld_scale = clutter.BehaviourScale(scale_start=self.scaleFactor, scale_end=1, alpha=alpha)
self.behaviourOld_scale = clutter.BehaviourScale(x_scale_start=self.scaleFactor, y_scale_start=self.scaleFactor, x_scale_end=1, y_scale_end=1, alpha=alpha)
self.behaviourOld_z = clutter.BehaviourDepth(depth_start=2, depth_end=1, alpha=alpha)
self.behaviourOld_opacity = clutter.BehaviourOpacity(opacity_start=255, opacity_end=self.inactiveOpacity, alpha=alpha)
@ -184,8 +185,8 @@ class coverViewer(clutter.Group):
incomingTexture = self.textureLibrary[incomingItem]
alpha = clutter.Alpha(self.timeline, clutter.ramp_inc_func)
self.behaviourNew_scale = clutter.BehaviourScale(scale_start=1, scale_end=self.scaleFactor, alpha=alpha)
#self.behaviourNew_scale = clutter.BehaviourScale(x_scale_start=1, y_scale_start=1, x_scale_end=self.scaleFactor, y_scale_end=self.scaleFactor, alpha=alpha)
#self.behaviourNew_scale = clutter.BehaviourScale(scale_start=1, scale_end=self.scaleFactor, alpha=alpha)
self.behaviourNew_scale = clutter.BehaviourScale(x_scale_start=1, y_scale_start=1, x_scale_end=self.scaleFactor, y_scale_end=self.scaleFactor, alpha=alpha)
self.behaviourNew_z = clutter.BehaviourDepth(depth_start=1, depth_end=2, alpha=alpha)
self.behaviourNew_opacity = clutter.BehaviourOpacity(opacity_start=self.inactiveOpacity, opacity_end=255, alpha=alpha)
@ -203,7 +204,7 @@ class coverViewer(clutter.Group):
self.timeline = clutter.Timeline(10,35)
alpha = clutter.Alpha(self.timeline, clutter.smoothstep_inc_func)
self.behaviourOld_scale = clutter.BehaviourScale(scale_start=self.scaleFactor, scale_end=1, alpha=alpha)
self.behaviourOld_scale = clutter.BehaviourScale(x_scale_start=self.scaleFactor, y_scale_start=self.scaleFactor, x_scale_end=1, y_scale_end=1, alpha=alpha)
self.behaviourOld_z = clutter.BehaviourDepth(depth_start=2, depth_end=1, alpha=alpha)
self.behaviourOld_opacity = clutter.BehaviourOpacity(opacity_start=255, opacity_end=self.inactiveOpacity, alpha=alpha)

View File

@ -9,68 +9,76 @@ class Transition:
def do_transition(self, fromMenu, toMenu):
oldGroup = fromMenu.getItemGroup()
oldMenuGroup = fromMenu #.getMenuGroup()
newGroup = toMenu.getItemGroup()
newMenuGroup = toMenu #.getMenuGroup()
oldGroup.set_opacity(255)
self.timeline = clutter.Timeline(25, 50)
self.alpha = clutter.Alpha(self.timeline, clutter.ramp_inc_func)
#self.exit_behaviour_scale = clutter.BehaviourScale(self.alpha, 1, 0.5, clutter.GRAVITY_CENTER)
self.exit_behaviour_opacity = clutter.BehaviourOpacity(opacity_start=150, opacity_end=0, alpha=self.alpha)
#Setup some knots
knots_exiting = (\
(oldGroup.get_x(), oldGroup.get_y()),\
#(-oldGroup.get_x(), int(fromMenu.getStage().get_height()/2))
(-oldGroup.get_x(), oldGroup.get_y())\
)
self.exit_behaviour_path = clutter.BehaviourPath(knots=knots_exiting, alpha=self.alpha)
#self.exit_behaviour_scale.apply(oldGroup)
self.exit_behaviour_opacity.apply(oldGroup)
self.exit_behaviour_opacity.apply(oldMenuGroup)
self.exit_behaviour_path.apply(oldGroup)
##################################################################
#Start incoming menu
#self.exit_behaviour_scale = clutter.BehaviourScale(self.alpha, 1, 0.5, clutter.GRAVITY_CENTER)
self.entrance_behaviour_opacity = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=self.alpha)
#Setup some knots
start_y = int(self.stage.get_height()/2 - newGroup.get_height()/2)
start_x = int(self.stage.get_width())
newGroup.set_position(start_x, start_y)
#end_x = int(self.stage.get_width() - newGroup.get_width())/2
(end_x, end_y) = toMenu.get_display_position()
end_x = oldGroup.get_x() #int(end_x)
end_y = oldGroup.get_y() #int(end_y)
knots_entering = (\
(newGroup.get_x(), newGroup.get_y()),\
#(-oldGroup.get_x(), int(fromMenu.getStage().get_height()/2))
(end_x, end_y) \
#toMenu.get_display_position()
)
self.entrance_behaviour_path = clutter.BehaviourPath(self.alpha, knots_entering)
self.entrance_behaviour_opacity.apply(newGroup)
self.entrance_behaviour_opacity.apply(newMenuGroup)
self.entrance_behaviour_path.apply(newGroup)
#newGroup.show_all()
#newMenuGroup.show_all()
oldGroup = fromMenu.getItemGroup()
oldMenuGroup = fromMenu #.getMenuGroup()
newGroup = toMenu.getItemGroup()
newMenuGroup = toMenu #.getMenuGroup()
oldGroup.set_opacity(255)
self.timeline = clutter.Timeline(25, 50)
self.timeline.connect('completed', self.slide_complete, fromMenu)
self.alpha = clutter.Alpha(self.timeline, clutter.ramp_inc_func)
#self.exit_behaviour_scale = clutter.BehaviourScale(self.alpha, 1, 0.5, clutter.GRAVITY_CENTER)
self.exit_behaviour_opacity = clutter.BehaviourOpacity(opacity_start=150, opacity_end=0, alpha=self.alpha)
#Setup some knots
knots_exiting = (\
(oldGroup.get_x(), oldGroup.get_y()),\
#(-oldGroup.get_x(), int(fromMenu.getStage().get_height()/2))
(-oldGroup.get_x(), oldGroup.get_y())\
)
self.exit_behaviour_path = clutter.BehaviourPath(knots=knots_exiting, alpha=self.alpha)
#self.exit_behaviour_scale.apply(oldGroup)
self.exit_behaviour_opacity.apply(oldGroup)
self.exit_behaviour_opacity.apply(oldMenuGroup)
self.exit_behaviour_path.apply(oldGroup)
##################################################################
#Start incoming menu
#self.exit_behaviour_scale = clutter.BehaviourScale(self.alpha, 1, 0.5, clutter.GRAVITY_CENTER)
self.entrance_behaviour_opacity = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=self.alpha)
#Setup some knots
start_y = int(self.stage.get_height()/2 - newGroup.get_height()/2)
start_x = int(self.stage.get_width())
newGroup.set_position(start_x, start_y)
#end_x = int(self.stage.get_width() - newGroup.get_width())/2
(end_x, end_y) = toMenu.get_display_position()
end_x = oldGroup.get_x() #int(end_x)
end_y = oldGroup.get_y() #int(end_y)
knots_entering = (\
(newGroup.get_x(), newGroup.get_y()),\
#(-oldGroup.get_x(), int(fromMenu.getStage().get_height()/2))
(end_x, end_y) \
#toMenu.get_display_position()
)
toMenu.display()
#Finally, move the selector bar
(bar_x, bar_y) = self.glossMgr.selector_bar.position_0
self.glossMgr.selector_bar.move_to(bar_x, bar_y, self.timeline)
toMenu.selectFirst(False)
self.timeline.start()
self.entrance_behaviour_path = clutter.BehaviourPath(self.alpha, knots_entering)
self.entrance_behaviour_opacity.apply(newGroup)
self.entrance_behaviour_opacity.apply(newMenuGroup)
self.entrance_behaviour_path.apply(newGroup)
#newGroup.show_all()
#newMenuGroup.show_all()
self.glossMgr.currentMenu = toMenu
toMenu.display()
#Add relevant new items to stage
self.stage.add(toMenu)
self.stage.add(newGroup)
#Finally, move the selector bar
(bar_x, bar_y) = self.glossMgr.selector_bar.position_0
self.glossMgr.selector_bar.move_to(bar_x, bar_y, self.timeline)
toMenu.selectFirst(False)
self.timeline.start()
self.glossMgr.currentMenu = toMenu
def slide_complete(self, timeline, fromMenu):
self.stage.remove(fromMenu)
self.stage.remove(fromMenu.getItemGroup())