From 193b25a53c51a36fe9538e03203b0054c8cfc355 Mon Sep 17 00:00:00 2001
From: mc <>
Date: Wed, 18 Feb 2015 02:02:37 +0100
Subject: Just... some... more... lines...
(bzr r13922.1.2)
---
src/ui/tools/gradient-tool.cpp | 43 ++++++++++++++++++++++++------------------
1 file changed, 25 insertions(+), 18 deletions(-)
(limited to 'src/ui/tools/gradient-tool.cpp')
diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp
index 5da30da7b..d1db5fb93 100644
--- a/src/ui/tools/gradient-tool.cpp
+++ b/src/ui/tools/gradient-tool.cpp
@@ -116,7 +116,7 @@ void GradientTool::selection_changed(Inkscape::Selection*) {
if (selection == NULL) {
return;
}
- guint n_obj = g_slist_length((GSList *) selection->itemList());
+ guint n_obj = selection->itemList().size();
if (!drag->isNonEmpty() || selection->isEmpty())
return;
@@ -502,10 +502,11 @@ bool GradientTool::root_handler(GdkEvent* event) {
if (over_line) {
// we take the first item in selection, because with doubleclick, the first click
// always resets selection to the single object under cursor
- sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->itemList()->data), this->mousepoint_doc, event->button.time);
+ sp_gradient_context_add_stop_near_point(this, SP_ITEM(selection->itemList().front()), this->mousepoint_doc, event->button.time);
} else {
- for (GSList const* i = selection->itemList(); i != NULL; i = i->next) {
- SPItem *item = SP_ITEM(i->data);
+ SelContainer items=selection->itemList();
+ for (SelContainer::const_iterator i = items.begin();i!=items.end();i++) {
+ SPItem *item = SP_ITEM(*i);
SPGradientType new_type = (SPGradientType) prefs->getInt("/tools/gradient/newgradient", SP_GRADIENT_TYPE_LINEAR);
Inkscape::PaintTarget fsmode = (prefs->getInt("/tools/gradient/newfillorstroke", 1) != 0) ? Inkscape::FOR_FILL : Inkscape::FOR_STROKE;
@@ -889,6 +890,12 @@ bool GradientTool::root_handler(GdkEvent* event) {
return ret;
}
+int sp_item_repr_compare_position_obj(SPObject const *first, SPObject const *second)
+{
+ return sp_repr_compare_position(((SPItem*)first)->getRepr(),
+ ((SPItem*)second)->getRepr())<0;
+}
+
static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*state*/, guint32 etime)
{
SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop;
@@ -908,32 +915,32 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta
} else {
// Starting from empty space:
// Sort items so that the topmost comes last
- GSList *items = g_slist_copy ((GSList *) selection->itemList());
- items = g_slist_sort(items, (GCompareFunc) sp_item_repr_compare_position);
+ SelContainer items(selection->itemList());
+ items.sort(sp_item_repr_compare_position_obj);
// take topmost
- vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(g_slist_last(items)->data), fill_or_stroke);
- g_slist_free (items);
+ vector = sp_gradient_vector_for_object(document, desktop, SP_ITEM(items.back()), fill_or_stroke);
}
// HACK: reset fill-opacity - that 0.75 is annoying; BUT remove this when we have an opacity slider for all tabs
SPCSSAttr *css = sp_repr_css_attr_new();
sp_repr_css_set_property(css, "fill-opacity", "1.0");
- for (GSList const *i = selection->itemList(); i != NULL; i = i->next) {
+ SelContainer itemlist = selection->itemList();
+ for (SelContainer::const_iterator i = itemlist.begin();i!=itemlist.end();i++) {
//FIXME: see above
- sp_repr_css_change_recursive(SP_OBJECT(i->data)->getRepr(), css, "style");
+ sp_repr_css_change_recursive(SP_OBJECT(*i)->getRepr(), css, "style");
- sp_item_set_gradient(SP_ITEM(i->data), vector, (SPGradientType) type, fill_or_stroke);
+ sp_item_set_gradient(SP_ITEM(*i), vector, (SPGradientType) type, fill_or_stroke);
if (type == SP_GRADIENT_TYPE_LINEAR) {
- sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_LG_BEGIN, 0, rc.origin, fill_or_stroke, true, false);
- sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_LG_END, 0, pt, fill_or_stroke, true, false);
+ sp_item_gradient_set_coords (SP_ITEM(*i), POINT_LG_BEGIN, 0, rc.origin, fill_or_stroke, true, false);
+ sp_item_gradient_set_coords (SP_ITEM(*i), POINT_LG_END, 0, pt, fill_or_stroke, true, false);
} else if (type == SP_GRADIENT_TYPE_RADIAL) {
- sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_RG_CENTER, 0, rc.origin, fill_or_stroke, true, false);
- sp_item_gradient_set_coords (SP_ITEM(i->data), POINT_RG_R1, 0, pt, fill_or_stroke, true, false);
+ sp_item_gradient_set_coords (SP_ITEM(*i), POINT_RG_CENTER, 0, rc.origin, fill_or_stroke, true, false);
+ sp_item_gradient_set_coords (SP_ITEM(*i), POINT_RG_R1, 0, pt, fill_or_stroke, true, false);
}
- SP_OBJECT(i->data)->requestModified(SP_OBJECT_MODIFIED_FLAG);
+ SP_OBJECT(*i)->requestModified(SP_OBJECT_MODIFIED_FLAG);
}
if (ec->_grdrag) {
ec->_grdrag->updateDraggers();
@@ -942,7 +949,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta
ec->_grdrag->local_change = true;
// give the grab out-of-bounds values of xp/yp because we're already dragging
// and therefore are already out of tolerance
- ec->_grdrag->grabKnot (SP_ITEM(selection->itemList()->data),
+ ec->_grdrag->grabKnot (SP_ITEM(selection->itemList().front()),
type == SP_GRADIENT_TYPE_LINEAR? POINT_LG_END : POINT_RG_R1,
-1, // ignore number (though it is always 1)
fill_or_stroke, 99999, 99999, etime);
@@ -951,7 +958,7 @@ static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*sta
// status text; we do not track coords because this branch is run once, not all the time
// during drag
- int n_objects = g_slist_length((GSList *) selection->itemList());
+ int n_objects = selection->itemList().size();
rc.message_context->setF(Inkscape::NORMAL_MESSAGE,
ngettext("Gradient for %d object; with Ctrl to snap angle",
"Gradient for %d objects; with Ctrl to snap angle", n_objects),
--
cgit v1.2.3