X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Fverbose_cursor.cc;h=bf11733b6d25e93e7e69b45dfa2870d2edeb89aa;hb=2e7e2d2658eb992993425204f76ae508d9d26ded;hp=fec9e80ae11d82b59a1753cda04d29a7b0d467ec;hpb=f00b3b7f111e36537d773daef0ae77b03d11f82f;p=ardour.git diff --git a/gtk2_ardour/verbose_cursor.cc b/gtk2_ardour/verbose_cursor.cc index fec9e80ae1..bf11733b6d 100644 --- a/gtk2_ardour/verbose_cursor.cc +++ b/gtk2_ardour/verbose_cursor.cc @@ -23,112 +23,89 @@ #include "ardour/profile.h" #include "canvas/debug.h" +#include "canvas/scroll_group.h" +#include "canvas/tracking_text.h" -#include "ardour_ui.h" #include "audio_clock.h" #include "editor.h" #include "editor_drag.h" #include "main_clock.h" -#include "utils.h" #include "verbose_cursor.h" +#include "ardour_ui.h" +#include "ui_config.h" -#include "i18n.h" +#include "pbd/i18n.h" using namespace std; using namespace ARDOUR; VerboseCursor::VerboseCursor (Editor* editor) : _editor (editor) - , _visible (false) - , _xoffset (0) - , _yoffset (0) { - _canvas_item = new ArdourCanvas::Text (_editor->_track_canvas->root()); + _canvas_item = new ArdourCanvas::TrackingText (_editor->get_noscroll_group()); 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"))); + _canvas_item->set_font_description (Pango::FontDescription (UIConfiguration::instance().get_LargerBoldFont())); + color_handler (); + + UIConfiguration::instance().ColorsChanged.connect (sigc::mem_fun (*this, &VerboseCursor::color_handler)); } -ArdourCanvas::Item * -VerboseCursor::canvas_item () const +void +VerboseCursor::color_handler () { - return _canvas_item; + _canvas_item->set_color (UIConfiguration::instance().color_mod ("verbose canvas cursor", "verbose canvas cursor")); } -void -VerboseCursor::set (string const & text, double x, double y) +ArdourCanvas::Item * +VerboseCursor::canvas_item () const { - set_text (text); - set_position (x, y); + return _canvas_item; } +/** Set the contents of the cursor. + */ void -VerboseCursor::set_text (string const & text) +VerboseCursor::set (string const & text) { _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 (double xoffset, double yoffset) +VerboseCursor::show () { - _xoffset = xoffset; - _yoffset = yoffset; - - if (_visible) { - return; - } - - _canvas_item->raise_to_top (); - _canvas_item->show (); - _visible = true; + _canvas_item->show_and_track (true, true); + _canvas_item->parent()->raise_to_top (); } void VerboseCursor::hide () { _canvas_item->hide (); - _visible = false; + _canvas_item->parent()->lower_to_bottom (); + /* reset back to a sensible default for the next time we display the VC */ + _canvas_item->set_offset (ArdourCanvas::Duple (10, 10)); } -double -VerboseCursor::clamp_x (double x) -{ - _editor->clamp_verbose_cursor_x (x); - return x; -} - -double -VerboseCursor::clamp_y (double y) +void +VerboseCursor::set_offset (ArdourCanvas::Duple const & d) { - _editor->clamp_verbose_cursor_y (y); - return y; + _canvas_item->set_offset (d); } void -VerboseCursor::set_time (framepos_t frame, double x, double y) +VerboseCursor::set_time (framepos_t frame) { char buf[128]; Timecode::Time timecode; Timecode::BBT_Time bbt; - int hours, mins; - framepos_t frame_rate; - float secs; if (_editor->_session == 0) { return; } - AudioClock::Mode m; + /* Take clock mode from the primary clock */ - if (Profile->get_sae() || Profile->get_small_screen()) { - m = ARDOUR_UI::instance()->primary_clock->mode(); - } else { - m = ARDOUR_UI::instance()->secondary_clock->mode(); - } + AudioClock::Mode m = ARDOUR_UI::instance()->primary_clock->mode(); switch (m) { case AudioClock::BBT: @@ -138,18 +115,11 @@ VerboseCursor::set_time (framepos_t frame, double x, double y) case AudioClock::Timecode: _editor->_session->timecode_time (frame, timecode); - snprintf (buf, sizeof (buf), "%02" PRId32 ":%02" PRId32 ":%02" PRId32 ":%02" PRId32, timecode.hours, timecode.minutes, timecode.seconds, timecode.frames); + snprintf (buf, sizeof (buf), "%s", Timecode::timecode_format_time (timecode).c_str()); break; case AudioClock::MinSec: - /* XXX this is copied from show_verbose_duration_cursor() */ - frame_rate = _editor->_session->frame_rate(); - hours = frame / (frame_rate * 3600); - frame = frame % (frame_rate * 3600); - mins = frame / (frame_rate * 60); - frame = frame % (frame_rate * 60); - secs = (float) frame / (float) frame_rate; - snprintf (buf, sizeof (buf), "%02" PRId32 ":%02" PRId32 ":%07.4f", hours, mins, secs); + AudioClock::print_minsec (frame, buf, sizeof (buf), _editor->_session->frame_rate()); break; default: @@ -157,32 +127,23 @@ VerboseCursor::set_time (framepos_t frame, double x, double y) break; } - set (buf, x, y); + _canvas_item->set (buf); } void -VerboseCursor::set_duration (framepos_t start, framepos_t end, double x, double y) +VerboseCursor::set_duration (framepos_t start, framepos_t end) { char buf[128]; Timecode::Time timecode; Timecode::BBT_Time sbbt; Timecode::BBT_Time ebbt; - int hours, mins; - framepos_t distance, frame_rate; - float secs; - Meter meter_at_start (_editor->_session->tempo_map().meter_at(start)); + Meter meter_at_start (_editor->_session->tempo_map().meter_at_frame (start)); if (_editor->_session == 0) { return; } - AudioClock::Mode m; - - if (Profile->get_sae() || Profile->get_small_screen()) { - m = ARDOUR_UI::instance()->primary_clock->mode (); - } else { - m = ARDOUR_UI::instance()->secondary_clock->mode (); - } + AudioClock::Mode m = ARDOUR_UI::instance()->primary_clock->mode (); switch (m) { case AudioClock::BBT: @@ -223,19 +184,11 @@ VerboseCursor::set_duration (framepos_t start, framepos_t end, double x, double case AudioClock::Timecode: _editor->_session->timecode_duration (end - start, timecode); - snprintf (buf, sizeof (buf), "%02" PRId32 ":%02" PRId32 ":%02" PRId32 ":%02" PRId32, timecode.hours, timecode.minutes, timecode.seconds, timecode.frames); + snprintf (buf, sizeof (buf), "%s", Timecode::timecode_format_time (timecode).c_str()); break; case AudioClock::MinSec: - /* XXX this stuff should be elsewhere.. */ - distance = end - start; - frame_rate = _editor->_session->frame_rate(); - hours = distance / (frame_rate * 3600); - distance = distance % (frame_rate * 3600); - mins = distance / (frame_rate * 60); - distance = distance % (frame_rate * 60); - secs = (float) distance / (float) frame_rate; - snprintf (buf, sizeof (buf), "%02" PRId32 ":%02" PRId32 ":%07.4f", hours, mins, secs); + AudioClock::print_minsec (end - start, buf, sizeof (buf), _editor->_session->frame_rate()); break; default: @@ -243,28 +196,11 @@ VerboseCursor::set_duration (framepos_t start, framepos_t end, double x, double break; } - set (buf, x, y); -} - -void -VerboseCursor::set_color (uint32_t 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->set_x_position (clamp_x (x + _xoffset)); - _canvas_item->set_y_position (clamp_y (y + _yoffset)); + _canvas_item->set (buf); } bool VerboseCursor::visible () const { - return _visible; + return _canvas_item->visible(); }