From dfd48bd9b4e9c017a5045b202deb7d9dd514e5b4 Mon Sep 17 00:00:00 2001 From: Maximilian Albert Date: Fri, 17 Aug 2007 18:42:23 +0000 Subject: Enable center-dragging of boxes ('in perspective') within the XY-plane (bzr r3497) --- src/object-edit.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'src/object-edit.cpp') diff --git a/src/object-edit.cpp b/src/object-edit.cpp index 4467074d0..765f90303 100644 --- a/src/object-edit.cpp +++ b/src/object-edit.cpp @@ -648,6 +648,22 @@ static void sp_3dbox_knot_set(SPItem *item, guint knot_id, NR::Point const &new_ sp_3dbox_set_z_orders (box); } +static void sp_3dbox_knot_center_set(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) +{ + NR::Matrix const i2d (sp_item_i2d_affine (item)); + sp_3dbox_recompute_XY_corners_from_new_center (SP_3DBOX (item), new_pos * i2d); + + sp_3dbox_update_curves (SP_3DBOX(item)); +} + +static NR::Point sp_3dbox_knot_center_get(SPItem *item) +{ + NR::Maybe center = sp_3dbox_get_center(SP_3DBOX(item)); + if (!center) return NR::Point (0, 0); + NR::Matrix const i2d (sp_item_i2d_affine (item)); + return (*center) * i2d; +} + static void sp_3dbox_knot0_set(SPItem *item, NR::Point const &new_pos, NR::Point const &origin, guint state) { sp_3dbox_knot_set(item, 0, new_pos, origin, state); @@ -752,6 +768,11 @@ sp_3dbox_knot_holder(SPItem *item, SPDesktop *desktop) _("Resize box along the Z axis; with Shift in X/Y direction; with Ctrl to constrain to the directions of edges or diagonals")); sp_knot_holder_add(knot_holder, sp_3dbox_knot7_set, sp_3dbox_knot7_get, NULL, _("Resize box along the Z axis; with Shift in X/Y direction; with Ctrl to constrain to the directions of edges or diagonals")); + + // center dragging + sp_knot_holder_add_full(knot_holder, sp_3dbox_knot_center_set, sp_3dbox_knot_center_get, NULL, + SP_KNOT_SHAPE_CROSS, SP_KNOT_MODE_XOR,_("Move the box in perspective.")); + sp_pat_knot_holder(item, knot_holder); return knot_holder; -- cgit v1.2.3