Only show user-presets in favorite sidebar
[ardour.git] / libs / canvas / canvas.cc
index a004d64ad3291eff86ab42d0ca32840a1d596dcb..8456d44d828181462eacaec1735d5346425ac901 100644 (file)
 #include "pbd/stacktrace.h"
 
 #include "canvas/canvas.h"
-#include "canvas/colors.h"
+#include "gtkmm2ext/colors.h"
 #include "canvas/debug.h"
 #include "canvas/line.h"
 #include "canvas/scroll_group.h"
-#include "canvas/utils.h"
 
 #ifdef __APPLE__
 #include <gdk/gdk.h>
@@ -57,7 +56,7 @@ uint32_t Canvas::tooltip_timeout_msecs = 750;
 /** Construct a new Canvas */
 Canvas::Canvas ()
        : _root (this)
-       , _bg_color (rgba_to_color (0, 1.0, 0.0, 1.0))
+       , _bg_color (Gtkmm2ext::rgba_to_color (0, 1.0, 0.0, 1.0))
        , _last_render_start_timestamp(0)
 {
        set_epoch ();
@@ -163,6 +162,18 @@ Canvas::prepare_for_render (Rect const & area) const
        }
 }
 
+gint64
+Canvas::get_microseconds_since_render_start () const
+{
+       gint64 timestamp = g_get_monotonic_time();
+
+       if (_last_render_start_timestamp == 0 || timestamp <= _last_render_start_timestamp) {
+               return 0;
+       }
+
+       return timestamp - _last_render_start_timestamp;
+}
+
 ostream&
 operator<< (ostream& o, Canvas& c)
 {
@@ -395,7 +406,7 @@ Canvas::set_tooltip_timeout (uint32_t msecs)
 }
 
 void
-Canvas::set_background_color (Color c)
+Canvas::set_background_color (Gtkmm2ext::Color c)
 {
        _bg_color = c;
 
@@ -862,7 +873,6 @@ GtkCanvas::on_expose_event (GdkEventExpose* ev)
        }
 #ifdef __APPLE__
        if (_nsglview) {
-               Gtkmm2ext::nsglview_queue_draw (_nsglview, ev->area.x, ev->area.y, ev->area.width, ev->area.height);
                return true;
        }
 #endif
@@ -914,7 +924,7 @@ GtkCanvas::on_expose_event (GdkEventExpose* ev)
 
        /* draw background color */
        draw_context->rectangle (ev->area.x, ev->area.y, ev->area.width, ev->area.height);
-       set_source_rgba (draw_context, _bg_color);
+       Gtkmm2ext::set_source_rgba (draw_context, _bg_color);
        draw_context->fill ();
 
        /* render canvas */
@@ -1190,6 +1200,30 @@ GtkCanvas::on_unmap ()
 #endif
 }
 
+void
+GtkCanvas::queue_draw()
+{
+#ifdef __APPLE__
+       if (_nsglview) {
+               Gtkmm2ext::nsglview_queue_draw (_nsglview, 0, 0, get_width (), get_height ());
+               return;
+       }
+#endif
+       Gtk::Widget::queue_draw ();
+}
+
+void
+GtkCanvas::queue_draw_area (int x, int y, int width, int height)
+{
+#ifdef __APPLE__
+       if (_nsglview) {
+               Gtkmm2ext::nsglview_queue_draw (_nsglview, x, y, width, height);
+               return;
+       }
+#endif
+       Gtk::Widget::queue_draw_area (x, y, width, height);
+}
+
 /** Called to request a redraw of our canvas.
  *  @param area Area to redraw, in window coordinates.
  */