From b98e9f3d5d62fa5733409d4d6b1fb95e32751438 Mon Sep 17 00:00:00 2001 From: buliabyak Date: Fri, 12 Oct 2007 05:40:24 +0000 Subject: [PATCH] proper averaging of all selected draggers on query style; select-next/prev return the new selected dragger --- src/gradient-drag.cpp | 53 ++++++++++++++++++++++++++----------------- src/gradient-drag.h | 4 ++-- 2 files changed, 34 insertions(+), 23 deletions(-) diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp index 3f7195b07..9244b8fd2 100644 --- a/src/gradient-drag.cpp +++ b/src/gradient-drag.cpp @@ -128,22 +128,25 @@ gr_drag_style_query (SPStyle *style, int property, gpointer data) int count = 0; - for (GSList const* i = ((GrDragger*)drag->selected->data)->draggables; i != NULL; i = i->next) { // for all draggables of dragger - GrDraggable *draggable = (GrDraggable *) i->data; - - if (ret == QUERY_STYLE_NOTHING) { - ret = QUERY_STYLE_SINGLE; - } else if (ret == QUERY_STYLE_SINGLE) { - ret = QUERY_STYLE_MULTIPLE_AVERAGED; - } + for (GList *i = drag->selected; i != NULL; i = i->next) { // for all selected draggers + GrDragger *d = (GrDragger *) i->data; + for (GSList const* j = d->draggables; j != NULL; j = j->next) { // for all draggables of dragger + GrDraggable *draggable = (GrDraggable *) j->data; + + if (ret == QUERY_STYLE_NOTHING) { + ret = QUERY_STYLE_SINGLE; + } else if (ret == QUERY_STYLE_SINGLE) { + ret = QUERY_STYLE_MULTIPLE_AVERAGED; + } - guint32 c = sp_item_gradient_stop_query_style (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke); - cf[0] += SP_RGBA32_R_F (c); - cf[1] += SP_RGBA32_G_F (c); - cf[2] += SP_RGBA32_B_F (c); - cf[3] += SP_RGBA32_A_F (c); + guint32 c = sp_item_gradient_stop_query_style (draggable->item, draggable->point_type, draggable->point_i, draggable->fill_or_stroke); + cf[0] += SP_RGBA32_R_F (c); + cf[1] += SP_RGBA32_G_F (c); + cf[2] += SP_RGBA32_B_F (c); + cf[3] += SP_RGBA32_A_F (c); - count ++; + count ++; + } } if (count) { @@ -1679,29 +1682,37 @@ GrDrag::selected_move_screen (double x, double y) /** Select the knot next to the last selected one and deselect all other selected. */ -void +GrDragger * GrDrag::select_next () { + GrDragger *d = NULL; if (selected == NULL || g_list_find(draggers, selected->data)->next == NULL) { - if (draggers) - setSelected ((GrDragger *) draggers->data); + if (draggers) + d = (GrDragger *) draggers->data; } else { - setSelected ((GrDragger *) g_list_find(draggers, selected->data)->next->data); + d = (GrDragger *) g_list_find(draggers, selected->data)->next->data; } + if (d) + setSelected (d); + return d; } /** Select the knot previous from the last selected one and deselect all other selected. */ -void +GrDragger * GrDrag::select_prev () { + GrDragger *d = NULL; if (selected == NULL || g_list_find(draggers, selected->data)->prev == NULL) { if (draggers) - setSelected ((GrDragger *) g_list_last (draggers)->data); + d = (GrDragger *) g_list_last (draggers)->data; } else { - setSelected ((GrDragger *) g_list_find(draggers, selected->data)->prev->data); + d = (GrDragger *) g_list_find(draggers, selected->data)->prev->data; } + if (d) + setSelected (d); + return d; } diff --git a/src/gradient-drag.h b/src/gradient-drag.h index a7b5af36b..b9a2fdcc2 100644 --- a/src/gradient-drag.h +++ b/src/gradient-drag.h @@ -150,8 +150,8 @@ public: // FIXME: make more of this private! void selected_move (double x, double y, bool write_repr = true, bool scale_radial = false); void selected_move_screen (double x, double y); - void select_next (); - void select_prev (); + GrDragger *select_next (); + GrDragger *select_prev (); void selected_reverse_vector (); -- 2.30.2