summaryrefslogtreecommitdiffstats
path: root/src/ui/tools
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2017-11-03 00:10:02 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2017-11-03 00:10:02 +0000
commitd2df0412f728dd5bb54537dfdfe7c35b34d40e0e (patch)
treee2703384779e83312c456399999997fcc289c5cf /src/ui/tools
parentMerge branch 'master' into powerpencil (diff)
parentchange assignment to equality (diff)
downloadinkscape-d2df0412f728dd5bb54537dfdfe7c35b34d40e0e.tar.gz
inkscape-d2df0412f728dd5bb54537dfdfe7c35b34d40e0e.zip
Merge branch 'master' into powerpencil
Diffstat (limited to 'src/ui/tools')
-rw-r--r--src/ui/tools/arc-tool.cpp15
-rw-r--r--src/ui/tools/box3d-tool.cpp8
-rw-r--r--src/ui/tools/calligraphic-tool.cpp26
-rw-r--r--src/ui/tools/connector-tool.cpp4
-rw-r--r--src/ui/tools/dropper-tool.cpp2
-rw-r--r--src/ui/tools/dynamic-base.cpp7
-rw-r--r--src/ui/tools/dynamic-base.h3
-rw-r--r--src/ui/tools/eraser-tool.cpp24
-rw-r--r--src/ui/tools/flood-tool.cpp4
-rw-r--r--src/ui/tools/freehand-base.cpp76
-rw-r--r--src/ui/tools/freehand-base.h6
-rw-r--r--src/ui/tools/gradient-tool.cpp97
-rw-r--r--src/ui/tools/lpe-tool.cpp4
-rw-r--r--src/ui/tools/measure-tool.cpp4
-rw-r--r--src/ui/tools/mesh-tool.cpp74
-rw-r--r--src/ui/tools/node-tool.cpp5
-rw-r--r--src/ui/tools/pen-tool.cpp61
-rw-r--r--src/ui/tools/pencil-tool.cpp12
-rw-r--r--src/ui/tools/rect-tool.cpp29
-rw-r--r--src/ui/tools/select-tool.cpp24
-rw-r--r--src/ui/tools/spiral-tool.cpp11
-rw-r--r--src/ui/tools/spray-tool.cpp8
-rw-r--r--src/ui/tools/star-tool.cpp12
-rw-r--r--src/ui/tools/text-tool.cpp22
-rw-r--r--src/ui/tools/tool-base.cpp55
-rw-r--r--src/ui/tools/tool-base.h3
-rw-r--r--src/ui/tools/tweak-tool.cpp17
-rw-r--r--src/ui/tools/zoom-tool.cpp4
28 files changed, 275 insertions, 342 deletions
diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp
index b501962fb..33f323eb3 100644
--- a/src/ui/tools/arc-tool.cpp
+++ b/src/ui/tools/arc-tool.cpp
@@ -227,7 +227,7 @@ bool ArcTool::root_handler(GdkEvent* event) {
break;
case GDK_KEY_PRESS:
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
case GDK_KEY_Alt_L:
case GDK_KEY_Alt_R:
case GDK_KEY_Control_L:
@@ -385,8 +385,8 @@ void ArcTool::drag(Geom::Point pt, guint state) {
Inkscape::Util::Quantity rdimx_q = Inkscape::Util::Quantity(rdimx, "px");
Inkscape::Util::Quantity rdimy_q = Inkscape::Util::Quantity(rdimy, "px");
- GString *xs = g_string_new(rdimx_q.string(desktop->namedview->display_units).c_str());
- GString *ys = g_string_new(rdimy_q.string(desktop->namedview->display_units).c_str());
+ Glib::ustring xs = rdimx_q.string(desktop->namedview->display_units);
+ Glib::ustring ys = rdimy_q.string(desktop->namedview->display_units);
if (state & GDK_CONTROL_MASK) {
int ratio_x, ratio_y;
@@ -399,13 +399,10 @@ void ArcTool::drag(Geom::Point pt, guint state) {
ratio_y = (int) rint (rdimy / rdimx);
}
- this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Ellipse</b>: %s &#215; %s (constrained to ratio %d:%d); with <b>Shift</b> to draw around the starting point"), xs->str, ys->str, ratio_x, ratio_y);
+ this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Ellipse</b>: %s &#215; %s (constrained to ratio %d:%d); with <b>Shift</b> to draw around the starting point"), xs.c_str(), ys.c_str(), ratio_x, ratio_y);
} else {
- this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Ellipse</b>: %s &#215; %s; with <b>Ctrl</b> to make square or integer-ratio ellipse; with <b>Shift</b> to draw around the starting point"), xs->str, ys->str);
+ this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Ellipse</b>: %s &#215; %s; with <b>Ctrl</b> to make square or integer-ratio ellipse; with <b>Shift</b> to draw around the starting point"), xs.c_str(), ys.c_str());
}
-
- g_string_free(xs, FALSE);
- g_string_free(ys, FALSE);
}
void ArcTool::finishItem() {
@@ -418,7 +415,7 @@ void ArcTool::finishItem() {
}
this->arc->updateRepr();
- this->arc->doWriteTransform(this->arc->getRepr(), this->arc->transform, NULL, true);
+ this->arc->doWriteTransform(this->arc->transform, NULL, true);
desktop->canvas->endForcedFullRedraws();
diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp
index 276385335..09ee2cda9 100644
--- a/src/ui/tools/box3d-tool.cpp
+++ b/src/ui/tools/box3d-tool.cpp
@@ -335,7 +335,7 @@ bool Box3dTool::root_handler(GdkEvent* event) {
break;
case GDK_KEY_PRESS:
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
case GDK_KEY_Up:
case GDK_KEY_Down:
case GDK_KEY_KP_Up:
@@ -529,9 +529,9 @@ void Box3dTool::drag(guint /*state*/) {
side->setAttribute("style", cur_style.data());
} else {
// use default style
- GString *pstring = g_string_new("");
- g_string_printf (pstring, "/tools/shapes/3dbox/%s", box3d_side_axes_string(side));
- desktop->applyCurrentOrToolStyle (side, pstring->str, false);
+ Glib::ustring tool_path = Glib::ustring::compose("/tools/shapes/3dbox/%1",
+ box3d_side_axes_string(side));
+ desktop->applyCurrentOrToolStyle (side, tool_path, false);
}
side->updateRepr(); // calls box3d_side_write() and updates, e.g., the axes string description
diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp
index 266375caa..2a29b25b0 100644
--- a/src/ui/tools/calligraphic-tool.cpp
+++ b/src/ui/tools/calligraphic-tool.cpp
@@ -421,10 +421,9 @@ void CalligraphicTool::cancel() {
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), 0);
/* Remove all temporary line segments */
- while (this->segments) {
- sp_canvas_item_destroy(SP_CANVAS_ITEM(this->segments->data));
- this->segments = g_slist_remove(this->segments, this->segments->data);
- }
+ for (auto i:this->segments)
+ sp_canvas_item_destroy(SP_CANVAS_ITEM(i));
+ this->segments.clear();
/* reset accumulated curve */
this->accumulated->reset();
@@ -731,10 +730,9 @@ bool CalligraphicTool::root_handler(GdkEvent* event) {
this->apply(motion_dt);
/* Remove all temporary line segments */
- while (this->segments) {
- sp_canvas_item_destroy(SP_CANVAS_ITEM(this->segments->data));
- this->segments = g_slist_remove(this->segments, this->segments->data);
- }
+ for (auto i:this->segments)
+ sp_canvas_item_destroy(SP_CANVAS_ITEM(i));
+ this->segments.clear();
/* Create object */
this->fit_and_split(true);
@@ -779,7 +777,7 @@ bool CalligraphicTool::root_handler(GdkEvent* event) {
}
case GDK_KEY_PRESS:
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
case GDK_KEY_Up:
case GDK_KEY_KP_Up:
if (!MOD__CTRL_ONLY(event)) {
@@ -860,7 +858,7 @@ bool CalligraphicTool::root_handler(GdkEvent* event) {
break;
case GDK_KEY_RELEASE:
- switch (get_group0_keyval(&event->key)) {
+ switch (get_latin_keyval(&event->key)) {
case GDK_KEY_Control_L:
case GDK_KEY_Control_R:
this->message_context->clear();
@@ -947,7 +945,7 @@ void CalligraphicTool::set_to_accumulated(bool unionize, bool subtract) {
result = desktop->getSelection()->singleItem();
}
- result->doWriteTransform(result->getRepr(), result->transform, NULL, true);
+ result->doWriteTransform(result->transform, NULL, true);
} else {
if (this->repr) {
sp_repr_unparent(this->repr);
@@ -1089,7 +1087,7 @@ void CalligraphicTool::fit_and_split(bool release) {
this->currentcurve->curveto(bp2[2], bp2[1], bp2[0]);
}
// FIXME: dc->segments is always NULL at this point??
- if (!this->segments) { // first segment
+ if (this->segments.empty()) { // first segment
add_cap(this->currentcurve, b2[0], b1[0], this->cap_rounding);
}
this->currentcurve->closepath();
@@ -1143,8 +1141,8 @@ void CalligraphicTool::fit_and_split(bool release) {
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cbp), 0x00000000, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
/* fixme: Cannot we cascade it to root more clearly? */
g_signal_connect(G_OBJECT(cbp), "event", G_CALLBACK(sp_desktop_root_handler), desktop);
-
- this->segments = g_slist_prepend(this->segments, cbp);
+
+ this->segments.push_back(cbp);
}
this->point1[0] = this->point1[this->npoints - 1];
diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp
index 6d2682089..b9d36706f 100644
--- a/src/ui/tools/connector-tool.cpp
+++ b/src/ui/tools/connector-tool.cpp
@@ -434,7 +434,7 @@ bool ConnectorTool::root_handler(GdkEvent* event) {
break;
case GDK_KEY_PRESS:
- ret = this->_handleKeyPress(get_group0_keyval (&event->key));
+ ret = this->_handleKeyPress(get_latin_keyval (&event->key));
break;
default:
@@ -904,7 +904,7 @@ void ConnectorTool::_flushWhite(SPCurve *gc) {
this->newconn->updateRepr();
}
- this->newconn->doWriteTransform(this->newconn->getRepr(), this->newconn->transform, NULL, true);
+ this->newconn->doWriteTransform(this->newconn->transform, NULL, true);
// Only set the selection after we are finished with creating the attributes of
// the connector. Otherwise, the selection change may alter the defaults for
diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp
index 53a99e481..7bde1b698 100644
--- a/src/ui/tools/dropper-tool.cpp
+++ b/src/ui/tools/dropper-tool.cpp
@@ -345,7 +345,7 @@ bool DropperTool::root_handler(GdkEvent* event) {
break;
case GDK_KEY_PRESS:
- switch (get_group0_keyval(&event->key)) {
+ switch (get_latin_keyval(&event->key)) {
case GDK_KEY_Up:
case GDK_KEY_Down:
case GDK_KEY_KP_Up:
diff --git a/src/ui/tools/dynamic-base.cpp b/src/ui/tools/dynamic-base.cpp
index bb4989333..1026c26c6 100644
--- a/src/ui/tools/dynamic-base.cpp
+++ b/src/ui/tools/dynamic-base.cpp
@@ -21,7 +21,6 @@ namespace Tools {
DynamicBase::DynamicBase(gchar const *const *cursor_shape)
: ToolBase(cursor_shape)
, accumulated(NULL)
- , segments(NULL)
, currentshape(NULL)
, currentcurve(NULL)
, cal1(NULL)
@@ -62,10 +61,10 @@ DynamicBase::~DynamicBase() {
this->accumulated = 0;
}
- while (this->segments) {
- sp_canvas_item_destroy(SP_CANVAS_ITEM(this->segments->data));
- this->segments = g_slist_remove(this->segments, this->segments->data);
+ for (auto i:segments) {
+ sp_canvas_item_destroy(SP_CANVAS_ITEM(i));
}
+ segments.clear();
if (this->currentcurve) {
this->currentcurve = this->currentcurve->unref();
diff --git a/src/ui/tools/dynamic-base.h b/src/ui/tools/dynamic-base.h
index e270052f3..b9ffd71ce 100644
--- a/src/ui/tools/dynamic-base.h
+++ b/src/ui/tools/dynamic-base.h
@@ -20,6 +20,7 @@
*/
#include "ui/tools/tool-base.h"
+#include "display/sp-canvas-item.h"
struct SPCanvasItem;
class SPCurve;
@@ -48,7 +49,7 @@ protected:
SPCurve *accumulated;
/** canvas items for "committed" segments */
- GSList *segments;
+ std::vector<SPCanvasItem*> segments;
/** canvas item for red "leading" segment */
SPCanvasItem *currentshape;
diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp
index b4246b9cc..7892e865b 100644
--- a/src/ui/tools/eraser-tool.cpp
+++ b/src/ui/tools/eraser-tool.cpp
@@ -360,10 +360,9 @@ void EraserTool::cancel() {
this->is_drawing = false;
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), 0);
/* Remove all temporary line segments */
- while (this->segments) {
- sp_canvas_item_destroy(SP_CANVAS_ITEM(this->segments->data));
- this->segments = g_slist_remove(this->segments, this->segments->data);
- }
+ for (auto i : this->segments)
+ sp_canvas_item_destroy(SP_CANVAS_ITEM(i));
+ this->segments.clear();
/* reset accumulated curve */
this->accumulated->reset();
this->clear_current();
@@ -464,10 +463,9 @@ bool EraserTool::root_handler(GdkEvent* event) {
this->apply(motion_dt);
/* Remove all temporary line segments */
- while (this->segments) {
- sp_canvas_item_destroy(SP_CANVAS_ITEM(this->segments->data));
- this->segments = g_slist_remove(this->segments, this->segments->data);
- }
+ for (auto i : this->segments)
+ sp_canvas_item_destroy(SP_CANVAS_ITEM(i));
+ this->segments.clear();
/* Create object */
this->fit_and_split(true);
@@ -494,7 +492,7 @@ bool EraserTool::root_handler(GdkEvent* event) {
}
case GDK_KEY_PRESS:
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
// case GDK_KEY_Up:
// case GDK_KEY_KP_Up:
// if (!MOD__CTRL_ONLY(event)) {
@@ -598,7 +596,7 @@ bool EraserTool::root_handler(GdkEvent* event) {
break;
case GDK_KEY_RELEASE:
- switch (get_group0_keyval(&event->key)) {
+ switch (get_latin_keyval(&event->key)) {
case GDK_KEY_Control_L:
case GDK_KEY_Control_R:
this->message_context->clear();
@@ -780,7 +778,7 @@ void EraserTool::set_to_accumulated() {
if (dup_clip) {
SPItem * dup_clip_obj = SP_ITEM(item_repr->parent->appendChildRepr(dup_clip));
if (dup_clip_obj) {
- dup_clip_obj->doWriteTransform(dup_clip, item->transform);
+ dup_clip_obj->doWriteTransform(item->transform);
sp_object_ref(clip_path, 0);
clip_path->deleteObject(true);
sp_object_unref(clip_path);
@@ -1015,7 +1013,7 @@ void EraserTool::fit_and_split(bool release) {
}
// FIXME: this->segments is always NULL at this point??
- if (!this->segments) { // first segment
+ if (this->segments.empty()) { // first segment
add_cap(this->currentcurve, b2[1], b2[0], b1[0], b1[1], this->cap_rounding);
}
@@ -1072,7 +1070,7 @@ void EraserTool::fit_and_split(bool release) {
/* fixme: Cannot we cascade it to root more clearly? */
g_signal_connect(G_OBJECT(cbp), "event", G_CALLBACK(sp_desktop_root_handler), desktop);
- this->segments = g_slist_prepend(this->segments, cbp);
+ this->segments.push_back(cbp);
if (eraser_mode == ERASER_MODE_DELETE) {
sp_canvas_item_hide(cbp);
diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp
index f6f9b4355..401b50c1c 100644
--- a/src/ui/tools/flood-tool.cpp
+++ b/src/ui/tools/flood-tool.cpp
@@ -444,7 +444,7 @@ static void do_trace(bitmap_coords_info bci, guchar *trace_px, SPDesktop *deskto
SPObject *reprobj = document->getObjectByRepr(pathRepr);
if (reprobj) {
- SP_ITEM(reprobj)->doWriteTransform(pathRepr, transform, NULL);
+ SP_ITEM(reprobj)->doWriteTransform(transform);
// premultiply the item transform by the accumulated parent transform in the paste layer
Geom::Affine local (SP_GROUP(desktop->currentLayer())->i2doc_affine());
@@ -1189,7 +1189,7 @@ bool FloodTool::root_handler(GdkEvent* event) {
}
break;
case GDK_KEY_PRESS:
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
case GDK_KEY_Up:
case GDK_KEY_Down:
case GDK_KEY_KP_Up:
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp
index 32f2bdde1..064a83a5a 100644
--- a/src/ui/tools/freehand-base.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -81,13 +81,10 @@ FreehandBase::FreehandBase(gchar const *const *cursor_shape)
, red_curve(NULL)
, blue_bpath(NULL)
, blue_curve(NULL)
- , green_bpaths(NULL)
, green_curve(NULL)
, green_anchor(NULL)
, green_closed(false)
, white_item(NULL)
- , white_curves(NULL)
- , white_anchors(NULL)
, overwrite_curve(NULL)
, sa(NULL)
, ea(NULL)
@@ -178,7 +175,7 @@ bool FreehandBase::root_handler(GdkEvent* event) {
switch (event->type) {
case GDK_KEY_PRESS:
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
case GDK_KEY_Up:
case GDK_KEY_Down:
case GDK_KEY_KP_Up:
@@ -619,22 +616,20 @@ static void spdc_attach_selection(FreehandBase *dc, Inkscape::Selection */*sel*/
SPCurve *norm = SP_PATH(item)->get_curve_for_edit();
norm->transform((dc->white_item)->i2dt_affine());
g_return_if_fail( norm != NULL );
- dc->white_curves = g_slist_reverse(norm->split());
+ dc->white_curves = norm->split();
norm->unref();
// Anchor list
- for (GSList *l = dc->white_curves; l != NULL; l = l->next) {
- SPCurve *c;
- c = static_cast<SPCurve*>(l->data);
+ for (auto c:dc->white_curves) {
g_return_if_fail( c->get_segment_count() > 0 );
if ( !c->is_closed() ) {
SPDrawAnchor *a;
a = sp_draw_anchor_new(dc, c, TRUE, *(c->first_point()));
if (a)
- dc->white_anchors = g_slist_prepend(dc->white_anchors, a);
+ dc->white_anchors.push_back(a);
a = sp_draw_anchor_new(dc, c, FALSE, *(c->last_point()));
if (a)
- dc->white_anchors = g_slist_prepend(dc->white_anchors, a);
+ dc->white_anchors.push_back(a);
}
}
// fixme: recalculate active anchor?
@@ -706,10 +701,9 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// Green
dc->green_curve = new SPCurve();
- while (dc->green_bpaths) {
- sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->green_bpaths->data));
- dc->green_bpaths = g_slist_remove(dc->green_bpaths, dc->green_bpaths->data);
- }
+ for (auto i : dc->green_bpaths)
+ sp_canvas_item_destroy(i);
+ dc->green_bpaths.clear();
// Blue
c->append_continuous(dc->blue_curve, 0.0625);
@@ -759,8 +753,8 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
c->unref();
dc->overwrite_curve->closepath_current();
if(dc->sa){
- dc->white_curves = g_slist_remove(dc->white_curves, dc->sa->curve);
- dc->white_curves = g_slist_append(dc->white_curves, dc->overwrite_curve);
+ dc->white_curves.erase(std::find(dc->white_curves.begin(),dc->white_curves.end(), dc->sa->curve));
+ dc->white_curves.push_back(dc->overwrite_curve);
}
}else{
dc->sa->curve->append_continuous(c, 0.0625);
@@ -774,7 +768,7 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
// Step C - test start
if (dc->sa) {
SPCurve *s = dc->sa->curve;
- dc->white_curves = g_slist_remove(dc->white_curves, s);
+ dc->white_curves.erase(std::find(dc->white_curves.begin(),dc->white_curves.end(), s));
if(prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 1 ||
prefs->getInt(tool_name(dc) + "/freehand-mode", 0) == 2){
s = dc->overwrite_curve;
@@ -787,7 +781,7 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
c = s;
} else /* Step D - test end */ if (dc->ea) {
SPCurve *e = dc->ea->curve;
- dc->white_curves = g_slist_remove(dc->white_curves, e);
+ dc->white_curves.erase(std::find(dc->white_curves.begin(),dc->white_curves.end(), e));
if (!dc->ea->start) {
e = reverse_then_unref(e);
}
@@ -827,11 +821,10 @@ void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
static void spdc_flush_white(FreehandBase *dc, SPCurve *gc)
{
SPCurve *c;
- if (dc->white_curves) {
+ if (! dc->white_curves.empty()) {
g_assert(dc->white_item);
c = SPCurve::concat(dc->white_curves);
- g_slist_free(dc->white_curves);
- dc->white_curves = NULL;
+ dc->white_curves.clear();
if (gc) {
c->append(gc, FALSE);
}
@@ -883,7 +876,7 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc)
Inkscape::GC::release(repr);
item->transform = SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
item->updateRepr();
- item->doWriteTransform(item->getRepr(), item->transform, NULL, true);
+ item->doWriteTransform(item->transform, NULL, true);
spdc_check_for_and_apply_waiting_LPE(dc, item, c, false);
dc->selection->set(repr);
if(previous_shape_type == BEND_CLIPBOARD){
@@ -917,8 +910,8 @@ SPDrawAnchor *spdc_test_inside(FreehandBase *dc, Geom::Point p)
active = sp_draw_anchor_test(dc->green_anchor, p, TRUE);
}
- for (GSList *l = dc->white_anchors; l != NULL; l = l->next) {
- SPDrawAnchor *na = sp_draw_anchor_test(static_cast<SPDrawAnchor*>(l->data), p, !active);
+ for (auto i:dc->white_anchors) {
+ SPDrawAnchor *na = sp_draw_anchor_test(i, p, !active);
if ( !active && na ) {
active = na;
}
@@ -932,14 +925,12 @@ static void spdc_reset_white(FreehandBase *dc)
// We do not hold refcount
dc->white_item = NULL;
}
- while (dc->white_curves) {
- reinterpret_cast<SPCurve *>(dc->white_curves->data)->unref();
- dc->white_curves = g_slist_remove(dc->white_curves, dc->white_curves->data);
- }
- while (dc->white_anchors) {
- sp_draw_anchor_destroy(static_cast<SPDrawAnchor*>(dc->white_anchors->data));
- dc->white_anchors = g_slist_remove(dc->white_anchors, dc->white_anchors->data);
- }
+ for (auto i: dc->white_curves)
+ i->unref();
+ dc->white_curves.clear();
+ for (auto i:dc->white_anchors)
+ sp_draw_anchor_destroy(i);
+ dc->white_anchors.clear();
}
static void spdc_free_colors(FreehandBase *dc)
@@ -963,10 +954,9 @@ static void spdc_free_colors(FreehandBase *dc)
}
// Green
- while (dc->green_bpaths) {
- sp_canvas_item_destroy(SP_CANVAS_ITEM(dc->green_bpaths->data));
- dc->green_bpaths = g_slist_remove(dc->green_bpaths, dc->green_bpaths->data);
- }
+ for (auto i : dc->green_bpaths)
+ sp_canvas_item_destroy(i);
+ dc->green_bpaths.clear();
if (dc->green_curve) {
dc->green_curve = dc->green_curve->unref();
}
@@ -979,14 +969,12 @@ static void spdc_free_colors(FreehandBase *dc)
// We do not hold refcount
dc->white_item = NULL;
}
- while (dc->white_curves) {
- reinterpret_cast<SPCurve *>(dc->white_curves->data)->unref();
- dc->white_curves = g_slist_remove(dc->white_curves, dc->white_curves->data);
- }
- while (dc->white_anchors) {
- sp_draw_anchor_destroy(static_cast<SPDrawAnchor *>(dc->white_anchors->data));
- dc->white_anchors = g_slist_remove(dc->white_anchors, dc->white_anchors->data);
- }
+ for (auto i: dc->white_curves)
+ i->unref();
+ dc->white_curves.clear();
+ for (auto i:dc->white_anchors)
+ sp_draw_anchor_destroy(i);
+ dc->white_anchors.clear();
}
void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *tool, guint event_state) {
diff --git a/src/ui/tools/freehand-base.h b/src/ui/tools/freehand-base.h
index 8759e6647..02d0a9982 100644
--- a/src/ui/tools/freehand-base.h
+++ b/src/ui/tools/freehand-base.h
@@ -66,15 +66,15 @@ public:
SPCurve *blue_curve;
// Green
- GSList *green_bpaths;
+ std::vector<SPCanvasItem*> green_bpaths;
SPCurve *green_curve;
SPDrawAnchor *green_anchor;
gboolean green_closed; // a flag meaning we hit the green anchor, so close the path on itself
// White
SPItem *white_item;
- GSList *white_curves;
- GSList *white_anchors;
+ std::list<SPCurve *> white_curves;
+ std::vector<SPDrawAnchor*> white_anchors;
// Alternative curve to use on continuing the exisiting curve in case of
// bspline or spirolive, because using anchor curves gives random memory
diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp
index 95d940bd6..1735a78df 100644
--- a/src/ui/tools/gradient-tool.cpp
+++ b/src/ui/tools/gradient-tool.cpp
@@ -219,7 +219,7 @@ sp_gradient_context_is_over_line (GradientTool *rc, SPItem *item, Geom::Point ev
}
static std::vector<Geom::Point>
-sp_gradient_context_get_stop_intervals (GrDrag *drag, GSList **these_stops, GSList **next_stops)
+sp_gradient_context_get_stop_intervals (GrDrag *drag, std::vector<SPStop *> &these_stops, std::vector<SPStop *> &next_stops)
{
std::vector<Geom::Point> coords;
@@ -285,15 +285,15 @@ sp_gradient_context_get_stop_intervals (GrDrag *drag, GSList **these_stops, GSLi
}
// if both adjacent draggers selected,
- if (!g_slist_find(*these_stops, this_stop) && dnext && dnext->isSelected()) {
+ if ((std::find(these_stops.begin(),these_stops.end(),this_stop)==these_stops.end()) && dnext && dnext->isSelected()) {
// remember the coords of the future dragger to select it
coords.push_back(0.5*(dragger->point + dnext->point));
// do not insert a stop now, it will confuse the loop;
// just remember the stops
- *these_stops = g_slist_prepend (*these_stops, this_stop);
- *next_stops = g_slist_prepend (*next_stops, next_stop);
+ these_stops.push_back(this_stop);
+ next_stops.push_back(next_stop);
}
}
}
@@ -307,12 +307,12 @@ sp_gradient_context_add_stops_between_selected_stops (GradientTool *rc)
SPDocument *doc = NULL;
GrDrag *drag = rc->_grdrag;
- GSList *these_stops = NULL;
- GSList *next_stops = NULL;
+ std::vector<SPStop *> these_stops;
+ std::vector<SPStop *> next_stops;
- std::vector<Geom::Point> coords = sp_gradient_context_get_stop_intervals (drag, &these_stops, &next_stops);
+ std::vector<Geom::Point> coords = sp_gradient_context_get_stop_intervals (drag, these_stops, next_stops);
- if (g_slist_length(these_stops) == 0 && drag->numSelected() == 1) {
+ if (these_stops.empty() && drag->numSelected() == 1) {
// if a single stop is selected, add between that stop and the next one
GrDragger *dragger = *(drag->selected.begin());
for (std::vector<GrDraggable *>::const_iterator j = dragger->draggables.begin(); j != dragger->draggables.end(); ++j) {
@@ -330,47 +330,42 @@ sp_gradient_context_add_stops_between_selected_stops (GradientTool *rc)
if (this_stop) {
SPStop *next_stop = this_stop->getNextStop();
if (next_stop) {
- these_stops = g_slist_prepend (these_stops, this_stop);
- next_stops = g_slist_prepend (next_stops, next_stop);
+ these_stops.push_back(this_stop);
+ next_stops.push_back(next_stop);
}
}
}
}
// now actually create the new stops
- GSList *i = these_stops;
- GSList *j = next_stops;
- GSList *new_stops = NULL;
+ auto i = these_stops.rbegin();
+ auto j = next_stops.rbegin();
+ std::vector<SPStop *> new_stops;
- for (; i != NULL && j != NULL; i = i->next, j = j->next) {
- SPStop *this_stop = (SPStop *) i->data;
- SPStop *next_stop = (SPStop *) j->data;
+ for (;i != these_stops.rend() && j != next_stops.rend(); ++i, ++j ) {
+ SPStop *this_stop = *i;
+ SPStop *next_stop = *j;
gfloat offset = 0.5*(this_stop->offset + next_stop->offset);
SPObject *parent = this_stop->parent;
if (SP_IS_GRADIENT (parent)) {
doc = parent->document;
SPStop *new_stop = sp_vector_add_stop (SP_GRADIENT (parent), this_stop, next_stop, offset);
- new_stops = g_slist_prepend (new_stops, new_stop);
+ new_stops.push_back(new_stop);
SP_GRADIENT(parent)->ensureVector();
}
}
- if (g_slist_length(these_stops) > 0 && doc) {
+ if (!these_stops.empty() && doc) {
DocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT, _("Add gradient stop"));
drag->updateDraggers();
// so that it does not automatically update draggers in idle loop, as this would deselect
drag->local_change = true;
// select the newly created stops
- for (GSList *s = new_stops; s != NULL; s = s->next) {
- drag->selectByStop((SPStop *)s->data);
+ for (auto i:new_stops) {
+ drag->selectByStop(i);
}
-
}
-
- g_slist_free (these_stops);
- g_slist_free (next_stops);
- g_slist_free (new_stops);
}
static double sqr(double x) {return x*x;}
@@ -381,26 +376,25 @@ sp_gradient_simplify(GradientTool *rc, double tolerance)
SPDocument *doc = NULL;
GrDrag *drag = rc->_grdrag;
- GSList *these_stops = NULL;
- GSList *next_stops = NULL;
+ std::vector<SPStop *> these_stops;
+ std::vector<SPStop *> next_stops;
- std::vector<Geom::Point> coords = sp_gradient_context_get_stop_intervals (drag, &these_stops, &next_stops);
+ std::vector<Geom::Point> coords = sp_gradient_context_get_stop_intervals (drag, these_stops, next_stops);
- GSList *todel = NULL;
+ std::set<SPStop *> todel;
- GSList *i = these_stops;
- GSList *j = next_stops;
- for (; i != NULL && j != NULL; i = i->next, j = j->next) {
- SPStop *stop0 = (SPStop *) i->data;
- SPStop *stop1 = (SPStop *) j->data;
+ auto i = these_stops.begin();
+ auto j = next_stops.end();
+ for (; i != these_stops.end() && j != next_stops.end(); ++i, ++j) {
+ SPStop *stop0 = *i;
+ SPStop *stop1 = *j;
- gint i1 = g_slist_index(these_stops, stop1);
- if (i1 != -1) {
- GSList *next_next = g_slist_nth (next_stops, i1);
- if (next_next) {
- SPStop *stop2 = (SPStop *) next_next->data;
+ auto i1 = std::find(these_stops.begin(), these_stops.end(), stop1);
+ if (i1 != these_stops.end()) {
+ if (next_stops.size()>(i1-these_stops.begin())) {
+ SPStop *stop2 = *(next_stops.begin() + (i1-these_stops.begin()));
- if (g_slist_find(todel, stop0) || g_slist_find(todel, stop2))
+ if (todel.find(stop0)!=todel.end() || todel.find(stop2) != todel.end())
continue;
guint32 const c0 = stop0->get_rgba32();
@@ -416,28 +410,23 @@ sp_gradient_simplify(GradientTool *rc, double tolerance)
sqr(SP_RGBA32_A_F(c1) - SP_RGBA32_A_F(c1r));
if (diff < tolerance)
- todel = g_slist_prepend (todel, stop1);
+ todel.insert(stop1);
}
}
}
- for (i = todel; i != NULL; i = i->next) {
- SPStop *stop = (SPStop*) i->data;
+ for (auto stop : todel) {
doc = stop->document;
Inkscape::XML::Node * parent = stop->getRepr()->parent();
parent->removeChild( stop->getRepr() );
}
- if (g_slist_length(todel) > 0) {
+ if (!todel.empty()) {
DocumentUndo::done(doc, SP_VERB_CONTEXT_GRADIENT, _("Simplify gradient"));
drag->local_change = true;
drag->updateDraggers();
drag->selectByCoords(coords);
}
-
- g_slist_free (todel);
- g_slist_free (these_stops);
- g_slist_free (next_stops);
}
@@ -676,7 +665,7 @@ bool GradientTool::root_handler(GdkEvent* event) {
break;
case GDK_KEY_PRESS:
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
case GDK_KEY_Alt_L:
case GDK_KEY_Alt_R:
case GDK_KEY_Control_L:
@@ -730,7 +719,7 @@ bool GradientTool::root_handler(GdkEvent* event) {
case GDK_KEY_KP_4:
if (!MOD__CTRL(event)) { // not ctrl
gint mul = 1 + gobble_key_events(
- get_group0_keyval(&event->key), 0); // with any mask
+ get_latin_keyval(&event->key), 0); // with any mask
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
drag->selected_move_screen(mul*-10, 0); // shift
@@ -753,7 +742,7 @@ bool GradientTool::root_handler(GdkEvent* event) {
case GDK_KEY_KP_8:
if (!MOD__CTRL(event)) { // not ctrl
gint mul = 1 + gobble_key_events(
- get_group0_keyval(&event->key), 0); // with any mask
+ get_latin_keyval(&event->key), 0); // with any mask
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
drag->selected_move_screen(0, mul*10); // shift
@@ -777,7 +766,7 @@ bool GradientTool::root_handler(GdkEvent* event) {
case GDK_KEY_KP_6:
if (!MOD__CTRL(event)) { // not ctrl
gint mul = 1 + gobble_key_events(
- get_group0_keyval(&event->key), 0); // with any mask
+ get_latin_keyval(&event->key), 0); // with any mask
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
@@ -802,7 +791,7 @@ bool GradientTool::root_handler(GdkEvent* event) {
case GDK_KEY_KP_2:
if (!MOD__CTRL(event)) { // not ctrl
gint mul = 1 + gobble_key_events(
- get_group0_keyval(&event->key), 0); // with any mask
+ get_latin_keyval(&event->key), 0); // with any mask
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
@@ -859,7 +848,7 @@ bool GradientTool::root_handler(GdkEvent* event) {
break;
case GDK_KEY_RELEASE:
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
case GDK_KEY_Alt_L:
case GDK_KEY_Alt_R:
case GDK_KEY_Control_L:
diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp
index 35e6d14a0..ad3964f4a 100644
--- a/src/ui/tools/lpe-tool.cpp
+++ b/src/ui/tools/lpe-tool.cpp
@@ -225,14 +225,14 @@ bool LpeTool::root_handler(GdkEvent* event) {
case GDK_KEY_PRESS:
/**
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
}
break;
**/
case GDK_KEY_RELEASE:
/**
- switch (get_group0_keyval(&event->key)) {
+ switch (get_latin_keyval(&event->key)) {
case GDK_Control_L:
case GDK_Control_R:
dc->_message_context->clear();
diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp
index 0da883891..24295e7cf 100644
--- a/src/ui/tools/measure-tool.cpp
+++ b/src/ui/tools/measure-tool.cpp
@@ -1005,7 +1005,7 @@ void MeasureTool::setLabelText(const char *value, Geom::Point pos, double fontsi
text_item_box->transform *= Geom::Translate(pos);
text_item_box->transform *= SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
text_item_box->updateRepr();
- text_item_box->doWriteTransform(text_item_box->getRepr(), text_item_box->transform, NULL, true);
+ text_item_box->doWriteTransform(text_item_box->transform, NULL, true);
Inkscape::XML::Node *rlabel = text_item_box->getRepr();
text_item_box->deleteObject();
measure_repr->addChild(rlabel, NULL);
@@ -1014,7 +1014,7 @@ void MeasureTool::setLabelText(const char *value, Geom::Point pos, double fontsi
text_item->transform *= Geom::Rotate(angle);
text_item->transform *= Geom::Translate(pos);
text_item->transform *= SP_ITEM(desktop->currentLayer())->i2doc_affine().inverse();
- text_item->doWriteTransform(text_item->getRepr(), text_item->transform, NULL, true);
+ text_item->doWriteTransform(text_item->transform, NULL, true);
}
}
diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp
index d79741270..fdfae84df 100644
--- a/src/ui/tools/mesh-tool.cpp
+++ b/src/ui/tools/mesh-tool.cpp
@@ -170,68 +170,6 @@ void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) {
// FIXME
// We need to update mesh gradient handles.
// Get gradient this drag belongs too..
- // std::cout << "mesh_selection_changed: selection: objects: " << n_obj << std::endl;
- // GSList *itemList = (GSList *) selection->itemList();
- // while( itemList ) {
-
- // SPItem *item = SP_ITEM( itemList->data );
- // // std::cout << " item: " << SP_OBJECT(item)->getId() << std::endl;
-
- // SPStyle *style = item->style;
- // if (style && (style->fill.isPaintserver())) {
-
- // SPPaintServer *server = item->style->getFillPaintServer();
- // if ( SP_IS_MESHGRADIENT(server) ) {
-
- // SPMeshGradient *mg = SP_MESHGRADIENT(server);
-
- // guint rows = 0;//mg->array.patches.size();
- // for ( guint i = 0; i < rows; ++i ) {
- // guint columns = 0;//mg->array.patches[0].size();
- // for ( guint j = 0; j < columns; ++j ) {
- // }
- // }
- // }
- // }
- // itemList = itemList->next;
- // }
-
- // GList* dragger_ptr = drag->draggers; // Points to GrDragger class (group of GrDraggable)
- // guint count = 0;
- // while( dragger_ptr ) {
-
- // std::cout << "mesh_selection_changed: dragger: " << ++count << std::endl;
- // GSList* draggable_ptr = ((GrDragger *) dragger_ptr->data)->draggables;
-
- // while( draggable_ptr ) {
-
- // std::cout << "mesh_selection_changed: draggable: " << draggable_ptr << std::endl;
- // GrDraggable *draggable = (GrDraggable *) draggable_ptr->data;
-
- // gint point_type = draggable->point_type;
- // gint point_i = draggable->point_i;
- // bool fill_or_stroke = draggable->fill_or_stroke;
-
- // if( point_type == POINT_MG_CORNER ) {
-
- // //std::cout << "mesh_selection_changed: POINT_MG_CORNER: " << point_i << std::endl;
- // // Now we must create or destroy corresponding handles.
-
- // if( g_list_find( drag->selected, dragger_ptr->data ) ) {
- // //std::cout << "gradient_selection_changed: Selected: " << point_i << std::endl;
- // // Which meshes does this point belong to?
-
- // } else {
- // //std::cout << "mesh_selection_changed: Not Selected: " << point_i << std::endl;
- // }
- // }
-
- // draggable_ptr = draggable_ptr->next;
-
- // }
-
- // dragger_ptr = dragger_ptr->next;
- // }
}
void MeshTool::setup() {
@@ -887,7 +825,7 @@ bool MeshTool::root_handler(GdkEvent* event) {
#endif
// FIXME: tip
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
case GDK_KEY_Alt_L:
case GDK_KEY_Alt_R:
case GDK_KEY_Control_L:
@@ -926,7 +864,7 @@ bool MeshTool::root_handler(GdkEvent* event) {
case GDK_KEY_KP_Left:
case GDK_KEY_KP_4:
if (!MOD__CTRL(event)) { // not ctrl
- gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask
+ gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
@@ -950,7 +888,7 @@ bool MeshTool::root_handler(GdkEvent* event) {
case GDK_KEY_KP_Up:
case GDK_KEY_KP_8:
if (!MOD__CTRL(event)) { // not ctrl
- gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask
+ gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
@@ -974,7 +912,7 @@ bool MeshTool::root_handler(GdkEvent* event) {
case GDK_KEY_KP_Right:
case GDK_KEY_KP_6:
if (!MOD__CTRL(event)) { // not ctrl
- gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask
+ gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
@@ -998,7 +936,7 @@ bool MeshTool::root_handler(GdkEvent* event) {
case GDK_KEY_KP_Down:
case GDK_KEY_KP_2:
if (!MOD__CTRL(event)) { // not ctrl
- gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask
+ gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
@@ -1096,7 +1034,7 @@ bool MeshTool::root_handler(GdkEvent* event) {
#ifdef DEBUG_MESH
std::cout << "sp_mesh_context_root_handler: GDK_KEY_RELEASE" << std::endl;
#endif
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
case GDK_KEY_Alt_L:
case GDK_KEY_Alt_R:
case GDK_KEY_Control_L:
diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp
index d508a16f2..2b3de5203 100644
--- a/src/ui/tools/node-tool.cpp
+++ b/src/ui/tools/node-tool.cpp
@@ -358,6 +358,7 @@ void NodeTool::set(const Inkscape::Preferences::Entry& value) {
}
/** Recursively collect ShapeRecords */
+static
void gather_items(NodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::ShapeRole role,
std::set<Inkscape::UI::ShapeRecord> &s)
{
@@ -437,7 +438,7 @@ void NodeTool::selection_changed(Inkscape::Selection *sel) {
if ((SP_IS_SHAPE(r.item) || SP_IS_TEXT(r.item) || SP_IS_GROUP(r.item) || SP_IS_OBJECTGROUP(r.item)) &&
this->_shape_editors.find(r.item) == this->_shape_editors.end())
{
- ShapeEditor *si = new ShapeEditor(this->desktop);
+ ShapeEditor *si = new ShapeEditor(this->desktop, r.edit_transform);
si->set_item(r.item);
this->_shape_editors.insert(const_cast<SPItem*&>(r.item), si);
}
@@ -549,7 +550,7 @@ bool NodeTool::root_handler(GdkEvent* event) {
// otherwise some features cease to work
case GDK_KEY_PRESS:
- switch (get_group0_keyval(&event->key))
+ switch (get_latin_keyval(&event->key))
{
case GDK_KEY_Escape: // deselect everything
if (this->_selected_nodes->empty()) {
diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp
index dcdbe1220..16cdf63b5 100644
--- a/src/ui/tools/pen-tool.cpp
+++ b/src/ui/tools/pen-tool.cpp
@@ -861,18 +861,18 @@ bool PenTool::_handle2ButtonPress(GdkEventButton const &bevent) {
void PenTool::_redrawAll() {
// green
- if (this->green_bpaths) {
+ if (! this->green_bpaths.empty()) {
// remove old piecewise green canvasitems
- while (this->green_bpaths) {
- sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data));
- this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
+ for (auto i : this->green_bpaths){
+ sp_canvas_item_destroy(i);
}
+ this->green_bpaths.clear();
// one canvas bpath for all of green_curve
SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve, true);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(canvas_shape), 0, SP_WIND_RULE_NONZERO);
- this->green_bpaths = g_slist_prepend(this->green_bpaths, canvas_shape);
+ this->green_bpaths.push_back(canvas_shape);
}
if (this->green_anchor) {
SP_CTRL(this->green_anchor->ctrl)->moveto(this->green_anchor->dp);
@@ -1063,7 +1063,7 @@ bool PenTool::_handleKeyPress(GdkEvent *event) {
}
}
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
case GDK_KEY_Left: // move last point left
case GDK_KEY_KP_Left:
if (!MOD__CTRL(event)) { // not ctrl
@@ -1254,10 +1254,10 @@ void PenTool::_resetColors() {
this->blue_curve->reset();
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->blue_bpath), NULL, true);
// Green
- while (this->green_bpaths) {
- sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data));
- this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
+ for (auto i:this->green_bpaths) {
+ sp_canvas_item_destroy(i);
}
+ this->green_bpaths.clear();
this->green_curve->reset();
if (this->green_anchor) {
this->green_anchor = sp_draw_anchor_destroy(this->green_anchor);
@@ -1292,7 +1292,7 @@ void PenTool::_setAngleDistanceStatusMessage(Geom::Point const p, int pc_point_t
Geom::Point rel = p - this->p[pc_point_to_compare];
Inkscape::Util::Quantity q = Inkscape::Util::Quantity(Geom::L2(rel), "px");
- GString *dist = g_string_new(q.string(desktop->namedview->display_units).c_str());
+ Glib::ustring dist = q.string(desktop->namedview->display_units);
double angle = atan2(rel[Geom::Y], rel[Geom::X]) * 180 / M_PI;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/options/compassangledisplay/value", 0) != 0) {
@@ -1302,8 +1302,7 @@ void PenTool::_setAngleDistanceStatusMessage(Geom::Point const p, int pc_point_t
}
}
- this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, message, angle, dist->str);
- g_string_free(dist, false);
+ this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, message, angle, dist.c_str());
}
// this function changes the colors red, green and blue making them transparent or not, depending on if spiro is being used.
@@ -1334,17 +1333,17 @@ void PenTool::_bsplineSpiroColor()
}
//We erase all the "green_bpaths" to recreate them after with the colour
//transparency recently modified
- if (this->green_bpaths) {
+ if (!this->green_bpaths.empty()) {
// remove old piecewise green canvasitems
- while (this->green_bpaths) {
- sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data));
- this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
+ for (auto i:this->green_bpaths) {
+ sp_canvas_item_destroy(i);
}
+ this->green_bpaths.clear();
// one canvas bpath for all of green_curve
SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve, true);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(canvas_shape), 0, SP_WIND_RULE_NONZERO);
- this->green_bpaths = g_slist_prepend(this->green_bpaths, canvas_shape);
+ this->green_bpaths.push_back(canvas_shape);
}
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(this->red_bpath), this->red_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
}
@@ -1557,18 +1556,18 @@ void PenTool::_bsplineSpiroMotion(guint const state){
this->overwrite_curve = tmp_curve->copy();
}
}
- if (this->green_bpaths) {
+ if (!this->green_bpaths.empty()) {
this->green_curve = tmp_curve->copy();
// remove old piecewise green canvasitems
- while (this->green_bpaths) {
- sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data));
- this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
+ for (auto i: this->green_bpaths) {
+ sp_canvas_item_destroy(i);
}
+ this->green_bpaths.clear();
// one canvas bpath for all of green_curve
SPCanvasItem *canvas_shape = sp_canvas_bpath_new(this->desktop->getSketch(), this->green_curve, true);
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
sp_canvas_bpath_set_fill(SP_CANVAS_BPATH(canvas_shape), 0, SP_WIND_RULE_NONZERO);
- this->green_bpaths = g_slist_prepend(this->green_bpaths, canvas_shape);
+ this->green_bpaths.push_back(canvas_shape);
}
}
if (cubic) {
@@ -1929,7 +1928,7 @@ void PenTool::_finishSegment(Geom::Point const p, guint const state) {
curve->unref();
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(canvas_shape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
- this->green_bpaths = g_slist_prepend(this->green_bpaths, canvas_shape);
+ this->green_bpaths.push_back(canvas_shape);
this->p[0] = this->p[3];
this->p[1] = this->p[4];
@@ -1955,11 +1954,9 @@ bool PenTool::_undoLastPoint() {
// Reset red curve
this->red_curve->reset();
// Destroy topmost green bpath
- if (this->green_bpaths) {
- if (this->green_bpaths->data) {
- sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data));
- }
- this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
+ if (!this->green_bpaths.empty()) {
+ sp_canvas_item_destroy(this->green_bpaths.back());
+ this->green_bpaths.pop_back();
}
// Get last segment
if ( this->green_curve->is_unset() ) {
@@ -1987,11 +1984,9 @@ bool PenTool::_undoLastPoint() {
// delete the last segment of the green curve
if (this->green_curve->get_segment_count() == 1) {
this->npoints = 5;
- if (this->green_bpaths) {
- if (this->green_bpaths->data) {
- sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data));
- }
- this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
+ if (!this->green_bpaths.empty()) {
+ sp_canvas_item_destroy(this->green_bpaths.back());
+ this->green_bpaths.pop_back();
}
this->green_curve->reset();
} else {
diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp
index 3705d0f43..6f64e8e26 100644
--- a/src/ui/tools/pencil-tool.cpp
+++ b/src/ui/tools/pencil-tool.cpp
@@ -475,10 +475,10 @@ void PencilTool::_cancel() {
this->red_curve->reset();
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->red_bpath), NULL);
- while (this->green_bpaths) {
- sp_canvas_item_destroy(SP_CANVAS_ITEM(this->green_bpaths->data));
- this->green_bpaths = g_slist_remove(this->green_bpaths, this->green_bpaths->data);
+ for (auto i:this->green_bpaths) {
+ sp_canvas_item_destroy(i);
}
+ this->green_bpaths.clear();
this->green_curve->reset();
if (this->green_anchor) {
this->green_anchor = sp_draw_anchor_destroy(this->green_anchor);
@@ -493,7 +493,7 @@ void PencilTool::_cancel() {
bool PencilTool::_handleKeyPress(GdkEventKey const &event) {
bool ret = false;
- switch (get_group0_keyval(&event)) {
+ switch (get_latin_keyval(&event)) {
case GDK_KEY_Up:
case GDK_KEY_Down:
case GDK_KEY_KP_Up:
@@ -546,7 +546,7 @@ bool PencilTool::_handleKeyPress(GdkEventKey const &event) {
bool PencilTool::_handleKeyRelease(GdkEventKey const &event) {
bool ret = false;
- switch (get_group0_keyval(&event)) {
+ switch (get_latin_keyval(&event)) {
case GDK_KEY_Alt_L:
case GDK_KEY_Alt_R:
case GDK_KEY_Meta_L:
@@ -1067,7 +1067,7 @@ void PencilTool::_fitAndSplit() {
}
sp_canvas_bpath_set_stroke(SP_CANVAS_BPATH(cshape), this->green_color, 1.0, SP_STROKE_LINEJOIN_MITER, SP_STROKE_LINECAP_BUTT);
- this->green_bpaths = g_slist_prepend(this->green_bpaths, cshape);
+ this->green_bpaths.push_back(cshape);
this->red_curve_is_valid = false;
}
diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp
index 9ebf51e76..655650ef4 100644
--- a/src/ui/tools/rect-tool.cpp
+++ b/src/ui/tools/rect-tool.cpp
@@ -258,7 +258,7 @@ bool RectTool::root_handler(GdkEvent* event) {
}
break;
case GDK_KEY_PRESS:
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
case GDK_KEY_Alt_L:
case GDK_KEY_Alt_R:
case GDK_KEY_Control_L:
@@ -326,7 +326,7 @@ bool RectTool::root_handler(GdkEvent* event) {
}
break;
case GDK_KEY_RELEASE:
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
case GDK_KEY_Alt_L:
case GDK_KEY_Alt_R:
case GDK_KEY_Control_L:
@@ -397,8 +397,8 @@ void RectTool::drag(Geom::Point const pt, guint state) {
Inkscape::Util::Quantity rdimx_q = Inkscape::Util::Quantity(rdimx, "px");
Inkscape::Util::Quantity rdimy_q = Inkscape::Util::Quantity(rdimy, "px");
- GString *xs = g_string_new(rdimx_q.string(desktop->namedview->display_units).c_str());
- GString *ys = g_string_new(rdimy_q.string(desktop->namedview->display_units).c_str());
+ Glib::ustring xs = rdimx_q.string(desktop->namedview->display_units);
+ Glib::ustring ys = rdimy_q.string(desktop->namedview->display_units);
if (state & GDK_CONTROL_MASK) {
int ratio_x, ratio_y;
@@ -421,20 +421,25 @@ void RectTool::drag(Geom::Point const pt, guint state) {
}
if (!is_golden_ratio) {
- this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s &#215; %s (constrained to ratio %d:%d); with <b>Shift</b> to draw around the starting point"), xs->str, ys->str, ratio_x, ratio_y);
+ this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE,
+ _("<b>Rectangle</b>: %s &#215; %s (constrained to ratio %d:%d); with <b>Shift</b> to draw around the starting point"),
+ xs.c_str(), ys.c_str(), ratio_x, ratio_y);
} else {
if (ratio_y == 1) {
- this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s &#215; %s (constrained to golden ratio 1.618 : 1); with <b>Shift</b> to draw around the starting point"), xs->str, ys->str);
+ this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE,
+ _("<b>Rectangle</b>: %s &#215; %s (constrained to golden ratio 1.618 : 1); with <b>Shift</b> to draw around the starting point"),
+ xs.c_str(), ys.c_str());
} else {
- this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s &#215; %s (constrained to golden ratio 1 : 1.618); with <b>Shift</b> to draw around the starting point"), xs->str, ys->str);
+ this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE,
+ _("<b>Rectangle</b>: %s &#215; %s (constrained to golden ratio 1 : 1.618); with <b>Shift</b> to draw around the starting point"),
+ xs.c_str(), ys.c_str());
}
}
} else {
- this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Rectangle</b>: %s &#215; %s; with <b>Ctrl</b> to make square or integer-ratio rectangle; with <b>Shift</b> to draw around the starting point"), xs->str, ys->str);
+ this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE,
+ _("<b>Rectangle</b>: %s &#215; %s; with <b>Ctrl</b> to make square or integer-ratio rectangle; with <b>Shift</b> to draw around the starting point"),
+ xs.c_str(), ys.c_str());
}
-
- g_string_free(xs, FALSE);
- g_string_free(ys, FALSE);
}
void RectTool::finishItem() {
@@ -447,7 +452,7 @@ void RectTool::finishItem() {
}
this->rect->updateRepr();
- this->rect->doWriteTransform(this->rect->getRepr(), this->rect->transform, NULL, true);
+ this->rect->doWriteTransform(this->rect->transform, NULL, true);
this->desktop->canvas->endForcedFullRedraws();
diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp
index fca2173ca..3dfb764bb 100644
--- a/src/ui/tools/select-tool.cpp
+++ b/src/ui/tools/select-tool.cpp
@@ -344,18 +344,18 @@ bool SelectTool::item_handler(SPItem* item, GdkEvent* event) {
break;
case GDK_KEY_PRESS:
- if (get_group0_keyval (&event->key) == GDK_KEY_space) {
+ if (get_latin_keyval (&event->key) == GDK_KEY_space) {
if (this->dragging && this->grabbed) {
/* stamping mode: show content mode moving */
_seltrans->stamp();
ret = TRUE;
}
- } else if (get_group0_keyval (&event->key) == GDK_KEY_Tab) {
+ } else if (get_latin_keyval (&event->key) == GDK_KEY_Tab) {
if (this->dragging && this->grabbed) {
_seltrans->getNextClosestPoint(false);
ret = TRUE;
}
- } else if (get_group0_keyval (&event->key) == GDK_KEY_ISO_Left_Tab) {
+ } else if (get_latin_keyval (&event->key) == GDK_KEY_ISO_Left_Tab) {
if (this->dragging && this->grabbed) {
_seltrans->getNextClosestPoint(true);
ret = TRUE;
@@ -854,7 +854,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
case GDK_KEY_PRESS: // keybindings for select context
{
{
- guint keyval = get_group0_keyval(&event->key);
+ guint keyval = get_latin_keyval(&event->key);
bool alt = ( MOD__ALT(event)
|| (keyval == GDK_KEY_Alt_L)
@@ -896,11 +896,11 @@ bool SelectTool::root_handler(GdkEvent* event) {
gdouble const offset = prefs->getDoubleLimited("/options/defaultscale/value", 2, 0, 1000, "px");
int const snaps = prefs->getInt("/options/rotationsnapsperpi/value", 12);
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
case GDK_KEY_Left: // move selection left
case GDK_KEY_KP_Left:
if (!MOD__CTRL(event)) { // not ctrl
- gint mul = 1 + gobble_key_events( get_group0_keyval(&event->key), 0); // with any mask
+ gint mul = 1 + gobble_key_events( get_latin_keyval(&event->key), 0); // with any mask
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
@@ -923,7 +923,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
case GDK_KEY_Up: // move selection up
case GDK_KEY_KP_Up:
if (!MOD__CTRL(event)) { // not ctrl
- gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask
+ gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
@@ -946,7 +946,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
case GDK_KEY_Right: // move selection right
case GDK_KEY_KP_Right:
if (!MOD__CTRL(event)) { // not ctrl
- gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask
+ gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
@@ -969,7 +969,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
case GDK_KEY_Down: // move selection down
case GDK_KEY_KP_Down:
if (!MOD__CTRL(event)) { // not ctrl
- gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask
+ gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask
if (MOD__ALT(event)) { // alt
if (MOD__SHIFT(event)) {
@@ -1024,7 +1024,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
case GDK_KEY_bracketleft:
if (MOD__ALT(event)) {
- gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask
+ gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask
selection->rotateScreen(mul*1);
} else if (MOD__CTRL(event)) {
selection->rotate(90);
@@ -1037,7 +1037,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
case GDK_KEY_bracketright:
if (MOD__ALT(event)) {
- gint mul = 1 + gobble_key_events(get_group0_keyval(&event->key), 0); // with any mask
+ gint mul = 1 + gobble_key_events(get_latin_keyval(&event->key), 0); // with any mask
selection->rotateScreen(-1*mul);
} else if (MOD__CTRL(event)) {
selection->rotate(-90);
@@ -1097,7 +1097,7 @@ bool SelectTool::root_handler(GdkEvent* event) {
break;
}
case GDK_KEY_RELEASE: {
- guint keyval = get_group0_keyval(&event->key);
+ guint keyval = get_latin_keyval(&event->key);
if (key_is_a_modifier (keyval)) {
this->defaultMessageContext()->clear();
}
diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp
index b681aec38..bb8ce6356 100644
--- a/src/ui/tools/spiral-tool.cpp
+++ b/src/ui/tools/spiral-tool.cpp
@@ -232,7 +232,7 @@ bool SpiralTool::root_handler(GdkEvent* event) {
break;
case GDK_KEY_PRESS:
- switch (get_group0_keyval(&event->key)) {
+ switch (get_latin_keyval(&event->key)) {
case GDK_KEY_Alt_R:
case GDK_KEY_Control_L:
case GDK_KEY_Control_R:
@@ -291,7 +291,7 @@ bool SpiralTool::root_handler(GdkEvent* event) {
break;
case GDK_KEY_RELEASE:
- switch (get_group0_keyval(&event->key)) {
+ switch (get_latin_keyval(&event->key)) {
case GDK_KEY_Alt_L:
case GDK_KEY_Alt_R:
case GDK_KEY_Control_L:
@@ -372,11 +372,10 @@ void SpiralTool::drag(Geom::Point const &p, guint state) {
/* status text */
Inkscape::Util::Quantity q = Inkscape::Util::Quantity(rad, "px");
- GString *rads = g_string_new(q.string(desktop->namedview->display_units).c_str());
+ Glib::ustring rads = q.string(desktop->namedview->display_units);
this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE,
_("<b>Spiral</b>: radius %s, angle %5g&#176;; with <b>Ctrl</b> to snap angle"),
- rads->str, sp_round((arg + 2.0*M_PI*this->spiral->revo)*180/M_PI, 0.0001));
- g_string_free(rads, FALSE);
+ rads.c_str(), sp_round((arg + 2.0*M_PI*this->spiral->revo)*180/M_PI, 0.0001));
}
void SpiralTool::finishItem() {
@@ -390,7 +389,7 @@ void SpiralTool::finishItem() {
spiral->set_shape();
spiral->updateRepr(SP_OBJECT_WRITE_EXT);
- spiral->doWriteTransform(spiral->getRepr(), spiral->transform, NULL, true);
+ spiral->doWriteTransform(spiral->transform, NULL, true);
this->desktop->canvas->endForcedFullRedraws();
diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp
index f3e7e6d3c..5593ceb34 100644
--- a/src/ui/tools/spray-tool.cpp
+++ b/src/ui/tools/spray-tool.cpp
@@ -120,7 +120,7 @@ static void sp_spray_rotate_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *i
// Rotate item.
item->set_i2d_affine(item->i2dt_affine() * affine);
// Use each item's own transform writer, consistent with sp_selection_apply_affine()
- item->doWriteTransform(item->getRepr(), item->transform);
+ item->doWriteTransform(item->transform);
// Restore the center position (it's changed because the bbox center changed)
if (item->isCenterSet()) {
item->setCenter(c);
@@ -133,7 +133,7 @@ static void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *it
{
Geom::Translate const s(c);
item->set_i2d_affine(item->i2dt_affine() * s.inverse() * scale * s);
- item->doWriteTransform(item->getRepr(), item->transform);
+ item->doWriteTransform(item->transform);
}
SprayTool::SprayTool()
@@ -1375,7 +1375,7 @@ bool SprayTool::root_handler(GdkEvent* event) {
}
case GDK_KEY_PRESS:
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
case GDK_KEY_j:
case GDK_KEY_J:
if (MOD__SHIFT_ONLY(event)) {
@@ -1487,7 +1487,7 @@ bool SprayTool::root_handler(GdkEvent* event) {
case GDK_KEY_RELEASE: {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- switch (get_group0_keyval(&event->key)) {
+ switch (get_latin_keyval(&event->key)) {
case GDK_KEY_Shift_L:
case GDK_KEY_Shift_R:
this->update_cursor(false);
diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp
index 32f0e6d92..ed25503c4 100644
--- a/src/ui/tools/star-tool.cpp
+++ b/src/ui/tools/star-tool.cpp
@@ -246,7 +246,7 @@ bool StarTool::root_handler(GdkEvent* event) {
break;
case GDK_KEY_PRESS:
- switch (get_group0_keyval(&event->key)) {
+ switch (get_latin_keyval(&event->key)) {
case GDK_KEY_Alt_R:
case GDK_KEY_Control_L:
case GDK_KEY_Control_R:
@@ -306,7 +306,7 @@ bool StarTool::root_handler(GdkEvent* event) {
break;
case GDK_KEY_RELEASE:
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
case GDK_KEY_Alt_L:
case GDK_KEY_Alt_R:
case GDK_KEY_Control_L:
@@ -389,14 +389,12 @@ void StarTool::drag(Geom::Point p, guint state)
/* status text */
Inkscape::Util::Quantity q = Inkscape::Util::Quantity(r1, "px");
- GString *rads = g_string_new(q.string(desktop->namedview->display_units).c_str());
+ Glib::ustring rads = q.string(desktop->namedview->display_units);
this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE,
( this->isflatsided?
_("<b>Polygon</b>: radius %s, angle %5g&#176;; with <b>Ctrl</b> to snap angle")
: _("<b>Star</b>: radius %s, angle %5g&#176;; with <b>Ctrl</b> to snap angle") ),
- rads->str, sp_round((arg1) * 180 / M_PI, 0.0001));
-
- g_string_free(rads, FALSE);
+ rads.c_str(), sp_round((arg1) * 180 / M_PI, 0.0001));
}
void StarTool::finishItem() {
@@ -415,7 +413,7 @@ void StarTool::finishItem() {
this->star->setCenter(this->center);
this->star->set_shape();
this->star->updateRepr(SP_OBJECT_WRITE_EXT);
- this->star->doWriteTransform(this->star->getRepr(), this->star->transform, NULL, true);
+ this->star->doWriteTransform(this->star->transform, NULL, true);
desktop->canvas->endForcedFullRedraws();
diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp
index 9091b455e..692b65c44 100644
--- a/src/ui/tools/text-tool.cpp
+++ b/src/ui/tools/text-tool.cpp
@@ -417,7 +417,7 @@ static void sp_text_context_setup_text(TextTool *tc)
text_item->transform = SP_ITEM(ec->desktop->currentLayer())->i2doc_affine().inverse();
text_item->updateRepr();
- text_item->doWriteTransform(text_item->getRepr(), text_item->transform, NULL, true);
+ text_item->doWriteTransform(text_item->transform, NULL, true);
DocumentUndo::done(ec->desktop->getDocument(), SP_VERB_CONTEXT_TEXT,
_("Create text"));
}
@@ -575,13 +575,9 @@ bool TextTool::root_handler(GdkEvent* event) {
// status text
Inkscape::Util::Quantity x_q = Inkscape::Util::Quantity(fabs((p - this->p0)[Geom::X]), "px");
Inkscape::Util::Quantity y_q = Inkscape::Util::Quantity(fabs((p - this->p0)[Geom::Y]), "px");
- GString *xs = g_string_new(x_q.string(desktop->namedview->display_units).c_str());
- GString *ys = g_string_new(y_q.string(desktop->namedview->display_units).c_str());
- this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Flowed text frame</b>: %s &#215; %s"), xs->str, ys->str);
-
- g_string_free(xs, FALSE);
- g_string_free(ys, FALSE);
-
+ Glib::ustring xs = x_q.string(desktop->namedview->display_units);
+ Glib::ustring ys = y_q.string(desktop->namedview->display_units);
+ this->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("<b>Flowed text frame</b>: %s &#215; %s"), xs.c_str(), ys.c_str());
} else if (!this->sp_event_context_knot_mouseover()) {
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);
@@ -657,7 +653,7 @@ bool TextTool::root_handler(GdkEvent* event) {
}
break;
case GDK_KEY_PRESS: {
- guint const group0_keyval = get_group0_keyval(&event->key);
+ guint const group0_keyval = get_latin_keyval(&event->key);
if (group0_keyval == GDK_KEY_KP_Add ||
group0_keyval == GDK_KEY_KP_Subtract) {
@@ -965,7 +961,7 @@ bool TextTool::root_handler(GdkEvent* event) {
if (this->text) {
if (MOD__ALT(event)) {
gint mul = 1 + gobble_key_events(
- get_group0_keyval(&event->key), 0); // with any mask
+ get_latin_keyval(&event->key), 0); // with any mask
if (MOD__SHIFT(event))
sp_te_adjust_kerning_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, Geom::Point(mul*-10, 0));
else
@@ -989,7 +985,7 @@ bool TextTool::root_handler(GdkEvent* event) {
if (this->text) {
if (MOD__ALT(event)) {
gint mul = 1 + gobble_key_events(
- get_group0_keyval(&event->key), 0); // with any mask
+ get_latin_keyval(&event->key), 0); // with any mask
if (MOD__SHIFT(event))
sp_te_adjust_kerning_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, Geom::Point(mul*10, 0));
else
@@ -1013,7 +1009,7 @@ bool TextTool::root_handler(GdkEvent* event) {
if (this->text) {
if (MOD__ALT(event)) {
gint mul = 1 + gobble_key_events(
- get_group0_keyval(&event->key), 0); // with any mask
+ get_latin_keyval(&event->key), 0); // with any mask
if (MOD__SHIFT(event))
sp_te_adjust_kerning_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, Geom::Point(0, mul*-10));
else
@@ -1037,7 +1033,7 @@ bool TextTool::root_handler(GdkEvent* event) {
if (this->text) {
if (MOD__ALT(event)) {
gint mul = 1 + gobble_key_events(
- get_group0_keyval(&event->key), 0); // with any mask
+ get_latin_keyval(&event->key), 0); // with any mask
if (MOD__SHIFT(event))
sp_te_adjust_kerning_screen(this->text, this->text_sel_start, this->text_sel_end, desktop, Geom::Point(0, mul*10));
else
diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp
index 12c3a3675..7b4f67da9 100644
--- a/src/ui/tools/tool-base.cpp
+++ b/src/ui/tools/tool-base.cpp
@@ -71,6 +71,10 @@ static guint32 scroll_event_time = 0;
static gdouble scroll_multiply = 1;
static guint scroll_keyval = 0;
+// globals for key processing
+static bool latin_keys_group_valid = FALSE;
+static gint latin_keys_group;
+
namespace Inkscape {
namespace UI {
@@ -598,7 +602,7 @@ bool ToolBase::root_handler(GdkEvent* event) {
int const key_scroll = prefs->getIntLimited("/options/keyscroll/value",
10, 0, 1000);
- switch (get_group0_keyval(&event->key)) {
+ switch (get_latin_keyval(&event->key)) {
// GDK insists on stealing these keys (F1 for no idea what, tab for cycling widgets
// in the editing window). So we resteal them back and run our regular shortcut
// invoker on them.
@@ -638,7 +642,7 @@ bool ToolBase::root_handler(GdkEvent* event) {
int i = (int) floor(key_scroll * accelerate_scroll(event,
acceleration, desktop->getCanvas()));
- gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
+ gobble_key_events(get_latin_keyval(&event->key), GDK_CONTROL_MASK);
this->desktop->scroll_relative(Geom::Point(i, 0));
ret = TRUE;
} else {
@@ -653,7 +657,7 @@ bool ToolBase::root_handler(GdkEvent* event) {
int i = (int) floor(key_scroll * accelerate_scroll(event,
acceleration, desktop->getCanvas()));
- gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
+ gobble_key_events(get_latin_keyval(&event->key), GDK_CONTROL_MASK);
this->desktop->scroll_relative(Geom::Point(0, i));
ret = TRUE;
} else {
@@ -668,7 +672,7 @@ bool ToolBase::root_handler(GdkEvent* event) {
int i = (int) floor(key_scroll * accelerate_scroll(event,
acceleration, desktop->getCanvas()));
- gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
+ gobble_key_events(get_latin_keyval(&event->key), GDK_CONTROL_MASK);
this->desktop->scroll_relative(Geom::Point(-i, 0));
ret = TRUE;
} else {
@@ -683,7 +687,7 @@ bool ToolBase::root_handler(GdkEvent* event) {
int i = (int) floor(key_scroll * accelerate_scroll(event,
acceleration, desktop->getCanvas()));
- gobble_key_events(get_group0_keyval(&event->key), GDK_CONTROL_MASK);
+ gobble_key_events(get_latin_keyval(&event->key), GDK_CONTROL_MASK);
this->desktop->scroll_relative(Geom::Point(0, -i));
ret = TRUE;
} else {
@@ -752,7 +756,7 @@ bool ToolBase::root_handler(GdkEvent* event) {
gdk_window_set_cursor(gtk_widget_get_window (w), this->cursor);
}
- switch (get_group0_keyval(&event->key)) {
+ switch (get_latin_keyval(&event->key)) {
case GDK_KEY_space:
if (within_tolerance) {
// Space was pressed, but not panned
@@ -1138,7 +1142,7 @@ void sp_event_root_menu_popup(SPDesktop *desktop, SPItem *item, GdkEvent *event)
void sp_event_show_modifier_tip(Inkscape::MessageContext *message_context,
GdkEvent *event, gchar const *ctrl_tip, gchar const *shift_tip,
gchar const *alt_tip) {
- guint keyval = get_group0_keyval(&event->key);
+ guint keyval = get_latin_keyval(&event->key);
bool ctrl = ctrl_tip && (MOD__CTRL(event) || (keyval == GDK_KEY_Control_L) || (keyval
== GDK_KEY_Control_R));
@@ -1159,19 +1163,48 @@ void sp_event_show_modifier_tip(Inkscape::MessageContext *message_context,
}
/**
- * Return the keyval corresponding to the key event in group 0, i.e.,
- * in the main (English) layout.
+ * Try to determine the keys group of Latin layout.
+ * Check available keymap entries for Latin 'a' key and find the minimal integer value.
+ */
+static void update_latin_keys_group() {
+ GdkKeymapKey* keys;
+ gint n_keys;
+
+ latin_keys_group_valid = FALSE;
+ if (gdk_keymap_get_entries_for_keyval(gdk_keymap_get_default(), GDK_KEY_a, &keys, &n_keys)) {
+ for (gint i = 0; i < n_keys; i++) {
+ if (!latin_keys_group_valid || keys[i].group < latin_keys_group) {
+ latin_keys_group = keys[i].group;
+ latin_keys_group_valid = TRUE;
+ }
+ }
+ g_free(keys);
+ }
+}
+
+/**
+ * Initialize Latin keys group handling.
+ */
+void init_latin_keys_group() {
+ g_signal_connect(G_OBJECT(gdk_keymap_get_default()),
+ "keys-changed", G_CALLBACK(update_latin_keys_group), NULL);
+ update_latin_keys_group();
+}
+
+/**
+ * Return the keyval corresponding to the key event in Latin group.
*
* Use this instead of simply event->keyval, so that your keyboard shortcuts
* work regardless of layouts (e.g., in Cyrillic).
*/
-guint get_group0_keyval(GdkEventKey const *event, guint *consumed_modifiers /*= NULL*/) {
+guint get_latin_keyval(GdkEventKey const *event, guint *consumed_modifiers /*= NULL*/) {
guint keyval = 0;
GdkModifierType modifiers;
+ gint group = latin_keys_group_valid ? latin_keys_group : event->group;
gdk_keymap_translate_keyboard_state(
gdk_keymap_get_for_display(gdk_display_get_default()),
- event->hardware_keycode, (GdkModifierType) event->state, 0 /*event->group*/,
+ event->hardware_keycode, (GdkModifierType) event->state, group,
&keyval, NULL, NULL, &modifiers);
if (consumed_modifiers) {
diff --git a/src/ui/tools/tool-base.h b/src/ui/tools/tool-base.h
index 09a9db660..7185b787e 100644
--- a/src/ui/tools/tool-base.h
+++ b/src/ui/tools/tool-base.h
@@ -251,7 +251,8 @@ gint gobble_motion_events(gint mask);
void sp_event_show_modifier_tip(Inkscape::MessageContext *message_context, GdkEvent *event,
gchar const *ctrl_tip, gchar const *shift_tip, gchar const *alt_tip);
-guint get_group0_keyval(GdkEventKey const *event, guint *consumed_modifiers = NULL);
+void init_latin_keys_group();
+guint get_latin_keyval(GdkEventKey const *event, guint *consumed_modifiers = NULL);
SPItem *sp_event_context_find_item (SPDesktop *desktop, Geom::Point const &p, bool select_under, bool into_groups);
SPItem *sp_event_context_over_item (SPDesktop *desktop, SPItem *item, Geom::Point const &p);
diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp
index dcd9413fb..9348ef842 100644
--- a/src/ui/tools/tweak-tool.cpp
+++ b/src/ui/tools/tweak-tool.cpp
@@ -374,23 +374,20 @@ sp_tweak_dilate_recursive (Inkscape::Selection *selection, SPItem *item, Geom::P
}
if (dynamic_cast<SPGroup *>(item) && !dynamic_cast<SPBox3D *>(item)) {
- GSList *children = NULL;
+ std::vector<SPItem *> children;
for (auto& child: item->children) {
- if (dynamic_cast<SPItem *>(static_cast<SPObject *>(&child))) {
- children = g_slist_prepend(children, &child);
+ if (dynamic_cast<SPItem *>(&child)) {
+ children.push_back(dynamic_cast<SPItem *>(&child));
}
}
- for (GSList *i = children; i; i = i->next) {
- SPItem *child = dynamic_cast<SPItem *>(static_cast<SPObject *>(i->data));
+ for (auto i = children.rbegin(); i!= children.rend(); ++i) {
+ SPItem *child = *i;
g_assert(child != NULL);
if (sp_tweak_dilate_recursive (selection, child, p, vector, mode, radius, force, fidelity, reverse)) {
did = true;
}
}
-
- g_slist_free(children);
-
} else {
if (mode == TWEAK_MODE_MOVE) {
@@ -1287,7 +1284,7 @@ bool TweakTool::root_handler(GdkEvent* event) {
}
case GDK_KEY_PRESS:
{
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
case GDK_KEY_m:
case GDK_KEY_M:
case GDK_KEY_0:
@@ -1482,7 +1479,7 @@ bool TweakTool::root_handler(GdkEvent* event) {
}
case GDK_KEY_RELEASE: {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- switch (get_group0_keyval(&event->key)) {
+ switch (get_latin_keyval(&event->key)) {
case GDK_KEY_Shift_L:
case GDK_KEY_Shift_R:
this->update_cursor(false);
diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp
index 8ba0c17b3..6f7fca242 100644
--- a/src/ui/tools/zoom-tool.cpp
+++ b/src/ui/tools/zoom-tool.cpp
@@ -168,7 +168,7 @@ bool ZoomTool::root_handler(GdkEvent* event) {
break;
}
case GDK_KEY_PRESS:
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
case GDK_KEY_Escape:
if (!Inkscape::Rubberband::get(desktop)->is_started()) {
Inkscape::SelectionHelper::selectNone(desktop);
@@ -206,7 +206,7 @@ bool ZoomTool::root_handler(GdkEvent* event) {
}
break;
case GDK_KEY_RELEASE:
- switch (get_group0_keyval (&event->key)) {
+ switch (get_latin_keyval (&event->key)) {
case GDK_KEY_Shift_L:
case GDK_KEY_Shift_R:
this->cursor_shape = cursor_zoom_xpm;