new MIDI binding maps for Korg nanoKontrol and M-Audio Axiom 25 from Chooch Schubert...
[ardour.git] / gtk2_ardour / lineset.cc
index 772824a533b8e6e32427cc3ba06b9f126e133e55..ac7ed56714dc2e5a1d273e8094e333ef1c474a45 100644 (file)
@@ -89,10 +89,10 @@ LineSet::LineSet(Group& parent, Orientation o)
 
        item_construct(parent);
 
-       property_x1().signal_changed().connect(mem_fun(*this, &LineSet::bounds_need_update));
-       property_y1().signal_changed().connect(mem_fun(*this, &LineSet::bounds_need_update));
-       property_x2().signal_changed().connect(mem_fun(*this, &LineSet::bounds_need_update));
-       property_y2().signal_changed().connect(mem_fun(*this, &LineSet::bounds_need_update));
+       property_x1().signal_changed().connect(sigc::mem_fun(*this, &LineSet::bounds_need_update));
+       property_y1().signal_changed().connect(sigc::mem_fun(*this, &LineSet::bounds_need_update));
+       property_x2().signal_changed().connect(sigc::mem_fun(*this, &LineSet::bounds_need_update));
+       property_y2().signal_changed().connect(sigc::mem_fun(*this, &LineSet::bounds_need_update));
 }
 
 LineSet::~LineSet()
@@ -108,8 +108,7 @@ LineSet::line_compare(const Line& a, const Line& b)
 void
 LineSet::print_lines()
 {
-       for (Lines::iterator it = lines.begin(); it != lines.end(); ++it)
-{
+       for (Lines::iterator it = lines.begin(); it != lines.end(); ++it) {
                cerr << "   " << it->coord << " " << it->width << " " << (int)it->r << " " << (int)it->g << " " << (int)it->b << " " << (int)it->a << endl;
        }
 }
@@ -179,7 +178,7 @@ LineSet::add_line(double coord, double width, uint32_t color)
        Line l(coord, width, color);
 
        Lines::iterator it = std::lower_bound(lines.begin(), lines.end(), l, line_compare);
-       
+
        /* overlap checking */
        if (it != lines.end()) {
                if (l.coord + l.width > it->coord) {
@@ -195,7 +194,7 @@ LineSet::add_line(double coord, double width, uint32_t color)
                }
                ++it;
        }
-       
+
        lines.insert(it, l);
        region_needs_update(coord, coord + width);
 }
@@ -228,13 +227,13 @@ LineSet::remove_until(double coord)
 {
        if (!lines.empty()) {
                double first = lines.front().coord;
-               
+
                // code
 
                region_needs_update(first, coord);
        }
 }
