X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=inline;f=gtk2_ardour%2Fverbose_cursor.cc;h=fec9e80ae11d82b59a1753cda04d29a7b0d467ec;hb=97758dcbeab57a073aef6be909409529814c51a8;hp=9380b36c1af4ab8030d664bb9b294c3895350103;hpb=988348185ece58b9af4ecc3a919e7f4862fa9a54;p=ardour.git diff --git a/gtk2_ardour/verbose_cursor.cc b/gtk2_ardour/verbose_cursor.cc index 9380b36c1a..fec9e80ae1 100644 --- a/gtk2_ardour/verbose_cursor.cc +++ b/gtk2_ardour/verbose_cursor.cc @@ -19,12 +19,18 @@ #include #include +#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" @@ -34,14 +40,13 @@ 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_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 * @@ -60,12 +65,23 @@ VerboseCursor::set (string const & text, double x, double y) 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; @@ -81,22 +97,14 @@ VerboseCursor::hide () 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; } @@ -117,9 +125,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 +179,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 +211,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; } @@ -241,14 +249,18 @@ VerboseCursor::set_duration (framepos_t start, framepos_t end, double x, double 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