redrawing when removing/adding from/to the selection
authorClaus Gittinger <cg@exept.de>
Tue, 01 Oct 1996 13:42:06 +0200
changeset 839 53a5344288e6
parent 838 d79133b1b409
child 840 b0071cea13fd
redrawing when removing/adding from/to the selection
ObjView.st
ObjectView.st
--- a/ObjView.st	Tue Oct 01 13:41:15 1996 +0200
+++ b/ObjView.st	Tue Oct 01 13:42:06 1996 +0200
@@ -2435,20 +2435,23 @@
 !ObjectView methodsFor:'selections'!
 
 addToSelection:anObject
-    "add anObject to the selection"
-
-    self hideSelection.
+    "add anObject to the selection; redraw it selected"
 
     selection isCollection ifFalse:[
         selection := OrderedCollection with:selection
     ].
+
     (selection includes:anObject) ifFalse:[
-        selection add:anObject.
-"/        self showSelected:anObject
+        (self frameIncludesSelectionHandlesOn:anObject) ifFalse:[
+            self hideSelection.
+            selection add:anObject.
+            self showSelection
+        ] ifTrue:[
+            self showSelected:anObject
+        ]
     ].
-    self showSelection
-
-    "Modified: 30.5.1996 / 18:44:06 / cg"
+
+    "Modified: 1.10.1996 / 12:12:59 / cg"
 !
 
 hideSelection
@@ -2462,10 +2465,16 @@
 removeFromSelection:anObject
     "remove anObject from the selection"
 
-    |wasSelected|
-
+    |wasSelected didHide|
+
+    didHide := false.
     wasSelected := true.
-    self hideSelection.
+
+    (self frameIncludesSelectionHandlesOn:anObject) ifFalse:[
+        "/ must hide any selection-handles first
+        self hideSelection.
+        didHide := true.
+    ].
 
     selection isCollection ifTrue:[
         (selection remove:anObject ifAbsent:[nil]) isNil ifTrue:[
@@ -2481,12 +2490,16 @@
             wasSelected := false
         ]
     ].
-    wasSelected ifTrue:[
-"/        self showUnselected:anObject
-    ].
-    self showSelection.
-
-    "Modified: 30.5.1996 / 18:44:25 / cg"
+
+    didHide ifTrue:[
+        self showSelection.
+    ] ifFalse:[
+        wasSelected ifTrue:[
+            self showUnselected:anObject
+        ].
+    ]
+
+    "Modified: 1.10.1996 / 12:10:17 / cg"
 !
 
 select:something
@@ -2634,6 +2647,17 @@
     ^ self findObjectAt:aPoint suchThat:aBlock
 !
 
+frameIncludesSelectionHandlesOn:anObject
+    "return true, if anObjects frame includes any selection
+     handles, false if not or if we do not know.
+     This can be used to optimize the redraw, in removeObjectFromSelection.
+     Subclasses which know how selections are highlighted may redefine this."
+
+    ^ false     "/ i.e. dont know.
+
+    "Created: 1.10.1996 / 12:06:51 / cg"
+!
+
 frameOf:anObjectOrCollection
     "answer the maximum extent defined by the argument, anObject or a
      collection of objects"
@@ -2882,5 +2906,5 @@
 !ObjectView  class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/Attic/ObjView.st,v 1.50 1996-08-01 17:14:04 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/Attic/ObjView.st,v 1.51 1996-10-01 11:42:06 cg Exp $'
 ! !
--- a/ObjectView.st	Tue Oct 01 13:41:15 1996 +0200
+++ b/ObjectView.st	Tue Oct 01 13:42:06 1996 +0200
@@ -2435,20 +2435,23 @@
 !ObjectView methodsFor:'selections'!
 
 addToSelection:anObject
-    "add anObject to the selection"
-
-    self hideSelection.
+    "add anObject to the selection; redraw it selected"
 
     selection isCollection ifFalse:[
         selection := OrderedCollection with:selection
     ].
+
     (selection includes:anObject) ifFalse:[
-        selection add:anObject.
-"/        self showSelected:anObject
+        (self frameIncludesSelectionHandlesOn:anObject) ifFalse:[
+            self hideSelection.
+            selection add:anObject.
+            self showSelection
+        ] ifTrue:[
+            self showSelected:anObject
+        ]
     ].
-    self showSelection
-
-    "Modified: 30.5.1996 / 18:44:06 / cg"
+
+    "Modified: 1.10.1996 / 12:12:59 / cg"
 !
 
 hideSelection
@@ -2462,10 +2465,16 @@
 removeFromSelection:anObject
     "remove anObject from the selection"
 
-    |wasSelected|
-
+    |wasSelected didHide|
+
+    didHide := false.
     wasSelected := true.
-    self hideSelection.
+
+    (self frameIncludesSelectionHandlesOn:anObject) ifFalse:[
+        "/ must hide any selection-handles first
+        self hideSelection.
+        didHide := true.
+    ].
 
     selection isCollection ifTrue:[
         (selection remove:anObject ifAbsent:[nil]) isNil ifTrue:[
@@ -2481,12 +2490,16 @@
             wasSelected := false
         ]
     ].
-    wasSelected ifTrue:[
-"/        self showUnselected:anObject
-    ].
-    self showSelection.
-
-    "Modified: 30.5.1996 / 18:44:25 / cg"
+
+    didHide ifTrue:[
+        self showSelection.
+    ] ifFalse:[
+        wasSelected ifTrue:[
+            self showUnselected:anObject
+        ].
+    ]
+
+    "Modified: 1.10.1996 / 12:10:17 / cg"
 !
 
 select:something
@@ -2634,6 +2647,17 @@
     ^ self findObjectAt:aPoint suchThat:aBlock
 !
 
+frameIncludesSelectionHandlesOn:anObject
+    "return true, if anObjects frame includes any selection
+     handles, false if not or if we do not know.
+     This can be used to optimize the redraw, in removeObjectFromSelection.
+     Subclasses which know how selections are highlighted may redefine this."
+
+    ^ false     "/ i.e. dont know.
+
+    "Created: 1.10.1996 / 12:06:51 / cg"
+!
+
 frameOf:anObjectOrCollection
     "answer the maximum extent defined by the argument, anObject or a
      collection of objects"
@@ -2882,5 +2906,5 @@
 !ObjectView  class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libwidg/ObjectView.st,v 1.50 1996-08-01 17:14:04 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libwidg/ObjectView.st,v 1.51 1996-10-01 11:42:06 cg Exp $'
 ! !