diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2013-09-19 22:33:11 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2013-09-19 22:33:11 +0000 |
| commit | 4bda89e32e33c7bdff5d3ea3c1ceee1f806de9f7 (patch) | |
| tree | caeb924426bcc861badc6fa81318b67460b26d47 /src/tweak-context.cpp | |
| parent | Update to trunk (diff) | |
| parent | updates for cmake (diff) | |
| download | inkscape-4bda89e32e33c7bdff5d3ea3c1ceee1f806de9f7.tar.gz inkscape-4bda89e32e33c7bdff5d3ea3c1ceee1f806de9f7.zip | |
Update to trunk
(bzr r11950.1.141)
Diffstat (limited to 'src/tweak-context.cpp')
| -rw-r--r-- | src/tweak-context.cpp | 440 |
1 files changed, 201 insertions, 239 deletions
diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp index 58b6f2b54..2171ecbe4 100644 --- a/src/tweak-context.cpp +++ b/src/tweak-context.cpp @@ -90,75 +90,59 @@ using Inkscape::DocumentUndo; #define DYNA_MIN_WIDTH 1.0e-6 -static void sp_tweak_context_dispose(GObject *object); +#include "tool-factory.h" -static void sp_tweak_context_setup(SPEventContext *ec); -static void sp_tweak_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val); -static gint sp_tweak_context_root_handler(SPEventContext *ec, GdkEvent *event); +namespace { + SPEventContext* createTweakContext() { + return new SPTweakContext(); + } -G_DEFINE_TYPE(SPTweakContext, sp_tweak_context, SP_TYPE_EVENT_CONTEXT); - -static void -sp_tweak_context_class_init(SPTweakContextClass *klass) -{ - GObjectClass *object_class = G_OBJECT_CLASS(klass); - SPEventContextClass *event_context_class = SP_EVENT_CONTEXT_CLASS(klass); - - object_class->dispose = sp_tweak_context_dispose; + bool tweakContextRegistered = ToolFactory::instance().registerObject("/tools/tweak", createTweakContext); +} - event_context_class->setup = sp_tweak_context_setup; - event_context_class->set = sp_tweak_context_set; - event_context_class->root_handler = sp_tweak_context_root_handler; +const std::string& SPTweakContext::getPrefsPath() { + return SPTweakContext::prefsPath; } -static void -sp_tweak_context_init(SPTweakContext *tc) -{ - SPEventContext *event_context = SP_EVENT_CONTEXT(tc); +const std::string SPTweakContext::prefsPath = "/tools/tweak"; - event_context->cursor_shape = cursor_push_xpm; - event_context->hot_x = 4; - event_context->hot_y = 4; +SPTweakContext::SPTweakContext() : SPEventContext() { + this->mode = 0; + this->dilate_area = 0; + this->usetilt = 0; + this->usepressure = 0; + this->is_drawing = false; + this->fidelity = 0; - /* attributes */ - tc->dragging = FALSE; + this->cursor_shape = cursor_push_xpm; + this->hot_x = 4; + this->hot_y = 4; - tc->width = 0.2; - tc->force = 0.2; - tc->pressure = TC_DEFAULT_PRESSURE; + /* attributes */ + this->dragging = FALSE; - tc->is_dilating = false; - tc->has_dilated = false; + this->width = 0.2; + this->force = 0.2; + this->pressure = TC_DEFAULT_PRESSURE; - tc->do_h = true; - tc->do_s = true; - tc->do_l = true; - tc->do_o = false; + this->is_dilating = false; + this->has_dilated = false; - new (&tc->style_set_connection) sigc::connection(); + this->do_h = true; + this->do_s = true; + this->do_l = true; + this->do_o = false; } -static void -sp_tweak_context_dispose(GObject *object) -{ - SPTweakContext *tc = SP_TWEAK_CONTEXT(object); - SPEventContext *ec = SP_EVENT_CONTEXT(object); - - ec->enableGrDrag(false); +SPTweakContext::~SPTweakContext() { + this->enableGrDrag(false); - tc->style_set_connection.disconnect(); - tc->style_set_connection.~connection(); - - if (tc->dilate_area) { - sp_canvas_item_destroy(tc->dilate_area); - tc->dilate_area = NULL; - } + this->style_set_connection.disconnect(); - if (tc->_message_context) { - delete tc->_message_context; + if (this->dilate_area) { + sp_canvas_item_destroy(this->dilate_area); + this->dilate_area = NULL; } - - G_OBJECT_CLASS(sp_tweak_context_parent_class)->dispose(object); } static bool is_transform_mode (gint mode) @@ -176,14 +160,10 @@ static bool is_color_mode (gint mode) return (mode == TWEAK_MODE_COLORPAINT || mode == TWEAK_MODE_COLORJITTER || mode == TWEAK_MODE_BLUR); } -static void -sp_tweak_update_cursor (SPTweakContext *tc, bool with_shift) -{ - SPEventContext *event_context = SP_EVENT_CONTEXT(tc); - SPDesktop *desktop = event_context->desktop; - +void SPTweakContext::update_cursor (bool with_shift) { guint num = 0; gchar *sel_message = NULL; + if (!desktop->selection->isEmpty()) { num = g_slist_length(const_cast<GSList *>(desktop->selection->itemList())); sel_message = g_strdup_printf(ngettext("<b>%i</b> object selected","<b>%i</b> objects selected",num), num); @@ -191,109 +171,103 @@ sp_tweak_update_cursor (SPTweakContext *tc, bool with_shift) sel_message = g_strdup_printf(_("<b>Nothing</b> selected")); } - switch (tc->mode) { + switch (this->mode) { case TWEAK_MODE_MOVE: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag to <b>move</b>."), sel_message); - event_context->cursor_shape = cursor_tweak_move_xpm; + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag to <b>move</b>."), sel_message); + this->cursor_shape = cursor_tweak_move_xpm; break; case TWEAK_MODE_MOVE_IN_OUT: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>move in</b>; with Shift to <b>move out</b>."), sel_message); + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>move in</b>; with Shift to <b>move out</b>."), sel_message); if (with_shift) { - event_context->cursor_shape = cursor_tweak_move_out_xpm; + this->cursor_shape = cursor_tweak_move_out_xpm; } else { - event_context->cursor_shape = cursor_tweak_move_in_xpm; + this->cursor_shape = cursor_tweak_move_in_xpm; } break; case TWEAK_MODE_MOVE_JITTER: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>move randomly</b>."), sel_message); - event_context->cursor_shape = cursor_tweak_move_jitter_xpm; + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>move randomly</b>."), sel_message); + this->cursor_shape = cursor_tweak_move_jitter_xpm; break; case TWEAK_MODE_SCALE: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>scale down</b>; with Shift to <b>scale up</b>."), sel_message); + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>scale down</b>; with Shift to <b>scale up</b>."), sel_message); if (with_shift) { - event_context->cursor_shape = cursor_tweak_scale_up_xpm; + this->cursor_shape = cursor_tweak_scale_up_xpm; } else { - event_context->cursor_shape = cursor_tweak_scale_down_xpm; + this->cursor_shape = cursor_tweak_scale_down_xpm; } break; case TWEAK_MODE_ROTATE: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>rotate clockwise</b>; with Shift, <b>counterclockwise</b>."), sel_message); + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>rotate clockwise</b>; with Shift, <b>counterclockwise</b>."), sel_message); if (with_shift) { - event_context->cursor_shape = cursor_tweak_rotate_counterclockwise_xpm; + this->cursor_shape = cursor_tweak_rotate_counterclockwise_xpm; } else { - event_context->cursor_shape = cursor_tweak_rotate_clockwise_xpm; + this->cursor_shape = cursor_tweak_rotate_clockwise_xpm; } break; case TWEAK_MODE_MORELESS: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>duplicate</b>; with Shift, <b>delete</b>."), sel_message); + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>duplicate</b>; with Shift, <b>delete</b>."), sel_message); if (with_shift) { - event_context->cursor_shape = cursor_tweak_less_xpm; + this->cursor_shape = cursor_tweak_less_xpm; } else { - event_context->cursor_shape = cursor_tweak_more_xpm; + this->cursor_shape = cursor_tweak_more_xpm; } break; case TWEAK_MODE_PUSH: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag to <b>push paths</b>."), sel_message); - event_context->cursor_shape = cursor_push_xpm; + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag to <b>push paths</b>."), sel_message); + this->cursor_shape = cursor_push_xpm; break; case TWEAK_MODE_SHRINK_GROW: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>inset paths</b>; with Shift to <b>outset</b>."), sel_message); + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>inset paths</b>; with Shift to <b>outset</b>."), sel_message); if (with_shift) { - event_context->cursor_shape = cursor_thicken_xpm; + this->cursor_shape = cursor_thicken_xpm; } else { - event_context->cursor_shape = cursor_thin_xpm; + this->cursor_shape = cursor_thin_xpm; } break; case TWEAK_MODE_ATTRACT_REPEL: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>attract paths</b>; with Shift to <b>repel</b>."), sel_message); + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>attract paths</b>; with Shift to <b>repel</b>."), sel_message); if (with_shift) { - event_context->cursor_shape = cursor_repel_xpm; + this->cursor_shape = cursor_repel_xpm; } else { - event_context->cursor_shape = cursor_attract_xpm; + this->cursor_shape = cursor_attract_xpm; } break; case TWEAK_MODE_ROUGHEN: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>roughen paths</b>."), sel_message); - event_context->cursor_shape = cursor_roughen_xpm; + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>roughen paths</b>."), sel_message); + this->cursor_shape = cursor_roughen_xpm; break; case TWEAK_MODE_COLORPAINT: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>paint objects</b> with color."), sel_message); - event_context->cursor_shape = cursor_color_xpm; + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>paint objects</b> with color."), sel_message); + this->cursor_shape = cursor_color_xpm; break; case TWEAK_MODE_COLORJITTER: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>randomize colors</b>."), sel_message); - event_context->cursor_shape = cursor_color_xpm; + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>randomize colors</b>."), sel_message); + this->cursor_shape = cursor_color_xpm; break; case TWEAK_MODE_BLUR: - tc->_message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>increase blur</b>; with Shift to <b>decrease</b>."), sel_message); - event_context->cursor_shape = cursor_color_xpm; + this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag or click to <b>increase blur</b>; with Shift to <b>decrease</b>."), sel_message); + this->cursor_shape = cursor_color_xpm; break; } - sp_event_context_update_cursor(event_context); + + this->sp_event_context_update_cursor(); g_free(sel_message); } -static bool -sp_tweak_context_style_set(SPCSSAttr const *css, SPTweakContext *tc) -{ - if (tc->mode == TWEAK_MODE_COLORPAINT) { // intercept color setting only in this mode +bool SPTweakContext::set_style(const SPCSSAttr* css) { + if (this->mode == TWEAK_MODE_COLORPAINT) { // intercept color setting only in this mode // we cannot store properties with uris - css = sp_css_attr_unset_uris (const_cast<SPCSSAttr *>(css)); + css = sp_css_attr_unset_uris(const_cast<SPCSSAttr *>(css)); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); - prefs->setStyle("/tools/tweak/style", const_cast<SPCSSAttr*>(css)); + prefs->setStyle("/tools/tweak/style", const_cast<SPCSSAttr *>(css)); return true; } + return false; } -static void -sp_tweak_context_setup(SPEventContext *ec) -{ - SPTweakContext *tc = SP_TWEAK_CONTEXT(ec); - - if ((SP_EVENT_CONTEXT_CLASS(sp_tweak_context_parent_class))->setup) { - (SP_EVENT_CONTEXT_CLASS(sp_tweak_context_parent_class))->setup(ec); - } +void SPTweakContext::setup() { + SPEventContext::setup(); { /* TODO: have a look at sp_dyna_draw_context_setup where the same is done.. generalize? at least make it an arcto! */ @@ -305,65 +279,61 @@ sp_tweak_context_setup(SPEventContext *ec) c->curveto(1, -C1, C1, -1, 0, -1 ); c->curveto(-C1, -1, -1, -C1, -1, 0 ); c->closepath(); - tc->dilate_area = sp_canvas_bpath_new(sp_desktop_controls(ec->desktop), c); + this->dilate_area = sp_canvas_bpath_new(sp_desktop_controls(this->desktop), c); c->unref(); - sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(tc->dilate_area), 0x00000000,(SPWindRule)0); - sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(tc->dilate_area), 0xff9900ff, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); - sp_canvas_item_hide(tc->dilate_area); + sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(this->dilate_area), 0x00000000,(SPWindRule)0); + sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->dilate_area), 0xff9900ff, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT); + sp_canvas_item_hide(this->dilate_area); } - tc->is_drawing = false; - - tc->_message_context = new Inkscape::MessageContext((ec->desktop)->messageStack()); - - sp_event_context_read(ec, "width"); - sp_event_context_read(ec, "mode"); - sp_event_context_read(ec, "fidelity"); - sp_event_context_read(ec, "force"); - sp_event_context_read(ec, "usepressure"); - sp_event_context_read(ec, "doh"); - sp_event_context_read(ec, "dol"); - sp_event_context_read(ec, "dos"); - sp_event_context_read(ec, "doo"); - - tc->style_set_connection = ec->desktop->connectSetStyle( // catch style-setting signal in this tool - sigc::bind(sigc::ptr_fun(&sp_tweak_context_style_set), tc) + this->is_drawing = false; + + sp_event_context_read(this, "width"); + sp_event_context_read(this, "mode"); + sp_event_context_read(this, "fidelity"); + sp_event_context_read(this, "force"); + sp_event_context_read(this, "usepressure"); + sp_event_context_read(this, "doh"); + sp_event_context_read(this, "dol"); + sp_event_context_read(this, "dos"); + sp_event_context_read(this, "doo"); + + this->style_set_connection = this->desktop->connectSetStyle( // catch style-setting signal in this tool + //sigc::bind(sigc::ptr_fun(&sp_tweak_context_style_set), this) + sigc::mem_fun(this, &SPTweakContext::set_style) ); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); if (prefs->getBool("/tools/tweak/selcue")) { - ec->enableSelectionCue(); + this->enableSelectionCue(); } if (prefs->getBool("/tools/tweak/gradientdrag")) { - ec->enableGrDrag(); + this->enableGrDrag(); } } -static void -sp_tweak_context_set(SPEventContext *ec, Inkscape::Preferences::Entry *val) -{ - SPTweakContext *tc = SP_TWEAK_CONTEXT(ec); - Glib::ustring path = val->getEntryName(); +void SPTweakContext::set(const Inkscape::Preferences::Entry& val) { + Glib::ustring path = val.getEntryName(); if (path == "width") { - tc->width = CLAMP(val->getDouble(0.1), -1000.0, 1000.0); + this->width = CLAMP(val.getDouble(0.1), -1000.0, 1000.0); } else if (path == "mode") { - tc->mode = val->getInt(); - sp_tweak_update_cursor(tc, false); + this->mode = val.getInt(); + this->update_cursor(false); } else if (path == "fidelity") { - tc->fidelity = CLAMP(val->getDouble(), 0.0, 1.0); + this->fidelity = CLAMP(val.getDouble(), 0.0, 1.0); } else if (path == "force") { - tc->force = CLAMP(val->getDouble(1.0), 0, 1.0); + this->force = CLAMP(val.getDouble(1.0), 0, 1.0); } else if (path == "usepressure") { - tc->usepressure = val->getBool(); + this->usepressure = val.getBool(); } else if (path == "doh") { - tc->do_h = val->getBool(); + this->do_h = val.getBool(); } else if (path == "dos") { - tc->do_s = val->getBool(); + this->do_s = val.getBool(); } else if (path == "dol") { - tc->do_l = val->getBool(); + this->do_l = val.getBool(); } else if (path == "doo") { - tc->do_o = val->getBool(); + this->do_o = val.getBool(); } } @@ -1157,7 +1127,7 @@ sp_tweak_switch_mode (SPTweakContext *tc, gint mode, bool with_shift) SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue ("tweak_tool_mode", mode); // need to set explicitly, because the prefs may not have changed by the previous tc->mode = mode; - sp_tweak_update_cursor (tc, with_shift); + tc->update_cursor(with_shift); } static void @@ -1171,43 +1141,37 @@ sp_tweak_switch_mode_temporarily (SPTweakContext *tc, gint mode, bool with_shift prefs->setInt("/tools/tweak/mode", now_mode); // changing prefs changed tc->mode, restore back :) tc->mode = mode; - sp_tweak_update_cursor (tc, with_shift); + tc->update_cursor(with_shift); } -gint -sp_tweak_context_root_handler(SPEventContext *event_context, - GdkEvent *event) -{ - SPTweakContext *tc = SP_TWEAK_CONTEXT(event_context); - SPDesktop *desktop = event_context->desktop; - +bool SPTweakContext::root_handler(GdkEvent* event) { gint ret = FALSE; switch (event->type) { case GDK_ENTER_NOTIFY: - sp_canvas_item_show(tc->dilate_area); + sp_canvas_item_show(this->dilate_area); break; case GDK_LEAVE_NOTIFY: - sp_canvas_item_hide(tc->dilate_area); + sp_canvas_item_hide(this->dilate_area); break; case GDK_BUTTON_PRESS: - if (event->button.button == 1 && !event_context->space_panning) { + if (event->button.button == 1 && !this->space_panning) { - if (Inkscape::have_viable_layer(desktop, tc->_message_context) == false) { + if (Inkscape::have_viable_layer(desktop, this->message_context) == false) { return TRUE; } Geom::Point const button_w(event->button.x, event->button.y); Geom::Point const button_dt(desktop->w2d(button_w)); - tc->last_push = desktop->dt2doc(button_dt); + this->last_push = desktop->dt2doc(button_dt); - sp_tweak_extinput(tc, event); + sp_tweak_extinput(this, event); desktop->canvas->forceFullRedrawAfterInterruptions(3); - tc->is_drawing = true; - tc->is_dilating = true; - tc->has_dilated = false; + this->is_drawing = true; + this->is_dilating = true; + this->has_dilated = false; ret = TRUE; } @@ -1218,27 +1182,27 @@ sp_tweak_context_root_handler(SPEventContext *event_context, event->motion.y); Geom::Point motion_dt(desktop->w2d(motion_w)); Geom::Point motion_doc(desktop->dt2doc(motion_dt)); - sp_tweak_extinput(tc, event); + sp_tweak_extinput(this, event); // draw the dilating cursor - double radius = get_dilate_radius(tc); + double radius = get_dilate_radius(this); Geom::Affine const sm (Geom::Scale(radius, radius) * Geom::Translate(desktop->w2d(motion_w))); - sp_canvas_item_affine_absolute(tc->dilate_area, sm); - sp_canvas_item_show(tc->dilate_area); + sp_canvas_item_affine_absolute(this->dilate_area, sm); + sp_canvas_item_show(this->dilate_area); guint num = 0; if (!desktop->selection->isEmpty()) { num = g_slist_length(const_cast<GSList *>(desktop->selection->itemList())); } if (num == 0) { - tc->_message_context->flash(Inkscape::ERROR_MESSAGE, _("<b>Nothing selected!</b> Select objects to tweak.")); + this->message_context->flash(Inkscape::ERROR_MESSAGE, _("<b>Nothing selected!</b> Select objects to tweak.")); } // dilating: - if (tc->is_drawing && ( event->motion.state & GDK_BUTTON1_MASK )) { - sp_tweak_dilate (tc, motion_w, motion_doc, motion_doc - tc->last_push, event->button.state & GDK_SHIFT_MASK? true : false); - //tc->last_push = motion_doc; - tc->has_dilated = true; + if (this->is_drawing && ( event->motion.state & GDK_BUTTON1_MASK )) { + sp_tweak_dilate (this, motion_w, motion_doc, motion_doc - this->last_push, event->button.state & GDK_SHIFT_MASK? true : false); + //this->last_push = motion_doc; + this->has_dilated = true; // it's slow, so prevent clogging up with events gobble_motion_events(GDK_BUTTON1_MASK); return TRUE; @@ -1252,67 +1216,67 @@ sp_tweak_context_root_handler(SPEventContext *event_context, Geom::Point const motion_dt(desktop->w2d(motion_w)); desktop->canvas->endForcedFullRedraws(); - tc->is_drawing = false; + this->is_drawing = false; - if (tc->is_dilating && event->button.button == 1 && !event_context->space_panning) { - if (!tc->has_dilated) { + if (this->is_dilating && event->button.button == 1 && !this->space_panning) { + if (!this->has_dilated) { // if we did not rub, do a light tap - tc->pressure = 0.03; - sp_tweak_dilate (tc, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT(event)); + this->pressure = 0.03; + sp_tweak_dilate (this, motion_w, desktop->dt2doc(motion_dt), Geom::Point(0,0), MOD__SHIFT(event)); } - tc->is_dilating = false; - tc->has_dilated = false; - switch (tc->mode) { + this->is_dilating = false; + this->has_dilated = false; + switch (this->mode) { case TWEAK_MODE_MOVE: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop), SP_VERB_CONTEXT_TWEAK, _("Move tweak")); break; case TWEAK_MODE_MOVE_IN_OUT: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop), SP_VERB_CONTEXT_TWEAK, _("Move in/out tweak")); break; case TWEAK_MODE_MOVE_JITTER: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop), SP_VERB_CONTEXT_TWEAK, _("Move jitter tweak")); break; case TWEAK_MODE_SCALE: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop), SP_VERB_CONTEXT_TWEAK, _("Scale tweak")); break; case TWEAK_MODE_ROTATE: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop), SP_VERB_CONTEXT_TWEAK, _("Rotate tweak")); break; case TWEAK_MODE_MORELESS: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop), SP_VERB_CONTEXT_TWEAK, _("Duplicate/delete tweak")); break; case TWEAK_MODE_PUSH: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop), SP_VERB_CONTEXT_TWEAK, _("Push path tweak")); break; case TWEAK_MODE_SHRINK_GROW: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop), SP_VERB_CONTEXT_TWEAK, _("Shrink/grow path tweak")); break; case TWEAK_MODE_ATTRACT_REPEL: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop), SP_VERB_CONTEXT_TWEAK, _("Attract/repel path tweak")); break; case TWEAK_MODE_ROUGHEN: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop), SP_VERB_CONTEXT_TWEAK, _("Roughen path tweak")); break; case TWEAK_MODE_COLORPAINT: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop), SP_VERB_CONTEXT_TWEAK, _("Color paint tweak")); break; case TWEAK_MODE_COLORJITTER: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop), SP_VERB_CONTEXT_TWEAK, _("Color jitter tweak")); break; case TWEAK_MODE_BLUR: - DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(tc)->desktop), + DocumentUndo::done(sp_desktop_document(SP_EVENT_CONTEXT(this)->desktop), SP_VERB_CONTEXT_TWEAK, _("Blur tweak")); break; } @@ -1326,7 +1290,7 @@ sp_tweak_context_root_handler(SPEventContext *event_context, case GDK_KEY_M: case GDK_KEY_0: if (MOD__SHIFT_ONLY(event)) { - sp_tweak_switch_mode(tc, TWEAK_MODE_MOVE, MOD__SHIFT(event)); + sp_tweak_switch_mode(this, TWEAK_MODE_MOVE, MOD__SHIFT(event)); ret = TRUE; } break; @@ -1334,7 +1298,7 @@ sp_tweak_context_root_handler(SPEventContext *event_context, case GDK_KEY_I: case GDK_KEY_1: if (MOD__SHIFT_ONLY(event)) { - sp_tweak_switch_mode(tc, TWEAK_MODE_MOVE_IN_OUT, MOD__SHIFT(event)); + sp_tweak_switch_mode(this, TWEAK_MODE_MOVE_IN_OUT, MOD__SHIFT(event)); ret = TRUE; } break; @@ -1342,7 +1306,7 @@ sp_tweak_context_root_handler(SPEventContext *event_context, case GDK_KEY_Z: case GDK_KEY_2: if (MOD__SHIFT_ONLY(event)) { - sp_tweak_switch_mode(tc, TWEAK_MODE_MOVE_JITTER, MOD__SHIFT(event)); + sp_tweak_switch_mode(this, TWEAK_MODE_MOVE_JITTER, MOD__SHIFT(event)); ret = TRUE; } break; @@ -1352,7 +1316,7 @@ sp_tweak_context_root_handler(SPEventContext *event_context, case GDK_KEY_period: case GDK_KEY_3: if (MOD__SHIFT_ONLY(event)) { - sp_tweak_switch_mode(tc, TWEAK_MODE_SCALE, MOD__SHIFT(event)); + sp_tweak_switch_mode(this, TWEAK_MODE_SCALE, MOD__SHIFT(event)); ret = TRUE; } break; @@ -1360,7 +1324,7 @@ sp_tweak_context_root_handler(SPEventContext *event_context, case GDK_KEY_bracketleft: case GDK_KEY_4: if (MOD__SHIFT_ONLY(event)) { - sp_tweak_switch_mode(tc, TWEAK_MODE_ROTATE, MOD__SHIFT(event)); + sp_tweak_switch_mode(this, TWEAK_MODE_ROTATE, MOD__SHIFT(event)); ret = TRUE; } break; @@ -1368,7 +1332,7 @@ sp_tweak_context_root_handler(SPEventContext *event_context, case GDK_KEY_D: case GDK_KEY_5: if (MOD__SHIFT_ONLY(event)) { - sp_tweak_switch_mode(tc, TWEAK_MODE_MORELESS, MOD__SHIFT(event)); + sp_tweak_switch_mode(this, TWEAK_MODE_MORELESS, MOD__SHIFT(event)); ret = TRUE; } break; @@ -1376,7 +1340,7 @@ sp_tweak_context_root_handler(SPEventContext *event_context, case GDK_KEY_P: case GDK_KEY_6: if (MOD__SHIFT_ONLY(event)) { - sp_tweak_switch_mode(tc, TWEAK_MODE_PUSH, MOD__SHIFT(event)); + sp_tweak_switch_mode(this, TWEAK_MODE_PUSH, MOD__SHIFT(event)); ret = TRUE; } break; @@ -1384,7 +1348,7 @@ sp_tweak_context_root_handler(SPEventContext *event_context, case GDK_KEY_S: case GDK_KEY_7: if (MOD__SHIFT_ONLY(event)) { - sp_tweak_switch_mode(tc, TWEAK_MODE_SHRINK_GROW, MOD__SHIFT(event)); + sp_tweak_switch_mode(this, TWEAK_MODE_SHRINK_GROW, MOD__SHIFT(event)); ret = TRUE; } break; @@ -1392,7 +1356,7 @@ sp_tweak_context_root_handler(SPEventContext *event_context, case GDK_KEY_A: case GDK_KEY_8: if (MOD__SHIFT_ONLY(event)) { - sp_tweak_switch_mode(tc, TWEAK_MODE_ATTRACT_REPEL, MOD__SHIFT(event)); + sp_tweak_switch_mode(this, TWEAK_MODE_ATTRACT_REPEL, MOD__SHIFT(event)); ret = TRUE; } break; @@ -1400,28 +1364,28 @@ sp_tweak_context_root_handler(SPEventContext *event_context, case GDK_KEY_R: case GDK_KEY_9: if (MOD__SHIFT_ONLY(event)) { - sp_tweak_switch_mode(tc, TWEAK_MODE_ROUGHEN, MOD__SHIFT(event)); + sp_tweak_switch_mode(this, TWEAK_MODE_ROUGHEN, MOD__SHIFT(event)); ret = TRUE; } break; case GDK_KEY_c: case GDK_KEY_C: if (MOD__SHIFT_ONLY(event)) { - sp_tweak_switch_mode(tc, TWEAK_MODE_COLORPAINT, MOD__SHIFT(event)); + sp_tweak_switch_mode(this, TWEAK_MODE_COLORPAINT, MOD__SHIFT(event)); ret = TRUE; } break; case GDK_KEY_j: case GDK_KEY_J: if (MOD__SHIFT_ONLY(event)) { - sp_tweak_switch_mode(tc, TWEAK_MODE_COLORJITTER, MOD__SHIFT(event)); + sp_tweak_switch_mode(this, TWEAK_MODE_COLORJITTER, MOD__SHIFT(event)); ret = TRUE; } break; case GDK_KEY_b: case GDK_KEY_B: if (MOD__SHIFT_ONLY(event)) { - sp_tweak_switch_mode(tc, TWEAK_MODE_BLUR, MOD__SHIFT(event)); + sp_tweak_switch_mode(this, TWEAK_MODE_BLUR, MOD__SHIFT(event)); ret = TRUE; } break; @@ -1429,61 +1393,61 @@ sp_tweak_context_root_handler(SPEventContext *event_context, case GDK_KEY_Up: case GDK_KEY_KP_Up: if (!MOD__CTRL_ONLY(event)) { - tc->force += 0.05; - if (tc->force > 1.0) { - tc->force = 1.0; + this->force += 0.05; + if (this->force > 1.0) { + this->force = 1.0; } - desktop->setToolboxAdjustmentValue ("tweak-force", tc->force * 100); + desktop->setToolboxAdjustmentValue ("tweak-force", this->force * 100); ret = TRUE; } break; case GDK_KEY_Down: case GDK_KEY_KP_Down: if (!MOD__CTRL_ONLY(event)) { - tc->force -= 0.05; - if (tc->force < 0.0) { - tc->force = 0.0; + this->force -= 0.05; + if (this->force < 0.0) { + this->force = 0.0; } - desktop->setToolboxAdjustmentValue ("tweak-force", tc->force * 100); + desktop->setToolboxAdjustmentValue ("tweak-force", this->force * 100); ret = TRUE; } break; case GDK_KEY_Right: case GDK_KEY_KP_Right: if (!MOD__CTRL_ONLY(event)) { - tc->width += 0.01; - if (tc->width > 1.0) { - tc->width = 1.0; + this->width += 0.01; + if (this->width > 1.0) { + this->width = 1.0; } - desktop->setToolboxAdjustmentValue ("altx-tweak", tc->width * 100); // the same spinbutton is for alt+x - sp_tweak_update_area(tc); + desktop->setToolboxAdjustmentValue ("altx-tweak", this->width * 100); // the same spinbutton is for alt+x + sp_tweak_update_area(this); ret = TRUE; } break; case GDK_KEY_Left: case GDK_KEY_KP_Left: if (!MOD__CTRL_ONLY(event)) { - tc->width -= 0.01; - if (tc->width < 0.01) { - tc->width = 0.01; + this->width -= 0.01; + if (this->width < 0.01) { + this->width = 0.01; } - desktop->setToolboxAdjustmentValue ("altx-tweak", tc->width * 100); - sp_tweak_update_area(tc); + desktop->setToolboxAdjustmentValue ("altx-tweak", this->width * 100); + sp_tweak_update_area(this); ret = TRUE; } break; case GDK_KEY_Home: case GDK_KEY_KP_Home: - tc->width = 0.01; - desktop->setToolboxAdjustmentValue ("altx-tweak", tc->width * 100); - sp_tweak_update_area(tc); + this->width = 0.01; + desktop->setToolboxAdjustmentValue ("altx-tweak", this->width * 100); + sp_tweak_update_area(this); ret = TRUE; break; case GDK_KEY_End: case GDK_KEY_KP_End: - tc->width = 1.0; - desktop->setToolboxAdjustmentValue ("altx-tweak", tc->width * 100); - sp_tweak_update_area(tc); + this->width = 1.0; + desktop->setToolboxAdjustmentValue ("altx-tweak", this->width * 100); + sp_tweak_update_area(this); ret = TRUE; break; case GDK_KEY_x: @@ -1496,17 +1460,17 @@ sp_tweak_context_root_handler(SPEventContext *event_context, case GDK_KEY_Shift_L: case GDK_KEY_Shift_R: - sp_tweak_update_cursor(tc, true); + this->update_cursor(true); break; case GDK_KEY_Control_L: case GDK_KEY_Control_R: - sp_tweak_switch_mode_temporarily(tc, TWEAK_MODE_SHRINK_GROW, MOD__SHIFT(event)); + sp_tweak_switch_mode_temporarily(this, TWEAK_MODE_SHRINK_GROW, MOD__SHIFT(event)); break; case GDK_KEY_Delete: case GDK_KEY_KP_Delete: case GDK_KEY_BackSpace: - ret = event_context->deleteSelectedDrag(MOD__CTRL_ONLY(event)); + ret = this->deleteSelectedDrag(MOD__CTRL_ONLY(event)); break; default: @@ -1519,15 +1483,15 @@ sp_tweak_context_root_handler(SPEventContext *event_context, switch (get_group0_keyval(&event->key)) { case GDK_KEY_Shift_L: case GDK_KEY_Shift_R: - sp_tweak_update_cursor(tc, false); + this->update_cursor(false); break; case GDK_KEY_Control_L: case GDK_KEY_Control_R: - sp_tweak_switch_mode (tc, prefs->getInt("/tools/tweak/mode"), MOD__SHIFT(event)); - tc->_message_context->clear(); + sp_tweak_switch_mode (this, prefs->getInt("/tools/tweak/mode"), MOD__SHIFT(event)); + this->message_context->clear(); break; default: - sp_tweak_switch_mode (tc, prefs->getInt("/tools/tweak/mode"), MOD__SHIFT(event)); + sp_tweak_switch_mode (this, prefs->getInt("/tools/tweak/mode"), MOD__SHIFT(event)); break; } } @@ -1536,9 +1500,7 @@ sp_tweak_context_root_handler(SPEventContext *event_context, } if (!ret) { - if ((SP_EVENT_CONTEXT_CLASS(sp_tweak_context_parent_class))->root_handler) { - ret = (SP_EVENT_CONTEXT_CLASS(sp_tweak_context_parent_class))->root_handler(event_context, event); - } + ret = SPEventContext::root_handler(event); } return ret; |
