- Begun abstraction of menu interfaces

This commit is contained in:
noisymime 2008-01-30 13:02:07 +00:00
parent 32e9765ff0
commit d5c4a760ea
9 changed files with 117 additions and 536 deletions

View File

@ -17,6 +17,11 @@ class GlossMgr:
self.themeMgr = ThemeMgr(self)
#Set the menu interface
element = self.themeMgr.search_docs("menu", "main").childNodes
interface_name = self.themeMgr.find_child_value(element, "interface")
self.set_menu_interface(interface_name)
#Set a default menu transition
self.set_menu_transition("slide")
@ -113,7 +118,7 @@ class GlossMgr:
# 1) Switch to a new menu
# 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
if action.__class__.__name__ == "Interface": # Check whether we're a pointing to an interface
self.transition.do_transition(self.currentMenu, action)
self.menuHistory.append(action)
else:
@ -162,12 +167,21 @@ class GlossMgr:
def display_msg(self, title, msg):
self.uiMsg.display_msg(title, msg)
def set_menu_interface(self, interface_name):
#Setup the menu interface
interface_path = "interfaces/" + interface_name + "/" + interface_name
self.interface = __import__(interface_path)
def set_menu_transition(self, transition_name):
#Setup the menu transition
transition_path = "transitions/menus/" + transition_name
self.transition = __import__(transition_path).Transition(self)
def create_menu(self):
return self.interface.Interface(self)
class MenuSelector(clutter.Texture):
x_offset = -50
height_percent = 1

427
Menu.py
View File

