diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-07-25 19:12:30 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-07-25 19:12:30 +0000 |
| commit | f0c58835ba91977fd0df1aa9bc4244f803cdcd16 (patch) | |
| tree | 4b605918b7db00d4bfee9dd6eba758f74ff88f17 /src | |
| parent | Removes extra unnecesary code pointed by Nathan Hurst (diff) | |
| parent | SPKnot no longer consumes all GDK_KEY_PRESS events (diff) | |
| download | inkscape-f0c58835ba91977fd0df1aa9bc4244f803cdcd16.tar.gz inkscape-f0c58835ba91977fd0df1aa9bc4244f803cdcd16.zip | |
update to trunk
(bzr r13973.1.20)
Diffstat (limited to 'src')
| -rw-r--r-- | src/display/snap-indicator.cpp | 11 | ||||
| -rw-r--r-- | src/knot.cpp | 9 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.cpp | 26 | ||||
| -rw-r--r-- | src/ui/dialog/inkscape-preferences.h | 1 | ||||
| -rw-r--r-- | src/ui/tools/tool-base.h | 7 | ||||
| -rw-r--r-- | src/ui/widget/preferences-widget.cpp | 1 | ||||
| -rw-r--r-- | src/ui/widget/preferences-widget.h | 1 | ||||
| -rw-r--r-- | src/vanishing-point.cpp | 30 |
8 files changed, 60 insertions, 26 deletions
diff --git a/src/display/snap-indicator.cpp b/src/display/snap-indicator.cpp index 926b35599..17deea16d 100644 --- a/src/display/snap-indicator.cpp +++ b/src/display/snap-indicator.cpp @@ -256,7 +256,12 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap "shape", SP_KNOT_SHAPE_CROSS, NULL ); - const int timeout_val = 4000; + double timeout_val = prefs->getDouble("/options/snapindicatorpersistence/value", 2.0); + if (timeout_val < 0.1) { + timeout_val = 0.1; // a zero value would mean infinite persistence (i.e. until new snap occurs) + // Besides, negatives values would ....? + } + // The snap indicator will be deleted after some time-out, and sp_canvas_item_dispose // will be called. This will set canvas->current_item to NULL if the snap indicator was @@ -272,7 +277,7 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap SP_CTRL(canvasitem)->pickable = false; SP_CTRL(canvasitem)->moveto(p.getPoint()); - _snaptarget = _desktop->add_temporary_canvasitem(canvasitem, timeout_val); + _snaptarget = _desktop->add_temporary_canvasitem(canvasitem, timeout_val*1000.0); _snaptarget_is_presnap = pre_snap; // Display the tooltip, which reveals the type of snap source and the type of snap target @@ -307,7 +312,7 @@ SnapIndicator::set_new_snaptarget(Inkscape::SnappedPoint const &p, bool pre_snap SP_CANVASTEXT(canvas_tooltip)->anchor_position = TEXT_ANCHOR_CENTER; g_free(tooltip_str); - _snaptarget_tooltip = _desktop->add_temporary_canvasitem(canvas_tooltip, timeout_val); + _snaptarget_tooltip = _desktop->add_temporary_canvasitem(canvas_tooltip, timeout_val*1000.0); } // Display the bounding box, if we snapped to one diff --git a/src/knot.cpp b/src/knot.cpp index b3813ab53..92d14afb9 100644 --- a/src/knot.cpp +++ b/src/knot.cpp @@ -206,6 +206,8 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot return true; } + bool key_press_event_unconsumed = FALSE; + knot_ref(knot); Inkscape::Preferences *prefs = Inkscape::Preferences::get(); @@ -355,6 +357,7 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot break; default: consumed = FALSE; + key_press_event_unconsumed = TRUE; break; } break; @@ -364,7 +367,11 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot knot_unref(knot); - return consumed || grabbed; + if (key_press_event_unconsumed) { + return false; // e.g. in case "%" was pressed to toggle snapping, or Q for quick zoom (while dragging a handle) + } else { + return consumed || grabbed; + } } void sp_knot_handler_request_position(GdkEvent *event, SPKnot *knot) { diff --git a/src/ui/dialog/inkscape-preferences.cpp b/src/ui/dialog/inkscape-preferences.cpp index 3b0731953..98695e080 100644 --- a/src/ui/dialog/inkscape-preferences.cpp +++ b/src/ui/dialog/inkscape-preferences.cpp @@ -1229,26 +1229,38 @@ void InkscapePreferences::initPageBehavior() this->AddPage(_page_scrolling, _("Scrolling"), iter_behavior, PREFS_PAGE_BEHAVIOR_SCROLLING); // Snapping options + _page_snapping.add_group_header( _("Snap indicator")); + _snap_indicator.init( _("Enable snap indicator"), "/options/snapindicator/value", true); - _page_snapping.add_line( false, "", _snap_indicator, "", + _page_snapping.add_line( true, "", _snap_indicator, "", _("After snapping, a symbol is drawn at the point that has snapped")); - _snap_delay.init("/options/snapdelay/value", 0, 1000, 50, 100, 300, 0); - _page_snapping.add_line( false, _("_Delay (in ms):"), _snap_delay, "", - _("Postpone snapping as long as the mouse is moving, and then wait an additional fraction of a second. This additional delay is specified here. When set to zero or to a very small number, snapping will be immediate."), true); + _snap_indicator.changed_signal.connect( sigc::mem_fun(_snap_persistence, &Gtk::Widget::set_sensitive) ); + + _snap_persistence.init("/options/snapindicatorpersistence/value", 0.1, 10, 0.1, 1, 2, 1); + _page_snapping.add_line( true, _("Snap indicator persistence (in seconds):"), _snap_persistence, "", + _("Controls how long the snap indicator message will be shown, before it disappears"), true); + + _page_snapping.add_group_header( _("What should snap")); _snap_closest_only.init( _("Only snap the node closest to the pointer"), "/options/snapclosestonly/value", false); - _page_snapping.add_line( false, "", _snap_closest_only, "", + _page_snapping.add_line( true, "", _snap_closest_only, "", _("Only try to snap the node that is initially closest to the mouse pointer")); _snap_weight.init("/options/snapweight/value", 0, 1, 0.1, 0.2, 0.5, 1); - _page_snapping.add_line( false, _("_Weight factor:"), _snap_weight, "", + _page_snapping.add_line( true, _("_Weight factor:"), _snap_weight, "", _("When multiple snap solutions are found, then Inkscape can either prefer the closest transformation (when set to 0), or prefer the node that was initially the closest to the pointer (when set to 1)"), true); _snap_mouse_pointer.init( _("Snap the mouse pointer when dragging a constrained knot"), "/options/snapmousepointer/value", false); - _page_snapping.add_line( false, "", _snap_mouse_pointer, "", + _page_snapping.add_line( true, "", _snap_mouse_pointer, "", _("When dragging a knot along a constraint line, then snap the position of the mouse pointer instead of snapping the projection of the knot onto the constraint line")); + _page_snapping.add_group_header( _("Delayed snap")); + + _snap_delay.init("/options/snapdelay/value", 0, 1, 0.1, 0.2, 0.3, 1); + _page_snapping.add_line( true, _("Delay (in seconds):"), _snap_delay, "", + _("Postpone snapping as long as the mouse is moving, and then wait an additional fraction of a second. This additional delay is specified here. When set to zero or to a very small number, snapping will be immediate."), true); + this->AddPage(_page_snapping, _("Snapping"), iter_behavior, PREFS_PAGE_BEHAVIOR_SNAPPING); // Steps options diff --git a/src/ui/dialog/inkscape-preferences.h b/src/ui/dialog/inkscape-preferences.h index dcea91741..7e0184c55 100644 --- a/src/ui/dialog/inkscape-preferences.h +++ b/src/ui/dialog/inkscape-preferences.h @@ -322,6 +322,7 @@ protected: UI::Widget::PrefCheckButton _importexport_import_res_override; UI::Widget::PrefSlider _snap_delay; UI::Widget::PrefSlider _snap_weight; + UI::Widget::PrefSlider _snap_persistence; UI::Widget::PrefCheckButton _font_dialog; UI::Widget::PrefCombo _font_unit_type; UI::Widget::PrefCheckButton _font_output_px; diff --git a/src/ui/tools/tool-base.h b/src/ui/tools/tool-base.h index 7a6ab83e7..58eb6f88e 100644 --- a/src/ui/tools/tool-base.h +++ b/src/ui/tools/tool-base.h @@ -75,7 +75,12 @@ public: Inkscape::Preferences *prefs = Inkscape::Preferences::get(); double value = prefs->getDoubleLimited("/options/snapdelay/value", 0, 0, 1000); - _timer_id = g_timeout_add(value, &sp_event_context_snap_watchdog_callback, this); + // We used to have this specified in milliseconds; this has changed to seconds now for consistency's sake + if (value > 1) { // Apparently we have an old preference file, this value must have been in milliseconds; + value = value / 1000.0; // now convert this value to seconds + } + + _timer_id = g_timeout_add(value*1000.0, &sp_event_context_snap_watchdog_callback, this); _event = gdk_event_copy((GdkEvent*) event); ((GdkEventMotion *)_event)->time = GDK_CURRENT_TIME; diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp index 72597e4d9..e906762e3 100644 --- a/src/ui/widget/preferences-widget.cpp +++ b/src/ui/widget/preferences-widget.cpp @@ -205,6 +205,7 @@ void PrefCheckButton::init(Glib::ustring const &label, Glib::ustring const &pref void PrefCheckButton::on_toggled() { + this->changed_signal.emit(this->get_active()); if (this->get_visible()) //only take action if the user toggled it { Inkscape::Preferences *prefs = Inkscape::Preferences::get(); diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h index 8b75b8368..1d2d77699 100644 --- a/src/ui/widget/preferences-widget.h +++ b/src/ui/widget/preferences-widget.h @@ -59,6 +59,7 @@ class PrefCheckButton : public Gtk::CheckButton public: void init(Glib::ustring const &label, Glib::ustring const &prefs_path, bool default_value); + sigc::signal<void, bool> changed_signal; protected: Glib::ustring _prefs_path; void on_toggled(); diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp index 46f895c06..553e3a31d 100644 --- a/src/vanishing-point.cpp +++ b/src/vanishing-point.cpp @@ -130,7 +130,7 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g // FIXME: Do we need to create a new dragger as well? dragger->updateZOrders (); DocumentUndo::done(SP_ACTIVE_DESKTOP->getDocument(), SP_VERB_CONTEXT_3DBOX, - _("Split vanishing points")); + _("Split vanishing points")); return; } } @@ -175,22 +175,24 @@ vp_knot_moved_handler (SPKnot *knot, Geom::Point const &ppointer, guint state, g // as is currently the case. DocumentUndo::done(SP_ACTIVE_DESKTOP->getDocument(), SP_VERB_CONTEXT_3DBOX, - _("Merge vanishing points")); + _("Merge vanishing points")); return; } } + } - // We didn't snap to another dragger, so we'll try a regular snap - SPDesktop *desktop = SP_ACTIVE_DESKTOP; - SnapManager &m = desktop->namedview->snap_manager; - m.setup(desktop); - Inkscape::SnappedPoint s = m.freeSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_OTHER_HANDLE)); - m.unSetup(); - if (s.getSnapped()) { - p = s.getPoint(); - knot->moveto(p); - } + // We didn't hit the return statement above, so we didn't snap to another dragger. Therefore we'll now try a regular snap + // Regardless of the status of the SHIFT key, we will try to snap; Here SHIFT does not disable snapping, as the shift key + // has a different purpose in this context (see above) + SPDesktop *desktop = SP_ACTIVE_DESKTOP; + SnapManager &m = desktop->namedview->snap_manager; + m.setup(desktop); + Inkscape::SnappedPoint s = m.freeSnap(Inkscape::SnapCandidatePoint(p, Inkscape::SNAPSOURCE_OTHER_HANDLE)); + m.unSetup(); + if (s.getSnapped()) { + p = s.getPoint(); + knot->moveto(p); } dragger->point = p; // FIXME: Is dragger->point being used at all? @@ -241,7 +243,7 @@ vp_knot_ungrabbed_handler (SPKnot *knot, guint /*state*/, gpointer data) g_return_if_fail (dragger->parent); g_return_if_fail (dragger->parent->document); DocumentUndo::done(dragger->parent->document, SP_VERB_CONTEXT_3DBOX, - _("3D box: Move vanishing point")); + _("3D box: Move vanishing point")); } unsigned int VanishingPoint::global_counter = 0; @@ -630,7 +632,7 @@ VPDrag::updateBoxHandles () // FIXME: Is there a way to update the knots without accessing the // (previously) statically linked function KnotHolder::update_knots? - std::vector<SPItem*> sel = selection->itemList(); + std::vector<SPItem*> sel = selection->itemList(); if (sel.empty()) return; // no selection |
