- MASSIVE rewrite of the ListMenu code. Result is ListMenu2

- This rewrite has affected many classes and this commit is still messy, but functional.
This commit is contained in:
noisymime 2008-06-15 11:27:47 +00:00
parent ff14140f4d
commit 3378b333b1
17 changed files with 5312 additions and 181 deletions

View File

@ -49,12 +49,6 @@ class GlossMgr:
background.show()
self.stage.add(background)
#Setup the selector bar
self.selector_bar = MenuSelector(self)
self.selector_bar.show_all()
self.stage.add(self.selector_bar)
self.currentPlugin = None
@ -78,14 +72,10 @@ class GlossMgr:
tmpLabel.set_text("AAA")
tmpLabel.set_font_name(self.currentMenu.font)
#Selector bar height is 20% larger than the labels
self.selector_bar.set_height( int(tmpLabel.get_height()*self.selector_bar.height_percent) )
self.selector_bar.set_menu(self.currentMenu)
#self.selector_bar.set_height( int(tmpLabel.get_height()*self.selector_bar.height_percent) )
#self.selector_bar.set_menu(self.currentMenu)
tmpLabel = None
def get_selector_bar(self):
return self.selector_bar
def get_stage(self):
return self.stage
@ -118,10 +108,10 @@ class GlossMgr:
# If none of these things, the menu needs to do something
if event.keyval == clutter.keysyms.Up: #Up button pressed
self.currentMenu.input_queue.input(event)
self.currentMenu.on_key_press_event(event)
#self.currentMenu.selectPrevious()
if event.keyval == clutter.keysyms.Down: #Down button pressed
self.currentMenu.input_queue.input(event)
self.currentMenu.on_key_press_event(event)
#self.currentMenu.selectNext()
if event.keyval == clutter.keysyms.q:
self.stage.show_cursor()
@ -200,119 +190,4 @@ class GlossMgr:
def create_menu(self):
return self.interface.Interface(self)
class MenuSelector(clutter.Texture):
"""This class will shortly be removed in the rewrite of the ListMenu interface, ignore it for now."""
x_offset = -50
height_percent = 1
position_0 = None
blank = True
def __init__ (self, glossMgr):
clutter.Texture.__init__ (self)
self.glossMgr = glossMgr
glossMgr.themeMgr.get_texture("selector_bar", glossMgr.stage, self)
self.set_position(0, self.get_y())
if not self.get_pixbuf() is None:
self.x_offset = int(glossMgr.themeMgr.get_value("texture", "selector_bar", "position.x"))
self.height_percent = float(glossMgr.themeMgr.get_value("texture", "selector_bar", "height_percent")) / float(100)
self.blank = False
else:
self.position_0 = (0, 0)
#This is a utility function that gets the coordinates of an that has been scaled
def get_true_abs_position(self, selectee):
#This whole clone label thing is a HORRIBLE hack but is there to compensate for the movement caused by scaling using GRAVITY_WEST
#Essentially a clone of the selectee is made and scaled to its final position to retrieve the final abs_position coords
cloneLabel = clutter.Label()
cloneLabel.set_text(selectee.get_text())
cloneLabel.set_font_name(selectee.get_font_name())
(scale_x, scale_y) = selectee.get_scale()
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(scale, scale)
return cloneLabel.get_abs_position()
def selectItem(self, selectee, timeline):
#Now get the end position of the clone
(x, y) = self.get_true_abs_position(selectee)
#print (x, y)
#Do some minor adjustments for centering etc
x = x + self.x_offset
y = y - int( (self.get_height()-selectee.get_height())/2 )
#Yet another little hack, but this stores the position of the first element
if self.position_0 is None:
self.position_0 = (x, y)
#Move the bar
self.move_to(x, y, timeline)
def move_to(self, x, y, timeline):
knots = (\
(self.get_x(), self.get_y()),\
(x, y)\
)
self.alpha = clutter.Alpha(timeline, clutter.ramp_inc_func)
self.behaviour = clutter.BehaviourPath(self.alpha, knots)
self.behaviour.apply(self)
def set_menu(self, menu):
self.menu = menu
def set_spinner(self, state):
#Make sure we're not blank first
if self.blank:
return
self.timeline = clutter.Timeline(25, 25)
self.alpha = clutter.Alpha(self.timeline, clutter.ramp_inc_func)
self.behaviour = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=self.alpha)
if state:
self.spinner = Spinner()
height = self.get_height() - int(self.get_height() * 0.11)
#Height has to be even otherwise spinner rotates on a slightly off axis
if (height % 2) == 1:
height = height -1
width = height
self.spinner.set_size(width, height)
(x, y) = self.get_abs_position()
x = x + self.get_width() - int(self.get_width() * 0.13)
y = y + int(self.get_height() * 0.03)
self.spinner.set_position(x, y)
self.spinner.set_opacity(0)
self.spinner.show()
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(opacity_start=255, opacity_end=0, alpha=self.alpha)
self.timeline.connect('completed', self.spinner_end_event)
self.behaviour.apply(self.spinner)
self.timeline.start()
def spinner_end_event(self, data):
self.glossMgr.get_stage().remove(self.spinner)
self.spinner = None
def get_x_offset(self):
return self.x_offset

