diff --git a/src/text-context.cpp b/src/text-context.cpp
index 078d2bece62dd30e555705e5b6eb020a274464ad..6e4b637b85d26b5163ec5821284f6d42850d99f7 100644 (file)
--- a/src/text-context.cpp
+++ b/src/text-context.cpp
#include "sp-metrics.h"
#include "context-fns.h"
#include "verbs.h"
+#include "shape-editor.h"
#include "text-editing.h"
event_context->tolerance = 0;
event_context->within_tolerance = false;
- event_context->shape_repr = NULL;
- event_context->shape_knot_holder = NULL;
-
tc->imc = NULL;
tc->text = NULL;
tc->style_set_connection.~connection();
tc->sel_changed_connection.~connection();
tc->sel_modified_connection.~connection();
+
+ delete ec->shape_editor;
+ ec->shape_editor = NULL;
+
tc->text_sel_end.~iterator();
tc->text_sel_start.~iterator();
tc->text_selection_quads.~vector();
}
Inkscape::Rubberband::get(ec->desktop)->stop();
-
- 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;
- }
}
-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 */
-};
-
static void
sp_text_context_setup(SPEventContext *ec)
{
if (((SPEventContextClass *) parent_class)->setup)
((SPEventContextClass *) parent_class)->setup(ec);
+ ec->shape_editor = new ShapeEditor(ec->desktop);
+
SPItem *item = sp_desktop_selection(ec->desktop)->singleItem();
if (item && SP_IS_FLOWTEXT (item) && SP_FLOWTEXT(item)->has_internal_frame()) {
- ec->shape_knot_holder = sp_item_knot_holder(item, ec->desktop);
- Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(SP_FLOWTEXT(item)->get_frame(NULL));
- 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);
}
tc->sel_changed_connection = sp_desktop_selection(desktop)->connectChanged(
@@ -373,6 +353,7 @@ sp_text_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve
sp_text_context_update_cursor(tc);
sp_text_context_update_text_selection(tc);
tc->dragging = 1;
+ sp_canvas_set_snap_delay_active(desktop->canvas, true);
}
ret = TRUE;
}
@@ -389,6 +370,7 @@ sp_text_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve
sp_text_context_update_cursor(tc);
sp_text_context_update_text_selection(tc);
tc->dragging = 2;
+ sp_canvas_set_snap_delay_active(desktop->canvas, true);
ret = TRUE;
}
}
@@ -400,12 +382,14 @@ sp_text_context_item_handler(SPEventContext *event_context, SPItem *item, GdkEve
sp_text_context_update_cursor(tc);
sp_text_context_update_text_selection(tc);
tc->dragging = 3;
+ sp_canvas_set_snap_delay_active(desktop->canvas, true);
ret = TRUE;
}
break;
case GDK_BUTTON_RELEASE:
if (event->button.button == 1 && tc->dragging && !event_context->space_panning) {
tc->dragging = 0;
+ sp_canvas_set_snap_delay_active(desktop->canvas, false);
ret = TRUE;
}
break;
/* yes, it's immediate .. why does it matter? */
sp_desktop_selection(ec->desktop)->set(text_item);
Inkscape::GC::release(rtext);
- text_item->transform = SP_ITEM(ec->desktop->currentRoot())->getRelativeTransform(ec->desktop->currentLayer());
-
- // bug #168777 (consider root transform and viewBox)
- // TODO: more generic solution desirable
- Geom::Matrix root_transform = sp_item_i2doc_affine(SP_ITEM(ec->desktop->currentRoot()));
- if (!root_transform.isIdentity()) {
- text_item->transform = root_transform.inverse() * text_item->transform;
- Geom::Point pdoc = tc->pdoc * root_transform;
- sp_repr_set_svg_double(rtext, "x", pdoc[Geom::X]);
- sp_repr_set_svg_double(rtext, "y", pdoc[Geom::Y]);
- }
+ text_item->transform = sp_item_i2doc_affine(SP_ITEM(ec->desktop->currentLayer())).inverse();
text_item->updateRepr();
sp_document_done(sp_desktop_document(ec->desktop), SP_VERB_CONTEXT_TEXT,
@@ -696,7 +670,7 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
/* Button 1, set X & Y & new item */
sp_desktop_selection(desktop)->clear();
Geom::Point dtp = desktop->w2d(Geom::Point(event->button.x, event->button.y));
- tc->pdoc = sp_desktop_dt2root_xy_point(desktop, dtp);
+ tc->pdoc = sp_desktop_dt2doc_xy_point(desktop, dtp);
tc->show = TRUE;
tc->phase = 1;
@@ -1041,7 +1015,7 @@ sp_text_context_root_handler(SPEventContext *const event_context, GdkEvent *cons
sp_document_maybe_done(sp_desktop_document(desktop), "kern:left", SP_VERB_CONTEXT_TEXT,
_("Kern to the left"));
} else {
- if (MOD__CTRL)
+ if (MOD__CTRL)
tc->text_sel_end.cursorLeftWithControl();
else
tc->text_sel_end.cursorLeft();
Glib::RefPtr<Gtk::Clipboard> refClipboard = Gtk::Clipboard::get();
Glib::ustring const clip_text = refClipboard->wait_for_text();
-
+
if (!clip_text.empty()) {
// Fix for 244940
// The XML standard defines the following as valid characters
itr = text.erase(itr);
}
}
-
+
if (!tc->text) { // create text if none (i.e. if nascent_object)
sp_text_context_setup_text(tc);
tc->nascent_object = 0; // we don't need it anymore, having created a real <text>
@@ -1459,26 +1433,10 @@ sp_text_context_selection_changed(Inkscape::Selection *selection, SPTextContext
SPEventContext *ec = SP_EVENT_CONTEXT(tc);
- 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 && SP_IS_FLOWTEXT (item) && SP_FLOWTEXT(item)->has_internal_frame()) {
- ec->shape_knot_holder = sp_item_knot_holder(item, ec->desktop);
- Inkscape::XML::Node *shape_repr = SP_OBJECT_REPR(SP_FLOWTEXT(item)->get_frame(NULL));
- 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 (tc->text && (item != tc->text)) {