diff --git a/src/box3d-context.cpp b/src/box3d-context.cpp
index 404723231d80bf4bc4309f9e11b81528fd776695..2b76233f5c5cdf3d88a1eb62ec01bfef760081d4 100644 (file)
--- a/src/box3d-context.cpp
+++ b/src/box3d-context.cpp
#include "box3d-side.h"
#include "document-private.h"
#include "line-geometry.h"
+#include "shape-editor.h"
static void sp_box3d_context_class_init(Box3DContextClass *klass);
static void sp_box3d_context_init(Box3DContext *box3d_context);
event_context->within_tolerance = false;
event_context->item_to_select = NULL;
- event_context->shape_repr = NULL;
- event_context->shape_knot_holder = NULL;
-
box3d_context->item = NULL;
box3d_context->ctrl_dragged = false;
box3d_context->extruded = false;
-
+
box3d_context->_vpdrag = NULL;
new (&box3d_context->sel_changed_connection) sigc::connection();
bc->sel_changed_connection.disconnect();
bc->sel_changed_connection.~connection();
+ delete ec->shape_editor;
+ ec->shape_editor = NULL;
+
/* fixme: This is necessary because we do not grab */
if (bc->item) {
sp_box3d_finish(bc);
}
- if (ec->shape_knot_holder) {
- delete ec->shape_knot_holder;
- ec->shape_knot_holder = NULL;
- }
-
- if (ec->shape_repr) { // remove old listener
- sp_repr_remove_listener_by_data(ec->shape_repr, ec);
- Inkscape::GC::release(ec->shape_repr);
- ec->shape_repr = 0;
- }
-
if (bc->_message_context) {
delete bc->_message_context;
}
G_OBJECT_CLASS(parent_class)->dispose(object);
}
-static Inkscape::XML::NodeEventVector ec_shape_repr_events = {
- NULL, /* child_added */
- NULL, /* child_removed */
- ec_shape_event_attr_changed,
- NULL, /* content_changed */
- NULL /* order_changed */
-};
-
/**
\brief Callback that processes the "changed" signal on the selection;
destroys old and creates new knotholder
@@ -174,27 +156,9 @@ static void sp_box3d_context_selection_changed(Inkscape::Selection *selection, g
Box3DContext *bc = SP_BOX3D_CONTEXT(data);
SPEventContext *ec = SP_EVENT_CONTEXT(bc);
- if (ec->shape_knot_holder) { // destroy knotholder
- delete ec->shape_knot_holder;
- ec->shape_knot_holder = NULL;
- }
-
- if (ec->shape_repr) { // remove old listener
- sp_repr_remove_listener_by_data(ec->shape_repr, ec);
- Inkscape::GC::release(ec->shape_repr);
- ec->shape_repr = 0;
- }
-
+ ec->shape_editor->unset_item(SH_KNOTHOLDER);
SPItem *item = selection->singleItem();
- if (item) {
- ec->shape_knot_holder = sp_item_knot_holder(item, ec->desktop);
- Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(item);
- if (shape_repr) {
- ec->shape_repr = shape_repr;
- Inkscape::GC::anchor(shape_repr);
- sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec);
- }
- }
+ ec->shape_editor->set_item(item, SH_KNOTHOLDER);
if (selection->perspList().size() == 1) {
// selecting a single box changes the current perspective
@@ -203,7 +167,7 @@ static void sp_box3d_context_selection_changed(Inkscape::Selection *selection, g
}
/* create a default perspective in document defs if none is present
- (can happen after 'vacuum defs' or when a pre-0.46 file is opened) */
+ (can happen after 'vacuum defs' or when a pre-0.46 file is opened) */
static void sp_box3d_context_check_for_persp_in_defs(SPDocument *document) {
SPDefs *defs = (SPDefs *) SP_DOCUMENT_DEFS(document);
sp_box3d_context_check_for_persp_in_defs(sp_desktop_document (ec->desktop));
+ ec->shape_editor = new ShapeEditor(ec->desktop);
+
SPItem *item = sp_desktop_selection(ec->desktop)->singleItem();
if (item) {
- ec->shape_knot_holder = sp_item_knot_holder(item, ec->desktop);
- Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(item);
- if (shape_repr) {
- ec->shape_repr = shape_repr;
- Inkscape::GC::anchor(shape_repr);
- sp_repr_add_listener(shape_repr, &ec_shape_repr_events, ec);
- }
+ ec->shape_editor->set_item(item, SH_KNOTHOLDER);
}
bc->sel_changed_connection.disconnect();
@@ -311,12 +271,13 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
event_context->xp = (gint) button_w[Geom::X];
event_context->yp = (gint) button_w[Geom::Y];
event_context->within_tolerance = true;
-
+
// remember clicked item, *not* disregarding groups (since a 3D box is a group), honoring Alt
event_context->item_to_select = sp_event_context_find_item (desktop, button_w, event->button.state & GDK_MOD1_MASK, event->button.state & GDK_CONTROL_MASK);
dragging = true;
-
+ sp_canvas_set_snap_delay_active(desktop->canvas, true);
+
/* */
Geom::Point button_dt(desktop->w2d(button_w));
bc->drag_origin = from_2geom(button_dt);
@@ -412,6 +373,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
event_context->xp = event_context->yp = 0;
if ( event->button.button == 1 && !event_context->space_panning) {
dragging = false;
+ sp_canvas_set_snap_delay_active(desktop->canvas, false);
if (!event_context->within_tolerance) {
// we've been dragging, finish the box
@@ -544,6 +506,7 @@ static gint sp_box3d_context_root_handler(SPEventContext *event_context, GdkEven
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
event->button.time);
dragging = false;
+ sp_canvas_set_snap_delay_active(desktop->canvas, false);
if (!event_context->within_tolerance) {
// we've been dragging, finish the box
sp_box3d_finish(bc);