add RAII DisplaySuspender

This commit is contained in:
Robin Gareus 2014-06-28 23:22:15 +02:00 committed by Paul Davis
parent 8db5d93a35
commit 67c1322f0d
4 changed files with 41 additions and 0 deletions

View file

@ -4847,6 +4847,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)
{

View file

@ -485,6 +485,9 @@ class Editor : public PublicEditor, public PBD::ScopedConnectionList, public ARD
void on_realize();
MasterBusUI* master_bus_ui () { return _master_bus_ui; }
void suspend_route_redisplay ();
void resume_route_redisplay ();
private:
void color_handler ();

View file

@ -32,6 +32,7 @@ PublicEditor::PublicEditor (std::string layout_script)
: Window (Gtk::WINDOW_TOPLEVEL)
, WavesUI (layout_script, *this)
, VisibilityTracker (*((Gtk::Window*)this))
, _suspend_route_redisplay_counter (0)
{
}

View file

@ -86,6 +86,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);
@ -430,6 +432,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__