View File

@ -94,7 +94,8 @@ class MainApp:
#Update splash status msg
self.splashScreen.set_msg("Creating menus")
MainMenu = self.glossMgr.create_menu()
MainMenu = self.glossMgr.create_menu()
self.glossMgr.addMenu(MainMenu)
#Update splash status msg
self.splashScreen.set_msg("Connecting to MythTV server")

View File

@ -41,7 +41,7 @@ class Interface(clutter.Group):
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)
#Sets up the UI from the theme
def setup_ui(self, themeMgr, name, menu):
@ -145,6 +145,10 @@ class Interface(clutter.Group):
def getItemGroup(self):
return self.itemGroup
def on_key_press_event(self, event):
self.input_queue.input(event)
#Returns the newly selected item
def selectNext(self):
@ -245,7 +249,7 @@ class Interface(clutter.Group):
self.timeline.start()
def selectFirst(self, moveBar):
def selectFirst(self, moveBar=False):
if self.timeline.is_playing:
"ERROR: Timeline should NOT be playing here!"

View File

@ -0,0 +1,194 @@
import clutter
import pygtk
import gtk
import pango
import time
import math
from utils.InputQueue import InputQueue
from interfaces.MenuItem import MenuItem
from ui_elements.label_list import LabelList, ListItem
class Interface(clutter.Group):
usePreviewEffects = True # Tells the modules to use any image preview effects where available
font = ""
menu_item_transition = None
zoomLevel = 0.5
opacityStep = 120
position_0 = None
def __init__ (self, glossMgr):
clutter.Group.__init__(self)
self.glossMgr = glossMgr
self.stage = self.glossMgr.get_stage()
self.itemGroup = clutter.Group()
#Setup input queue controller
self.input_queue = InputQueue()
self.input_queue.set_action(InputQueue.NORTH, self.selectPrevious)
self.input_queue.set_action(InputQueue.SOUTH, self.selectNext)
self.label_list = LabelList()
self.label_list.show()
self.add(self.label_list)
#This is a group to hold all the images
self.image_group = clutter.Group()
self.image_group.show()
self.setup(glossMgr.themeMgr)
def setup(self, themeMgr):
element = themeMgr.search_docs("menu", "main").childNodes
#setup the menu_image properties
tmp_frame = themeMgr.get_imageFrame("menu_item_texture")
self.menu_image_size = int(tmp_frame.img_size)
self.use_reflection = tmp_frame.use_reflection
self.menu_image_x = tmp_frame.get_x()
self.menu_image_y = tmp_frame.get_y()
self.label_list.setup_from_theme_id(themeMgr, "main_menu")
#This is a hack, but we move the label list to (0,0) and set self to be where it was (As specified in the theme)
self.set_position(self.label_list.get_x(), self.label_list.get_y())
self.label_list.set_position(0, 0)
#Setup the menu image transition
image_transition = themeMgr.find_child_value(element, "image_transition.name")
transition_options = themeMgr.find_child_value(element, "image_transition.options")
transition_path = "interfaces/ListMenu2/transitions/" + str(image_transition)
try:
self.menu_item_transition = __import__(transition_path).Transition(self.glossMgr)
self.menu_item_transition.set_options(transition_options)
except ImportError:
print "Theme Error: No menu_item transition titled '" + str(image_transition) + "'"
self.menu_item_transition = None
#Setup the menu transition
menu_transition = themeMgr.find_child_value(element, "menu_transition.name")
menu_transition_options = themeMgr.find_child_value(element, "menu_transition.options")
themeMgr.glossMgr.set_menu_transition(menu_transition)
def on_key_press_event(self, event):
self.input_queue.input(event)
def addItem(self, itemLabel):
font = self.label_list.font_string
newItem = MenuListItem(self, itemLabel, self.label_list, font)
self.label_list.add_item(itemLabel, newItem=newItem)
return newItem
def display(self):
self.label_list.display()
self.stage.add(self)
self.stage.add(self.image_group)
self.image_group.show()
self.image_group.show_all()
self.show()
def undisplay(self):
self.stage.remove(self)
self.stage.remove(self.image_group)
self.image_group.hide_all()
def selectNext(self):
timeline = clutter.Timeline(self.label_list.frames, self.label_list.fps)
self.input_queue.set_timeline(timeline)
#Do the transition of the menu graphic
#If there's no transition set (Would have been set in the theme) then the item is simply show
if not self.menu_item_transition is None:
item_to = self.label_list.get_current_item(offset=1)
#if item_to is None, means we're at the bottom of the list
if not item_to is None: item_to = item_to.get_item_textures()
else: return
item_from = self.label_list.get_current_item().get_item_textures()
if not item_to is None: self.image_group.add(item_to)
self.menu_item_transition.forward(timeline, item_from, item_to)
else:
self.menuItems[self.selected].get_item_textures().show()
self.label_list.move_selection(self.label_list.DIRECTION_DOWN, timeline=timeline)
def selectPrevious(self):
timeline = clutter.Timeline(self.label_list.frames, self.label_list.fps)
self.input_queue.set_timeline(timeline)
#Do the transition of the menu graphic
#If there's no transition set (Would have been set in the theme) then the item is simply show
if not self.menu_item_transition is None:
item_to = self.label_list.get_current_item(offset=-1)
#if item_to is None, means we're at the top of the list
if not item_to is None: item_to = item_to.get_item_textures()
else: return
item_from = self.label_list.get_current_item().get_item_textures()
if not item_to is None: self.image_group.add(item_to)
self.menu_item_transition.backward(timeline, item_from, item_to)
else:
self.menuItems[self.selected].get_item_textures().show()
self.label_list.move_selection(self.label_list.DIRECTION_UP, timeline=timeline)
def selectFirst(self, moveBar=False):
if moveBar: self.label_list.select_first_elegant()
else: self.label_list.select_first()
self.input_queue.set_timeline(self.label_list.timeline)
#Show the current menu item's graphic
self.label_list.get_current_item().get_item_textures().show()
self.image_group.add(self.label_list.get_current_item().get_item_textures())
#self.menuItems[self.selected].itemTexturesGroup.show()
def get_current_item(self):
return self.label_list.get_current_item()
def get_selector_bar(self):
return self.label_list.selector_bar
class MenuListItem (ListItem):
"""
This class really should have used multiple inheritance (MenuItem, ListItem) however due to gobject not supporting
multiple inheritance this was not possible. To make it work, it singly inherits from ListItem and 'pretends' to be a MenuItem as well
"""
def __init__(self, menu, label, label_list, font):
ListItem.__init__(self, font, label, label_list=label_list)
self.menu_item = MenuItem(menu, label, 0)
self.menu = menu
#MenuItem.__init__(self, menu, label, 0)
#All methods below are to 'mask' this class as a MenuItem
def add_image_from_path(self, path, x, y, width=None, height=None):
self.menu_item.add_image_from_path(path, x, y, width, height)
def add_image_from_texture(self, texture):
self.menu_item.add_image_from_texture(texture)
def set_data(self, data):
self.menu_item.set_data(data)
def get_data(self):
return self.menu_item.data
def get_main_texture(self):
return self.menu_item.main_texture
def setAction(self, newAction):
self.menu_item.action = newAction
def getAction(self):
return self.menu_item.action
def get_menu(self):
return self.menu
def get_item_textures(self):
return self.menu_item.itemTexturesGroup

