- Fixes to label_queue

This commit is contained in:
noisymime 2008-06-20 23:58:53 +00:00
parent 0ac07b5c9c
commit eb32e8c8ff
4 changed files with 21 additions and 36 deletions

View File

@ -18,7 +18,7 @@ class Module(clutter.Group):
self.backdrop.set_height(self.stage.get_height()) self.backdrop.set_height(self.stage.get_height())
self.add(self.backdrop) self.add(self.backdrop)
self.queue = LabelQueue() self.queue = LabelQueue(orientation=LabelQueue.ORIENTATION_BOTTOM)
self.queue.setup_from_theme_id(glossMgr.themeMgr, "tests_label_queue") self.queue.setup_from_theme_id(glossMgr.themeMgr, "tests_label_queue")
self.add(self.queue) self.add(self.queue)
@ -33,13 +33,6 @@ class Module(clutter.Group):
return True return True
def begin(self, glossMgr): def begin(self, glossMgr):
"""
self.label = clutter.Label()
self.label.set_text("blahdslkfjdsl")
self.label.show()
self.label.set_color(clutter.color_parse('White'))
self.add(self.label)
"""
self.backdrop.set_opacity(0) self.backdrop.set_opacity(0)
self.backdrop.show() self.backdrop.show()

View File

@ -166,10 +166,8 @@ class Module:
for fs_object in module_list: for fs_object in module_list:
file = tests_dir + "/" + fs_object file = tests_dir + "/" + fs_object
print file[-8:]
if (file[-3:] == ".py") and (not file[-8:] == "tests.py"): if (file[-3:] == ".py") and (not file[-8:] == "tests.py"):
file = file.rstrip(".py") file = file.rstrip(".py")
print file
test = __import__(file).Module(self.glossMgr, self.dbMgr) test = __import__(file).Module(self.glossMgr, self.dbMgr)
self.tests.append(test) self.tests.append(test)
tempItem = tempMenu.addItem(fs_object) tempItem = tempMenu.addItem(fs_object)

View File

@ -22,7 +22,7 @@
Eg: 1.00 means that each item will be the same height as the font, 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 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> <item_height_percent>1.10</item_height_percent>
<item_width_percent>1.00</item_width_percent> <item_width_percent>1.00</item_width_percent>
<!-- These are the opacity and scale values for the 3 possible steps in the menu <!-- These are the opacity and scale values for the 3 possible steps in the menu
@ -30,9 +30,6 @@
<opacity_step0>255</opacity_step0> <opacity_step0>255</opacity_step0>
<opacity_step1>135</opacity_step1> <opacity_step1>135</opacity_step1>
<opacity_step2>135</opacity_step2> <opacity_step2>135</opacity_step2>
<scale_step0>1</scale_step0>
<scale_step1>1</scale_step1>
<scale_step2>1</scale_step2>
<transition_fps>30</transition_fps> <transition_fps>30</transition_fps>
<transition_frames>10</transition_frames> <transition_frames>10</transition_frames>

View File

