From 335833bba32a4643e95bd31337637f5e2a075cee Mon Sep 17 00:00:00 2001 From: isen Date: Wed, 23 Sep 2009 20:19:41 +0000 Subject: first changes but not working --- diff --git a/addons/bubblemessage.py b/addons/bubblemessage.py index a859ef8..2ff3454 100644 --- a/addons/bubblemessage.py +++ b/addons/bubblemessage.py @@ -21,8 +21,9 @@ class BubbleMessage(Action): position = TArrayProperty([0,0], 2, 2) # Do the same for the tail position tail_pos = TArrayProperty([0,0], 2, 2) + tail_pos2 = TArrayProperty([0,0],2, 2) - def __init__(self, message=None, pos=None, speaker=None, tailpos=None): + def __init__(self, message=None, pos=None, speaker=None, tailpos=None, tailpos2=None): """ Shows a dialog with a given text, at the given position on the screen. @@ -38,6 +39,8 @@ class BubbleMessage(Action): self.position = pos if tailpos: self.tail_pos = tailpos + if tailpos2: + self.tail_pos2 = tailpos2 if message: self.message = message @@ -63,7 +66,7 @@ class BubbleMessage(Action): # TODO: tails are relative to tailpos. They should be relative to # the speaking widget. Same of the bubble position. self._bubble = overlayer.TextBubble(text=self.message, - tailpos=self.tail_pos) + tailpos=self.tail_pos, tailpos2=self.tail_pos2) self._bubble.show() self.overlay.put(self._bubble, x, y) self.overlay.queue_draw() @@ -86,7 +89,7 @@ class BubbleMessage(Action): assert not self._drag, "bubble action set to editmode twice" x, y = self.position self._bubble = overlayer.TextBubble(text=self.message, - tailpos=self.tail_pos) + tailpos=self.tail_pos, tailpos2=self.tail_pos2) self.overlay.put(self._bubble, x, y) self._bubble.show() diff --git a/setup.cfg b/setup.cfg index e33c680..98b22b6 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,8 +1,9 @@ [install] # enter absolute path path -prefix=/home/simpoir/Source/sugar-jhbuild/install/ +prefix=/home/isen/tutorius/install force=1 [test] # same as above -prefix=/home/simpoir/Source/sugar-jhbuild/install/ +prefix=/home/isen/tutorius/install +force=1 diff --git a/tests/actiontests.py b/tests/actiontests.py index 4e126b3..265ffa1 100644 --- a/tests/actiontests.py +++ b/tests/actiontests.py @@ -65,7 +65,7 @@ class DialogMessageTest(unittest.TestCase): class BubbleMessageTest(unittest.TestCase): def setUp(self): - self.bubble = addon.create('BubbleMessage', message="Message text", pos=[200, 300], tailpos=[-15, -25]) + self.bubble = addon.create('BubbleMessage', message="Message text", pos=[200, 300], tailpos=[-15, -25], tailpos2=[-15, -25]) def test_properties(self): props = self.bubble.get_properties() @@ -76,6 +76,8 @@ class BubbleMessageTest(unittest.TestCase): assert "tail_pos" in props, 'No tail position property in BubbleMessage' + assert "tail_pos2" in props, 'No tail position property in BubbleMessage' + class CountAction(Action): """ diff --git a/tests/serializertests.py b/tests/serializertests.py index 6c25bae..320feaf 100644 --- a/tests/serializertests.py +++ b/tests/serializertests.py @@ -76,7 +76,7 @@ class XMLSerializerTest(unittest.TestCase): # Add a few states act1 = addon.create('BubbleMessage', message="Hi", pos=[300, 450]) ev1 = addon.create('GtkWidgetEventFilter', "0.12.31.2.2", "clicked", "Second") - act2 = addon.create('BubbleMessage', message="Second message", pos=[250, 150], tailpos=[1,2]) + act2 = addon.create('BubbleMessage', message="Second message", pos=[250, 150], tailpos=[1,2], tailpos2=[1,2]) st1 = State("INIT") st1.add_action(act1) @@ -143,7 +143,7 @@ class XMLSerializerTest(unittest.TestCase): """ st = State("INIT") - act1 = addon.create('BubbleMessage', "Hi!", pos=[10,120], tailpos=[-12,30]) + act1 = addon.create('BubbleMessage', "Hi!", pos=[10,120], tailpos=[-12,30], tailpos2=[-12,30]) act2 = addon.create('DialogMessage', "Hello again.", pos=[120,10]) act3 = WidgetIdentifyAction() act4 = DisableWidgetAction("0.0.0.1.0.0.0") diff --git a/tutorius/overlayer.py b/tutorius/overlayer.py index 931949d..592b8f0 100644 --- a/tutorius/overlayer.py +++ b/tutorius/overlayer.py @@ -157,7 +157,7 @@ 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]): + def __init__(self, text, speaker=None, tailpos=[0,0], tailpos2=[0,0]): """ Creates a new cairo rendered text bubble. @@ -176,6 +176,7 @@ class TextBubble(gtk.Widget): self.label = text self.speaker = speaker self.tailpos = tailpos + self.tailpos2= tailpos2 self.line_width = 5 self.padding = 20 @@ -206,6 +207,15 @@ class TextBubble(gtk.Widget): 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() # bubble border context.move_to(width-self.padding, 0.0) @@ -235,6 +245,15 @@ class TextBubble(gtk.Widget): 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() context.set_source_rgb(1.0, 1.0, 1.0) pangoctx = pangocairo.CairoContext(context) -- cgit v0.9.1