X-Git-Url: https://git.tokkee.org/?a=blobdiff_plain;ds=sidebyside;f=src%2Fgradient-context.cpp;h=f104bbd413aad9a0666b4b15d3ec29a9f242420c;hb=6c572dd450c636a069b4d513f1b85742c1afb9fd;hp=03c3c947cb418a9579e9cc5a512bdfe8ea29f698;hpb=6a15201cbb894ffa10891d94c4b42acc91214f03;p=inkscape.git diff --git a/src/gradient-context.cpp b/src/gradient-context.cpp index 03c3c947c..f104bbd41 100644 --- a/src/gradient-context.cpp +++ b/src/gradient-context.cpp @@ -1,5 +1,3 @@ -#define __SP_GRADIENT_CONTEXT_C__ - /* * Gradient drawing and editing tool * @@ -147,6 +145,9 @@ gradient_selection_changed (Inkscape::Selection *, gpointer data) GrDrag *drag = rc->_grdrag; Inkscape::Selection *selection = sp_desktop_selection(SP_EVENT_CONTEXT(rc)->desktop); + if (selection == NULL) { + return; + } guint n_obj = g_slist_length((GSList *) selection->itemList()); if (!drag->isNonEmpty() || selection->isEmpty()) @@ -157,34 +158,34 @@ gradient_selection_changed (Inkscape::Selection *, gpointer data) //The use of ngettext in the following code is intentional even if the English singular form would never be used if (n_sel == 1) { if (drag->singleSelectedDraggerNumDraggables() == 1) { - gchar * message = g_strconcat( - //TRANSLATORS: %s will be substituted with the point name (see previous messages); This is part of a compound message - _("%s selected"), - //TRANSLATORS: Mind the space in front. This is part of a compound message - ngettext(" out of %d gradient handle"," out of %d gradient handles",n_tot), - ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL); - rc->_message_context->setF(Inkscape::NORMAL_MESSAGE, - message,_(gr_handle_descr[drag->singleSelectedDraggerSingleDraggableType()]), n_tot, n_obj); + gchar * message = g_strconcat( + //TRANSLATORS: %s will be substituted with the point name (see previous messages); This is part of a compound message + _("%s selected"), + //TRANSLATORS: Mind the space in front. This is part of a compound message + ngettext(" out of %d gradient handle"," out of %d gradient handles",n_tot), + ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL); + rc->_message_context->setF(Inkscape::NORMAL_MESSAGE, + message,_(gr_handle_descr[drag->singleSelectedDraggerSingleDraggableType()]), n_tot, n_obj); } else { - gchar * message = g_strconcat( - //TRANSLATORS: This is a part of a compound message (out of two more indicating: grandint handle count & object count) - ngettext("One handle merging %d stop (drag with Shift to separate) selected", - "One handle merging %d stops (drag with Shift to separate) selected",drag->singleSelectedDraggerNumDraggables()), - ngettext(" out of %d gradient handle"," out of %d gradient handles",n_tot), - ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL); - rc->_message_context->setF(Inkscape::NORMAL_MESSAGE,message,drag->singleSelectedDraggerNumDraggables(), n_tot, n_obj); + gchar * message = g_strconcat( + //TRANSLATORS: This is a part of a compound message (out of two more indicating: grandint handle count & object count) + ngettext("One handle merging %d stop (drag with Shift to separate) selected", + "One handle merging %d stops (drag with Shift to separate) selected",drag->singleSelectedDraggerNumDraggables()), + ngettext(" out of %d gradient handle"," out of %d gradient handles",n_tot), + ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL); + rc->_message_context->setF(Inkscape::NORMAL_MESSAGE,message,drag->singleSelectedDraggerNumDraggables(), n_tot, n_obj); } } else if (n_sel > 1) { - //TRANSLATORS: The plural refers to number of selected gradient handles. This is part of a compound message (part two indicates selected object count) - gchar * message = g_strconcat(ngettext("%d gradient handle selected out of %d","%d gradient handles selected out of %d",n_sel), - //TRANSLATORS: Mind the space in front. (Refers to gradient handles selected). This is part of a compound message - ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL); + //TRANSLATORS: The plural refers to number of selected gradient handles. This is part of a compound message (part two indicates selected object count) + gchar * message = g_strconcat(ngettext("%d gradient handle selected out of %d","%d gradient handles selected out of %d",n_sel), + //TRANSLATORS: Mind the space in front. (Refers to gradient handles selected). This is part of a compound message + ngettext(" on %d selected object"," on %d selected objects",n_obj),NULL); rc->_message_context->setF(Inkscape::NORMAL_MESSAGE,message, n_sel, n_tot, n_obj); } else if (n_sel == 0) { rc->_message_context->setF(Inkscape::NORMAL_MESSAGE, - //TRANSLATORS: The plural refers to number of selected objects - ngettext("No gradient handles selected out of %d on %d selected object", - "No gradient handles selected out of %d on %d selected objects",n_obj), n_tot, n_obj); + //TRANSLATORS: The plural refers to number of selected objects + ngettext("No gradient handles selected out of %d on %d selected object", + "No gradient handles selected out of %d on %d selected objects",n_obj), n_tot, n_obj); } } @@ -216,8 +217,6 @@ static void sp_gradient_context_setup(SPEventContext *ec) rc->selcon = new sigc::connection (selection->connectChanged( sigc::bind (sigc::ptr_fun(&gradient_selection_changed), rc))); rc->subselcon = new sigc::connection (ec->desktop->connectToolSubselectionChanged(sigc::bind (sigc::ptr_fun(&gradient_subselection_changed), rc))); gradient_selection_changed(selection, rc); - - sp_event_context_snap_window_open(ec); } void @@ -290,7 +289,7 @@ sp_gradient_context_get_stop_intervals (GrDrag *drag, GSList **these_stops, GSLi // from draggables to stops SPStop *this_stop = sp_get_stop_i (vector, d->point_i); - SPStop *next_stop = sp_next_stop (this_stop); + SPStop *next_stop = this_stop->getNextStop(); SPStop *last_stop = sp_last_stop (vector); gint fs = d->fill_or_stroke; @@ -361,7 +360,7 @@ sp_gradient_context_add_stops_between_selected_stops (SPGradientContext *rc) SPGradient *gradient = sp_item_gradient (d->item, d->fill_or_stroke); SPGradient *vector = sp_gradient_get_forked_vector_if_necessary (gradient, false); SPStop *this_stop = sp_get_stop_i (vector, d->point_i); - SPStop *next_stop = sp_next_stop (this_stop); + SPStop *next_stop = this_stop->getNextStop(); if (this_stop && next_stop) { these_stops = g_slist_prepend (these_stops, this_stop); next_stops = g_slist_prepend (next_stops, next_stop); @@ -380,7 +379,7 @@ sp_gradient_context_add_stops_between_selected_stops (SPGradientContext *rc) if (SP_IS_GRADIENT (parent)) { doc = SP_OBJECT_DOCUMENT (parent); sp_vector_add_stop (SP_GRADIENT (parent), this_stop, next_stop, offset); - sp_gradient_ensure_vector (SP_GRADIENT (parent)); + SP_GRADIENT(parent)->ensureVector(); } } @@ -555,10 +554,10 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) if (!(event->button.state & GDK_CONTROL_MASK)) event_context->item_to_select = sp_event_context_find_item (desktop, button_w, event->button.state & GDK_MOD1_MASK, TRUE); - /* Snap center to nearest magnetic point */ SnapManager &m = desktop->namedview->snap_manager; m.setup(desktop); - m.freeSnapReturnByRef(Inkscape::SnapPreferences::SNAPPOINT_NODE, button_dt, Inkscape::SNAPSOURCE_HANDLE); + m.freeSnapReturnByRef(button_dt, Inkscape::SNAPSOURCE_NODE_HANDLE); + m.unSetup(); rc->origin = from_2geom(button_dt); } @@ -593,6 +592,17 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) ret = TRUE; } else { + if (!drag->mouseOver()) { + SnapManager &m = desktop->namedview->snap_manager; + m.setup(desktop); + + Geom::Point const motion_w(event->motion.x, event->motion.y); + Geom::Point const motion_dt = event_context->desktop->w2d(motion_w); + + m.preSnap(Inkscape::SnapCandidatePoint(motion_dt, Inkscape::SNAPSOURCE_NODE_HANDLE)); + m.unSetup(); + } + bool over_line = false; if (drag->lines) { for (GSList *l = drag->lines; l != NULL; l = l->next) { @@ -641,7 +651,7 @@ sp_gradient_context_root_handler(SPEventContext *event_context, GdkEvent *event) if (!event_context->within_tolerance) { // we've been dragging, either do nothing (grdrag handles that), // or rubberband-select if we have rubberband - Inkscape::Rubberband::Rubberband *r = Inkscape::Rubberband::get(desktop); + Inkscape::Rubberband *r = Inkscape::Rubberband::get(desktop); if (r->is_started() && !event_context->within_tolerance) { // this was a rubberband drag if (r->getMode() == RUBBERBAND_MODE_RECT) { @@ -939,4 +949,4 @@ static void sp_gradient_drag(SPGradientContext &rc, Geom::Point const pt, guint fill-column:99 End: */ -// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :