== Interface/Nodes ==
authorMatt Ebb <matt@mke3.net>
Thu, 26 Jan 2006 17:35:26 +0000 (17:35 +0000)
committerMatt Ebb <matt@mke3.net>
Thu, 26 Jan 2006 17:35:26 +0000 (17:35 +0000)
Modification to allow adding a point in a curve button by LMB clicking/dragging directly on the curve, as in GIMP/Photoshop/etc.

source/blender/src/interface.c

index d51859b34f8aaaef8ac35dfb58e837bf6b12b2e8..5c02db94fd8acd60828080fe31234077dfc92efa 100644 (file)
@@ -3400,6 +3400,39 @@ static int ui_do_but_CURVE(uiBut *but)
                        mindist= dist;
                }
        }
+       
+       if (sel == -1) {
+               /* if the click didn't select anything, check if it's clicked on the 
+                * curve itself, and if so, add a point */
+               fx= ((float)mval[0] - but->x1)/zoomx + offsx;
+               fy= ((float)mval[1] - but->y1)/zoomy + offsy;
+               
+               cmp= cuma->table;
+
+               /* loop through the curve segment table and find what's near the mouse.
+                * 0.05 is kinda arbitrary, but seems to be what works nicely. */
+               for(a=0; a<=CM_TABLE; a++) {                    
+                       if ( ( fabs(fx - cmp[a].x) < (0.05) ) && ( fabs(fy - cmp[a].y) < (0.05) ) ) {
+                       
+                               curvemap_insert(cuma, fx, fy);
+                               curvemapping_changed(cumap, 0);
+                               
+                               ui_draw_but(but);
+                               ui_block_flush_back(but->block);
+                               
+                               /* reset cmp back to the curve points again, rather than drawing segments */            
+                               cmp= cuma->curve;
+                               
+                               /* find newly added point and make it 'sel' */
+                               for(a=0; a<cuma->totpoint; a++) {
+                                       if (cmp[a].x == fx) sel = a;
+                               }
+                                       
+                               break;
+                       }
+               }
+       }
+       
        /* ok, we move a point */
        if(sel!= -1) {
                int moved_point;