@ -1,427 +0,0 @@
import clutter
import pygtk
import gtk
import pango
import time
import math
from ReflectionTexture import Texture_Reflection
from InputQueue import InputQueue
class Menu(clutter.Group):
font = ""
menu_item_transition = None
zoomLevel = 0.5
opacityStep = 120
def __init__ (self, glossMgr):
clutter.Group.__init__(self)
self.glossMgr = glossMgr
self.stage = self.glossMgr.get_stage()
self.itemGroup = clutter.Group()
self.glossMgr.themeMgr.setup_menu("main", self)
#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.menuItems = []
self.selected = 0
self.displayMin = 0 #The number of menu items that will be shown at a time
self.moveQueue = 0
self.displaySize = self.displayMax - self.displayMin
self.displayPosition = (0, 0)
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)
def addItem(self, itemLabel):
if len(self.menuItems) == 0:
tempLabel = clutter.Label()
tempLabel.set_font_name(self.font)
tempLabel.set_text("S")
#tempLabel.set_scale_with_gravity(self.zoomStep0, self.zoomStep0, clutter.GRAVITY_WEST)
self.label_height = tempLabel.get_height()
#self.label_height = self.label_height * self.zoomStep1
label_width = 0
#else:
# (label_width, label_height) = self.menuItems[0].get_size()
label_y = len(self.menuItems) * (self.label_height + self.item_gap)
#print "Label height: " + str(self.label_height)
newItem = ListItem(self, itemLabel, label_y)
self.menuItems.append(newItem)
self.itemGroup.add(newItem)
#group_x = self.itemGroup.get_x()
#group_y = self.itemGroup.get_y() - (self.label_height)
#self.itemGroup.set_position(group_x, group_y)
return newItem
def display(self):
if self.displayMax > len(self.menuItems):
self.displayMax = len(self.menuItems)
self.displaySize = self.displayMax - self.displayMin
for i in range(self.displaySize):
self.menuItems[i].show()
self.itemGroup.show()
def getItem(self, index):
return self.menuItems[index]
def getStage(self):
return self.stage
def getGlossMgr(self):
return self.glossMgr
def setMenuPositionByName(self, location):
return None
if location == "center":
menu_y = (self.stage.get_height()-self.itemGroup.get_height())/2
menu_x = (self.stage.get_width()-self.itemGroup.get_width())/2
self.itemGroup.set_position(menu_x, menu_y)
#print "Original Group size: " + str(self.itemGroup.get_width())
#print "Starting at : " + str(menu_x) + ":" + str(menu_y)
#The display position is the x, y coords of where the menu is when it is active
def get_display_position(self):
return (self.itemGroup.get_x(), self.itemGroup.get_y())
def setMenuPosition(self, x, y):
self.itemGroup.set_position(x,y)
def getItemGroup(self):
return self.itemGroup
def setListFont(self, newFont):
currentY= 0 #self.itemGroup.get_y()
self.font = newFont
for li in self.menuItems:
x = li.get_x()
#y = li.getPositionY()
li.set_font_name(newFont)
li.set_position(x,currentY)
currentY = currentY + li.get_height()
#Returns the newly selected item
def selectNext(self):
#Check if we're at the last item in the list
if (self.selected) != (len(self.menuItems)-1):
self.timeline = clutter.Timeline (15,85)
self.input_queue.set_timeline(self.timeline)
#self.timeline.connect('completed', self.completeMove)
if not self.moveQueue == 0:
self.selected = self.selected +1 #+ self.moveQueue
self.moveQueue = self.moveQueue - 1 #0
if self.selected > (len(self.menuItems)-1):
self.selected = (len(self.menuItems)-1)
else:
self.selected = self.selected+1
#This horrible loop does all the scaling
#This includes, the selected item and the ones on either side of it
for i in range(len(self.menuItems)):
if i == self.selected:
self.menuItems[i].scaleLabel(0, self.timeline)
elif (i == self.selected-1) and (i >= self.displayMin):
self.menuItems[i].scaleLabel(1, self.timeline)
elif (i == self.selected+1) and (i <= self.displayMax-1):
self.menuItems[i].scaleLabel(1, self.timeline)
else:
self.menuItems[i].scaleLabel(2, self.timeline)
#print self.menuItems[self.selected].data + " " + str(self.menuItems[self.selected].itemTexturesGroup.scale_start)
#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:
self.menu_item_transition.forward(self.timeline, self.menuItems[self.selected-1].itemTexturesGroup, self.menuItems[self.selected].itemTexturesGroup)
else:
self.menuItems[self.selected].itemTexturesGroup.show()
#Check we're at the bottom of the viewable list
if self.selected >= (self.displayMax):
#If yes, move the menu, leave the selection bar where is
self.menuItems[self.selected].set_opacity(0)
self.menuItems[self.selected].show()
self.rollMenu( self.menuItems[self.selected], self.menuItems[self.selected-self.displaySize], self.timeline)
else:
#move the selection bar
self.glossMgr.get_selector_bar().selectItem(self.menuItems[self.selected], self.timeline)
self.timeline.start()
self.moveQueue = 0
#Returns the newly selected item
def selectPrevious(self):
#Check if we're at the first item in the list
if (self.selected) != 0:
self.timeline = clutter.Timeline (15,85)
self.input_queue.set_timeline(self.timeline)
#self.timeline.connect('completed', self.completeMove)
if not self.moveQueue == 0:
self.selected = self.selected -1 #+ self.moveQueue
self.moveQueue = self.moveQueue + 1 # 0
if self.selected < 0:
self.selected = 0
else:
self.selected = self.selected-1
#This horrible loop does all the scaling
#This includes, the selected item and the ones on either side of it
for i in range(len(self.menuItems)):
#print str(i)
if i == self.selected:
self.menuItems[i].scaleLabel(0, self.timeline)
elif (i == self.selected-1) and (i >= self.displayMin):
self.menuItems[i].scaleLabel(1, self.timeline)
elif (i == self.selected+1) and (i <= self.displayMax-1):
self.menuItems[i].scaleLabel(1, self.timeline)
else:
self.menuItems[i].scaleLabel(2, self.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:
self.menu_item_transition.backward(self.timeline, self.menuItems[self.selected+1].itemTexturesGroup, self.menuItems[self.selected].itemTexturesGroup)
else:
self.menuItems[self.selected].itemTexturesGroup.show()
#Check we're at the top of the viewable list
if self.selected < (self.displayMin):
#If yes, move the menu, leave the selection bar where is
#self.menuItems[self.selected].set_opacity(0)
#self.menuItems[self.selected].show()
self.rollMenu( self.menuItems[self.selected], self.menuItems[self.selected+self.displaySize], self.timeline)
else:
#move the selection bar
self.glossMgr.get_selector_bar().selectItem(self.menuItems[self.selected], self.timeline)
self.timeline.start()
def selectFirst(self, moveBar):
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)):
if i == 0:
self.menuItems[i].scaleLabel(0, self.timeline)
elif i == 1:
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()
if moveBar:
self.glossMgr.get_selector_bar().selectItem(self.menuItems[self.selected], self.timeline)
self.timeline.start()
#When the menu needs to display a new item from the top or bottom, it rolls
# The distance the menu moves is the distance (in pixels) between the incoming item and the selector bar
def rollMenu(self, incomingMenuItem, outgoingMenuItem, timeline):
(group_x, group_y) = self.itemGroup.get_abs_position()
(bar_x, bar_y) = self.glossMgr.get_selector_bar().get_abs_position() # incomingMenuItem.get_menu().getMenuMgr().
(incoming_x, incoming_y) = self.glossMgr.get_selector_bar().get_true_abs_position(incomingMenuItem) #incomingMenuItem.get_abs_position()
#print self.itemGroup.get_abs_position()
#print "Starting group position: " + self.itemGroup.get_abs_position()
if incoming_y > bar_y:
#Then the incoming item is below the selector bar
height_diff = int(self.glossMgr.get_selector_bar().get_height() - incomingMenuItem.get_height()) #self.glossMgr.get_selector_bar().get_height())
#print "height diff: " + str(height_diff)
gap = ((incoming_y - bar_y) - math.floor(height_diff/2)) * -1
gap = int(gap)
#gap = -65
self.displayMin = self.displayMin+1
self.displayMax = self.displayMax+1
else:
#Then the incoming item is above the selector bar
height_diff = int(self.glossMgr.get_selector_bar().get_height() - incomingMenuItem.get_height()) #self.glossMgr.get_selector_bar().get_height())
gap = bar_y - incoming_y + math.ceil(height_diff/2)
gap = int(gap)
#gap = 65
self.displayMin = self.displayMin-1
self.displayMax = self.displayMax-1
#print "Gap: " + str(gap)
new_y = (group_y + gap)
knots = (\
(group_x, group_y),\
(group_x, new_y )\
)
alpha = clutter.Alpha(timeline, clutter.ramp_inc_func)
self.behaviour1 = clutter.BehaviourPath(alpha, knots)
self.behaviour2 = clutter.BehaviourOpacity(opacity_start=outgoingMenuItem.get_opacity(), opacity_end=0, alpha=alpha)
#print "Going to: "+ str(new_y)
#print behaviour1.get_knots()
self.behaviour1.apply(self.itemGroup)
self.behaviour2.apply(outgoingMenuItem)
def get_item_gap(self):
return self.item_gap
def get_current_item(self):
return self.menuItems[self.selected]
class ListItem (clutter.Label):
zoomLevel = 0.5
opacityStep = 120
def __init__ (self, menu, itemLabel, y):
clutter.Label.__init__ (self)
glossMgr = menu.getGlossMgr()
self.menu = menu
self.stage = glossMgr.get_stage()
#ItemTexturesGroup is what shows any images / reflections associated with the item
self.itemTexturesGroup = clutter.Group()
self.itemTexturesGroup.set_position(menu.menu_image_x, menu.menu_image_y)
#setup the label
font = menu.font
self.set_font_name(font)
self.set_text(itemLabel)
self.color = clutter.Color(0xff, 0xff, 0xff, 0xdd)
self.set_color(self.color)
self.currentOpacity = 255
self.data = itemLabel #By default the items data is simply its label
#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
self.set_scale(self.zoomLevel, self.zoomLevel)
self.currentZoom = 0
#(label_width, label_height) = self.label.get_size()
label_x = 0 #x #self.stage.get_width() - label_width - 50
label_y = y #self.stage.get_height() - label_height
self.set_position(0, y)
#Add textures group and mark whether or not the textures are currently on the stage
self.itemTexturesGroup.show_all()
self.onStage = False
def scaleLabel(self, level, timeline):
#Determine the zooming level
zoomTo=0
opacityTo = 255
if level==0:
zoomTo = self.menu.zoomStep0 #self.zoomLevel * 1.5
opacityTo = self.menu.opacityStep0
self.itemTexturesGroup.hide()
self.menu.add(self.itemTexturesGroup)
self.onStage = True
#self.itemTexturesGroup.show_all()
if level==1:
zoomTo = self.menu.zoomStep1
opacityTo = self.menu.opacityStep1
if self.onStage:
#self.menu.remove(self.itemTexturesGroup)
self.onStage = False
#self.itemTexturesGroup.hide_all()
if level==2:
zoomTo = self.menu.zoomStep2
opacityTo = self.menu.opacityStep2
if self.onStage:
#self.menu.remove(self.itemTexturesGroup)
self.onStage = False
#self.itemTexturesGroup.hide_all()
if (zoomTo == self.currentZoom) and (opacityTo == self.currentOpacity):
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.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)
self.behaviour2.apply(self)
#timeline.connect('completed', self.scale_end_event, zoomTo, opacityTo)
self.currentZoom = zoomTo
self.currentOpacity = opacityTo
def scale_end_event(self, data, zoomTo, opacityTo):
pass
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
def get_data(self):
return self.data
def setAction(self, newAction):
self.action = newAction
def getAction(self):
return self.action
def get_menu(self):
return self.menu

