summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMartin Owens <doctormo@gmail.com>2014-02-28 15:50:05 +0000
committerMartin Owens <doctormo@gmail.com>2014-02-28 15:50:05 +0000
commit1bc1b442d8ec6f394f456c4675d5ca7f6aa1d0d6 (patch)
tree0b4c86988abeb6c01b23324f159bd0a8a936f485 /src
parentImproved uri testing (diff)
parentSpray tool: (diff)
downloadinkscape-1bc1b442d8ec6f394f456c4675d5ca7f6aa1d0d6.tar.gz
inkscape-1bc1b442d8ec6f394f456c4675d5ca7f6aa1d0d6.zip
Merge to trunk
(bzr r13047.1.7)
Diffstat (limited to 'src')
-rw-r--r--src/desktop.cpp18
-rw-r--r--src/display/curve.cpp1
-rw-r--r--src/display/nr-filter.cpp23
-rw-r--r--src/display/sp-canvas.cpp24
-rw-r--r--src/extension/dbus/doc/spec-to-docbook.xsl2
-rw-r--r--src/selection-chemistry.cpp110
-rw-r--r--src/seltrans.cpp6
-rw-r--r--src/sp-filter.cpp28
-rw-r--r--src/sp-root.cpp18
-rw-r--r--src/sp-root.h1
-rw-r--r--src/sp-use.cpp17
-rw-r--r--src/sp-use.h1
-rw-r--r--src/ui/dialog/swatches.cpp13
-rw-r--r--src/ui/tools/arc-tool.cpp49
-rw-r--r--src/ui/tools/box3d-tool.cpp23
-rw-r--r--src/ui/tools/calligraphic-tool.cpp34
-rw-r--r--src/ui/tools/connector-tool.cpp73
-rw-r--r--src/ui/tools/dropper-tool.cpp26
-rw-r--r--src/ui/tools/dynamic-base.cpp69
-rw-r--r--src/ui/tools/dynamic-base.h8
-rw-r--r--src/ui/tools/eraser-tool.cpp7
-rw-r--r--src/ui/tools/flood-tool.cpp15
-rw-r--r--src/ui/tools/freehand-base.cpp56
-rw-r--r--src/ui/tools/freehand-base.h4
-rw-r--r--src/ui/tools/gradient-tool.cpp22
-rw-r--r--src/ui/tools/lpe-tool.cpp18
-rw-r--r--src/ui/tools/measure-tool.cpp10
-rw-r--r--src/ui/tools/mesh-tool.cpp24
-rw-r--r--src/ui/tools/node-tool.cpp45
-rw-r--r--src/ui/tools/pen-tool.cpp65
-rw-r--r--src/ui/tools/pen-tool.h3
-rw-r--r--src/ui/tools/pencil-tool.cpp21
-rw-r--r--src/ui/tools/rect-tool.cpp20
-rw-r--r--src/ui/tools/select-tool.cpp36
-rw-r--r--src/ui/tools/select-tool.h4
-rw-r--r--src/ui/tools/spiral-tool.cpp22
-rw-r--r--src/ui/tools/spray-tool.cpp151
-rw-r--r--src/ui/tools/spray-tool.h8
-rw-r--r--src/ui/tools/star-tool.cpp28
-rw-r--r--src/ui/tools/text-tool.cpp51
-rw-r--r--src/ui/tools/text-tool.h10
-rw-r--r--src/ui/tools/tool-base.cpp42
-rw-r--r--src/ui/tools/tool-base.h32
-rw-r--r--src/ui/tools/tweak-tool.cpp45
-rw-r--r--src/ui/tools/tweak-tool.h6
-rw-r--r--src/ui/tools/zoom-tool.cpp11
-rw-r--r--src/ui/widget/selected-style.cpp5
-rw-r--r--src/widgets/desktop-widget.cpp5
-rw-r--r--src/widgets/pencil-toolbar.cpp12
-rw-r--r--src/widgets/spray-toolbar.cpp8
50 files changed, 706 insertions, 624 deletions
diff --git a/src/desktop.cpp b/src/desktop.cpp
index 364b5e930..a02baeac8 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -52,6 +52,7 @@
#include "display/sp-canvas.h"
#include "display/sp-canvas-util.h"
#include "document.h"
+#include "document-undo.h"
#include "event-log.h"
#include "helper/action-context.h"
#include "interface.h"
@@ -167,8 +168,23 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid
canvas = aCanvas;
SPDocument *document = namedview->document;
- /* Kill flicker */
+ /* XXX:
+ * ensureUpToDate() sends a 'modified' signal to the root element.
+ * This is reportedly required to prevent flickering after the document
+ * loads. However, many SPObjects write to their repr in response
+ * to this signal. This is apparently done to support live path effects,
+ * which rewrite their result paths after each modification of the base object.
+ * This causes the generation of an incomplete undo transaction,
+ * which causes problems down the line, including crashes in the
+ * Undo History dialog.
+ *
+ * For now, this is handled by disabling undo tracking during this call.
+ * A proper fix would involve modifying the way ensureUpToDate() works,
+ * so that the LPE results are not rewritten.
+ */
+ Inkscape::DocumentUndo::setUndoSensitive(document, false);
document->ensureUpToDate();
+ Inkscape::DocumentUndo::setUndoSensitive(document, true);
/* Setup Dialog Manager */
_dlg_mgr = &Inkscape::UI::Dialog::DialogManager::getInstance();
diff --git a/src/display/curve.cpp b/src/display/curve.cpp
index ae243853e..50f4c8954 100644
--- a/src/display/curve.cpp
+++ b/src/display/curve.cpp
@@ -34,7 +34,6 @@ SPCurve::SPCurve()
: _refcount(1),
_pathv()
{
- _pathv.clear();
}
SPCurve::SPCurve(Geom::PathVector const& pathv)
diff --git a/src/display/nr-filter.cpp b/src/display/nr-filter.cpp
index 11984ba76..90b233fbc 100644
--- a/src/display/nr-filter.cpp
+++ b/src/display/nr-filter.cpp
@@ -222,14 +222,19 @@ void Filter::area_enlarge(Geom::IntRect &bbox, Inkscape::DrawingItem const *item
Geom::OptRect Filter::filter_effect_area(Geom::OptRect const &bbox)
{
Geom::Point minp, maxp;
- double len_x = bbox ? bbox->width() : 0;
- double len_y = bbox ? bbox->height() : 0;
- /* TODO: fetch somehow the object ex and em lengths */
- _region_x.update(12, 6, len_x);
- _region_y.update(12, 6, len_y);
- _region_width.update(12, 6, len_x);
- _region_height.update(12, 6, len_y);
+
if (_filter_units == SP_FILTER_UNITS_OBJECTBOUNDINGBOX) {
+
+ double len_x = bbox ? bbox->width() : 0;
+ double len_y = bbox ? bbox->height() : 0;
+ /* TODO: fetch somehow the object ex and em lengths */
+
+ // Update for em, ex, and % values
+ _region_x.update(12, 6, len_x);
+ _region_y.update(12, 6, len_y);
+ _region_width.update(12, 6, len_x);
+ _region_height.update(12, 6, len_y);
+
if (!bbox) return Geom::OptRect();
if (_region_x.unit == SVGLength::PERCENT) {
@@ -254,7 +259,7 @@ Geom::OptRect Filter::filter_effect_area(Geom::OptRect const &bbox)
maxp[Y] = minp[Y] + _region_height.computed * len_y;
}
} else if (_filter_units == SP_FILTER_UNITS_USERSPACEONUSE) {
- /* TODO: make sure bbox and fe region are in same coordinate system */
+ // Region already set in sp-filter.cpp
minp[X] = _region_x.computed;
maxp[X] = minp[X] + _region_width.computed;
minp[Y] = _region_y.computed;
@@ -262,7 +267,9 @@ Geom::OptRect Filter::filter_effect_area(Geom::OptRect const &bbox)
} else {
g_warning("Error in Inkscape::Filters::Filter::filter_effect_area: unrecognized value of _filter_units");
}
+
Geom::OptRect area(minp, maxp);
+ // std::cout << "Filter::filter_effect_area: area: " << *area << std::endl;
return area;
}
diff --git a/src/display/sp-canvas.cpp b/src/display/sp-canvas.cpp
index d9640f763..c502daf64 100644
--- a/src/display/sp-canvas.cpp
+++ b/src/display/sp-canvas.cpp
@@ -1387,8 +1387,13 @@ void SPCanvasImpl::realize(GtkWidget *widget)
gdk_window_set_user_data (window, widget);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- if ( prefs->getBool("/options/useextinput/value", true) )
+ if (prefs->getBool("/options/useextinput/value", true)) {
gtk_widget_set_events(widget, attributes.event_mask);
+#if !GTK_CHECK_VERSION(3,0,0)
+ gtk_widget_set_extension_events(widget, GDK_EXTENSION_EVENTS_ALL);
+ // TODO: Extension event stuff has been deprecated in GTK+ 3
+#endif
+ }
#if !GTK_CHECK_VERSION(3,0,0)
// This does nothing in GTK+ 3
@@ -1524,23 +1529,22 @@ int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event)
// Convert to world coordinates -- we have two cases because of different
// offsets of the fields in the event structures.
- //
- GdkEvent ev = *event;
+ GdkEvent *ev = gdk_event_copy(event);
- switch (ev.type) {
+ switch (ev->type) {
case GDK_ENTER_NOTIFY:
case GDK_LEAVE_NOTIFY:
- ev.crossing.x += canvas->x0;
- ev.crossing.y += canvas->y0;
+ ev->crossing.x += canvas->x0;
+ ev->crossing.y += canvas->y0;
break;
case GDK_MOTION_NOTIFY:
case GDK_BUTTON_PRESS:
case GDK_2BUTTON_PRESS:
case GDK_3BUTTON_PRESS:
case GDK_BUTTON_RELEASE:
- ev.motion.x += canvas->x0;
- ev.motion.y += canvas->y0;
+ ev->motion.x += canvas->x0;
+ ev->motion.y += canvas->y0;
break;
default:
break;
@@ -1593,12 +1597,14 @@ int SPCanvasImpl::emitEvent(SPCanvas *canvas, GdkEvent *event)
while (item && !finished) {
g_object_ref (item);
- g_signal_emit (G_OBJECT (item), item_signals[ITEM_EVENT], 0, &ev, &finished);
+ g_signal_emit (G_OBJECT (item), item_signals[ITEM_EVENT], 0, ev, &finished);
SPCanvasItem *parent = item->parent;
g_object_unref (item);
item = parent;
}
+ gdk_event_free(ev);
+
return finished;
}
diff --git a/src/extension/dbus/doc/spec-to-docbook.xsl b/src/extension/dbus/doc/spec-to-docbook.xsl
index e200a05e0..a4e792df0 100644
--- a/src/extension/dbus/doc/spec-to-docbook.xsl
+++ b/src/extension/dbus/doc/spec-to-docbook.xsl
@@ -491,7 +491,7 @@ See also:
<xsl:template name="pad-spaces">
<xsl:param name="width"/>
- <xsl:variable name="spaces" xml:space="preserve"> </xsl:variable>
+ <xsl:variable name="spaces" select="' '" ></xsl:variable>
<xsl:value-of select="substring($spaces,1,$width)"/>
</xsl:template>
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index c3d37af72..76be086a2 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -53,6 +53,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS;
#include "sp-ellipse.h"
#include "sp-star.h"
#include "sp-spiral.h"
+#include "sp-switch.h"
#include "sp-polyline.h"
#include "sp-line.h"
#include "text-editing.h"
@@ -767,57 +768,95 @@ void sp_selection_group(Inkscape::Selection *selection, SPDesktop *desktop)
Inkscape::GC::release(group);
}
+static gint clone_depth_descending(gconstpointer a, gconstpointer b) {
+ SPUse *use_a = static_cast<SPUse *>(const_cast<gpointer>(a));
+ SPUse *use_b = static_cast<SPUse *>(const_cast<gpointer>(b));
+ int depth_a = use_a->cloneDepth();
+ int depth_b = use_b->cloneDepth();
+ if (depth_a < depth_b) {
+ return 1;
+ } else if (depth_a == depth_b) {
+ return 0;
+ } else {
+ return -1;
+ }
+}
+
void sp_selection_ungroup(Inkscape::Selection *selection, SPDesktop *desktop)
{
if (selection->isEmpty()) {
selection_display_message(desktop, Inkscape::WARNING_MESSAGE, _("Select a <b>group</b> to ungroup."));
+ }
+
+ // first check whether there is anything to ungroup
+ GSList *old_select = const_cast<GSList *>(selection->itemList());
+ GSList *new_select = NULL;
+ GSList *groups = NULL;
+ for (GSList *item = old_select; item; item = item->next) {
+ SPItem *obj = static_cast<SPItem*>(item->data);
+ if (SP_IS_GROUP(obj) && !SP_IS_SWITCH(obj)) {
+ groups = g_slist_prepend(groups, obj);
+ }
+ }
+
+ if (groups == NULL) {
+ selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("<b>No groups</b> to ungroup in the selection."));
+ g_slist_free(groups);
return;
}
- GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList()));
+ GSList *items = g_slist_copy(old_select);
selection->clear();
- // Get a copy of current selection.
- GSList *new_select = NULL;
- bool ungrouped = false;
- for (GSList *i = items;
- i != NULL;
- i = i->next)
- {
- SPItem *group = static_cast<SPItem *>(i->data);
+ // If any of the clones refer to the groups, unlink them and replace them with successors
+ // in the items list.
+ GSList *clones_to_unlink = NULL;
+ for (GSList *item = items; item; item = item->next) {
+ SPUse *use = dynamic_cast<SPUse *>(static_cast<SPItem *>(item->data));
- // when ungrouping cloned groups with their originals, some objects that were selected may no more exist due to unlinking
- if (!SP_IS_OBJECT(group) || !group->getRepr()) {
- continue;
+ SPItem *original = use;
+ while (SP_IS_USE(original)) {
+ original = SP_USE(original)->get_original();
}
- // This check reflects the g_return_if_fail in sp_item_group_ungroup and
- // may be a redundent. It also allows ungrouping of 'a' tags and we dont
- if (strcmp(group->getRepr()->name(), "svg:g") && strcmp(group->getRepr()->name(), "svg:switch") &&
- strcmp(group->getRepr()->name(), "svg:svg")) {
- // keep the non-group item in the new selection
- new_select = g_slist_append(new_select, group);
- continue;
+ if (g_slist_find(groups, original) != NULL) {
+ clones_to_unlink = g_slist_prepend(clones_to_unlink, item->data);
}
-
- GSList *children = NULL;
- /* This is not strictly required, but is nicer to rely on group ::destroy (lauris) */
- sp_item_group_ungroup(SP_GROUP(group), &children, false);
- ungrouped = true;
- // Add ungrouped items to the new selection.
- new_select = g_slist_concat(new_select, children);
}
- if (new_select) { // Set new selection.
- selection->addList(new_select);
- g_slist_free(new_select);
+ // Unlink clones beginning from those with highest clone depth.
+ // This way we can be sure than no additional automatic unlinking happens,
+ // and the items in the list remain valid
+ clones_to_unlink = g_slist_sort(clones_to_unlink, clone_depth_descending);
+
+ for (GSList *item = clones_to_unlink; item; item = item->next) {
+ SPUse *use = static_cast<SPUse *>(item->data);
+ GSList *items_node = g_slist_find(items, item->data);
+ items_node->data = use->unlink();
}
- if (!ungrouped) {
- selection_display_message(desktop, Inkscape::ERROR_MESSAGE, _("<b>No groups</b> to ungroup in the selection."));
+ g_slist_free(clones_to_unlink);
+
+ // do the actual work
+ for (GSList *item = items; item; item = item->next) {
+ SPItem *obj = static_cast<SPItem *>(item->data);
+
+ // ungroup only the groups marked earlier
+ if (g_slist_find(groups, item->data) != NULL) {
+ GSList *children = NULL;
+ sp_item_group_ungroup(SP_GROUP(obj), &children, false);
+ // add the items resulting from ungrouping to the selection
+ new_select = g_slist_concat(new_select, children);
+ item->data = NULL; // zero out the original pointer, which is no longer valid
+ } else {
+ // if not a group, keep in the selection
+ new_select = g_slist_append(new_select, item->data);
+ }
}
+ selection->addList(new_select);
+ g_slist_free(new_select);
g_slist_free(items);
-
+
DocumentUndo::done(selection->layers()->getDocument(), SP_VERB_SELECTION_UNGROUP,
_("Ungroup"));
}
@@ -1458,6 +1497,13 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons
for (GSList const *l = selection->itemList(); l != NULL; l = l->next) {
SPItem *item = SP_ITEM(l->data);
+ if( SP_IS_ROOT(item) ) {
+ // An SVG element cannot have a transform. We could change 'x' and 'y' in response
+ // to a translation... but leave that for another day.
+ selection->desktop()->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Cannot transform an embedded SVG."));
+ break;
+ }
+
Geom::Point old_center(0,0);
if (set_i2d && item->isCenterSet())
old_center = item->getCenter();
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index 78d9958c4..a55bc3c0d 100644
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
@@ -29,11 +29,13 @@
#include "desktop-handles.h"
#include "desktop-style.h"
#include "knot.h"
+#include "message-stack.h"
#include "snap.h"
#include "selection.h"
#include "ui/tools/select-tool.h"
#include "sp-item.h"
#include "sp-item-transform.h"
+#include "sp-root.h"
#include "seltrans-handles.h"
#include "seltrans.h"
#include "selection-chemistry.h"
@@ -381,6 +383,10 @@ void Inkscape::SelTrans::transform(Geom::Affine const &rel_affine, Geom::Point c
// update the content
for (unsigned i = 0; i < _items.size(); i++) {
SPItem &item = *_items[i];
+ if( SP_IS_ROOT(&item) ) {
+ _desktop->messageStack()->flash(Inkscape::WARNING_MESSAGE, _("Cannot transform an embedded SVG."));
+ break;
+ }
Geom::Affine const &prev_transform = _items_affines[i];
item.set_i2d_affine(prev_transform * affine);
}
diff --git a/src/sp-filter.cpp b/src/sp-filter.cpp
index c3e7d217e..0e3d2d5ce 100644
--- a/src/sp-filter.cpp
+++ b/src/sp-filter.cpp
@@ -28,6 +28,7 @@ using std::pair;
#include "sp-filter.h"
#include "sp-filter-reference.h"
#include "sp-filter-primitive.h"
+#include "sp-item.h"
#include "uri.h"
#include "xml/repr.h"
#include <cstring>
@@ -206,6 +207,33 @@ void SPFilter::update(SPCtx *ctx, guint flags) {
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG |
SP_OBJECT_VIEWPORT_MODIFIED_FLAG)) {
+ SPItemCtx *ictx = (SPItemCtx *) ctx;
+
+ // Do here since we know viewport (Bounding box case handled during rendering)
+ // Note: This only works for root viewport since this routine is not called after
+ // setting a new viewport. A true fix requires a strategy like SPItemView or SPMarkerView.
+ if(this->filterUnits == SP_FILTER_UNITS_USERSPACEONUSE) {
+ std::cout << " userSpaceOnUse" << std::endl;
+ if (this->x.unit == SVGLength::PERCENT) {
+ this->x._set = true;
+ this->x.computed = this->x.value * ictx->viewport.width();
+ }
+
+ if (this->y.unit == SVGLength::PERCENT) {
+ this->y._set = true;
+ this->y.computed = this->y.value * ictx->viewport.height();
+ }
+
+ if (this->width.unit == SVGLength::PERCENT) {
+ this->width._set = true;
+ this->width.computed = this->width.value * ictx->viewport.width();
+ }
+
+ if (this->height.unit == SVGLength::PERCENT) {
+ this->height._set = true;
+ this->height.computed = this->height.value * ictx->viewport.height();
+ }
+ }
/* do something to trigger redisplay, updates? */
}
diff --git a/src/sp-root.cpp b/src/sp-root.cpp
index bc870b116..12570e03e 100644
--- a/src/sp-root.cpp
+++ b/src/sp-root.cpp
@@ -221,7 +221,7 @@ void SPRoot::remove_child(Inkscape::XML::Node *child)
void SPRoot::update(SPCtx *ctx, guint flags)
{
- SPItemCtx *ictx = (SPItemCtx *) ctx;
+ SPItemCtx const *ictx = (SPItemCtx const *) ctx;
if( !this->parent ) {
@@ -288,10 +288,17 @@ void SPRoot::update(SPCtx *ctx, guint flags)
this->height.computed = this->height.value * ictx->viewport.height();
}
+ // std::cout << "SPRoot::update: final:"
+ // << " x: " << x.computed
+ // << " y: " << y.computed
+ // << " width: " << width.computed
+ // << " height: " << height.computed << std::endl;
+
// Calculate new viewport
- ictx->viewport = Geom::Rect::from_xywh( this->x.computed, this->y.computed,
- this->width.computed, this->height.computed );
- SPItemCtx rctx = get_rctx( ictx );
+ SPItemCtx rctx = *ictx;
+ rctx.viewport = Geom::Rect::from_xywh( this->x.computed, this->y.computed,
+ this->width.computed, this->height.computed );
+ rctx = get_rctx( &rctx );
/* And invoke parent method */
SPGroup::update((SPCtx *) &rctx, flags);
@@ -380,6 +387,9 @@ void SPRoot::print(SPPrintContext *ctx)
sp_print_release(ctx);
}
+const char *SPRoot::displayName() const {
+ return "SVG"; // Do not translate
+}
/*
Local Variables:
diff --git a/src/sp-root.h b/src/sp-root.h
index 1c9faed9b..0e5d87133 100644
--- a/src/sp-root.h
+++ b/src/sp-root.h
@@ -63,6 +63,7 @@ public:
virtual Inkscape::DrawingItem* show(Inkscape::Drawing &drawing, unsigned int key, unsigned int flags);
virtual void print(SPPrintContext *ctx);
+ virtual const char* displayName() const;
};
#endif /* !SP_ROOT_H_SEEN */
diff --git a/src/sp-use.cpp b/src/sp-use.cpp
index b2a51b8d9..e394e84c2 100644
--- a/src/sp-use.cpp
+++ b/src/sp-use.cpp
@@ -300,6 +300,23 @@ SPItem const *SPUse::root() const {
}
/**
+ * Get the number of dereferences or calls to get_original() needed to get an object
+ * which is not an svg:use. Returns -1 if there is no original object.
+ */
+int SPUse::cloneDepth() const {
+ unsigned depth = 1;
+ SPItem *orig = this->child;
+
+ while (orig && SP_IS_USE(orig)) {
+ ++depth;
+ orig = SP_USE(orig)->child;
+ }
+
+ if (!orig) return -1;
+ return depth;
+}
+
+/**
* Returns the effective transform that goes from the ultimate original to given SPUse, both ends
* included.
*/
diff --git a/src/sp-use.h b/src/sp-use.h
index 31a52c1a1..604040d59 100644
--- a/src/sp-use.h
+++ b/src/sp-use.h
@@ -66,6 +66,7 @@ public:
SPItem *root();
SPItem const *root() const;
+ int cloneDepth() const;
SPItem *unlink();
SPItem *get_original();
diff --git a/src/ui/dialog/swatches.cpp b/src/ui/dialog/swatches.cpp
index 3f161ad28..807618b4d 100644
--- a/src/ui/dialog/swatches.cpp
+++ b/src/ui/dialog/swatches.cpp
@@ -746,7 +746,7 @@ class DocTrack
{
public:
DocTrack(SPDocument *doc, sigc::connection &gradientRsrcChanged, sigc::connection &defsChanged, sigc::connection &defsModified) :
- doc(doc),
+ doc(doc->doRef()),
updatePending(false),
lastGradientUpdate(0.0),
gradientRsrcChanged(gradientRsrcChanged),
@@ -776,6 +776,8 @@ public:
gradientRsrcChanged.disconnect();
defsChanged.disconnect();
defsModified.disconnect();
+ doc->doUnref();
+ doc = NULL;
}
}
@@ -858,7 +860,7 @@ bool DocTrack::queueUpdateIfNeeded( SPDocument *doc )
void SwatchesPanel::_trackDocument( SwatchesPanel *panel, SPDocument *document )
{
- SPDocument *oldDoc = 0;
+ SPDocument *oldDoc = NULL;
if (docPerPanel.find(panel) != docPerPanel.end()) {
oldDoc = docPerPanel[panel];
if (!oldDoc) {
@@ -867,7 +869,7 @@ void SwatchesPanel::_trackDocument( SwatchesPanel *panel, SPDocument *document )
}
if (oldDoc != document) {
if (oldDoc) {
- docPerPanel[panel] = 0;
+ docPerPanel[panel] = NULL;
bool found = false;
for (std::map<SwatchesPanel*, SPDocument*>::iterator it = docPerPanel.begin(); (it != docPerPanel.end()) && !found; ++it) {
found = (it->second == document);
@@ -905,11 +907,6 @@ void SwatchesPanel::_trackDocument( SwatchesPanel *panel, SPDocument *document )
}
}
}
-
- std::set<SPDocument*> docs;
- for (std::map<SwatchesPanel*, SPDocument*>::iterator it = docPerPanel.begin(); it != docPerPanel.end(); ++it) {
- docs.insert(it->second);
- }
}
void SwatchesPanel::_setDocument( SPDocument *document )
diff --git a/src/ui/tools/arc-tool.cpp b/src/ui/tools/arc-tool.cpp
index bb7dfa21c..435f4aa4b 100644
--- a/src/ui/tools/arc-tool.cpp
+++ b/src/ui/tools/arc-tool.cpp
@@ -69,18 +69,10 @@ const std::string& ArcTool::getPrefsPath() {
const std::string ArcTool::prefsPath = "/tools/shapes/arc";
-ArcTool::ArcTool() : ToolBase() {
- this->cursor_shape = cursor_ellipse_xpm;
- this->hot_x = 4;
- this->hot_y = 4;
- this->xp = 0;
- this->yp = 0;
- this->tolerance = 0;
- this->within_tolerance = false;
- this->item_to_select = NULL;
- //this->tool_url = "/tools/shapes/arc";
-
- this->arc = NULL;
+ArcTool::ArcTool()
+ : ToolBase(cursor_ellipse_xpm, 4, 4)
+ , arc(NULL)
+{
}
void ArcTool::finish() {
@@ -142,13 +134,10 @@ void ArcTool::setup() {
}
bool ArcTool::item_handler(SPItem* item, GdkEvent* event) {
- gint ret = FALSE;
-
switch (event->type) {
case GDK_BUTTON_PRESS:
if (event->button.button == 1 && !this->space_panning) {
Inkscape::setup_for_drag_start(desktop, this, event);
- ret = TRUE;
}
break;
// motion and release are always on root (why?)
@@ -156,13 +145,7 @@ bool ArcTool::item_handler(SPItem* item, GdkEvent* event) {
break;
}
-// if ((SP_EVENT_CONTEXT_CLASS(sp_arc_context_parent_class))->item_handler) {
-// ret = (SP_EVENT_CONTEXT_CLASS(sp_arc_context_parent_class))->item_handler(event_context, item, event);
-// }
- // CPPIFY: ret is overwritten...
- ret = ToolBase::item_handler(item, event);
-
- return ret;
+ return ToolBase::item_handler(item, event);
}
bool ArcTool::root_handler(GdkEvent* event) {
@@ -173,7 +156,7 @@ bool ArcTool::root_handler(GdkEvent* event) {
this->tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
- gint ret = FALSE;
+ bool handled = false;
switch (event->type) {
case GDK_BUTTON_PRESS:
@@ -191,7 +174,7 @@ bool ArcTool::root_handler(GdkEvent* event) {
GDK_KEY_PRESS_MASK | GDK_BUTTON_RELEASE_MASK |
GDK_POINTER_MOTION_MASK | GDK_POINTER_MOTION_HINT_MASK | GDK_BUTTON_PRESS_MASK,
NULL, event->button.time);
- ret = TRUE;
+ handled = true;
m.unSetup();
}
break;
@@ -214,7 +197,7 @@ bool ArcTool::root_handler(GdkEvent* event) {
gobble_motion_events(GDK_BUTTON1_MASK);
- ret = TRUE;
+ handled = true;
} else if (!sp_event_context_knot_mouseover(this)){
SnapManager &m = desktop->namedview->snap_manager;
m.setup(desktop);
@@ -249,7 +232,7 @@ bool ArcTool::root_handler(GdkEvent* event) {
this->xp = 0;
this->yp = 0;
this->item_to_select = NULL;
- ret = TRUE;
+ handled = true;
}
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), event->button.time);
break;
@@ -278,14 +261,14 @@ bool ArcTool::root_handler(GdkEvent* event) {
case GDK_KEY_KP_Down:
// prevent the zoom field from activation
if (!MOD__CTRL_ONLY(event))
- ret = TRUE;
+ handled = true;
break;
case GDK_KEY_x:
case GDK_KEY_X:
if (MOD__ALT_ONLY(event)) {
desktop->setToolboxFocusTo ("altx-arc");
- ret = TRUE;
+ handled = true;
}
break;
@@ -295,7 +278,7 @@ bool ArcTool::root_handler(GdkEvent* event) {
sp_event_context_discard_delayed_snap_event(this);
// if drawing, cancel, otherwise pass it up for deselecting
this->cancel();
- ret = TRUE;
+ handled = true;
}
break;
@@ -316,7 +299,7 @@ bool ArcTool::root_handler(GdkEvent* event) {
case GDK_KEY_Delete:
case GDK_KEY_KP_Delete:
case GDK_KEY_BackSpace:
- ret = this->deleteSelectedDrag(MOD__CTRL_ONLY(event));
+ handled = this->deleteSelectedDrag(MOD__CTRL_ONLY(event));
break;
default:
@@ -346,11 +329,11 @@ bool ArcTool::root_handler(GdkEvent* event) {
break;
}
- if (!ret) {
- ret = ToolBase::root_handler(event);
+ if (!handled) {
+ handled = ToolBase::root_handler(event);
}
- return ret;
+ return handled;
}
void ArcTool::drag(Geom::Point pt, guint state) {
diff --git a/src/ui/tools/box3d-tool.cpp b/src/ui/tools/box3d-tool.cpp
index 2e345fef1..f0381a4a5 100644
--- a/src/ui/tools/box3d-tool.cpp
+++ b/src/ui/tools/box3d-tool.cpp
@@ -72,22 +72,13 @@ const std::string& Box3dTool::getPrefsPath() {
const std::string Box3dTool::prefsPath = "/tools/shapes/3dbox";
-Box3dTool::Box3dTool() : ToolBase() {
- this->cursor_shape = cursor_3dbox_xpm;
- this->hot_x = 4;
- this->hot_y = 4;
- this->xp = 0;
- this->yp = 0;
- this->tolerance = 0;
- this->within_tolerance = false;
- this->item_to_select = NULL;
-
- this->box3d = NULL;
-
- this->ctrl_dragged = false;
- this->extruded = false;
-
- this->_vpdrag = NULL;
+Box3dTool::Box3dTool()
+ : ToolBase(cursor_3dbox_xpm, 4, 4)
+ , _vpdrag(NULL)
+ , box3d(NULL)
+ , ctrl_dragged(false)
+ , extruded(false)
+{
}
void Box3dTool::finish() {
diff --git a/src/ui/tools/calligraphic-tool.cpp b/src/ui/tools/calligraphic-tool.cpp
index 2c5e6561c..64097e834 100644
--- a/src/ui/tools/calligraphic-tool.cpp
+++ b/src/ui/tools/calligraphic-tool.cpp
@@ -105,30 +105,24 @@ const std::string& CalligraphicTool::getPrefsPath() {
const std::string CalligraphicTool::prefsPath = "/tools/calligraphic";
-CalligraphicTool::CalligraphicTool() : DynamicBase() {
- this->cursor_shape = cursor_calligraphy_xpm;
- this->hot_x = 4;
- this->hot_y = 4;
-
+CalligraphicTool::CalligraphicTool()
+ : DynamicBase(cursor_calligraphy_xpm, 4, 4)
+ , keep_selected(true)
+ , hatch_spacing(0)
+ , hatch_spacing_step(0)
+ , hatch_item(NULL)
+ , hatch_livarot_path(NULL)
+ , hatch_last_nearest(Geom::Point(0,0))
+ , hatch_last_pointer(Geom::Point(0,0))
+ , hatch_escaped(false)
+ , hatch_area(NULL)
+ , just_started_drawing(false)
+ , trace_bg(false)
+{
this->vel_thin = 0.1;
this->flatness = 0.9;
this->cap_rounding = 0.0;
-
this->abs_width = false;
- this->keep_selected = true;
-
- this->hatch_spacing = 0;
- this->hatch_spacing_step = 0;
-
- this->hatch_last_nearest = Geom::Point(0,0);
- this->hatch_last_pointer = Geom::Point(0,0);
- this->hatch_escaped = false;
- this->hatch_area = NULL;
- this->hatch_item = NULL;
- this->hatch_livarot_path = NULL;
-
- this->trace_bg = false;
- this->just_started_drawing = false;
}
CalligraphicTool::~CalligraphicTool() {
diff --git a/src/ui/tools/connector-tool.cpp b/src/ui/tools/connector-tool.cpp
index 50cb00360..391bae2e5 100644
--- a/src/ui/tools/connector-tool.cpp
+++ b/src/ui/tools/connector-tool.cpp
@@ -182,54 +182,39 @@ const std::string& ConnectorTool::getPrefsPath() {
const std::string ConnectorTool::prefsPath = "/tools/connector";
-ConnectorTool::ConnectorTool() : ToolBase() {
- this->red_curve = 0;
- this->isOrthogonal = false;
- this->c1 = 0;
- this->red_bpath = 0;
- this->green_curve = 0;
- this->selection = 0;
- this->cl0 = 0;
- this->cl1 = 0;
- this->c0 = 0;
-
- this->cursor_shape = cursor_connector_xpm;
- this->hot_x = 1;
- this->hot_y = 1;
- this->xp = 0;
- this->yp = 0;
-
- this->red_color = 0xff00007f;
-
- this->newconn = NULL;
- this->newConnRef = NULL;
- this->curvature = 0.0;
-
- this->sel_changed_connection = sigc::connection();
-
- this->active_shape = NULL;
- this->active_shape_repr = NULL;
- this->active_shape_layer_repr = NULL;
-
- this->active_conn = NULL;
- this->active_conn_repr = NULL;
-
- this->active_handle = NULL;
-
- this->selected_handle = NULL;
-
- this->clickeditem = NULL;
- this->clickedhandle = NULL;
-
+ConnectorTool::ConnectorTool()
+ : ToolBase(cursor_connector_xpm, 1, 1)
+ , selection(NULL)
+ , npoints(0)
+ , state(SP_CONNECTOR_CONTEXT_IDLE)
+ , red_bpath(NULL)
+ , red_curve(NULL)
+ , red_color(0xff00007f)
+ , green_curve(NULL)
+ , newconn(NULL)
+ , newConnRef(NULL)
+ , curvature(0.0)
+ , isOrthogonal(false)
+ , active_shape(NULL)
+ , active_shape_repr(NULL)
+ , active_shape_layer_repr(NULL)
+ , active_conn(NULL)
+ , active_conn_repr(NULL)
+ , active_handle(NULL)
+ , selected_handle(NULL)
+ , clickeditem(NULL)
+ , clickedhandle(NULL)
+ , shref(NULL)
+ , ehref(NULL)
+ , c0(NULL)
+ , c1(NULL)
+ , cl0(NULL)
+ , cl1(NULL)
+{
for (int i = 0; i < 2; ++i) {
this->endpt_handle[i] = NULL;
this->endpt_handler_id[i] = 0;
}
-
- this->shref = NULL;
- this->ehref = NULL;
- this->npoints = 0;
- this->state = SP_CONNECTOR_CONTEXT_IDLE;
}
ConnectorTool::~ConnectorTool() {
diff --git a/src/ui/tools/dropper-tool.cpp b/src/ui/tools/dropper-tool.cpp
index 88ed342df..e9e2d6c39 100644
--- a/src/ui/tools/dropper-tool.cpp
+++ b/src/ui/tools/dropper-tool.cpp
@@ -72,21 +72,17 @@ const std::string& DropperTool::getPrefsPath() {
const std::string DropperTool::prefsPath = "/tools/dropper";
-DropperTool::DropperTool() : ToolBase() {
- this->R = 0;
- this->G = 0;
- this->B = 0;
- this->alpha = 0;
- this->dragging = false;
-
- this->grabbed = 0;
- this->area = 0;
- this->centre = Geom::Point(0, 0);
-
- this->cursor_shape = cursor_dropper_f_xpm;
- this->hot_x = 7;
- this->hot_y = 7;
-
+DropperTool::DropperTool()
+ : ToolBase(cursor_dropper_f_xpm, 7, 7)
+ , R(0)
+ , G(0)
+ , B(0)
+ , alpha(0)
+ , dragging(false)
+ , grabbed(NULL)
+ , area(NULL)
+ , centre(0, 0)
+{
cursor_dropper_fill = sp_cursor_new_from_xpm(cursor_dropper_f_xpm , 7, 7);
cursor_dropper_stroke = sp_cursor_new_from_xpm(cursor_dropper_s_xpm , 7, 7);
}
diff --git a/src/ui/tools/dynamic-base.cpp b/src/ui/tools/dynamic-base.cpp
index cec58dce9..21b4b0532 100644
--- a/src/ui/tools/dynamic-base.cpp
+++ b/src/ui/tools/dynamic-base.cpp
@@ -23,40 +23,41 @@ namespace Inkscape {
namespace UI {
namespace Tools {
-DynamicBase::DynamicBase() :
- ToolBase(),
- accumulated(NULL),
- segments(NULL),
- currentshape(NULL),
- currentcurve(NULL),
- cal1(NULL),
- cal2(NULL),
- point1(),
- point2(),
- repr(NULL),
- cur(0,0),
- vel(0,0),
- vel_max(0),
- acc(0,0),
- ang(0,0),
- last(0,0),
- del(0,0),
- pressure(DEFAULT_PRESSURE),
- xtilt(0),
- ytilt(0),
- dragging(FALSE),
- usepressure(FALSE),
- usetilt(FALSE),
- mass(0.3),
- drag(DRAG_DEFAULT),
- angle(30.0),
- width(0.2),
- vel_thin(0.1),
- flatness(0.9),
- tremor(0),
- cap_rounding(0),
- is_drawing(false),
- abs_width(false)
+DynamicBase::DynamicBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y)
+ : ToolBase(cursor_shape, hot_x, hot_y)
+ , accumulated(NULL)
+ , segments(NULL)
+ , currentshape(NULL)
+ , currentcurve(NULL)
+ , cal1(NULL)
+ , cal2(NULL)
+ , point1()
+ , point2()
+ , npoints(0)
+ , repr(NULL)
+ , cur(0, 0)
+ , vel(0, 0)
+ , vel_max(0)
+ , acc(0, 0)
+ , ang(0, 0)
+ , last(0, 0)
+ , del(0, 0)
+ , pressure(DEFAULT_PRESSURE)
+ , xtilt(0)
+ , ytilt(0)
+ , dragging(false)
+ , usepressure(false)
+ , usetilt(false)
+ , mass(0.3)
+ , drag(DRAG_DEFAULT)
+ , angle(30.0)
+ , width(0.2)
+ , vel_thin(0.1)
+ , flatness(0.9)
+ , tremor(0)
+ , cap_rounding(0)
+ , is_drawing(false)
+ , abs_width(false)
{
}
diff --git a/src/ui/tools/dynamic-base.h b/src/ui/tools/dynamic-base.h
index 9218eabd3..76fcd0f02 100644
--- a/src/ui/tools/dynamic-base.h
+++ b/src/ui/tools/dynamic-base.h
@@ -31,7 +31,7 @@ namespace Tools {
class DynamicBase : public ToolBase {
public:
- DynamicBase();
+ DynamicBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y);
virtual ~DynamicBase();
virtual void set(const Inkscape::Preferences::Entry& val);
@@ -81,9 +81,9 @@ protected:
gdouble ytilt;
/* attributes */
- guint dragging : 1; /* mouse state: mouse is dragging */
- guint usepressure : 1;
- guint usetilt : 1;
+ bool dragging; /* mouse state: mouse is dragging */
+ bool usepressure;
+ bool usetilt;
double mass, drag;
double angle;
double width;
diff --git a/src/ui/tools/eraser-tool.cpp b/src/ui/tools/eraser-tool.cpp
index 270987d27..011d28663 100644
--- a/src/ui/tools/eraser-tool.cpp
+++ b/src/ui/tools/eraser-tool.cpp
@@ -103,10 +103,9 @@ const std::string& EraserTool::getPrefsPath() {
const std::string EraserTool::prefsPath = "/tools/eraser";
-EraserTool::EraserTool() : DynamicBase() {
- this->cursor_shape = cursor_eraser_xpm;
- this->hot_x = 4;
- this->hot_y = 4;
+EraserTool::EraserTool()
+ : DynamicBase(cursor_eraser_xpm, 4, 4)
+{
}
EraserTool::~EraserTool() {
diff --git a/src/ui/tools/flood-tool.cpp b/src/ui/tools/flood-tool.cpp
index 4e29b8856..d74848dc6 100644
--- a/src/ui/tools/flood-tool.cpp
+++ b/src/ui/tools/flood-tool.cpp
@@ -94,17 +94,12 @@ const std::string& FloodTool::getPrefsPath() {
const std::string FloodTool::prefsPath = "/tools/paintbucket";
-FloodTool::FloodTool() : ToolBase() {
- this->cursor_shape = cursor_paintbucket_xpm;
- this->hot_x = 11;
- this->hot_y = 30;
- this->xp = 0;
- this->yp = 0;
+FloodTool::FloodTool()
+ : ToolBase(cursor_paintbucket_xpm, 11, 30)
+ , item(NULL)
+{
+ // TODO: Why does the flood tool use a hardcoded tolerance instead of a pref?
this->tolerance = 4;
- this->within_tolerance = false;
- this->item_to_select = NULL;
-
- this->item = NULL;
}
FloodTool::~FloodTool() {
diff --git a/src/ui/tools/freehand-base.cpp b/src/ui/tools/freehand-base.cpp
index 1e0e6b3b6..2fb4a3481 100644
--- a/src/ui/tools/freehand-base.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -70,37 +70,31 @@ static void spdc_flush_white(FreehandBase *dc, SPCurve *gc);
static void spdc_reset_white(FreehandBase *dc);
static void spdc_free_colors(FreehandBase *dc);
-FreehandBase::FreehandBase() : ToolBase() {
- this->selection = 0;
- this->grab = 0;
- this->anchor_statusbar = false;
-
- this->attach = FALSE;
-
- this->red_color = 0xff00007f;
- this->blue_color = 0x0000ff7f;
- this->green_color = 0x00ff007f;
- this->red_curve_is_valid = false;
-
- this->red_bpath = NULL;
- this->red_curve = NULL;
-
- this->blue_bpath = NULL;
- this->blue_curve = NULL;
-
- this->green_bpaths = NULL;
- this->green_curve = NULL;
- this->green_anchor = NULL;
- this->green_closed = false;
-
- this->white_item = NULL;
- this->white_curves = NULL;
- this->white_anchors = NULL;
-
- this->sa = NULL;
- this->ea = NULL;
-
- this->waiting_LPE_type = Inkscape::LivePathEffect::INVALID_LPE;
+FreehandBase::FreehandBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y)
+ : ToolBase(cursor_shape, hot_x, hot_y)
+ , selection(NULL)
+ , grab(NULL)
+ , attach(false)
+ , red_color(0xff00007f)
+ , blue_color(0x0000ff7f)
+ , green_color(0x00ff007f)
+ , red_bpath(NULL)
+ , 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)
+ , sa(NULL)
+ , ea(NULL)
+ , waiting_LPE_type(Inkscape::LivePathEffect::INVALID_LPE)
+ , red_curve_is_valid(false)
+ , anchor_statusbar(false)
+{
}
FreehandBase::~FreehandBase() {
diff --git a/src/ui/tools/freehand-base.h b/src/ui/tools/freehand-base.h
index 7e53684e3..c8da9faed 100644
--- a/src/ui/tools/freehand-base.h
+++ b/src/ui/tools/freehand-base.h
@@ -37,13 +37,13 @@ namespace Tools {
class FreehandBase : public ToolBase {
public:
- FreehandBase();
+ FreehandBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y);
virtual ~FreehandBase();
Inkscape::Selection *selection;
SPCanvasItem *grab;
- guint attach : 1;
+ bool attach;
guint32 red_color;
guint32 blue_color;
diff --git a/src/ui/tools/gradient-tool.cpp b/src/ui/tools/gradient-tool.cpp
index 10f78a8a8..a0bbfbaf1 100644
--- a/src/ui/tools/gradient-tool.cpp
+++ b/src/ui/tools/gradient-tool.cpp
@@ -74,20 +74,16 @@ const std::string& GradientTool::getPrefsPath() {
const std::string GradientTool::prefsPath = "/tools/gradient";
-GradientTool::GradientTool() : ToolBase() {
- this->node_added = false;
- this->subselcon = 0;
- this->selcon = 0;
-
- this->cursor_addnode = false;
- this->cursor_shape = cursor_gradient_xpm;
- this->hot_x = 4;
- this->hot_y = 4;
- this->xp = 0;
- this->yp = 0;
+GradientTool::GradientTool()
+ : ToolBase(cursor_gradient_xpm, 4, 4)
+ , cursor_addnode(false)
+ , node_added(false)
+// TODO: Why are these connections stored as pointers?
+ , selcon(NULL)
+ , subselcon(NULL)
+{
+ // TODO: This value is overwritten in the root handler
this->tolerance = 6;
- this->within_tolerance = false;
- this->item_to_select = NULL;
}
GradientTool::~GradientTool() {
diff --git a/src/ui/tools/lpe-tool.cpp b/src/ui/tools/lpe-tool.cpp
index a5406f1c5..6c41bb160 100644
--- a/src/ui/tools/lpe-tool.cpp
+++ b/src/ui/tools/lpe-tool.cpp
@@ -81,16 +81,14 @@ const std::string& LpeTool::getPrefsPath() {
const std::string LpeTool::prefsPath = "/tools/lpetool";
-LpeTool::LpeTool() : PenTool() {
- this->mode = Inkscape::LivePathEffect::BEND_PATH;
- this->shape_editor = 0;
-
- this->cursor_shape = cursor_crosshairs_xpm;
- this->hot_x = 7;
- this->hot_y = 7;
-
- this->canvas_bbox = NULL;
- this->measuring_items = new std::map<SPPath *, SPCanvasItem*>;
+LpeTool::LpeTool()
+ : PenTool(cursor_crosshairs_xpm, 7, 7)
+ , shape_editor(NULL)
+ , canvas_bbox(NULL)
+ , mode(Inkscape::LivePathEffect::BEND_PATH)
+// TODO: pointer?
+ , measuring_items(new std::map<SPPath *, SPCanvasItem*>)
+{
}
LpeTool::~LpeTool() {
diff --git a/src/ui/tools/measure-tool.cpp b/src/ui/tools/measure-tool.cpp
index 4d7f1e074..380aa79e3 100644
--- a/src/ui/tools/measure-tool.cpp
+++ b/src/ui/tools/measure-tool.cpp
@@ -236,12 +236,10 @@ void createAngleDisplayCurve(SPDesktop *desktop, Geom::Point const &center, Geom
} // namespace
-MeasureTool::MeasureTool() : ToolBase() {
- this->grabbed = 0;
-
- this->cursor_shape = cursor_measure_xpm;
- this->hot_x = 4;
- this->hot_y = 4;
+MeasureTool::MeasureTool()
+ : ToolBase(cursor_measure_xpm, 4, 4)
+ , grabbed(NULL)
+{
}
MeasureTool::~MeasureTool() {
diff --git a/src/ui/tools/mesh-tool.cpp b/src/ui/tools/mesh-tool.cpp
index 4e7617f44..7d6d3bc23 100644
--- a/src/ui/tools/mesh-tool.cpp
+++ b/src/ui/tools/mesh-tool.cpp
@@ -75,20 +75,18 @@ const std::string& MeshTool::getPrefsPath() {
const std::string MeshTool::prefsPath = "/tools/mesh";
-MeshTool::MeshTool() : ToolBase() {
- this->selcon = 0;
- this->node_added = false;
- this->subselcon = 0;
-
- this->cursor_addnode = false;
- this->cursor_shape = cursor_gradient_xpm;
- this->hot_x = 4;
- this->hot_y = 4;
- this->xp = 0;
- this->yp = 0;
+// TODO: The gradient tool class looks like a 1:1 copy.
+
+MeshTool::MeshTool()
+ : ToolBase(cursor_gradient_xpm, 4, 4)
+ , cursor_addnode(false)
+ , node_added(false)
+// TODO: Why are these connections stored as pointers?
+ , selcon(NULL)
+ , subselcon(NULL)
+{
+ // TODO: This value is overwritten in the root handler
this->tolerance = 6;
- this->within_tolerance = false;
- this->item_to_select = NULL;
}
MeshTool::~MeshTool() {
diff --git a/src/ui/tools/node-tool.cpp b/src/ui/tools/node-tool.cpp
index 7e33b1a4c..b1e11bd66 100644
--- a/src/ui/tools/node-tool.cpp
+++ b/src/ui/tools/node-tool.cpp
@@ -126,30 +126,27 @@ const std::string NodeTool::prefsPath = "/tools/nodes";
SPCanvasGroup *create_control_group(SPDesktop *d);
-NodeTool::NodeTool() : ToolBase() {
- this->show_handles = false;
- this->single_node_transform_handles = false;
- this->show_transform_handles = false;
- this->cursor_drag = false;
- this->live_objects = false;
- this->edit_clipping_paths = false;
- this->live_outline = false;
- this->flashed_item = 0;
- this->_transform_handle_group = 0;
- this->show_path_direction = false;
- this->_last_over = 0;
- this->edit_masks = false;
- this->show_outline = false;
- this->flash_tempitem = 0;
-
- this->cursor_shape = cursor_node_xpm;
- this->hot_x = 1;
- this->hot_y = 1;
-
- this->_selected_nodes = 0;
- this->_multipath = 0;
- this->_selector = 0;
- this->_path_data = 0;
+NodeTool::NodeTool()
+ : ToolBase(cursor_node_xpm, 1, 1)
+ , _selected_nodes(NULL)
+ , _multipath(NULL)
+ , edit_clipping_paths(false)
+ , edit_masks(false)
+ , flashed_item(NULL)
+ , flash_tempitem(NULL)
+ , _selector(NULL)
+ , _path_data(NULL)
+ , _transform_handle_group(NULL)
+ , _last_over(NULL)
+ , cursor_drag(false)
+ , show_handles(false)
+ , show_outline(false)
+ , live_outline(false)
+ , live_objects(false)
+ , show_path_direction(false)
+ , show_transform_handles(false)
+ , single_node_transform_handles(false)
+{
}
SPCanvasGroup *create_control_group(SPDesktop *d)
diff --git a/src/ui/tools/pen-tool.cpp b/src/ui/tools/pen-tool.cpp
index dc5e801c0..39b69f576 100644
--- a/src/ui/tools/pen-tool.cpp
+++ b/src/ui/tools/pen-tool.cpp
@@ -89,29 +89,44 @@ const std::string& PenTool::getPrefsPath() {
const std::string PenTool::prefsPath = "/tools/freehand/pen";
-PenTool::PenTool() : FreehandBase() {
- this->polylines_only = false;
- this->polylines_paraxial = false;
- this->expecting_clicks_for_LPE = 0;
-
- this->cursor_shape = cursor_pen_xpm;
- this->hot_x = 4;
- this->hot_y = 4;
-
- this->npoints = 0;
- this->mode = MODE_CLICK;
- this->state = POINT;
-
- this->c0 = NULL;
- this->c1 = NULL;
- this->cl0 = NULL;
- this->cl1 = NULL;
-
- this->events_disabled = 0;
+PenTool::PenTool()
+ : FreehandBase(cursor_pen_xpm, 4, 4)
+ , p()
+ , npoints(0)
+ , mode(MODE_CLICK)
+ , state(POINT)
+ , polylines_only(false)
+ , polylines_paraxial(false)
+ , num_clicks(0)
+ , expecting_clicks_for_LPE(0)
+ , waiting_LPE(NULL)
+ , waiting_item(NULL)
+ , c0(NULL)
+ , c1(NULL)
+ , cl0(NULL)
+ , cl1(NULL)
+ , events_disabled(false)
+{
+}
- this->num_clicks = 0;
- this->waiting_LPE = NULL;
- this->waiting_item = NULL;
+PenTool::PenTool(gchar const *const *cursor_shape, gint hot_x, gint hot_y)
+ : FreehandBase(cursor_shape, hot_x, hot_y)
+ , p()
+ , npoints(0)
+ , mode(MODE_CLICK)
+ , state(POINT)
+ , polylines_only(false)
+ , polylines_paraxial(false)
+ , num_clicks(0)
+ , expecting_clicks_for_LPE(0)
+ , waiting_LPE(NULL)
+ , waiting_item(NULL)
+ , c0(NULL)
+ , c1(NULL)
+ , cl0(NULL)
+ , cl1(NULL)
+ , events_disabled(false)
+{
}
PenTool::~PenTool() {
@@ -1305,13 +1320,13 @@ static void spdc_pen_finish(PenTool *const pc, gboolean const closed)
}
static void pen_disable_events(PenTool *const pc) {
- pc->events_disabled++;
+ pc->events_disabled = true;
}
static void pen_enable_events(PenTool *const pc) {
- g_return_if_fail(pc->events_disabled != 0);
+ g_return_if_fail(pc->events_disabled != 0);
- pc->events_disabled--;
+ pc->events_disabled = false;
}
void sp_pen_context_wait_for_LPE_mouse_clicks(PenTool *pc, Inkscape::LivePathEffect::EffectType effect_type,
diff --git a/src/ui/tools/pen-tool.h b/src/ui/tools/pen-tool.h
index 4452dbd68..f2b1ee04a 100644
--- a/src/ui/tools/pen-tool.h
+++ b/src/ui/tools/pen-tool.h
@@ -23,6 +23,7 @@ namespace Tools {
class PenTool : public FreehandBase {
public:
PenTool();
+ PenTool(gchar const *const *cursor_shape, gint hot_x, gint hot_y);
virtual ~PenTool();
enum Mode {
@@ -60,7 +61,7 @@ public:
SPCtrlLine *cl0;
SPCtrlLine *cl1;
- unsigned int events_disabled : 1;
+ bool events_disabled;
static const std::string prefsPath;
diff --git a/src/ui/tools/pencil-tool.cpp b/src/ui/tools/pencil-tool.cpp
index 52779d551..4fbaa50f3 100644
--- a/src/ui/tools/pencil-tool.cpp
+++ b/src/ui/tools/pencil-tool.cpp
@@ -83,20 +83,15 @@ const std::string& PencilTool::getPrefsPath() {
const std::string PencilTool::prefsPath = "/tools/freehand/pencil";
-PencilTool::PencilTool() :
- FreehandBase(),
- p(),
- npoints(0),
- state(SP_PENCIL_CONTEXT_IDLE),
- req_tangent(0,0),
- is_drawing(false),
- ps(),
- sketch_interpolation(Geom::Piecewise<Geom::D2<Geom::SBasis> >())// since PencilTool is not properly constructed...
+PencilTool::PencilTool()
+ : FreehandBase(cursor_pencil_xpm, 4, 4)
+ , p()
+ , npoints(0)
+ , state(SP_PENCIL_CONTEXT_IDLE)
+ , req_tangent(0, 0)
+ , is_drawing(false)
+ , sketch_n(0)
{
- this->cursor_shape = cursor_pencil_xpm;
- this->hot_x = 4;
- this->hot_y = 4;
- this->sketch_n = 0;
}
void PencilTool::setup() {
diff --git a/src/ui/tools/rect-tool.cpp b/src/ui/tools/rect-tool.cpp
index 263fdea84..f5153e8ce 100644
--- a/src/ui/tools/rect-tool.cpp
+++ b/src/ui/tools/rect-tool.cpp
@@ -66,20 +66,12 @@ const std::string& RectTool::getPrefsPath() {
const std::string RectTool::prefsPath = "/tools/shapes/rect";
-RectTool::RectTool() : ToolBase() {
- this->cursor_shape = cursor_rect_xpm;
- this->hot_x = 4;
- this->hot_y = 4;
- this->xp = 0;
- this->yp = 0;
- this->tolerance = 0;
- this->within_tolerance = false;
- this->item_to_select = NULL;
-
- this->rect = NULL;
-
- this->rx = 0.0;
- this->ry = 0.0;
+RectTool::RectTool()
+ : ToolBase(cursor_rect_xpm, 4, 4)
+ , rect(NULL)
+ , rx(0)
+ , ry(0)
+{
}
void RectTool::finish() {
diff --git a/src/ui/tools/select-tool.cpp b/src/ui/tools/select-tool.cpp
index 498882417..85bc3fd4a 100644
--- a/src/ui/tools/select-tool.cpp
+++ b/src/ui/tools/select-tool.cpp
@@ -90,24 +90,24 @@ sp_load_handles(int start, int count, char const **xpm) {
}
}
-SelectTool::SelectTool() : ToolBase() {
- this->grabbed = 0;
- this->item = 0;
-
- this->dragging = FALSE;
- this->moved = FALSE;
- this->button_press_shift = false;
- this->button_press_ctrl = false;
- this->button_press_alt = false;
- this->cycling_items = NULL;
- this->cycling_items_cmp = NULL;
- this->cycling_items_selected_before = NULL;
- this->cycling_cur_item = NULL;
- this->cycling_wrap = true;
- this->_seltrans = NULL;
- this->_describer = NULL;
-
-
+SelectTool::SelectTool()
+ // Don't load a default cursor
+ : ToolBase(NULL, 0, 0)
+ , dragging(false)
+ , moved(false)
+ , button_press_shift(false)
+ , button_press_ctrl(false)
+ , button_press_alt(false)
+ , cycling_items(NULL)
+ , cycling_items_cmp(NULL)
+ , cycling_items_selected_before(NULL)
+ , cycling_cur_item(NULL)
+ , cycling_wrap(true)
+ , item(NULL)
+ , grabbed(NULL)
+ , _seltrans(NULL)
+ , _describer(NULL)
+{
// cursors in select context
CursorSelectMouseover = sp_cursor_new_from_xpm(cursor_select_m_xpm , 1, 1);
CursorSelectDragging = sp_cursor_new_from_xpm(cursor_select_d_xpm , 1, 1);
diff --git a/src/ui/tools/select-tool.h b/src/ui/tools/select-tool.h
index b26fc03bc..81763e8b1 100644
--- a/src/ui/tools/select-tool.h
+++ b/src/ui/tools/select-tool.h
@@ -35,8 +35,8 @@ public:
SelectTool();
virtual ~SelectTool();
- guint dragging : 1;
- guint moved : 1;
+ bool dragging;
+ bool moved;
bool button_press_shift;
bool button_press_ctrl;
bool button_press_alt;
diff --git a/src/ui/tools/spiral-tool.cpp b/src/ui/tools/spiral-tool.cpp
index 005b2d239..7d33b0f67 100644
--- a/src/ui/tools/spiral-tool.cpp
+++ b/src/ui/tools/spiral-tool.cpp
@@ -65,21 +65,13 @@ const std::string& SpiralTool::getPrefsPath() {
const std::string SpiralTool::prefsPath = "/tools/shapes/spiral";
-SpiralTool::SpiralTool() : ToolBase() {
- this->cursor_shape = cursor_spiral_xpm;
- this->hot_x = 4;
- this->hot_y = 4;
- this->xp = 0;
- this->yp = 0;
- this->tolerance = 0;
- this->within_tolerance = false;
- this->item_to_select = NULL;
-
- this->spiral = NULL;
-
- this->revo = 3.0;
- this->exp = 1.0;
- this->t0 = 0.0;
+SpiralTool::SpiralTool()
+ : ToolBase(cursor_spiral_xpm, 4, 4)
+ , spiral(NULL)
+ , revo(3)
+ , exp(1)
+ , t0(0)
+{
}
void SpiralTool::finish() {
diff --git a/src/ui/tools/spray-tool.cpp b/src/ui/tools/spray-tool.cpp
index 14a3acd9a..e43b6575e 100644
--- a/src/ui/tools/spray-tool.cpp
+++ b/src/ui/tools/spray-tool.cpp
@@ -79,6 +79,11 @@ using namespace std;
#define DDC_RED_RGBA 0xff0000ff
#define DYNA_MIN_WIDTH 1.0e-6
+// Disabled in 0.91 because of Bug #1274831 (crash, spraying an object
+// with the mode: spray object in single path)
+// Please enable again when working on 1.0
+//#define ENABLE_SPRAY_MODE_SINGLE_PATH
+
#include "tool-factory.h"
namespace Inkscape {
@@ -86,15 +91,15 @@ namespace UI {
namespace Tools {
namespace {
- ToolBase* createSprayContext() {
- return new SprayTool();
- }
+ ToolBase* createSprayContext() {
+ return new SprayTool();
+ }
- bool sprayContextRegistered = ToolFactory::instance().registerObject("/tools/spray", createSprayContext);
+ bool sprayContextRegistered = ToolFactory::instance().registerObject("/tools/spray", createSprayContext);
}
const std::string& SprayTool::getPrefsPath() {
- return SprayTool::prefsPath;
+ return SprayTool::prefsPath;
}
const std::string SprayTool::prefsPath = "/tools/spray";
@@ -114,9 +119,9 @@ inline double NormalDistribution(double mu, double sigma)
static void sp_spray_rotate_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *item, Geom::Rotate const &rotation)
{
Geom::Translate const s(c);
- Geom::Affine affine = Geom::Affine(s).inverse() * Geom::Affine(rotation) * Geom::Affine(s);
+ Geom::Affine affine = s.inverse() * rotation * s;
// Rotate item.
- item->set_i2d_affine(item->i2dt_affine() * (Geom::Affine)affine);
+ 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);
// Restore the center position (it's changed because the bbox center changed)
@@ -134,35 +139,30 @@ static void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *it
item->doWriteTransform(item->getRepr(), item->transform);
}
-SprayTool::SprayTool() : ToolBase() {
- this->usetilt = 0;
- this->dilate_area = 0;
- this->usetext = false;
- this->population = 0;
- this->is_drawing = false;
- this->mode = 0;
- this->usepressure = 0;
-
- this->cursor_shape = cursor_spray_xpm;
- this->hot_x = 4;
- this->hot_y = 4;
-
- /* attributes */
- this->dragging = FALSE;
- this->distrib = 1;
- this->width = 0.2;
- this->force = 0.2;
- this->ratio = 0;
- this->tilt = 0;
- this->mean = 0.2;
- this->rotation_variation = 0;
- this->standard_deviation = 0.2;
- this->scale = 1;
- this->scale_variation = 1;
- this->pressure = TC_DEFAULT_PRESSURE;
-
- this->is_dilating = false;
- this->has_dilated = false;
+SprayTool::SprayTool()
+ : ToolBase(cursor_spray_xpm, 4, 4)
+ , pressure(TC_DEFAULT_PRESSURE)
+ , dragging(false)
+ , usepressure(0)
+ , usetilt(0)
+ , usetext(false)
+ , width(0.2)
+ , ratio(0)
+ , tilt(0)
+ , rotation_variation(0)
+ , force(0.2)
+ , population(0)
+ , scale_variation(1)
+ , scale(1)
+ , mean(0.2)
+ , standard_deviation(0.2)
+ , distrib(1)
+ , mode(0)
+ , is_drawing(false)
+ , is_dilating(false)
+ , has_dilated(false)
+ , dilate_area(NULL)
+{
}
SprayTool::~SprayTool() {
@@ -194,22 +194,22 @@ void SprayTool::update_cursor(bool /*with_shift*/) {
sel_message = g_strdup_printf("%s", _("<b>Nothing</b> selected"));
}
- switch (this->mode) {
- case SPRAY_MODE_COPY:
- this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray <b>copies</b> of the initial selection."), sel_message);
- break;
- case SPRAY_MODE_CLONE:
- this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray <b>clones</b> of the initial selection."), sel_message);
- break;
- case SPRAY_MODE_SINGLE_PATH:
- this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray in a <b>single path</b> of the initial selection."), sel_message);
- break;
- default:
- break;
- }
-
- this->sp_event_context_update_cursor();
- g_free(sel_message);
+ switch (this->mode) {
+ case SPRAY_MODE_COPY:
+ this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray <b>copies</b> of the initial selection."), sel_message);
+ break;
+ case SPRAY_MODE_CLONE:
+ this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray <b>clones</b> of the initial selection."), sel_message);
+ break;
+ case SPRAY_MODE_SINGLE_PATH:
+ this->message_context->setF(Inkscape::NORMAL_MESSAGE, _("%s. Drag, click or click and scroll to spray in a <b>single path</b> of the initial selection."), sel_message);
+ break;
+ default:
+ break;
+ }
+
+ this->sp_event_context_update_cursor();
+ g_free(sel_message);
}
void SprayTool::setup() {
@@ -425,6 +425,7 @@ static bool sp_spray_recursive(SPDesktop *desktop,
did = true;
}
}
+#ifdef ENABLE_SPRAY_MODE_SINGLE_PATH
} else if (mode == SPRAY_MODE_SINGLE_PATH) {
SPItem *parent_item = NULL; // Initial object
@@ -480,6 +481,7 @@ static bool sp_spray_recursive(SPDesktop *desktop,
did = true;
}
}
+#endif
} else if (mode == SPRAY_MODE_CLONE) {
Geom::OptRect a = item->documentVisualBounds();
if (a) {
@@ -521,8 +523,8 @@ static bool sp_spray_recursive(SPDesktop *desktop,
static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point p, Geom::Point vector, bool reverse)
{
- Inkscape::Selection *selection = sp_desktop_selection(SP_EVENT_CONTEXT(tc)->desktop);
- SPDesktop *desktop = SP_EVENT_CONTEXT(tc)->desktop;
+ SPDesktop *desktop = tc->desktop;
+ Inkscape::Selection *selection = sp_desktop_selection(desktop);
if (selection->isEmpty()) {
return false;
@@ -546,18 +548,35 @@ static bool sp_spray_dilate(SprayTool *tc, Geom::Point /*event_p*/, Geom::Point
double move_mean = get_move_mean(tc);
double move_standard_deviation = get_move_standard_deviation(tc);
- for (GSList *items = g_slist_copy(const_cast<GSList *>(selection->itemList()));
- items != NULL;
- items = items->next) {
+ {
+ GSList *const original_selection = g_slist_copy(const_cast<GSList *>(selection->itemList()));
+
+ for (GSList *items = original_selection;
+ items != NULL;
+ items = items->next) {
+ sp_object_ref(SP_ITEM(items->data));
+ }
+
+ for (GSList *items = original_selection;
+ items != NULL;
+ items = items->next) {
+ SPItem *item = SP_ITEM(items->data);
- SPItem *item = SP_ITEM(items->data);
+ if (is_transform_modes(tc->mode)) {
+ if (sp_spray_recursive(desktop, selection, item, p, vector, tc->mode, radius, move_force, tc->population, tc->scale, tc->scale_variation, reverse, move_mean, move_standard_deviation, tc->ratio, tc->tilt, tc->rotation_variation, tc->distrib)) {
+ did = true;
+ }
+ } else {
+ if (sp_spray_recursive(desktop, selection, item, p, vector, tc->mode, radius, path_force, tc->population, tc->scale, tc->scale_variation, reverse, path_mean, path_standard_deviation, tc->ratio, tc->tilt, tc->rotation_variation, tc->distrib)) {
+ did = true;
+ }
+ }
+ }
- if (is_transform_modes(tc->mode)) {
- if (sp_spray_recursive(desktop, selection, item, p, vector, tc->mode, radius, move_force, tc->population, tc->scale, tc->scale_variation, reverse, move_mean, move_standard_deviation, tc->ratio, tc->tilt, tc->rotation_variation, tc->distrib))
- did = true;
- } else {
- if (sp_spray_recursive(desktop, selection, item, p, vector, tc->mode, radius, path_force, tc->population, tc->scale, tc->scale_variation, reverse, path_mean, path_standard_deviation, tc->ratio, tc->tilt, tc->rotation_variation, tc->distrib))
- did = true;
+ for (GSList *items = original_selection;
+ items != NULL;
+ items = items->next) {
+ sp_object_unref(SP_ITEM(items->data));
}
}
@@ -740,6 +759,7 @@ bool SprayTool::root_handler(GdkEvent* event) {
ret = TRUE;
}
break;
+#ifdef ENABLE_SPRAY_MODE_SINGLE_PATH
case GDK_KEY_l:
case GDK_KEY_L:
if (MOD__SHIFT_ONLY(event)) {
@@ -747,6 +767,7 @@ bool SprayTool::root_handler(GdkEvent* event) {
ret = TRUE;
}
break;
+#endif
case GDK_KEY_Up:
case GDK_KEY_KP_Up:
if (!MOD__CTRL_ONLY(event)) {
@@ -859,7 +880,7 @@ bool SprayTool::root_handler(GdkEvent* event) {
// if ((SP_EVENT_CONTEXT_CLASS(sp_spray_context_parent_class))->root_handler) {
// ret = (SP_EVENT_CONTEXT_CLASS(sp_spray_context_parent_class))->root_handler(event_context, event);
// }
- ret = ToolBase::root_handler(event);
+ ret = ToolBase::root_handler(event);
}
return ret;
diff --git a/src/ui/tools/spray-tool.h b/src/ui/tools/spray-tool.h
index e7362fd50..1a8f98006 100644
--- a/src/ui/tools/spray-tool.h
+++ b/src/ui/tools/spray-tool.h
@@ -61,10 +61,10 @@ public:
gdouble pressure;
/* attributes */
- guint dragging : 1; /* mouse state: mouse is dragging */
- guint usepressure : 1;
- guint usetilt : 1;
- bool usetext ;
+ bool dragging; /* mouse state: mouse is dragging */
+ bool usepressure;
+ bool usetilt;
+ bool usetext;
double width;
double ratio;
diff --git a/src/ui/tools/star-tool.cpp b/src/ui/tools/star-tool.cpp
index b5d8c4418..42010788f 100644
--- a/src/ui/tools/star-tool.cpp
+++ b/src/ui/tools/star-tool.cpp
@@ -69,25 +69,15 @@ const std::string& StarTool::getPrefsPath() {
const std::string StarTool::prefsPath = "/tools/shapes/star";
-StarTool::StarTool() : ToolBase() {
- this->randomized = 0;
- this->rounded = 0;
-
- this->cursor_shape = cursor_star_xpm;
- this->hot_x = 4;
- this->hot_y = 4;
- this->xp = 0;
- this->yp = 0;
- this->tolerance = 0;
- this->within_tolerance = false;
- this->item_to_select = NULL;
- //this->tool_url = "/tools/shapes/star";
-
- this->star = NULL;
-
- this->magnitude = 5;
- this->proportion = 0.5;
- this->isflatsided = false;
+StarTool::StarTool()
+ : ToolBase(cursor_star_xpm, 4, 4)
+ , star(NULL)
+ , magnitude(5)
+ , proportion(0.5)
+ , isflatsided(false)
+ , rounded(0)
+ , randomized(0)
+{
}
void StarTool::finish() {
diff --git a/src/ui/tools/text-tool.cpp b/src/ui/tools/text-tool.cpp
index ba68c7829..00f6a853c 100644
--- a/src/ui/tools/text-tool.cpp
+++ b/src/ui/tools/text-tool.cpp
@@ -91,37 +91,26 @@ const std::string& TextTool::getPrefsPath() {
const std::string TextTool::prefsPath = "/tools/text";
-TextTool::TextTool() : ToolBase() {
- this->preedit_string = 0;
- this->unipos = 0;
-
- this->cursor_shape = cursor_text_xpm;
- this->hot_x = 7;
- this->hot_y = 7;
-
- this->xp = 0;
- this->yp = 0;
- this->tolerance = 0;
- this->within_tolerance = false;
-
- this->imc = NULL;
-
- this->text = NULL;
- this->pdoc = Geom::Point(0, 0);
-
- this->unimode = false;
-
- this->cursor = NULL;
- this->indicator = NULL;
- this->frame = NULL;
- this->grabbed = NULL;
- this->timeout = 0;
- this->show = FALSE;
- this->phase = 0;
- this->nascent_object = 0;
- this->over_text = 0;
- this->dragging = 0;
- this->creating = 0;
+TextTool::TextTool()
+ : ToolBase(cursor_text_xpm, 7, 7)
+ , imc(NULL)
+ , text(NULL)
+ , pdoc(0, 0)
+ , unimode(false)
+ , unipos(0)
+ , cursor(NULL)
+ , indicator(NULL)
+ , frame(NULL)
+ , timeout(0)
+ , show(false)
+ , phase(false)
+ , nascent_object(false)
+ , over_text(false)
+ , dragging(0)
+ , creating(false)
+ , grabbed(NULL)
+ , preedit_string(NULL)
+{
}
TextTool::~TextTool() {
diff --git a/src/ui/tools/text-tool.h b/src/ui/tools/text-tool.h
index ef8a67984..c5336d378 100644
--- a/src/ui/tools/text-tool.h
+++ b/src/ui/tools/text-tool.h
@@ -61,15 +61,15 @@ public:
SPCanvasItem *frame; // hiliting the first frame of flowtext; FIXME: make this a list to accommodate arbitrarily many chained shapes
std::vector<SPCanvasItem*> text_selection_quads;
gint timeout;
- guint show : 1;
- guint phase : 1;
- guint nascent_object : 1; // true if we're clicked on canvas to put cursor, but no text typed yet so ->text is still NULL
+ bool show;
+ bool phase;
+ bool nascent_object; // true if we're clicked on canvas to put cursor, but no text typed yet so ->text is still NULL
- guint over_text : 1; // true if cursor is over a text object
+ bool over_text; // true if cursor is over a text object
guint dragging : 2; // dragging selection over text
- guint creating : 1; // dragging rubberband to create flowtext
+ bool creating; // dragging rubberband to create flowtext
SPCanvasItem *grabbed; // we grab while we are creating, to get events even if the mouse goes out of the window
Geom::Point p0; // initial point if the flowtext rect
diff --git a/src/ui/tools/tool-base.cpp b/src/ui/tools/tool-base.cpp
index cc028724a..dc10e9388 100644
--- a/src/ui/tools/tool-base.cpp
+++ b/src/ui/tools/tool-base.cpp
@@ -90,28 +90,26 @@ SPDesktop const& ToolBase::getDesktop() const {
return *desktop;
}
-ToolBase::ToolBase() {
- this->hot_y = 0;
- this->xp = 0;
- this->cursor_shape = 0;
- this->pref_observer = 0;
- this->hot_x = 0;
- this->yp = 0;
- this->within_tolerance = false;
- this->tolerance = 0;
- //this->key = 0;
- this->item_to_select = 0;
-
- this->desktop = NULL;
- this->cursor = NULL;
- this->message_context = NULL;
- this->_selcue = NULL;
- this->_grdrag = NULL;
- this->space_panning = false;
- this->shape_editor = NULL;
- this->_delayed_snap_event = NULL;
- this->_dse_callback_in_process = false;
- //this->tool_url = NULL;
+ToolBase::ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y)
+ : pref_observer(NULL)
+ , cursor(NULL)
+ , xp(0)
+ , yp(0)
+ , tolerance(0)
+ , within_tolerance(false)
+ , item_to_select(NULL)
+ , message_context(NULL)
+ , _selcue(NULL)
+ , _grdrag(NULL)
+ , shape_editor(NULL)
+ , space_panning(false)
+ , _delayed_snap_event(NULL)
+ , _dse_callback_in_process(false)
+ , desktop(NULL)
+ , cursor_shape(cursor_shape)
+ , hot_x(hot_x)
+ , hot_y(hot_y)
+{
}
ToolBase::~ToolBase() {
diff --git a/src/ui/tools/tool-base.h b/src/ui/tools/tool-base.h
index 43edc4bd7..79bdfe89d 100644
--- a/src/ui/tools/tool-base.h
+++ b/src/ui/tools/tool-base.h
@@ -110,7 +110,8 @@ public:
void enableGrDrag (bool enable=true);
bool deleteSelectedDrag(bool just_one);
- ToolBase();
+ ToolBase(gchar const *const *cursor_shape, gint hot_x, gint hot_y);
+
virtual ~ToolBase();
Inkscape::Preferences::Observer *pref_observer;
@@ -179,8 +180,11 @@ public:
SPDesktop *desktop;
protected:
+ /// An xpm containing the shape of the tool's cursor.
gchar const *const *cursor_shape;
- gint hot_x, hot_y; ///< indicates the cursor's hot spot
+
+ /// The cursor's hot spot
+ gint hot_x, hot_y;
private:
ToolBase(const ToolBase&);
@@ -211,9 +215,31 @@ void sp_toggle_dropper(SPDesktop *dt);
bool sp_event_context_knot_mouseover(ToolBase *ec);
+} // namespace Tools
+
+//#include <type_traits>
+
+namespace Tool {
+
+template<class Derived, typename T>
+bool is_a(const T* t) {
+ //static_assert(std::is_base_of<Tools::ToolBase, Derived>(), "Destination type not derived from ToolBase.");
+ //static_assert(std::is_convertible<const Tools::ToolBase*, const T*>(), "Cannot cast passed pointer to ToolBase*.");
+
+ return dynamic_cast<const Derived*>(static_cast<const Tools::ToolBase*>(t)) != NULL;
}
+
+template<class Derived, typename T>
+Derived* to(T* t) {
+ //static_assert(std::is_base_of<Tools::ToolBase, Derived>(), "Destination type not derived from ToolBase.");
+ //static_assert(std::is_convertible<Tools::ToolBase*, T*>(), "Cannot cast passed pointer to ToolBase*.");
+
+ return dynamic_cast<Derived*>(static_cast<Tools::ToolBase*>(t));
}
-}
+
+} // namespace Tool
+} // namespace UI
+} // namespace Inkscape
#endif // SEEN_SP_EVENT_CONTEXT_H
diff --git a/src/ui/tools/tweak-tool.cpp b/src/ui/tools/tweak-tool.cpp
index 0791eff5a..75650d3af 100644
--- a/src/ui/tools/tweak-tool.cpp
+++ b/src/ui/tools/tweak-tool.cpp
@@ -111,32 +111,25 @@ const std::string& TweakTool::getPrefsPath() {
const std::string TweakTool::prefsPath = "/tools/tweak";
-TweakTool::TweakTool() : ToolBase() {
- this->mode = 0;
- this->dilate_area = 0;
- this->usetilt = 0;
- this->usepressure = 0;
- this->is_drawing = false;
- this->fidelity = 0;
-
- this->cursor_shape = cursor_push_xpm;
- this->hot_x = 4;
- this->hot_y = 4;
-
- /* attributes */
- this->dragging = FALSE;
-
- this->width = 0.2;
- this->force = 0.2;
- this->pressure = TC_DEFAULT_PRESSURE;
-
- this->is_dilating = false;
- this->has_dilated = false;
-
- this->do_h = true;
- this->do_s = true;
- this->do_l = true;
- this->do_o = false;
+TweakTool::TweakTool()
+ : ToolBase(cursor_push_xpm, 4, 4)
+ , pressure(TC_DEFAULT_PRESSURE)
+ , dragging(false)
+ , usepressure(false)
+ , usetilt(false)
+ , width(0.2)
+ , force(0.2)
+ , fidelity(0)
+ , mode(0)
+ , is_drawing(false)
+ , is_dilating(false)
+ , has_dilated(false)
+ , dilate_area(NULL)
+ , do_h(true)
+ , do_s(true)
+ , do_l(true)
+ , do_o(false)
+{
}
TweakTool::~TweakTool() {
diff --git a/src/ui/tools/tweak-tool.h b/src/ui/tools/tweak-tool.h
index 6cbb9aded..7fe4b1856 100644
--- a/src/ui/tools/tweak-tool.h
+++ b/src/ui/tools/tweak-tool.h
@@ -50,9 +50,9 @@ public:
gdouble pressure;
/* attributes */
- guint dragging : 1; /* mouse state: mouse is dragging */
- guint usepressure : 1;
- guint usetilt : 1;
+ bool dragging; /* mouse state: mouse is dragging */
+ bool usepressure;
+ bool usetilt;
double width;
double force;
diff --git a/src/ui/tools/zoom-tool.cpp b/src/ui/tools/zoom-tool.cpp
index 0996e6cf4..9f99cfe2e 100644
--- a/src/ui/tools/zoom-tool.cpp
+++ b/src/ui/tools/zoom-tool.cpp
@@ -45,12 +45,11 @@ const std::string& ZoomTool::getPrefsPath() {
const std::string ZoomTool::prefsPath = "/tools/zoom";
-ZoomTool::ZoomTool() : ToolBase() {
- this->grabbed = 0;
- this->cursor_shape = cursor_zoom_xpm;
- this->hot_x = 6;
- this->hot_y = 6;
- this->escaped = false;
+ZoomTool::ZoomTool()
+ : ToolBase(cursor_zoom_xpm, 6, 6)
+ , grabbed(NULL)
+ , escaped(false)
+{
}
ZoomTool::~ZoomTool() {
diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp
index d29554c41..042a6614e 100644
--- a/src/ui/widget/selected-style.cpp
+++ b/src/ui/widget/selected-style.cpp
@@ -1267,6 +1267,11 @@ RotateableSwatch::color_adjust(float *hsla, double by, guint32 cc, guint modifie
} else if (modifier == 3) { // alpha
double old = hsla[3];
hsla[3] += by/2;
+ if (hsla[3] < 0) {
+ hsla[3] = 0;
+ } else if (hsla[3] > 1) {
+ hsla[3] = 1;
+ }
diff = hsla[3] - old;
} else { // hue
double old = hsla[0];
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index cf6a908b6..583dbec85 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -552,11 +552,6 @@ void SPDesktopWidget::init( SPDesktopWidget *dtw )
GtkStyle *style = gtk_style_copy(gtk_widget_get_style(GTK_WIDGET(dtw->canvas)));
style->bg[GTK_STATE_NORMAL] = style->white;
gtk_widget_set_style (GTK_WIDGET (dtw->canvas), style);
-
- // TODO: Extension event stuff has been removed from public API in GTK+ 3
- // Need to check that this hasn't broken anything
- if ( prefs->getBool("/options/useextinput/value", true) )
- gtk_widget_set_extension_events(GTK_WIDGET (dtw->canvas) , GDK_EXTENSION_EVENTS_ALL); //set extension events for tablets, unless disabled in preferences
#endif
g_signal_connect (G_OBJECT (dtw->canvas), "event", G_CALLBACK (sp_desktop_widget_event), dtw);
diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp
index e8296f735..7ad23bbbd 100644
--- a/src/widgets/pencil-toolbar.cpp
+++ b/src/widgets/pencil-toolbar.cpp
@@ -102,8 +102,16 @@ static void freehand_mode_changed(EgeSelectOneAction* act, GObject* tbl)
// in pen tool we have more options than in pencil tool; if one of them was chosen, we do any
// preparatory work here
- if (SP_IS_PEN_CONTEXT(desktop->event_context)) {
- Inkscape::UI::Tools::PenTool *pc = SP_PEN_CONTEXT(desktop->event_context);
+ //if (SP_IS_PEN_CONTEXT(desktop->event_context)) {
+ // Inkscape::UI::Tools::PenTool *pc = SP_PEN_CONTEXT(desktop->event_context);
+ // sp_pen_context_set_polyline_mode(pc);
+ //}
+
+ using namespace Inkscape::UI;
+ using Inkscape::UI::Tools::PenTool;
+
+ if (Tool::is_a<PenTool>(desktop->event_context)) {
+ PenTool* pc = Tool::to<PenTool>(desktop->event_context);
sp_pen_context_set_polyline_mode(pc);
}
}
diff --git a/src/widgets/spray-toolbar.cpp b/src/widgets/spray-toolbar.cpp
index 2a8c85475..49406d564 100644
--- a/src/widgets/spray-toolbar.cpp
+++ b/src/widgets/spray-toolbar.cpp
@@ -60,6 +60,10 @@ using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
using Inkscape::UI::PrefPusher;
+// Disabled in 0.91 because of Bug #1274831 (crash, spraying an object
+// with the mode: spray object in single path)
+// Please enable again when working on 1.0
+//#define ENABLE_SPRAY_MODE_SINGLE_PATH
//########################
//## Spray ##
@@ -186,14 +190,14 @@ void sp_spray_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
1, _("Spray clones of the initial selection"),
2, INKSCAPE_ICON("spray-mode-clone"),
-1 );
-
+#ifdef ENABLE_SPRAY_MODE_SINGLE_PATH
gtk_list_store_append( model, &iter );
gtk_list_store_set( model, &iter,
0, _("Spray single path"),
1, _("Spray objects in a single path"),
2, INKSCAPE_ICON("spray-mode-union"),
-1 );
-
+#endif
EgeSelectOneAction* act = ege_select_one_action_new( "SprayModeAction", _("Mode"), (""), NULL, GTK_TREE_MODEL(model) );
g_object_set( act, "short_label", _("Mode:"), NULL );
gtk_action_group_add_action( mainActions, GTK_ACTION(act) );