Tempo Marks : set point colour by discontinuity, display non-quarter pulse if we...
authornick_m <mainsbridge@gmail.com>
Mon, 27 Feb 2017 00:10:47 +0000 (11:10 +1100)
committerRobin Gareus <robin@gareus.org>
Mon, 27 Feb 2017 19:16:10 +0000 (20:16 +0100)
- 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
gtk2_ardour/marker.cc
gtk2_ardour/marker.h

index 86b1b8d65a54c5b4ed5ce12166fd9530f2c07bbf..fbe58b8eae0aff94932d77636c0e764fd9c45038 100644 (file)
@@ -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<const MeterSection*>(*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<MeterSection*>(ms))));
                        }
-               } else if ((ts = dynamic_cast<const TempoSection*>(*i)) != 0) {
-                       if (UIConfiguration::instance().get_allow_non_quarter_pulse()) {
+               } else if ((ts = dynamic_cast<TempoSection*>(*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<TempoSection*>(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<TempoMarker*> (*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<MeterMarker*> (*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;
                }
        }
index c51def38c47b91d0a0a2f059bb80a021710baecd..faa4365ed558bd263c1d87bca5644811dfea77d9 100644 (file)
@@ -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)
 {
index e80b87e9c8b15874a6d73534fd325f1fe886c94f..e23c79b4bb3ed18436c99e7de94433ad6fad7244 100644 (file)
@@ -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;