Fix horizontal positioning of PC flags.
[ardour.git] / gtk2_ardour / tempo_lines.cc
index 5b73c877acb53281493dec49aaa0f7ac848ab495..1400b189fb50773e7eda1734dee69a2469160962 100644 (file)
 
 using namespace std;
 
-#define MAX_CACHED_LINES 512
+#define MAX_CACHED_LINES 128
        
-TempoLines::TempoLines(ArdourCanvas::Canvas& canvas, ArdourCanvas::Group* group)
+TempoLines::TempoLines(ArdourCanvas::Canvas& canvas, ArdourCanvas::Group* group, double screen_height)
        : _canvas(canvas)
        , _group(group)
        , _clean_left(DBL_MAX)
        , _clean_right(0.0)
+       , _height(screen_height)
 {
 }
 
@@ -40,15 +41,15 @@ TempoLines::tempo_map_changed()
        _clean_left = DBL_MAX;
        _clean_right = 0.0;
 
-       size_t d = 0;
+       size_t d = 1;
        // TODO: Dirty/slow, but 'needed' for zoom :(
        for (Lines::iterator i = _lines.begin(); i != _lines.end(); ++d) {
                Lines::iterator next = i;
                ++next;
-       i->second->property_x1() = DBL_MAX - d;
-       i->second->property_x2() = DBL_MAX - d;
+       i->second->property_x1() = - d;
+       i->second->property_x2() = - d;
                _lines.erase(i);
-               _lines.insert(make_pair(DBL_MAX - d, i->second));
+               _lines.insert(make_pair(- d, i->second));
                i = next;
        }
 }
@@ -76,7 +77,7 @@ TempoLines::draw (ARDOUR::TempoMap::BBTPointList& points, double frames_per_unit
        ArdourCanvas::SimpleLine *line = NULL;
        gdouble xpos;
        double who_cares;
-       double x1, x2, y1, y2, beat_density;
+       double x1, x2, y1, beat_density;
 
        uint32_t beats = 0;
        uint32_t bars = 0;
@@ -85,7 +86,6 @@ TempoLines::draw (ARDOUR::TempoMap::BBTPointList& points, double frames_per_unit
        const size_t needed = points.size();
 
        _canvas.get_scroll_region (x1, y1, x2, who_cares);
-       _canvas.root()->get_bounds(who_cares, who_cares, who_cares, y2);
 
        /* get the first bar spacing */
 
@@ -98,6 +98,7 @@ TempoLines::draw (ARDOUR::TempoMap::BBTPointList& points, double frames_per_unit
 
        if (beat_density > 4.0f) {
                /* if the lines are too close together, they become useless */
+               tempo_map_changed();
                return;
        }
 
@@ -220,7 +221,8 @@ TempoLines::draw (ARDOUR::TempoMap::BBTPointList& points, double frames_per_unit
                                line = new ArdourCanvas::SimpleLine (*_group);
                                line->property_x1() = xpos;
                                line->property_x2() = xpos;
-                               line->property_y2() = y2;
+                               line->property_y1() = 0.0;
+                               line->property_y2() = _height;
                                line->property_color_rgba() = color;
                                _lines.insert(make_pair(xpos, line));
                                inserted_last_time = true;