[PATCH] hide brush when mouse leave area

Gonzalo Odiard godiard at gmail.com
Wed Jun 2 19:01:10 EDT 2010


---
 Area.py |   15 ++++++++++++++-
 1 files changed, 14 insertions(+), 1 deletions(-)

diff --git a/Area.py b/Area.py
index 8a5e523..c83f38f 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.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,17 @@ 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
+            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
+            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.6.6.1


-- 
Gonzalo Odiard
Responsable de Desarrollo
Sistemas Australes

--000e0cdf193c24be7a0488141962
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable



More information about the Sugar-devel mailing list