diff --git a/gtk2_ardour/beatbox_gui.cc b/gtk2_ardour/beatbox_gui.cc index e99fc06dfd..09e7ad8ac2 100644 --- a/gtk2_ardour/beatbox_gui.cc +++ b/gtk2_ardour/beatbox_gui.cc @@ -20,6 +20,8 @@ #include #include +#include + #include "pbd/compose.h" #include "pbd/i18n.h" @@ -789,10 +791,18 @@ StepView::view_mode_changed () { /* this should leave the text to the last text-displaying mode */ - if (_seq.mode() == SequencerGrid::Octave) { + switch (_seq.mode()) { + case SequencerGrid::Octave: set_octave_text (); - } else if (_seq.mode() == SequencerGrid::Group) { + break; + case SequencerGrid::Group: set_group_text (); + break; + case SequencerGrid::Timing: + set_timing_text (); + break; + default: + text->hide (); } } @@ -822,11 +832,38 @@ StepView::set_octave_text () } } +void +StepView::set_timing_text () +{ + if (!_step.velocity()) { + text->hide (); + return; + } + + if (_step.offset() == Temporal::Beats()) { + text->set (X_("0")); + } else { + const int64_t gcd = boost::math::gcd (_step.offset().to_ticks(), int64_t (1920)); + const int64_t n = _step.offset().to_ticks() / gcd; + const int64_t d = 1920 / gcd; + text->set (string_compose ("%1/%2", n, d)); + text->show (); + } + + if (text->self_visible()) { + const double w = text->width(); + const double h = text->height(); + text->set_position (Duple (_step_dimen/2 - (w/2), _step_dimen/2 - (h/2))); + } +} + void StepView::step_changed (PropertyChange const &) { if (_seq.mode() == SequencerGrid::Octave) { set_octave_text (); + } else if (_seq.mode() == SequencerGrid::Timing) { + set_timing_text (); } if (_step.velocity()) { diff --git a/gtk2_ardour/beatbox_gui.h b/gtk2_ardour/beatbox_gui.h index 836063d555..0fcb98f463 100644 --- a/gtk2_ardour/beatbox_gui.h +++ b/gtk2_ardour/beatbox_gui.h @@ -123,7 +123,8 @@ class StepView : public ArdourCanvas::Rectangle, public sigc::trackable { void set_octave_text (); void set_group_text (); - + void set_timing_text (); + static Gtkmm2ext::Color on_fill_color; static Gtkmm2ext::Color off_fill_color; };