Code

Removed use of union in paint type/struct
[inkscape.git] / src / sp-shape.cpp
index a38a10b4d954286dcd4cd1f79f2c346463d0bc3e..a37da6840540274e02e0cb98772ee84d3fa80ab9 100644 (file)
@@ -88,19 +88,19 @@ sp_shape_get_type (void)
 static void
 sp_shape_class_init (SPShapeClass *klass)
 {
-        GObjectClass *gobject_class;
+    GObjectClass *gobject_class;
        SPObjectClass *sp_object_class;
        SPItemClass * item_class;
        SPPathClass * path_class;
 
-        gobject_class = (GObjectClass *) klass;
+    gobject_class = (GObjectClass *) klass;
        sp_object_class = (SPObjectClass *) klass;
        item_class = (SPItemClass *) klass;
        path_class = (SPPathClass *) klass;
 
        parent_class = (SPItemClass *)g_type_class_peek_parent (klass);
 
-        gobject_class->finalize = sp_shape_finalize;
+    gobject_class->finalize = sp_shape_finalize;
 
        sp_object_class->build = sp_shape_build;
        sp_object_class->release = sp_shape_release;
@@ -111,7 +111,7 @@ sp_shape_class_init (SPShapeClass *klass)
        item_class->print = sp_shape_print;
        item_class->show = sp_shape_show;
        item_class->hide = sp_shape_hide;
-        item_class->snappoints = sp_shape_snappoints;
+    item_class->snappoints = sp_shape_snappoints;
 }
 
 /**
@@ -238,13 +238,15 @@ sp_shape_update (SPObject *object, SPCtx *ctx, unsigned int flags)
        if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_PARENT_MODIFIED_FLAG)) {
                /* This is suboptimal, because changing parent style schedules recalculation */
                /* But on the other hand - how can we know that parent does not tie style and transform */
-                NR::Rect const paintbox = SP_ITEM(object)->invokeBbox(NR::identity());
+                NR::Maybe<NR::Rect> paintbox = SP_ITEM(object)->getBounds(NR::identity());
                for (SPItemView *v = SP_ITEM (shape)->display; v != NULL; v = v->next) {
                     NRArenaShape * const s = NR_ARENA_SHAPE(v->arenaitem);
                     if (flags & SP_OBJECT_MODIFIED_FLAG) {
                         nr_arena_shape_set_path(s, shape->curve, (flags & SP_OBJECT_USER_MODIFIED_FLAG_B));
                     }
-                    s->setPaintBox(paintbox);
+                    if (paintbox) {
+                        s->setPaintBox(*paintbox);
+                    }
                }
        }
 
@@ -753,8 +755,10 @@ sp_shape_show (SPItem *item, NRArena *arena, unsigned int key, unsigned int flag
         NRArenaShape * const s = NR_ARENA_SHAPE(arenaitem);
        nr_arena_shape_set_style(s, object->style);
        nr_arena_shape_set_path(s, shape->curve, false);
-        NR::Rect const paintbox = item->invokeBbox(NR::identity());
-        s->setPaintBox(paintbox);
+        NR::Maybe<NR::Rect> paintbox = item->getBounds(NR::identity());
+        if (paintbox) {
+            s->setPaintBox(*paintbox);
+        }
 
         if (sp_shape_has_markers (shape)) {
 
@@ -1018,6 +1022,10 @@ static void sp_shape_snappoints(SPItem const *item, SnapPointsIter p)
         *p = bp->c(3) * i2d;
         bp++;
     }
+    
+    // Additionaly, add the center for snapping
+    *p = shape->getCenter();
+    
 }