Fixing everything that broke in the implementation of interfaces
This commit is contained in:
parent
d5c4a760ea
commit
b474bf0ad1
|
@ -68,8 +68,8 @@ class GlossMgr:
|
|||
self.currentMenu.show_all()
|
||||
self.currentMenu.show()
|
||||
|
||||
self.stage.add(self.currentMenu)
|
||||
self.stage.add(self.currentMenu.getItemGroup())
|
||||
#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()
|
||||
|
@ -79,6 +79,7 @@ class GlossMgr:
|
|||
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
|
||||
|
@ -130,7 +131,6 @@ class GlossMgr:
|
|||
#hide any unnecesary actors
|
||||
self.currentMenu.hide()
|
||||
#self.stage.remove(self.currentMenu.getItemGroup())
|
||||
|
||||
#And begin the plugin
|
||||
action.begin( self )
|
||||
# This is tres bodge
|
||||
|
|
15
gloss.py
15
gloss.py
|
@ -55,15 +55,7 @@ class MainApp:
|
|||
|
||||
#Update splash status msg
|
||||
self.splashScreen.set_msg("Creating menus")
|
||||
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")
|
||||
|
||||
#menu1.setListFont('Tahoma 42')
|
||||
MainMenu.setMenuPositionByName("center")
|
||||
#self.MainMenu = menu
|
||||
|
||||
MainMenu = self.glossMgr.create_menu()
|
||||
|
||||
#Update splash status msg
|
||||
self.splashScreen.set_msg("Connecting to MythTV server")
|
||||
|
@ -79,9 +71,8 @@ class MainApp:
|
|||
self.splashScreen.set_msg("Loading "+title)
|
||||
temp_menu_item = MainMenu.addItem(title)
|
||||
temp_menu_item.add_image_from_texture(tempMod.menu_image)
|
||||
|
||||
temp_menu_item.setAction(tempMod.action())
|
||||
|
||||
|
||||
self.splashScreen.remove()
|
||||
self.stage.connect('key-press-event', self.glossMgr.on_key_press_event)
|
||||
MainMenu.display()
|
||||
|
@ -89,8 +80,6 @@ class MainApp:
|
|||
|
||||
|
||||
return False
|
||||
#print self.menuMgr.get_selector_bar().get_abs_position()
|
||||
#self.menuMgr.get_selector_bar().set_spinner(True)
|
||||
|
||||
|
||||
def on_button_press_event (self, stage, event):
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
The main interface filename must be the same as the directory its in:
|
||||
<intefaces>
|
||||
<ListMenu>
|
||||
ListMenu.py
|
||||
<WheelMenu>
|
||||
WheelMenu.py
|
||||
|
||||
Class name must be 'Interface' and be a subclass of clutter.Group
|
||||
__init__ function takes form (self, glossMgr)
|
||||
|
||||
####################################################
|
||||
#Interfaces require the following to be implemented:
|
||||
####################################################
|
||||
Class Name = Interface
|
||||
- addItem(label)
|
||||
- display()
|
||||
- getItem(index)
|
||||
- Returns the menu item identified by index
|
||||
- selectNext()
|
||||
- selectPrevious()
|
||||
- selectFirst()
|
||||
- get_current_item()
|
||||
- Returns the currently selected item
|
||||
|
||||
#####################################################
|
||||
HIGHLY RECOMMENDED:
|
||||
Implement the inputQueue mgr with the following:
|
||||
|
||||
#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)
|
|
@ -0,0 +1,92 @@
|
|||
import clutter
|
||||
import pango
|
||||
|
||||
class MenuItem (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 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
|
|
@ -0,0 +1,39 @@
|
|||
import clutter
|
||||
import pygtk
|
||||
import gtk
|
||||
import pango
|
||||
import time
|
||||
import math
|
||||
from ReflectionTexture import Texture_Reflection
|
||||
from interfaces.ListItem import ListItem
|
||||
from InputQueue import InputQueue
|
||||
|
||||
class Interface(clutter.Group):
|
||||
itemGroup = clutter.Group()
|
||||
|
||||
def __init__ (self, glossMgr):
|
||||
clutter.Group.__init__(self)
|
||||
self.glossMgr = glossMgr
|
||||
self.stage = self.glossMgr.get_stage()
|
||||
self.itemGroup = clutter.Group()
|
||||
self.setup_ui(self.glossMgr.themeMgr, "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)
|
||||
|
||||
def addItem(self, itemLabel):
|
||||
if len(self.itemsGroup) == 0:
|
||||
tempLabel = clutter.Label()
|
||||
tempLabel.set_font_name(self.font)
|
||||
tempLabel.set_text("S")
|
||||
self.label_height = tempLabel.get_height()
|
||||
label_width = 0
|
||||
|
||||
label_y = len(self.menuItems) * (self.label_height + self.item_gap)
|
||||
#print "Label height: " + str(self.label_height)
|
||||
|
||||
newItem = MenuListItem(self, itemLabel, label_y)
|
||||
self.menuItems.append(newItem)
|
||||
self.itemGroup.add(newItem)
|
|
@ -359,9 +359,9 @@ class Module:
|
|||
self.nexttSong = None
|
||||
|
||||
#The following generates a menu with an option for each of the slideshows in the base menu
|
||||
def generateMenu(self):
|
||||
|
||||
def generateMenu(self):
|
||||
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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -8,11 +8,8 @@ class Transition:
|
|||
|
||||
def do_transition(self, fromMenu, toMenu):
|
||||
|
||||
|
||||
oldGroup = fromMenu.getItemGroup()
|
||||
oldMenuGroup = fromMenu #.getMenuGroup()
|
||||
newGroup = toMenu.getItemGroup()
|
||||
newMenuGroup = toMenu #.getMenuGroup()
|
||||
|
||||
oldGroup.set_opacity(255)
|
||||
|
||||
|
@ -24,16 +21,16 @@ class Transition:
|
|||
|
||||
#Setup some knots
|
||||
knots_exiting = (\
|
||||
(oldGroup.get_x(), oldGroup.get_y()),\
|
||||
(fromMenu.get_x(), fromMenu.get_y()),\
|
||||
#(-oldGroup.get_x(), int(fromMenu.getStage().get_height()/2))
|
||||
(-oldGroup.get_x(), oldGroup.get_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(oldGroup)
|
||||
self.exit_behaviour_opacity.apply(oldMenuGroup)
|
||||
self.exit_behaviour_path.apply(oldGroup)
|
||||
self.exit_behaviour_opacity.apply(fromMenu.get_current_item().itemTexturesGroup)
|
||||
self.exit_behaviour_opacity.apply(fromMenu)
|
||||
self.exit_behaviour_path.apply(fromMenu)
|
||||
|
||||
|
||||
##################################################################
|
||||
|
@ -42,43 +39,36 @@ class Transition:
|
|||
self.entrance_behaviour_opacity = clutter.BehaviourOpacity(opacity_start=0, opacity_end=255, alpha=self.alpha)
|
||||
|
||||
#Setup some knots
|
||||
start_y = oldGroup.get_y()#int(self.stage.get_height()/2 - newGroup.get_height()/2)
|
||||
start_y = fromMenu.get_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)
|
||||
|
||||
(end_x, end_y) = fromMenu.get_position()
|
||||
knots_entering = (\
|
||||
(newGroup.get_x(), newGroup.get_y()),\
|
||||
#(toMenu.get_x(), toMenu.get_y()),\
|
||||
(start_x, start_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)
|
||||
self.entrance_behaviour_opacity.apply(toMenu.get_current_item().itemTexturesGroup)
|
||||
self.entrance_behaviour_opacity.apply(toMenu)
|
||||
self.entrance_behaviour_path.apply(toMenu)
|
||||
#newGroup.show_all()
|
||||
#newMenuGroup.show_all()
|
||||
|
||||
#This takes care of adding the new menu to the stage etc
|
||||
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())
|
||||
self.stage.remove(fromMenu.get_current_item().itemTexturesGroup)
|
|
@ -1,6 +1,7 @@
|
|||
<gloss-theme>
|
||||
<menu id="main">
|
||||
|
||||
<interface>ListMenu</interface>
|
||||
|
||||
<font id="main">
|
||||
<face>Tahoma</face>
|
||||
<size id="default">30</size>
|
||||
|
@ -48,7 +49,7 @@
|
|||
|
||||
<!-- Used for transitioning between menus -->
|
||||
<menu_transition>
|
||||
<name>zoom_fade</name>
|
||||
<name>slide</name>
|
||||
<options>None</options>
|
||||
</menu_transition>
|
||||
|
||||
|
|
Loading…
Reference in New Issue