@ -56,6 +56,7 @@ class LabelQueue(clutter.Group):
#Score is used when adding / removing items as it is a two stage process (eg 2 timelines) #Score is used when adding / removing items as it is a two stage process (eg 2 timelines)
self.score = clutter.Score() self.score = clutter.Score()
self.score.connect("completed", self.flush_backlog) self.score.connect("completed", self.flush_backlog)
self.score.append(clutter.Timeline(20,20)) # Seems to be a bug in Clutter 0.6 if score.remove_all() is called before a timeline has been added, so just add an unusued timeline here
self.backlog = [] self.backlog = []
def setup_from_theme_id(self, themeMgr, id, parent=None): def setup_from_theme_id(self, themeMgr, id, parent=None):
@ -139,12 +140,12 @@ class LabelQueue(clutter.Group):
return self.timeline return self.timeline
def add_item(self, itemLabel, newItem=None): def add_item(self, itemLabel, newItem=None):
"""
if self.score.is_playing(): if self.score.is_playing():
self.backlog.append(itemLabel) self.backlog.append(itemLabel)
return return
self.score.remove_all() self.score.remove_all()
"""
if len(self.items) == 0: if len(self.items) == 0:
#self.displayMax = self.height / self.label_height #self.displayMax = self.height / self.label_height
label_width = 0 label_width = 0
@ -153,23 +154,18 @@ class LabelQueue(clutter.Group):
if self.display_group.get_parent() is None: if self.display_group.get_parent() is None:
self.add(self.display_group) self.add(self.display_group)
if newItem is None: newItem = QueueItem(self.font_string, itemLabel, label_queue = self, max_width = self.width) if newItem is None: newItem = QueueItem(self.font_string, self, label=itemLabel)
newItem.set_background(clutter.CloneTexture(self.inactive_item_background), self.item_width_percent, self.item_height_percent) newItem.set_background(clutter.CloneTexture(self.inactive_item_background), self.item_width_percent, self.item_height_percent)
"""
newItem = clutter.Label()
newItem.set_text("blahdslkfjdsl")
newItem.show()
newItem.set_color(clutter.color_parse('White'))
"""
item_height = newItem.get_height() item_height = newItem.get_height()
if self.orientation == self.ORIENTATION_TOP: if self.orientation == self.ORIENTATION_TOP:
item_y = 0 item_y = 0
elif self.orientation == self.ORIENTATION_BOTTOM: elif self.orientation == self.ORIENTATION_BOTTOM:
running_y = 0 running_y = int(self.height + (item_height/2))
for item in self.items: for item in self.items:
running_y += (item.get_height()) running_y += (item.get_height())
item_y = running_y item_y = int(running_y)
newItem.show() newItem.show()
newItem.set_position(0, item_y) newItem.set_position(0, item_y)
newItem.set_opacity(0) newItem.set_opacity(0)
@ -191,9 +187,9 @@ class LabelQueue(clutter.Group):
tmp_behaviour.apply(item) tmp_behaviour.apply(item)
self.behaviours.append(tmp_behaviour) self.behaviours.append(tmp_behaviour)
elif self.orientation == self.ORIENTATION_BOTTOM: elif self.orientation == self.ORIENTATION_BOTTOM:
knots = ( knots = (\
(self.item_group.get_x(), self.item_group.get_y()),\ (self.item_group.get_x(), self.item_group.get_y()),\
(self.item_group.get_x(), self.item_group.get_y()-item_height)\ (self.item_group.get_x(), int(self.item_group.get_y()-item_height))\
) )
tmp_behaviour = clutter.BehaviourPath(alpha1, knots) tmp_behaviour = clutter.BehaviourPath(alpha1, knots)
tmp_behaviour.apply(self.item_group) tmp_behaviour.apply(self.item_group)
@ -433,7 +429,7 @@ class QueueItem(clutter.Group):
opacity_step_medium = 135 opacity_step_medium = 135
opacity_step_none = 50 opacity_step_none = 50
def __init__ (self, font, label="", label_queue=None, max_width=None): def __init__ (self, font, label_queue, label=""):
clutter.Group.__init__ (self) clutter.Group.__init__ (self)
self.set_anchor_point_from_gravity(clutter.GRAVITY_NORTH) self.set_anchor_point_from_gravity(clutter.GRAVITY_NORTH)
#self.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER) #self.set_anchor_point_from_gravity(clutter.GRAVITY_CENTER)
@ -442,12 +438,12 @@ class QueueItem(clutter.Group):
self.label = clutter.Label() self.label = clutter.Label()
#Takes the scale and opacity values from a label list, if given #Takes the scale and opacity values from a label list, if given
if not label_queue is None:
self.opacity_step_full = label_queue.opacityStep0 self.opacity_step_full = label_queue.opacityStep0
self.opacity_step_medium = label_queue.opacityStep1 self.opacity_step_medium = label_queue.opacityStep1
self.opacity_step_none = label_queue.opacityStep2 self.opacity_step_none = label_queue.opacityStep2
self.label.set_width(max_width) self.label_queue = label_queue
self.label.set_width(label_queue.width)
#setup the label/s #setup the label/s
self.add(self.label) self.add(self.label)
@ -495,7 +491,7 @@ class QueueItem(clutter.Group):
def set_background(self, texture, width_percent, height_percent): def set_background(self, texture, width_percent, height_percent):
if self.background is None: if self.background is None:
texture.set_width(int(self.label.get_width() * width_percent)) texture.set_width(int(self.label_queue.width * width_percent))
texture.set_height(int(self.label.get_height() * height_percent)) texture.set_height(int(self.label.get_height() * height_percent))
else: else:
texture.set_width(self.background.get_width()) texture.set_width(self.background.get_width())
@ -508,7 +504,8 @@ class QueueItem(clutter.Group):
self.label.set_position(label_x, label_y) self.label.set_position(label_x, label_y)
self.add(self.background) self.add(self.background)
self.lower_child(self.background, self.label) self.lower_child(self.label, self.background)
self.background.show()
def set_data(self, data): def set_data(self, data):
self.data = data self.data = data