Bulk clutter 0.5 compatibility updates.

This commit is contained in:
noisymime 2008-01-05 14:29:48 +00:00
parent 591b9c201e
commit ec67a9d641
11 changed files with 173 additions and 129 deletions

View File

@ -15,10 +15,21 @@ class GlossMgr:
self.currentMenu = None
self.uiMsg = message(stage)
#Setup the menu transition
self.transition = "slide"
transition_path = "transitions/menus/" + self.transition
self.transition = __import__(transition_path).Transition(self)
self.themeMgr = ThemeMgr(self.stage)
background = self.themeMgr.get_texture("background", None, None)
#background.set_depth(-500)
#background.set_scale(1, 1)
background.set_width(stage.get_width())
background.set_height(stage.get_height())
background.show()
self.stage.add(background)
print "Perspective: " + str(stage.get_perspective())
#stage.set_perspective(60.0, 1.0, 0.1, 1)
self.selector_bar = MenuSelector(self)
self.stage.add(self.selector_bar)#Load the theme manager
@ -47,73 +58,7 @@ class GlossMgr:
def get_themeMgr(self):
return self.themeMgr
def transition_fade_zoom(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(self.alpha, 150, 0)
#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(self.alpha, knots_exiting)
#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(self.alpha, 0, 255)
#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()
toMenu.display()
#Finally, move the selector bar
self.selector_bar.selectItem(fromMenu.getItem(0), self.timeline)
#(to_x, to_y) = toMenu.get_display_position() #fromMenu.getItem(0).get_abs_position()
#self.selector_bar.move_to(int(to_x), int(to_y), self.timeline)
toMenu.selectFirst(False)
#self.timeline.connect('completed', self.on_transition_complete)
self.timeline.start()
self.currentMenu = toMenu
def on_key_press_event (self, stage, event):
#Firstly check whether any messages are currently displayed
if self.uiMsg.active:
@ -141,7 +86,7 @@ class GlossMgr:
# 2) Launch a module
action = self.currentMenu.get_current_item().getAction()
if action.__class__.__name__ == "Menu": # Check whether we're a pointing to a menu object
self.transition_fade_zoom(self.currentMenu, action)
self.transition.do_transition(self.currentMenu, action)
self.menuHistory.append(action)
else:
#We have a plugin and need to start it
@ -161,7 +106,7 @@ class GlossMgr:
#If there's no plugin running, go back one in the menu list (Providing we're not already at the first item.
else:
if len(self.menuHistory)>1:
self.transition_fade_zoom(self.menuHistory.pop(), self.menuHistory[-1])
self.transition.do_transition(self.menuHistory.pop(), self.menuHistory[-1])
self.currentMenu = self.menuHistory[-1]
#print event.hardware_keycode
@ -195,14 +140,15 @@ class MenuSelector(clutter.Texture):
cloneLabel.set_text(selectee.get_text())
cloneLabel.set_font_name(selectee.get_font_name())
(scale_x, scale_y) = selectee.get_scale()
cloneLabel.set_scale_with_gravity(scale_x, scale_y, clutter.GRAVITY_WEST)
cloneLabel.set_anchor_point_from_gravity(clutter.GRAVITY_WEST)
cloneLabel.set_scale(scale_x, scale_y)
selectee.get_parent().add(cloneLabel)
cloneLabel.set_position(selectee.get_x(), selectee.get_y())
#Now that all the cloning is done, find out what the scale is to become and set it on the clone
scale = selectee.currentZoom
cloneLabel.set_scale_with_gravity(scale, scale, clutter.GRAVITY_WEST)
cloneLabel.set_scale(scale, scale)
return cloneLabel.get_abs_position()
@ -255,11 +201,11 @@ class MenuSelector(clutter.Texture):
self.spinner.set_opacity(0)
self.spinner.show()
self.menuMgr.get_stage().add(self.spinner)
self.behaviour = clutter.BehaviourOpacity(self.alpha, 0,255)
self.glossMgr.get_stage().add(self.spinner)
self.behaviour = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=self.alpha)
self.spinner.start()
else:
self.behaviour = clutter.BehaviourOpacity(self.alpha, 255,0)
self.behaviour = clutter.BehaviourOpacity(opacity_start=255, opacity_end=0, alpha=self.alpha)
self.timeline.connect('completed', self.spinner_end_event)
#self.menuMgr.get_stage().remove(self.spinner)
#self.spinner = None
@ -268,7 +214,7 @@ class MenuSelector(clutter.Texture):
self.timeline.start()
def spinner_end_event(self, data):
self.menuMgr.get_stage().remove(self.spinner)
self.glossMgr.get_stage().remove(self.spinner)
self.spinner = None
def get_x_offset(self):

