- Small fixes
This commit is contained in:
parent
4719b607df
commit
54e693d7a3
21
themeMgr.py
21
themeMgr.py
|
@ -160,7 +160,7 @@ class ThemeMgr:
|
||||||
if relativeTo == "relativeToStage":
|
if relativeTo == "relativeToStage":
|
||||||
parent = self.stage
|
parent = self.stage
|
||||||
elif relativeTo == "relativeToParent":
|
elif relativeTo == "relativeToParent":
|
||||||
parent = actor.get_parent()
|
if parent is None: parent = actor.get_parent()
|
||||||
elif relativeTo == "relativeToSelf":
|
elif relativeTo == "relativeToSelf":
|
||||||
parent = actor
|
parent = actor
|
||||||
|
|
||||||
|
@ -198,8 +198,8 @@ class ThemeMgr:
|
||||||
if width[-1] == "%":
|
if width[-1] == "%":
|
||||||
#Quick check on parent
|
#Quick check on parent
|
||||||
if parent is None:
|
if parent is None:
|
||||||
print "Theme error: type must be specified when using percentage values"
|
print "Theme error (get_dimensions width): parent must be specified when using percentage values"
|
||||||
return None
|
return (None, None)
|
||||||
|
|
||||||
width = (float(width[:-1]) / 100.0) * parent.get_width()
|
width = (float(width[:-1]) / 100.0) * parent.get_width()
|
||||||
#print "width: " + str(width)
|
#print "width: " + str(width)
|
||||||
|
@ -226,7 +226,7 @@ class ThemeMgr:
|
||||||
if x[-1] == "%":
|
if x[-1] == "%":
|
||||||
#Quick check on parent
|
#Quick check on parent
|
||||||
if parent is None:
|
if parent is None:
|
||||||
print "Theme error: type must be specified when using percentage values"
|
print "Theme error (get_position x): type must be specified when using percentage values"
|
||||||
return None
|
return None
|
||||||
|
|
||||||
x = (float(x[:-1]) / 100.0) * parent.get_width()
|
x = (float(x[:-1]) / 100.0) * parent.get_width()
|
||||||
|
@ -246,7 +246,7 @@ class ThemeMgr:
|
||||||
if y[-1] == "%":
|
if y[-1] == "%":
|
||||||
#Quick check on parent
|
#Quick check on parent
|
||||||
if parent is None:
|
if parent is None:
|
||||||
print "Theme error: type must be specified when using percentage values"
|
print "Theme error (get_position y): type must be specified when using percentage values"
|
||||||
return None
|
return None
|
||||||
|
|
||||||
y = (float(y[:-1]) / 100.0) * parent.get_height()
|
y = (float(y[:-1]) / 100.0) * parent.get_height()
|
||||||
|
@ -262,13 +262,14 @@ class ThemeMgr:
|
||||||
|
|
||||||
return (int(x), int(y))
|
return (int(x), int(y))
|
||||||
|
|
||||||
def get_texture(self, name, parent, texture):
|
def get_texture(self, name, parent, texture = None, element = None):
|
||||||
texture_src = None
|
texture_src = None
|
||||||
if texture is None:
|
if texture is None:
|
||||||
texture = clutter.Texture()
|
texture = clutter.Texture()
|
||||||
|
|
||||||
element = self.search_docs("texture", name).childNodes
|
#Element can be supplied but if not, we search through everything
|
||||||
#Quick check to make sure we found something
|
if element is None: element = self.search_docs("texture", name).childNodes
|
||||||
|
#Quick check to make sure we've got something
|
||||||
if element is None:
|
if element is None:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
@ -277,13 +278,15 @@ class ThemeMgr:
|
||||||
#Special case to handle no image
|
#Special case to handle no image
|
||||||
if src == "None":
|
if src == "None":
|
||||||
return texture
|
return texture
|
||||||
|
if src is None:
|
||||||
|
return None
|
||||||
|
|
||||||
src = self.theme_dir + self.currentTheme + "/" + src
|
src = self.theme_dir + self.currentTheme + "/" + src
|
||||||
pixbuf = gtk.gdk.pixbuf_new_from_file(src)
|
pixbuf = gtk.gdk.pixbuf_new_from_file(src)
|
||||||
texture.set_pixbuf(pixbuf)
|
texture.set_pixbuf(pixbuf)
|
||||||
|
|
||||||
#Setup general actor properties
|
#Setup general actor properties
|
||||||
self.setup_actor(texture, element, None)
|
self.setup_actor(texture, element, parent)
|
||||||
|
|
||||||
return texture
|
return texture
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,7 @@
|
||||||
<transition_fps>30</transition_fps>
|
<transition_fps>30</transition_fps>
|
||||||
<transition_frames>10</transition_frames>
|
<transition_frames>10</transition_frames>
|
||||||
|
|
||||||
|
|
||||||
</label_list>
|
</label_list>
|
||||||
|
|
||||||
<label_list id="music_songs">
|
<label_list id="music_songs">
|
||||||
|
|
|
@ -33,6 +33,19 @@
|
||||||
<transition_fps>30</transition_fps>
|
<transition_fps>30</transition_fps>
|
||||||
<transition_frames>10</transition_frames>
|
<transition_frames>10</transition_frames>
|
||||||
|
|
||||||
|
<texture id="inactive_background">
|
||||||
|
<image>music/songlist_off.png</image>
|
||||||
|
<dimensions type="relativeToParent">
|
||||||
|
<width>100%</width>
|
||||||
|
<height>100%</height>
|
||||||
|
</dimensions>
|
||||||
|
<position type="blah">
|
||||||
|
<x>0</x>
|
||||||
|
<y>0</y>
|
||||||
|
</position>
|
||||||
|
</texture>
|
||||||
|
<inactive_background>music/songlist_off.png</inactive_background>
|
||||||
|
|
||||||
</label_list>
|
</label_list>
|
||||||
|
|
||||||
</gloss-theme>
|
</gloss-theme>
|
||||||
|
|
|
@ -1,5 +1,7 @@
|
||||||
import clutter
|
import clutter
|
||||||
import pango
|
import pango
|
||||||
|
import pygtk
|
||||||
|
import gtk
|
||||||
from InputQueue import InputQueue
|
from InputQueue import InputQueue
|
||||||
|
|
||||||
class LabelList(clutter.Group):
|
class LabelList(clutter.Group):
|
||||||
|
@ -26,6 +28,11 @@ class LabelList(clutter.Group):
|
||||||
self.displayMax = length
|
self.displayMax = length
|
||||||
self.displaySize = self.displayMax - self.displayMin
|
self.displaySize = self.displayMax - self.displayMin
|
||||||
|
|
||||||
|
self.inactive_item_background = None
|
||||||
|
self.background_group = clutter.Group()
|
||||||
|
self.background_group.show()
|
||||||
|
self.add(self.background_group)
|
||||||
|
|
||||||
#Selector bar image, moves with selections to show current item
|
#Selector bar image, moves with selections to show current item
|
||||||
self.selector_bar = None
|
self.selector_bar = None
|
||||||
|
|
||||||
|
@ -54,8 +61,15 @@ class LabelList(clutter.Group):
|
||||||
self.fps = int(themeMgr.find_child_value(element, "transition_fps"))
|
self.fps = int(themeMgr.find_child_value(element, "transition_fps"))
|
||||||
self.frames = int(themeMgr.find_child_value(element, "transition_frames"))
|
self.frames = int(themeMgr.find_child_value(element, "transition_frames"))
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
themeMgr.setup_actor(self, element, themeMgr.stage)
|
themeMgr.setup_actor(self, element, themeMgr.stage)
|
||||||
|
|
||||||
|
img_element = themeMgr.search_docs("label_list", id).getElementsByTagName("texture")
|
||||||
|
if len(img_element) > 0: img_element = img_element[0].childNodes
|
||||||
|
#img_element = themeMgr.find_element(element, "id", "inactive_background")
|
||||||
|
self.inactive_item_background = themeMgr.get_texture("inactive_background", self, element = img_element)
|
||||||
|
|
||||||
def on_key_press_event (self, event):
|
def on_key_press_event (self, event):
|
||||||
self.input_queue.input(event)
|
self.input_queue.input(event)
|
||||||
return self.timeline
|
return self.timeline
|
||||||
|
@ -72,6 +86,16 @@ class LabelList(clutter.Group):
|
||||||
|
|
||||||
label_y = len(self.items) * (self.label_height + self.item_gap)
|
label_y = len(self.items) * (self.label_height + self.item_gap)
|
||||||
|
|
||||||
|
#If a background pic is specified in the theme, clone it and add
|
||||||
|
if not self.inactive_item_background is None:
|
||||||
|
bg_img = clutter.CloneTexture(self.inactive_item_background)
|
||||||
|
bg_img.set_height(self.label_height)
|
||||||
|
bg_img.set_width(self.get_width())
|
||||||
|
bg_img.set_position(0, label_y)
|
||||||
|
bg_img.show()
|
||||||
|
self.background_group.add(bg_img)
|
||||||
|
|
||||||
|
|
||||||
newItem = ListItem(self.font_string, itemLabel, label_list = self)
|
newItem = ListItem(self.font_string, itemLabel, label_list = self)
|
||||||
newItem.set_position(0, label_y)
|
newItem.set_position(0, label_y)
|
||||||
newItem.show()
|
newItem.show()
|
||||||
|
|
Loading…
Reference in New Issue