diff options
| author | John Smith <john.smith7545@yahoo.com> | 2012-09-22 09:59:01 +0000 |
|---|---|---|
| committer | John Smith <john.smith7545@yahoo.com> | 2012-09-22 09:59:01 +0000 |
| commit | a8e76949f48267a704af633032e33d6982c682cc (patch) | |
| tree | b7363e4c0d1d41470e0b72c535487a429062a40a /src/gradient-chemistry.cpp | |
| parent | Fix for 166691 : Revert fix (diff) | |
| download | inkscape-a8e76949f48267a704af633032e33d6982c682cc.tar.gz inkscape-a8e76949f48267a704af633032e33d6982c682cc.zip | |
Fix for 367548 : Invert doesnt work on objects with gradients
(bzr r11694)
Diffstat (limited to 'src/gradient-chemistry.cpp')
| -rw-r--r-- | src/gradient-chemistry.cpp | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 34934f75b..2ddfe5ff7 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -26,7 +26,13 @@ #include "style.h" #include "document-private.h" +#include "document-undo.h" #include "desktop-style.h" +#include "desktop-handles.h" +#include "event-context.h" +#include "selection.h" +#include "verbs.h" +#include <glibmm/i18n.h> #include "sp-gradient-reference.h" #include "sp-gradient-vector.h" @@ -47,6 +53,7 @@ #define noSP_GR_VERBOSE +using Inkscape::DocumentUndo; namespace { @@ -1508,6 +1515,36 @@ SPGradient *sp_gradient_vector_for_object( SPDocument *const doc, SPDesktop *con } +void sp_gradient_invert_selected_gradients(SPDesktop *desktop, Inkscape::PaintTarget fill_or_stroke) +{ + Inkscape::Selection *selection = sp_desktop_selection(desktop); + SPEventContext *ev = sp_desktop_event_context(desktop); + + if (!ev) { + return; + } + + GrDrag *drag = ev->get_drag(); + + // First try selected dragger + if (drag && drag->selected) { + drag->selected_reverse_vector(); + } else { // If no drag or no dragger selected, act on selection (both fill and stroke gradients) + for (GSList const* i = selection->itemList(); i != NULL; i = i->next) { + if (fill_or_stroke == Inkscape::FOR_FILL_AND_STROKE) { + sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_FILL); + sp_item_gradient_reverse_vector(SP_ITEM(i->data), Inkscape::FOR_STROKE); + } else { + sp_item_gradient_reverse_vector(SP_ITEM(i->data), fill_or_stroke); + } + } + } + + // we did an undoable action + DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_GRADIENT, + _("Invert gradient")); +} + /* Local Variables: mode:c++ |