33
Menu.py
View File

@ -207,6 +207,10 @@ class Menu(clutter.Group):
if self.timeline.is_playing:
"ERROR: Timeline should NOT be playing here!"
#Empty out things on the menu first (if any)
for group in self.get_children():
self.remove(group)
self.timeline = clutter.Timeline(1, 75)
self.selected = 0
for i in range(0,len(self.menuItems)):
@ -339,8 +343,9 @@ class ListItem (clutter.Label):
return None
alpha = clutter.Alpha(timeline, clutter.ramp_inc_func)
self.behaviour1 = clutter.BehaviourScale(alpha, self.currentZoom, zoomTo, clutter.GRAVITY_WEST)
self.behaviour2 = clutter.BehaviourOpacity(alpha, self.currentOpacity, opacityTo)
self.behaviour1 = clutter.BehaviourScale(scale_start=self.currentZoom, scale_end=zoomTo, alpha=alpha) #scale_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)
self.behaviour2.apply(self)
@ -360,21 +365,27 @@ class ListItem (clutter.Label):
pixbuf = gtk.gdk.pixbuf_new_from_file(path)
self.tempTexture.set_pixbuf(pixbuf)
#Scale the image down by half
xy_ratio = self.tempTexture.get_width() / self.tempTexture.get_height()
self.tempTexture.set_width(int(self.stage.get_width() * 0.20)) #30% of the stages width
self.tempTexture.set_height(self.tempTexture.get_width() * xy_ratio ) #Just makes sure the sizes stay the same
#Rotate appropriately
self.tempTexture.set_depth(self.tempTexture.get_width()/2)
self.tempTexture.set_rotation(clutter.Y_AXIS, 45, (self.tempTexture.get_width()/2), 0, 0)
self.itemTexturesGroup.add(self.tempTexture)
self.tempTexture.hide_all()
#Set position
(abs_x, abs_y) = self.get_abs_position()
x = abs_x# - self.tempTexture.get_width()
y = (self.menu.getStage().get_height()/2) - (self.tempTexture.get_height()/2)
self.tempTexture.set_position(x, y)
self.tempTexture.rotate_y(45,0,0)
self.itemTexturesGroup.add(self.tempTexture)
self.tempTexture.hide_all()
#Scale the image down by half
xy_ratio = self.tempTexture.get_width() / self.tempTexture.get_height()
self.tempTexture.set_width(int(self.stage.get_width() * 0.30)) #30% of the stages width
self.tempTexture.set_height(self.tempTexture.get_width() * xy_ratio ) #Just makes sure the sizes stay the same
if useReflection:
self.reflectionTexture = Texture_Reflection(self.tempTexture)
#self.reflectionTexture.set_position(0, 0)#self.tempTexture.get_height())

View File

@ -6,24 +6,26 @@ class Texture_Reflection (clutter.Texture):
clutter.Texture.__init__(self)
self.set_pixbuf(origTexture.get_pixbuf())
self.set_width(origTexture.get_width())
self.set_height(origTexture.get_height())
(w, h) = origTexture.get_abs_size()
self.set_width(w)
self.set_height(h)
#Rotate the reflection based on any rotations to the master
ang_y = origTexture.get_ryang()
self.rotate_y(ang_y,0,0)
ang_x = origTexture.get_rxang()
self.rotate_x(ang_x,0,0)
ang_z = origTexture.get_rzang()
self.rotate_z(ang_z,0,0)
ang_y = origTexture.get_rotation(clutter.Y_AXIS) #ryang()
self.set_rotation(clutter.Y_AXIS, ang_y[0], (origTexture.get_width()), 0, 0)
ang_x = origTexture.get_rotation(clutter.X_AXIS)
self.set_rotation(clutter.X_AXIS, ang_x[0], 0, (origTexture.get_height()), 0)
#ang_z = origTexture.get_rotation(clutter.Z_AXIS)
#self.set_rotation(clutter.Z_AXIS, ang_z[0], 0, 0, 0)
#Get the location for it
(x, y) = origTexture.get_abs_position()
print (x, y)
#self.set_clip(0,self.get_height()/2,self.get_width(), (self.get_height()/2))
#Flip it upside down
self.rotate_x(180,origTexture.get_height(),0)
#self.set_rotation(clutter.X_AXIS, 180, 0, origTexture.get_height(), 0)
#self.rotate_x(180,origTexture.get_height(),0)
self.set_opacity(50)
self.set_position(x, y)

