- Added zoom_fade menu transition

- Moved menu transition to theme
This commit is contained in:
noisymime 2008-01-23 22:21:28 +00:00
parent 5985ce3908
commit b755aeb831
8 changed files with 107 additions and 16 deletions

View File

@ -17,24 +17,22 @@ class GlossMgr:
self.themeMgr = ThemeMgr(self)
#Setup the menu transition
self.transition = "slide"
transition_path = "transitions/menus/" + self.transition
self.transition = __import__(transition_path).Transition(self)
#Set a default menu transition
self.set_menu_transition("slide")
#The background is a bit messy due to the depth issues :(
background = self.themeMgr.get_texture("background", None, None)
(width, height) = background.get_abs_size()
print background.get_abs_size()
#background.set_anchor_point_from_gravity(clutter.GRAVITY_NORTH_WEST)
background.set_anchor_point(int(background.get_width()/3), int(background.get_height()/3))
background.set_anchor_point(int(background.get_width()/3.5), int(background.get_height()/3.5))
#background.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER)
background.set_depth(-self.stage.get_width())
print background.get_abs_size()
#
(width_new, height_new) = background.get_abs_size()
#width = width * (width / width_new) + width_new
#height = height * (height / height_new) + height_new
#width = self.stage.get_width()
#height = self.stage.get_height()
scale_x = float(width)/float(width_new)
scale_y = float(height)/float(height_new)
background.set_scale(scale_x, scale_y)
@ -158,6 +156,11 @@ class GlossMgr:
def display_msg(self, title, msg):
self.uiMsg.display_msg(title, msg)
def set_menu_transition(self, transition_name):
#Setup the menu transition
transition_path = "transitions/menus/" + transition_name
self.transition = __import__(transition_path).Transition(self)
class MenuSelector(clutter.Texture):
x_offset = -50
height_percent = 1

View File

@ -44,34 +44,37 @@ class cover_item(clutter.Group):
self.main_pic.set_height(cover_size)
width = int(cover_size * xy_ratio)
self.main_pic.set_width(width)
x = x + (cover_size - width)/2
x = (cover_size - width)/2
#x = int(cover_size / 2)
#x = x + (cover_size - width)
else:
xy_ratio = float(self.main_pic.get_height()) / float(self.main_pic.get_width())
self.main_pic.set_width(cover_size)
height = int(cover_size * xy_ratio)
self.main_pic.set_height(height)
y = y + (cover_size - height)/2
y = (cover_size - height)/2
#y = y + (cover_size - height)
#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
anchor_x = (cover_size - gap)/2
#anchor_x = 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
anchor_y = (cover_size - gap)/2
#anchor_y = 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)
self.main_pic.set_position(x, y)
self.add(self.main_pic)
#If this is a folder, we also add a title
if not folder_name is None:
self.add_label(folder_name)

View File

@ -86,7 +86,7 @@ class coverViewer(clutter.Group):
def add_texture_group(self, tempGroup):
tempGroup.set_opacity(self.inactiveOpacity)
tempGroup.set_position( (self.num_covers * self.cover_size), 0)
#tempGroup.set_position( (self.num_covers * self.cover_size), 0)
tempGroup.set_depth(1)
self.textureLibrary.append(tempGroup)

View File

@ -184,6 +184,7 @@ class Module():
self.currentViewer.select_first()
self.folderLibrary[self.folder_level].on_key_press_event(event)
self.currentViewer = self.folderLibrary[self.folder_level].get_current_viewer()
#**********************************************************
elif self.controlState == self.STATE_VIDEO:

View File

@ -30,7 +30,7 @@ class ThemeMgr:
for file in file_list:
conf_file = dir + "/" + file
print conf_file
#print conf_file
docs.append(minidom.parse(conf_file))
#Filter function for fiding XML files
@ -359,6 +359,11 @@ class ThemeMgr:
except ImportError:
print "Theme Error: No menu_item transition titled '" + str(image_transition) + "'"
menu.menu_item_transition = None
#Setup the menu transition
menu_transition = self.find_child_value(element, "menu_transition.name")
menu_transition_options = self.find_child_value(element, "menu_transition.options")
self.glossMgr.set_menu_transition(menu_transition)
#Finally set general actor properties (position etc)
self.setup_actor(menu.getItemGroup(), element, self.stage)

View File

@ -0,0 +1,67 @@
import clutter
class Transition:
out_depth = 1000
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.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)
self.exit_behaviour_depth = clutter.BehaviourDepth(depth_start=fromMenu.get_depth(), depth_end=self.out_depth, alpha=self.alpha)
#self.exit_behaviour_scale.apply(oldGroup)
self.exit_behaviour_opacity.apply(oldGroup)
self.exit_behaviour_opacity.apply(oldMenuGroup)
self.exit_behaviour_depth.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_x, start_y) = oldGroup.get_position()
newGroup.set_position(start_x, start_y)
self.entrance_behaviour_depth = clutter.BehaviourDepth(depth_start=-self.out_depth, depth_end=oldGroup.get_depth()+1, alpha=self.alpha)
self.entrance_behaviour_opacity.apply(newGroup)
self.entrance_behaviour_opacity.apply(newMenuGroup)
self.entrance_behaviour_depth.apply(newGroup)
newGroup.show()
#newMenuGroup.show_all()
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())

View File

@ -44,6 +44,12 @@
<scale_step0>1</scale_step0>
<scale_step1>0.5</scale_step1>
<scale_step2>0.4</scale_step2>
<!-- Used for transitioning between menus -->
<menu_transition>
<name>zoom_fade</name>
<options>None</options>
</menu_transition>
</menu>

View File

@ -47,6 +47,12 @@
<scale_step0>1</scale_step0>
<scale_step1>0.5</scale_step1>
<scale_step2>0.4</scale_step2>
<!-- Used for transitioning between menus -->
<menu_transition>
<name>slide</name>
<options>None</options>
</menu_transition>
</menu>