diff options
| author | John Smith <john.smith7545@yahoo.com> | 2012-03-08 03:15:38 +0000 |
|---|---|---|
| committer | John Smith <removethis.john.q.public@bigmail.com> | 2012-03-08 03:15:38 +0000 |
| commit | a5ec25ba1491283c77471323159e78dd7bdb8ca0 (patch) | |
| tree | 382863052aef881cd733c9d832ea92bed99b93e3 /src/gradient-drag.cpp | |
| parent | cmake fix (diff) | |
| download | inkscape-a5ec25ba1491283c77471323159e78dd7bdb8ca0.tar.gz inkscape-a5ec25ba1491283c77471323159e78dd7bdb8ca0.zip | |
Fix for 855676 : Gradient - misplacing when adding new stop by mouse
(bzr r11061)
Diffstat (limited to 'src/gradient-drag.cpp')
| -rw-r--r-- | src/gradient-drag.cpp | 20 |
1 files changed, 14 insertions, 6 deletions
diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index c4c8ba15f..5ff0e23e2 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -339,10 +339,10 @@ guint32 GrDrag::getColor() SPStop *GrDrag::addStopNearPoint(SPItem *item, Geom::Point mouse_p, double tolerance) { - gfloat offset = 0; // type of SPStop.offset = gfloat + gfloat new_stop_offset = 0; // type of SPStop.offset = gfloat SPGradient *gradient; bool fill_or_stroke = true; - bool r1_knot = false; + //bool r1_knot = false; bool addknot = false; do { @@ -355,6 +355,8 @@ SPStop *GrDrag::addStopNearPoint(SPItem *item, Geom::Point mouse_p, double toler Geom::Point nearest = ls.pointAt(offset); double dist_screen = Geom::distance(mouse_p, nearest); if ( dist_screen < tolerance ) { + // calculate the new stop offset + new_stop_offset = distance(begin, nearest) / distance(begin, end); // add the knot addknot = true; break; // break out of the while loop: add only one knot @@ -367,8 +369,11 @@ SPStop *GrDrag::addStopNearPoint(SPItem *item, Geom::Point mouse_p, double toler Geom::Point nearest = ls.pointAt(offset); double dist_screen = Geom::distance(mouse_p, nearest); if ( dist_screen < tolerance ) { + // calculate the new stop offset + new_stop_offset = distance(begin, nearest) / distance(begin, end); + // add the knot addknot = true; - r1_knot = true; + //r1_knot = true; break; // break out of the while loop: add only one knot } @@ -378,8 +383,11 @@ SPStop *GrDrag::addStopNearPoint(SPItem *item, Geom::Point mouse_p, double toler nearest = ls.pointAt(offset); dist_screen = Geom::distance(mouse_p, nearest); if ( dist_screen < tolerance ) { + // calculate the new stop offset + new_stop_offset = distance(begin, nearest) / distance(begin, end); + // add the knot addknot = true; - r1_knot = false; + //r1_knot = false; break; // break out of the while loop: add only one knot } } @@ -391,7 +399,7 @@ SPStop *GrDrag::addStopNearPoint(SPItem *item, Geom::Point mouse_p, double toler SPStop* prev_stop = vector->getFirstStop(); SPStop* next_stop = prev_stop->getNextStop(); guint i = 1; - while ( (next_stop) && (next_stop->offset < offset) ) { + while ( (next_stop) && (next_stop->offset < new_stop_offset) ) { prev_stop = next_stop; next_stop = next_stop->getNextStop(); i++; @@ -402,7 +410,7 @@ SPStop *GrDrag::addStopNearPoint(SPItem *item, Geom::Point mouse_p, double toler } - SPStop *newstop = sp_vector_add_stop (vector, prev_stop, next_stop, offset); + SPStop *newstop = sp_vector_add_stop (vector, prev_stop, next_stop, new_stop_offset); gradient->ensureVector(); updateDraggers(); |
