diff options
| author | Bastien Bouclet <bastien.bouclet@gmail.com> | 2008-03-28 19:13:14 +0000 |
|---|---|---|
| committer | bgk <bgk@users.sourceforge.net> | 2008-03-28 19:13:14 +0000 |
| commit | 6ba273d25f2e2e2697d502eb9b56c10da96d7c1e (patch) | |
| tree | 33a74ec0fae6b19d0948ce84a49c350767c8be7d /src/ui | |
| parent | nr_matrix_inverse is no more, removed test from nr-matrix-test (diff) | |
| download | inkscape-6ba273d25f2e2e2697d502eb9b56c10da96d7c1e.tar.gz inkscape-6ba273d25f2e2e2697d502eb9b56c10da96d7c1e.zip | |
- Created a SPLPEItem class that handles applying a LPE to an Item
- LPEs can now be applied to groups
- Updated the bend path to work properly with groups
(bzr r5219)
Diffstat (limited to 'src/ui')
| -rw-r--r-- | src/ui/clipboard.cpp | 32 | ||||
| -rw-r--r-- | src/ui/dialog/livepatheffect-editor.cpp | 36 |
2 files changed, 25 insertions, 43 deletions
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp index 081657cf0..842f10d52 100644 --- a/src/ui/clipboard.cpp +++ b/src/ui/clipboard.cpp @@ -556,9 +556,12 @@ void ClipboardManagerImpl::_copyUsedDefs(SPItem *item) _copyNode(SP_OBJECT_REPR(SP_OBJECT(shape->marker[i])), _doc, _defs); } } - // Also copy live effects if applicable - if (sp_shape_has_path_effect(shape)) { - _copyNode(SP_OBJECT_REPR(SP_OBJECT(sp_shape_get_livepatheffectobject(shape))), _doc, _defs); + } + // For lpe items, copy liveeffect if applicable + if (SP_IS_LPE_ITEM(item)) { + SPLPEItem *lpeitem = SP_LPE_ITEM (item); + if (sp_lpe_item_has_path_effect(lpeitem)) { + _copyNode(SP_OBJECT_REPR(SP_OBJECT(sp_lpe_item_get_livepatheffectobject(lpeitem))), _doc, _defs); } } // For 3D boxes, copy perspectives @@ -887,31 +890,14 @@ void ClipboardManagerImpl::_applyPathEffect(SPItem *item, gchar const *effect) { if ( item == NULL ) return; - if (SP_IS_SHAPE(item)) + if (SP_IS_LPE_ITEM(item)) { - SPShape *shape = SP_SHAPE(item); + SPLPEItem *lpeitem = SP_LPE_ITEM(item); SPObject *obj = sp_uri_reference_resolve(_clipboardSPDoc, effect); if (!obj) return; // if the effect is not used by anyone, we might as well take it LivePathEffectObject *lpeobj = LIVEPATHEFFECT(obj)->fork_private_if_necessary(1); - sp_shape_set_path_effect(shape, lpeobj); - - // set inkscape:original-d for paths. the other shapes don't need this - if (SP_IS_PATH(item)) { - Inkscape::XML::Node *pathrepr = SP_OBJECT_REPR(item); - if (!pathrepr->attribute("inkscape:original-d")) { - pathrepr->setAttribute("inkscape:original-d", pathrepr->attribute("d")); - } - } - } - else if (SP_IS_GROUP(item)) - { - for (SPObject *child = sp_object_first_child(SP_OBJECT(item)) ; - child != NULL ; child = SP_OBJECT_NEXT(child)) - { - if (!SP_IS_ITEM(child)) continue; - _applyPathEffect(SP_ITEM(child), effect); - } + sp_lpe_item_set_path_effect(lpeitem, lpeobj); } } diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index 29ec03a8c..2394adc6f 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -3,6 +3,8 @@ * * Authors: * Johan Engelen <j.b.c.engelen@utwente.nl> + * Steren Giannini <steren.giannini@gmail.com> + * Bastien Bouclet <bgkweb@gmail.com> * * Copyright (C) 2007 Author * @@ -18,6 +20,7 @@ #include "verbs.h" #include "selection.h" #include "sp-shape.h" +#include "sp-item-group.h" #include "sp-path.h" #include "live_effects/effect.h" #include "live_effects/lpeobject.h" @@ -150,9 +153,9 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel) if ( sel && !sel->isEmpty() ) { SPItem *item = sel->singleItem(); if ( item ) { - if ( SP_IS_SHAPE(item) ) { - SPShape *shape = SP_SHAPE(item); - LivePathEffectObject *lpeobj = sp_shape_get_livepatheffectobject(shape); + if ( SP_IS_LPE_ITEM(item) ) { + SPLPEItem *lpeitem = SP_LPE_ITEM(item); + LivePathEffectObject *lpeobj = sp_lpe_item_get_livepatheffectobject(lpeitem); set_sensitize_all(true); if (lpeobj) { if (lpeobj->lpe) { @@ -164,8 +167,10 @@ LivePathEffectEditor::onSelectionChanged(Inkscape::Selection *sel) showText(_("No effect applied")); button_remove.set_sensitive(false); } - } else { - showText(_("Item is not a shape or path")); + } + else + { + showText(_("Item is not compound by paths")); set_sensitize_all(false); } } else { @@ -218,12 +223,13 @@ LivePathEffectEditor::onApply() Inkscape::Selection *sel = _getSelection(); if ( sel && !sel->isEmpty() ) { SPItem *item = sel->singleItem(); - if ( item && SP_IS_SHAPE(item) ) { + if ( item && SP_IS_LPE_ITEM(item) ) { SPDocument *doc = current_desktop->doc(); const Util::EnumData<LivePathEffect::EffectType>* data = combo_effecttype.get_active_data(); if (!data) return; + // Path effect definition Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc); Inkscape::XML::Node *repr = xml_doc->createElement("inkscape:path-effect"); repr->setAttribute("effect", data->key.c_str() ); @@ -233,18 +239,10 @@ LivePathEffectEditor::onApply() Inkscape::GC::release(repr); gchar *href = g_strdup_printf("#%s", repr_id); - sp_shape_set_path_effect(SP_SHAPE(item), href); + sp_lpe_item_set_path_effect(SP_LPE_ITEM(item), href); g_free(href); - // make sure there is an original-d for paths!!! - if ( SP_IS_PATH(item) ) { - Inkscape::XML::Node *pathrepr = SP_OBJECT_REPR(item); - if ( ! pathrepr->attribute("inkscape:original-d") ) { - pathrepr->setAttribute("inkscape:original-d", pathrepr->attribute("d")); - } - } - - LivePathEffectObject *lpeobj = sp_shape_get_livepatheffectobject(SP_SHAPE(item)); + LivePathEffectObject *lpeobj = sp_lpe_item_get_livepatheffectobject(SP_LPE_ITEM(item)); if (lpeobj && lpeobj->lpe) { lpeobj->lpe->resetDefaults(item); } @@ -263,8 +261,8 @@ LivePathEffectEditor::onRemove() Inkscape::Selection *sel = _getSelection(); if ( sel && !sel->isEmpty() ) { SPItem *item = sel->singleItem(); - if ( item && SP_IS_SHAPE(item) ) { - sp_shape_remove_path_effect(SP_SHAPE(item)); + if ( item && SP_IS_LPE_ITEM(item) ) { + sp_lpe_item_remove_path_effect(SP_LPE_ITEM(item), false); showText(_("No effect applied")); button_remove.set_sensitive(false); sp_document_done ( sp_desktop_document (current_desktop), SP_VERB_DIALOG_LIVE_PATH_EFFECT, @@ -273,8 +271,6 @@ LivePathEffectEditor::onRemove() } } - - } // namespace Dialog } // namespace UI } // namespace Inkscape |