Binary file not shown.

View File

@ -14,7 +14,7 @@ class Spinner (clutter.Texture):
self.timeline = clutter.Timeline(40,20)
self.timeline.set_loop(True)
alpha = clutter.Alpha(self.timeline, clutter.ramp_inc_func)
self.spin_behaviour = clutter.BehaviourRotate(alpha, clutter.Z_AXIS, clutter.ROTATE_CW, 0, 359)
self.spin_behaviour = clutter.BehaviourRotate( axis=clutter.Z_AXIS , direction=clutter.ROTATE_CW, angle_start=0, angle_end=359, alpha=alpha)
self.spin_behaviour.set_center(self.get_width()/2,self.get_height()/2, 0)
self.spin_behaviour.apply(self)
self.timeline.start()

Binary file not shown.

View File

@ -124,7 +124,7 @@ class Module:
self.backdrop.show()
timeline_backdrop = clutter.Timeline(10,30)
alpha = clutter.Alpha(timeline_backdrop, clutter.ramp_inc_func)
self.backdrop_behaviour = clutter.BehaviourOpacity(alpha, 0, 255)
self.backdrop_behaviour = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=alpha)
self.backdrop_behaviour.apply(self.backdrop)
timeline_backdrop.start()
@ -179,7 +179,8 @@ class Module:
#Zooming stuff
rand_zoom = random.uniform(1,1.3) # Zoom somewhere between 1 and 1.3 times
self.behaviour1 = clutter.BehaviourScale(self.alpha, 1, rand_zoom, clutter.GRAVITY_CENTER)
self.behaviour1 = clutter.BehaviourScale(scale_start=1, 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
x_pos = self.currentTexture.get_x() + random.randint(-100, 100)
@ -206,8 +207,8 @@ class Module:
self.alpha_dissolve = clutter.Alpha(self.timeline_dissolve, clutter.ramp_inc_func)
#Setup the dissolve to the next image
self.behaviour3 = clutter.BehaviourOpacity(self.alpha_dissolve, 255, 0)
self.behaviour4 = clutter.BehaviourOpacity(self.alpha_dissolve, 0, 255)
self.behaviour3 = clutter.BehaviourOpacity(opacity_start=255, opacity_end=0, alpha=self.alpha_dissolve)
self.behaviour4 = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=self.alpha_dissolve)
self.behaviour3.apply(self.currentTexture)
self.behaviour4.apply(self.nextTexture)

View File

