diff options
author | Carl Hetherington <carl@carlh.net> | 2011-04-25 21:19:25 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2011-04-25 21:19:25 +0000 |
commit | 8ca87df015f4cd0af56bcc36e2554a7ad44f3dc6 (patch) | |
tree | 3631ded4c5668abe6e18b77423647efe7d0f576c /gtk2_ardour/editor_mouse.cc | |
parent | 3356957afae11607f8fb8996ca22028ffd5fde2d (diff) |
Fix subtraction of bar/beat/tick for verbose canvas cursor (#4011).
git-svn-id: svn://localhost/ardour2/branches/3.0@9426 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour/editor_mouse.cc')
-rw-r--r-- | gtk2_ardour/editor_mouse.cc | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/gtk2_ardour/editor_mouse.cc b/gtk2_ardour/editor_mouse.cc index 96815f2568..a931ad3686 100644 --- a/gtk2_ardour/editor_mouse.cc +++ b/gtk2_ardour/editor_mouse.cc @@ -2264,6 +2264,7 @@ Editor::show_verbose_duration_cursor (framepos_t start, framepos_t end, double o switch (m) { case AudioClock::BBT: + { _session->bbt_time (start, sbbt); _session->bbt_time (end, ebbt); @@ -2272,22 +2273,31 @@ Editor::show_verbose_duration_cursor (framepos_t start, framepos_t end, double o 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; + /* use signed integers for the working values so that + we can underflow. + */ + + int ticks = ebbt.ticks; + int beats = ebbt.beats; + int bars = ebbt.bars; + + ticks -= sbbt.ticks; + if (ticks < 0) { + ticks += int (Timecode::BBT_Time::ticks_per_beat); + --beats; } - if (ebbt.ticks >= sbbt.ticks) { - ebbt.ticks -= sbbt.ticks; - } else { - ebbt.beats--; - ebbt.ticks = int(Timecode::BBT_Time::ticks_per_beat) + ebbt.ticks - sbbt.ticks; + + beats -= sbbt.beats; + if (beats < 0) { + beats += int (meter_at_start.beats_per_bar()); + --bars; } - snprintf (buf, sizeof (buf), "%02" PRIu32 "|%02" PRIu32 "|%02" PRIu32, ebbt.bars, ebbt.beats, ebbt.ticks); + bars -= sbbt.bars; + + snprintf (buf, sizeof (buf), "%02" PRIu32 "|%02" PRIu32 "|%02" PRIu32, bars, beats, ticks); break; + } case AudioClock::Timecode: _session->timecode_duration (end - start, timecode); |