gcompris r3452 - in branches/gcomprixogoo/src: anim-activity gcompris



Author: bcoudoin
Date: Wed May 21 21:49:04 2008
New Revision: 3452
URL: http://svn.gnome.org/viewvc/gcompris?rev=3452&view=rev

Log:
improved the management of the drawing area. More precisely, 
the move and resize no more let you draw outside the drawinf area.


Modified:
   branches/gcomprixogoo/src/anim-activity/AnimItem.py
   branches/gcomprixogoo/src/gcompris/gcompris_im.h

Modified: branches/gcomprixogoo/src/anim-activity/AnimItem.py
==============================================================================
--- branches/gcomprixogoo/src/anim-activity/AnimItem.py	(original)
+++ branches/gcomprixogoo/src/anim-activity/AnimItem.py	Wed May 21 21:49:04 2008
@@ -48,6 +48,10 @@
     # Given x,y return a new x,y snapped to the grid
     def snap_to_grid(self, x, y):
 
+        if self.item:
+            (x, y) = self.anim.gcomprisBoard.canvas.\
+                convert_from_item_space(self.item, x, y)
+
         # Check drawing boundaries
         if(x < self.drawing_area[0]):
           x = self.drawing_area[0]
@@ -66,6 +70,11 @@
         tmp = round(((y+(self.step)) -
                      self.drawing_area[1])/self.step) - 1
         result.append(float(self.drawing_area[1] + tmp*self.step))
+
+        if self.item:
+            return self.anim.gcomprisBoard.canvas.\
+                convert_to_item_space(self.item, x, y)
+
         return result
 
     # Given two points p1 and p2, return the
@@ -177,6 +186,17 @@
             dx = event.x - self.old_x
             dy = event.y - self.old_y
 
+            bounds = self.item.get_bounds()
+            # Check drawing boundaries
+            if(bounds.x1 + dx < self.drawing_area[0]):
+                dx = self.drawing_area[0] - bounds.x1
+            if(bounds.x2 + dx > self.drawing_area[2]):
+                dx = self.drawing_area[2] - bounds.x2
+            if(bounds.y1 + dy < self.drawing_area[1]):
+                dy = self.drawing_area[1]- bounds.y1
+            if(bounds.y2 + dy > self.drawing_area[3]):
+                dy = self.drawing_area[3]- bounds.y2
+
             self.item.translate(dx, dy)
 
             if self.anchor:

Modified: branches/gcomprixogoo/src/gcompris/gcompris_im.h
==============================================================================
--- branches/gcomprixogoo/src/gcompris/gcompris_im.h	(original)
+++ branches/gcomprixogoo/src/gcompris/gcompris_im.h	Wed May 21 21:49:04 2008
@@ -23,7 +23,7 @@
 #ifndef GCOMPRIS_IM_H
 #define GCOMPRIS_IM_H
 
-void gc_im_init();
+void gc_im_init(GtkWidget *window);
 void gc_im_reset();
 
 #endif



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]