Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/thoughtview.py
diff options
context:
space:
mode:
authorTomeu Vizoso <tomeu@sugarlabs.org>2009-01-24 16:51:28 (GMT)
committer Tomeu Vizoso <tomeu@sugarlabs.org>2009-01-24 16:51:28 (GMT)
commit7fc1f05973a16f9852d6c25d4f2484384747e00a (patch)
tree330f2a03200174828abf6a5a2f2283f87555d86a /thoughtview.py
parent9ee11dda200e1ae317d7ec9b919692f41fd39c52 (diff)
Add a '+' button to the thought view for adding a child thought
Diffstat (limited to 'thoughtview.py')
-rw-r--r--thoughtview.py24
1 files changed, 24 insertions, 0 deletions
diff --git a/thoughtview.py b/thoughtview.py
index 5d02365..cd79682 100644
--- a/thoughtview.py
+++ b/thoughtview.py
@@ -45,6 +45,7 @@ class ThoughtView(CanvasElement):
self._last_height = -1
self._dragging = False
self._selected = False
+ self._add_control_rect = gtk.gdk.Rectangle(0, 0, 0, 0)
def set_dragging(self, dragging):
if self._dragging != dragging:
@@ -84,6 +85,9 @@ class ThoughtView(CanvasElement):
width, height = self._draw_text(context)
self._draw_bounding_box(context, width, height)
+ if self.hovering:
+ self._draw_controls(context, width, height)
+
self._last_width = width
self._last_height = height
@@ -139,6 +143,26 @@ class ThoughtView(CanvasElement):
context.stroke()
context.restore()
+ def _draw_controls(self, context, width, height):
+ context.save()
+
+ context.set_source_rgb(0.0, 0.0, 0.0)
+
+ layout = context.create_layout()
+ layout.set_text('+')
+
+ label_width, label_height = layout.get_pixel_size()
+
+ x = self.x + width - label_width
+ y = self.y
+ context.translate(x, y)
+ context.show_layout(layout)
+
+ context.restore()
+
+ self._add_control_rect = gtk.gdk.Rectangle(x, y, label_width,
+ label_height)
+
def get_rect(self):
if -1 in (self._last_width, self._last_height):
layout = self._get_name_layout()