Code

change API: separate functions creating a blur filter, one for a given item, another...
[inkscape.git] / src / sp-use.cpp
index 3a55331a049f25d3c7e2dd8090bef30356ba0e5a..ae4e9f61a2c451e21f7413115cc073ecdd0cabfd 100644 (file)
@@ -26,6 +26,7 @@
 #include "sp-object-repr.h"
 #include "sp-flowregion.h"
 #include "uri.h"
+#include "print.h"
 #include "xml/repr.h"
 #include "prefs-utils.h"
 #include "style.h"
@@ -279,11 +280,23 @@ sp_use_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsig
 static void
 sp_use_print(SPItem *item, SPPrintContext *ctx)
 {
+    bool translated = false;
+    NRMatrix tp;
     SPUse *use = SP_USE(item);
 
+    if ((use->x._set && use->x.computed != 0) || (use->y._set && use->y.computed != 0)) {
+        nr_matrix_set_translate(&tp, use->x.computed, use->y.computed);
+        sp_print_bind(ctx, &tp, 1.0);
+        translated = true;
+    }
+
     if (use->child && SP_IS_ITEM(use->child)) {
         sp_item_invoke_print(SP_ITEM(use->child), ctx);
     }
+
+    if (translated) {
+        sp_print_release(ctx);
+    }
 }
 
 static gchar *
@@ -294,7 +307,7 @@ sp_use_description(SPItem *item)
     char *ret;
     if (use->child) {
         static unsigned recursion_depth = 0;
-        if (recursion_depth >= 2) {
+        if (recursion_depth >= 4) {
             /* TRANSLATORS: Used for statusbar description for long <use> chains:
              * "Clone of: Clone of: ... in Layer 1". */
             return g_strdup(_("..."));
@@ -320,6 +333,7 @@ sp_use_show(SPItem *item, NRArena *arena, unsigned key, unsigned flags)
 
     NRArenaItem *ai = NRArenaGroup::create(arena);
     nr_arena_group_set_transparent(NR_ARENA_GROUP(ai), FALSE);
+    nr_arena_group_set_style(NR_ARENA_GROUP(ai), SP_OBJECT_STYLE(item));
 
     if (use->child) {
         NRArenaItem *ac = sp_item_invoke_show(SP_ITEM(use->child), arena, key, flags);
@@ -553,6 +567,12 @@ sp_use_update(SPObject *object, SPCtx *ctx, unsigned flags)
     if (flags & SP_OBJECT_MODIFIED_FLAG) flags |= SP_OBJECT_PARENT_MODIFIED_FLAG;
     flags &= SP_OBJECT_MODIFIED_CASCADE;
 
+    if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) {
+      for (SPItemView *v = SP_ITEM(object)->display; v != NULL; v = v->next) {
+       nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
+      }
+    }
+
     /* Set up child viewport */
     if (use->x.unit == SVGLength::PERCENT) {
         use->x.computed = use->x.value * (ictx->vp.x1 - ictx->vp.x0);
@@ -606,6 +626,12 @@ sp_use_modified(SPObject *object, guint flags)
     }
     flags &= SP_OBJECT_MODIFIED_CASCADE;
 
+    if (flags & SP_OBJECT_STYLE_MODIFIED_FLAG) {
+      for (SPItemView *v = SP_ITEM(object)->display; v != NULL; v = v->next) {
+       nr_arena_group_set_style(NR_ARENA_GROUP(v->arenaitem), SP_OBJECT_STYLE(object));
+      }
+    }
+
     SPObject *child = use_obj->child;
     if (child) {
         g_object_ref(G_OBJECT(child));