-void
-Editor::show_verbose_time_cursor (framepos_t frame, double offset, double xpos, double ypos)
-{
- char buf[128];
- Timecode::Time timecode;
- BBT_Time bbt;
- int hours, mins;
- framepos_t frame_rate;
- float secs;
-
- if (_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();
- }
-
- switch (m) {
- case AudioClock::BBT:
- _session->bbt_time (frame, bbt);
- snprintf (buf, sizeof (buf), "%02" PRIu32 "|%02" PRIu32 "|%02" PRIu32, bbt.bars, bbt.beats, bbt.ticks);
- break;
-
- case AudioClock::Timecode:
- _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);
- break;
-
- case AudioClock::MinSec:
- /* XXX this is copied from show_verbose_duration_cursor() */
- frame_rate = _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);
- break;
-
- default:
- snprintf (buf, sizeof(buf), "%" PRIi64, frame);
- break;
- }
-
- if (xpos >= 0 && ypos >=0) {
- set_verbose_canvas_cursor (buf, xpos + offset, ypos + offset);
- } else {
- set_verbose_canvas_cursor (buf, _drags->current_pointer_x() + offset - horizontal_position(), _drags->current_pointer_y() + offset - vertical_adjustment.get_value() + canvas_timebars_vsize);
- }
- show_verbose_canvas_cursor ();
-}
-
-void
-Editor::show_verbose_duration_cursor (framepos_t start, framepos_t end, double offset, double xpos, double ypos)
-{
- char buf[128];
- Timecode::Time timecode;
- BBT_Time sbbt;
- BBT_Time ebbt;
- int hours, mins;
- framepos_t distance, frame_rate;
- float secs;
- Meter meter_at_start(_session->tempo_map().meter_at(start));
-
- if (_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 ();
- }
-
- switch (m) {
- case AudioClock::BBT:
- _session->bbt_time (start, sbbt);
- _session->bbt_time (end, ebbt);
-
- /* subtract */
- /* XXX this computation won't work well if the
- user makes a selection that spans any meter changes.
- */
-
- ebbt.bars -= sbbt.bars;
- if (ebbt.beats >= sbbt.beats) {
- ebbt.beats -= sbbt.beats;
- } else {
- ebbt.bars--;
- ebbt.beats = int(meter_at_start.beats_per_bar()) + ebbt.beats - sbbt.beats;
- }
- if (ebbt.ticks >= sbbt.ticks) {
- ebbt.ticks -= sbbt.ticks;
- } else {
- ebbt.beats--;
- ebbt.ticks = int(Meter::ticks_per_beat) + ebbt.ticks - sbbt.ticks;
- }
-
- snprintf (buf, sizeof (buf), "%02" PRIu32 "|%02" PRIu32 "|%02" PRIu32, ebbt.bars, ebbt.beats, ebbt.ticks);
- break;
-
- case AudioClock::Timecode:
- _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);
- break;
-
- case AudioClock::MinSec:
- /* XXX this stuff should be elsewhere.. */
- distance = end - start;
- frame_rate = _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);
- break;
-
- default:
- snprintf (buf, sizeof(buf), "%" PRIi64, end - start);
- break;
- }
-
- if (xpos >= 0 && ypos >=0) {
- set_verbose_canvas_cursor (buf, xpos + offset, ypos + offset);
- }
- else {
- set_verbose_canvas_cursor (buf, _drags->current_pointer_x() + offset, _drags->current_pointer_y() + offset);
- }
-
- show_verbose_canvas_cursor ();
-}
-