10
Page.py
View File

@ -1,10 +0,0 @@
import clutter
"""
A Page is like a menu, but without the menu and 'things' placed everywhere
instead of menu items
"""
class Page():
def __init__():
pass

View File

@ -21,7 +21,7 @@ for fs_object in module_list:
print "Found Module: " + fs_object
modules.append(__import__(tmp_dir))
from Menu import Menu
#from Menu import Menu
from GlossMgr import GlossMgr
from myth.MythMySQL import mythDB
@ -55,7 +55,7 @@ class MainApp:
#Update splash status msg
self.splashScreen.set_msg("Creating menus")
MainMenu = Menu(self.glossMgr)
MainMenu = self.glossMgr.create_menu() #Menu(self.glossMgr)
#menu1.addItem("nothing", "ui/dvd.png")
#menu1.addItem("nothing", "ui/dvd.png")
#menu1.addItem("nothing", "ui/dvd.png")

View File

@ -2,6 +2,8 @@ import clutter
import pygtk
import gtk
import random
import math
from ReflectionTexture import Texture_Reflection
class image_previewer(clutter.Group):
tex1 = None
@ -13,21 +15,39 @@ class image_previewer(clutter.Group):
behave3 = None
scale_start = 0.6
seconds = 8
fps = 25
def __init__(self, stage):
clutter.Group.__init__(self)
self.textures = []
self.stage = stage
self.timeline = clutter.Timeline(200, 25)
self.timeline.set_loop(True)
self.timeline.connect('completed', self.next_image)
self.timeline1 = clutter.Timeline((self.seconds*self.fps), self.fps)
self.timeline1.set_loop(True)
self.timeline1.connect('completed', self.next_image)
self.handler_id1 = self.timeline1.connect('new-frame', self.kickoff)
self.timeline2 = clutter.Timeline((self.seconds*self.fps), self.fps)
self.timeline2.set_loop(True)
self.timeline2.connect('completed', self.next_image)
self.handler_id2 = self.timeline2.connect('new-frame', self.kickoff)
self.timeline3 = clutter.Timeline((self.seconds*self.fps), self.fps)
self.timeline3.set_loop(True)
self.timeline3.connect('completed', self.next_image)
self.timeline3.connect('new-frame', self.kickoff)
self.connect('show', self.start)
self.alpha = clutter.Alpha(self.timeline, clutter.ramp_inc_func)
self.alpha1 = clutter.Alpha(self.timeline1, clutter.ramp_inc_func)
self.alpha2 = clutter.Alpha(self.timeline2, clutter.ramp_inc_func)
self.alpha3 = clutter.Alpha(self.timeline3, clutter.ramp_inc_func)
self.behaviour_scale = clutter.BehaviourScale(x_scale_start=self.scale_start, y_scale_start=self.scale_start, x_scale_end=1, y_scale_end=1, alpha=self.alpha)
self.behaviour_depth = clutter.BehaviourDepth(depth_start=-300, depth_end=200, alpha=self.alpha)
#self.behaviour_scale = clutter.BehaviourScale(x_scale_start=self.scale_start, y_scale_start=self.scale_start, x_scale_end=1, y_scale_end=1, alpha=self.alpha)
self.behaviour_depth1 = clutter.BehaviourDepth(depth_start=-800, depth_end=200, alpha=self.alpha1)
self.behaviour_depth2 = clutter.BehaviourDepth(depth_start=-800, depth_end=200, alpha=self.alpha2)
self.behaviour_depth3 = clutter.BehaviourDepth(depth_start=-800, depth_end=200, alpha=self.alpha3)
def add_texture(self, texture_src):
@ -41,13 +61,24 @@ class image_previewer(clutter.Group):
self.tex2 = self.get_rand_tex()
self.tex3 = self.get_rand_tex()
self.behave1 = clutter.BehaviourPath(self.alpha, self.get_texture_knots(self.tex1))
self.behave2 = clutter.BehaviourPath(self.alpha, self.get_texture_knots(self.tex2))
self.behave3 = clutter.BehaviourPath(self.alpha, self.get_texture_knots(self.tex3))
self.behave1 = clutter.BehaviourPath(self.alpha1, self.get_texture_knots(self.tex1))
self.behave2 = clutter.BehaviourPath(self.alpha2, self.get_texture_knots(self.tex2))
self.behave3 = clutter.BehaviourPath(self.alpha3, self.get_texture_knots(self.tex3))
#self.tex1.set_scale(self.scale_start, self.scale_start)
self.behaviour_depth.apply(self.tex1)
self.behaviour_depth1.apply(self.tex1)
self.behave1.apply(self.tex1)
self.behaviour_depth2.apply(self.tex2)
self.behave2.apply(self.tex2)
self.behaviour_depth3.apply(self.tex3)
self.behave3.apply(self.tex3)
#Special opacity behaviour to brin ghte fist texture in
timeline_opacity = clutter.Timeline(20, self.fps)
alpha_opacity = clutter.Alpha(timeline_opacity, clutter.ramp_inc_func)
self.behaviour_opacity = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=alpha_opacity)
self.tex1.set_opacity(0)
self.behaviour_opacity.apply(self.tex1)
self.add(self.tex1)
@ -62,7 +93,27 @@ class image_previewer(clutter.Group):
self.tex1.show()
self.show()
#parent.add(self)
self.timeline.start()
self.timeline1.start()
timeline_opacity.start()
self.nextTexture = self.get_rand_tex()
#This starts the various timelines at the appropriate points
def kickoff(self, timeline, frame_no):
if frame_no == (math.floor(self.fps*self.seconds/3)) or frame_no == (2*math.floor(self.fps*self.seconds/3)):
if timeline == self.timeline1:
self.add(self.tex2)
self.tex2.show()
self.timeline2.start()
self.timeline1.disconnect(self.handler_id1)
self.handler_id1 = None
if timeline == self.timeline2:
self.add(self.tex3)
self.tex3.show()
self.timeline3.start()
self.timeline2.disconnect(self.handler_id2)
self.handler_id2 = None
def get_rand_tex(self):
rand = random.randint(0, len(self.textures)-1)
@ -73,12 +124,18 @@ class image_previewer(clutter.Group):
xy_ratio = float(texture.get_width()) / texture.get_height()
#texture.set_height(self.get_height())
width = int(texture.get_height() * xy_ratio)
reflectionTexture = Texture_Reflection(texture)
textureGroup = clutter.Group()
textureGroup.add(texture)
textureGroup.add(reflectionTexture)
texture.show()
reflectionTexture.show()
#texture.set_width(width)
return texture
return textureGroup
def next_image(self, data):
texture = self.get_rand_tex()
self.add(texture)
texture = self.nextTexture
#Remove the old texture
@ -90,8 +147,9 @@ class image_previewer(clutter.Group):
#Set the appropriate tex
if self.frontTex == self.tex1:
self.tex1 = texture
self.behave1 = clutter.BehaviourPath(self.alpha, knots)
currentBehave = self.behave1
self.behave1 = clutter.BehaviourPath(self.alpha1, knots)
self.behave1.apply(self.tex1)
self.behaviour_depth1.apply(self.tex1)
self.frontTex = self.tex2
#texture.lower(self.tex2)
@ -99,32 +157,40 @@ class image_previewer(clutter.Group):
elif self.frontTex == self.tex2:
self.tex2 = texture
self.behave2 = clutter.BehaviourPath(self.alpha, knots)
currentBehave = self.behave2
self.behave2 = clutter.BehaviourPath(self.alpha2, knots)
self.behave2.apply(self.tex2)
self.behaviour_depth2.apply(self.tex2)
self.frontTex = self.tex3
#texture.lower(self.tex1)
#texture.lower(self.tex3)
elif self.frontTex == self.tex3:
self.tex3 = texture
self.behave3 = clutter.BehaviourPath(self.alpha, knots)
currentBehave = self.behave3
self.behave3 = clutter.BehaviourPath(self.alpha3, knots)
self.behave3.apply(self.tex3)
self.behaviour_depth3.apply(self.tex3)
self.frontTex = self.tex1
#texture.lower(self.tex1)
#texture.lower(self.tex2)
#Special opacity behaviour to bring texture in
timeline_opacity = clutter.Timeline(20, self.fps)
alpha_opacity = clutter.Alpha(timeline_opacity, clutter.ramp_inc_func)
self.behaviour_opacity = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=alpha_opacity)
texture.set_opacity(0)
self.behaviour_opacity.apply(texture)
timeline_opacity.start()
currentBehave.apply(texture)
self.add(texture)
texture.show()
self.nextTexture = self.get_rand_tex()
def get_texture_knots(self, texture):
knots = (\
(0, 0),\
#(int(self.get_width()*0.2), int(self.get_height()*0.2)),\
#(int(self.stage.get_width()*0.1), int(self.stage.get_height()*0.1)),\
(int(-texture.get_width()), int(self.get_height()*0.3))\
#int(self.get_height()*0.3))\
(int(-texture.get_width()), 0)\
)
return knots

