Make send automation work (#4734).
[ardour.git] / gtk2_ardour / verbose_cursor.cc
index 9380b36c1af4ab8030d664bb9b294c3895350103..eb73cb91c84241610e52548d0822868957cc0e07 100644 (file)
 
 #include <string>
 #include <gtkmm/enums.h>
+#include "pbd/stacktrace.h"
 #include "ardour/profile.h"
-#include "editor.h"
+
 #include "ardour_ui.h"
-#include "verbose_cursor.h"
-#include "utils.h"
+#include "audio_clock.h"
+#include "editor.h"
 #include "editor_drag.h"
+#include "main_clock.h"
+#include "utils.h"
+#include "verbose_cursor.h"
 
 #include "i18n.h"
 
@@ -34,14 +38,12 @@ using namespace ARDOUR;
 VerboseCursor::VerboseCursor (Editor* editor)
        : _editor (editor)
        , _visible (false)
+       , _xoffset (0)
+       , _yoffset (0)
 {
-       Pango::FontDescription* font = get_font_for_style (N_("VerboseCanvasCursor"));
-
        _canvas_item = new ArdourCanvas::NoEventText (*_editor->track_canvas->root());
-       _canvas_item->property_font_desc() = *font;
+       _canvas_item->property_font_desc() = get_font_for_style (N_("VerboseCanvasCursor"));
        _canvas_item->property_anchor() = Gtk::ANCHOR_NW;
-
-       delete font;
 }
 
 ArdourCanvas::Item *
@@ -63,9 +65,20 @@ VerboseCursor::set_text (string const & text)
        _canvas_item->property_text() = text.c_str();
 }
 
+/** @param xoffset x offset to be applied on top of any set_position() call
+ *  before the next show ().
+ *  @param yoffset y offset as above.
+ */
 void
-VerboseCursor::show ()
+VerboseCursor::show (double xoffset, double yoffset)
 {
+       _xoffset = xoffset;
+       _yoffset = yoffset;
+
+       if (_visible) {
+               return;
+       }
+
        _canvas_item->raise_to_top ();
        _canvas_item->show ();
        _visible = true;
@@ -117,9 +130,9 @@ VerboseCursor::set_time (framepos_t frame, double x, double y)
        AudioClock::Mode m;
 
        if (Profile->get_sae() || Profile->get_small_screen()) {
-               m = ARDOUR_UI::instance()->primary_clock.mode();
+               m = ARDOUR_UI::instance()->primary_clock->mode();
        } else {
-               m = ARDOUR_UI::instance()->secondary_clock.mode();
+               m = ARDOUR_UI::instance()->secondary_clock->mode();
        }
 
        switch (m) {
@@ -171,9 +184,9 @@ VerboseCursor::set_duration (framepos_t start, framepos_t end, double x, double
        AudioClock::Mode m;
 
        if (Profile->get_sae() || Profile->get_small_screen()) {
-               m = ARDOUR_UI::instance()->primary_clock.mode ();
+               m = ARDOUR_UI::instance()->primary_clock->mode ();
        } else {
-               m = ARDOUR_UI::instance()->secondary_clock.mode ();
+               m = ARDOUR_UI::instance()->secondary_clock->mode ();
        }
 
        switch (m) {
@@ -203,7 +216,7 @@ VerboseCursor::set_duration (framepos_t start, framepos_t end, double x, double
 
                beats -= sbbt.beats;
                if (beats < 0) {
-                       beats += int (meter_at_start.beats_per_bar());
+                       beats += int (meter_at_start.divisions_per_bar());
                        --bars;
                }
 
@@ -244,11 +257,15 @@ VerboseCursor::set_color (uint32_t color)
        _canvas_item->property_fill_color_rgba() = color;
 }
 
+/** Set the position of the verbose cursor.  Any x/y offsets
+ *  passed to the last call to show() will be applied to the
+ *  coordinates passed in here.
+ */
 void
 VerboseCursor::set_position (double x, double y)
 {
-       _canvas_item->property_x() = clamp_x (x);
-       _canvas_item->property_y() = clamp_y (y);
+       _canvas_item->property_x() = clamp_x (x + _xoffset);
+       _canvas_item->property_y() = clamp_y (y + _yoffset);
 }
 
 bool