diff --git a/src/star-context.cpp b/src/star-context.cpp
index 6e10a03fad6e8af044f9d7efa0931d47225961f0..c5fa5a0b975ce3907be51ad74e66e269de4da3e8 100644 (file)
--- a/src/star-context.cpp
+++ b/src/star-context.cpp
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "config.h"
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#include <cstring>
+#include <string>
#include <gdk/gdkkeysyms.h>
sc->sel_changed_connection.~connection();
if (ec->shape_knot_holder) {
- sp_knot_holder_destroy (ec->shape_knot_holder);
+ delete ec->shape_knot_holder;
ec->shape_knot_holder = NULL;
}
@@ -169,7 +174,7 @@ sp_star_context_selection_changed (Inkscape::Selection * selection, gpointer dat
SPEventContext *ec = SP_EVENT_CONTEXT (sc);
if (ec->shape_knot_holder) { // desktroy knotholder
- sp_knot_holder_destroy (ec->shape_knot_holder);
+ delete ec->shape_knot_holder;
ec->shape_knot_holder = NULL;
}
@@ -269,14 +274,16 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
switch (event->type) {
case GDK_BUTTON_PRESS:
- if (event->button.button == 1) {
+ if (event->button.button == 1 && !event_context->space_panning) {
dragging = TRUE;
sc->center = Inkscape::setup_for_drag_start(desktop, event_context, event);
-
- SnapManager const m(desktop->namedview);
- sc->center = m.freeSnap(Inkscape::Snapper::SNAP_POINT, sc->center, sc->item).getPoint();
+
+ /* Snap center */
+ SnapManager &m = desktop->namedview->snap_manager;
+ m.setup(desktop, NULL); //null, because we don't have an item yet
+ m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, sc->center);
sp_canvas_item_grab(SP_CANVAS_ITEM(desktop->acetate),
GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
@@ -286,7 +293,7 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
}
break;
case GDK_MOTION_NOTIFY:
- if (dragging && (event->motion.state & GDK_BUTTON1_MASK)) {
+ if (dragging && (event->motion.state & GDK_BUTTON1_MASK) && !event_context->space_panning) {
if ( event_context->within_tolerance
&& ( abs( (gint) event->motion.x - event_context->xp ) < event_context->tolerance )
@@ -299,14 +306,18 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
event_context->within_tolerance = false;
NR::Point const motion_w(event->motion.x, event->motion.y);
- NR::Point const motion_dt(event_context->desktop->w2d(motion_w));
+ NR::Point motion_dt(desktop->w2d(motion_w));
+
sp_star_drag (sc, motion_dt, event->motion.state);
+
+ gobble_motion_events(GDK_BUTTON1_MASK);
+
ret = TRUE;
}
break;
case GDK_BUTTON_RELEASE:
event_context->xp = event_context->yp = 0;
- if (event->button.button == 1) {
+ if (event->button.button == 1 && !event_context->space_panning) {
dragging = FALSE;
if (!event_context->within_tolerance) {
// we've been dragging, finish the star
@@ -360,6 +371,21 @@ static gint sp_star_context_root_handler(SPEventContext *event_context, GdkEvent
case GDK_Escape:
sp_desktop_selection(desktop)->clear();
//TODO: make dragging escapable by Esc
+ break;
+
+ case GDK_space:
+ if (dragging) {
+ sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate),
+ event->button.time);
+ dragging = false;
+ if (!event_context->within_tolerance) {
+ // we've been dragging, finish the rect
+ sp_star_finish(sc);
+ }
+ // do not return true, so that space would work switching to selector
+ }
+ break;
+
default:
break;
}
}
/* Create object */
- Inkscape::XML::Node *repr = sp_repr_new("svg:path");
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(SP_EVENT_CONTEXT_DOCUMENT(sc));
+ Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
repr->setAttribute("sodipodi:type", "star");
/* Set style */
Inkscape::GC::release(repr);
sc->item->transform = SP_ITEM(desktop->currentRoot())->getRelativeTransform(desktop->currentLayer());
sc->item->updateRepr();
+
+ sp_canvas_force_full_redraw_after_interruptions(desktop->canvas, 5);
}
+ /* Snap corner point with no constraints */
+ SnapManager &m = desktop->namedview->snap_manager;
+ m.setup(desktop, sc->item);
+ m.freeSnapReturnByRef(Inkscape::Snapper::SNAPPOINT_NODE, p);
+
NR::Point const p0 = sp_desktop_dt2root_xy_point(desktop, sc->center);
NR::Point p1 = sp_desktop_dt2root_xy_point(desktop, p);
-
- /* Snap corner point with no constraints */
- SnapManager const m(desktop->namedview);;
- p1 = m.freeSnap(Inkscape::Snapper::SNAP_POINT, p1, sc->item).getPoint();
-
+
SPStar *star = SP_STAR(sc->item);
double const sides = (gdouble) sc->magnitude;
/* status text */
GString *rads = SP_PX_TO_METRIC_STRING(r1, desktop->namedview->getDefaultMetric());
- sc->_message_context->setF(Inkscape::NORMAL_MESSAGE,
+ sc->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE,
( sc->isflatsided?
_("<b>Polygon</b>: radius %s, angle %5g°; with <b>Ctrl</b> to snap angle")
: _("<b>Star</b>: radius %s, angle %5g°; with <b>Ctrl</b> to snap angle") ),
sp_shape_set_shape(SP_SHAPE(sc->item));
- object->updateRepr(NULL, SP_OBJECT_WRITE_EXT);
+ object->updateRepr(SP_OBJECT_WRITE_EXT);
+
+ sp_canvas_end_forced_full_redraws(desktop->canvas);
sp_desktop_selection(desktop)->set(sc->item);
- sp_document_done(sp_desktop_document(desktop));
+ sp_document_done(sp_desktop_document(desktop), SP_VERB_CONTEXT_STAR,
+ _("Create star"));
sc->item = NULL;
}