Gd Lk ramps - rework auto scaling. change colour.
authornick_m <mainsbridge@gmail.com>
Tue, 24 May 2016 18:10:22 +0000 (04:10 +1000)
committernick_m <mainsbridge@gmail.com>
Fri, 27 May 2016 13:38:17 +0000 (23:38 +1000)
gtk2_ardour/editor_tempodisplay.cc
gtk2_ardour/tempo_curve.cc

index c100fbd4c729706f3e2bd8a8b83acc341f9638d4..ef04f84b76f0267cf9fa2d8520521bc5c6215b8f 100644 (file)
@@ -103,7 +103,7 @@ Editor::draw_metric_marks (const Metrics& metrics)
                        max_tempo = max (max_tempo, ts->beats_per_minute());
                        min_tempo = min (min_tempo, ts->beats_per_minute());
 
-                       tempo_curves.push_back (new TempoCurve (*this, *tempo_group, UIConfiguration::instance().color ("range drag rect"),
+                       tempo_curves.push_back (new TempoCurve (*this, *tempo_group, UIConfiguration::instance().color ("color 62"),
                                                                *(const_cast<TempoSection*>(ts)), ts->frame(), false));
                        metric_marks.push_back (new TempoMarker (*this, *tempo_group, UIConfiguration::instance().color ("tempo marker"), buf,
                                                                 *(const_cast<TempoSection*>(ts))));
@@ -112,6 +112,14 @@ Editor::draw_metric_marks (const Metrics& metrics)
 
        }
 
+       const double min_tempo_range = 5.0;
+       const double tempo_delta = fabs (max_tempo - min_tempo);
+
+       if (tempo_delta < min_tempo_range) {
+               max_tempo += min_tempo_range - tempo_delta;
+               min_tempo += tempo_delta - min_tempo_range;
+       }
+
        for (Curves::iterator x = tempo_curves.begin(); x != tempo_curves.end(); ) {
                Curves::iterator tmp = x;
                (*x)->set_max_tempo (max_tempo);
@@ -203,6 +211,14 @@ Editor::marker_position_changed ()
 
        tempo_curves.sort (CurveComparator());
 
+       const double min_tempo_range = 5.0;
+       const double tempo_delta = fabs (max_tempo - min_tempo);
+
+       if (tempo_delta < min_tempo_range) {
+               max_tempo += min_tempo_range - tempo_delta;
+               min_tempo += tempo_delta - min_tempo_range;
+       }
+
        for (Curves::iterator x = tempo_curves.begin(); x != tempo_curves.end(); ) {
                Curves::iterator tmp = x;
                (*x)->set_max_tempo (max_tempo);
index b3968e33aa122461eea2307a8d01daf57f57128b..cac512c0b2b34ca3b74b55eade3608fc26b5357b 100644 (file)
@@ -44,15 +44,15 @@ TempoCurve::TempoCurve (PublicEditor& ed, ArdourCanvas::Container& parent, guint
 
        group = new ArdourCanvas::Container (&parent, ArdourCanvas::Duple (unit_position, 1));
 #ifdef CANVAS_DEBUG
-       group->name = string_compose ("Marker::group for %1", _tempo.beats_per_minute());
+       group->name = string_compose ("TempoCurve::group for %1", _tempo.beats_per_minute());
 #endif
 
        _curve = new ArdourCanvas::FramedCurve (group);
 #ifdef CANVAS_DEBUG
-       _curve->name = string_compose ("TempoCurve::_curve for %1", _tempo.beats_per_minute());
+       _curve->name = string_compose ("TempoCurve::curve for %1", _tempo.beats_per_minute());
 #endif
        _curve->set_fill_mode (ArdourCanvas::FramedCurve::Inside);
-       _curve->set_points_per_segment (31);
+       _curve->set_points_per_segment (3);
 
        points = new ArdourCanvas::Points ();
        points->push_back (ArdourCanvas::Duple (0.0, 0.0));
@@ -110,14 +110,11 @@ TempoCurve::the_item() const
 void
 TempoCurve::set_position (framepos_t frame, framepos_t end_frame)
 {
-       const double tempo_delta = max (10.0, _max_tempo - _min_tempo);
-
        unit_position = editor.sample_to_pixel (frame);
        group->set_x_position (unit_position);
        frame_position = frame;
        _end_frame = end_frame;
 
-
        points->clear();
 
        points = new ArdourCanvas::Points ();
@@ -125,18 +122,18 @@ TempoCurve::set_position (framepos_t frame, framepos_t end_frame)
 
        if (end_frame == UINT32_MAX) {
                const double tempo_at = _tempo.tempo_at_frame (frame, editor.session()->frame_rate()) * _tempo.note_type();
-               const double y_pos =  (curve_height) - (((tempo_at - _min_tempo) / (tempo_delta)) * curve_height);
+               const double y_pos =  (curve_height) - (((tempo_at - _min_tempo) / (_max_tempo - _min_tempo)) * curve_height);
 
                points->push_back (ArdourCanvas::Duple (0.0, y_pos));
                points->push_back (ArdourCanvas::Duple (ArdourCanvas::COORD_MAX - 5.0, y_pos));
 
        } else {
-               const framepos_t frame_step = ((end_frame - 1) - frame) / 29;
+               const framepos_t frame_step = (end_frame - frame) / 5;
                framepos_t current_frame = frame;
 
                while (current_frame < (end_frame - frame_step)) {
                        const double tempo_at = _tempo.tempo_at_frame (current_frame, editor.session()->frame_rate()) * _tempo.note_type();
-                       const double y_pos = (curve_height) - (((tempo_at - _min_tempo) / (tempo_delta)) * curve_height);
+                       const double y_pos = (curve_height) - (((tempo_at - _min_tempo) / (_max_tempo - _min_tempo)) * curve_height);
 
                        points->push_back (ArdourCanvas::Duple (editor.sample_to_pixel (current_frame - frame), y_pos));
 
@@ -144,7 +141,7 @@ TempoCurve::set_position (framepos_t frame, framepos_t end_frame)
                }
 
                const double tempo_at = _tempo.tempo_at_frame (end_frame, editor.session()->frame_rate()) * _tempo.note_type();
-               const double y_pos = (curve_height) - (((tempo_at - _min_tempo) / (tempo_delta)) * curve_height);
+               const double y_pos = (curve_height) - (((tempo_at - _min_tempo) / (_max_tempo - _min_tempo)) * curve_height);
 
                points->push_back (ArdourCanvas::Duple (editor.sample_to_pixel ((end_frame - 1) - frame), y_pos));
        }
@@ -178,7 +175,7 @@ void
 TempoCurve::set_color_rgba (uint32_t c)
 {
        _color = c;
-       _curve->set_fill_color (UIConfiguration::instance().color_mod ("selection rect", "selection rect"));
+       _curve->set_fill_color (UIConfiguration::instance().color_mod ("color 62", "selection rect"));
        _curve->set_outline_color (_color);
 
 }