From 4007abe02509fc1e312a007fb26f31c5a595df26 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Thu, 3 Apr 2014 21:04:51 -0400 Subject: Begin first stage of resolving issue with duplicate knots (bzr r13090.1.46) --- src/knotholder.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'src/knotholder.cpp') diff --git a/src/knotholder.cpp b/src/knotholder.cpp index cf87423d4..94a041385 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -203,14 +203,16 @@ KnotHolder::knot_ungrabbed_handler(SPKnot */*knot*/, guint) /* do cleanup tasks (e.g., for LPE items write the parameter values * that were changed by dragging the handle to SVG) */ - if (SP_IS_LPE_ITEM(object)) { + if (dynamic_cast (object)) { // This writes all parameters to SVG. Is this sufficiently efficient or should we only // write the ones that were changed? - - Inkscape::LivePathEffect::Effect *lpe = SP_LPE_ITEM(object)->getCurrentLPE(); - if (lpe) { - LivePathEffectObject *lpeobj = lpe->getLPEObj(); - lpeobj->updateRepr(); + SPLPEItem * lpeitem = SP_LPE_ITEM(this->item); + if (lpeitem) { + Inkscape::LivePathEffect::Effect *lpe = lpeitem->getCurrentLPE(); + if (lpe) { + LivePathEffectObject *lpeobj = lpe->getLPEObj(); + lpeobj->updateRepr(); + } } } -- cgit v1.2.3 From 09ab1cca2d7fb8cdbb252feb4d1ef7945249c051 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Fri, 4 Apr 2014 15:37:48 -0400 Subject: Prevent crash on "three knot" issue (bzr r13090.1.47) --- src/knotholder.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'src/knotholder.cpp') diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 94a041385..30a7e58d5 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -234,9 +234,14 @@ KnotHolder::knot_ungrabbed_handler(SPKnot */*knot*/, guint) else object_verb = SP_VERB_SELECTION_DYNAMIC_OFFSET; } - - DocumentUndo::done(object->document, object_verb, - _("Move handle")); + if (object) { //increasingly aggressive sanity checks + if (object->document) { + if (object_verb <= SP_VERB_LAST && object_verb >= SP_VERB_INVALID) { + DocumentUndo::done(object->document, object_verb, + _("Move handle")); + } + } + } //else { abort(); } } } -- cgit v1.2.3 From 6f508cfcaa161695711309d3413b90d2b3f44ea0 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Mon, 14 Apr 2014 21:50:06 -0400 Subject: Minor things (bzr r13090.1.58) --- src/knotholder.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/knotholder.cpp') diff --git a/src/knotholder.cpp b/src/knotholder.cpp index 30a7e58d5..aea983cbb 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -154,8 +154,15 @@ KnotHolder::knot_clicked_handler(SPKnot *knot, guint state) } // for drag, this is done by ungrabbed_handler, but for click we must do it here - DocumentUndo::done(saved_item->document, object_verb, - _("Change handle")); + + if (saved_item) { //increasingly aggressive sanity checks + if (saved_item->document) { + if (object_verb <= SP_VERB_LAST && object_verb >= SP_VERB_INVALID) { + DocumentUndo::done(saved_item->document, object_verb, + _("Change handle")); + } + } + } // else { abort(); } } void -- cgit v1.2.3 From b9a8b72cd7bb5c6dbfe5118f15fa870cff8eb4c5 Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Thu, 31 Jul 2014 14:53:10 -0400 Subject: I'm an idiot (bzr r13090.1.97) --- src/knotholder.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/knotholder.cpp') diff --git a/src/knotholder.cpp b/src/knotholder.cpp index aea983cbb..9890647e1 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -213,7 +213,7 @@ KnotHolder::knot_ungrabbed_handler(SPKnot */*knot*/, guint) if (dynamic_cast (object)) { // This writes all parameters to SVG. Is this sufficiently efficient or should we only // write the ones that were changed? - SPLPEItem * lpeitem = SP_LPE_ITEM(this->item); + SPLPEItem * lpeitem = SP_LPE_ITEM(object); if (lpeitem) { Inkscape::LivePathEffect::Effect *lpe = lpeitem->getCurrentLPE(); if (lpe) { -- cgit v1.2.3 From acd8f135f2a901c5f046e51ad7783e442c43997a Mon Sep 17 00:00:00 2001 From: "Liam P. White" Date: Mon, 4 Aug 2014 12:10:37 -0400 Subject: Allow editing of fill and stroke patterns simultaneously. Fixes #601336, #604025, #486192 Fixed bugs: - https://launchpad.net/bugs/601336 - https://launchpad.net/bugs/604025 - https://launchpad.net/bugs/486192 (bzr r13489) --- src/knotholder.cpp | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) (limited to 'src/knotholder.cpp') diff --git a/src/knotholder.cpp b/src/knotholder.cpp index cf87423d4..f0e69716b 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -247,12 +247,32 @@ void KnotHolder::add(KnotHolderEntity *e) void KnotHolder::add_pattern_knotholder() { - if ((item->style->fill.isPaintserver()) - && SP_IS_PATTERN(item->style->getFillPaintServer())) - { - PatternKnotHolderEntityXY *entity_xy = new PatternKnotHolderEntityXY(); - PatternKnotHolderEntityAngle *entity_angle = new PatternKnotHolderEntityAngle(); - PatternKnotHolderEntityScale *entity_scale = new PatternKnotHolderEntityScale(); + if ((item->style->fill.isPaintserver()) && SP_IS_PATTERN(item->style->getFillPaintServer())) { + PatternKnotHolderEntityXY *entity_xy = new PatternKnotHolderEntityXY(true); + PatternKnotHolderEntityAngle *entity_angle = new PatternKnotHolderEntityAngle(true); + PatternKnotHolderEntityScale *entity_scale = new PatternKnotHolderEntityScale(true); + entity_xy->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT, + // TRANSLATORS: This refers to the pattern that's inside the object + _("Move the pattern fill inside the object"), + SP_KNOT_SHAPE_CROSS); + + entity_scale->create(desktop, item, this, Inkscape::CTRL_TYPE_SIZER, + _("Scale the pattern fill; uniformly if with Ctrl"), + SP_KNOT_SHAPE_SQUARE, SP_KNOT_MODE_XOR); + + entity_angle->create(desktop, item, this, Inkscape::CTRL_TYPE_ROTATE, + _("Rotate the pattern fill; with Ctrl to snap angle"), + SP_KNOT_SHAPE_CIRCLE, SP_KNOT_MODE_XOR); + + entity.push_back(entity_xy); + entity.push_back(entity_angle); + entity.push_back(entity_scale); + } + + if ((item->style->stroke.isPaintserver()) && SP_IS_PATTERN(item->style->getStrokePaintServer())) { + PatternKnotHolderEntityXY *entity_xy = new PatternKnotHolderEntityXY(false); + PatternKnotHolderEntityAngle *entity_angle = new PatternKnotHolderEntityAngle(false); + PatternKnotHolderEntityScale *entity_scale = new PatternKnotHolderEntityScale(false); entity_xy->create(desktop, item, this, Inkscape::CTRL_TYPE_POINT, // TRANSLATORS: This refers to the pattern that's inside the object _("Move the pattern fill inside the object"), -- cgit v1.2.3 From e2ae473da92a1f96e307e3f1f3e206cad7bd1c38 Mon Sep 17 00:00:00 2001 From: "Jon A. Cruz" Date: Thu, 23 Oct 2014 19:33:47 -0700 Subject: Initial removal of box3d outdated GTKish macros. (bzr r13634) --- src/knotholder.cpp | 75 ++++++++++++++++++++++++++++++++---------------------- 1 file changed, 45 insertions(+), 30 deletions(-) (limited to 'src/knotholder.cpp') diff --git a/src/knotholder.cpp b/src/knotholder.cpp index f0e69716b..553f25842 100644 --- a/src/knotholder.cpp +++ b/src/knotholder.cpp @@ -6,6 +6,7 @@ * bulia byak * Maximilian Albert * Abhishek Sharma + * Jon A. Cruz * * Copyright (C) 2001-2008 authors * @@ -58,8 +59,7 @@ KnotHolder::KnotHolder(SPDesktop *desktop, SPItem *item, SPKnotHolderReleasedFun local_change(FALSE), dragging(false) { - - if (!desktop || !item || !SP_IS_ITEM(item)) { + if (!desktop || !item) { g_print ("Error! Throw an exception, please!\n"); } @@ -128,29 +128,37 @@ KnotHolder::knot_clicked_handler(SPKnot *knot, guint state) } } - if (SP_IS_SHAPE(saved_item)) { - SP_SHAPE(saved_item)->set_shape(); + { + SPShape *savedShape = dynamic_cast(saved_item); + if (savedShape) { + savedShape->set_shape(); + } } knot_holder->update_knots(); unsigned int object_verb = SP_VERB_NONE; - if (SP_IS_RECT(saved_item)) + // TODO extract duplicated blocks; + if (dynamic_cast(saved_item)) { object_verb = SP_VERB_CONTEXT_RECT; - else if (SP_IS_BOX3D(saved_item)) + } else if (dynamic_cast(saved_item)) { object_verb = SP_VERB_CONTEXT_3DBOX; - else if (SP_IS_GENERICELLIPSE(saved_item)) + } else if (dynamic_cast(saved_item)) { object_verb = SP_VERB_CONTEXT_ARC; - else if (SP_IS_STAR(saved_item)) + } else if (dynamic_cast(saved_item)) { object_verb = SP_VERB_CONTEXT_STAR; - else if (SP_IS_SPIRAL(saved_item)) + } else if (dynamic_cast(saved_item)) { object_verb = SP_VERB_CONTEXT_SPIRAL; - else if (SP_IS_OFFSET(saved_item)) { - if (SP_OFFSET(saved_item)->sourceHref) - object_verb = SP_VERB_SELECTION_LINKED_OFFSET; - else - object_verb = SP_VERB_SELECTION_DYNAMIC_OFFSET; + } else { + SPOffset *offset = dynamic_cast(saved_item); + if (offset) { + if (offset->sourceHref) { + object_verb = SP_VERB_SELECTION_LINKED_OFFSET; + } else { + object_verb = SP_VERB_SELECTION_DYNAMIC_OFFSET; + } + } } // for drag, this is done by ungrabbed_handler, but for click we must do it here @@ -177,8 +185,9 @@ KnotHolder::knot_moved_handler(SPKnot *knot, Geom::Point const &p, guint state) } } - if (SP_IS_SHAPE (item)) { - SP_SHAPE (item)->set_shape(); + SPShape *shape = dynamic_cast(item); + if (shape) { + shape->set_shape(); } this->update_knots(); @@ -203,11 +212,12 @@ KnotHolder::knot_ungrabbed_handler(SPKnot */*knot*/, guint) /* do cleanup tasks (e.g., for LPE items write the parameter values * that were changed by dragging the handle to SVG) */ - if (SP_IS_LPE_ITEM(object)) { + SPLPEItem *lpeItem = dynamic_cast(object); + if (lpeItem) { // This writes all parameters to SVG. Is this sufficiently efficient or should we only // write the ones that were changed? - Inkscape::LivePathEffect::Effect *lpe = SP_LPE_ITEM(object)->getCurrentLPE(); + Inkscape::LivePathEffect::Effect *lpe = lpeItem->getCurrentLPE(); if (lpe) { LivePathEffectObject *lpeobj = lpe->getLPEObj(); lpeobj->updateRepr(); @@ -216,21 +226,26 @@ KnotHolder::knot_ungrabbed_handler(SPKnot */*knot*/, guint) unsigned int object_verb = SP_VERB_NONE; - if (SP_IS_RECT(object)) + // TODO extract duplicated blocks: + if (dynamic_cast(object)) { object_verb = SP_VERB_CONTEXT_RECT; - else if (SP_IS_BOX3D(object)) + } else if (dynamic_cast(object)) { object_verb = SP_VERB_CONTEXT_3DBOX; - else if (SP_IS_GENERICELLIPSE(object)) + } else if (dynamic_cast(object)) { object_verb = SP_VERB_CONTEXT_ARC; - else if (SP_IS_STAR(object)) + } else if (dynamic_cast(object)) { object_verb = SP_VERB_CONTEXT_STAR; - else if (SP_IS_SPIRAL(object)) + } else if (dynamic_cast(object)) { object_verb = SP_VERB_CONTEXT_SPIRAL; - else if (SP_IS_OFFSET(object)) { - if (SP_OFFSET(object)->sourceHref) - object_verb = SP_VERB_SELECTION_LINKED_OFFSET; - else - object_verb = SP_VERB_SELECTION_DYNAMIC_OFFSET; + } else { + SPOffset *offset = dynamic_cast(object); + if (offset) { + if (offset->sourceHref) { + object_verb = SP_VERB_SELECTION_LINKED_OFFSET; + } else { + object_verb = SP_VERB_SELECTION_DYNAMIC_OFFSET; + } + } } DocumentUndo::done(object->document, object_verb, @@ -247,7 +262,7 @@ void KnotHolder::add(KnotHolderEntity *e) void KnotHolder::add_pattern_knotholder() { - if ((item->style->fill.isPaintserver()) && SP_IS_PATTERN(item->style->getFillPaintServer())) { + if ((item->style->fill.isPaintserver()) && dynamic_cast(item->style->getFillPaintServer())) { PatternKnotHolderEntityXY *entity_xy = new PatternKnotHolderEntityXY(true); PatternKnotHolderEntityAngle *entity_angle = new PatternKnotHolderEntityAngle(true); PatternKnotHolderEntityScale *entity_scale = new PatternKnotHolderEntityScale(true); @@ -269,7 +284,7 @@ void KnotHolder::add_pattern_knotholder() entity.push_back(entity_scale); } - if ((item->style->stroke.isPaintserver()) && SP_IS_PATTERN(item->style->getStrokePaintServer())) { + if ((item->style->stroke.isPaintserver()) && dynamic_cast(item->style->getStrokePaintServer())) { PatternKnotHolderEntityXY *entity_xy = new PatternKnotHolderEntityXY(false); PatternKnotHolderEntityAngle *entity_angle = new PatternKnotHolderEntityAngle(false); PatternKnotHolderEntityScale *entity_scale = new PatternKnotHolderEntityScale(false); -- cgit v1.2.3