View File

View File

@ -0,0 +1,105 @@
import clutter
class Transition:
def __init__(self, GlossMgr):
self.stage = GlossMgr.stage
self.glossMgr = GlossMgr
def forward(self, timeline, oldGroup, newGroup):
timeline.connect('completed', self.on_transition_complete, oldGroup)
alpha = clutter.Alpha(timeline, clutter.ramp_inc_func)
newGroup.set_position( int(-newGroup.get_width()), int(oldGroup.get_y() * 0.8))
newGroup.show()
knots_incoming = (\
#( int(-newGroup.get_width()), int(oldGroup.get_y() * 0.8) ),\
( int(oldGroup.get_x()/2), int(oldGroup.get_y()*1.5) ),\
( int(oldGroup.get_x()*1.2) , int(oldGroup.get_y()) ),\
( oldGroup.get_x(), oldGroup.get_y() )\
)
#self.behaviour_incoming_bspline = clutter.BehaviourBspline(knots=knots_incoming, alpha=alpha)
self.behaviour_incoming_bspline = clutter.BehaviourPath(knots=knots_incoming, alpha=alpha)
self.behaviour_incoming_bspline.apply(newGroup)
self.behaviour_incoming_scale = clutter.BehaviourScale(x_scale_start=0, y_scale_start=0, x_scale_end=1, y_scale_end=1, alpha=alpha)
self.behaviour_incoming_scale.apply(newGroup)
#self.behaviour_incoming_depth = clutter.BehaviourDepth(depth_start=-1000, depth_end=oldGroup.get_depth(), alpha=alpha)
#self.behaviour_incoming_depth.apply(newGroup)
self.behaviour_incoming_opacity = clutter.BehaviourOpacity(opacity_start=0, opacity_end=oldGroup.get_opacity(), alpha=alpha)
self.behaviour_incoming_opacity.apply(newGroup)
#*************************************************************************8
#Do the outgoing group
knots_outgoing = (\
( oldGroup.get_x(), oldGroup.get_y() ),\
( int(oldGroup.get_x()/2) , int(oldGroup.get_y() * 0.9) ),\
( int(-oldGroup.get_width()), int(oldGroup.get_y() * 0.8) )\
)
self.behaviour_outgoing_bspline = clutter.BehaviourPath(knots=knots_outgoing, alpha=alpha)
self.behaviour_outgoing_bspline.apply(oldGroup)
self.behaviour_outgoing_scale = clutter.BehaviourScale(x_scale_start=1, y_scale_start=1, x_scale_end=2, y_scale_end=2, alpha=alpha)
self.behaviour_outgoing_scale.apply(oldGroup)
#self.behaviour_outgoing_depth = clutter.BehaviourDepth(depth_start=oldGroup.get_depth(), depth_end=1000, alpha=alpha)
#self.behaviour_outgoing_depth.apply(oldGroup)
self.behaviour_outgoing_opacity = clutter.BehaviourOpacity(opacity_start=oldGroup.get_opacity(), opacity_end=0, alpha=alpha)
self.behaviour_outgoing_opacity.apply(oldGroup)
def backward(self, timeline, oldGroup, newGroup):
timeline.connect('completed', self.on_transition_complete, oldGroup)
alpha = clutter.Alpha(timeline, clutter.ramp_inc_func)
newGroup.set_position( int(-newGroup.get_width()), int(oldGroup.get_y() * 0.8))
newGroup.show()
knots_incoming = (\
( int(-newGroup.get_width()), int(oldGroup.get_y() * 0.8) ),\
( int(oldGroup.get_x()/2) , int(oldGroup.get_y() * 0.9) ),\
( oldGroup.get_x(), oldGroup.get_y() )\
)
#self.behaviour_incoming_bspline = clutter.BehaviourBspline(knots=knots_incoming, alpha=alpha)
self.behaviour_incoming_bspline = clutter.BehaviourPath(knots=knots_incoming, alpha=alpha)
self.behaviour_incoming_bspline.apply(newGroup)
self.behaviour_incoming_scale = clutter.BehaviourScale(x_scale_start=2, y_scale_start=2, x_scale_end=1, y_scale_end=1, alpha=alpha)
self.behaviour_incoming_scale.apply(newGroup)
#self.behaviour_incoming_depth = clutter.BehaviourDepth(depth_start=1000, depth_end=oldGroup.get_depth(), alpha=alpha)
#self.behaviour_incoming_depth.apply(newGroup)
self.behaviour_incoming_opacity = clutter.BehaviourOpacity(opacity_start=0, opacity_end=oldGroup.get_opacity(), alpha=alpha)
self.behaviour_incoming_opacity.apply(newGroup)
#*****************************************************************
#Begin outgoing stuff
knots_outgoing = (\
( oldGroup.get_x(), oldGroup.get_y() ),\
( int(oldGroup.get_x()/2) , int(oldGroup.get_y() * 0.9) ),\
(( int(-oldGroup.get_width()), int(oldGroup.get_y() * 0.8) ))\
)
self.behaviour_outgoing_bspline = clutter.BehaviourPath(knots=knots_outgoing, alpha=alpha)
self.behaviour_outgoing_bspline.apply(oldGroup)
self.behaviour_outgoing_scale = clutter.BehaviourScale(x_scale_start=1, y_scale_start=1, x_scale_end=0, y_scale_end=0, alpha=alpha)
self.behaviour_outgoing_scale.apply(oldGroup)
#self.behaviour_outgoing_depth = clutter.BehaviourDepth(depth_start=oldGroup.get_depth(), depth_end=-1000, alpha=alpha)
#self.behaviour_outgoing_depth.apply(oldGroup)
self.behaviour_outgoing_opacity = clutter.BehaviourOpacity(opacity_start=oldGroup.get_opacity(), opacity_end=0, alpha=alpha)
self.behaviour_outgoing_opacity.apply(oldGroup)
def on_transition_complete(self, data, oldGroup):
oldGroup.get_parent().remove(oldGroup)
oldGroup.hide()
def set_options(self, options):
pass