@ -130,17 +130,19 @@ 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(alpha, 1, self.scaleFactor, clutter.GRAVITY_CENTER)
self.behaviourNew_z = clutter.BehaviourDepth(alpha, 1, 2)
self.behaviourNew_scale = clutter.BehaviourScale(scale_start=1, 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:
self.behaviourNew_opacity = clutter.BehaviourOpacity(alpha, 0, 255)
self.behaviourNew_opacity = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=alpha)
else:
self.behaviourNew_opacity = clutter.BehaviourOpacity(alpha, self.inactiveOpacity, 255)
self.behaviourNew_opacity = clutter.BehaviourOpacity(opacity_start=self.inactiveOpacity, opacity_end=255, alpha=alpha)
self.behaviourOld_scale = clutter.BehaviourScale(alpha, self.scaleFactor, 1, clutter.GRAVITY_CENTER)
self.behaviourOld_z = clutter.BehaviourDepth(alpha, 2, 1)
self.behaviourOld_opacity = clutter.BehaviourOpacity(alpha, 255, self.inactiveOpacity)
self.behaviourOld_scale = clutter.BehaviourScale(scale_start=self.scaleFactor, scale_end=1, alpha=alpha)
self.behaviourOld_scale.set_property("scale=gravity", clutter.GRAVITY_CENTER)
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)
self.behaviourNew_scale.apply(incomingTexture)
self.behaviourNew_z.apply(incomingTexture)
@ -165,9 +167,10 @@ class coverViewer(clutter.Group):
incomingTexture = self.textureLibrary[incomingItem]
alpha = clutter.Alpha(self.timeline, clutter.ramp_inc_func)
self.behaviourNew_scale = clutter.BehaviourScale(alpha, 1, self.scaleFactor, clutter.GRAVITY_CENTER)
self.behaviourNew_z = clutter.BehaviourDepth(alpha, 1, 2)
self.behaviourNew_opacity = clutter.BehaviourOpacity(alpha, self.inactiveOpacity, 255)
self.behaviourNew_scale = clutter.BehaviourScale(scale_start=1, scale_end=self.scaleFactor, alpha=alpha)
self.behaviourNew_scale.set_property("scale-gravity", clutter.GRAVITY_CENTER)
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)
self.behaviourNew_scale.apply(incomingTexture)
self.behaviourNew_z.apply(incomingTexture)
@ -183,10 +186,11 @@ class coverViewer(clutter.Group):
self.timeline = clutter.Timeline(10,35)
alpha = clutter.Alpha(self.timeline, clutter.smoothstep_inc_func)
self.behaviourOld_scale = clutter.BehaviourScale(alpha, self.scaleFactor, 1, clutter.GRAVITY_CENTER)
self.behaviourOld_z = clutter.BehaviourDepth(alpha, 2, 1)
self.behaviourOld_opacity = clutter.BehaviourOpacity(alpha, 255, self.inactiveOpacity)
self.behaviourOldDetails_opacity = clutter.BehaviourOpacity(alpha, 255, 0)
self.behaviourOld_scale = clutter.BehaviourScale(scale_start=self.scaleFactor, scale_end=1, alpha=alpha)
self.behaviourOld_scale.set_property("scale-gravity", clutter.GRAVITY_CENTER)
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)
self.behaviourOldDetails_opacity = clutter.BehaviourOpacity(opacity_start=255, opacity_end=0, alpha=alpha)
current_cover = self.textureLibrary[self.currentSelection]
self.behaviourOld_scale.apply(current_cover)
@ -241,8 +245,8 @@ class coverViewer(clutter.Group):
alpha = clutter.Alpha(timeline, clutter.ramp_inc_func)
self.behaviour_path = clutter.BehaviourPath(alpha, knots)
self.behaviour_incoming = clutter.BehaviourOpacity(alpha, 0, self.inactiveOpacity)
self.behaviour_outgoing = clutter.BehaviourOpacity(alpha, self.inactiveOpacity, 0)
self.behaviour_incoming = clutter.BehaviourOpacity(opacity_start=0, opacity_end=self.inactiveOpacity, alpha=alpha)
self.behaviour_outgoing = clutter.BehaviourOpacity(opacity_start=self.inactiveOpacity, opacity_end=0, alpha=alpha)
self.behaviour_path.apply(self.covers_group)
#Also need to change a few opacities - This is really messy, but works

View File

