diff options
| author | John Smith <john.smith7545@yahoo.com> | 2012-04-01 01:59:30 +0000 |
|---|---|---|
| committer | John Smith <removethis.john.q.public@bigmail.com> | 2012-04-01 01:59:30 +0000 |
| commit | e00ac80a336aaafb2aa544b72e949351fe78456a (patch) | |
| tree | 8f4c792b73beb20db3ee13f7384e4b5e6c7063fe /src | |
| parent | Fix for 950677 : Add stops and repeat controls to the gradient toolbar (diff) | |
| download | inkscape-e00ac80a336aaafb2aa544b72e949351fe78456a.tar.gz inkscape-e00ac80a336aaafb2aa544b72e949351fe78456a.zip | |
Fix for 627728 : Make newly added gradient stop active
(bzr r11135)
Diffstat (limited to 'src')
| -rw-r--r-- | src/gradient-context.cpp | 14 | ||||
| -rw-r--r-- | src/gradient-drag.cpp | 26 | ||||
| -rw-r--r-- | src/gradient-drag.h | 1 |
3 files changed, 38 insertions, 3 deletions
diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index 0543f8061..110ae0b8b 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -382,6 +382,8 @@ sp_gradient_context_add_stops_between_selected_stops (SPGradientContext *rc) // now actually create the new stops GSList *i = these_stops; GSList *j = next_stops; + GSList *new_stops = NULL; + for (; i != NULL && j != NULL; i = i->next, j = j->next) { SPStop *this_stop = (SPStop *) i->data; SPStop *next_stop = (SPStop *) j->data; @@ -389,7 +391,8 @@ sp_gradient_context_add_stops_between_selected_stops (SPGradientContext *rc) SPObject *parent = this_stop->parent; if (SP_IS_GRADIENT (parent)) { doc = parent->document; - sp_vector_add_stop (SP_GRADIENT (parent), this_stop, next_stop, offset); + SPStop *new_stop = sp_vector_add_stop (SP_GRADIENT (parent), this_stop, next_stop, offset); + new_stops = g_slist_prepend (new_stops, new_stop); SP_GRADIENT(parent)->ensureVector(); } } @@ -399,12 +402,17 @@ sp_gradient_context_add_stops_between_selected_stops (SPGradientContext *rc) drag->updateDraggers(); // so that it does not automatically update draggers in idle loop, as this would deselect drag->local_change = true; - // select all the old selected and new created draggers - drag->selectByCoords(coords); + + // select the newly created stops + for (GSList *s = new_stops; s != NULL; s = s->next) { + drag->selectByStop((SPStop *)s->data); + } + } g_slist_free (these_stops); g_slist_free (next_stops); + g_slist_free (new_stops); } double sqr(double x) {return x*x;} diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 5ff0e23e2..12ecd467c 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -414,6 +414,12 @@ SPStop *GrDrag::addStopNearPoint(SPItem *item, Geom::Point mouse_p, double toler gradient->ensureVector(); updateDraggers(); + // so that it does not automatically update draggers in idle loop, as this would deselect + local_change = true; + + // select the newly created stop + selectByStop(newstop); + return newstop; } @@ -1469,7 +1475,27 @@ void GrDrag::selectByCoords(std::vector<Geom::Point> coords) } } +/** + * Select draggers by stop + */ +void GrDrag::selectByStop(SPStop *stop ) +{ + for (GList *i = this->draggers; i != NULL; i = i->next) { + + GrDragger *dragger = (GrDragger *) i->data; + for (GSList const* j = dragger->draggables; j != NULL; j = j->next) { + GrDraggable *d = (GrDraggable *) j->data; + SPGradient *gradient = sp_item_gradient(d->item, d->fill_or_stroke); + SPGradient *vector = sp_gradient_get_forked_vector_if_necessary(gradient, false); + SPStop *stop_i = sp_get_stop_i(vector, d->point_i); + + if (stop_i == stop) { + setSelected(dragger, true, true); + } + } + } +} /** * Select all stops/draggers that fall within the rect. */ diff --git a/src/gradient-drag.h b/src/gradient-drag.h index 8aa9a6550..a16b48759 100644 --- a/src/gradient-drag.h +++ b/src/gradient-drag.h @@ -134,6 +134,7 @@ public: // FIXME: make more of this private! void deselectAll(); void selectAll(); void selectByCoords(std::vector<Geom::Point> coords); + void selectByStop(SPStop *stop); void selectRect(Geom::Rect const &r); bool dropColor(SPItem *item, gchar const *c, Geom::Point p); |
