diff options
| author | John Smith <john.smith7545@yahoo.com> | 2012-07-05 00:35:33 +0000 |
|---|---|---|
| committer | John Smith <john.smith7545@yahoo.com> | 2012-07-05 00:35:33 +0000 |
| commit | 23b6b126c73efed2f651727f5f0c5763de3fd57c (patch) | |
| tree | 891a930cb4379c9d76e668815ce9a872c8422f50 /src/sp-item.cpp | |
| parent | Fix for 168658 : Font substitution warning dialog - GTK3 compile (diff) | |
| download | inkscape-23b6b126c73efed2f651727f5f0c5763de3fd57c.tar.gz inkscape-23b6b126c73efed2f651727f5f0c5763de3fd57c.zip | |
Fix for 181473 : Layers drag and drop
(bzr r11526)
Diffstat (limited to 'src/sp-item.cpp')
| -rw-r--r-- | src/sp-item.cpp | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/sp-item.cpp b/src/sp-item.cpp index d182c7d07..9f50e5e0c 100644 --- a/src/sp-item.cpp +++ b/src/sp-item.cpp @@ -368,6 +368,52 @@ void SPItem::lowerToBottom() { } } +/* + * Move this SPItem into or after another SPItem in the doc + * \param target - the SPItem to move into or after + * \param intoafter - move to after the target (false), move inside (sublayer) of the target (true) + */ +void SPItem::moveTo(SPItem *target, gboolean intoafter) { + + Inkscape::XML::Node *target_ref = ( target ? target->getRepr() : NULL ); + Inkscape::XML::Node *our_ref = getRepr(); + gboolean first = FALSE; + + if (target_ref == our_ref) { + // Move to ourself ignore + return; + } + + if (!target_ref) { + // Assume move to the "first" in the top node, find the top node + target_ref = our_ref; + while (target_ref->parent() != target_ref->root()) { + target_ref = target_ref->parent(); + } + first = TRUE; + } + + if (intoafter) { + // Move this inside of the target at the end + our_ref->parent()->removeChild(our_ref); + target_ref->addChild(our_ref, NULL); + } else if (target_ref->parent() != our_ref->parent()) { + // Change in parent, need to remove and add + our_ref->parent()->removeChild(our_ref); + target_ref->parent()->addChild(our_ref, target_ref); + } else if (!first) { + // Same parent, just move + our_ref->parent()->changeOrder(our_ref, target_ref); + } + + if (first) { + // If "first" ensure it appears after the defs etc + lowerToBottom(); + return; + } +} + + void SPItem::sp_item_build(SPObject *object, SPDocument *document, Inkscape::XML::Node *repr) { object->readAttr( "style" ); |
