graphics/GraphicCommons.py
changeset 110 29b6b70e1721
parent 108 9aa1fdfb7cb2
child 112 317148fc1225
--- a/graphics/GraphicCommons.py	Fri Oct 19 10:15:23 2007 +0200
+++ b/graphics/GraphicCommons.py	Fri Oct 19 17:08:08 2007 +0200
@@ -451,8 +451,11 @@
                 self.Dragging = True
             # If a dragging have been initiated, refreshes the element state
             if self.Dragging:
-                self.oldPos = pos
-                self.ProcessDragging(movex, movey)
+                dragx, dragy = self.ProcessDragging(movex, movey)
+                if dragx:
+                    self.oldPos.x = pos.x
+                if dragy:
+                    self.oldPos.y = pos.y
             return True
         # If cursor just pass over the element, changes the cursor if it is on a handle
         else:
@@ -483,8 +486,8 @@
         handle_type, handle = self.Handle
         # If it is a resize handle, calculate the values from resizing
         if handle_type == HANDLE_RESIZE:
-            x, y = 0, 0
-            width, height = self.GetSize()
+            x = y = start_x = start_y = 0
+            width, height = start_width, start_height = self.GetSize()
             if handle[0] == 1:
                 x = movex
                 width -= movex
@@ -497,11 +500,23 @@
                 height += movey
             # Verify that new size is not lesser than minimum
             min_width, min_height = self.GetMinSize()
-            if width >= min_width and height >= min_height or width >= self.Size[0] and height >= self.Size[1]:
-                self.Resize(x, y, width, height)
+            dragx = dragy = False
+            if handle[0] != 2 and (width >= min_width or width > self.Size[0]):
+                start_x = x
+                start_width = width
+                dragx = True
+            if handle[1] != 2 and (height >= min_height or height > self.Size[1]):
+                start_y = y
+                start_height = height
+                dragy = True
+            if dragx or dragy:
+                self.Resize(start_x, start_y, start_width, start_height)
+            return dragx, dragy
         # If it is a move handle, Move this element
         elif handle_type == HANDLE_MOVE:
             self.Move(movex, movey)
+            return True, True
+        return False, False
     
     # Override this method for defining the method to call for refreshing the model of this element
     def RefreshModel(self, move=True):
@@ -1691,12 +1706,14 @@
                 if self.EndConnected:
                     self.UnConnectEndPoint()
                 self.MoveEndPoint(new_pos)
+            return True, True
         # A segment has been handled, move a segment
         elif handle_type == HANDLE_SEGMENT:
             self.MoveSegment(handle[0], movex, movey)
+            return True, True
         # Execute the default method for a graphic element
         else:
-            Graphic_Element.ProcessDragging(self, movex, movey)
+            return Graphic_Element.ProcessDragging(self, movex, movey)
     
     # Refreshes the wire model
     def RefreshModel(self, move=True):