map::clear() calls erase. Cleans up cpp check warning 'iterator used after element...
[ardour.git] / libs / gtkmm2ext / fader.cc
old mode 100755 (executable)
new mode 100644 (file)
index 0fedd33..f6fe487
@@ -46,23 +46,23 @@ static void get_closest_point_on_line(double xa, double ya, double xb, double yb
        // Storing vector A->B
        double a_to_b_x = xb - xa;
        double a_to_b_y = yb - ya;
-    
+
        // Storing vector A->P
        double a_to_p_x = xp - xa;
        double a_to_p_y = yp - ya;
-    
+
 
        // Basically finding the squared magnitude
        // of a_to_b
        double atb2 = a_to_b_x * a_to_b_x + a_to_b_y * a_to_b_y;
+
        // The dot product of a_to_p and a_to_b
        double atp_dot_atb = a_to_p_x * a_to_b_x + a_to_p_y * a_to_b_y;
-    
+
        // The normalized "distance" from a to
        // your closest point
        double t = atp_dot_atb / atb2;
-    
+
        // Add the distance to A, moving
        // towards B
        double x = xa + a_to_b_x * t;
@@ -116,7 +116,7 @@ Fader::Fader (Gtk::Adjustment& adj,
               const Glib::RefPtr<Gdk::Pixbuf>& underlay_pixbuf,
               const Glib::RefPtr<Gdk::Pixbuf>& handle_pixbuf,
               const Glib::RefPtr<Gdk::Pixbuf>& active_handle_pixbuf,
-              int min_pos_x, 
+              int min_pos_x,
               int min_pos_y,
               int max_pos_x,
               int max_pos_y,
@@ -162,7 +162,7 @@ Fader::get_image_scales (double &x_scale, double &y_scale)
        int pbheight = _face_pixbuf->get_height ();
        int width = get_width ();
        int height = get_height ();
-       
+
        if ((width != pbwidth) || (height != pbheight)) {
                x_scale = double (width) / double (pbwidth);
                if (x_scale == 0.0) {
@@ -186,17 +186,17 @@ Fader::set_touch_cursor (const Glib::RefPtr<Gdk::Pixbuf>& touch_cursor)
 void
 Fader::render (cairo_t* cr, cairo_rectangle_t*)
 {
-       
+
        double xscale = 1.0;
        double yscale = 1.0;
-       
+
        get_image_scales (xscale, yscale);
-       
+
        cairo_matrix_t matrix;
        cairo_get_matrix (cr, &matrix);
        cairo_matrix_scale (&matrix, xscale, yscale);
        cairo_set_matrix (cr, &matrix);
-       
+
        get_handle_position (_last_drawn_x, _last_drawn_y);
 
        if (_underlay_pixbuf != 0) {
@@ -208,8 +208,8 @@ Fader::render (cairo_t* cr, cairo_rectangle_t*)
        }
 
        gdk_cairo_set_source_pixbuf (cr,
-                                    ((get_state () == Gtk::STATE_ACTIVE) && (_active_face_pixbuf != 0)) ? 
-                                    _active_face_pixbuf->gobj() : 
+                                    ((get_state () == Gtk::STATE_ACTIVE) && (_active_face_pixbuf != 0)) ?
+                                    _active_face_pixbuf->gobj() :
                                     _face_pixbuf->gobj(),
                                     0,
                                     0);
@@ -240,12 +240,12 @@ Fader::on_size_allocate (Gtk::Allocation& alloc)
 bool
 Fader::on_button_press_event (GdkEventButton* ev)
 {
-       focus_handler();
-    
+       focus_handler(this);
+
        if (_read_only) {
                return false;
        }
-    
+
        if (ev->type != GDK_BUTTON_PRESS) {
                return false;
        }
@@ -264,28 +264,28 @@ Fader::on_button_press_event (GdkEventButton* ev)
 
        double xscale = 1.0;
        double yscale = 1.0;
-       
+
        get_image_scales (xscale, yscale);
-       
+
        double hw = _handle_pixbuf->get_width() * xscale;
        double hh = _handle_pixbuf->get_height() * yscale;
 
        if ((ev->x < (_grab_start_handle_x - hw/2)) || (ev->x > (_grab_start_handle_x + hw/2)) || (ev->y < (_grab_start_handle_y - hh/2)) || (ev->y > (_grab_start_handle_y + hh/2))) {
                return false;
        }
-    
+
        double ev_pos_x;
        double ev_pos_y;
-               
+
        get_closest_point_on_line(_min_pos_x, _min_pos_y,
-                                 _max_pos_x, _max_pos_y, 
+                                 _max_pos_x, _max_pos_y,
                                  ev->x, ev->y,
                                  ev_pos_x, ev_pos_y );
        add_modal_grab ();
-       
+
        _grab_window = ev->window;
        _dragging = true;
-       
+
        gdk_pointer_grab(ev->window,false,
                         GdkEventMask (Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK),
                         NULL,
@@ -293,7 +293,7 @@ Fader::on_button_press_event (GdkEventButton* ev)
                         ev->time);
 
        queue_draw();
-       
+
        return true;
 }
 
@@ -368,22 +368,22 @@ Fader::on_motion_notify_event (GdkEventMotion* ev)
        if (_dragging) {
                double ev_pos_x;
                double ev_pos_y;
-               
+
                if (ev->window != _grab_window) {
                        _grab_window = ev->window;
                        return true;
                }
 
                get_closest_point_on_line(_min_pos_x, _min_pos_y,
-                                         _max_pos_x, _max_pos_y, 
+                                         _max_pos_x, _max_pos_y,
                                          _grab_start_handle_x + (ev->x - _grab_start_mouse_x), _grab_start_handle_y + (ev->y - _grab_start_mouse_y),
                                          ev_pos_x, ev_pos_y );
-               
+
                double const fract = sqrt((ev_pos_x - _min_pos_x) * (ev_pos_x - _min_pos_x) +
                                          (ev_pos_y - _min_pos_y) * (ev_pos_y - _min_pos_y)) /
                        sqrt((double)((_max_pos_x - _min_pos_x) * (_max_pos_x - _min_pos_x) +
                                      (_max_pos_y - _min_pos_y) * (_max_pos_y - _min_pos_y)));
-               
+
                adjustment.set_value (adjustment.get_lower() + (adjustment.get_upper() - adjustment.get_lower()) * fract);
        }
        return true;