lmi-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[lmi-commits] [lmi] master 3f8f9ae 4/4: Improve calculation-summary resp


From: Greg Chicares
Subject: [lmi-commits] [lmi] master 3f8f9ae 4/4: Improve calculation-summary responsiveness
Date: Wed, 21 Feb 2018 20:40:03 -0500 (EST)

branch: master
commit 3f8f9aec6d6f21fc2d4fe418f1a3f67609126ae8
Author: Gregory W. Chicares <address@hidden>
Commit: Gregory W. Chicares <address@hidden>

    Improve calculation-summary responsiveness
    
    Sorted child-list so that active child is updated first; added a call
    to Update() to synchronize the screen right away.
    
    Incidentally, pointer 'c' had to lose its constness so that Update()
    could be called through it.
---
 skeleton.cpp | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)

diff --git a/skeleton.cpp b/skeleton.cpp
index 169b1e7..dc0d610 100644
--- a/skeleton.cpp
+++ b/skeleton.cpp
@@ -101,6 +101,7 @@
 #include <wx/xrc/xmlres.h>
 
 #include <iterator>                     // insert_iterator
+#include <list>
 #include <sstream>
 #include <stdexcept>
 #include <string>
@@ -1357,18 +1358,36 @@ void 
Skeleton::OpenCommandLineFiles(std::vector<std::string> const& files)
         }
 }
 
+/// Update all MVC views potentially affected by a global change.
+///
+/// As of 2018-02, the only update trigger is editing the preferences
+/// dialog, which may change the calculation-summary column selection.
+///
+/// To improve responsiveness, update any active child first.
+
 void Skeleton::UpdateViews()
 {
     wxBusyCursor wait;
-    for(auto const& i : frame_->GetChildren())
+
+    // Assignment implicitly ensures that this is not a wx legacy
+    // container, and thus that std::list operations are valid.
+    std::list<wxWindow*> z = frame_->GetChildren();
+    wxMDIChildFrame*     a = frame_->GetActiveChild();
+    // Bring any active child to front so it's updated first.
+    // It doesn't matter here if it's null: that's filtered below.
+    z.remove(a);
+    z.push_front(a);
+
+    for(auto const& i : z)
         {
-        wxDocMDIChildFrame const* c = dynamic_cast<wxDocMDIChildFrame*>(i);
+        wxDocMDIChildFrame* c = dynamic_cast<wxDocMDIChildFrame*>(i);
         if(c)
             {
             IllustrationView* v = 
dynamic_cast<IllustrationView*>(c->GetView());
             if(v)
                 {
                 v->DisplaySelectedValuesAsHtml();
+                c->Update();
                 }
             }
         }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]