Code

Added skeleton files for other filter primitives' SP-objects. Added blur slider on...
[inkscape.git] / src / sp-item-group.cpp
index 3ce551b983199f763841b7acdaaa622dbfa0be80..0f7031f56c9fe4f15ad0c0e9631d2e3bfbd3d452 100644 (file)
@@ -17,9 +17,7 @@
 # include "config.h"
 #endif
 
-#if defined(WIN32) || defined(__APPLE__)
-# include <glibmm/i18n.h>
-#endif
+#include <glibmm/i18n.h>
 
 #include "display/nr-arena-group.h"
 #include "libnr/nr-matrix-ops.h"
@@ -29,6 +27,7 @@
 #include "document.h"
 #include "style.h"
 #include "attributes.h"
+#include "sp-item-transform.h"
 
 #include "sp-root.h"
 #include "sp-use.h"
@@ -445,7 +444,8 @@ sp_item_group_ungroup (SPGroup *group, GSList **children, bool do_done)
                items = g_slist_remove (items, items->data);
        }
 
-       if (do_done) sp_document_done (doc);
+       if (do_done) sp_document_done (doc, SP_VERB_NONE, 
+                                      /* TODO: annotate */ "sp-item-group.cpp:448");
 }
 
 /*
@@ -524,6 +524,19 @@ void SPGroup::_updateLayerMode(unsigned int display_key) {
        }
 }
 
+void SPGroup::translateChildItems(NR::translate const &tr)
+{
+       if (this->hasChildren())
+       {
+               SPObject *o = NULL;
+               for (o = sp_object_first_child(SP_OBJECT(this)) ; o != NULL ; o = SP_OBJECT_NEXT(o) ) {
+                       if (SP_IS_ITEM (o)) {
+                               sp_item_move_rel(static_cast<SPItem *>(o), tr);
+                       }
+               }
+       }
+}
+
 CGroup::CGroup(SPGroup *group) {
     _group = group;
 }
@@ -579,18 +592,27 @@ void CGroup::onChildRemoved(Inkscape::XML::Node */*child*/) {
 }
 
 void CGroup::onUpdate(SPCtx *ctx, unsigned int flags) {    
-    SPObject *child;
     SPItemCtx *ictx, cctx;
 
     ictx = (SPItemCtx *) ctx;
     cctx = *ictx;
 
-    if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
+    if (flags & SP_OBJECT_MODIFIED_FLAG) {
+      flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
+    }
+
     flags &= SP_OBJECT_MODIFIED_CASCADE;
 
-    GSList *l = g_slist_reverse(_childList(true, ActionUpdate));
+    if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) {
+      SPObject *object = SP_OBJECT(_group);
+      for (SPItemView *v = SP_ITEM(_group)->display; v != NULL; v = v->next) {
+       nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
+      }
+    }
+
+    GSList *l = g_slist_reverse(_group->childList(true, SPObject::ActionUpdate));
     while (l) {
-        child = SP_OBJECT (l->data);
+        SPObject *child = SP_OBJECT (l->data);
         l = g_slist_remove (l, child);
         if (flags || (child->uflags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_CHILD_MODIFIED_FLAG))) {
             if (SP_IS_ITEM (child)) {
@@ -606,24 +628,20 @@ void CGroup::onUpdate(SPCtx *ctx, unsigned int flags) {
     }
 }
 
-GSList *CGroup::_childList(bool add_ref, Action) {
-    GSList *l = NULL;
-    for (SPObject *child = sp_object_first_child(_group) ; child != NULL ; child = SP_OBJECT_NEXT(child) ) {
-        if (add_ref)
-            g_object_ref (G_OBJECT (child));
-
-        l = g_slist_prepend (l, child);
-    }
-    return l;
-}
-
 void CGroup::onModified(guint flags) {
     SPObject *child;
 
     if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
     flags &= SP_OBJECT_MODIFIED_CASCADE;
 
-    GSList *l = g_slist_reverse(_childList(true));
+    if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) {
+      SPObject *object = SP_OBJECT(_group);
+      for (SPItemView *v = SP_ITEM(_group)->display; v != NULL; v = v->next) {
+       nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
+      }
+    }
+
+    GSList *l = g_slist_reverse(_group->childList(true));
     while (l) {
         child = SP_OBJECT (l->data);
         l = g_slist_remove (l, child);
@@ -635,7 +653,7 @@ void CGroup::onModified(guint flags) {
 }
 
 void CGroup::calculateBBox(NRRect *bbox, NR::Matrix const &transform, unsigned const flags) {
-    GSList *l = _childList(false, ActionBBox);
+    GSList *l = _group->childList(false, SPObject::ActionBBox);
     while (l) {
         SPObject *o = SP_OBJECT (l->data);
         if (SP_IS_ITEM(o)) {
@@ -648,7 +666,7 @@ void CGroup::calculateBBox(NRRect *bbox, NR::Matrix const &transform, unsigned c
 }
 
 void CGroup::onPrint(SPPrintContext *ctx) {
-    GSList *l = _childList(false);
+    GSList *l = g_slist_reverse(_group->childList(false));
     while (l) {
         SPObject *o = SP_OBJECT (l->data);
         if (SP_IS_ITEM(o)) {
@@ -679,11 +697,14 @@ gchar *CGroup::getDescription() {
 
 NRArenaItem *CGroup::show (NRArena *arena, unsigned int key, unsigned int flags) {
     NRArenaItem *ai;
+    SPObject *object = SP_OBJECT(_group);
 
     ai = NRArenaGroup::create(arena);
+
     nr_arena_group_set_transparent(NR_ARENA_GROUP (ai),
                                    _group->effectiveLayerMode(key) ==
                          SPGroup::LAYER);
+    nr_arena_group_set_style(NR_ARENA_GROUP(ai), SP_OBJECT_STYLE(object));
 
     _showChildren(arena, ai, key, flags);
     return ai;
@@ -693,7 +714,7 @@ void CGroup::_showChildren (NRArena *arena, NRArenaItem *ai, unsigned int key, u
     NRArenaItem *ac = NULL;
     NRArenaItem *ar = NULL;
     SPItem * child = NULL;
-    GSList *l = _childList(false, ActionShow);
+    GSList *l = g_slist_reverse(_group->childList(false, SPObject::ActionShow));
     while (l) {
         SPObject *o = SP_OBJECT (l->data);
         if (SP_IS_ITEM (o)) {
@@ -712,7 +733,7 @@ void CGroup::_showChildren (NRArena *arena, NRArenaItem *ai, unsigned int key, u
 void CGroup::hide (unsigned int key) {
     SPItem * child;
 
-    GSList *l = _childList(false, ActionShow);
+    GSList *l = g_slist_reverse(_group->childList(false, SPObject::ActionShow));
     while (l) {
         SPObject *o = SP_OBJECT (l->data);
         if (SP_IS_ITEM (o)) {