diff options
-rw-r--r-- | gtk2_ardour/editor_tempodisplay.cc | 35 | ||||
-rw-r--r-- | gtk2_ardour/tempo_curve.cc | 32 | ||||
-rw-r--r-- | gtk2_ardour/tempo_curve.h | 3 |
3 files changed, 37 insertions, 33 deletions
diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc index 767d84d918..752373db6e 100644 --- a/gtk2_ardour/editor_tempodisplay.cc +++ b/gtk2_ardour/editor_tempodisplay.cc @@ -105,19 +105,6 @@ Editor::draw_metric_marks (const Metrics& metrics) } } else if ((ts = dynamic_cast<TempoSection*>(*i)) != 0) { - if (ts->type() == TempoSection::Constant) { - if (ts->note_type() != 4.0) { - snprintf (buf, sizeof (buf), "%.3f/%.0f", ts->note_types_per_minute(), ts->note_type()); - } else { - snprintf (buf, sizeof (buf), "%.3f", ts->note_types_per_minute()); - } - } else { - if (ts->note_type() != 4.0) { - snprintf (buf, sizeof (buf), "%.3f/%.0f>%.3f", ts->note_types_per_minute(), ts->note_type(), ts->end_note_types_per_minute()); - } else { - snprintf (buf, sizeof (buf), "%.3f>%.3f", ts->note_types_per_minute(), ts->end_note_types_per_minute()); - } - } max_tempo = max (max_tempo, ts->note_types_per_minute()); max_tempo = max (max_tempo, ts->end_note_types_per_minute()); min_tempo = min (min_tempo, ts->note_types_per_minute()); @@ -127,11 +114,12 @@ Editor::draw_metric_marks (const Metrics& metrics) tempo_curves.push_back (new TempoCurve (*this, *tempo_group, tc_color, *(const_cast<TempoSection*>(ts)), ts->frame(), false)); + const std::string tname (X_("")); if (ts->position_lock_style() == MusicTime) { - metric_marks.push_back (new TempoMarker (*this, *tempo_group, UIConfiguration::instance().color ("tempo marker music"), buf, + metric_marks.push_back (new TempoMarker (*this, *tempo_group, UIConfiguration::instance().color ("tempo marker music"), tname, *(const_cast<TempoSection*>(ts)))); } else { - metric_marks.push_back (new TempoMarker (*this, *tempo_group, UIConfiguration::instance().color ("tempo marker"), buf, + metric_marks.push_back (new TempoMarker (*this, *tempo_group, UIConfiguration::instance().color ("tempo marker"), tname, *(const_cast<TempoSection*>(ts)))); } if (prev_ts && abs (prev_ts->end_note_types_per_minute() - ts->note_types_per_minute()) < 1.0) { @@ -233,7 +221,6 @@ Editor::tempometric_position_changed (const PropertyChange& /*ignored*/) if ((ts = &tempo_marker->tempo()) != 0) { tempo_marker->set_position (ts->frame ()); - char buf[64]; if (prev_ts && abs (prev_ts->end_note_types_per_minute() - ts->note_types_per_minute()) < 1.0) { tempo_marker->set_points_color (UIConfiguration::instance().color ("tempo marker music")); @@ -241,22 +228,6 @@ Editor::tempometric_position_changed (const PropertyChange& /*ignored*/) tempo_marker->set_points_color (UIConfiguration::instance().color ("tempo marker")); } - if (ts->type() == TempoSection::Constant) { - if (ts->note_type() != 4.0) { - snprintf (buf, sizeof (buf), "%.3f/%.0f", ts->note_types_per_minute(), ts->note_type()); - } else { - snprintf (buf, sizeof (buf), "%.3f", ts->note_types_per_minute()); - } - } else { - if (ts->note_type() != 4.0) { - snprintf (buf, sizeof (buf), "%.3f/%.0f>%.3f", ts->note_types_per_minute(), ts->note_type(), ts->end_note_types_per_minute()); - } else { - snprintf (buf, sizeof (buf), "%.3f>%.3f", ts->note_types_per_minute(), ts->end_note_types_per_minute()); - } - } - - tempo_marker->set_name (buf); - max_tempo = max (max_tempo, ts->note_types_per_minute()); max_tempo = max (max_tempo, ts->end_note_types_per_minute()); min_tempo = min (min_tempo, ts->note_types_per_minute()); diff --git a/gtk2_ardour/tempo_curve.cc b/gtk2_ardour/tempo_curve.cc index c43e91c9ac..720418e030 100644 --- a/gtk2_ardour/tempo_curve.cc +++ b/gtk2_ardour/tempo_curve.cc @@ -37,7 +37,8 @@ TempoCurve::TempoCurve (PublicEditor& ed, ArdourCanvas::Container& parent, guint , _min_tempo (temp.note_types_per_minute()) , _max_tempo (temp.note_types_per_minute()) , _tempo (temp) - + , _start_text (0) + , _end_text (0) { frame_position = frame; unit_position = editor.sample_to_pixel (frame); @@ -55,6 +56,18 @@ TempoCurve::TempoCurve (PublicEditor& ed, ArdourCanvas::Container& parent, guint points = new ArdourCanvas::Points (); _curve->set (*points); + _start_text = new ArdourCanvas::Text (group); + _end_text = new ArdourCanvas::Text (group); + _start_text->set_font_description (ARDOUR_UI_UTILS::get_font_for_style (N_("MarkerText"))); + _end_text->set_font_description (ARDOUR_UI_UTILS::get_font_for_style (N_("MarkerText"))); + _start_text->set_color (RGBA_TO_UINT (255,255,255,255)); + _end_text->set_color (RGBA_TO_UINT (255,255,255,255)); + char buf[10]; + snprintf (buf, sizeof (buf), "%.3f/%.0f", _tempo.note_types_per_minute(), _tempo.note_type()); + _start_text->set (buf); + snprintf (buf, sizeof (buf), "%.3f", _tempo.end_note_types_per_minute()); + _end_text->set (buf); + set_color_rgba (rgba); editor.ZoomChanged.connect (sigc::mem_fun (*this, &TempoCurve::reposition)); @@ -147,6 +160,23 @@ TempoCurve::set_position (framepos_t frame, framepos_t end_frame) } _curve->set (*points); + + char buf[10]; + snprintf (buf, sizeof (buf), "%.3f/%.0f", _tempo.note_types_per_minute(), _tempo.note_type()); + _start_text->set (buf); + snprintf (buf, sizeof (buf), "%.3f", _tempo.end_note_types_per_minute()); + _end_text->set (buf); + + _start_text->set_position (ArdourCanvas::Duple (10, .5 )); + _end_text->set_position (ArdourCanvas::Duple (editor.sample_to_pixel (end_frame - frame) - _end_text->text_width() - 10, .5 )); + + if (_end_text->text_width() + _start_text->text_width() + 20 > editor.sample_to_pixel (end_frame - frame)) { + _start_text->hide(); + _end_text->hide(); + } else { + _start_text->show(); + _end_text->show(); + } } void diff --git a/gtk2_ardour/tempo_curve.h b/gtk2_ardour/tempo_curve.h index 9cee2265f0..ec1c6fd90f 100644 --- a/gtk2_ardour/tempo_curve.h +++ b/gtk2_ardour/tempo_curve.h @@ -11,6 +11,7 @@ #include "canvas/types.h" #include "canvas/framed_curve.h" +#include "canvas/text.h" namespace ARDOUR { class TempoSection; @@ -68,6 +69,8 @@ private: TempoCurve (TempoCurve const &); TempoCurve & operator= (TempoCurve const &); ARDOUR::TempoSection& _tempo; + ArdourCanvas::Text *_start_text; + ArdourCanvas::Text *_end_text; }; #endif /* __gtk_ardour_tempo_curve_h__ */ |