diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index 153d1fa517a4496b28961eb87f767f8cc26682d8..a37da6840540274e02e0cb98772ee84d3fa80ab9 100644 (file)
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
#include <libnr/nr-matrix-translate-ops.h>
#include <libnr/nr-scale-matrix-ops.h>
+#include <sigc++/functors/ptr_fun.h>
+#include <sigc++/adaptors/bind.h>
#include "macros.h"
#include "display/nr-arena-shape.h"
#include "print.h"
#include "document.h"
-#include "marker-status.h"
#include "style.h"
-#include "sp-marker.h"
+#include "marker.h"
#include "sp-path.h"
#include "prefs-utils.h"
static void sp_shape_class_init (SPShapeClass *klass);
static void sp_shape_init (SPShape *shape);
+static void sp_shape_finalize (GObject *object);
static void sp_shape_build (SPObject * object, SPDocument * document, Inkscape::XML::Node * repr);
static void sp_shape_release (SPObject *object);
static void
sp_shape_class_init (SPShapeClass *klass)
{
+ GObjectClass *gobject_class;
SPObjectClass *sp_object_class;
SPItemClass * item_class;
SPPathClass * path_class;
+ 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;
+
sp_object_class->build = sp_shape_build;
sp_object_class->release = sp_shape_release;
sp_object_class->update = sp_shape_update;
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;
}
/**
- * Initializes an SPShape object. Nothing particular is needed to initialize
- * an SPShape object; this is just here as a stub.
+ * Initializes an SPShape object.
*/
static void
sp_shape_init (SPShape *shape)
{
- /* Nothing here */
+ for ( int i = 0 ; i < SP_MARKER_LOC_QTY ; i++ ) {
+ new (&shape->release_connect[i]) sigc::connection();
+ new (&shape->modified_connect[i]) sigc::connection();
+ }
+}
+
+static void
+sp_shape_finalize (GObject *object)
+{
+ SPShape *shape=(SPShape *)object;
+
+ for ( int i = 0 ; i < SP_MARKER_LOC_QTY ; i++ ) {
+ shape->release_connect[i].disconnect();
+ shape->release_connect[i].~connection();
+ shape->modified_connect[i].disconnect();
+ shape->modified_connect[i].~connection();
+ }
+
+ if (((GObjectClass *) (parent_class))->finalize) {
+ (* ((GObjectClass *) (parent_class))->finalize)(object);
+ }
}
/**
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);
+ }
}
}
{
SPStyle *style = ((SPObject *) shape)->style;
- marker_status("sp_shape_update_marker_view: Updating views of markers");
-
for (int i = SP_MARKER_LOC_START; i < SP_MARKER_LOC_QTY; i++) {
if (shape->marker[i] == NULL) {
continue;
@@ -730,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)) {
item = (SPItem *) shape;
- marker_status("sp_shape_marker_release: Releasing markers");
for (i = SP_MARKER_LOC_START; i < SP_MARKER_LOC_QTY; i++) {
if (marker == shape->marker[i]) {
SPItemView *v;
SPItemView *v;
/* Detach marker */
- g_signal_handler_disconnect (shape->marker[key], shape->release_connect[key]);
- g_signal_handler_disconnect (shape->marker[key], shape->modified_connect[key]);
+ shape->release_connect[key].disconnect();
+ shape->modified_connect[key].disconnect();
/* Hide marker */
for (v = item->display; v != NULL; v = v->next) {
}
if (SP_IS_MARKER (mrk)) {
shape->marker[key] = sp_object_href (mrk, object);
- shape->release_connect[key] = g_signal_connect (G_OBJECT (shape->marker[key]), "release",
- G_CALLBACK (sp_shape_marker_release), shape);
- shape->modified_connect[key] = g_signal_connect (G_OBJECT (shape->marker[key]), "modified",
- G_CALLBACK (sp_shape_marker_modified), shape);
+ shape->release_connect[key] = mrk->connectRelease(sigc::bind<1>(sigc::ptr_fun(&sp_shape_marker_release), shape));
+ shape->modified_connect[key] = mrk->connectModified(sigc::bind<2>(sigc::ptr_fun(&sp_shape_marker_modified), shape));
}
}
}
*p = bp->c(3) * i2d;
bp++;
}
+
+ // Additionaly, add the center for snapping
+ *p = shape->getCenter();
+
}