#include <string>
#include <gtkmm/enums.h>
+#include "pbd/stacktrace.h"
#include "ardour/profile.h"
-#include "editor.h"
+
+#include "canvas/debug.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"
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_anchor() = Gtk::ANCHOR_NW;
-
- delete font;
+ _canvas_item = new ArdourCanvas::Text (_editor->_track_canvas->root());
+ CANVAS_DEBUG_NAME (_canvas_item, "verbose canvas cursor");
+ _canvas_item->set_ignore_events (true);
+ _canvas_item->set_font_description (get_font_for_style (N_("VerboseCanvasCursor")));
}
ArdourCanvas::Item *
void
VerboseCursor::set_text (string const & text)
{
- _canvas_item->property_text() = text.c_str();
+ _canvas_item->set (text);
}
+/** @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;
double
VerboseCursor::clamp_x (double x)
{
- if (x < 0) {
- x = 0;
- } else {
- x = min (_editor->_canvas_width - 200.0, x);
- }
+ _editor->clamp_verbose_cursor_x (x);
return x;
}
double
VerboseCursor::clamp_y (double y)
{
- if (y < _editor->canvas_timebars_vsize) {
- y = _editor->canvas_timebars_vsize;
- } else {
- y = min (_editor->_canvas_height - 50, y);
- }
+ _editor->clamp_verbose_cursor_y (y);
return 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) {
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) {
beats -= sbbt.beats;
if (beats < 0) {
- beats += int (meter_at_start.beats_per_bar());
+ beats += int (meter_at_start.divisions_per_bar());
--bars;
}
void
VerboseCursor::set_color (uint32_t color)
{
- _canvas_item->property_fill_color_rgba() = color;
+ _canvas_item->set_color (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->set_x_position (clamp_x (x + _xoffset));
+ _canvas_item->set_y_position (clamp_y (y + _yoffset));
}
bool