Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSimon Poirier <simpoir@gmail.com>2009-12-08 04:04:21 (GMT)
committer Simon Poirier <simpoir@gmail.com>2009-12-08 04:04:21 (GMT)
commit64836f57dd3ab59f03ee7c5e375caff4019791f0 (patch)
tree59d2affa3d56a2d94e9b023da401e37a1cc8b97f
parent034e36d4983da0c2d44c56d4efd9af922b2cab4e (diff)
esthetic fixes on drag.
Signed-off-by: Simon Poirier <simpoir@gmail.com>
-rw-r--r--tutorius/actions.py46
-rw-r--r--tutorius/creator.py4
-rw-r--r--tutorius/overlayer.py9
3 files changed, 43 insertions, 16 deletions
diff --git a/tutorius/actions.py b/tutorius/actions.py
index fe64c95..f6f3338 100644
--- a/tutorius/actions.py
+++ b/tutorius/actions.py
@@ -17,6 +17,7 @@
This module defines Actions that can be done and undone on a state
"""
import gtk
+import cairo
import logging
from gettext import gettext as _
@@ -70,22 +71,35 @@ class DragWrapper(object):
y = self._widget.allocation.y
depth = 24 # Should be set dynamically
- pxbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8, width, height)
- pxbuf.fill(0xFFFFFFFF)
-
- px = gtk.gdk.Pixmap(None, width, height, depth) # source, size, colors
- px.set_colormap(gtk.gdk.colormap_get_system())
- ctxt = px.cairo_create()
- ctxt.set_source_pixbuf(pxbuf,0,0)
- ctxt.paint()
-
- # Compensate when drawing the icon for the context
- # translation done to the position occupied by the widget
- ctxt.translate(-x, -y)
- self._widget.draw_with_context(ctxt)
-
- pxbuf.get_from_drawable(px,gtk.gdk.colormap_get_system(), 0, 0, 0, 0, -1, -1)
- drag_context.set_icon_pixbuf(pxbuf,0,0)
+ if hasattr(self._widget, 'draw_with_context'):
+ px = gtk.gdk.Pixmap(None, width, height, depth) # source, size, colors
+ ctxt = px.cairo_create()
+ # Compensate when drawing the icon for the context
+ # translation done to the position occupied by the widget
+ ctxt.translate(-x, -y)
+ self._widget.draw_with_context(ctxt)
+
+ # Do the same for the icon shape mask
+ mask = gtk.gdk.Pixmap(None, width, height, 1)
+ ctxt = mask.cairo_create()
+ ctxt.set_operator(cairo.OPERATOR_CLEAR)
+ ctxt.paint()
+ ctxt.set_operator(cairo.OPERATOR_SOURCE)
+ ctxt.translate(-x, -y)
+ self._widget.draw_with_context(ctxt)
+
+ drag_context.set_icon_pixmap(gtk.gdk.colormap_get_system(),
+ px, mask, 0, 0)
+ else:
+ pxbuf = gtk.gdk.Pixbuf(gtk.gdk.COLORSPACE_RGB, True, 8,
+ width, height)
+ pxbuf.get_from_drawable(self._widget.window,
+ gtk.gdk.colormap_get_system(),
+ src_x=0, src_y=0, # has it's own window
+ dest_x=0, dest_y=0,
+ width=width, height=height)
+ drag_context.set_icon_pixbuf(pxbuf, 0, 0)
+
def _drag_fail(self, *args):
"""
diff --git a/tutorius/creator.py b/tutorius/creator.py
index 2de21ac..9b1b9bf 100644
--- a/tutorius/creator.py
+++ b/tutorius/creator.py
@@ -224,6 +224,10 @@ class Creator(Object):
@param state_name: the name of the state to use as insertion point
"""
+ # Check if already in state to avoid reinstalling actions needlessly
+ if self._state == state_name:
+ return
+
# first is not modifiable, as the auto transition would make changes
# pointless. The end state is also pointless to modify, as the tutorial
# gets detached.
diff --git a/tutorius/overlayer.py b/tutorius/overlayer.py
index 96e9acf..5eb0f49 100644
--- a/tutorius/overlayer.py
+++ b/tutorius/overlayer.py
@@ -256,6 +256,13 @@ class TextBubble(gtk.Widget):
yradius = height/2
width -= self.line_width
height -= self.line_width
+
+ # translate by line width to because line is drawn both side of the
+ # coordinates. here what a line stroke looks like:
+ # / """""""""" }out of shape
+ # width | ---------- <-exact coord
+ # \ .......... }in shape
+ context.translate(self.line_width/2, self.line_width/2)
#
# TODO fetch speaker coordinates
@@ -428,6 +435,8 @@ class TextBubbleWImg(gtk.Widget):
yradius = height/2
width -= self.line_width
height -= self.line_width
+
+ context.translate(self.line_width/2, self.line_width/2)
#
# TODO fetch speaker coordinates