@ -82,35 +82,37 @@ class folderMenu(clutter.Group):
if direction > 0:
rotation_direction = clutter.ROTATE_CCW
self.behaviour_rotate_incoming = clutter.BehaviourRotate(alpha, clutter.X_AXIS, rotation_direction, 90, 0)
self.behaviour_rotate_outgoing = clutter.BehaviourRotate(alpha, clutter.X_AXIS, rotation_direction, 0, 270)
self.behaviour_rotate_incoming = clutter.BehaviourRotate(axis=clutter.X_AXIS, direction=rotation_direction, angle_start=90, angle_end=0, alpha=alpha)
self.behaviour_rotate_outgoing = clutter.BehaviourRotate(axis=clutter.X_AXIS, direction=rotation_direction, angle_start=0, angle_end=270, alpha=alpha)
else:
rotation_direction = clutter.ROTATE_CW
self.behaviour_rotate_incoming = clutter.BehaviourRotate(alpha, clutter.X_AXIS, rotation_direction, 270, 0)
self.behaviour_rotate_outgoing = clutter.BehaviourRotate(alpha, clutter.X_AXIS, rotation_direction, 0, 90)
self.behaviour_rotate_incoming = clutter.BehaviourRotate(axis=clutter.X_AXIS, direction=rotation_direction, angle_start=270, angle_end=0, alpha=alpha)
self.behaviour_rotate_outgoing = clutter.BehaviourRotate(axis=clutter.X_AXIS, direction=rotation_direction, angle_start=0, angle_end=90, alpha=alpha)
#Need to set the axis of rotation for the covers
self.behaviour_rotate_outgoing.set_center(0, self.item_size/2, 0)
self.behaviour_rotate_incoming.set_center(0, self.item_size/2, 0)
self.behaviour_opacity_incoming = clutter.BehaviourOpacity(alpha, 0, new_viewer.inactiveOpacity)
self.behaviour_opacity_incoming = clutter.BehaviourOpacity(opacity_start=0, opacity_end=new_viewer.inactiveOpacity, alpha=alpha)
#Apply the outgong behaviour
current_viewer = self.viewerLibrary[self.currentItemNo]
timeline.connect('completed', self.completeSwitch, current_viewer)
self.behaviour_opacity_outgoing = clutter.BehaviourOpacity(alpha, current_viewer.inactiveOpacity, 0)
self.behaviour_opacity_outgoing = clutter.BehaviourOpacity(opacity_start=current_viewer.inactiveOpacity, opacity_end=0, alpha=alpha)
self.behaviour_opacity_outgoing.apply(current_viewer)
for cover in current_viewer.get_item_library():
#cover.set_depth(cover.get_height())
self.behaviour_rotate_outgoing.apply(cover)
#Apply the incoming behaviour
new_viewer.set_opacity(0)
self.behaviour_opacity_incomingViewer = clutter.BehaviourOpacity(alpha, 0, 255)
self.behaviour_opacity_incomingViewer = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=alpha)
self.behaviour_opacity_incomingViewer.apply(new_viewer)
for cover in new_viewer.get_item_library():
cover.set_opacity(0)
#cover.set_depth(int(cover.get_height()/2))
self.behaviour_rotate_incoming.apply(cover)
self.behaviour_opacity_incoming.apply(cover)

View File

@ -188,10 +188,9 @@ class Module():
#Fade the backdrop in
timeline_begin = clutter.Timeline(10,40)
alpha = clutter.Alpha(timeline_begin, clutter.ramp_inc_func)
self.begin_behaviour = clutter.BehaviourOpacity(alpha, 0, 255)
self.begin_behaviour = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=alpha)
self.begin_behaviour.apply(self.backdrop)
self.stage.add(self.folderLibrary[0])
self.folderLibrary[0].show()
@ -218,7 +217,7 @@ class Module():
#Fade everything out
timeline_stop = clutter.Timeline(10,30)
alpha = clutter.Alpha(timeline_stop, clutter.ramp_inc_func)
self.stop_behaviour = clutter.BehaviourOpacity(alpha, 255, 0)
self.stop_behaviour = clutter.BehaviourOpacity(opacity_start=255, opacity_end=0, alpha=alpha)
self.stop_behaviour.apply(self.currentViewer)
self.stop_behaviour.apply(self.backdrop)
self.stop_behaviour.apply(self.folderLibrary[self.folder_level])
@ -249,10 +248,10 @@ class Module():
timeline = clutter.Timeline(15, 25)
self.currentViewer.set_opacity(0)
alpha = clutter.Alpha(timeline, clutter.ramp_inc_func)
self.behaviour = clutter.BehaviourOpacity(alpha, 0,255)
self.behaviour = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=alpha)
self.behaviour.apply(self.currentViewer)
self.stage.add(self.currentViewer)
self.stage.add()
self.currentViewer.show()
timeline.start()

View File

@ -0,0 +1,79 @@
import clutter
class Transition:
def __init__(self, GlossMgr):
self.stage = GlossMgr.stage
self.glossMgr = GlossMgr
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()
toMenu.display()
#Finally, move the selector bar
self.glossMgr.selector_bar.selectItem(fromMenu.getItem(0), self.timeline)
#(to_x, to_y) = toMenu.get_display_position() #fromMenu.getItem(0).get_abs_position()
#self.selector_bar.move_to(int(to_x), int(to_y), self.timeline)
toMenu.selectFirst(False)
#self.timeline.connect('completed', self.on_transition_complete, fromMenu)
self.timeline.start()
self.glossMgr.currentMenu = toMenu
def on_transition_complete(self, data):
pass