View File

@ -8,7 +8,7 @@ class MenuItem (clutter.Label):
zoomLevel = 0.5
opacityStep = 120
def __init__ (self, menu, itemLabel, y):
def __init__ (self, menu, itemLabel, y=0):
clutter.Label.__init__ (self)
glossMgr = menu.glossMgr
self.menu = menu
@ -29,11 +29,6 @@ class MenuItem (clutter.Label):
self.set_color(self.color)
self.currentOpacity = 255
self.data = itemLabel #By default the items data is simply its label
if not glossMgr.get_selector_bar().get_pixbuf() is None:
#The width is the length of the selector bar minus its offset
width = glossMgr.get_selector_bar().get_width() + glossMgr.get_selector_bar().get_x_offset()
self.set_width(width)
self.set_ellipsize(pango.ELLIPSIZE_END)
#Text is actually scaled down in 'regular' position so that it doesn't get jaggies when zoomed in
@ -79,7 +74,6 @@ class MenuItem (clutter.Label):
"""
if self.main_texture is None:
self.main_texture = texture
self.itemTexturesGroup.add(texture)
self.itemTexturesGroup.show_all()

View File

@ -6,7 +6,7 @@ import time
import math
from ui_elements.ReflectionTexture import Texture_Reflection
from interfaces.MenuItem import MenuItem
from InputQueue import InputQueue
from utils.InputQueue import InputQueue
class Interface(clutter.Group):
usePreviewEffects = False # Tells the modules NOT to use any effects on the images
@ -28,8 +28,6 @@ class Interface(clutter.Group):
self.input_queue.set_action(InputQueue.NORTH, self.selectPrevious)
self.input_queue.set_action(InputQueue.SOUTH, self.selectNext)
self.glossMgr.addMenu(self)
def setup_ui(self, themeMgr, name, menu):
element = themeMgr.search_docs("menu", name).childNodes
#Quick check to make sure we found something
@ -73,6 +71,9 @@ class Interface(clutter.Group):
#themeMgr.setup_actor(menu.getItemGroup(), element, themeMgr.stage)
themeMgr.setup_actor(menu, element, themeMgr.stage)
def on_key_press_event(self, event):
self.input_queue.input(event)
def addItem(self, itemLabel):
if self.itemGroup.get_n_children() == 0:
tempLabel = clutter.Label()
@ -266,5 +267,5 @@ class Interface(clutter.Group):
class WheelListItem(MenuItem):
def __init__ (self, menu, itemLabel):
MenuItem.__init__ (self, menu, itemLabel, 0)
MenuItem.__init__ (self, menu, itemLabel)
self.glossMgr = menu.glossMgr

View File

@ -494,7 +494,7 @@ class Module:
#new_file_list = os.listdir(dirPath)
if tempMenu.usePreviewEffects:
tempItem.itemTexturesGroup = img_previewer
tempItem.menu_item.itemTexturesGroup = img_previewer
img_previewer.set_position(tempItem.menu.menu_image_x, tempItem.menu.menu_image_y)
else:
if not len(img_list) == 0:
@ -502,5 +502,6 @@ class Module:
tempItem.setAction(self)
tempMenu.selectFirst()
return tempMenu

File diff suppressed because it is too large Load Diff

After

Width:  |  Height:  |  Size: 138 KiB

View File

@ -1,6 +1,6 @@
<gloss-theme>
<menu id="main">
<interface>ListMenu</interface>
<interface>ListMenu2</interface>
<font id="main">
<face>Tahoma</face>
@ -19,6 +19,58 @@
<y>30%</y>
</position>
<label_list id="main_menu">
<font id="main">
<face>Tahoma</face>
<size id="default">30</size>
<size id="1024x768">38</size>
<size id="800x600">30</size>
<size id="1920x1080">25</size>
</font>
<dimensions type="relativeToStage">
<width>40%</width>
<height>40%</height>
</dimensions>
<position type="relativeToStage">
<x>60%</x>
<y>30%</y>
</position>
<!-- This determines the height of each item based on a percentage of the font size.
Eg: 1.00 means that each item will be the same height as the font,
1.50 means that the item will be 1.x times the height as the font etc
-->
<item_height_percent>1.00</item_height_percent>
<!-- These are the opacity and scale values for the 3 possible steps in the menu
Make all the values the same if you do not want these effects -->
<opacity_step0>255</opacity_step0>
<opacity_step1>135</opacity_step1>
<opacity_step2>50</opacity_step2>
<scale_step0>1</scale_step0>
<scale_step1>0.5</scale_step1>
<scale_step2>0.4</scale_step2>
<transition_fps>150</transition_fps>
<transition_frames>30</transition_frames>
<texture id="selector_bar">
<image>active_bar.png</image>
<!-- This is a special property of selector bar the sets the height of the bar relative to the menu items its selecting -->
<height_percent>120</height_percent>
<dimensions type="relativeToStage">
<width>40%</width>
<height>default</height>
</dimensions>
<position type="relativeToParent">
<x>-20</x>
<y>-1%</y>
</position>
</texture>
</label_list>
<item_gap>0</item_gap>
<num_visible_elements>4</num_visible_elements>

0
themes/__init__.py Normal file
View File

View File

@ -99,7 +99,7 @@ class Transition:
def on_transition_complete(self, data, oldGroup):
oldGroup.get_parent().remove(oldGroup)
pass
oldGroup.hide()
def set_options(self, options):
pass

View File

@ -23,12 +23,14 @@ class Transition:
knots_exiting = (\
(fromMenu.get_x(), fromMenu.get_y()),\
#(-oldGroup.get_x(), int(fromMenu.getStage().get_height()/2))
(-fromMenu.get_x(), fromMenu.get_group_y())\
#(-fromMenu.get_x(), fromMenu.get_group_y())\
(-fromMenu.get_x(), fromMenu.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(fromMenu.get_current_item().itemTexturesGroup)
#self.exit_behaviour_opacity.apply(fromMenu.get_current_item().itemTexturesGroup)
self.exit_behaviour_opacity.apply(fromMenu.image_group)
self.exit_behaviour_opacity.apply(fromMenu)
self.exit_behaviour_path.apply(fromMenu)
@ -52,7 +54,8 @@ class Transition:
)
self.entrance_behaviour_path = clutter.BehaviourPath(self.alpha, knots_entering)
self.entrance_behaviour_opacity.apply(toMenu.get_current_item().itemTexturesGroup)
self.entrance_behaviour_opacity.apply(toMenu.image_group)#get_current_item().get_item_textures())
self.entrance_behaviour_opacity.apply(toMenu)
self.entrance_behaviour_path.apply(toMenu)
@ -60,14 +63,24 @@ class Transition:
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)
fromMenu.get_selector_bar().hide()
bar = toMenu.get_selector_bar()
if not bar is None:
bar.show()
(begin_x, begin_y) = fromMenu.get_selector_bar().get_position()
begin_x = -int(self.stage.get_width() - fromMenu.get_x())
(finish_x, finish_y) = toMenu.get_selector_bar().get_position()
knots_selector_bar = (\
(begin_x, begin_y),\
(finish_x, finish_y)
)
self.selector_behaviour_path = clutter.BehaviourPath(self.alpha, knots_selector_bar)
self.selector_behaviour_path.apply(bar)
self.timeline.start()
self.glossMgr.currentMenu = toMenu
def slide_complete(self, timeline, fromMenu):
self.stage.remove(fromMenu)
fromMenu.undisplay()
#self.stage.remove(fromMenu.get_current_item().itemTexturesGroup)
fromMenu.get_current_item().itemTexturesGroup.get_parent().remove(fromMenu.get_current_item().itemTexturesGroup)
#fromMenu.get_current_item().itemTexturesGroup.get_parent().remove(fromMenu.get_current_item().itemTexturesGroup)

View File

@ -122,10 +122,8 @@ class image_previewer(clutter.Group):
if self.tex1.get_parent() is None: self.add(self.tex1)
parent = self.get_parent()
if parent is None:
print "Parent is none!"
if not parent is None: parent.show()
parent.show()
self.frontTex = self.tex1
self.tex1.show()
self.show()

View File

@ -152,7 +152,7 @@ class LabelList(clutter.Group):
return self.item_height
def add_item(self, itemLabel):
def add_item(self, itemLabel, newItem=None):
if len(self.items) == 0:
self.displayMax = self.height / self.label_height
label_width = 0
@ -163,6 +163,7 @@ class LabelList(clutter.Group):
item_y = len(self.items) * self.item_height
label_y = item_y + ((self.item_height - self.label_height)/2)
label_y += int(self.item_height/2)
label_y = int(label_y)
#If a background pic is specified in the theme, clone it and add
@ -174,15 +175,9 @@ class LabelList(clutter.Group):
self.background_group.add(bg_img)
self.bg_items.append(bg_img)
newItem = ListItem(self.font_string, itemLabel, label_list = self, max_width = self.width)
if newItem is None: newItem = ListItem(self.font_string, itemLabel, label_list = self, max_width = self.width)
newItem.set_position(0, label_y)
"""
if len(self.items) < self.displaySize:
newItem.show()
if not self.image_down is None: self.image_down.set_opacity(255)
if not self.inactive_item_background is None: bg_img.show()
"""
newItem.show()
if not self.image_down is None: self.image_down.set_opacity(255)
if not self.inactive_item_background is None: bg_img.show()
@ -206,7 +201,7 @@ class LabelList(clutter.Group):
self.show()
def move_selection(self, direction):
def move_selection(self, direction, timeline=None):
if direction == self.DIRECTION_DOWN:
#Check if we're at the last item in the list
@ -221,7 +216,8 @@ class LabelList(clutter.Group):
else:
self.selected -= 1
self.timeline = clutter.Timeline (self.frames, self.fps)
if timeline is None: self.timeline = clutter.Timeline (self.frames, self.fps)
else: self.timeline = timeline
alpha = clutter.Alpha(self.timeline, clutter.ramp_inc_func)
self.input_queue.set_timeline(self.timeline)
@ -298,6 +294,16 @@ class LabelList(clutter.Group):
if not self.selector_bar is None:
self.behaviour_opacity = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=alpha)
self.behaviour_opacity.apply(self.selector_bar)
"""
#move the selector bar
abs_y = self.selector_bar.y_offset
knots = (\
(self.selector_bar.get_x(), self.selector_bar.get_y()),
(self.selector_bar.get_x(), abs_y)
)
self.behaviour_path_bar = clutter.BehaviourPath(knots=knots, alpha=alpha)
self.behaviour_path_bar.apply(self.selector_bar)
"""
#Timeline only gets started if it was created in this function
if timeline is None: self.timeline.start()
@ -340,10 +346,11 @@ class LabelList(clutter.Group):
self.displayMax += 1
self.roll_point_min += 1
self.roll_point_max += 1
"""
outgoing_item = self.items[self.displayMin-1]
incoming_item = self.items[self.displayMax+1]
"""
else:
#Then the incoming item is above the selector bar
gap = self.item_height
@ -351,10 +358,10 @@ class LabelList(clutter.Group):
self.displayMax -= 1
self.roll_point_min -=1
self.roll_point_max -=1
"""
incoming_item = self.items[self.displayMin-1]
outgoing_item = self.items[self.displayMax+1]
"""
#print "Gap: " + str(gap)
new_y = (group_y + gap)
knots = (\
@ -364,8 +371,8 @@ class LabelList(clutter.Group):
alpha = clutter.Alpha(timeline, clutter.ramp_inc_func)
self.behaviour_path = clutter.BehaviourPath(alpha, knots)
self.behaviour_opacity_outgoing = clutter.BehaviourOpacity(opacity_start=outgoing_item.get_opacity(), opacity_end=0, alpha=alpha)
self.behaviour_opacity_incoming = clutter.BehaviourOpacity(opacity_start=0, opacity_end=outgoing_item.get_opacity(), alpha=alpha)
#self.behaviour_opacity_outgoing = clutter.BehaviourOpacity(opacity_start=outgoing_item.get_opacity(), opacity_end=0, alpha=alpha)
#self.behaviour_opacity_incoming = clutter.BehaviourOpacity(opacity_start=0, opacity_end=outgoing_item.get_opacity(), alpha=alpha)
self.behaviour_path.apply(self.item_group)
self.behaviour_path.apply(self.background_group)
@ -378,8 +385,10 @@ class LabelList(clutter.Group):
#self.behaviour_opacity_incoming.apply(incomingMenutem)
"""
def get_current_item(self):
return self.items[self.selected]
def get_current_item(self, offset=0):
selection = self.selected + offset
if (selection < 0) or (selection >= len(self.items)): return None
return self.items[self.selected+offset]
import gobject
class ListItem(clutter.Group):
@ -403,7 +412,8 @@ class ListItem(clutter.Group):
def __init__ (self, font, label_left="", label_right="", label_list=None, max_width=None):
clutter.Group.__init__ (self)
self.set_anchor_point_from_gravity(clutter.GRAVITY_WEST)
self.set_anchor_point_from_gravity(clutter.GRAVITY_NORTH)
#self.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER)
self.label_left = clutter.Label()
self.label_right = clutter.Label()
@ -434,6 +444,7 @@ class ListItem(clutter.Group):
#Text is actually scaled down in 'regular' position so that it doesn't get jaggies when zoomed in
self.currentZoom = self.scale_step_medium
self.currentOpacity = self.opacity_step_medium
self.set_anchor_point_from_gravity(clutter.GRAVITY_WEST)
self.set_scale(self.currentZoom, self.currentZoom)
self.set_opacity(self.currentOpacity)

View File

@ -12,7 +12,7 @@ class ThemeMgr:
currentTheme = "default"
currentTheme = "Pear"
#currentTheme = "Mich"
currentTheme = "Gloxygen"
#currentTheme = "Gloxygen"
def __init__(self, glossMgr):
self.stage = glossMgr.stage