add RAII DisplaySuspender
authorRobin Gareus <robin@gareus.org>
Sat, 28 Jun 2014 21:22:15 +0000 (23:22 +0200)
committerRobin Gareus <robin@gareus.org>
Sat, 28 Jun 2014 21:22:15 +0000 (23:22 +0200)
gtk2_ardour/editor.cc
gtk2_ardour/editor.h
gtk2_ardour/public_editor.cc
gtk2_ardour/public_editor.h

index 98fdad2ef255abac2f0c696c81878a17a36b8b2c..e3d1bc03982b1bd7a4e086391ac66379c69a0e85 100644 (file)
@@ -4803,6 +4803,22 @@ Editor::axis_views_from_routes (boost::shared_ptr<RouteList> r) const
        return t;
 }
 
+void
+Editor::suspend_route_redisplay ()
+{
+       if (_routes) {
+               _routes->suspend_redisplay();
+       }
+}
+
+void
+Editor::resume_route_redisplay ()
+{
+       if (_routes) {
+               _routes->resume_redisplay();
+       }
+}
+
 void
 Editor::add_routes (RouteList& routes)
 {
index 83610f0895046601e74b0bf7e300397333c33423..dad59cd6641afca1b636fb04eb99013768f2fdc5 100644 (file)
@@ -476,6 +476,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
 
        void on_realize();
 
+       void suspend_route_redisplay ();
+       void resume_route_redisplay ();
+
   private:
 
        void color_handler ();
index 6c5d528e1e9aad86d84496496955def2b5bc5c7f..e88f273c8795e29944c2c90f0c448a9eec292de8 100644 (file)
@@ -31,6 +31,7 @@ sigc::signal<void> PublicEditor::DropDownKeys;
 PublicEditor::PublicEditor ()
        : Window (Gtk::WINDOW_TOPLEVEL)
        , VisibilityTracker (*((Gtk::Window*)this))
+       , _suspend_route_redisplay_counter (0)
 {
 }
 
index ff77387ce1d51c38c7c5d8e4496b7201c04b25b0..9eac1be2f71919ede945a1295773d193a4f1a137 100644 (file)
@@ -84,6 +84,8 @@ class VerboseCursor;
 class XMLNode;
 struct SelectionRect;
 
+class DisplaySuspender;
+
 namespace ARDOUR_UI_UTILS {
 bool relay_key_press (GdkEventKey* ev, Gtk::Window* win);
 bool forward_key_press (GdkEventKey* ev);
@@ -428,6 +430,25 @@ class PublicEditor : public Gtk::Window, public PBD::StatefulDestructible, publi
           (and protected) method here does not have a default value.
        */
        virtual void _ensure_time_axis_view_is_visible (TimeAxisView const & tav, bool at_top) = 0;
+
+       friend class DisplaySuspender;
+       virtual void suspend_route_redisplay () = 0;
+       virtual void resume_route_redisplay () = 0;
+       gint _suspend_route_redisplay_counter;
+};
+
+class DisplaySuspender {
+       public:
+               DisplaySuspender() {
+                       if (g_atomic_int_add(&PublicEditor::instance()._suspend_route_redisplay_counter, 1) == 0) {
+                               PublicEditor::instance().suspend_route_redisplay ();
+                       }
+               }
+               ~DisplaySuspender () {
+                       if (g_atomic_int_dec_and_test (&PublicEditor::instance()._suspend_route_redisplay_counter)) {
+                               PublicEditor::instance().resume_route_redisplay ();
+                       }
+               }
 };
 
 #endif // __gtk_ardour_public_editor_h__