diff options
author | isen <isen@isen-desktop.(none)> | 2009-10-09 04:09:42 (GMT) |
---|---|---|
committer | isen <isen@isen-desktop.(none)> | 2009-10-09 04:09:42 (GMT) |
commit | 1d062b1e7397b9413f4f73efb451bb8d890ab296 (patch) | |
tree | 2d4ad914d9a6f02c232151522e5a081de0638057 /tutorius/overlayer.py | |
parent | 335833bba32a4643e95bd31337637f5e2a075cee (diff) | |
parent | c67e568a0a34e89a77cb2121d2b3859cd6885e69 (diff) |
Merge branch 'lp426452_suite' into lp426452
lp426452_suite was the generalisation of the tail drawing (n tails)
Conflicts:
addons/bubblemessage.py
setup.cfg
tutorius/overlayer.py
Diffstat (limited to 'tutorius/overlayer.py')
-rw-r--r-- | tutorius/overlayer.py | 63 |
1 files changed, 24 insertions, 39 deletions
diff --git a/tutorius/overlayer.py b/tutorius/overlayer.py index 592b8f0..4ee5241 100644 --- a/tutorius/overlayer.py +++ b/tutorius/overlayer.py @@ -157,14 +157,14 @@ class TextBubble(gtk.Widget): A CanvasDrawableWidget drawing a round textbox and a tail pointing to a specified widget. """ - def __init__(self, text, speaker=None, tailpos=[0,0], tailpos2=[0,0]): + def __init__(self, text, speaker=None, tailpos=[[0,0],[0,0],[0,0]]):#list with N éléments (cf bublemessage.py) """ Creates a new cairo rendered text bubble. @param text the text to render in the bubble @param speaker the widget to compute the tail position from - @param tailpos (optional) position relative to the bubble to use as - the tail position, if no speaker + @param tailpos (optional) list of positions relative to the bubble to use as + tails position, if no speaker """ gtk.Widget.__init__(self) @@ -175,8 +175,7 @@ class TextBubble(gtk.Widget): self.label = text self.speaker = speaker - self.tailpos = tailpos - self.tailpos2= tailpos2 + self.tailpos = tailpos self.line_width = 5 self.padding = 20 @@ -199,23 +198,16 @@ class TextBubble(gtk.Widget): # # TODO fetch speaker coordinates - # draw bubble tail if present - if self.tailpos != [0,0]: - context.move_to(xradius-width/4, yradius) - context.line_to(self.tailpos[0], self.tailpos[1]) - context.line_to(xradius+width/4, yradius) - context.set_line_width(self.line_width) - context.set_source_rgb(*xo_line_color) - context.stroke_preserve() - - # draw bubble tail2 if present - if self.tailpos2 != [0,0]: - context.move_to(xradius-width/4, yradius) - context.line_to(self.tailpos2[0], self.tailpos2[1]) - context.line_to(xradius+width/4, yradius) - context.set_line_width(self.line_width) - context.set_source_rgb(*xo_line_color) - context.stroke_preserve() + + # draw bubble tails if present + for i in range(len(self.tailpos)): + if self.tailpos[i] != [0,0]: + context.move_to(xradius-width/4, yradius) + context.line_to(self.tailpos[i][0], self.tailpos[i][1]) + context.line_to(xradius+width/4, yradius) + context.set_line_width(self.line_width) + context.set_source_rgb(*xo_line_color) + context.stroke_preserve() # bubble border context.move_to(width-self.padding, 0.0) @@ -237,23 +229,16 @@ class TextBubble(gtk.Widget): context.set_source_rgb(*xo_fill_color) context.fill() - # bubble painting. Redrawing the inside after the tail will combine - if self.tailpos != [0,0]: - context.move_to(xradius-width/4, yradius) - context.line_to(self.tailpos[0], self.tailpos[1]) - context.line_to(xradius+width/4, yradius) - context.set_line_width(self.line_width) - context.set_source_rgb(*xo_fill_color) - context.fill() - - # bubble painting. Redrawing the inside after the tail will combine - if self.tailpos2 != [0,0]: - context.move_to(xradius-width/4, yradius) - context.line_to(self.tailpos2[0], self.tailpos2[1]) - context.line_to(xradius+width/4, yradius) - context.set_line_width(self.line_width) - context.set_source_rgb(*xo_fill_color) - context.fill() + + # bubble painting. Redrawing the inside after tails will combine + for i in range(len(self.tailpos)): + if self.tailpos[i] != [0,0]: + context.move_to(xradius-width/4, yradius) + context.line_to(self.tailpos[i][0], self.tailpos[i][1]) + context.line_to(xradius+width/4, yradius) + context.set_line_width(self.line_width) + context.set_source_rgb(*xo_fill_color) + context.fill() context.set_source_rgb(1.0, 1.0, 1.0) pangoctx = pangocairo.CairoContext(context) |