From fa54435615cc8129bf5ea4fea542386195f17dcf Mon Sep 17 00:00:00 2001 From: Matt Ebb Date: Thu, 26 Jan 2006 17:35:26 +0000 Subject: == Interface/Nodes == 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 | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/source/blender/src/interface.c b/source/blender/src/interface.c index d51859b34f8..5c02db94fd8 100644 --- a/source/blender/src/interface.c +++ b/source/blender/src/interface.c @@ -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; atotpoint; a++) { + if (cmp[a].x == fx) sel = a; + } + + break; + } + } + } + /* ok, we move a point */ if(sel!= -1) { int moved_point; -- cgit v1.2.3