#UI_ENHANCEMENT by exept
authorClaus Gittinger <cg@exept.de>
Sun, 01 Sep 2019 10:03:38 +0200
changeset 6131 41f5521f5b0a
parent 6130 8b28d3706b4b
child 6132 a15871e06ccd
#UI_ENHANCEMENT by exept class: MenuPanel less flicker if multiple enable/disable events come fast for the same item (expecco's testRun page) added: #delayedInvalidateItem:repairNow: comment/format in: #redrawX:y:width:height: changed: #invalidateItem:repairNow:
MenuPanel.st
--- a/MenuPanel.st	Sat Aug 31 16:32:30 2019 +0200
+++ b/MenuPanel.st	Sun Sep 01 10:03:38 2019 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
 "
  COPYRIGHT (c) 1997 by eXept Software AG
               All Rights Reserved
@@ -2769,6 +2771,22 @@
 
 !MenuPanel methodsFor:'drawing'!
 
+delayedInvalidateItem:anItem repairNow:aBool
+    "an item changed; invalidate the item's layout"
+
+    |itemsFrame|
+
+    (mustRearrange not and:[shown]) ifTrue:[
+        itemsFrame := anItem layout.
+
+        (itemsFrame bottom > margin and:[itemsFrame top < (height - margin)]) ifTrue:[
+            self invalidate:(itemsFrame "insetBy:-1") repairNow:aBool
+        ]
+    ].
+
+    "Modified: / 29.2.2000 / 11:28:59 / cg"
+!
+
 disabledRedrawDo:aBlock
     "evaluate a block without redrawing within the block; after processing
      of the block a redraw might be performed"
@@ -2999,16 +3017,18 @@
 !
 
 invalidateItem:anItem repairNow:aBool
-    "an item changed; invalidate the items layout"
-
-    |layout|
-
-    (mustRearrange not and:[shown]) ifTrue:[
-        layout := anItem layout.
-
-        (layout bottom > margin and:[layout top < (height - margin)]) ifTrue:[
-            self invalidate:(layout "insetBy:-1") repairNow:aBool
-        ]
+    "an item changed; invalidate the item's layout"
+
+    "/ enqueue delayed to avoid flicker in case the item's state changes again
+    "/ (multiple enable/disable events with icon change as consequence coming fast,
+    "/  which happens eg. in expecco's testRun page)
+
+    aBool ifTrue:[
+        self delayedInvalidateItem:anItem repairNow:aBool.
+    ] ifFalse:[
+        self sensor
+            enqueueMessage:#delayedInvalidateItem:repairNow: 
+            for:self arguments:{anItem . aBool }
     ].
 
     "Modified: / 29.2.2000 / 11:28:59 / cg"
@@ -5262,7 +5282,7 @@
      we have non translated sub menus (when using them later for viewing).
      Problem expecco Menu 'View' was somethimes untranslated and somethimes not.
      Dependent if this code was called before the user did open (instantiate) the menu via the application.
-     May also the shortcuts itself could vary when translated 'Open &File' -> 'Datei &öffnen' ????"
+     May also the shortcuts itself could vary when translated 'Open &File' -> 'Datei &öffnen' ????"
     Menu::NeedResourcesQuery answer:true do:[
 "/    Menu::NeedResourcesQuery answer:false do:[
         [true] whileTrue:[