View File

@ -6,7 +6,7 @@ import clutter
from clutter import cluttergst
from modules.myth_tv_player.MythBackendConn import MythBackendConnection
from Menu import Menu
#from Menu import Menu
from VideoController import VideoController
class Module:
@ -73,7 +73,7 @@ class Module:
#The following generates a menu with an option for each of the slideshows in the base menu
def generateMenu(self):
tempMenu = Menu(self.MenuMgr)
tempMenu = self.glossMgr.create_menu() #Menu(self.MenuMgr)
self.dbMgr.get_channels()
file_list = os.listdir(self.baseDir)

View File

@ -1,7 +1,7 @@
import clutter
from clutter import cluttergst
#__import__("../../Menu", "Menu")
from Menu import Menu
#from Menu import Menu
from image_preview import image_previewer
import time
import os.path
@ -361,7 +361,7 @@ class Module:
#The following generates a menu with an option for each of the slideshows in the base menu
def generateMenu(self):
tempMenu = Menu(self.glossMgr)
tempMenu = self.glossMgr.create_menu() #Menu(self.glossMgr)
self.menu = tempMenu
#print self.baseDir
#This occurs when there are not slideshows or we could not connect to the db to establish baseDir
@ -391,7 +391,7 @@ class Module:
img_previewer.add_texture(imgPath)
#print imgPath
#new_file_list = os.listdir(dirPath)
#tempItem.itemTexturesGroup = img_previewer
tempItem.itemTexturesGroup = img_previewer
img_previewer.set_position(tempItem.menu.menu_image_x, tempItem.menu.menu_image_y)
tempItem.setAction(self)

