diff --git a/src/draw-context.cpp b/src/draw-context.cpp
index 0cb408293decefe06134213148c046793cbaa997..43e028aa5655032071f821e2c089a40e58b623e8 100644 (file)
--- a/src/draw-context.cpp
+++ b/src/draw-context.cpp
#include "selection-chemistry.h"
#include "snap.h"
#include "sp-path.h"
-
+#include "sp-namedview.h"
static void sp_draw_context_class_init(SPDrawContextClass *klass);
static void sp_draw_context_init(SPDrawContext *dc);
((SPEventContextClass *) draw_parent_class)->setup(ec);
}
- dc->selection = SP_DT_SELECTION(dt);
+ dc->selection = sp_desktop_selection(dt);
/* Connect signals to track selection changes */
dc->sel_changed_connection = dc->selection->connectChanged(
);
/* Create red bpath */
- dc->red_bpath = sp_canvas_bpath_new(SP_DT_SKETCH(ec->desktop), NULL);
+ dc->red_bpath = sp_canvas_bpath_new(sp_desktop_sketch(ec->desktop), NULL);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(dc->red_bpath), dc->red_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
/* Create red curve */
dc->red_curve = sp_curve_new_sized(4);
/* Create blue bpath */
- dc->blue_bpath = sp_canvas_bpath_new(SP_DT_SKETCH(ec->desktop), NULL);
+ dc->blue_bpath = sp_canvas_bpath_new(sp_desktop_sketch(ec->desktop), NULL);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(dc->blue_bpath), dc->blue_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
/* Create blue curve */
dc->blue_curve = sp_curve_new_sized(8);
gint
sp_draw_context_root_handler(SPEventContext *ec, GdkEvent *event)
{
- //SPDrawContext *dc = SP_DRAW_CONTEXT(ec);
- SPDesktop *desktop = ec->desktop;
-
gint ret = FALSE;
switch (event->type) {
case GDK_KEY_PRESS:
switch (get_group0_keyval (&event->key)) {
- case GDK_Escape:
- SP_DT_SELECTION(desktop)->clear();
- ret = TRUE;
- break;
- case GDK_Tab: // Tab - cycle selection forward
- if (!(MOD__CTRL_ONLY || (MOD__CTRL && MOD__SHIFT))) {
- sp_selection_item_next();
- ret = TRUE;
- }
- break;
- case GDK_ISO_Left_Tab: // Shift Tab - cycle selection backward
- if (!(MOD__CTRL_ONLY || (MOD__CTRL && MOD__SHIFT))) {
- sp_selection_item_prev();
- ret = TRUE;
- }
- break;
case GDK_Up:
case GDK_Down:
case GDK_KP_Up:
SPCurve *norm = sp_shape_get_curve(SP_SHAPE(item));
sp_curve_transform(norm, sp_item_i2d_affine(dc->white_item));
g_return_if_fail( norm != NULL );
- dc->white_curves = sp_curve_split(norm);
+ dc->white_curves = g_slist_reverse(sp_curve_split(norm));
sp_curve_unref(norm);
/* Anchor list */
for (GSList *l = dc->white_curves; l != NULL; l = l->next) {
SPCurve *c;
c = (SPCurve*)l->data;
g_return_if_fail( c->end > 1 );
- if ( c->bpath->code == NR_MOVETO_OPEN ) {
+ if ( SP_CURVE_BPATH(c)->code == NR_MOVETO_OPEN ) {
NArtBpath *s, *e;
SPDrawAnchor *a;
s = sp_curve_first_bpath(c);
@@ -372,9 +353,9 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, NR::Point &p, N
p = o + bdot * best;
/* Snap it along best vector */
- SnapManager const m(SP_EVENT_CONTEXT_DESKTOP(ec)->namedview);
- p = m.constrainedSnap(Inkscape::Snapper::SNAP_POINT | Inkscape::Snapper::BBOX_POINT,
- p, best, NULL).getPoint();
+ SnapManager const &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
+ p = m.constrainedSnap(Inkscape::Snapper::SNAPPOINT_NODE,
+ p, Inkscape::Snapper::ConstraintLine(best), NULL).getPoint();
}
}
@@ -386,9 +367,8 @@ void spdc_endpoint_snap_free(SPEventContext const * const ec, NR::Point& p, guin
return;
}
- /* FIXME: this should be doing bbox snap as well */
- SnapManager const m(SP_EVENT_CONTEXT_DESKTOP(ec)->namedview);
- p = m.freeSnap(Inkscape::Snapper::BBOX_POINT | Inkscape::Snapper::SNAP_POINT, p, NULL).getPoint();
+ SnapManager const &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
+ p = m.freeSnap(Inkscape::Snapper::SNAPPOINT_NODE, p, NULL).getPoint();
}
static SPCurve *
: sp_desktop_dt2root_affine(SP_EVENT_CONTEXT_DESKTOP(dc)) ));
SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(dc);
- SPDocument *doc = SP_DT_DOCUMENT(desktop);
+ SPDocument *doc = sp_desktop_document(desktop);
+ Inkscape::XML::Document *xml_doc = sp_document_repr_doc(doc);
if ( c && !sp_curve_empty(c) ) {
/* We actually have something to write */
if (dc->white_item) {
repr = SP_OBJECT_REPR(dc->white_item);
} else {
- repr = sp_repr_new("svg:path");
+ repr = xml_doc->createElement("svg:path");
/* Set style */
sp_desktop_apply_style_tool(desktop, repr, tool_name(dc), false);
}
item->updateRepr();
}
- sp_document_done(doc);
+ sp_document_done(doc, SP_IS_PEN_CONTEXT(dc)? SP_VERB_CONTEXT_PEN : SP_VERB_CONTEXT_PENCIL,
+ _("Draw path"));
}
sp_curve_unref(c);