Logo Search packages:      
Sourcecode: inkscape version File versions

void sp_object_reorder ( SPObject object,
SPObject prev 
)

In list of object's siblings, move object behind prev.

Definition at line 599 of file sp-object.cpp.

References SPObject::_last_child, SPObject::children, SPObject::next, and SPObject::parent.

Referenced by sp_object_order_changed().

                                                    {
    g_return_if_fail(object != NULL);
    g_return_if_fail(SP_IS_OBJECT(object));
    g_return_if_fail(object->parent != NULL);
    g_return_if_fail(object != prev);
    g_return_if_fail(!prev || SP_IS_OBJECT(prev));
    g_return_if_fail(!prev || prev->parent == object->parent);

    SPObject *const parent=object->parent;

    SPObject *old_prev=NULL;
    for ( SPObject *child = parent->children ; child && child != object ;
          child = child->next )
    {
        old_prev = child;
    }

    SPObject *next=object->next;
    if (old_prev) {
        old_prev->next = next;
    } else {
        parent->children = next;
    }
    if (!next) {
        parent->_last_child = old_prev;
    }
    if (prev) {
        next = prev->next;
        prev->next = object;
    } else {
        next = parent->children;
        parent->children = object;
    }
    object->next = next;
    if (!next) {
        parent->_last_child = object;
    }
}


Generated by  Doxygen 1.6.0   Back to index