UI: avoid flickering when updating variable object list
authorJan Vrany <jan.vrany@fit.cvut.cz>
Tue, 06 Feb 2018 14:35:33 +0000
changeset 62 8a52495c2108
parent 61 a8b0e1d29ef7
child 63 b8c6b168d25f
UI: avoid flickering when updating variable object list
VDBAbstractApplication.st
VDBAbstractListApplication.st
VDBVariableObjectListApplication.st
VDBVariableObjectPresenter.st
--- a/VDBAbstractApplication.st	Mon Feb 05 21:46:29 2018 +0000
+++ b/VDBAbstractApplication.st	Tue Feb 06 14:35:33 2018 +0000
@@ -255,6 +255,12 @@
 
 !VDBAbstractApplication methodsFor:'menu actions'!
 
+doInspectApplication
+    self inspect
+
+    "Created: / 06-02-2018 / 12:54:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 doInspectDebugger
    debugger inspect
 
--- a/VDBAbstractListApplication.st	Mon Feb 05 21:46:29 2018 +0000
+++ b/VDBAbstractListApplication.st	Tue Feb 06 14:35:33 2018 +0000
@@ -145,17 +145,26 @@
             enabled: hasSelection
             label: 'Inspect Model'
             itemValue: doInspectModel
+            isVisible: true
           )
          (MenuItem
             label: 'Inspect Presenter'
             itemValue: doInspectPresenter
+            isVisible: true
+          )
+         (MenuItem
+            label: 'Inspect Application'
+            itemValue: doInspectApplication
+            isVisible: true
           )
          (MenuItem
             label: '-'
+            isVisible: true
           )
          (MenuItem
             label: 'Update'
             itemValue: duUpdateList
+            isVisible: true
           )
          )
         nil
@@ -251,10 +260,10 @@
 
 enqueueDelayedInvalidateInternalList
     internalListView notNil ifTrue:[
-        internalListView scrolledView invalidate
+        self enqueueDelayedUpdate: #delayedInvalidateInternalList
     ]
 
-    "Created: / 01-02-2018 / 23:11:06 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Created: / 06-02-2018 / 12:43:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 !
 
 enqueueDelayedUpdateInternalList
@@ -285,6 +294,14 @@
 
 !VDBAbstractListApplication methodsFor:'change & update-delayed'!
 
+delayedInvalidateInternalList
+    internalListView notNil ifTrue:[ 
+        internalListView scrolledView invalidate.
+    ].
+
+    "Created: / 06-02-2018 / 12:43:48 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 delayedUpdateInternalList
     "raise an error: must be redefined in concrete subclass(es)"
 
@@ -388,3 +405,10 @@
     "Modified: / 22-09-2014 / 01:13:39 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!VDBAbstractListApplication class methodsFor:'documentation'!
+
+version_HG
+
+    ^ '$Changeset: <not expanded> $'
+! !
+
--- a/VDBVariableObjectListApplication.st	Mon Feb 05 21:46:29 2018 +0000
+++ b/VDBVariableObjectListApplication.st	Tue Feb 06 14:35:33 2018 +0000
@@ -203,6 +203,37 @@
 
 !VDBVariableObjectListApplication methodsFor:'change & update-delayed'!
 
+delayedInvalidateInternalList
+
+    "/ Updating children may take a while as it needs to issue
+    "/ several commands to the GDB and wait for results. To avoid
+    "/ flickering, we first force an update of all values
+    "/ in background and then force an invalidate.
+    "/ 
+    "/ Note, that update of each individual variable is pushed back 
+    "/ to event queue, allowing the UI to react for user events that 
+    "/ may have come meanwhile.
+
+    | children changed |
+
+    children := internalListHolder root children.
+    changed := false.
+    children do:[:each | 
+        self enqueueDelayedAction: [ 
+            "/ Update the child, but only if the list of currently displayed
+            "/ children remains the same. Keep in mind that user may have
+            "/ have switched to another frame before we're finished with the update.
+            internalListHolder root children == children ifTrue: [ changed := each varobj hasChanged or:[changed] ] 
+        ].
+    ].
+    self enqueueDelayedAction:[ 
+        (internalListHolder root children == children and:[changed]) ifTrue:[ super delayedInvalidateInternalList ].
+    ]
+
+    "Created: / 06-02-2018 / 12:52:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+    "Modified: / 21-03-2018 / 09:42:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 delayedUpdateInternalList
     | root |
 
--- a/VDBVariableObjectPresenter.st	Mon Feb 05 21:46:29 2018 +0000
+++ b/VDBVariableObjectPresenter.st	Tue Feb 06 14:35:33 2018 +0000
@@ -41,8 +41,8 @@
 
 
     "
-     MenuEditor new openOnClass:VDBVariablePresenter andSelector:#contextMenu
-     (Menu new fromLiteralArrayEncoding:(VDBVariablePresenter contextMenu)) startUp
+     MenuEditor new openOnClass:VDBVariableObjectPresenter andSelector:#contextMenu
+     (Menu new fromLiteralArrayEncoding:(VDBVariableObjectPresenter contextMenu)) startUp
     "
 
     <resource: #menu>
@@ -53,6 +53,12 @@
          (MenuItem
             label: 'Copy Value'
             itemValue: doCopyValue
+            isVisible: true
+          )
+         (MenuItem
+            label: 'Copy Expression'
+            itemValue: doCopyPath
+            isVisible: true
           )
          )
         nil
@@ -108,6 +114,12 @@
 
 !VDBVariableObjectPresenter methodsFor:'menu actions'!
 
+doCopyPath
+    self doCopy: varobj path.
+
+    "Created: / 05-02-2018 / 22:32:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
 doCopyValue
     self doCopy: varobj value.