From 3a7bc1fd3f32f0681182bcb399c030eb1899e523 Mon Sep 17 00:00:00 2001 From: nick_m Date: Mon, 27 Feb 2017 11:10:47 +1100 Subject: Tempo Marks : set point colour by discontinuity, display non-quarter pulse if we are non-quarter. - a jump in tempo by more than 1 ntpm results in a red tempo mark pointer. - ignore UIConfiguration::get_allow_non_quarter_pulse() when displaying note type in the marker text (only display note type if we are non-quarter). --- gtk2_ardour/editor_tempodisplay.cc | 40 ++++++++++++++++++++++++++++---------- gtk2_ardour/marker.cc | 9 +++++++++ gtk2_ardour/marker.h | 2 ++ 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/gtk2_ardour/editor_tempodisplay.cc b/gtk2_ardour/editor_tempodisplay.cc index 86b1b8d65a..fbe58b8eae 100644 --- a/gtk2_ardour/editor_tempodisplay.cc +++ b/gtk2_ardour/editor_tempodisplay.cc @@ -84,6 +84,7 @@ void Editor::draw_metric_marks (const Metrics& metrics) { char buf[64]; + TempoSection* prev_ts = 0; double max_tempo = 0.0; double min_tempo = DBL_MAX; @@ -91,7 +92,7 @@ Editor::draw_metric_marks (const Metrics& metrics) for (Metrics::const_iterator i = metrics.begin(); i != metrics.end(); ++i) { const MeterSection *ms; - const TempoSection *ts; + TempoSection *ts; if ((ms = dynamic_cast(*i)) != 0) { snprintf (buf, sizeof(buf), "%g/%g", ms->divisions_per_bar(), ms->note_divisor ()); @@ -102,8 +103,9 @@ Editor::draw_metric_marks (const Metrics& metrics) metric_marks.push_back (new MeterMarker (*this, *meter_group, UIConfiguration::instance().color ("meter marker"), buf, *(const_cast(ms)))); } - } else if ((ts = dynamic_cast(*i)) != 0) { - if (UIConfiguration::instance().get_allow_non_quarter_pulse()) { + } else if ((ts = dynamic_cast(*i)) != 0) { + + 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()); @@ -125,6 +127,12 @@ Editor::draw_metric_marks (const Metrics& metrics) metric_marks.push_back (new TempoMarker (*this, *tempo_group, UIConfiguration::instance().color ("tempo marker"), buf, *(const_cast(ts)))); } + if (prev_ts && abs (prev_ts->end_note_types_per_minute() - ts->note_types_per_minute()) < 1.0) { + metric_marks.back()->set_points_color (UIConfiguration::instance().color ("tempo marker music")); + } else { + metric_marks.back()->set_points_color (UIConfiguration::instance().color ("tempo marker")); + } + prev_ts = ts; } } @@ -204,21 +212,29 @@ Editor::tempometric_position_changed (const PropertyChange& /*ignored*/) tempo_lines->tempo_map_changed(); } + TempoSection* prev_ts = 0; double max_tempo = 0.0; double min_tempo = DBL_MAX; for (Marks::iterator x = metric_marks.begin(); x != metric_marks.end(); ++x) { TempoMarker* tempo_marker; MeterMarker* meter_marker; - const TempoSection *ts; + TempoSection *ts; const MeterSection *ms; if ((tempo_marker = dynamic_cast (*x)) != 0) { if ((ts = &tempo_marker->tempo()) != 0) { + tempo_marker->set_position (ts->frame ()); char buf[64]; - if (UIConfiguration::instance().get_allow_non_quarter_pulse()) { + 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")); + } else { + tempo_marker->set_points_color (UIConfiguration::instance().color ("tempo marker")); + } + + 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()); @@ -230,6 +246,8 @@ Editor::tempometric_position_changed (const PropertyChange& /*ignored*/) max_tempo = max (max_tempo, ts->end_note_types_per_minute()); min_tempo = min (min_tempo, ts->note_types_per_minute()); min_tempo = min (min_tempo, ts->end_note_types_per_minute()); + + prev_ts = ts; } } if ((meter_marker = dynamic_cast (*x)) != 0) { @@ -313,11 +331,13 @@ void Editor::tempo_curve_selected (TempoSection* ts, bool yn) { for (Curves::iterator x = tempo_curves.begin(); x != tempo_curves.end(); ++x) { - if (&(*x)->tempo() == ts && yn) { - (*x)->set_color_rgba (UIConfiguration::instance().color ("location marker")); - break; - } else if (&(*x)->tempo() == ts) { - (*x)->set_color_rgba (UIConfiguration::instance().color ("tempo curve")); + if (&(*x)->tempo() == ts) { + (*x)->set_selected (yn); + if (yn) { + (*x)->set_color_rgba (UIConfiguration::instance().color ("location marker")); + } else { + (*x)->set_color_rgba (UIConfiguration::instance().color ("tempo curve")); + } break; } } diff --git a/gtk2_ardour/marker.cc b/gtk2_ardour/marker.cc index c51def38c4..faa4365ed5 100644 --- a/gtk2_ardour/marker.cc +++ b/gtk2_ardour/marker.cc @@ -74,6 +74,7 @@ ArdourMarker::ArdourMarker (PublicEditor& ed, ArdourCanvas::Container& parent, g , _shown (false) , _line_shown (false) , _color (rgba) + , _points_color (rgba) , _left_label_limit (DBL_MAX) , _right_label_limit (DBL_MAX) , _label_offset (0) @@ -485,6 +486,14 @@ ArdourMarker::hide () setup_line (); } +void +ArdourMarker::set_points_color (uint32_t c) +{ + _points_color = c; + mark->set_fill_color (_points_color); + mark->set_outline_color (_points_color); +} + void ArdourMarker::set_color_rgba (uint32_t c) { diff --git a/gtk2_ardour/marker.h b/gtk2_ardour/marker.h index e80b87e9c8..e23c79b4bb 100644 --- a/gtk2_ardour/marker.h +++ b/gtk2_ardour/marker.h @@ -77,6 +77,7 @@ class ArdourMarker : public sigc::trackable void set_position (framepos_t); void set_name (const std::string&); + void set_points_color (uint32_t rgba); void set_color_rgba (uint32_t rgba); void setup_line (); @@ -123,6 +124,7 @@ class ArdourMarker : public sigc::trackable bool _line_shown; double _canvas_height; uint32_t _color; + uint32_t _points_color; double _left_label_limit; ///< the number of pixels available to the left of this marker for a label double _right_label_limit; ///< the number of pixels available to the right of this marker for a label double _label_offset; -- cgit v1.2.3