[PATCH] hide brush when mouse leave area
James Cameron
quozl at laptop.org
Thu Jun 3 02:59:10 EDT 2010
Adds an enter and leave event handler for the drawing area, in order
to draw or not draw the outline cursor.
Tested-by: James Cameron <quozl at laptop.org>
---
Area.py | 20 +++++++++++++++++---
1 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/Area.py b/Area.py
index 570d093..a7f0bd0 100644
--- a/Area.py
+++ b/Area.py
@@ -97,11 +97,15 @@ class Area(gtk.DrawingArea):
gtk.gdk.BUTTON_PRESS_MASK |
gtk.gdk.BUTTON_RELEASE_MASK|
gtk.gdk.EXPOSURE_MASK |
- gtk.gdk.KEY_PRESS_MASK)
-
+ gtk.gdk.LEAVE_NOTIFY_MASK |
+ gtk.gdk.ENTER_NOTIFY_MASK |
+ gtk.gdk.KEY_PRESS_MASK)
+
self.connect("expose_event",self.expose)
self.connect("motion_notify_event", self.mousemove)
self.connect("button_press_event", self.mousedown)
+ self.connect("leave_notify_event", self.mouseleave)
+ self.connect("enter_notify_event", self.mouseenter)
self.connect("button_release_event", self.mouseup)
self.connect("key_press_event", self.key_press)
@@ -353,8 +357,18 @@ class Area(gtk.DrawingArea):
self.desenha = True
widget.queue_draw()
+ def mouseleave(self, widget, event):
+ if self.tool['name'] in ['pencil','eraser','brush','rainbow']:
+ self.drawing = True
+ size = self.tool['line size']
+ widget.queue_draw_area(self.x_cursor-size, self.y_cursor-size, size*2, size*2)
+
+ def mouseenter(self, widget, event):
+ if self.tool['name'] in ['pencil','eraser','brush','rainbow']:
+ self.drawing = False
+ size = self.tool['line size']
+ widget.queue_draw_area(self.x_cursor-size, self.y_cursor-size, size*2, size*2)
-
def mousemove(self,widget,event):
"""Make the Area object (GtkDrawingArea) recognize that the mouse is moving.
--
1.7.1
--
James Cameron
http://quozl.linux.org.au/
More information about the Sugar-devel
mailing list