summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2014-06-28 23:22:15 +0200
committerRobin Gareus <robin@gareus.org>2014-06-28 23:22:15 +0200
commit77216ac468d4ffe9ba044a9be377d7d2a7fa27b4 (patch)
tree34f76b0670a3fd60770c8b4d1c9cf6c3c605bcf4
parentfd7cddb847639b28bbeaf72d5b613833761efe6f (diff)
add RAII DisplaySuspender
-rw-r--r--gtk2_ardour/editor.cc16
-rw-r--r--gtk2_ardour/editor.h3
-rw-r--r--gtk2_ardour/public_editor.cc1
-rw-r--r--gtk2_ardour/public_editor.h21
4 files changed, 41 insertions, 0 deletions
diff --git a/gtk2_ardour/editor.cc b/gtk2_ardour/editor.cc
index 98fdad2ef2..e3d1bc0398 100644
--- a/gtk2_ardour/editor.cc
+++ b/gtk2_ardour/editor.cc
@@ -4804,6 +4804,22 @@ Editor::axis_views_from_routes (boost::shared_ptr<RouteList> r) const
}
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)
{
ENSURE_GUI_THREAD (*this, &Editor::handle_new_route, routes)
diff --git a/gtk2_ardour/editor.h b/gtk2_ardour/editor.h
index 83610f0895..dad59cd664 100644
--- a/gtk2_ardour/editor.h
+++ b/gtk2_ardour/editor.h
@@ -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 ();
diff --git a/gtk2_ardour/public_editor.cc b/gtk2_ardour/public_editor.cc
index 6c5d528e1e..e88f273c87 100644
--- a/gtk2_ardour/public_editor.cc
+++ b/gtk2_ardour/public_editor.cc
@@ -31,6 +31,7 @@ sigc::signal<void> PublicEditor::DropDownKeys;
PublicEditor::PublicEditor ()
: Window (Gtk::WINDOW_TOPLEVEL)
, VisibilityTracker (*((Gtk::Window*)this))
+ , _suspend_route_redisplay_counter (0)
{
}
diff --git a/gtk2_ardour/public_editor.h b/gtk2_ardour/public_editor.h
index ff77387ce1..9eac1be2f7 100644
--- a/gtk2_ardour/public_editor.h
+++ b/gtk2_ardour/public_editor.h
@@ -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__