Explorar o código

Merge branch 'master' of linode:hci1

Keep changes for now
Michael Pitidis %!s(int64=13) %!d(string=hai) anos
pai
achega
7cf604bd6a
Modificáronse 2 ficheiros con 17 adicións e 7 borrados
  1. 11 6
      canvas.py
  2. 6 1
      shape.py

+ 11 - 6
canvas.py

@@ -76,8 +76,8 @@ class Canvas(QWidget):
                 self.repaint()
             elif self.selectedShape:
                 self.selectedShapeCopy = self.selectedShape.copy()
-                self.selectedShapeCopy.line_color = QColor(255, 0, 0, 64)
-                self.selectedShapeCopy.fill_color = QColor(0, 255, 0, 64)
+               # self.selectedShapeCopy.line_color = QColor(255, 0, 0, 64)
+                #self.selectedShapeCopy.fill_color = QColor(0, 255, 0, 64)
                 self.repaint()
             return
 
@@ -117,9 +117,13 @@ class Canvas(QWidget):
                 self.setToolTip("Object '%s'" % shape.label)
                 self.highlightedShape = shape
                 self.overrideCursor(CURSOR_GRAB)
+                self.repaint()
+
                 break
         else:
             self.highlightedShape = None
+            self.repaint()
+
         if previous != self.highlightedShape:
             # Try to minimise repaints.
             self.repaint()
@@ -164,8 +168,8 @@ class Canvas(QWidget):
     def endMove(self, copy=False):
         assert self.selectedShape and self.selectedShapeCopy
         shape = self.selectedShapeCopy
-        del shape.fill_color
-        del shape.line_color
+        #del shape.fill_color
+        #del shape.line_color
         if copy:
             self.shapes.append(shape)
             self.selectedShape.selected = False
@@ -205,6 +209,7 @@ class Canvas(QWidget):
         for shape in reversed(self.shapes):
             if self.isVisible(shape) and shape.containsPoint(point):
                 shape.selected = True
+                
                 self.selectedShape = shape
                 self.calculateOffsets(shape, point)
                 self.setHiding()
@@ -238,7 +243,7 @@ class Canvas(QWidget):
         self.prevPoint = pos
 
     def deSelectShape(self):
-        if self.selectedShape:
+        if self.selectedShape: 
             self.selectedShape.selected = False
             self.selectedShape = None
             self.setHiding(False)
@@ -259,7 +264,7 @@ class Canvas(QWidget):
             self.shapes.append(shape)
             self.selectedShape = shape
             self.deSelectShape()
-            self.repaint()
+            #self.repaint()
             return shape
 
     def paintEvent(self, event):

+ 6 - 1
shape.py

@@ -21,6 +21,7 @@ class Shape(object):
     ## of _all_ shape objects.
     line_color = DEFAULT_LINE_COLOR
     fill_color = DEFAULT_FILL_COLOR
+    sel_fill_color=QColor(0, 128, 255, 155)
     select_color = DEFAULT_SELECT_COLOR
     point_type = P_SQUARE
     point_size = 8
@@ -69,7 +70,11 @@ class Shape(object):
             painter.drawPath(line_path)
             painter.fillPath(vrtx_path, self.line_color)
             if self.fill:
-                painter.fillPath(line_path, self.fill_color)
+                if self.selected:
+                    fillColor=self.sel_fill_color
+                else:
+                    fillColor=self.fill_color
+                painter.fillPath(line_path,fillColor)
 
     def drawVertex(self, path, point):
         d = self.point_size / self.scale