View File

@ -7,7 +7,7 @@ from xml.dom import minidom
class ThemeMgr:
defaultTheme = "default"
currentTheme = "default"
currentTheme = "Pear"
#currentTheme = "Pear"
def __init__(self, glossMgr):
self.stage = glossMgr.stage
@ -303,67 +303,4 @@ class ThemeMgr:
size = defSize
fontString = str(face) + " " + str(size)
return fontString
def setup_menu(self, name, menu):
element = self.search_docs("menu", name).childNodes
#Quick check to make sure we found something
if element is None:
return None
menu.item_gap = int(self.find_child_value(element, "item_gap"))
menu.displayMax = int(self.find_child_value(element, "num_visible_elements"))
#Grab the font
font_node = self.get_subnode(element, "font")
fontString = self.get_font("main", font_node)
menu.font = fontString
#Set the selection effect steps
menu.zoomStep0 = float(self.find_child_value(element, "scale_step0"))
menu.zoomStep1 = float(self.find_child_value(element, "scale_step1"))
menu.zoomStep2 = float(self.find_child_value(element, "scale_step2"))
menu.opacityStep0 = int(self.find_child_value(element, "opacity_step0"))
menu.opacityStep1 = int(self.find_child_value(element, "opacity_step1"))
menu.opacityStep2 = int(self.find_child_value(element, "opacity_step2"))
#setup the menu_image properties
menu.useReflection = "True" == (self.find_child_value(element, "menu_item_texture.use_image_reflections"))
menu.menu_image_rotation = int(self.find_child_value(element, "menu_item_texture.image_y_rotation"))
menu_image_node = self.get_subnode(element, "menu_item_texture")
if not menu_image_node is None:
#Set the position
(x, y) = self.get_position(menu_image_node, self.stage)
menu.menu_image_x = int(x)
menu.menu_image_y = int(y)
"""
#Set the size
(width, height) = self.get_dimensions(menu_image_node, self.stage)
if width is None:
print "no size change"
menu.menu_image_width = None
menu.menu_image_height = None
else:
menu.menu_image_width = int(width)
menu.menu_image_height = int(height)
"""
#Setup the menu image transition
image_transition = self.find_child_value(element, "menu_item_texture.image_transition.name")
transition_options = self.find_child_value(element, "menu_item_texture.image_transition.options")
transition_path = "transitions/menu_items/" + str(image_transition)
try:
menu.menu_item_transition = __import__(transition_path).Transition(self.glossMgr)
menu.menu_item_transition.set_options(transition_options)
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)
return fontString

View File

@ -1,5 +1,6 @@
<gloss-theme>
<menu id="main">
<interface>ListMenu</interface>
<font id="main">
<face>Tahoma</face>