-       
+
 void
 LineSet::remove_from(double coord)
 {
@@ -253,7 +252,7 @@ LineSet::clear()
        if (!lines.empty()) {
                double coord1 = lines.front().coord;
                double coord2 = lines.back().coord + lines.back().width;
-                       
+
                lines.clear();
                region_needs_update(coord1, coord2);
        }
@@ -300,10 +299,10 @@ LineSet::line_at(double coord)
                Line dummy(coord);
 
                cached_pos = lower_bound(lines.begin(), lines.end(), dummy, line_compare);
-               
+
                /* The iterator found should point to the element after the one we want. */
                --cached_pos;
-               
+
                if (cached_pos != lines.end()) {
                        if (cached_pos->coord <= coord) {
                                if (cached_pos->coord + cached_pos->width >= coord) {
@@ -323,21 +322,26 @@ LineSet::line_at(double coord)
 }
 
 void
-LineSet::redraw_request(ArtIRect& r)
-{
-       get_canvas()->request_redraw(r.x0, r.y0, r.x1, r.y1);
-}
-
-void
-LineSet::redraw_request(ArtDRect& r)
+LineSet::redraw_request (ArtDRect const & r)
 {
        int x0, y0, x1, y1;
        Canvas& cv = *get_canvas();
 
        //cerr << "redraw request: " << r.x0 << " " << r.y0 << " " << r.x1 << " " << r.y1 << endl;
 
-       cv.w2c(r.x0, r.y0, x0, y0);
-       cv.w2c(r.x1, r.y1, x1, y1);
+       double fx0 = r.x0;
+       if (fx0 > INT_MAX) {
+               fx0 = INT_MAX;
+       }
+
+       double fx1 = r.x1;
+       if (fx1 > INT_MAX) {
+               fx1 = INT_MAX;
+       }
+
+       cv.w2c (fx0, r.y0, x0, y0);
+       cv.w2c (fx1, r.y1, x1, y1);
+
        cv.request_redraw(x0, y0, x1, y1);
 }
 
@@ -356,7 +360,7 @@ LineSet::update_lines(bool need_redraw)
                LineSet::bounds_vfunc(&redraw.x0, &redraw.y0, &redraw.x1, &redraw.y1);
                i2w(redraw.x0, redraw.y0);
                i2w(redraw.x1, redraw.y1);
-               
+
                if (orientation == Vertical) {
                        redraw.x1 = redraw.x0 + update_region2;
                        redraw.x0 += update_region1;
@@ -401,10 +405,21 @@ LineSet::update_bounds()
        item->y1 = new_b.y0;
        item->x2 = new_b.x1;
        item->y2 = new_b.y1;
-       
+
        /* Update bounding box used in rendering function */
-       cv.w2c(new_b.x0, new_b.y0, bbox.x0, bbox.y0);
-       cv.w2c(new_b.x1, new_b.y1, bbox.x1, bbox.y1);
+
+       double fx0 = new_b.x0;
+       if (fx0 > INT_MAX) {
+               fx0 = INT_MAX;
+       }
+
+       double fx1 = new_b.x1;
+       if (fx1 > INT_MAX) {
+               fx1 = INT_MAX;
+       }
+       
+       cv.w2c (fx0, new_b.y0, bbox.x0, bbox.y0);
+       cv.w2c (fx1, new_b.y1, bbox.x1, bbox.y1);
 
        /*
         * if the first primary axis property (x1 for Vertical, y1 for Horizontal) changed, we must redraw everything,
@@ -428,7 +443,7 @@ LineSet::update_bounds()
                                redraw.y1 = max(old_b.y1, new_b.y1);
                                redraw_request(redraw);
                        }
-                       
+
                        if (new_b.x1 > old_b.x1) {
                                // we have a larger area ==> possibly more lines
                                request_lines(old_b.x1, new_b.x1);
@@ -470,7 +485,7 @@ LineSet::update_bounds()
                                redraw.x1 = max(old_b.x1, new_b.x1);
                                redraw_request(redraw);
                        }
-                       
+
                        if (new_b.y1 > old_b.y1) {
                                // we have a larger area ==> possibly more lines
                                request_lines(old_b.y1, new_b.y1);
@@ -604,7 +619,7 @@ LineSet::render_vfunc(GnomeCanvasBuf* buf)
 
        /**
         * The first and the last line in this render have to be handled separately from those in between, because those lines
-        * may be cut off at the ends. 
+        * may be cut off at the ends.
         */
 
        if (orientation == Vertical) {
@@ -633,7 +648,7 @@ LineSet::render_vfunc(GnomeCanvasBuf* buf)
                for (; it != end; ++it) {
                        pos0 = ((int) floor(it->coord)) + offset;
                        pos1 = pos0 + ((int) floor(it->width));
-                       
+
                        if (pos1 > rect.x0) {
                                pos0 = max(pos0, rect.x0);
                                paint_vert(buf, *it, pos0, rect.y0, pos1, rect.y1);
@@ -641,7 +656,7 @@ LineSet::render_vfunc(GnomeCanvasBuf* buf)
                                break;
                        }
                }
-               
+
                // render what's between the first and last lines
                for (; it != end; ++it) {
                        pos0 = ((int) floor(it->coord)) + offset;
@@ -675,7 +690,7 @@ LineSet::render_vfunc(GnomeCanvasBuf* buf)
                for (; it != end; ++it) {
                        pos0 = ((int) floor(it->coord)) + offset;
                        pos1 = pos0 + ((int) floor(it->width));
-                       
+
                        if (pos1 > rect.y0) {
                                pos0 = max(pos0, rect.y0);
                                paint_horiz(buf, *it, rect.x0, pos0, rect.x1, pos1);
@@ -683,7 +698,7 @@ LineSet::render_vfunc(GnomeCanvasBuf* buf)
                                break;
                        }
                }
-               
+
                // render what's between the first and last lines
                for (; it != end; ++it) {
                        pos0 = ((int) floor(it->coord)) + offset;
@@ -775,7 +790,7 @@ LineSet::region_needs_update(double coord1, double coord2)
  * Don't know why this happens
  */
 bool LineSet::on_event(GdkEvent* /*p1*/)
-{ 
+{
        return false;
 }