summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorJabier Arraiza Cenoz <jabier.arraiza@marker.es>2013-11-13 00:00:04 +0000
committerJabiertxof <jtx@jtx.marker.es>2013-11-13 00:00:04 +0000
commit152a0caf7e216e7ceafeed20822500c385e3e2df (patch)
treea3b5d60e08f3bd8221ba2e50eea80b087e5d541a /src
parentUpdate to trunk (diff)
parentfix C++11 compilation. There A LOT of const_casts in this file... :-( (diff)
downloadinkscape-152a0caf7e216e7ceafeed20822500c385e3e2df.tar.gz
inkscape-152a0caf7e216e7ceafeed20822500c385e3e2df.zip
Update to trunk
(bzr r12588.1.26)
Diffstat (limited to 'src')
-rw-r--r--src/2geom/sbasis.h13
-rw-r--r--src/CMakeLists.txt49
-rw-r--r--src/Makefile.am1
-rw-r--r--src/Makefile_insert26
-rw-r--r--src/box3d-side.cpp2
-rw-r--r--src/box3d.cpp2
-rw-r--r--src/context-fns.cpp6
-rw-r--r--src/context-fns.h13
-rw-r--r--src/desktop-events.cpp12
-rw-r--r--src/desktop-handles.cpp8
-rw-r--r--src/desktop-handles.h14
-rw-r--r--src/desktop-style.cpp2
-rw-r--r--src/desktop.cpp127
-rw-r--r--src/desktop.h22
-rw-r--r--src/dialogs/dialog-events.cpp4
-rw-r--r--src/display/drawing-context.h4
-rw-r--r--src/display/drawing-image.cpp25
-rw-r--r--src/display/nr-filter-image.cpp4
-rw-r--r--src/dom/svgimpl.cpp8
-rw-r--r--src/doxygen-main.cpp28
-rw-r--r--src/draw-anchor.cpp13
-rw-r--r--src/draw-anchor.h15
-rw-r--r--src/file.cpp2
-rw-r--r--src/gradient-chemistry.cpp4
-rw-r--r--src/helper/window.cpp4
-rw-r--r--src/inkscape-private.h2
-rw-r--r--src/inkscape.cpp8
-rw-r--r--src/inkscape.h13
-rw-r--r--src/interface.cpp4
-rw-r--r--src/knot.cpp8
-rw-r--r--src/knotholder.cpp8
-rw-r--r--src/libnrtype/Layout-TNG-OutIter.cpp27
-rw-r--r--src/livarot/PathOutline.cpp2
-rw-r--r--src/live_effects/effect.cpp6
-rw-r--r--src/live_effects/lpe-line_segment.cpp4
-rw-r--r--src/live_effects/lpe-perp_bisector.h4
-rw-r--r--src/live_effects/parameter/path.cpp4
-rw-r--r--src/main.cpp16
-rw-r--r--src/persp3d.cpp6
-rw-r--r--src/persp3d.h12
-rw-r--r--src/proofs2
-rw-r--r--src/remove-last.h7
-rw-r--r--src/selection-chemistry.cpp41
-rw-r--r--src/seltrans.cpp4
-rw-r--r--src/shortcuts.cpp4
-rw-r--r--src/snap.cpp2
-rw-r--r--src/sp-flowtext.cpp2
-rw-r--r--src/sp-item-group.h2
-rw-r--r--src/sp-item-rm-unsatisfied-cns.cpp6
-rw-r--r--src/sp-path.cpp2
-rw-r--r--src/sp-switch.cpp1
-rw-r--r--src/sp-switch.h2
-rw-r--r--src/splivarot.cpp36
-rw-r--r--src/tool-factory.h15
-rw-r--r--src/tools-switch.cpp46
-rw-r--r--src/trace/siox.cpp1
-rw-r--r--src/ui/CMakeLists.txt54
-rw-r--r--src/ui/clipboard.cpp10
-rw-r--r--src/ui/dialog/align-and-distribute.cpp8
-rw-r--r--src/ui/dialog/dialog.cpp6
-rw-r--r--src/ui/dialog/guides.cpp2
-rw-r--r--src/ui/dialog/layer-properties.cpp4
-rw-r--r--src/ui/dialog/layers.cpp4
-rw-r--r--src/ui/dialog/spellcheck.cpp2
-rw-r--r--src/ui/dialog/xml-tree.cpp6
-rw-r--r--src/ui/tool/Makefile_insert2
-rw-r--r--src/ui/tool/control-point-selection.cpp2
-rw-r--r--src/ui/tool/control-point-selection.h2
-rw-r--r--src/ui/tool/control-point.cpp8
-rw-r--r--src/ui/tool/control-point.h13
-rw-r--r--src/ui/tool/curve-drag-point.cpp2
-rw-r--r--src/ui/tool/curve-drag-point.h2
-rw-r--r--src/ui/tool/manipulator.h6
-rw-r--r--src/ui/tool/multi-path-manipulator.cpp2
-rw-r--r--src/ui/tool/multi-path-manipulator.h2
-rw-r--r--src/ui/tool/node.cpp4
-rw-r--r--src/ui/tool/node.h12
-rw-r--r--src/ui/tool/path-manipulator.cpp2
-rw-r--r--src/ui/tool/path-manipulator.h2
-rw-r--r--src/ui/tool/selector.cpp10
-rw-r--r--src/ui/tool/selector.h2
-rw-r--r--src/ui/tool/transform-handle-set.cpp6
-rw-r--r--src/ui/tool/transform-handle-set.h2
-rw-r--r--src/ui/tools/Makefile_insert28
-rw-r--r--src/ui/tools/arc-tool.cpp (renamed from src/arc-context.cpp)52
-rw-r--r--src/ui/tools/arc-tool.h (renamed from src/arc-context.h)20
-rw-r--r--src/ui/tools/box3d-tool.cpp (renamed from src/box3d-context.cpp)54
-rw-r--r--src/ui/tools/box3d-tool.h (renamed from src/box3d-context.h)20
-rw-r--r--src/ui/tools/calligraphic-tool.cpp (renamed from src/dyna-draw-context.cpp)66
-rw-r--r--src/ui/tools/calligraphic-tool.h (renamed from src/dyna-draw-context.h)16
-rw-r--r--src/ui/tools/connector-tool.cpp (renamed from src/connector-context.cpp)151
-rw-r--r--src/ui/tools/connector-tool.h (renamed from src/connector-context.h)23
-rw-r--r--src/ui/tools/dropper-tool.cpp (renamed from src/dropper-context.cpp)40
-rw-r--r--src/ui/tools/dropper-tool.h (renamed from src/dropper-context.h)20
-rw-r--r--src/ui/tools/dynamic-base.cpp (renamed from src/common-context.cpp)22
-rw-r--r--src/ui/tools/dynamic-base.h (renamed from src/common-context.h)16
-rw-r--r--src/ui/tools/eraser-tool.cpp (renamed from src/eraser-context.cpp)52
-rw-r--r--src/ui/tools/eraser-tool.h (renamed from src/eraser-context.h)16
-rw-r--r--src/ui/tools/flood-tool.cpp (renamed from src/flood-context.cpp)50
-rw-r--r--src/ui/tools/flood-tool.h (renamed from src/flood-context.h)24
-rw-r--r--src/ui/tools/freehand-base.cpp (renamed from src/draw-context.cpp)91
-rw-r--r--src/ui/tools/freehand-base.h (renamed from src/draw-context.h)32
-rw-r--r--src/ui/tools/gradient-tool.cpp (renamed from src/gradient-context.cpp)61
-rw-r--r--src/ui/tools/gradient-tool.h (renamed from src/gradient-context.h)26
-rw-r--r--src/ui/tools/lpe-tool.cpp (renamed from src/lpe-tool-context.cpp)71
-rw-r--r--src/ui/tools/lpe-tool.h (renamed from src/lpe-tool-context.h)36
-rw-r--r--src/ui/tools/measure-tool.cpp (renamed from src/measure-context.cpp)45
-rw-r--r--src/ui/tools/measure-tool.h (renamed from src/measure-context.h)20
-rw-r--r--src/ui/tools/mesh-tool.cpp (renamed from src/mesh-context.cpp)56
-rw-r--r--src/ui/tools/mesh-tool.h (renamed from src/mesh-context.h)24
-rw-r--r--src/ui/tools/node-tool.cpp (renamed from src/ui/tool/node-tool.cpp)70
-rw-r--r--src/ui/tools/node-tool.h (renamed from src/ui/tool/node-tool.h)20
-rw-r--r--src/ui/tools/pen-tool.cpp (renamed from src/pen-context.cpp)242
-rw-r--r--src/ui/tools/pen-tool.h (renamed from src/pen-context.h)32
-rw-r--r--src/ui/tools/pencil-tool.cpp (renamed from src/pencil-context.cpp)100
-rw-r--r--src/ui/tools/pencil-tool.h (renamed from src/pencil-context.h)24
-rw-r--r--src/ui/tools/rect-tool.cpp (renamed from src/rect-context.cpp)51
-rw-r--r--src/ui/tools/rect-tool.h (renamed from src/rect-context.h)20
-rw-r--r--src/ui/tools/select-tool.cpp (renamed from src/select-context.cpp)53
-rw-r--r--src/ui/tools/select-tool.h (renamed from src/select-context.h)20
-rw-r--r--src/ui/tools/spiral-tool.cpp (renamed from src/spiral-context.cpp)50
-rw-r--r--src/ui/tools/spiral-tool.h (renamed from src/spiral-context.h)20
-rw-r--r--src/ui/tools/spray-tool.cpp (renamed from src/spray-context.cpp)58
-rw-r--r--src/ui/tools/spray-tool.h (renamed from src/spray-context.h)22
-rw-r--r--src/ui/tools/star-tool.cpp (renamed from src/star-context.cpp)48
-rw-r--r--src/ui/tools/star-tool.h (renamed from src/star-context.h)16
-rw-r--r--src/ui/tools/text-tool.cpp (renamed from src/text-context.cpp)133
-rw-r--r--src/ui/tools/text-tool.h (renamed from src/text-context.h)36
-rw-r--r--src/ui/tools/tool-base.cpp (renamed from src/event-context.cpp)189
-rw-r--r--src/ui/tools/tool-base.h (renamed from src/event-context.h)86
-rw-r--r--src/ui/tools/tweak-tool.cpp (renamed from src/tweak-context.cpp)55
-rw-r--r--src/ui/tools/tweak-tool.h (renamed from src/tweak-context.h)16
-rw-r--r--src/ui/tools/zoom-tool.cpp (renamed from src/zoom-context.cpp)34
-rw-r--r--src/ui/tools/zoom-tool.h (renamed from src/zoom-context.h)20
-rw-r--r--src/ui/widget/rotateable.cpp4
-rw-r--r--src/ui/widget/selected-style.cpp6
-rw-r--r--src/ui/widget/selected-style.h3
-rw-r--r--src/ui/widget/spinbutton.cpp4
-rw-r--r--src/vanishing-point.cpp4
-rw-r--r--src/verbs.cpp18
-rw-r--r--src/widgets/arc-toolbar.cpp2
-rw-r--r--src/widgets/box3d-toolbar.cpp4
-rw-r--r--src/widgets/calligraphy-toolbar.cpp2
-rw-r--r--src/widgets/connector-toolbar.cpp12
-rw-r--r--src/widgets/desktop-widget.cpp2
-rw-r--r--src/widgets/dropper-toolbar.cpp2
-rw-r--r--src/widgets/eraser-toolbar.cpp2
-rw-r--r--src/widgets/fill-style.cpp6
-rw-r--r--src/widgets/gradient-toolbar.cpp25
-rw-r--r--src/widgets/lpe-toolbar.cpp22
-rw-r--r--src/widgets/measure-toolbar.cpp2
-rw-r--r--src/widgets/mesh-toolbar.cpp6
-rw-r--r--src/widgets/node-toolbar.cpp49
-rw-r--r--src/widgets/paintbucket-toolbar.cpp12
-rw-r--r--src/widgets/pencil-toolbar.cpp6
-rw-r--r--src/widgets/rect-toolbar.cpp2
-rw-r--r--src/widgets/sp-color-notebook.cpp4
-rw-r--r--src/widgets/spinbutton-events.cpp4
-rw-r--r--src/widgets/spiral-toolbar.cpp2
-rw-r--r--src/widgets/spray-toolbar.cpp4
-rw-r--r--src/widgets/star-toolbar.cpp2
-rw-r--r--src/widgets/text-toolbar.cpp12
-rw-r--r--src/widgets/toolbox.cpp19
-rw-r--r--src/widgets/toolbox.h13
-rw-r--r--src/widgets/tweak-toolbar.cpp18
-rw-r--r--src/widgets/zoom-toolbar.cpp4
166 files changed, 2004 insertions, 1702 deletions
diff --git a/src/2geom/sbasis.h b/src/2geom/sbasis.h
index e201f16ec..ca864ac7c 100644
--- a/src/2geom/sbasis.h
+++ b/src/2geom/sbasis.h
@@ -74,14 +74,16 @@ class SBasis{
public:
// As part of our migration away from SBasis isa vector we provide this minimal set of vector interface methods.
size_t size() const {return d.size();}
+ typedef std::vector<Linear>::iterator iterator;
+ typedef std::vector<Linear>::const_iterator const_iterator;
Linear operator[](unsigned i) const {
return d[i];
}
Linear& operator[](unsigned i) { return d.at(i); }
- Linear const* begin() const { return (Linear const*)&*d.begin();}
- Linear const* end() const { return (Linear const*)&*d.end();}
- Linear* begin() { return (Linear*)&*d.begin();}
- Linear* end() { return (Linear*)&*d.end();}
+ const_iterator begin() const { return d.begin();}
+ const_iterator end() const { return d.end();}
+ iterator begin() { return d.begin();}
+ iterator end() { return d.end();}
bool empty() const {return d.empty();}
Linear &back() {return d.back();}
Linear const &back() const {return d.back();}
@@ -90,8 +92,7 @@ public:
void resize(unsigned n, Linear const& l) { d.resize(n, l);}
void reserve(unsigned n) { d.reserve(n);}
void clear() {d.clear();}
- void insert(Linear* before, const Linear* src_begin, const Linear* src_end) { d.insert(std::vector<Linear>::iterator(before), src_begin, src_end);}
- //void insert(Linear* aa, Linear* bb, Linear* cc} { d.insert(aa, bb, cc);}
+ void insert(iterator before, const_iterator src_begin, const_iterator src_end) { d.insert(before, src_begin, src_end);}
Linear& at(unsigned i) { return d.at(i);}
//void insert(Linear* before, int& n, Linear const &l) { d.insert(std::vector<Linear>::iterator(before), n, l);}
bool operator==(SBasis const&B) const { return d == B.d;}
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 32bcf19a7..54b15d342 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -77,7 +77,6 @@ set(sp_SRC
sp-tspan.cpp
sp-use-reference.cpp
sp-use.cpp
- spiral-context.cpp
splivarot.cpp
@@ -167,19 +166,15 @@ set(sp_SRC
)
set(inkscape_SRC
- arc-context.cpp
attributes.cpp
axis-manip.cpp
- box3d-context.cpp
box3d-side.cpp
box3d.cpp
color-profile.cpp
color.cpp
- common-context.cpp
composite-undo-stack-observer.cpp
conditions.cpp
conn-avoid-ref.cpp
- connector-context.cpp
console-output-undo-observer.cpp
context-fns.cpp
desktop-events.cpp
@@ -193,26 +188,19 @@ set(inkscape_SRC
document.cpp
doxygen-main.cpp
draw-anchor.cpp
- draw-context.cpp
- dropper-context.cpp
- dyna-draw-context.cpp
ege-adjustment-action.cpp
ege-color-prof-tracker.cpp
ege-output-action.cpp
ege-select-one-action.cpp
- eraser-context.cpp
- event-context.cpp
event-log.cpp
extract-uri.cpp
file.cpp
filter-chemistry.cpp
filter-enums.cpp
- flood-context.cpp
gc-anchored.cpp
gc-finalized.cpp
gc.cpp
gradient-chemistry.cpp
- gradient-context.cpp
gradient-drag.cpp
graphlayout.cpp
guide-snapper.cpp
@@ -232,12 +220,9 @@ set(inkscape_SRC
layer-model.cpp
line-geometry.cpp
line-snapper.cpp
- lpe-tool-context.cpp
main-cmdlineact.cpp
marker.cpp
- measure-context.cpp
media.cpp
- mesh-context.cpp
message-context.cpp
message-stack.cpp
mod360.cpp
@@ -245,8 +230,6 @@ set(inkscape_SRC
object-hierarchy.cpp
object-snapper.cpp
path-chemistry.cpp
- pen-context.cpp
- pencil-context.cpp
persp3d-reference.cpp
persp3d.cpp
perspective-line.cpp
@@ -256,13 +239,11 @@ set(inkscape_SRC
profile-manager.cpp
proj_pt.cpp
rdf.cpp
- rect-context.cpp
removeoverlap.cpp
resource-manager.cpp
rubberband.cpp
satisfied-guide-cns.cpp
selcue.cpp
- select-context.cpp
selection-chemistry.cpp
selection-describer.cpp
selection.cpp
@@ -276,17 +257,13 @@ set(inkscape_SRC
snapped-line.cpp
snapped-point.cpp
snapper.cpp
- spray-context.cpp
- star-context.cpp
style.cpp
svg-view-widget.cpp
svg-view.cpp
text-chemistry.cpp
- text-context.cpp
text-editing.cpp
tools-switch.cpp
transf_mat_3x4.cpp
- tweak-context.cpp
unclump.cpp
unicoderange.cpp
uri-references.cpp
@@ -294,20 +271,16 @@ set(inkscape_SRC
vanishing-point.cpp
verbs.cpp
version.cpp
- zoom-context.cpp
-
# -------
# Headers
MultiPrinter.h
PylogFormatter.h
TRPIFormatter.h
- arc-context.h
attributes-test.h
attributes.h
axis-manip.h
bad-uri-exception.h
- box3d-context.h
box3d-side.h
box3d.h
cms-color-types.h
@@ -318,12 +291,10 @@ set(inkscape_SRC
color-rgba.h
color.h
colorspace.h
- common-context.h
composite-undo-stack-observer.h
conditions.h
conn-avoid-ref.h
connection-pool.h
- connector-context.h
console-output-undo-observer.h
context-fns.h
decimal-round.h
@@ -339,16 +310,11 @@ set(inkscape_SRC
document-undo.h
document.h
draw-anchor.h
- draw-context.h
- dropper-context.h
- dyna-draw-context.h
ege-adjustment-action.h
ege-color-prof-tracker.h
ege-output-action.h
ege-select-one-action.h
enums.h
- eraser-context.h
- event-context.h
event-log.h
event.h
extract-uri-test.h
@@ -358,7 +324,6 @@ set(inkscape_SRC
fill-or-stroke.h
filter-chemistry.h
filter-enums.h
- flood-context.h
gc-alloc.h
gc-allocator.h
gc-anchored.h
@@ -367,7 +332,6 @@ set(inkscape_SRC
gc-managed.h
gc-soft-ptr.h
gradient-chemistry.h
- gradient-context.h
gradient-drag.h
graphlayout.h
guide-snapper.h
@@ -393,15 +357,12 @@ set(inkscape_SRC
layer-model.h
line-geometry.h
line-snapper.h
- lpe-tool-context.h
macros.h
main-cmdlineact.h
marker-test.h
marker.h
- measure-context.h
media.h
menus-skeleton.h
- mesh-context.h
message-context.h
message-stack.h
message.h
@@ -414,8 +375,6 @@ set(inkscape_SRC
object-snapper.h
path-chemistry.h
path-prefix.h
- pen-context.h
- pencil-context.h
persp3d-reference.h
persp3d.h
perspective-line.h
@@ -427,7 +386,6 @@ set(inkscape_SRC
profile-manager.h
proj_pt.h
rdf.h
- rect-context.h
registrytool.h
remove-last.h
removeoverlap.h
@@ -438,7 +396,6 @@ set(inkscape_SRC
rubberband.h
satisfied-guide-cns.h
selcue.h
- select-context.h
selection-chemistry.h
selection-describer.h
selection.h
@@ -454,10 +411,7 @@ set(inkscape_SRC
snapped-line.h
snapped-point.h
snapper.h
- spiral-context.h
splivarot.h
- spray-context.h
- star-context.h
streq.h
strneq.h
style-test.h
@@ -468,13 +422,11 @@ set(inkscape_SRC
syseq.h
test-helpers.h
text-chemistry.h
- text-context.h
text-editing.h
text-tag-attributes.h
tool-factory.h
tools-switch.h
transf_mat_3x4.h
- tweak-context.h
unclump.h
undo-stack-observer.h
unicoderange.h
@@ -484,7 +436,6 @@ set(inkscape_SRC
verbs-test.h
verbs.h
version.h
- zoom-context.h
)
if(WIN32)
diff --git a/src/Makefile.am b/src/Makefile.am
index 411e3cf86..2f91c3c24 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -134,6 +134,7 @@ include ui/Makefile_insert
include ui/cache/Makefile_insert
include ui/dialog/Makefile_insert
include ui/tool/Makefile_insert
+include ui/tools/Makefile_insert
include ui/view/Makefile_insert
include ui/widget/Makefile_insert
include util/Makefile_insert
diff --git a/src/Makefile_insert b/src/Makefile_insert
index e719f8894..5e441560a 100644
--- a/src/Makefile_insert
+++ b/src/Makefile_insert
@@ -4,14 +4,12 @@ ink_common_sources += \
util/find-last-if.h \
util/longest-common-suffix.h \
remove-last.h \
- arc-context.cpp arc-context.h \
attributes.cpp attributes.h \
attribute-rel-svg.cpp attribute-rel-svg.h \
attribute-rel-css.cpp attribute-rel-css.h \
attribute-rel-util.cpp attribute-rel-util.h \
axis-manip.cpp axis-manip.h \
bad-uri-exception.h \
- box3d-context.cpp box3d-context.h \
box3d.cpp box3d.h \
box3d-side.cpp box3d-side.h \
brokenimage.xpm \
@@ -22,13 +20,11 @@ ink_common_sources += \
color-profile-cms-fns.h \
color-rgba.h \
colorspace.h \
- common-context.cpp common-context.h \
composite-undo-stack-observer.cpp \
composite-undo-stack-observer.h \
conditions.cpp conditions.h \
conn-avoid-ref.cpp conn-avoid-ref.h \
connection-pool.h \
- connector-context.cpp connector-context.h \
console-output-undo-observer.h console-output-undo-observer.cpp \
context-fns.cpp context-fns.h \
decimal-round.h \
@@ -43,16 +39,11 @@ ink_common_sources += \
document-undo.cpp document-undo.h \
doxygen-main.cpp \
draw-anchor.cpp draw-anchor.h \
- draw-context.cpp draw-context.h \
- dropper-context.cpp dropper-context.h \
- dyna-draw-context.cpp dyna-draw-context.h \
ege-adjustment-action.cpp ege-adjustment-action.h \
ege-color-prof-tracker.cpp ege-color-prof-tracker.h \
ege-output-action.cpp ege-output-action.h \
ege-select-one-action.cpp ege-select-one-action.h \
enums.h \
- eraser-context.cpp eraser-context.h \
- event-context.cpp event-context.h \
event-log.cpp event-log.h event.h \
extract-uri.cpp extract-uri.h \
factory.h \
@@ -60,7 +51,6 @@ ink_common_sources += \
fill-or-stroke.h \
filter-chemistry.cpp filter-chemistry.h \
filter-enums.cpp filter-enums.h \
- flood-context.cpp flood-context.h \
gc-alloc.h \
gc-anchored.h gc-anchored.cpp \
gc-core.h \
@@ -69,7 +59,6 @@ ink_common_sources += \
gc-managed.h \
gc-soft-ptr.h \
gradient-chemistry.cpp gradient-chemistry.h \
- gradient-context.cpp gradient-context.h \
gradient-drag.cpp gradient-drag.h \
graphlayout.cpp graphlayout.h \
guide-snapper.cpp guide-snapper.h \
@@ -96,13 +85,11 @@ ink_common_sources += \
layer-model.cpp layer-model.h \
line-geometry.cpp line-geometry.h \
line-snapper.cpp line-snapper.h \
- lpe-tool-context.cpp lpe-tool-context.h \
macros.h \
main-cmdlineact.cpp main-cmdlineact.h \
marker.cpp marker.h \
media.cpp media.h \
menus-skeleton.h \
- mesh-context.cpp mesh-context.h \
message-context.cpp message-context.h \
message.h \
message-stack.cpp message-stack.h \
@@ -113,8 +100,6 @@ ink_common_sources += \
object-snapper.cpp object-snapper.h \
path-chemistry.cpp path-chemistry.h \
path-prefix.h \
- pencil-context.cpp pencil-context.h \
- pen-context.cpp pen-context.h \
persp3d.cpp persp3d.h \
persp3d-reference.cpp persp3d-reference.h \
perspective-line.cpp perspective-line.h \
@@ -126,14 +111,12 @@ ink_common_sources += \
proj_pt.cpp proj_pt.h \
removeoverlap.cpp removeoverlap.h \
rdf.cpp rdf.h \
- rect-context.cpp rect-context.h \
resource-manager.cpp resource-manager.h \
require-config.h \
round.h \
rubberband.cpp rubberband.h \
satisfied-guide-cns.cpp satisfied-guide-cns.h \
selcue.cpp selcue.h \
- select-context.cpp select-context.h \
selection-chemistry.cpp selection-chemistry.h \
selection.cpp selection.h \
selection-describer.cpp selection-describer.h \
@@ -177,7 +160,6 @@ ink_common_sources += \
sp-guide-constraint.h \
sp-guide.cpp sp-guide.h \
sp-image.cpp sp-image.h \
- spiral-context.cpp spiral-context.h \
sp-item.cpp sp-item.h \
sp-item-group.cpp sp-item-group.h \
sp-item-notify-moveto.cpp sp-item-notify-moveto.h \
@@ -226,8 +208,6 @@ ink_common_sources += \
sp-tspan.cpp sp-tspan.h \
sp-use.cpp sp-use.h \
sp-use-reference.cpp sp-use-reference.h \
- spray-context.cpp spray-context.h \
- star-context.cpp star-context.h \
streq.h \
strneq.h \
style.cpp style.h \
@@ -236,13 +216,11 @@ ink_common_sources += \
svg-view-widget.cpp svg-view-widget.h \
syseq.h \
text-chemistry.cpp text-chemistry.h \
- text-context.cpp text-context.h \
text-editing.cpp text-editing.h \
text-tag-attributes.h \
tool-factory.h \
tools-switch.cpp tools-switch.h \
transf_mat_3x4.cpp transf_mat_3x4.h \
- tweak-context.h tweak-context.cpp \
unclump.cpp unclump.h \
undo-stack-observer.h \
unicoderange.cpp unicoderange.h \
@@ -250,9 +228,7 @@ ink_common_sources += \
uri-references.cpp uri-references.h \
vanishing-point.cpp vanishing-point.h \
verbs.cpp verbs.h \
- version.cpp version.h \
- zoom-context.cpp zoom-context.h \
- measure-context.cpp measure-context.h
+ version.cpp version.h
# Additional dependencies
diff --git a/src/box3d-side.cpp b/src/box3d-side.cpp
index 040b031c6..7b5ddc00e 100644
--- a/src/box3d-side.cpp
+++ b/src/box3d-side.cpp
@@ -19,7 +19,7 @@
#include "attributes.h"
#include "inkscape.h"
#include "persp3d.h"
-#include "box3d-context.h"
+#include "ui/tools/box3d-tool.h"
#include "preferences.h"
#include "desktop-style.h"
#include "box3d.h"
diff --git a/src/box3d.cpp b/src/box3d.cpp
index 32442746d..13a8d0e3e 100644
--- a/src/box3d.cpp
+++ b/src/box3d.cpp
@@ -21,7 +21,7 @@
#include "box3d.h"
#include "box3d-side.h"
-#include "box3d-context.h"
+#include "ui/tools/box3d-tool.h"
#include "proj_pt.h"
#include "transf_mat_3x4.h"
#include "perspective-line.h"
diff --git a/src/context-fns.cpp b/src/context-fns.cpp
index 81eb6fdb5..1e30e51de 100644
--- a/src/context-fns.cpp
+++ b/src/context-fns.cpp
@@ -9,7 +9,7 @@
#include "message-stack.h"
#include "context-fns.h"
#include "snap.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "sp-namedview.h"
#include "display/snap-indicator.h"
@@ -217,14 +217,14 @@ Geom::Rect Inkscape::snap_rectangular_box(SPDesktop const *desktop, SPItem *item
-Geom::Point Inkscape::setup_for_drag_start(SPDesktop *desktop, SPEventContext* ec, GdkEvent *ev)
+Geom::Point Inkscape::setup_for_drag_start(SPDesktop *desktop, Inkscape::UI::Tools::ToolBase* ec, GdkEvent *ev)
{
ec->xp = static_cast<gint>(ev->button.x);
ec->yp = static_cast<gint>(ev->button.y);
ec->within_tolerance = true;
Geom::Point const p(ev->button.x, ev->button.y);
- ec->item_to_select = sp_event_context_find_item(desktop, p, ev->button.state & GDK_MOD1_MASK, TRUE);
+ ec->item_to_select = Inkscape::UI::Tools::sp_event_context_find_item(desktop, p, ev->button.state & GDK_MOD1_MASK, TRUE);
return ec->desktop->w2d(p);
}
diff --git a/src/context-fns.h b/src/context-fns.h
index 43a45e4c7..bd48e5fb8 100644
--- a/src/context-fns.h
+++ b/src/context-fns.h
@@ -16,7 +16,16 @@
class SPDesktop;
class SPItem;
-class SPEventContext;
+
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class ToolBase;
+
+}
+}
+}
const double goldenratio = 1.61803398874989484820; // golden ratio
@@ -30,7 +39,7 @@ extern bool have_viable_layer(SPDesktop *desktop, MessageContext *message);
extern bool have_viable_layer(SPDesktop *desktop, MessageStack *message);
Geom::Rect snap_rectangular_box(SPDesktop const *desktop, SPItem *item,
Geom::Point const &pt, Geom::Point const &center, int state);
-Geom::Point setup_for_drag_start(SPDesktop *desktop, SPEventContext* ec, GdkEvent *ev);
+Geom::Point setup_for_drag_start(SPDesktop *desktop, Inkscape::UI::Tools::ToolBase* ec, GdkEvent *ev);
}
diff --git a/src/desktop-events.cpp b/src/desktop-events.cpp
index 5cb26abc0..4f8f7889f 100644
--- a/src/desktop-events.cpp
+++ b/src/desktop-events.cpp
@@ -32,7 +32,7 @@
#include "display/snap-indicator.h"
#include "document.h"
#include "document-undo.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "helper/action.h"
#include "message-context.h"
#include "preferences.h"
@@ -245,7 +245,7 @@ static gint sp_dt_ruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidge
int sp_dt_hruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dtw)
{
if (event->type == GDK_MOTION_NOTIFY) {
- sp_event_context_snap_delay_handler(dtw->desktop->event_context, (gpointer) widget, (gpointer) dtw, (GdkEventMotion *)event, DelayedSnapEvent::GUIDE_HRULER);
+ sp_event_context_snap_delay_handler(dtw->desktop->event_context, (gpointer) widget, (gpointer) dtw, (GdkEventMotion *)event, Inkscape::UI::Tools::DelayedSnapEvent::GUIDE_HRULER);
}
return sp_dt_ruler_event(widget, event, dtw, true);
}
@@ -253,7 +253,7 @@ int sp_dt_hruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dtw)
int sp_dt_vruler_event(GtkWidget *widget, GdkEvent *event, SPDesktopWidget *dtw)
{
if (event->type == GDK_MOTION_NOTIFY) {
- sp_event_context_snap_delay_handler(dtw->desktop->event_context, (gpointer) widget, (gpointer) dtw, (GdkEventMotion *)event, DelayedSnapEvent::GUIDE_VRULER);
+ sp_event_context_snap_delay_handler(dtw->desktop->event_context, (gpointer) widget, (gpointer) dtw, (GdkEventMotion *)event, Inkscape::UI::Tools::DelayedSnapEvent::GUIDE_VRULER);
}
return sp_dt_ruler_event(widget, event, dtw, false);
}
@@ -324,7 +324,7 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data)
event->motion.y);
Geom::Point motion_dt(desktop->w2d(motion_w));
- sp_event_context_snap_delay_handler(desktop->event_context, (gpointer) item, data, (GdkEventMotion *)event, DelayedSnapEvent::GUIDE_HANDLER);
+ sp_event_context_snap_delay_handler(desktop->event_context, (gpointer) item, data, (GdkEventMotion *)event, Inkscape::UI::Tools::DelayedSnapEvent::GUIDE_HANDLER);
// This is for snapping while dragging existing guidelines. New guidelines,
// which are dragged off the ruler, are being snapped in sp_dt_ruler_event
@@ -525,7 +525,7 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data)
desktop->guidesMessageContext()->clear();
break;
case GDK_KEY_PRESS:
- switch (get_group0_keyval (&event->key)) {
+ switch (Inkscape::UI::Tools::get_group0_keyval (&event->key)) {
case GDK_KEY_Delete:
case GDK_KEY_KP_Delete:
case GDK_KEY_BackSpace:
@@ -558,7 +558,7 @@ gint sp_dt_guide_event(SPCanvasItem *item, GdkEvent *event, gpointer data)
}
break;
case GDK_KEY_RELEASE:
- switch (get_group0_keyval (&event->key)) {
+ switch (Inkscape::UI::Tools::get_group0_keyval (&event->key)) {
case GDK_KEY_Shift_L:
case GDK_KEY_Shift_R:
GdkCursor *guide_cursor;
diff --git a/src/desktop-handles.cpp b/src/desktop-handles.cpp
index ebfa22c3e..8fa7ad986 100644
--- a/src/desktop-handles.cpp
+++ b/src/desktop-handles.cpp
@@ -15,14 +15,6 @@
#include "desktop.h"
#include "desktop-handles.h"
-//SPEventContext *
-//sp_desktop_event_context (SPDesktop const * desktop)
-//{
-// g_return_val_if_fail (desktop != NULL, NULL);
-//
-// return desktop->event_context;
-//}
-
Inkscape::Selection *
sp_desktop_selection (SPDesktop const * desktop)
{
diff --git a/src/desktop-handles.h b/src/desktop-handles.h
index 9413f075b..70a8c8b5f 100644
--- a/src/desktop-handles.h
+++ b/src/desktop-handles.h
@@ -16,7 +16,17 @@
class SPDesktop;
class SPDocument;
-class SPEventContext;
+
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class ToolBase;
+
+}
+}
+}
+
class SPNamedView;
struct SPCanvas;
struct SPCanvasGroup;
@@ -34,7 +44,7 @@ namespace Inkscape {
#define SP_COORDINATES_UNDERLINE_X (1 << Geom::X)
#define SP_COORDINATES_UNDERLINE_Y (1 << Geom::Y)
-//SPEventContext * sp_desktop_event_context (SPDesktop const * desktop);
+//ToolBase * sp_desktop_event_context (SPDesktop const * desktop);
Inkscape::Selection * sp_desktop_selection (SPDesktop const * desktop);
SPDocument * sp_desktop_document (SPDesktop const * desktop);
SPCanvas * sp_desktop_canvas (SPDesktop const * desktop);
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index f8fad9711..00b9db7d0 100644
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
@@ -42,7 +42,7 @@
#include "xml/sp-css-attr.h"
#include "libnrtype/font-style-to-pos.h"
#include "sp-path.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "desktop-style.h"
#include "svg/svg-icc-color.h"
diff --git a/src/desktop.cpp b/src/desktop.cpp
index ec446e0f0..e24d7eef0 100644
--- a/src/desktop.cpp
+++ b/src/desktop.cpp
@@ -33,7 +33,7 @@
#include <2geom/transforms.h>
#include <2geom/rect.h>
-#include "box3d-context.h"
+#include "ui/tools/box3d-tool.h"
#include "color.h"
#include "desktop-events.h"
#include "desktop.h"
@@ -64,19 +64,20 @@
#include "message-stack.h"
#include "preferences.h"
#include "resource-manager.h"
-#include "select-context.h"
+#include "ui/tools/select-tool.h"
#include "selection.h"
#include "sp-item-group.h"
#include "sp-item-group.h"
#include "sp-namedview.h"
#include "sp-root.h"
#include "sp-defs.h"
+#include "tool-factory.h"
#include "widgets/desktop-widget.h"
#include "xml/repr.h"
#include "helper/action.h" //sp_action_perform
// TODO those includes are only for node tool quick zoom. Remove them after fixing it.
-#include "ui/tool/node-tool.h"
+#include "ui/tools/node-tool.h"
#include "ui/tool/control-point-selection.h"
namespace Inkscape { namespace XML { class Node; }}
@@ -229,14 +230,7 @@ SPDesktop::init (SPNamedView *nv, SPCanvas *aCanvas, Inkscape::UI::View::EditWid
tempgroup = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
controls = (SPCanvasGroup *) sp_canvas_item_new (main, SP_TYPE_CANVAS_GROUP, NULL);
- /* Push select tool to the bottom of stack */
- /** \todo
- * FIXME: this is the only call to this. Everything else seems to just
- * call "set" instead of "push". Can we assume that there is only one
- * context ever?
- */
- //push_event_context (SP_TYPE_SELECT_CONTEXT, "/tools/select", SP_EVENT_CONTEXT_STATIC);
- //set_event_context(SP_TYPE_SELECT_CONTEXT, "/tools/select");
+ // Set the select tool as the active tool.
set_event_context2("/tools/select");
// display rect and zoom are now handled in sp_desktop_widget_realize()
@@ -361,18 +355,10 @@ void SPDesktop::destroy()
g_signal_handlers_disconnect_by_func(G_OBJECT (main), (gpointer) G_CALLBACK(sp_desktop_root_handler), this);
g_signal_handlers_disconnect_by_func(G_OBJECT (drawing), (gpointer) G_CALLBACK(_arena_handler), this);
-// while (event_context) {
-// SPEventContext *ec = event_context;
-// event_context = ec->next;
-// sp_event_context_finish (ec);
-// g_object_unref (G_OBJECT (ec));
-// }
- //sp_event_context_finish(event_context);
- event_context->finish();
- //g_object_unref(G_OBJECT(event_context));
if (event_context) {
+ event_context->finish();
delete event_context;
- event_context = 0;
+ event_context = NULL;
}
delete layers;
@@ -401,7 +387,7 @@ SPDesktop::~SPDesktop()
}
-SPEventContext* SPDesktop::getEventContext() const {
+Inkscape::UI::Tools::ToolBase* SPDesktop::getEventContext() const {
return event_context;
}
@@ -668,92 +654,33 @@ SPDesktop::change_document (SPDocument *theDocument)
_document_replaced_signal.emit (this, theDocument);
}
-
-#include "tool-factory.h"
-
+/**
+ * Replaces the currently active tool with a new one.
+ */
void SPDesktop::set_event_context2(const std::string& toolName) {
- SPEventContext* ec_old = event_context;
-
- if (ec_old) {
- ec_old->deactivate();
- }
-
- SPEventContext* ec_new = ToolFactory::instance().createObject(toolName);
- ec_new->desktop = this;
- ec_new->message_context = new Inkscape::MessageContext(this->messageStack());
+ Inkscape::UI::Tools::ToolBase* new_tool = ToolFactory::instance().createObject(toolName);
+ new_tool->desktop = this;
+ new_tool->message_context = new Inkscape::MessageContext(this->messageStack());
- event_context = ec_new;
+ Inkscape::UI::Tools::ToolBase* old_tool = event_context;
+ event_context = new_tool;
- if (ec_old) {
- ec_old->finish();
- delete ec_old;
+ if (old_tool) {
+ old_tool->finish();
+ delete old_tool;
}
- ec_new->setup();
+ new_tool->setup();
- sp_event_context_activate(event_context);
+ // Make sure no delayed snapping events are carried over after switching tools
+ // (this is only an additional safety measure against sloppy coding, because each
+ // tool should take care of this by itself)
+ sp_event_context_discard_delayed_snap_event(event_context);
_event_context_changed_signal.emit(this, event_context);
}
/**
- * Make desktop switch event contexts.
- */
-//void
-//SPDesktop::set_event_context (GType type, const gchar *config)
-//{
-// //SPEventContext *ec;
-// //while (event_context) {
-// //ec = event_context;
-// sp_event_context_deactivate (event_context);
-// // we have to keep event_context valid during destruction - otherwise writing
-// // destructors is next to impossible
-// // SPEventContext *next = ec->next;
-// sp_event_context_finish (event_context);
-// g_object_unref (G_OBJECT (event_context));
-// // event_context = next;
-// //}
-//
-// // The event_context will be null. This means that it will be impossible
-// // to process any event invoked by the lines below. See for example bug
-// // LP #622350. Cutting and undoing again in the node tool resets the event
-// // context to the node tool. In this bug the line bellow invokes GDK_LEAVE_NOTIFY
-// // events which cannot be handled and must be discarded.
-// event_context = sp_event_context_new (type, this, config, SP_EVENT_CONTEXT_STATIC);
-// // ec->next = event_context;
-// //event_context = ec;
-// // Now the event_context has been set again and we can process all events again
-// sp_event_context_activate (event_context);
-// _event_context_changed_signal.emit (this, event_context);
-//}
-
-/**
- * Push event context onto desktop's context stack.
- */
-//void
-//SPDesktop::push_event_context (GType type, const gchar *config, unsigned int key)
-//{
-// SPEventContext *ref, *ec;
-//
-// if (event_context && event_context->key == key) return;
-// ref = event_context;
-// while (ref && ref->next && ref->next->key != key) ref = ref->next;
-// if (ref && ref->next) {
-// ec = ref->next;
-// ref->next = ec->next;
-// sp_event_context_finish (ec);
-// g_object_unref (G_OBJECT (ec));
-// }
-//
-// if (event_context) sp_event_context_deactivate (event_context);
-// ec = sp_event_context_new (type, this, config, key);
-// ec->next = event_context;
-// event_context = ec;
-// sp_event_context_activate (ec);
-// _event_context_changed_signal.emit (this, ec);
-//}
-
-/**
* Sets the coordinate status to a given point
*/
void
@@ -976,7 +903,7 @@ void SPDesktop::zoom_quick(bool enable)
// TODO This needs to migrate into the node tool, but currently the design
// of this method is sufficiently wrong to prevent this.
if (!zoomed && INK_IS_NODE_TOOL(event_context)) {
- InkNodeTool *nt = static_cast<InkNodeTool*>(event_context);
+ Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(event_context);
if (!nt->_selected_nodes->empty()) {
Geom::Rect nodes = *nt->_selected_nodes->bounds();
double area = nodes.area();
@@ -1945,7 +1872,7 @@ SPDesktop::show_dialogs()
// void
// SPDesktop::pop_event_context (unsigned int key)
// {
-// SPEventContext *ec = NULL;
+// ToolBase *ec = NULL;
//
// if (event_context && event_context->key == key) {
// g_return_if_fail (event_context);
@@ -1957,7 +1884,7 @@ SPDesktop::show_dialogs()
// _event_context_changed_signal.emit (this, ec);
// }
//
-// SPEventContext *ref = event_context;
+// ToolBase *ref = event_context;
// while (ref && ref->next && ref->next->key != key)
// ref = ref->next;
//
diff --git a/src/desktop.h b/src/desktop.h
index 938c2153a..faaa7e3a5 100644
--- a/src/desktop.h
+++ b/src/desktop.h
@@ -41,7 +41,17 @@ class SPCSSAttr;
struct SPCanvas;
struct SPCanvasItem;
struct SPCanvasGroup;
-class SPEventContext;
+
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class ToolBase;
+
+}
+}
+}
+
class SPItem;
class SPNamedView;
class SPObject;
@@ -110,7 +120,7 @@ namespace Inkscape {
* data, like grid and guideline placement, snapping options and so on.
*
* Associated with each SPDesktop are the two most important editing
- * related objects - SPSelection and SPEventContext.
+ * related objects - SPSelection and ToolBase.
*
* Sodipodi keeps track of the active desktop and invokes notification
* signals whenever it changes. UI elements can use these to update their
@@ -128,14 +138,14 @@ public:
Inkscape::LayerModel *layers;
/// current selection; will never generally be NULL
Inkscape::Selection *selection;
- SPEventContext *event_context;
+ Inkscape::UI::Tools::ToolBase *event_context;
Inkscape::LayerManager *layer_manager;
Inkscape::EventLog *event_log;
DocumentInterface *dbus_document_interface;
Inkscape::Display::TemporaryItemList *temporary_item_list;
Inkscape::Display::SnapIndicator *snapindicator;
- SPEventContext* getEventContext() const;
+ Inkscape::UI::Tools::ToolBase* getEventContext() const;
Inkscape::Selection* getSelection() const;
SPDocument* getDocument() const;
SPCanvas* getCanvas() const;
@@ -207,7 +217,7 @@ public:
return _document_replaced_signal.connect (slot);
}
- sigc::connection connectEventContextChanged (const sigc::slot<void,SPDesktop*,SPEventContext*> & slot)
+ sigc::connection connectEventContextChanged (const sigc::slot<void,SPDesktop*,Inkscape::UI::Tools::ToolBase*> & slot)
{
return _event_context_changed_signal.connect (slot);
}
@@ -425,7 +435,7 @@ private:
sigc::signal<void,SPDesktop*,SPDocument*> _document_replaced_signal;
sigc::signal<void> _activate_signal;
sigc::signal<void> _deactivate_signal;
- sigc::signal<void,SPDesktop*,SPEventContext*> _event_context_changed_signal;
+ sigc::signal<void,SPDesktop*,Inkscape::UI::Tools::ToolBase*> _event_context_changed_signal;
sigc::signal<void, gpointer> _tool_subselection_changed;
sigc::connection _activate_connection;
diff --git a/src/dialogs/dialog-events.cpp b/src/dialogs/dialog-events.cpp
index 4fbf26f94..a12e3eafc 100644
--- a/src/dialogs/dialog-events.cpp
+++ b/src/dialogs/dialog-events.cpp
@@ -27,7 +27,7 @@
#include "desktop.h"
#include "inkscape-private.h"
#include "preferences.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "dialog-events.h"
@@ -107,7 +107,7 @@ sp_dialog_event_handler (GtkWindow *win, GdkEvent *event, gpointer data)
case GDK_KEY_PRESS:
- switch (get_group0_keyval (&event->key)) {
+ switch (Inkscape::UI::Tools::get_group0_keyval (&event->key)) {
case GDK_KEY_Escape:
sp_dialog_defocus (win);
ret = TRUE;
diff --git a/src/display/drawing-context.h b/src/display/drawing-context.h
index d4f0dbfc3..35be9a86b 100644
--- a/src/display/drawing-context.h
+++ b/src/display/drawing-context.h
@@ -111,6 +111,10 @@ public:
void setSource(DrawingSurface *s);
void setSourceCheckerboard();
+ void patternSetFilter(cairo_filter_t filter) {
+ cairo_pattern_set_filter(cairo_get_source(_ct), filter);
+ }
+
Geom::Rect targetLogicalBounds() const;
cairo_t *raw() { return _ct; }
diff --git a/src/display/drawing-image.cpp b/src/display/drawing-image.cpp
index a9c0499c2..1b9214c49 100644
--- a/src/display/drawing-image.cpp
+++ b/src/display/drawing-image.cpp
@@ -108,13 +108,6 @@ unsigned DrawingImage::_renderItem(DrawingContext &ct, Geom::IntRect const &/*ar
if (!outline) {
if (!_pixbuf) return RENDER_OK;
-
- // if (_style) {
- // _style->image_rendering.computed
- // See: http://www.w3.org/TR/SVG/painting.html#ImageRenderingProperty
- // http://www.w3.org/TR/css4-images/#the-image-rendering
- // style.h/style.cpp
- // }
Inkscape::DrawingContext::Save save(ct);
ct.transform(_ctm);
@@ -126,6 +119,24 @@ unsigned DrawingImage::_renderItem(DrawingContext &ct, Geom::IntRect const &/*ar
ct.scale(_scale);
ct.setSource(_pixbuf->getSurfaceRaw(), 0, 0);
+ if (_style) {
+ // See: http://www.w3.org/TR/SVG/painting.html#ImageRenderingProperty
+ // http://www.w3.org/TR/css4-images/#the-image-rendering
+ // style.h/style.cpp
+ switch (_style->image_rendering.computed) {
+ case SP_CSS_COLOR_RENDERING_AUTO:
+ // Do nothing
+ break;
+ case SP_CSS_COLOR_RENDERING_OPTIMIZEQUALITY:
+ ct.patternSetFilter( CAIRO_FILTER_BEST );
+ break;
+ case SP_CSS_COLOR_RENDERING_OPTIMIZESPEED:
+ default:
+ ct.patternSetFilter( CAIRO_FILTER_NEAREST );
+ break;
+ }
+ }
+
ct.paint(_opacity);
} else { // outline; draw a rect instead
diff --git a/src/display/nr-filter-image.cpp b/src/display/nr-filter-image.cpp
index 4ca4cd07c..92bb9dcaa 100644
--- a/src/display/nr-filter-image.cpp
+++ b/src/display/nr-filter-image.cpp
@@ -163,6 +163,10 @@ void FilterImage::render_cairo(FilterSlot &slot)
broken_ref = false;
}
+ if (broken_ref) {
+ return;
+ }
+
cairo_surface_t *image_surface = image->getSurfaceRaw();
Geom::Rect sa = slot.get_slot_area();
diff --git a/src/dom/svgimpl.cpp b/src/dom/svgimpl.cpp
index 4372e1b87..0f420dc87 100644
--- a/src/dom/svgimpl.cpp
+++ b/src/dom/svgimpl.cpp
@@ -81,7 +81,7 @@ static double s2d(const DOMString &s)
typedef struct
{
const char *name;
- int type;
+ unsigned int type;
} SVGTableEntry;
@@ -119,7 +119,7 @@ SVGTableEntry interfaceTable[] =
{ "SVGUnitTypes", SVG_UNIT_TYPES },
{ "SVGURIReference", SVG_URI_REFERENCE },
{ "SVGViewSpec", SVG_VIEW_SPEC },
- { "SVGZoomAndPan", static_cast<int>(SVG_ZOOM_AND_PAN)}
+ { "SVGZoomAndPan", SVG_ZOOM_AND_PAN }
};
@@ -266,9 +266,9 @@ int svgInterfaceStrToEnum(const char *str)
* Return the string corresponding to a given SVG element type enum
* Return "unknown" if not found
*/
-const char *svgInterfaceEnumToStr(int type)
+const char *svgInterfaceEnumToStr(unsigned int type)
{
- if (type < 1 || type > (int)SVG_ZOOM_AND_PAN)
+ if (type < 1 || type > SVG_ZOOM_AND_PAN)
return "unknown";
SVGTableEntry *entry = interfaceTable;
for (int i = 0 ; i < SVG_NR_INTERFACES ; i++)
diff --git a/src/doxygen-main.cpp b/src/doxygen-main.cpp
index e581b8708..6a5723bfd 100644
--- a/src/doxygen-main.cpp
+++ b/src/doxygen-main.cpp
@@ -258,27 +258,27 @@ namespace XML {}
*
* \section Event Context Class Hierarchy
*
- *- SPEventContext[\ref event-context.cpp, \ref event-context.h]
- * - SPArcContext [\ref arc-context.cpp, \ref arc-context.h]
+ *- ToolBase[\ref event-context.cpp, \ref event-context.h]
+ * - ArcTool [\ref arc-context.cpp, \ref arc-context.h]
* - SPDrawContext [\ref draw-context.cpp, \ref draw-context.h]
- * - SPPenContext [\ref pen-context.cpp, \ref pen-context.h]
- * - SPPencilContext [\ref pencil-context.cpp, \ref pencil-context.h]
- * - SPConnectorContext [\ref connector-context.cpp, \ref connector-context.h, \ref sp-conn-end.cpp, \ref sp-conn-end-pair.cpp]
- * - SPGradientContext [\ref gradient-context.cpp, \ref gradient-context.h, \ref gradient-drag.cpp, \ref gradient-toolbar.cpp]
- * - SPRectContext [\ref rect-context.cpp, \ref rect-context.h]
- * - SPSelectContext [\ref select-context.cpp, \ref select-context.h]
- * - SPSpiralContext [\ref spiral-context.cpp, \ref spiral-context.h]
- * - SPStarContext [\ref star-context.cpp, \ref star-context.h]
+ * - PenTool [\ref pen-context.cpp, \ref pen-context.h]
+ * - PencilTool [\ref pencil-context.cpp, \ref pencil-context.h]
+ * - ConnectorTool [\ref connector-context.cpp, \ref connector-context.h, \ref sp-conn-end.cpp, \ref sp-conn-end-pair.cpp]
+ * - GradientTool [\ref gradient-context.cpp, \ref gradient-context.h, \ref gradient-drag.cpp, \ref gradient-toolbar.cpp]
+ * - RectTool [\ref rect-context.cpp, \ref rect-context.h]
+ * - SelectTool [\ref select-context.cpp, \ref select-context.h]
+ * - SpiralTool [\ref spiral-context.cpp, \ref spiral-context.h]
+ * - StarTool [\ref star-context.cpp, \ref star-context.h]
* - FloodContext [\ref flood-context.cpp, \ref flood-context.h]
- * - Box3DContext [\ref box3d-context.cpp, \ref box3d-context.h]
+ * - Box3dTool [\ref box3d-context.cpp, \ref box3d-context.h]
*
* SPNodeContext [\ref node-context.cpp, \ref node-context.h]
*
- * SPZoomContext [\ref zoom-context.cpp, \ref zoom-context.h]
+ * ZoomTool [\ref zoom-context.cpp, \ref zoom-context.h]
*
- * SPDynaDrawContext [\ref dyna-draw-context.cpp, \ref dyna-draw-context.h]
+ * CalligraphicTool [\ref dyna-draw-context.cpp, \ref dyna-draw-context.h]
*
- * SPDropperContext [\ref dropper-context.cpp, \ref dropper-context.h]
+ * DropperTool [\ref dropper-context.cpp, \ref dropper-context.h]
*/
/** \page UI User Interface Classes and Files
*
diff --git a/src/draw-anchor.cpp b/src/draw-anchor.cpp
index 2133d5de6..00db936e1 100644
--- a/src/draw-anchor.cpp
+++ b/src/draw-anchor.cpp
@@ -16,8 +16,8 @@
#include "draw-anchor.h"
#include "desktop.h"
#include "desktop-handles.h"
-#include "event-context.h"
-#include "lpe-tool-context.h"
+#include "ui/tools/tool-base.h"
+#include "ui/tools/lpe-tool.h"
#include "display/sodipodi-ctrl.h"
#include "display/curve.h"
#include "ui/control-manager.h"
@@ -30,15 +30,13 @@ using Inkscape::ControlManager;
/**
* Creates an anchor object and initializes it.
*/
-SPDrawAnchor *sp_draw_anchor_new(SPDrawContext *dc, SPCurve *curve, gboolean start, Geom::Point delta)
+SPDrawAnchor *sp_draw_anchor_new(Inkscape::UI::Tools::FreehandBase *dc, SPCurve *curve, gboolean start, Geom::Point delta)
{
if (SP_IS_LPETOOL_CONTEXT(dc)) {
// suppress all kinds of anchors in LPEToolContext
return NULL;
}
- SPDesktop *dt = SP_EVENT_CONTEXT_DESKTOP(dc);
-
SPDrawAnchor *a = g_new(SPDrawAnchor, 1);
a->dc = dc;
@@ -47,7 +45,7 @@ SPDrawAnchor *sp_draw_anchor_new(SPDrawContext *dc, SPCurve *curve, gboolean sta
a->start = start;
a->active = FALSE;
a->dp = delta;
- a->ctrl = ControlManager::getManager().createControl(sp_desktop_controls(dt), Inkscape::CTRL_TYPE_ANCHOR);
+ a->ctrl = ControlManager::getManager().createControl(sp_desktop_controls(&dc->getDesktop()), Inkscape::CTRL_TYPE_ANCHOR);
SP_CTRL(a->ctrl)->moveto(delta);
@@ -77,10 +75,9 @@ SPDrawAnchor *sp_draw_anchor_destroy(SPDrawAnchor *anchor)
*/
SPDrawAnchor *sp_draw_anchor_test(SPDrawAnchor *anchor, Geom::Point w, gboolean activate)
{
- SPDesktop *dt = SP_EVENT_CONTEXT_DESKTOP(anchor->dc);
SPCtrl *ctrl = SP_CTRL(anchor->ctrl);
- if ( activate && ( Geom::LInfty( w - dt->d2w(anchor->dp) ) <= (ctrl->box.width() / 2.0) ) ) {
+ if ( activate && ( Geom::LInfty( w - anchor->dc->getDesktop().d2w(anchor->dp) ) <= (ctrl->box.width() / 2.0) ) ) {
if (!anchor->active) {
g_object_set(anchor->ctrl, "fill_color", FILL_COLOR_MOUSEOVER, NULL);
anchor->active = TRUE;
diff --git a/src/draw-anchor.h b/src/draw-anchor.h
index 1ca2b9888..e7b252186 100644
--- a/src/draw-anchor.h
+++ b/src/draw-anchor.h
@@ -8,14 +8,23 @@
#include <glib.h>
#include <2geom/point.h>
-class SPDrawContext;
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class FreehandBase;
+
+}
+}
+}
+
class SPCurve;
struct SPCanvasItem;
/// The drawing anchor.
/// \todo Make this a regular knot, this will allow to set statusbar tips.
struct SPDrawAnchor {
- SPDrawContext *dc;
+ Inkscape::UI::Tools::FreehandBase *dc;
SPCurve *curve;
guint start : 1;
guint active : 1;
@@ -24,7 +33,7 @@ struct SPDrawAnchor {
};
-SPDrawAnchor *sp_draw_anchor_new(SPDrawContext *dc, SPCurve *curve, gboolean start,
+SPDrawAnchor *sp_draw_anchor_new(Inkscape::UI::Tools::FreehandBase *dc, SPCurve *curve, gboolean start,
Geom::Point delta);
SPDrawAnchor *sp_draw_anchor_destroy(SPDrawAnchor *anchor);
SPDrawAnchor *sp_draw_anchor_test(SPDrawAnchor *anchor, Geom::Point w, gboolean activate);
diff --git a/src/file.cpp b/src/file.cpp
index f978ec66e..cec634c9b 100644
--- a/src/file.cpp
+++ b/src/file.cpp
@@ -36,7 +36,7 @@
#include "dir-util.h"
#include "document-private.h"
#include "document-undo.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "extension/db.h"
#include "extension/input.h"
#include "extension/output.h"
diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp
index 40260ea66..89b7968fc 100644
--- a/src/gradient-chemistry.cpp
+++ b/src/gradient-chemistry.cpp
@@ -32,7 +32,7 @@
#include "desktop.h"
#include "desktop-style.h"
#include "desktop-handles.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "selection.h"
#include "verbs.h"
#include <glibmm/i18n.h>
@@ -1571,7 +1571,7 @@ void sp_gradient_invert_selected_gradients(SPDesktop *desktop, Inkscape::PaintTa
void sp_gradient_reverse_selected_gradients(SPDesktop *desktop)
{
Inkscape::Selection *selection = sp_desktop_selection(desktop);
- SPEventContext *ev = desktop->getEventContext();
+ Inkscape::UI::Tools::ToolBase *ev = desktop->getEventContext();
if (!ev) {
return;
diff --git a/src/helper/window.cpp b/src/helper/window.cpp
index cf6fb12ec..98fbef170 100644
--- a/src/helper/window.cpp
+++ b/src/helper/window.cpp
@@ -22,14 +22,14 @@
#include "inkscape.h"
#include "shortcuts.h"
#include "desktop.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "window.h"
#include <gtk/gtk.h>
static bool on_window_key_press(GdkEventKey* event)
{
unsigned int shortcut;
- shortcut = get_group0_keyval (event) |
+ shortcut = Inkscape::UI::Tools::get_group0_keyval (event) |
( event->state & GDK_SHIFT_MASK ?
SP_SHORTCUT_SHIFT_MASK : 0 ) |
( event->state & GDK_CONTROL_MASK ?
diff --git a/src/inkscape-private.h b/src/inkscape-private.h
index 364e3dab6..d28ed223e 100644
--- a/src/inkscape-private.h
+++ b/src/inkscape-private.h
@@ -43,7 +43,7 @@ void inkscape_trackalt(guint);
void inkscape_selection_modified (Inkscape::Selection *selection, guint flags);
void inkscape_selection_changed (Inkscape::Selection * selection);
void inkscape_selection_set (Inkscape::Selection * selection);
-void inkscape_eventcontext_set (SPEventContext * eventcontext);
+void inkscape_eventcontext_set (Inkscape::UI::Tools::ToolBase * eventcontext);
void inkscape_add_desktop (SPDesktop * desktop);
void inkscape_remove_desktop (SPDesktop * desktop);
void inkscape_activate_desktop (SPDesktop * desktop);
diff --git a/src/inkscape.cpp b/src/inkscape.cpp
index 228841362..8c4ba5695 100644
--- a/src/inkscape.cpp
+++ b/src/inkscape.cpp
@@ -51,7 +51,7 @@
#include "desktop-handles.h"
#include "device-manager.h"
#include "document.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "extension/db.h"
#include "extension/init.h"
#include "extension/output.h"
@@ -145,7 +145,7 @@ struct Inkscape::ApplicationClass {
void (* change_subselection) (Inkscape::Application * inkscape, SPDesktop *desktop);
void (* modify_selection) (Inkscape::Application * inkscape, Inkscape::Selection * selection, guint flags);
void (* set_selection) (Inkscape::Application * inkscape, Inkscape::Selection * selection);
- void (* set_eventcontext) (Inkscape::Application * inkscape, SPEventContext * eventcontext);
+ void (* set_eventcontext) (Inkscape::Application * inkscape, Inkscape::UI::Tools::ToolBase * eventcontext);
void (* activate_desktop) (Inkscape::Application * inkscape, SPDesktop * desktop);
void (* deactivate_desktop) (Inkscape::Application * inkscape, SPDesktop * desktop);
void (* destroy_document) (Inkscape::Application *inkscape, SPDocument *doc);
@@ -991,7 +991,7 @@ inkscape_selection_set (Inkscape::Selection * selection)
void
-inkscape_eventcontext_set (SPEventContext * eventcontext)
+inkscape_eventcontext_set (Inkscape::UI::Tools::ToolBase * eventcontext)
{
g_return_if_fail (eventcontext != NULL);
g_return_if_fail (SP_IS_EVENT_CONTEXT (eventcontext));
@@ -1338,7 +1338,7 @@ bool inkscape_is_sole_desktop_for_document(SPDesktop const &desktop) {
return true;
}
-SPEventContext *
+Inkscape::UI::Tools::ToolBase *
inkscape_active_event_context (void)
{
if (SP_ACTIVE_DESKTOP) {
diff --git a/src/inkscape.h b/src/inkscape.h
index 0effc3c38..823e7524f 100644
--- a/src/inkscape.h
+++ b/src/inkscape.h
@@ -17,7 +17,16 @@
class SPDesktop;
class SPDocument;
-class SPEventContext;
+
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class ToolBase;
+
+}
+}
+}
namespace Inkscape {
class ActionContext;
@@ -49,7 +58,7 @@ bool inkscapeIsCrashing();
SPDesktop * inkscape_find_desktop_by_dkey (unsigned int dkey);
#define SP_ACTIVE_EVENTCONTEXT inkscape_active_event_context ()
-SPEventContext * inkscape_active_event_context (void);
+Inkscape::UI::Tools::ToolBase * inkscape_active_event_context (void);
#define SP_ACTIVE_DOCUMENT inkscape_active_document ()
SPDocument * inkscape_active_document (void);
diff --git a/src/interface.cpp b/src/interface.cpp
index f411989ce..5d4022e7b 100644
--- a/src/interface.cpp
+++ b/src/interface.cpp
@@ -67,7 +67,7 @@
#include "svg/svg-color.h"
#include "desktop-style.h"
#include "style.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "gradient-drag.h"
#include "widgets/ege-paint-def.h"
#include "document-undo.h"
@@ -1300,7 +1300,7 @@ sp_ui_drag_data_received(GtkWidget *widget,
}
}
-#include "gradient-context.h"
+#include "ui/tools/gradient-tool.h"
void sp_ui_drag_motion( GtkWidget */*widget*/,
GdkDragContext */*drag_context*/,
diff --git a/src/knot.cpp b/src/knot.cpp
index 2b67440dc..2179bc3d5 100644
--- a/src/knot.cpp
+++ b/src/knot.cpp
@@ -27,7 +27,7 @@
#include "preferences.h"
#include "message-stack.h"
#include "message-context.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
using Inkscape::DocumentUndo;
@@ -396,7 +396,7 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot
SP_KNOT_DRAGGING,
TRUE);
}
- sp_event_context_snap_delay_handler(knot->desktop->event_context, NULL, (gpointer) knot, (GdkEventMotion *)event, DelayedSnapEvent::KNOT_HANDLER);
+ sp_event_context_snap_delay_handler(knot->desktop->event_context, NULL, (gpointer) knot, (GdkEventMotion *)event, Inkscape::UI::Tools::DelayedSnapEvent::KNOT_HANDLER);
sp_knot_handler_request_position(event, knot);
moved = TRUE;
}
@@ -426,7 +426,7 @@ static int sp_knot_handler(SPCanvasItem */*item*/, GdkEvent *event, SPKnot *knot
consumed = TRUE;
break;
case GDK_KEY_PRESS: // keybindings for knot
- switch (get_group0_keyval(&event->key)) {
+ switch (Inkscape::UI::Tools::get_group0_keyval(&event->key)) {
case GDK_KEY_Escape:
sp_knot_set_flag(knot, SP_KNOT_GRABBED, FALSE);
if (!nograb) {
@@ -471,7 +471,7 @@ void sp_knot_handler_request_position(GdkEvent *event, SPKnot *knot)
knot->desktop->scroll_to_point (motion_dt);
knot->desktop->set_coordinate_status(knot->pos); // display the coordinate of knot, not cursor - they may be different!
if (event->motion.state & GDK_BUTTON1_MASK)
- gobble_motion_events(GDK_BUTTON1_MASK);
+ Inkscape::UI::Tools::gobble_motion_events(GDK_BUTTON1_MASK);
}
SPKnot *sp_knot_new(SPDesktop *desktop, const gchar *tip)
diff --git a/src/knotholder.cpp b/src/knotholder.cpp
index 7129348c2..71bccca16 100644
--- a/src/knotholder.cpp
+++ b/src/knotholder.cpp
@@ -20,13 +20,13 @@
#include "knot.h"
#include "knotholder.h"
#include "knot-holder-entity.h"
-#include "rect-context.h"
+#include "ui/tools/rect-tool.h"
#include "sp-rect.h"
-#include "arc-context.h"
+#include "ui/tools/arc-tool.h"
#include "sp-ellipse.h"
-#include "star-context.h"
+#include "ui/tools/tweak-tool.h"
#include "sp-star.h"
-#include "spiral-context.h"
+#include "ui/tools/spiral-tool.h"
#include "sp-spiral.h"
#include "sp-offset.h"
#include "box3d.h"
diff --git a/src/libnrtype/Layout-TNG-OutIter.cpp b/src/libnrtype/Layout-TNG-OutIter.cpp
index 4e61c10a0..8d8621d64 100644
--- a/src/libnrtype/Layout-TNG-OutIter.cpp
+++ b/src/libnrtype/Layout-TNG-OutIter.cpp
@@ -168,7 +168,7 @@ Layout::iterator Layout::getLetterAt(double x, double y) const
return end();
}
-Layout::iterator Layout::sourceToIterator(void *source_cookie, Glib::ustring::const_iterator text_iterator) const
+Layout::iterator Layout::sourceToIterator(void *source_cookie /*, Glib::ustring::const_iterator text_iterator*/) const
{
unsigned source_index;
if (_characters.empty()) return end();
@@ -182,6 +182,8 @@ Layout::iterator Layout::sourceToIterator(void *source_cookie, Glib::ustring::co
return iterator(this, char_index);
InputStreamTextSource const *text_source = static_cast<InputStreamTextSource const *>(_input_stream[source_index]);
+ return iterator(this, char_index);
+ /* This code was never used, the text_iterator argument was "NULL" in all calling code
if (text_iterator <= text_source->text_begin) return iterator(this, char_index);
if (text_iterator >= text_source->text_end) {
if (source_index == _input_stream.size() - 1) return end();
@@ -194,11 +196,7 @@ Layout::iterator Layout::sourceToIterator(void *source_cookie, Glib::ustring::co
iter_text++;
}
return end(); // never happens
-}
-
-Layout::iterator Layout::sourceToIterator(void *source_cookie) const
-{
- return sourceToIterator(source_cookie, Glib::ustring::const_iterator(std::string::const_iterator(NULL)));
+ */
}
Geom::OptRect Layout::glyphBoundingBox(iterator const &it, double *rotation) const
@@ -534,19 +532,24 @@ void Layout::getSourceOfCharacter(iterator const &it, void **source_cookie, Glib
InputStreamItem *stream_item = _input_stream[_spans[_characters[it._char_index].in_span].in_input_stream_item];
*source_cookie = stream_item->source_cookie;
if (text_iterator && stream_item->Type() == TEXT_SOURCE) {
- InputStreamTextSource const *text_source = static_cast<InputStreamTextSource const *>(stream_item);
- Glib::ustring::const_iterator text_iter_const = text_source->text_begin;
+ InputStreamTextSource *text_source = dynamic_cast<InputStreamTextSource *>(stream_item);
+
+ // In order to return a non-const iterator in text_iterator, do the const_cast here.
+ // Note that, although ugly, it is safe because we do not write to *iterator anywhere.
+ Glib::ustring::iterator text_iter = const_cast<Glib::ustring *>(text_source->text)->begin();
+
unsigned char_index = it._char_index;
unsigned original_input_source_index = _spans[_characters[char_index].in_span].in_input_stream_item;
// confusing algorithm because the iterator goes forwards while the index goes backwards.
// It's just that it's faster doing it that way
while (char_index && _spans[_characters[char_index - 1].in_span].in_input_stream_item == original_input_source_index) {
- ++text_iter_const;
+ ++text_iter;
char_index--;
}
- text_source->text->begin().base() + (text_iter_const.base() - text_source->text->begin().base());
- *text_iterator = Glib::ustring::iterator(std::string::iterator(const_cast<char*>(&*text_source->text->begin().base() + (text_iter_const.base() - text_source->text->begin().base()))));
- // the caller owns the string, so they're going to want a non-const iterator
+
+ if (text_iterator) {
+ *text_iterator = text_iter;
+ }
}
}
diff --git a/src/livarot/PathOutline.cpp b/src/livarot/PathOutline.cpp
index fbfaa98aa..f15da4af7 100644
--- a/src/livarot/PathOutline.cpp
+++ b/src/livarot/PathOutline.cpp
@@ -1183,7 +1183,7 @@ Path::OutlineJoin (Path * dest, Geom::Point pos, Geom::Point stNor, Geom::Point
const double angSi = cross (enNor,stNor);
const double angCo = dot (stNor, enNor);
- if (angSi == 0 && angCo > 0) { // The join is straight -> nothing to do.
+ if (fabs(angSi < .0000001) && angCo > 0) { // The join is straight -> nothing to do.
} else {
if ((angSi > 0 && width >= 0)
|| (angSi < 0 && width < 0)) { // This is an inside join -> join is independent of chosen JoinType.
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index 623879ac5..70ce1e89d 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -58,7 +58,7 @@
#include "document-private.h"
#include "xml/document.h"
#include <glibmm/i18n.h>
-#include "pen-context.h"
+#include "ui/tools/pen-tool.h"
#include "tools-switch.h"
#include "message-stack.h"
#include "desktop.h"
@@ -343,8 +343,8 @@ Effect::doAcceptPathPreparations(SPLPEItem *lpeitem)
tools_switch(desktop, TOOLS_FREEHAND_PEN);
}
- SPEventContext *ec = desktop->event_context;
- SPPenContext *pc = SP_PEN_CONTEXT(ec);
+ Inkscape::UI::Tools::ToolBase *ec = desktop->event_context;
+ Inkscape::UI::Tools::PenTool *pc = SP_PEN_CONTEXT(ec);
pc->expecting_clicks_for_LPE = this->acceptsNumClicks();
pc->waiting_LPE = this;
pc->waiting_item = lpeitem;
diff --git a/src/live_effects/lpe-line_segment.cpp b/src/live_effects/lpe-line_segment.cpp
index 2e7240e25..78d286143 100644
--- a/src/live_effects/lpe-line_segment.cpp
+++ b/src/live_effects/lpe-line_segment.cpp
@@ -12,7 +12,7 @@
*/
#include "live_effects/lpe-line_segment.h"
-#include "lpe-tool-context.h"
+#include "ui/tools/lpe-tool.h"
#include <2geom/pathvector.h>
#include <2geom/geom.h>
@@ -45,7 +45,7 @@ LPELineSegment::~LPELineSegment()
void
LPELineSegment::doBeforeEffect (SPLPEItem const* lpeitem)
{
- lpetool_get_limiting_bbox_corners(lpeitem->document, bboxA, bboxB);
+ Inkscape::UI::Tools::lpetool_get_limiting_bbox_corners(lpeitem->document, bboxA, bboxB);
}
std::vector<Geom::Path>
diff --git a/src/live_effects/lpe-perp_bisector.h b/src/live_effects/lpe-perp_bisector.h
index 4ff9909a4..3a2278de3 100644
--- a/src/live_effects/lpe-perp_bisector.h
+++ b/src/live_effects/lpe-perp_bisector.h
@@ -27,7 +27,7 @@ namespace PB {
class KnotHolderEntityEnd;
class KnotHolderEntityLeftEnd;
class KnotHolderEntityRightEnd;
- void bisector_end_set(SPItem *item, Geom::Point const &p, guint state, bool left);
+ void bisector_end_set(SPItem *item, Geom::Point const &p, guint state, bool left = true);
}
class LPEPerpBisector : public Effect {
@@ -46,7 +46,7 @@ public:
friend class PB::KnotHolderEntityEnd;
friend class PB::KnotHolderEntityLeftEnd;
friend class PB::KnotHolderEntityRightEnd;
- friend void PB::bisector_end_set(SPItem *item, Geom::Point const &p, guint state, bool left = true);
+ friend void PB::bisector_end_set(SPItem *item, Geom::Point const &p, guint state, bool left);
void addKnotHolderEntities(KnotHolder *knotholder, SPDesktop *desktop, SPItem *item);
private:
diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp
index e5648dc68..77f7eabcc 100644
--- a/src/live_effects/parameter/path.cpp
+++ b/src/live_effects/parameter/path.cpp
@@ -40,7 +40,7 @@
#include "sp-text.h"
#include "display/curve.h"
-#include "ui/tool/node-tool.h"
+#include "ui/tools/node-tool.h"
#include "ui/tool/multi-path-manipulator.h"
#include "ui/tool/shape-record.h"
@@ -208,7 +208,7 @@ PathParam::param_editOncanvas(SPItem *item, SPDesktop * dt)
tools_switch(dt, TOOLS_NODES);
}
- InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
+ Inkscape::UI::Tools::NodeTool *nt = static_cast<Inkscape::UI::Tools::NodeTool*>(dt->event_context);
std::set<ShapeRecord> shapes;
ShapeRecord r;
diff --git a/src/main.cpp b/src/main.cpp
index 1c0f4cee7..29bc7f7e9 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -917,6 +917,16 @@ static int sp_common_main( int argc, char const **argv, GSList **flDest )
return 0;
}
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+guint get_group0_keyval(GdkEventKey* event);
+
+}
+}
+}
+
static void
snooper(GdkEvent *event, gpointer /*data*/) {
if (inkscape_mapalt()) /* returns the map of the keyboard modifier to map to Alt, zero if no mapping */
@@ -959,7 +969,7 @@ snooper(GdkEvent *event, gpointer /*data*/) {
static gboolean altL_pressed = FALSE;
static gboolean altR_pressed = FALSE;
static gboolean alt_pressed = FALSE;
- guint get_group0_keyval(GdkEventKey* event);
+
guint keyval = 0;
switch (event->type) {
case GDK_MOTION_NOTIFY:
@@ -969,7 +979,7 @@ snooper(GdkEvent *event, gpointer /*data*/) {
alt_pressed = TRUE && (event->button.state & GDK_MOD1_MASK);
break;
case GDK_KEY_PRESS:
- keyval = get_group0_keyval(&event->key);
+ keyval = Inkscape::UI::Tools::get_group0_keyval(&event->key);
if (keyval == GDK_KEY_Alt_L) altL_pressed = TRUE;
if (keyval == GDK_KEY_Alt_R) altR_pressed = TRUE;
alt_pressed = alt_pressed || altL_pressed || altR_pressed;
@@ -980,7 +990,7 @@ snooper(GdkEvent *event, gpointer /*data*/) {
event->key.state &= ~GDK_MOD1_MASK;
break;
case GDK_KEY_RELEASE:
- keyval = get_group0_keyval(&event->key);
+ keyval = Inkscape::UI::Tools::get_group0_keyval(&event->key);
if (keyval == GDK_KEY_Alt_L) altL_pressed = FALSE;
if (keyval == GDK_KEY_Alt_R) altR_pressed = FALSE;
if (!altL_pressed && !altR_pressed)
diff --git a/src/persp3d.cpp b/src/persp3d.cpp
index 530da0799..b10e5f23b 100644
--- a/src/persp3d.cpp
+++ b/src/persp3d.cpp
@@ -17,7 +17,7 @@
#include "document-private.h"
#include "document-undo.h"
#include "vanishing-point.h"
-#include "box3d-context.h"
+#include "ui/tools/box3d-tool.h"
#include "box3d.h"
#include "xml/document.h"
#include "xml/node-event-vector.h"
@@ -140,9 +140,9 @@ void Persp3D::set(unsigned key, gchar const *value) {
}
// FIXME: Is this the right place for resetting the draggers?
- SPEventContext *ec = inkscape_active_event_context();
+ Inkscape::UI::Tools::ToolBase *ec = inkscape_active_event_context();
if (SP_IS_BOX3D_CONTEXT(ec)) {
- Box3DContext *bc = SP_BOX3D_CONTEXT(ec);
+ Inkscape::UI::Tools::Box3dTool *bc = SP_BOX3D_CONTEXT(ec);
bc->_vpdrag->updateDraggers();
bc->_vpdrag->updateLines();
bc->_vpdrag->updateBoxHandles();
diff --git a/src/persp3d.h b/src/persp3d.h
index cb7e7f900..4690c0582 100644
--- a/src/persp3d.h
+++ b/src/persp3d.h
@@ -24,7 +24,17 @@
#include "inkscape.h"
class SPBox3D;
-class Box3DContext;
+
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class Box3dTool;
+
+}
+}
+}
+
class Persp3DImpl {
public:
diff --git a/src/proofs b/src/proofs
index 05f27daea..d1922647e 100644
--- a/src/proofs
+++ b/src/proofs
@@ -23,7 +23,7 @@ in which case we'd have filled in pc->red_curve to a non-empty curve.
Expansion of the above claim of at least 3 distinct points: We know n_segs <= 0 ||
unsigned(dc->npoints) >= G_N_ELEMENTS(pc->p) from the negation of the containing `if' condition.
-G_N_ELEMENTS(pc->p) is greater than 3 (in int arithmetic), from SPPencilContext::p array definition
+G_N_ELEMENTS(pc->p) is greater than 3 (in int arithmetic), from PencilTool::p array definition
in pencil-context.h. npoints grows by no more than one per fit_and_split invocation; we should be
able to establish that dc->npoints == G_N_ELEMENTS(pc->p) if unsigned(dc->npoints) >=
G_N_ELEMENTS(pc->p), in which case 3 <= dc->npoints in int arithmetic. We know that dc->npoints >=
diff --git a/src/remove-last.h b/src/remove-last.h
index a5bbd89f8..8c84d0ed4 100644
--- a/src/remove-last.h
+++ b/src/remove-last.h
@@ -8,12 +8,9 @@
template<class T>
inline void remove_last(std::vector<T> &seq, T const &elem)
{
- using std::vector;
-
- typename vector<T>::reverse_iterator i(find(seq.rbegin(), seq.rend(), elem));
+ typename std::vector<T>::reverse_iterator i(find(seq.rbegin(), seq.rend(), elem));
g_assert( i != seq.rend() );
- typename vector<T>::iterator ii(&*i);
- seq.erase(ii);
+ seq.erase(i.base());
}
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index e68feb188..26e575439 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -56,11 +56,11 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS;
#include "sp-polyline.h"
#include "sp-line.h"
#include "text-editing.h"
-#include "text-context.h"
-#include "connector-context.h"
+#include "ui/tools/text-tool.h"
+#include "ui/tools/connector-tool.h"
#include "sp-path.h"
#include "sp-conn-end.h"
-#include "dropper-context.h"
+#include "ui/tools/dropper-tool.h"
#include <glibmm/i18n.h>
#include <2geom/transforms.h>
#include "xml/repr.h"
@@ -74,7 +74,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS;
#include "sp-pattern.h"
#include "sp-symbol.h"
#include "sp-radial-gradient.h"
-#include "gradient-context.h"
+#include "ui/tools/gradient-tool.h"
#include "sp-namedview.h"
#include "preferences.h"
#include "sp-offset.h"
@@ -111,7 +111,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS;
// For clippath editing
#include "tools-switch.h"
-#include "ui/tool/node-tool.h"
+#include "ui/tools/node-tool.h"
#include "ui/clipboard.h"
#include "verbs.h"
@@ -119,6 +119,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS;
using Inkscape::DocumentUndo;
using Geom::X;
using Geom::Y;
+using Inkscape::UI::Tools::NodeTool;
/* The clipboard handling is in ui/clipboard.cpp now. There are some legacy functions left here,
because the layer manipulation code uses them. It should be rewritten specifically
@@ -146,7 +147,7 @@ namespace Inkscape {
void SelectionHelper::selectAll(SPDesktop *dt)
{
if (tools_isactive(dt, TOOLS_NODES)) {
- InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
+ NodeTool *nt = static_cast<NodeTool*>(dt->event_context);
if (!nt->_multipath->empty()) {
nt->_multipath->selectSubpaths();
return;
@@ -158,7 +159,7 @@ void SelectionHelper::selectAll(SPDesktop *dt)
void SelectionHelper::selectAllInAll(SPDesktop *dt)
{
if (tools_isactive(dt, TOOLS_NODES)) {
- InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
+ NodeTool *nt = static_cast<NodeTool*>(dt->event_context);
nt->_selected_nodes->selectAll();
} else {
sp_edit_select_all_in_all_layers(dt);
@@ -167,9 +168,9 @@ void SelectionHelper::selectAllInAll(SPDesktop *dt)
void SelectionHelper::selectNone(SPDesktop *dt)
{
- InkNodeTool *nt = NULL;
+ NodeTool *nt = NULL;
if (tools_isactive(dt, TOOLS_NODES)) {
- nt = static_cast<InkNodeTool*>(dt->event_context);
+ nt = static_cast<NodeTool*>(dt->event_context);
}
if (nt && !nt->_selected_nodes->empty()) {
@@ -210,7 +211,7 @@ void SelectionHelper::selectSameObjectType(SPDesktop *dt)
void SelectionHelper::invert(SPDesktop *dt)
{
if (tools_isactive(dt, TOOLS_NODES)) {
- InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
+ NodeTool *nt = static_cast<NodeTool*>(dt->event_context);
nt->_multipath->invertSelectionInSubpaths();
} else {
sp_edit_invert(dt);
@@ -220,7 +221,7 @@ void SelectionHelper::invert(SPDesktop *dt)
void SelectionHelper::invertAllInAll(SPDesktop *dt)
{
if (tools_isactive(dt, TOOLS_NODES)) {
- InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
+ NodeTool *nt = static_cast<NodeTool*>(dt->event_context);
nt->_selected_nodes->invertSelection();
} else {
sp_edit_invert_in_all_layers(dt);
@@ -231,7 +232,7 @@ void SelectionHelper::reverse(SPDesktop *dt)
{
// TODO make this a virtual method of event context!
if (tools_isactive(dt, TOOLS_NODES)) {
- InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
+ NodeTool *nt = static_cast<NodeTool*>(dt->event_context);
nt->_multipath->reverseSubpaths();
} else {
sp_selected_path_reverse(dt);
@@ -240,13 +241,13 @@ void SelectionHelper::reverse(SPDesktop *dt)
void SelectionHelper::selectNext(SPDesktop *dt)
{
- SPEventContext *ec = dt->event_context;
+ Inkscape::UI::Tools::ToolBase *ec = dt->event_context;
if (tools_isactive(dt, TOOLS_NODES)) {
- InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
+ NodeTool *nt = static_cast<NodeTool*>(dt->event_context);
nt->_multipath->shiftSelection(1);
} else if (tools_isactive(dt, TOOLS_GRADIENT)
&& ec->_grdrag->isNonEmpty()) {
- sp_gradient_context_select_next(ec);
+ Inkscape::UI::Tools::sp_gradient_context_select_next(ec);
} else {
sp_selection_item_next(dt);
}
@@ -254,13 +255,13 @@ void SelectionHelper::selectNext(SPDesktop *dt)
void SelectionHelper::selectPrev(SPDesktop *dt)
{
- SPEventContext *ec = dt->event_context;
+ Inkscape::UI::Tools::ToolBase *ec = dt->event_context;
if (tools_isactive(dt, TOOLS_NODES)) {
- InkNodeTool *nt = static_cast<InkNodeTool*>(dt->event_context);
+ NodeTool *nt = static_cast<NodeTool*>(dt->event_context);
nt->_multipath->shiftSelection(-1);
} else if (tools_isactive(dt, TOOLS_GRADIENT)
&& ec->_grdrag->isNonEmpty()) {
- sp_gradient_context_select_prev(ec);
+ Inkscape::UI::Tools::sp_gradient_context_select_prev(ec);
} else {
sp_selection_item_prev(dt);
}
@@ -388,7 +389,7 @@ void sp_selection_delete(SPDesktop *desktop)
}
if (tools_isactive(desktop, TOOLS_TEXT))
- if (sp_text_delete_selection(desktop->event_context)) {
+ if (Inkscape::UI::Tools::sp_text_delete_selection(desktop->event_context)) {
DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_CONTEXT_TEXT,
_("Delete text"));
return;
@@ -1471,7 +1472,7 @@ void sp_selection_apply_affine(Inkscape::Selection *selection, Geom::Affine cons
// If we're moving a connector, we want to detach it
// from shapes that aren't part of the selection, but
// leave it attached if they are
- if (cc_item_is_connector(item)) {
+ if (Inkscape::UI::Tools::cc_item_is_connector(item)) {
SPItem *attItem[2];
SP_PATH(item)->connEndPair.getAttachedItems(attItem);
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index ed0fd3a08..f961e309d 100644
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
@@ -31,7 +31,7 @@
#include "knot.h"
#include "snap.h"
#include "selection.h"
-#include "select-context.h"
+#include "ui/tools/select-tool.h"
#include "sp-item.h"
#include "sp-item-transform.h"
#include "seltrans-handles.h"
@@ -66,7 +66,7 @@ static gboolean sp_sel_trans_handle_event(SPKnot *knot, GdkEvent *event, gpointe
case GDK_MOTION_NOTIFY:
break;
case GDK_KEY_PRESS:
- if (get_group0_keyval (&event->key) == GDK_KEY_space) {
+ if (Inkscape::UI::Tools::get_group0_keyval (&event->key) == GDK_KEY_space) {
/* stamping mode: both mode(show content and outline) operation with knot */
if (!SP_KNOT_IS_GRABBED(knot)) {
return FALSE;
diff --git a/src/shortcuts.cpp b/src/shortcuts.cpp
index 231e33e4a..1e43c98c6 100644
--- a/src/shortcuts.cpp
+++ b/src/shortcuts.cpp
@@ -43,7 +43,7 @@
#include "xml/repr.h"
#include "document.h"
#include "preferences.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "inkscape.h"
#include "desktop.h"
#include "path-prefix.h"
@@ -121,7 +121,7 @@ unsigned int sp_gdkmodifier_to_shortcut(guint accel_key, Gdk::ModifierType gdkmo
event.state = gdkmodifier;
event.keyval = accel_key;
event.hardware_keycode = hardware_keycode;
- guint keyval = get_group0_keyval (&event);
+ guint keyval = Inkscape::UI::Tools::get_group0_keyval (&event);
shortcut = accel_key |
( (gdkmodifier & GDK_SHIFT_MASK) || ( accel_key != keyval) ?
diff --git a/src/snap.cpp b/src/snap.cpp
index 15f24ef53..ecf799cdc 100644
--- a/src/snap.cpp
+++ b/src/snap.cpp
@@ -32,7 +32,7 @@
#include "selection.h"
#include "sp-guide.h"
#include "preferences.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "util/mathfns.h"
using std::vector;
using Inkscape::Util::round_to_upper_multiple_plus;
diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp
index fee320e90..0cadb4345 100644
--- a/src/sp-flowtext.cpp
+++ b/src/sp-flowtext.cpp
@@ -297,7 +297,7 @@ gchar* SPFlowtext::description() const {
int const nChars = layout.iteratorToCharIndex(layout.end());
char const *trunc = (layout.inputTruncated()) ? _(" [truncated]") : "";
- return g_strdup_printf(ngettext(_("(%d character%s)"), _("(%d characters%s)"), nChars), nChars, trunc);
+ return g_strdup_printf(ngettext("(%d character%s)", "(%d characters%s)", nChars), nChars, trunc);
}
void SPFlowtext::snappoints(std::vector<Inkscape::SnapCandidatePoint> &p, Inkscape::SnapPreferences const *snapprefs) const {
diff --git a/src/sp-item-group.h b/src/sp-item-group.h
index deb80a641..2004a72b8 100644
--- a/src/sp-item-group.h
+++ b/src/sp-item-group.h
@@ -55,7 +55,7 @@ public:
void scaleChildItemsRec(Geom::Scale const &sc, Geom::Point const &p);
gint getItemCount() const;
- void _showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags);
+ virtual void _showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags);
private:
void _updateLayerMode(unsigned int display_key=0);
diff --git a/src/sp-item-rm-unsatisfied-cns.cpp b/src/sp-item-rm-unsatisfied-cns.cpp
index 8fb171c08..7a712b083 100644
--- a/src/sp-item-rm-unsatisfied-cns.cpp
+++ b/src/sp-item-rm-unsatisfied-cns.cpp
@@ -24,10 +24,12 @@ void sp_item_rm_unsatisfied_cns(SPItem &item)
g_assert( snappoint_ix < int(snappoints.size()) );
if (!Geom::are_near(cn.g->getDistanceFrom(snappoints[snappoint_ix].getPoint()), 0, 1e-2)) {
+
remove_last(cn.g->attached_items, SPGuideAttachment(&item, cn.snappoint_ix));
+
g_assert( i < item.constraints.size() );
- vector<SPGuideConstraint>::iterator const ei(&item.constraints[i]);
- item.constraints.erase(ei);
+
+ item.constraints.erase(item.constraints.begin() + i);
}
}
}
diff --git a/src/sp-path.cpp b/src/sp-path.cpp
index 563c5b326..cbb61b0f6 100644
--- a/src/sp-path.cpp
+++ b/src/sp-path.cpp
@@ -43,7 +43,7 @@
#include "desktop.h"
#include "desktop-handles.h"
#include "desktop-style.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "inkscape.h"
#include "style.h"
#include "message-stack.h"
diff --git a/src/sp-switch.cpp b/src/sp-switch.cpp
index 5c88d7af8..b4841c0d0 100644
--- a/src/sp-switch.cpp
+++ b/src/sp-switch.cpp
@@ -40,6 +40,7 @@ SPSwitch::SPSwitch() : SPGroup() {
}
SPSwitch::~SPSwitch() {
+ _releaseLastItem(_cached_item);
}
SPObject *SPSwitch::_evaluateFirst() {
diff --git a/src/sp-switch.h b/src/sp-switch.h
index 3ccc9e3b7..c35982860 100644
--- a/src/sp-switch.h
+++ b/src/sp-switch.h
@@ -28,7 +28,7 @@ public:
void resetChildEvaluated() { _reevaluate(); }
GSList *_childList(bool add_ref, SPObject::Action action);
- void _showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags);
+ virtual void _showChildren (Inkscape::Drawing &drawing, Inkscape::DrawingItem *ai, unsigned int key, unsigned int flags);
SPObject *_evaluateFirst();
void _reevaluate(bool add_to_arena = false);
diff --git a/src/splivarot.cpp b/src/splivarot.cpp
index ad40178fb..7bf556aa1 100644
--- a/src/splivarot.cpp
+++ b/src/splivarot.cpp
@@ -338,6 +338,8 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool
return;
}
+ g_assert(il != NULL);
+
if (g_slist_length(il) > 2) {
if (bop == bool_op_diff || bop == bool_op_cut || bop == bool_op_slice ) {
boolop_display_error_message(desktop, _("Select <b>exactly 2 paths</b> to perform difference, division, or path cut."));
@@ -352,8 +354,8 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool
if (bop == bool_op_diff || bop == bool_op_cut || bop == bool_op_slice) {
// check in the tree to find which element of the selection list is topmost (for 2-operand commands only)
- Inkscape::XML::Node *a = reinterpret_cast<SPObject *>(il->data)->getRepr();
- Inkscape::XML::Node *b = reinterpret_cast<SPObject *>(il->next->data)->getRepr();
+ Inkscape::XML::Node *a = SP_OBJECT(il->data)->getRepr();
+ Inkscape::XML::Node *b = SP_OBJECT(il->next->data)->getRepr();
if (a == NULL || b == NULL) {
boolop_display_error_message(desktop, _("Unable to determine the <b>z-order</b> of the objects selected for difference, XOR, division, or path cut."));
@@ -393,6 +395,7 @@ sp_selected_path_boolop(Inkscape::Selection *selection, SPDesktop *desktop, bool
}
il = g_slist_copy(il);
+ g_assert(il != NULL);
// first check if all the input objects have shapes
// otherwise bail out
@@ -1160,7 +1163,7 @@ sp_selected_path_outline(SPDesktop *desktop)
items != NULL;
items = items->next) {
- SPItem *item = (SPItem *) items->data;
+ SPItem *item = SP_ITEM(items->data);
if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item))
continue;
@@ -1177,6 +1180,8 @@ sp_selected_path_outline(SPDesktop *desktop)
continue;
}
+ g_assert(curve != NULL);
+
if (curve->get_pathvector().empty()) {
continue;
}
@@ -1595,6 +1600,8 @@ void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool
}
}
+ g_assert(curve != NULL);
+
Geom::Affine const transform(item->transform);
item->doWriteTransform(item->getRepr(), Geom::identity());
@@ -1610,9 +1617,6 @@ void sp_selected_path_create_offset_object(SPDesktop *desktop, int expand, bool
float o_width = 0;
{
- SPStyle *i_style = item->style;
-
- o_width = i_style->stroke_width.computed;
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
o_width = prefs->getDouble("/options/defaultoffsetwidth/value", 1.0, "px");
@@ -1774,7 +1778,7 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset)
items != NULL;
items = items->next) {
- SPItem *item = (SPItem *) items->data;
+ SPItem *item = SP_ITEM(items->data);
if (!SP_IS_SHAPE(item) && !SP_IS_TEXT(item))
continue;
@@ -1791,6 +1795,9 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset)
continue;
}
+ // We've now checked that there is a curve for this item
+ g_assert(curve != NULL);
+
Geom::Affine const transform(item->transform);
item->doWriteTransform(item->getRepr(), Geom::identity());
@@ -1805,9 +1812,6 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset)
{
SPStyle *i_style = item->style;
int jointype = i_style->stroke_linejoin.value;
- //int captype = i_style->stroke_linecap.value;
-
- o_width = i_style->stroke_width.computed;
switch (jointype) {
case SP_STROKE_LINEJOIN_MITER:
@@ -1821,18 +1825,6 @@ sp_selected_path_do_offset(SPDesktop *desktop, bool expand, double prefOffset)
break;
}
- /*switch (captype) {
- case SP_STROKE_LINECAP_SQUARE:
- o_butt = butt_square;
- break;
- case SP_STROKE_LINECAP_ROUND:
- o_butt = butt_round;
- break;
- default:
- o_butt = butt_straight;
- break;
- }*/
-
o_width = prefOffset;
if (o_width < 0.1)
diff --git a/src/tool-factory.h b/src/tool-factory.h
index d8aeb5f04..726706732 100644
--- a/src/tool-factory.h
+++ b/src/tool-factory.h
@@ -1,5 +1,5 @@
/** @file
- * Factory for SPEventContext tree
+ * Factory for ToolBase tree
*//*
* Authors:
* Markus Engel
@@ -13,8 +13,17 @@
#include "factory.h"
-class SPEventContext;
-typedef Singleton< Factory<SPEventContext> > ToolFactory;
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class ToolBase;
+
+}
+}
+}
+
+typedef Singleton< Factory<Inkscape::UI::Tools::ToolBase> > ToolFactory;
#endif
diff --git a/src/tools-switch.cpp b/src/tools-switch.cpp
index 5f54ad15a..fe9d32f43 100644
--- a/src/tools-switch.cpp
+++ b/src/tools-switch.cpp
@@ -25,36 +25,36 @@
#include <xml/repr.h>
-#include "select-context.h"
-#include "ui/tool/node-tool.h"
-#include "tweak-context.h"
-#include "spray-context.h"
+#include "ui/tools/select-tool.h"
+#include "ui/tools/node-tool.h"
+#include "ui/tools/tweak-tool.h"
+#include "ui/tools/spray-tool.h"
#include "sp-path.h"
-#include "rect-context.h"
+#include "ui/tools/rect-tool.h"
#include "sp-rect.h"
-#include "box3d-context.h"
+#include "ui/tools/box3d-tool.h"
#include "box3d.h"
-#include "arc-context.h"
+#include "ui/tools/arc-tool.h"
#include "sp-ellipse.h"
-#include "star-context.h"
+#include "ui/tools/tweak-tool.h"
#include "sp-star.h"
-#include "spiral-context.h"
+#include "ui/tools/spiral-tool.h"
#include "sp-spiral.h"
-#include "dyna-draw-context.h"
-#include "eraser-context.h"
-#include "pen-context.h"
-#include "pencil-context.h"
-#include "lpe-tool-context.h"
-#include "text-context.h"
+#include "ui/tools/calligraphic-tool.h"
+#include "ui/tools/eraser-tool.h"
+#include "ui/tools/pen-tool.h"
+#include "ui/tools/pencil-tool.h"
+#include "ui/tools/lpe-tool.h"
+#include "ui/tools/text-tool.h"
#include "sp-text.h"
#include "sp-flowtext.h"
-#include "gradient-context.h"
-#include "mesh-context.h"
-#include "zoom-context.h"
-#include "measure-context.h"
-#include "dropper-context.h"
-#include "connector-context.h"
-#include "flood-context.h"
+#include "ui/tools/gradient-tool.h"
+#include "ui/tools/mesh-tool.h"
+#include "ui/tools/zoom-tool.h"
+#include "ui/tools/measure-tool.h"
+#include "ui/tools/dropper-tool.h"
+#include "ui/tools/connector-tool.h"
+#include "ui/tools/flood-tool.h"
#include "sp-offset.h"
#include "message-context.h"
@@ -169,7 +169,7 @@ void tools_switch_by_item(SPDesktop *dt, SPItem *item, Geom::Point const p)
} else if (SP_IS_SPIRAL(item)) {
tools_switch(dt, TOOLS_SHAPES_SPIRAL);
} else if (SP_IS_PATH(item)) {
- if (cc_item_is_connector(item)) {
+ if (Inkscape::UI::Tools::cc_item_is_connector(item)) {
tools_switch(dt, TOOLS_CONNECTOR);
}
else {
diff --git a/src/trace/siox.cpp b/src/trace/siox.cpp
index 92992d440..0706cfed1 100644
--- a/src/trace/siox.cpp
+++ b/src/trace/siox.cpp
@@ -11,6 +11,7 @@
#include <stdarg.h>
#include <map>
#include <algorithm>
+#include <cstdlib>
namespace org
diff --git a/src/ui/CMakeLists.txt b/src/ui/CMakeLists.txt
index 24324c874..c3e406e3f 100644
--- a/src/ui/CMakeLists.txt
+++ b/src/ui/CMakeLists.txt
@@ -14,13 +14,38 @@ set(ui_SRC
tool/manipulator.cpp
tool/modifier-tracker.cpp
tool/multi-path-manipulator.cpp
- tool/node-tool.cpp
tool/node.cpp
tool/path-manipulator.cpp
tool/selectable-control-point.cpp
tool/selector.cpp
tool/transform-handle-set.cpp
+ tools/arc-tool.cpp
+ tools/box3d-tool.cpp
+ tools/calligraphic-tool.cpp
+ tools/connector-tool.cpp
+ tools/dropper-tool.cpp
+ tools/dynamic-base.cpp
+ tools/eraser-tool.cpp
+ tools/flood-tool.cpp
+ tools/freehand-base.cpp
+ tools/gradient-tool.cpp
+ tools/lpe-tool.cpp
+ tools/measure-tool.cpp
+ tools/mesh-tool.cpp
+ tools/node-tool.cpp
+ tools/pencil-tool.cpp
+ tools/pen-tool.cpp
+ tools/rect-tool.cpp
+ tools/select-tool.cpp
+ tools/spiral-tool.cpp
+ tools/spray-tool.cpp
+ tools/star-tool.cpp
+ tools/text-tool.cpp
+ tools/tool-base.cpp
+ tools/tweak-tool.cpp
+ tools/zoom-tool.cpp
+
dialog/aboutbox.cpp
dialog/align-and-distribute.cpp
dialog/calligraphic-profile-rename.cpp
@@ -200,7 +225,6 @@ set(ui_SRC
tool/manipulator.h
tool/modifier-tracker.h
tool/multi-path-manipulator.h
- tool/node-tool.h
tool/node-types.h
tool/node.h
tool/path-manipulator.h
@@ -209,6 +233,32 @@ set(ui_SRC
tool/shape-record.h
tool/transform-handle-set.h
+ tools/arc-tool.h
+ tools/box3d-tool.h
+ tools/calligraphic-tool.h
+ tools/connector-tool.h
+ tools/dropper-tool.h
+ tools/dynamic-base.h
+ tools/eraser-tool.h
+ tools/flood-tool.h
+ tools/freehand-base.h
+ tools/gradient-tool.h
+ tools/lpe-tool.h
+ tools/measure-tool.h
+ tools/mesh-tool.h
+ tools/node-tool.h
+ tools/pencil-tool.h
+ tools/pen-tool.h
+ tools/rect-tool.h
+ tools/select-tool.h
+ tools/spiral-tool.h
+ tools/spray-tool.h
+ tools/star-tool.h
+ tools/text-tool.h
+ tools/tool-base.h
+ tools/tweak-tool.h
+ tools/zoom-tool.h
+
widget/attr-widget.h
widget/button.h
widget/color-picker.h
diff --git a/src/ui/clipboard.cpp b/src/ui/clipboard.cpp
index da6fed86b..8e2502545 100644
--- a/src/ui/clipboard.cpp
+++ b/src/ui/clipboard.cpp
@@ -44,7 +44,7 @@
#include "selection.h"
#include "message-stack.h"
#include "context-fns.h"
-#include "dropper-context.h" // used in copy()
+#include "ui/tools/dropper-tool.h" // used in copy()
#include "style.h"
#include "extension/db.h" // extension database
#include "extension/input.h"
@@ -74,7 +74,7 @@
#include "live_effects/parameter/path.h"
#include "svg/svg.h" // for sp_svg_transform_write, used in _copySelection
#include "svg/css-ostringstream.h" // used in copy
-#include "text-context.h"
+#include "ui/tools/text-tool.h"
#include "text-editing.h"
#include "tools-switch.h"
#include "path-chemistry.h"
@@ -247,13 +247,13 @@ void ClipboardManagerImpl::copy(SPDesktop *desktop)
// not the object that holds it; also copy the style at cursor into
if (tools_isactive(desktop, TOOLS_TEXT)) {
_discardInternalClipboard();
- Glib::ustring selected_text = sp_text_get_selected_text(desktop->event_context);
+ Glib::ustring selected_text = Inkscape::UI::Tools::sp_text_get_selected_text(desktop->event_context);
_clipboard->set_text(selected_text);
if (_text_style) {
sp_repr_css_attr_unref(_text_style);
_text_style = NULL;
}
- _text_style = sp_text_get_style_at_cursor(desktop->event_context);
+ _text_style = Inkscape::UI::Tools::sp_text_get_style_at_cursor(desktop->event_context);
return;
}
@@ -908,7 +908,7 @@ bool ClipboardManagerImpl::_pasteText(SPDesktop *desktop)
// if the text editing tool is active, paste the text into the active text object
if (tools_isactive(desktop, TOOLS_TEXT)) {
- return sp_text_paste_inline(desktop->event_context);
+ return Inkscape::UI::Tools::sp_text_paste_inline(desktop->event_context);
}
// try to parse the text as a color and, if successful, apply it as the current style
diff --git a/src/ui/dialog/align-and-distribute.cpp b/src/ui/dialog/align-and-distribute.cpp
index 38f10c59c..6b4aeebb9 100644
--- a/src/ui/dialog/align-and-distribute.cpp
+++ b/src/ui/dialog/align-and-distribute.cpp
@@ -40,7 +40,7 @@
#include "text-editing.h"
#include "tools-switch.h"
#include "ui/icon-names.h"
-#include "ui/tool/node-tool.h"
+#include "ui/tools/node-tool.h"
#include "ui/tool/multi-path-manipulator.h"
#include "util/glib-list-iterators.h"
#include "verbs.h"
@@ -374,13 +374,13 @@ private :
return;
}
- SPEventContext *event_context = _dialog.getDesktop()->getEventContext();
+ Inkscape::UI::Tools::ToolBase *event_context = _dialog.getDesktop()->getEventContext();
if (!INK_IS_NODE_TOOL(event_context)) {
return;
}
- InkNodeTool *nt = INK_NODE_TOOL(event_context);
+ Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(event_context);
if (_distribute) {
nt->_multipath->distributeNodes(_orientation);
@@ -829,7 +829,7 @@ private :
-static void on_tool_changed(Inkscape::Application */*inkscape*/, SPEventContext */*context*/, AlignAndDistribute *daad)
+static void on_tool_changed(Inkscape::Application */*inkscape*/, Inkscape::UI::Tools::ToolBase */*context*/, AlignAndDistribute *daad)
{
SPDesktop *desktop = SP_ACTIVE_DESKTOP;
if (desktop && desktop->getEventContext())
diff --git a/src/ui/dialog/dialog.cpp b/src/ui/dialog/dialog.cpp
index f27d344fa..3cc3f3d88 100644
--- a/src/ui/dialog/dialog.cpp
+++ b/src/ui/dialog/dialog.cpp
@@ -23,7 +23,7 @@
#include <gdk/gdkkeysyms.h>
#include "inkscape.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "modifier-fns.h"
@@ -270,7 +270,7 @@ bool Dialog::_onEvent(GdkEvent *event)
switch (event->type) {
case GDK_KEY_PRESS: {
- switch (get_group0_keyval (&event->key)) {
+ switch (Inkscape::UI::Tools::get_group0_keyval (&event->key)) {
case GDK_KEY_Escape: {
_defocus();
ret = true;
@@ -300,7 +300,7 @@ bool Dialog::_onEvent(GdkEvent *event)
bool Dialog::_onKeyPress(GdkEventKey *event)
{
unsigned int shortcut;
- shortcut = get_group0_keyval(event) |
+ shortcut = Inkscape::UI::Tools::get_group0_keyval(event) |
( event->state & GDK_SHIFT_MASK ?
SP_SHORTCUT_SHIFT_MASK : 0 ) |
( event->state & GDK_CONTROL_MASK ?
diff --git a/src/ui/dialog/guides.cpp b/src/ui/dialog/guides.cpp
index 5dfafa78d..e84f25733 100644
--- a/src/ui/dialog/guides.cpp
+++ b/src/ui/dialog/guides.cpp
@@ -25,7 +25,7 @@
#include "sp-guide.h"
#include "sp-namedview.h"
#include "desktop-handles.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "widgets/desktop-widget.h"
#include <glibmm/i18n.h>
#include "dialogs/dialog-events.h"
diff --git a/src/ui/dialog/layer-properties.cpp b/src/ui/dialog/layer-properties.cpp
index b9e5d4883..f19828b1f 100644
--- a/src/ui/dialog/layer-properties.cpp
+++ b/src/ui/dialog/layer-properties.cpp
@@ -31,7 +31,7 @@
#include "selection-chemistry.h"
#include "ui/icon-names.h"
#include "ui/widget/imagetoggler.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
namespace Inkscape {
namespace UI {
@@ -318,7 +318,7 @@ SPObject* LayerPropertiesDialog::_selectedLayer()
bool LayerPropertiesDialog::_handleKeyEvent(GdkEventKey *event)
{
- switch (get_group0_keyval(event)) {
+ switch (Inkscape::UI::Tools::get_group0_keyval(event)) {
case GDK_KEY_Return:
case GDK_KEY_KP_Enter: {
_strategy->perform(*this);
diff --git a/src/ui/dialog/layers.cpp b/src/ui/dialog/layers.cpp
index c01903f94..12fdf6b7d 100644
--- a/src/ui/dialog/layers.cpp
+++ b/src/ui/dialog/layers.cpp
@@ -41,7 +41,7 @@
#include "widgets/icon.h"
#include "xml/repr.h"
#include "sp-root.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "selection-chemistry.h"
//#define DUMP_LAYERS 1
@@ -544,7 +544,7 @@ void LayersPanel::_toggled( Glib::ustring const& str, int targetCol )
bool LayersPanel::_handleKeyEvent(GdkEventKey *event)
{
- switch (get_group0_keyval(event)) {
+ switch (Inkscape::UI::Tools::get_group0_keyval(event)) {
case GDK_KEY_Return:
case GDK_KEY_KP_Enter:
case GDK_KEY_F2: {
diff --git a/src/ui/dialog/spellcheck.cpp b/src/ui/dialog/spellcheck.cpp
index 45106755c..00bd445bf 100644
--- a/src/ui/dialog/spellcheck.cpp
+++ b/src/ui/dialog/spellcheck.cpp
@@ -24,7 +24,7 @@
#include "desktop.h"
#include "desktop-handles.h"
#include "tools-switch.h"
-#include "text-context.h"
+#include "ui/tools/text-tool.h"
#include "interface.h"
#include "preferences.h"
#include "sp-text.h"
diff --git a/src/ui/dialog/xml-tree.cpp b/src/ui/dialog/xml-tree.cpp
index a537b7fca..0e1e9f7a6 100644
--- a/src/ui/dialog/xml-tree.cpp
+++ b/src/ui/dialog/xml-tree.cpp
@@ -27,7 +27,7 @@
#include "dialogs/dialog-events.h"
#include "document.h"
#include "document-undo.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "helper/window.h"
#include "inkscape.h"
#include "interface.h"
@@ -328,7 +328,7 @@ void XmlTree::attr_reset_context(gint attr)
bool XmlTree::sp_xml_tree_key_press(GdkEventKey *event)
{
- unsigned int shortcut = get_group0_keyval (event) |
+ unsigned int shortcut = Inkscape::UI::Tools::get_group0_keyval (event) |
( event->state & GDK_SHIFT_MASK ?
SP_SHORTCUT_SHIFT_MASK : 0 ) |
( event->state & GDK_CONTROL_MASK ?
@@ -842,7 +842,7 @@ void XmlTree::on_document_uri_set(gchar const * /*uri*/, SPDocument * /*document
gboolean XmlTree::quit_on_esc (GtkWidget *w, GdkEventKey *event, GObject */*tbl*/)
{
- switch (get_group0_keyval (event)) {
+ switch (Inkscape::UI::Tools::get_group0_keyval (event)) {
case GDK_KEY_Escape: // defocus
gtk_widget_destroy(w);
return TRUE;
diff --git a/src/ui/tool/Makefile_insert b/src/ui/tool/Makefile_insert
index 2a72dd645..f46f48b72 100644
--- a/src/ui/tool/Makefile_insert
+++ b/src/ui/tool/Makefile_insert
@@ -19,8 +19,6 @@ ink_common_sources += \
ui/tool/node.cpp \
ui/tool/node.h \
ui/tool/node-types.h \
- ui/tool/node-tool.cpp \
- ui/tool/node-tool.h \
ui/tool/path-manipulator.cpp \
ui/tool/path-manipulator.h \
ui/tool/selectable-control-point.cpp \
diff --git a/src/ui/tool/control-point-selection.cpp b/src/ui/tool/control-point-selection.cpp
index 1c42c5d90..b5ee0a597 100644
--- a/src/ui/tool/control-point-selection.cpp
+++ b/src/ui/tool/control-point-selection.cpp
@@ -582,7 +582,7 @@ void ControlPointSelection::_commitHandlesTransform(CommitEvent ce)
signal_commit.emit(ce);
}
-bool ControlPointSelection::event(SPEventContext * /*event_context*/, GdkEvent *event)
+bool ControlPointSelection::event(Inkscape::UI::Tools::ToolBase * /*event_context*/, GdkEvent *event)
{
// implement generic event handling that should apply for all control point selections here;
// for example, keyboard moves and transformations. This way this functionality doesn't need
diff --git a/src/ui/tool/control-point-selection.h b/src/ui/tool/control-point-selection.h
index f5eb47026..a087e0455 100644
--- a/src/ui/tool/control-point-selection.h
+++ b/src/ui/tool/control-point-selection.h
@@ -90,7 +90,7 @@ public:
void invertSelection();
void spatialGrow(SelectableControlPoint *origin, int dir);
- virtual bool event(SPEventContext *, GdkEvent *);
+ virtual bool event(Inkscape::UI::Tools::ToolBase *, GdkEvent *);
void transform(Geom::Affine const &m);
void align(Geom::Dim2 d);
diff --git a/src/ui/tool/control-point.cpp b/src/ui/tool/control-point.cpp
index 069dcc67b..e98c7b2a2 100644
--- a/src/ui/tool/control-point.cpp
+++ b/src/ui/tool/control-point.cpp
@@ -14,7 +14,7 @@
#include "desktop-handles.h"
#include "display/sp-canvas.h"
#include "display/snap-indicator.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "message-context.h"
#include "preferences.h"
#include "snap-preferences.h"
@@ -218,7 +218,7 @@ int ControlPoint::_event_handler(SPCanvasItem */*item*/, GdkEvent *event, Contro
}
// main event callback, which emits all other callbacks.
-bool ControlPoint::_eventHandler(SPEventContext *event_context, GdkEvent *event)
+bool ControlPoint::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEvent *event)
{
// NOTE the static variables below are shared for all points!
// TODO handle clicks and drags from other buttons too
@@ -310,7 +310,7 @@ bool ControlPoint::_eventHandler(SPEventContext *event_context, GdkEvent *event)
_desktop->set_coordinate_status(_position);
sp_event_context_snap_delay_handler(event_context, NULL,
(gpointer) this, &event->motion,
- DelayedSnapEvent::CONTROL_POINT_HANDLER);
+ Inkscape::UI::Tools::DelayedSnapEvent::CONTROL_POINT_HANDLER);
}
return true;
}
@@ -375,7 +375,7 @@ bool ControlPoint::_eventHandler(SPEventContext *event_context, GdkEvent *event)
// update tips on modifier state change
// TODO add ESC keybinding as drag cancel
case GDK_KEY_PRESS:
- switch (get_group0_keyval(&event->key))
+ switch (Inkscape::UI::Tools::get_group0_keyval(&event->key))
{
case GDK_KEY_Escape: {
// ignore Escape if this is not a drag
diff --git a/src/ui/tool/control-point.h b/src/ui/tool/control-point.h
index 30efe8a27..b3ed9545e 100644
--- a/src/ui/tool/control-point.h
+++ b/src/ui/tool/control-point.h
@@ -23,7 +23,16 @@
#include "enums.h"
class SPDesktop;
-class SPEventContext;
+
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class ToolBase;
+
+}
+}
+}
namespace Inkscape {
namespace UI {
@@ -181,7 +190,7 @@ public:
static Glib::ustring format_tip(char const *format, ...) G_GNUC_PRINTF(1,2);
// temporarily public, until snap delay is refactored a little
- virtual bool _eventHandler(SPEventContext *event_context, GdkEvent *event);
+ virtual bool _eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEvent *event);
SPDesktop *const _desktop; ///< The desktop this control point resides on.
protected:
diff --git a/src/ui/tool/curve-drag-point.cpp b/src/ui/tool/curve-drag-point.cpp
index b83ce1b3c..4ca736f80 100644
--- a/src/ui/tool/curve-drag-point.cpp
+++ b/src/ui/tool/curve-drag-point.cpp
@@ -32,7 +32,7 @@ CurveDragPoint::CurveDragPoint(PathManipulator &pm) :
setVisible(false);
}
-bool CurveDragPoint::_eventHandler(SPEventContext *event_context, GdkEvent *event)
+bool CurveDragPoint::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEvent *event)
{
// do not process any events when the manipulator is empty
if (_pm.empty()) {
diff --git a/src/ui/tool/curve-drag-point.h b/src/ui/tool/curve-drag-point.h
index 73e4cd969..ea83978e0 100644
--- a/src/ui/tool/curve-drag-point.h
+++ b/src/ui/tool/curve-drag-point.h
@@ -35,7 +35,7 @@ public:
void setSize(double sz) { _setSize(sz); }
void setTimeValue(double t) { _t = t; }
void setIterator(NodeList::iterator i) { first = i; }
- virtual bool _eventHandler(SPEventContext *event_context, GdkEvent *event);
+ virtual bool _eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEvent *event);
protected:
diff --git a/src/ui/tool/manipulator.h b/src/ui/tool/manipulator.h
index ffed370d3..07e01a656 100644
--- a/src/ui/tool/manipulator.h
+++ b/src/ui/tool/manipulator.h
@@ -18,7 +18,7 @@
#include <glib.h>
#include <gdk/gdk.h>
#include <boost/shared_ptr.hpp>
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
class SPDesktop;
namespace Inkscape {
@@ -40,7 +40,7 @@ public:
virtual ~Manipulator() {}
/// Handle input event. Returns true if handled.
- virtual bool event(SPEventContext *, GdkEvent *)=0;
+ virtual bool event(Inkscape::UI::Tools::ToolBase *, GdkEvent *)=0;
SPDesktop *const _desktop;
};
@@ -145,7 +145,7 @@ public:
}
}
- virtual bool event(SPEventContext *event_context, GdkEvent *event) {
+ virtual bool event(Inkscape::UI::Tools::ToolBase *event_context, GdkEvent *event) {
for (typename MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
if ((*i).second->event(event_context, event)) return true;
}
diff --git a/src/ui/tool/multi-path-manipulator.cpp b/src/ui/tool/multi-path-manipulator.cpp
index 5d5ea2adc..519c4ac6a 100644
--- a/src/ui/tool/multi-path-manipulator.cpp
+++ b/src/ui/tool/multi-path-manipulator.cpp
@@ -557,7 +557,7 @@ void MultiPathManipulator::updateHandles()
invokeForAll(&PathManipulator::updateHandles);
}
-bool MultiPathManipulator::event(SPEventContext *event_context, GdkEvent *event)
+bool MultiPathManipulator::event(Inkscape::UI::Tools::ToolBase *event_context, GdkEvent *event)
{
_tracker.event(event);
guint key = 0;
diff --git a/src/ui/tool/multi-path-manipulator.h b/src/ui/tool/multi-path-manipulator.h
index 54a9b5753..1328372c6 100644
--- a/src/ui/tool/multi-path-manipulator.h
+++ b/src/ui/tool/multi-path-manipulator.h
@@ -36,7 +36,7 @@ class MultiPathManipulator : public PointManipulator {
public:
MultiPathManipulator(PathSharedData &data, sigc::connection &chg);
virtual ~MultiPathManipulator();
- virtual bool event(SPEventContext *, GdkEvent *event);
+ virtual bool event(Inkscape::UI::Tools::ToolBase *, GdkEvent *event);
bool empty() { return _mmap.empty(); }
unsigned size() { return _mmap.empty(); }
diff --git a/src/ui/tool/node.cpp b/src/ui/tool/node.cpp
index 76ec68c3e..e246bf997 100644
--- a/src/ui/tool/node.cpp
+++ b/src/ui/tool/node.cpp
@@ -250,7 +250,7 @@ char const *Handle::handle_type_to_localized_string(NodeType type)
}
}
-bool Handle::_eventHandler(SPEventContext *event_context, GdkEvent *event)
+bool Handle::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEvent *event)
{
switch (event->type)
{
@@ -834,7 +834,7 @@ NodeType Node::parse_nodetype(char x)
}
}
-bool Node::_eventHandler(SPEventContext *event_context, GdkEvent *event)
+bool Node::_eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEvent *event)
{
int dir = 0;
diff --git a/src/ui/tool/node.h b/src/ui/tool/node.h
index 591dd8532..b874949f5 100644
--- a/src/ui/tool/node.h
+++ b/src/ui/tool/node.h
@@ -16,7 +16,13 @@
#include <iosfwd>
#include <stdexcept>
#include <cstddef>
+
+#if __cplusplus >= 201103L
+#include <functional>
+#else
#include <tr1/functional>
+#endif
+
#include <boost/enable_shared_from_this.hpp>
#include <boost/shared_ptr.hpp>
#include "ui/tool/selectable-control-point.h"
@@ -31,11 +37,13 @@ template <typename> class NodeIterator;
}
}
+#if __cplusplus < 201103L
namespace std {
namespace tr1 {
template <typename N> struct hash< Inkscape::UI::NodeIterator<N> >;
}
}
+#endif
namespace Inkscape {
namespace UI {
@@ -106,7 +114,7 @@ protected:
Handle(NodeSharedData const &data, Geom::Point const &initial_pos, Node *parent);
- virtual bool _eventHandler(SPEventContext *event_context, GdkEvent *event);
+ virtual bool _eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEvent *event);
virtual void dragged(Geom::Point &new_pos, GdkEventMotion *event);
virtual bool grabbed(GdkEventMotion *event);
virtual void ungrabbed(GdkEventButton *event);
@@ -217,7 +225,7 @@ public:
// temporarily public
/** Customized event handler to catch scroll events needed for selection grow/shrink. */
- virtual bool _eventHandler(SPEventContext *event_context, GdkEvent *event);
+ virtual bool _eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEvent *event);
Inkscape::SnapCandidatePoint snapCandidatePoint();
diff --git a/src/ui/tool/path-manipulator.cpp b/src/ui/tool/path-manipulator.cpp
index d12e2958b..ec58e2141 100644
--- a/src/ui/tool/path-manipulator.cpp
+++ b/src/ui/tool/path-manipulator.cpp
@@ -157,7 +157,7 @@ PathManipulator::~PathManipulator()
}
/** Handle motion events to update the position of the curve drag point. */
-bool PathManipulator::event(SPEventContext * /*event_context*/, GdkEvent *event)
+bool PathManipulator::event(Inkscape::UI::Tools::ToolBase * /*event_context*/, GdkEvent *event)
{
if (empty()) return false;
diff --git a/src/ui/tool/path-manipulator.h b/src/ui/tool/path-manipulator.h
index e01e8617f..7a13ce723 100644
--- a/src/ui/tool/path-manipulator.h
+++ b/src/ui/tool/path-manipulator.h
@@ -56,7 +56,7 @@ public:
PathManipulator(MultiPathManipulator &mpm, SPPath *path, Geom::Affine const &edit_trans,
guint32 outline_color, Glib::ustring lpe_key);
~PathManipulator();
- virtual bool event(SPEventContext *, GdkEvent *);
+ virtual bool event(Inkscape::UI::Tools::ToolBase *, GdkEvent *);
bool empty();
void writeXML();
diff --git a/src/ui/tool/selector.cpp b/src/ui/tool/selector.cpp
index 2b3ba837c..bdeacadc9 100644
--- a/src/ui/tool/selector.cpp
+++ b/src/ui/tool/selector.cpp
@@ -13,7 +13,7 @@
#include "desktop.h"
#include "desktop-handles.h"
#include "display/sodipodi-ctrlrect.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "preferences.h"
#include "ui/tool/event-utils.h"
#include "ui/tool/selector.h"
@@ -48,12 +48,12 @@ public:
SPDesktop *desktop() { return _desktop; }
- bool event(SPEventContext *ec, GdkEvent *e) {
+ bool event(Inkscape::UI::Tools::ToolBase *ec, GdkEvent *e) {
return _eventHandler(ec, e);
}
protected:
- virtual bool _eventHandler(SPEventContext *event_context, GdkEvent *event) {
+ virtual bool _eventHandler(Inkscape::UI::Tools::ToolBase *event_context, GdkEvent *event) {
if (event->type == GDK_KEY_PRESS && shortcut_key(event->key) == GDK_KEY_Escape &&
sp_canvas_item_is_visible(_rubber))
{
@@ -110,7 +110,7 @@ Selector::~Selector()
delete _dragger;
}
-bool Selector::event(SPEventContext *event_context, GdkEvent *event)
+bool Selector::event(Inkscape::UI::Tools::ToolBase *event_context, GdkEvent *event)
{
// The hidden control point will capture all events after it obtains the grab,
// but it relies on this function to initiate it. If we pass only first button
@@ -118,7 +118,7 @@ bool Selector::event(SPEventContext *event_context, GdkEvent *event)
switch (event->type) {
case GDK_BUTTON_PRESS:
// Do not pass button presses other than left button to the control point.
- // This way middle click and right click can be handled in SPEventContext.
+ // This way middle click and right click can be handled in ToolBase.
if (event->button.button == 1 && !event_context->space_panning) {
_dragger->setPosition(_desktop->w2d(event_point(event->motion)));
return _dragger->event(event_context, event);
diff --git a/src/ui/tool/selector.h b/src/ui/tool/selector.h
index 7e2759b69..dbe751ede 100644
--- a/src/ui/tool/selector.h
+++ b/src/ui/tool/selector.h
@@ -28,7 +28,7 @@ class Selector : public Manipulator {
public:
Selector(SPDesktop *d);
virtual ~Selector();
- virtual bool event(SPEventContext *, GdkEvent *);
+ virtual bool event(Inkscape::UI::Tools::ToolBase *, GdkEvent *);
sigc::signal<void, Geom::Rect const &, GdkEventButton*> signal_area;
sigc::signal<void, Geom::Point const &, GdkEventButton*> signal_point;
diff --git a/src/ui/tool/transform-handle-set.cpp b/src/ui/tool/transform-handle-set.cpp
index daed3a523..f21e1661a 100644
--- a/src/ui/tool/transform-handle-set.cpp
+++ b/src/ui/tool/transform-handle-set.cpp
@@ -26,7 +26,7 @@
#include "ui/tool/selectable-control-point.h"
#include "ui/tool/event-utils.h"
#include "ui/tool/transform-handle-set.h"
-#include "ui/tool/node-tool.h"
+#include "ui/tools/node-tool.h"
#include "ui/tool/node.h"
#include "seltrans.h"
@@ -128,7 +128,7 @@ bool TransformHandle::grabbed(GdkEventMotion *)
_setState(_state);
// Collect the snap-candidates, one for each selected node. These will be stored in the _snap_points vector.
- InkNodeTool *nt = INK_NODE_TOOL(_th._desktop->event_context);
+ Inkscape::UI::Tools::NodeTool *nt = INK_NODE_TOOL(_th._desktop->event_context);
//ControlPointSelection *selection = nt->_selected_nodes.get();
ControlPointSelection* selection = nt->_selected_nodes;
@@ -754,7 +754,7 @@ void TransformHandleSet::setBounds(Geom::Rect const &r, bool preserve_center)
}
}
-bool TransformHandleSet::event(SPEventContext *, GdkEvent*)
+bool TransformHandleSet::event(Inkscape::UI::Tools::ToolBase *, GdkEvent*)
{
return false;
}
diff --git a/src/ui/tool/transform-handle-set.h b/src/ui/tool/transform-handle-set.h
index ce949cbb2..54f81adf5 100644
--- a/src/ui/tool/transform-handle-set.h
+++ b/src/ui/tool/transform-handle-set.h
@@ -40,7 +40,7 @@ public:
TransformHandleSet(SPDesktop *d, SPCanvasGroup *th_group);
virtual ~TransformHandleSet();
- virtual bool event(SPEventContext *, GdkEvent *);
+ virtual bool event(Inkscape::UI::Tools::ToolBase *, GdkEvent *);
bool visible() const { return _visible; }
Mode mode() const { return _mode; }
diff --git a/src/ui/tools/Makefile_insert b/src/ui/tools/Makefile_insert
new file mode 100644
index 000000000..cd09a3230
--- /dev/null
+++ b/src/ui/tools/Makefile_insert
@@ -0,0 +1,28 @@
+## Makefile.am fragment sourced by src/Makefile.am.
+
+ink_common_sources += \
+ ui/tools/arc-tool.cpp ui/tools/arc-tool.h \
+ ui/tools/box3d-tool.cpp ui/tools/box3d-tool.h \
+ ui/tools/calligraphic-tool.cpp ui/tools/calligraphic-tool.h \
+ ui/tools/connector-tool.cpp ui/tools/connector-tool.h \
+ ui/tools/dropper-tool.cpp ui/tools/dropper-tool.h \
+ ui/tools/dynamic-base.cpp ui/tools/dynamic-base.h \
+ ui/tools/eraser-tool.cpp ui/tools/eraser-tool.h \
+ ui/tools/flood-tool.cpp ui/tools/flood-tool.h \
+ ui/tools/freehand-base.cpp ui/tools/freehand-base.h \
+ ui/tools/gradient-tool.cpp ui/tools/gradient-tool.h \
+ ui/tools/lpe-tool.cpp ui/tools/lpe-tool.h \
+ ui/tools/measure-tool.cpp ui/tools/measure-tool.h \
+ ui/tools/mesh-tool.cpp ui/tools/mesh-tool.h \
+ ui/tools/node-tool.cpp ui/tools/node-tool.h \
+ ui/tools/pen-tool.cpp ui/tools/pen-tool.h \
+ ui/tools/pencil-tool.cpp ui/tools/pencil-tool.h \
+ ui/tools/rect-tool.cpp ui/tools/rect-tool.h \
+ ui/tools/select-tool.cpp ui/tools/select-tool.h \
+ ui/tools/spiral-tool.cpp ui/tools/spiral-tool.h \
+ ui/tools/spray-tool.cpp ui/tools/spray-tool.h \
+ ui/tools/star-tool.cpp ui/tools/star-tool.h \
+ ui/tools/text-tool.cpp ui/tools/text-tool.h \
+ ui/tools/tool-base.cpp ui/tools/tool-base.h \
+ ui/tools/tweak-tool.cpp ui/tools/tweak-tool.h \
+ ui/tools/zoom-tool.cpp ui/tools/zoom-tool.h \ No newline at end of file
diff --git a/src/arc-context.cpp b/src/ui/tools/arc-tool.cpp
index a14562a32..bb7dfa21c 100644
--- a/src/arc-context.cpp
+++ b/src/ui/tools/arc-tool.cpp
@@ -41,31 +41,35 @@
#include "context-fns.h"
#include "verbs.h"
#include "shape-editor.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
-#include "arc-context.h"
+#include "ui/tools/arc-tool.h"
#include "display/sp-canvas-item.h"
using Inkscape::DocumentUndo;
#include "tool-factory.h"
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
namespace {
- SPEventContext* createArcContext() {
- return new SPArcContext();
+ ToolBase* createArcContext() {
+ return new ArcTool();
}
bool arcContextRegistered = ToolFactory::instance().registerObject("/tools/shapes/arc", createArcContext);
}
-const std::string& SPArcContext::getPrefsPath() {
- return SPArcContext::prefsPath;
+const std::string& ArcTool::getPrefsPath() {
+ return ArcTool::prefsPath;
}
-const std::string SPArcContext::prefsPath = "/tools/shapes/arc";
+const std::string ArcTool::prefsPath = "/tools/shapes/arc";
-SPArcContext::SPArcContext() : SPEventContext() {
+ArcTool::ArcTool() : ToolBase() {
this->cursor_shape = cursor_ellipse_xpm;
this->hot_x = 4;
this->hot_y = 4;
@@ -79,15 +83,15 @@ SPArcContext::SPArcContext() : SPEventContext() {
this->arc = NULL;
}
-void SPArcContext::finish() {
+void ArcTool::finish() {
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), GDK_CURRENT_TIME);
this->finishItem();
this->sel_changed_connection.disconnect();
- SPEventContext::finish();
+ ToolBase::finish();
}
-SPArcContext::~SPArcContext() {
+ArcTool::~ArcTool() {
this->enableGrDrag(false);
this->sel_changed_connection.disconnect();
@@ -105,13 +109,13 @@ SPArcContext::~SPArcContext() {
* Callback that processes the "changed" signal on the selection;
* destroys old and creates new knotholder.
*/
-void SPArcContext::selection_changed(Inkscape::Selection* selection) {
+void ArcTool::selection_changed(Inkscape::Selection* selection) {
this->shape_editor->unset_item(SH_KNOTHOLDER);
this->shape_editor->set_item(selection->singleItem(), SH_KNOTHOLDER);
}
-void SPArcContext::setup() {
- SPEventContext::setup();
+void ArcTool::setup() {
+ ToolBase::setup();
Inkscape::Selection *selection = sp_desktop_selection(this->desktop);
@@ -124,7 +128,7 @@ void SPArcContext::setup() {
this->sel_changed_connection.disconnect();
this->sel_changed_connection = selection->connectChanged(
- sigc::mem_fun(this, &SPArcContext::selection_changed)
+ sigc::mem_fun(this, &ArcTool::selection_changed)
);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -137,7 +141,7 @@ void SPArcContext::setup() {
}
}
-bool SPArcContext::item_handler(SPItem* item, GdkEvent* event) {
+bool ArcTool::item_handler(SPItem* item, GdkEvent* event) {
gint ret = FALSE;
switch (event->type) {
@@ -156,12 +160,12 @@ bool SPArcContext::item_handler(SPItem* item, GdkEvent* event) {
// ret = (SP_EVENT_CONTEXT_CLASS(sp_arc_context_parent_class))->item_handler(event_context, item, event);
// }
// CPPIFY: ret is overwritten...
- ret = SPEventContext::item_handler(item, event);
+ ret = ToolBase::item_handler(item, event);
return ret;
}
-bool SPArcContext::root_handler(GdkEvent* event) {
+bool ArcTool::root_handler(GdkEvent* event) {
static bool dragging;
Inkscape::Selection *selection = sp_desktop_selection(desktop);
@@ -343,13 +347,13 @@ bool SPArcContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPEventContext::root_handler(event);
+ ret = ToolBase::root_handler(event);
}
return ret;
}
-void SPArcContext::drag(Geom::Point pt, guint state) {
+void ArcTool::drag(Geom::Point pt, guint state) {
if (!this->arc) {
if (Inkscape::have_viable_layer(desktop, this->message_context) == false) {
return;
@@ -441,7 +445,7 @@ void SPArcContext::drag(Geom::Point pt, guint state) {
g_string_free(ys, FALSE);
}
-void SPArcContext::finishItem() {
+void ArcTool::finishItem() {
this->message_context->clear();
if (this->arc != NULL) {
@@ -463,7 +467,7 @@ void SPArcContext::finishItem() {
}
}
-void SPArcContext::cancel() {
+void ArcTool::cancel() {
sp_desktop_selection(desktop)->clear();
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), 0);
@@ -482,6 +486,10 @@ void SPArcContext::cancel() {
DocumentUndo::cancel(sp_desktop_document(desktop));
}
+}
+}
+}
+
/*
Local Variables:
diff --git a/src/arc-context.h b/src/ui/tools/arc-tool.h
index 6a0a6c071..eaa50f2b9 100644
--- a/src/arc-context.h
+++ b/src/ui/tools/arc-tool.h
@@ -19,17 +19,21 @@
#include <sigc++/connection.h>
#include <2geom/point.h>
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "sp-ellipse.h"
-#define SP_ARC_CONTEXT(obj) (dynamic_cast<SPArcContext*>((SPEventContext*)obj))
-#define SP_IS_ARC_CONTEXT(obj) (dynamic_cast<const SPArcContext*>(const SPEventContext*(obj)) != NULL)
+#define SP_ARC_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::ArcTool*>((Inkscape::UI::Tools::ToolBase*)obj))
+#define SP_IS_ARC_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::ArcTool*>(const Inkscape::UI::Tools::ToolBase*(obj)) != NULL)
-class SPArcContext : public SPEventContext {
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class ArcTool : public ToolBase {
public:
- SPArcContext();
- virtual ~SPArcContext();
+ ArcTool();
+ virtual ~ArcTool();
static const std::string prefsPath;
@@ -54,6 +58,10 @@ private:
void cancel();
};
+}
+}
+}
+
#endif /* !SEEN_ARC_CONTEXT_H */
/*
diff --git a/src/box3d-context.cpp b/src/ui/tools/box3d-tool.cpp
index f270fa244..80cc75e79 100644
--- a/src/box3d-context.cpp
+++ b/src/ui/tools/box3d-tool.cpp
@@ -34,7 +34,7 @@
#include "message-context.h"
#include "pixmaps/cursor-3dbox.xpm"
#include "box3d.h"
-#include "box3d-context.h"
+#include "ui/tools/box3d-tool.h"
#include <glibmm/i18n.h>
#include "xml/repr.h"
#include "xml/node-event-vector.h"
@@ -54,21 +54,25 @@ using Inkscape::DocumentUndo;
#include "tool-factory.h"
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
namespace {
- SPEventContext* createBox3dContext() {
- return new Box3DContext();
+ ToolBase* createBox3dTool() {
+ return new Box3dTool();
}
- bool box3dContextRegistered = ToolFactory::instance().registerObject("/tools/shapes/3dbox", createBox3dContext);
+ bool Box3dToolRegistered = ToolFactory::instance().registerObject("/tools/shapes/3dbox", createBox3dTool);
}
-const std::string& Box3DContext::getPrefsPath() {
- return Box3DContext::prefsPath;
+const std::string& Box3dTool::getPrefsPath() {
+ return Box3dTool::prefsPath;
}
-const std::string Box3DContext::prefsPath = "/tools/shapes/3dbox";
+const std::string Box3dTool::prefsPath = "/tools/shapes/3dbox";
-Box3DContext::Box3DContext() : SPEventContext() {
+Box3dTool::Box3dTool() : ToolBase() {
this->cursor_shape = cursor_3dbox_xpm;
this->hot_x = 4;
this->hot_y = 4;
@@ -86,16 +90,16 @@ Box3DContext::Box3DContext() : SPEventContext() {
this->_vpdrag = NULL;
}
-void Box3DContext::finish() {
+void Box3dTool::finish() {
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), GDK_CURRENT_TIME);
this->finishItem();
this->sel_changed_connection.disconnect();
- SPEventContext::finish();
+ ToolBase::finish();
}
-Box3DContext::~Box3DContext() {
+Box3dTool::~Box3dTool() {
this->enableGrDrag(false);
delete (this->_vpdrag);
@@ -116,7 +120,7 @@ Box3DContext::~Box3DContext() {
* Callback that processes the "changed" signal on the selection;
* destroys old and creates new knotholder.
*/
-void Box3DContext::selection_changed(Inkscape::Selection* selection) {
+void Box3dTool::selection_changed(Inkscape::Selection* selection) {
this->shape_editor->unset_item(SH_KNOTHOLDER);
this->shape_editor->set_item(selection->singleItem(), SH_KNOTHOLDER);
@@ -145,8 +149,8 @@ static void sp_box3d_context_ensure_persp_in_defs(SPDocument *document) {
}
}
-void Box3DContext::setup() {
- SPEventContext::setup();
+void Box3dTool::setup() {
+ ToolBase::setup();
this->shape_editor = new ShapeEditor(this->desktop);
@@ -157,7 +161,7 @@ void Box3DContext::setup() {
this->sel_changed_connection.disconnect();
this->sel_changed_connection = sp_desktop_selection(this->desktop)->connectChanged(
- sigc::mem_fun(this, &Box3DContext::selection_changed)
+ sigc::mem_fun(this, &Box3dTool::selection_changed)
);
this->_vpdrag = new Box3D::VPDrag(sp_desktop_document(this->desktop));
@@ -173,7 +177,7 @@ void Box3DContext::setup() {
}
}
-bool Box3DContext::item_handler(SPItem* item, GdkEvent* event) {
+bool Box3dTool::item_handler(SPItem* item, GdkEvent* event) {
gint ret = FALSE;
switch (event->type) {
@@ -188,16 +192,16 @@ bool Box3DContext::item_handler(SPItem* item, GdkEvent* event) {
break;
}
-// if (((SPEventContextClass *) sp_box3d_context_parent_class)->item_handler) {
-// ret = ((SPEventContextClass *) sp_box3d_context_parent_class)->item_handler(event_context, item, event);
+// if (((ToolBaseClass *) sp_box3d_context_parent_class)->item_handler) {
+// ret = ((ToolBaseClass *) sp_box3d_context_parent_class)->item_handler(event_context, item, event);
// }
// CPPIFY: ret is always overwritten...
- ret = SPEventContext::item_handler(item, event);
+ ret = ToolBase::item_handler(item, event);
return ret;
}
-bool Box3DContext::root_handler(GdkEvent* event) {
+bool Box3dTool::root_handler(GdkEvent* event) {
static bool dragging;
SPDocument *document = sp_desktop_document (desktop);
@@ -505,13 +509,13 @@ bool Box3DContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPEventContext::root_handler(event);
+ ret = ToolBase::root_handler(event);
}
return ret;
}
-void Box3DContext::drag(guint state) {
+void Box3dTool::drag(guint state) {
if (!this->box3d) {
if (Inkscape::have_viable_layer(desktop, this->message_context) == false) {
return;
@@ -588,7 +592,7 @@ void Box3DContext::drag(guint state) {
this->message_context->setF(Inkscape::NORMAL_MESSAGE, "%s", _("<b>3D Box</b>; with <b>Shift</b> to extrude along the Z axis"));
}
-void Box3DContext::finishItem() {
+void Box3dTool::finishItem() {
this->message_context->clear();
this->ctrl_dragged = false;
this->extruded = false;
@@ -617,6 +621,10 @@ void Box3DContext::finishItem() {
}
}
+}
+}
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/box3d-context.h b/src/ui/tools/box3d-tool.h
index 044d79d7d..99bf99a7a 100644
--- a/src/box3d-context.h
+++ b/src/ui/tools/box3d-tool.h
@@ -17,19 +17,23 @@
#include <stddef.h>
#include <sigc++/sigc++.h>
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "proj_pt.h"
#include "vanishing-point.h"
#include "box3d.h"
-#define SP_BOX3D_CONTEXT(obj) (dynamic_cast<Box3DContext*>((SPEventContext*)obj))
-#define SP_IS_BOX3D_CONTEXT(obj) (dynamic_cast<const Box3DContext*>((const SPEventContext*)obj) != NULL)
+#define SP_BOX3D_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::Box3dTool*>((Inkscape::UI::Tools::ToolBase*)obj))
+#define SP_IS_BOX3D_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::Box3dTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL)
-class Box3DContext : public SPEventContext {
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class Box3dTool : public ToolBase {
public:
- Box3DContext();
- virtual ~Box3DContext();
+ Box3dTool();
+ virtual ~Box3dTool();
Box3D::VPDrag * _vpdrag;
@@ -73,6 +77,10 @@ private:
void finishItem();
};
+}
+}
+}
+
#endif /* __SP_BOX3D_CONTEXT_H__ */
/*
diff --git a/src/dyna-draw-context.cpp b/src/ui/tools/calligraphic-tool.cpp
index f8980e218..2c5e6561c 100644
--- a/src/dyna-draw-context.cpp
+++ b/src/ui/tools/calligraphic-tool.cpp
@@ -68,7 +68,7 @@
#include "livarot/Shape.h"
#include "verbs.h"
-#include "dyna-draw-context.h"
+#include "ui/tools/calligraphic-tool.h"
using Inkscape::DocumentUndo;
@@ -82,27 +82,30 @@ using Inkscape::DocumentUndo;
#define DYNA_MIN_WIDTH 1.0e-6
-static void add_cap(SPCurve *curve, Geom::Point const &from, Geom::Point const &to, double rounding);
+#include "tool-factory.h"
+namespace Inkscape {
+namespace UI {
+namespace Tools {
-#include "tool-factory.h"
+static void add_cap(SPCurve *curve, Geom::Point const &from, Geom::Point const &to, double rounding);
namespace {
- SPEventContext* createCalligraphicContext() {
- return new SPDynaDrawContext();
+ ToolBase* createCalligraphicContext() {
+ return new CalligraphicTool();
}
bool calligraphicContextRegistered = ToolFactory::instance().registerObject("/tools/calligraphic", createCalligraphicContext);
}
-const std::string& SPDynaDrawContext::getPrefsPath() {
- return SPDynaDrawContext::prefsPath;
+const std::string& CalligraphicTool::getPrefsPath() {
+ return CalligraphicTool::prefsPath;
}
-const std::string SPDynaDrawContext::prefsPath = "/tools/calligraphic";
+const std::string CalligraphicTool::prefsPath = "/tools/calligraphic";
-SPDynaDrawContext::SPDynaDrawContext() : SPCommonContext() {
+CalligraphicTool::CalligraphicTool() : DynamicBase() {
this->cursor_shape = cursor_calligraphy_xpm;
this->hot_x = 4;
this->hot_y = 4;
@@ -128,15 +131,15 @@ SPDynaDrawContext::SPDynaDrawContext() : SPCommonContext() {
this->just_started_drawing = false;
}
-SPDynaDrawContext::~SPDynaDrawContext() {
+CalligraphicTool::~CalligraphicTool() {
if (this->hatch_area) {
sp_canvas_item_destroy(this->hatch_area);
this->hatch_area = NULL;
}
}
-void SPDynaDrawContext::setup() {
- SPCommonContext::setup();
+void CalligraphicTool::setup() {
+ DynamicBase::setup();
this->accumulated = new SPCurve();
this->currentcurve = new SPCurve();
@@ -152,7 +155,7 @@ void SPDynaDrawContext::setup() {
g_signal_connect(G_OBJECT(this->currentshape), "event", G_CALLBACK(sp_desktop_root_handler), this->desktop);
{
- /* TODO: have a look at SPDropperContext::setup where the same is done.. generalize? */
+ /* TODO: have a look at DropperTool::setup where the same is done.. generalize? */
Geom::PathVector path;
Geom::Circle(0, 0, 1).getPath(path);
@@ -189,7 +192,7 @@ void SPDynaDrawContext::setup() {
}
}
-void SPDynaDrawContext::set(const Inkscape::Preferences::Entry& val) {
+void CalligraphicTool::set(const Inkscape::Preferences::Entry& val) {
Glib::ustring path = val.getEntryName();
if (path == "tracebackground") {
@@ -198,7 +201,7 @@ void SPDynaDrawContext::set(const Inkscape::Preferences::Entry& val) {
this->keep_selected = val.getBool();
} else {
//pass on up to parent class to handle common attributes.
- SPCommonContext::set(val);
+ DynamicBase::set(val);
}
//g_print("DDC: %g %g %g %g\n", ddc->mass, ddc->drag, ddc->angle, ddc->width);
@@ -211,7 +214,7 @@ flerp(double f0, double f1, double p)
}
///* Get normalized point */
-//Geom::Point SPDynaDrawContext::getNormalizedPoint(Geom::Point v) const {
+//Geom::Point CalligraphicTool::getNormalizedPoint(Geom::Point v) const {
// Geom::Rect drect = desktop->get_display_area();
//
// double const max = MAX ( drect.dimensions()[Geom::X], drect.dimensions()[Geom::Y] );
@@ -220,7 +223,7 @@ flerp(double f0, double f1, double p)
//}
//
///* Get view point */
-//Geom::Point SPDynaDrawContext::getViewPoint(Geom::Point n) const {
+//Geom::Point CalligraphicTool::getViewPoint(Geom::Point n) const {
// Geom::Rect drect = desktop->get_display_area();
//
// double const max = MAX ( drect.dimensions()[Geom::X], drect.dimensions()[Geom::Y] );
@@ -228,7 +231,7 @@ flerp(double f0, double f1, double p)
// return Geom::Point(n[Geom::X] * max + drect.min()[Geom::X], n[Geom::Y] * max + drect.min()[Geom::Y]);
//}
-void SPDynaDrawContext::reset(Geom::Point p) {
+void CalligraphicTool::reset(Geom::Point p) {
this->last = this->cur = this->getNormalizedPoint(p);
this->vel = Geom::Point(0,0);
@@ -238,7 +241,7 @@ void SPDynaDrawContext::reset(Geom::Point p) {
this->del = Geom::Point(0,0);
}
-void SPDynaDrawContext::extinput(GdkEvent *event) {
+void CalligraphicTool::extinput(GdkEvent *event) {
if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &this->pressure)) {
this->pressure = CLAMP (this->pressure, DDC_MIN_PRESSURE, DDC_MAX_PRESSURE);
} else {
@@ -259,7 +262,7 @@ void SPDynaDrawContext::extinput(GdkEvent *event) {
}
-bool SPDynaDrawContext::apply(Geom::Point p) {
+bool CalligraphicTool::apply(Geom::Point p) {
Geom::Point n = this->getNormalizedPoint(p);
/* Calculate mass and drag */
@@ -356,7 +359,7 @@ bool SPDynaDrawContext::apply(Geom::Point p) {
return TRUE;
}
-void SPDynaDrawContext::brush() {
+void CalligraphicTool::brush() {
g_assert( this->npoints >= 0 && this->npoints < SAMPLING_SIZE );
// How much velocity thins strokestyle
@@ -436,7 +439,7 @@ sp_ddc_update_toolbox (SPDesktop *desktop, const gchar *id, double value)
desktop->setToolboxAdjustmentValue (id, value);
}
-void SPDynaDrawContext::cancel() {
+void CalligraphicTool::cancel() {
this->dragging = false;
this->is_drawing = false;
@@ -457,7 +460,7 @@ void SPDynaDrawContext::cancel() {
}
}
-bool SPDynaDrawContext::root_handler(GdkEvent* event) {
+bool CalligraphicTool::root_handler(GdkEvent* event) {
gint ret = FALSE;
switch (event->type) {
@@ -900,14 +903,14 @@ bool SPDynaDrawContext::root_handler(GdkEvent* event) {
// if ((SP_EVENT_CONTEXT_CLASS(sp_dyna_draw_context_parent_class))->root_handler) {
// ret = (SP_EVENT_CONTEXT_CLASS(sp_dyna_draw_context_parent_class))->root_handler(event_context, event);
// }
- ret = SPCommonContext::root_handler(event);
+ ret = DynamicBase::root_handler(event);
}
return ret;
}
-void SPDynaDrawContext::clear_current() {
+void CalligraphicTool::clear_current() {
/* reset bpath */
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), NULL);
/* reset curve */
@@ -918,7 +921,7 @@ void SPDynaDrawContext::clear_current() {
this->npoints = 0;
}
-void SPDynaDrawContext::set_to_accumulated(bool unionize, bool subtract) {
+void CalligraphicTool::set_to_accumulated(bool unionize, bool subtract) {
if (!this->accumulated->is_empty()) {
if (!this->repr) {
/* Create object */
@@ -995,7 +998,7 @@ add_cap(SPCurve *curve,
}
}
-bool SPDynaDrawContext::accumulate() {
+bool CalligraphicTool::accumulate() {
if (
this->cal1->is_empty() ||
this->cal2->is_empty() ||
@@ -1050,7 +1053,7 @@ static double square(double const x)
return x * x;
}
-void SPDynaDrawContext::fit_and_split(bool release) {
+void CalligraphicTool::fit_and_split(bool release) {
double const tolerance_sq = square( desktop->w2d().descrim() * TOLERANCE_CALLIGRAPHIC );
#ifdef DYNA_DRAW_VERBOSE
@@ -1175,7 +1178,7 @@ void SPDynaDrawContext::fit_and_split(bool release) {
}
}
-void SPDynaDrawContext::draw_temporary_box() {
+void CalligraphicTool::draw_temporary_box() {
this->currentcurve->reset();
this->currentcurve->moveto(this->point2[this->npoints-1]);
@@ -1196,6 +1199,11 @@ void SPDynaDrawContext::draw_temporary_box() {
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve);
}
+}
+}
+}
+
+
/*
Local Variables:
mode:c++
diff --git a/src/dyna-draw-context.h b/src/ui/tools/calligraphic-tool.h
index 36a429a8d..926e9d126 100644
--- a/src/dyna-draw-context.h
+++ b/src/ui/tools/calligraphic-tool.h
@@ -18,7 +18,7 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "common-context.h"
+#include "ui/tools/dynamic-base.h"
#include "splivarot.h"
#define DDC_MIN_PRESSURE 0.0
@@ -29,10 +29,14 @@
#define DDC_MAX_TILT 1.0
#define DDC_DEFAULT_TILT 0.0
-class SPDynaDrawContext : public SPCommonContext {
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class CalligraphicTool : public DynamicBase {
public:
- SPDynaDrawContext();
- virtual ~SPDynaDrawContext();
+ CalligraphicTool();
+ virtual ~CalligraphicTool();
static const std::string prefsPath;
@@ -72,6 +76,10 @@ private:
void reset(Geom::Point p);
};
+}
+}
+}
+
#endif // SP_DYNA_DRAW_CONTEXT_H_SEEN
/*
diff --git a/src/connector-context.cpp b/src/ui/tools/connector-tool.cpp
index 99239533d..62d52f6af 100644
--- a/src/connector-context.cpp
+++ b/src/ui/tools/connector-tool.cpp
@@ -72,7 +72,7 @@
#include <string>
#include <cstring>
-#include "connector-context.h"
+#include "ui/tools/connector-tool.h"
#include "pixmaps/cursor-connector.xpm"
#include "xml/node-event-vector.h"
#include "xml/repr.h"
@@ -109,32 +109,38 @@
using Inkscape::DocumentUndo;
+#include "tool-factory.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
// Stuff borrowed from DrawContext
-static void spcc_connector_set_initial_point(SPConnectorContext *cc, Geom::Point const p);
-static void spcc_connector_set_subsequent_point(SPConnectorContext *cc, Geom::Point const p);
-static void spcc_connector_finish_segment(SPConnectorContext *cc, Geom::Point p);
-static void spcc_reset_colors(SPConnectorContext *cc);
-static void spcc_connector_finish(SPConnectorContext *cc);
-static void spcc_concat_colors_and_flush(SPConnectorContext *cc);
-static void spcc_flush_white(SPConnectorContext *cc, SPCurve *gc);
+static void spcc_connector_set_initial_point(ConnectorTool *cc, Geom::Point const p);
+static void spcc_connector_set_subsequent_point(ConnectorTool *cc, Geom::Point const p);
+static void spcc_connector_finish_segment(ConnectorTool *cc, Geom::Point p);
+static void spcc_reset_colors(ConnectorTool *cc);
+static void spcc_connector_finish(ConnectorTool *cc);
+static void spcc_concat_colors_and_flush(ConnectorTool *cc);
+static void spcc_flush_white(ConnectorTool *cc, SPCurve *gc);
// Context event handlers
-static gint connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const &bevent);
-static gint connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion const &mevent);
-static gint connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton const &revent);
-static gint connector_handle_key_press(SPConnectorContext *const cc, guint const keyval);
+static gint connector_handle_button_press(ConnectorTool *const cc, GdkEventButton const &bevent);
+static gint connector_handle_motion_notify(ConnectorTool *const cc, GdkEventMotion const &mevent);
+static gint connector_handle_button_release(ConnectorTool *const cc, GdkEventButton const &revent);
+static gint connector_handle_key_press(ConnectorTool *const cc, guint const keyval);
-static void cc_active_shape_add_knot(SPConnectorContext *cc, SPItem* item);
-static void cc_set_active_shape(SPConnectorContext *cc, SPItem *item);
+static void cc_active_shape_add_knot(ConnectorTool *cc, SPItem* item);
+static void cc_set_active_shape(ConnectorTool *cc, SPItem *item);
static void cc_clear_active_knots(SPKnotList k);
-static void cc_clear_active_shape(SPConnectorContext *cc);
-static void cc_set_active_conn(SPConnectorContext *cc, SPItem *item);
-static void cc_clear_active_conn(SPConnectorContext *cc);
-static bool conn_pt_handle_test(SPConnectorContext *cc, Geom::Point& p, gchar **href);
+static void cc_clear_active_shape(ConnectorTool *cc);
+static void cc_set_active_conn(ConnectorTool *cc, SPItem *item);
+static void cc_clear_active_conn(ConnectorTool *cc);
+static bool conn_pt_handle_test(ConnectorTool *cc, Geom::Point& p, gchar **href);
static void cc_select_handle(SPKnot* knot);
static void cc_deselect_handle(SPKnot* knot);
static bool cc_item_is_shape(SPItem *item);
-static void cc_connector_rerouting_finish(SPConnectorContext *const cc,
+static void cc_connector_rerouting_finish(ConnectorTool *const cc,
Geom::Point *const p);
static void shape_event_attr_deleted(Inkscape::XML::Node *repr,
@@ -162,24 +168,21 @@ static Inkscape::XML::NodeEventVector layer_repr_events = {
NULL /* order_changed */
};
-
-#include "tool-factory.h"
-
namespace {
- SPEventContext* createConnectorContext() {
- return new SPConnectorContext();
+ ToolBase* createConnectorContext() {
+ return new ConnectorTool();
}
bool connectorContextRegistered = ToolFactory::instance().registerObject("/tools/connector", createConnectorContext);
}
-const std::string& SPConnectorContext::getPrefsPath() {
- return SPConnectorContext::prefsPath;
+const std::string& ConnectorTool::getPrefsPath() {
+ return ConnectorTool::prefsPath;
}
-const std::string SPConnectorContext::prefsPath = "/tools/connector";
+const std::string ConnectorTool::prefsPath = "/tools/connector";
-SPConnectorContext::SPConnectorContext() : SPEventContext() {
+ConnectorTool::ConnectorTool() : ToolBase() {
this->red_curve = 0;
this->isOrthogonal = false;
this->c1 = 0;
@@ -229,7 +232,7 @@ SPConnectorContext::SPConnectorContext() : SPEventContext() {
this->state = SP_CONNECTOR_CONTEXT_IDLE;
}
-SPConnectorContext::~SPConnectorContext() {
+ConnectorTool::~ConnectorTool() {
this->sel_changed_connection.disconnect();
for (int i = 0; i < 2; ++i) {
@@ -252,14 +255,14 @@ SPConnectorContext::~SPConnectorContext() {
g_assert( this->newConnRef == NULL );
}
-void SPConnectorContext::setup() {
- SPEventContext::setup();
+void ConnectorTool::setup() {
+ ToolBase::setup();
this->selection = sp_desktop_selection(this->desktop);
this->sel_changed_connection.disconnect();
this->sel_changed_connection = this->selection->connectChanged(
- sigc::mem_fun(this, &SPConnectorContext::selection_changed)
+ sigc::mem_fun(this, &ConnectorTool::selection_changed)
);
/* Create red bpath */
@@ -292,7 +295,7 @@ void SPConnectorContext::setup() {
this->desktop->canvas->gen_all_enter_events = true;
}
-void SPConnectorContext::set(const Inkscape::Preferences::Entry& val) {
+void ConnectorTool::set(const Inkscape::Preferences::Entry& val) {
/* fixme: Proper error handling for non-numeric data. Use a locale-independent function like
* g_ascii_strtod (or a thin wrapper that does the right thing for invalid values inf/nan). */
Glib::ustring name = val.getEntryName();
@@ -304,11 +307,11 @@ void SPConnectorContext::set(const Inkscape::Preferences::Entry& val) {
}
}
-void SPConnectorContext::finish() {
+void ConnectorTool::finish() {
spcc_connector_finish(this);
this->state = SP_CONNECTOR_CONTEXT_IDLE;
- SPEventContext::finish();
+ ToolBase::finish();
if (this->selection) {
this->selection = NULL;
@@ -325,7 +328,7 @@ void SPConnectorContext::finish() {
static void
-cc_clear_active_shape(SPConnectorContext *cc)
+cc_clear_active_shape(ConnectorTool *cc)
{
if (cc->active_shape == NULL) {
return;
@@ -360,7 +363,7 @@ cc_clear_active_knots(SPKnotList k)
}
static void
-cc_clear_active_conn(SPConnectorContext *cc)
+cc_clear_active_conn(ConnectorTool *cc)
{
if (cc->active_conn == NULL) {
return;
@@ -385,7 +388,7 @@ cc_clear_active_conn(SPConnectorContext *cc)
static bool
-conn_pt_handle_test(SPConnectorContext *cc, Geom::Point& p, gchar **href)
+conn_pt_handle_test(ConnectorTool *cc, Geom::Point& p, gchar **href)
{
if (cc->active_handle && (cc->knots.find(cc->active_handle) != cc->knots.end()))
{
@@ -417,7 +420,7 @@ cc_deselect_handle(SPKnot* knot)
sp_knot_update_ctrl(knot);
}
-bool SPConnectorContext::item_handler(SPItem* item, GdkEvent* event) {
+bool ConnectorTool::item_handler(SPItem* item, GdkEvent* event) {
gint ret = FALSE;
Geom::Point p(event->button.x, event->button.y);
@@ -472,7 +475,7 @@ bool SPConnectorContext::item_handler(SPItem* item, GdkEvent* event) {
return ret;
}
-bool SPConnectorContext::root_handler(GdkEvent* event) {
+bool ConnectorTool::root_handler(GdkEvent* event) {
gint ret = FALSE;
switch (event->type) {
@@ -497,7 +500,7 @@ bool SPConnectorContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPEventContext::root_handler(event);
+ ret = ToolBase::root_handler(event);
}
return ret;
@@ -505,18 +508,18 @@ bool SPConnectorContext::root_handler(GdkEvent* event) {
static gint
-connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const &bevent)
+connector_handle_button_press(ConnectorTool *const cc, GdkEventButton const &bevent)
{
Geom::Point const event_w(bevent.x, bevent.y);
/* Find desktop coordinates */
Geom::Point p = cc->desktop->w2d(event_w);
- SPEventContext *event_context = SP_EVENT_CONTEXT(cc);
+ ToolBase *event_context = SP_EVENT_CONTEXT(cc);
gint ret = FALSE;
if ( bevent.button == 1 && !event_context->space_panning ) {
- SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc);
+ SPDesktop *desktop = cc->desktop;
if (Inkscape::have_viable_layer(desktop, cc->message_context) == false) {
return TRUE;
@@ -541,7 +544,7 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const
if ( cc->npoints == 0 ) {
cc_clear_active_conn(cc);
- SP_EVENT_CONTEXT_DESKTOP(cc)->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Creating new connector"));
+ cc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Creating new connector"));
/* Set start anchor */
/* Create green anchor */
@@ -612,10 +615,10 @@ connector_handle_button_press(SPConnectorContext *const cc, GdkEventButton const
}
static gint
-connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion const &mevent)
+connector_handle_motion_notify(ConnectorTool *const cc, GdkEventMotion const &mevent)
{
gint ret = FALSE;
- SPEventContext *event_context = SP_EVENT_CONTEXT(cc);
+ ToolBase *event_context = SP_EVENT_CONTEXT(cc);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (event_context->space_panning || mevent.state & GDK_BUTTON2_MASK || mevent.state & GDK_BUTTON3_MASK) {
@@ -706,13 +709,13 @@ connector_handle_motion_notify(SPConnectorContext *const cc, GdkEventMotion cons
}
static gint
-connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton const &revent)
+connector_handle_button_release(ConnectorTool *const cc, GdkEventButton const &revent)
{
gint ret = FALSE;
- SPEventContext *event_context = SP_EVENT_CONTEXT(cc);
+ ToolBase *event_context = SP_EVENT_CONTEXT(cc);
if ( revent.button == 1 && !event_context->space_panning ) {
- SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc);
+ SPDesktop *desktop = cc->desktop;
SPDocument *doc = sp_desktop_document(desktop);
SnapManager &m = desktop->namedview->snap_manager;
@@ -771,7 +774,7 @@ connector_handle_button_release(SPConnectorContext *const cc, GdkEventButton con
}
static gint
-connector_handle_key_press(SPConnectorContext *const cc, guint const keyval)
+connector_handle_key_press(ConnectorTool *const cc, guint const keyval)
{
gint ret = FALSE;
@@ -787,7 +790,7 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval)
case GDK_KEY_Escape:
if (cc->state == SP_CONNECTOR_CONTEXT_REROUTING) {
- SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc);
+ SPDesktop *desktop = cc->desktop;
SPDocument *doc = sp_desktop_document(desktop);
cc_connector_rerouting_finish(cc, NULL);
@@ -814,9 +817,9 @@ connector_handle_key_press(SPConnectorContext *const cc, guint const keyval)
static void
-cc_connector_rerouting_finish(SPConnectorContext *const cc, Geom::Point *const p)
+cc_connector_rerouting_finish(ConnectorTool *const cc, Geom::Point *const p)
{
- SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc);
+ SPDesktop *desktop = cc->desktop;
SPDocument *doc = sp_desktop_document(desktop);
// Clear the temporary path:
@@ -849,7 +852,7 @@ cc_connector_rerouting_finish(SPConnectorContext *const cc, Geom::Point *const p
static void
-spcc_reset_colors(SPConnectorContext *cc)
+spcc_reset_colors(ConnectorTool *cc)
{
/* Red */
cc->red_curve->reset();
@@ -861,7 +864,7 @@ spcc_reset_colors(SPConnectorContext *cc)
static void
-spcc_connector_set_initial_point(SPConnectorContext *const cc, Geom::Point const p)
+spcc_connector_set_initial_point(ConnectorTool *const cc, Geom::Point const p)
{
g_assert( cc->npoints == 0 );
@@ -873,7 +876,7 @@ spcc_connector_set_initial_point(SPConnectorContext *const cc, Geom::Point const
static void
-spcc_connector_set_subsequent_point(SPConnectorContext *const cc, Geom::Point const p)
+spcc_connector_set_subsequent_point(ConnectorTool *const cc, Geom::Point const p)
{
g_assert( cc->npoints != 0 );
@@ -910,7 +913,7 @@ spcc_connector_set_subsequent_point(SPConnectorContext *const cc, Geom::Point co
* Invoke _flush_white to write result back to object.
*/
static void
-spcc_concat_colors_and_flush(SPConnectorContext *cc)
+spcc_concat_colors_and_flush(ConnectorTool *cc)
{
SPCurve *c = cc->green_curve;
cc->green_curve = new SPCurve();
@@ -938,7 +941,7 @@ spcc_concat_colors_and_flush(SPConnectorContext *cc)
*/
static void
-spcc_flush_white(SPConnectorContext *cc, SPCurve *gc)
+spcc_flush_white(ConnectorTool *cc, SPCurve *gc)
{
SPCurve *c;
@@ -950,9 +953,9 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc)
}
/* Now we have to go back to item coordinates at last */
- c->transform(SP_EVENT_CONTEXT_DESKTOP(cc)->dt2doc());
+ c->transform(cc->desktop->dt2doc());
- SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(cc);
+ SPDesktop *desktop = cc->desktop;
SPDocument *doc = sp_desktop_document(desktop);
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
@@ -1015,7 +1018,7 @@ spcc_flush_white(SPConnectorContext *cc, SPCurve *gc)
static void
-spcc_connector_finish_segment(SPConnectorContext *const cc, Geom::Point const /*p*/)
+spcc_connector_finish_segment(ConnectorTool *const cc, Geom::Point const /*p*/)
{
if (!cc->red_curve->is_empty()) {
cc->green_curve->append_continuous(cc->red_curve, 0.0625);
@@ -1030,7 +1033,7 @@ spcc_connector_finish_segment(SPConnectorContext *const cc, Geom::Point const /*
static void
-spcc_connector_finish(SPConnectorContext *const cc)
+spcc_connector_finish(ConnectorTool *const cc)
{
SPDesktop *const desktop = cc->desktop;
desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Finishing connector"));
@@ -1055,7 +1058,7 @@ cc_generic_knot_handler(SPCanvasItem *, GdkEvent *event, SPKnot *knot)
g_object_ref(knot);
- SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(
+ ConnectorTool *cc = SP_CONNECTOR_CONTEXT(
knot->desktop->event_context);
gboolean consumed = FALSE;
@@ -1096,7 +1099,7 @@ cc_generic_knot_handler(SPCanvasItem *, GdkEvent *event, SPKnot *knot)
static gboolean
-endpt_handler(SPKnot */*knot*/, GdkEvent *event, SPConnectorContext *cc)
+endpt_handler(SPKnot */*knot*/, GdkEvent *event, ConnectorTool *cc)
{
//g_assert( SP_IS_CONNECTOR_CONTEXT(cc) );
@@ -1144,7 +1147,7 @@ endpt_handler(SPKnot */*knot*/, GdkEvent *event, SPConnectorContext *cc)
return consumed;
}
-static void cc_active_shape_add_knot(SPConnectorContext *cc, SPItem* item)
+static void cc_active_shape_add_knot(ConnectorTool *cc, SPItem* item)
{
SPDesktop *desktop = cc->desktop;
SPKnot *knot = sp_knot_new(desktop, 0);
@@ -1168,7 +1171,7 @@ static void cc_active_shape_add_knot(SPConnectorContext *cc, SPItem* item)
cc->knots[knot] = 1;
}
-static void cc_set_active_shape(SPConnectorContext *cc, SPItem *item)
+static void cc_set_active_shape(ConnectorTool *cc, SPItem *item)
{
g_assert(item != NULL );
@@ -1219,7 +1222,7 @@ static void cc_set_active_shape(SPConnectorContext *cc, SPItem *item)
static void
-cc_set_active_conn(SPConnectorContext *cc, SPItem *item)
+cc_set_active_conn(ConnectorTool *cc, SPItem *item)
{
g_assert( SP_IS_PATH(item) );
@@ -1323,7 +1326,7 @@ cc_set_active_conn(SPConnectorContext *cc, SPItem *item)
sp_knot_show(cc->endpt_handle[1]);
}
-void cc_create_connection_point(SPConnectorContext* cc)
+void cc_create_connection_point(ConnectorTool* cc)
{
if (cc->active_shape && cc->state == SP_CONNECTOR_CONTEXT_IDLE)
{
@@ -1419,7 +1422,7 @@ void cc_selection_set_avoid(bool const set_avoid)
DocumentUndo::done(document, SP_VERB_CONTEXT_CONNECTOR, event_desc);
}
-void SPConnectorContext::selection_changed(Inkscape::Selection *selection) {
+void ConnectorTool::selection_changed(Inkscape::Selection *selection) {
SPItem *item = selection->singleItem();
if (this->active_conn == item) {
@@ -1442,7 +1445,7 @@ shape_event_attr_deleted(Inkscape::XML::Node */*repr*/, Inkscape::XML::Node *chi
Inkscape::XML::Node */*ref*/, gpointer data)
{
g_assert(data);
- SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(data);
+ ConnectorTool *cc = SP_CONNECTOR_CONTEXT(data);
if (child == cc->active_shape_repr) {
// The active shape has been deleted. Clear active shape.
@@ -1457,7 +1460,7 @@ shape_event_attr_changed(Inkscape::XML::Node *repr, gchar const *name,
bool /*is_interactive*/, gpointer data)
{
g_assert(data);
- SPConnectorContext *cc = SP_CONNECTOR_CONTEXT(data);
+ ConnectorTool *cc = SP_CONNECTOR_CONTEXT(data);
// Look for changes that result in onscreen movement.
if (!strcmp(name, "d") || !strcmp(name, "x") || !strcmp(name, "y") ||
@@ -1476,6 +1479,10 @@ shape_event_attr_changed(Inkscape::XML::Node *repr, gchar const *name,
}
}
+}
+}
+}
+
/*
Local Variables:
diff --git a/src/connector-context.h b/src/ui/tools/connector-tool.h
index 1c4bfc34d..7cd6a6dad 100644
--- a/src/connector-context.h
+++ b/src/ui/tools/connector-tool.h
@@ -15,13 +15,13 @@
#include <stddef.h>
#include <sigc++/sigc++.h>
#include <sigc++/connection.h>
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include <2geom/point.h>
#include "libavoid/connector.h"
#include <glibmm/i18n.h>
-#define SP_CONNECTOR_CONTEXT(obj) (dynamic_cast<SPConnectorContext*>((SPEventContext*)obj))
-//#define SP_IS_CONNECTOR_CONTEXT(obj) (dynamic_cast<const SPConnectorContext*>((const SPEventContext*)obj) != NULL)
+#define SP_CONNECTOR_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::ConnectorTool*>((Inkscape::UI::Tools::ToolBase*)obj))
+//#define SP_IS_CONNECTOR_CONTEXT(obj) (dynamic_cast<const ConnectorTool*>((const ToolBase*)obj) != NULL)
struct SPKnot;
class SPCurve;
@@ -42,10 +42,14 @@ enum {
typedef std::map<SPKnot *, int> SPKnotList;
-class SPConnectorContext : public SPEventContext {
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class ConnectorTool : public ToolBase {
public:
- SPConnectorContext();
- virtual ~SPConnectorContext();
+ ConnectorTool();
+ virtual ~ConnectorTool();
Inkscape::Selection *selection;
Geom::Point p[5];
@@ -109,10 +113,13 @@ private:
};
void cc_selection_set_avoid(bool const set_ignore);
-void cc_create_connection_point(SPConnectorContext* cc);
-void cc_remove_connection_point(SPConnectorContext* cc);
+void cc_create_connection_point(ConnectorTool* cc);
+void cc_remove_connection_point(ConnectorTool* cc);
bool cc_item_is_connector(SPItem *item);
+}
+}
+}
#endif /* !SEEN_CONNECTOR_CONTEXT_H */
diff --git a/src/dropper-context.cpp b/src/ui/tools/dropper-tool.cpp
index dcb1ab66c..9c47b50e9 100644
--- a/src/dropper-context.cpp
+++ b/src/ui/tools/dropper-tool.cpp
@@ -42,10 +42,10 @@
#include "pixmaps/cursor-dropper-f.xpm"
#include "pixmaps/cursor-dropper-s.xpm"
-#include "dropper-context.h"
+#include "ui/tools/dropper-tool.h"
#include "message-context.h"
#include "verbs.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
using Inkscape::DocumentUndo;
@@ -54,21 +54,25 @@ static GdkCursor *cursor_dropper_stroke = NULL;
#include "tool-factory.h"
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
namespace {
- SPEventContext* createDropperContext() {
- return new SPDropperContext();
+ ToolBase* createDropperContext() {
+ return new DropperTool();
}
bool dropperContextRegistered = ToolFactory::instance().registerObject("/tools/dropper", createDropperContext);
}
-const std::string& SPDropperContext::getPrefsPath() {
- return SPDropperContext::prefsPath;
+const std::string& DropperTool::getPrefsPath() {
+ return DropperTool::prefsPath;
}
-const std::string SPDropperContext::prefsPath = "/tools/dropper";
+const std::string DropperTool::prefsPath = "/tools/dropper";
-SPDropperContext::SPDropperContext() : SPEventContext() {
+DropperTool::DropperTool() : ToolBase() {
this->R = 0;
this->G = 0;
this->B = 0;
@@ -87,13 +91,13 @@ SPDropperContext::SPDropperContext() : SPEventContext() {
cursor_dropper_stroke = sp_cursor_new_from_xpm(cursor_dropper_s_xpm , 7, 7);
}
-SPDropperContext::~SPDropperContext() {
+DropperTool::~DropperTool() {
}
-void SPDropperContext::setup() {
- SPEventContext::setup();
+void DropperTool::setup() {
+ ToolBase::setup();
- /* TODO: have a look at SPDynaDrawContext::setup where the same is done.. generalize? */
+ /* TODO: have a look at CalligraphicTool::setup where the same is done.. generalize? */
Geom::PathVector path;
Geom::Circle(0, 0, 1).getPath(path);
@@ -118,7 +122,7 @@ void SPDropperContext::setup() {
}
}
-void SPDropperContext::finish() {
+void DropperTool::finish() {
this->enableGrDrag(false);
if (this->grabbed) {
@@ -153,7 +157,7 @@ void SPDropperContext::finish() {
/**
* Returns the current dropper context color.
*/
-guint32 SPDropperContext::get_color() {
+guint32 DropperTool::get_color() {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int pick = prefs->getInt("/tools/dropper/pick", SP_DROPPER_PICK_VISIBLE);
@@ -165,7 +169,7 @@ guint32 SPDropperContext::get_color() {
(pick == SP_DROPPER_PICK_ACTUAL && setalpha) ? this->alpha : 1.0);
}
-bool SPDropperContext::root_handler(GdkEvent* event) {
+bool DropperTool::root_handler(GdkEvent* event) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int ret = FALSE;
@@ -387,12 +391,16 @@ bool SPDropperContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPEventContext::root_handler(event);
+ ret = ToolBase::root_handler(event);
}
return ret;
}
+}
+}
+}
+
/*
Local Variables:
diff --git a/src/dropper-context.h b/src/ui/tools/dropper-tool.h
index 6e1015644..dd6f25bb6 100644
--- a/src/dropper-context.h
+++ b/src/ui/tools/dropper-tool.h
@@ -12,20 +12,24 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
-#define SP_DROPPER_CONTEXT(obj) (dynamic_cast<SPDropperContext*>((SPEventContext*)obj))
-#define SP_IS_DROPPER_CONTEXT(obj) (dynamic_cast<const SPDropperContext*>((const SPEventContext*)obj) != NULL)
+#define SP_DROPPER_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::DropperTool*>((Inkscape::UI::Tools::ToolBase*)obj))
+#define SP_IS_DROPPER_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::DropperTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL)
enum {
SP_DROPPER_PICK_VISIBLE,
SP_DROPPER_PICK_ACTUAL
};
-class SPDropperContext : public SPEventContext {
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class DropperTool : public ToolBase {
public:
- SPDropperContext();
- virtual ~SPDropperContext();
+ DropperTool();
+ virtual ~DropperTool();
static const std::string prefsPath;
@@ -51,6 +55,10 @@ private:
Geom::Point centre;
};
+}
+}
+}
+
#endif
/*
diff --git a/src/common-context.cpp b/src/ui/tools/dynamic-base.cpp
index 2155f9739..cec58dce9 100644
--- a/src/common-context.cpp
+++ b/src/ui/tools/dynamic-base.cpp
@@ -1,5 +1,5 @@
-#include "common-context.h"
+#include "ui/tools/dynamic-base.h"
#include <gtk/gtk.h>
@@ -19,8 +19,12 @@
#define DRAG_DEFAULT 1.0
#define DRAG_MAX 1.0
-SPCommonContext::SPCommonContext() :
- SPEventContext(),
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+DynamicBase::DynamicBase() :
+ ToolBase(),
accumulated(NULL),
segments(NULL),
currentshape(NULL),
@@ -56,7 +60,7 @@ SPCommonContext::SPCommonContext() :
{
}
-SPCommonContext::~SPCommonContext() {
+DynamicBase::~DynamicBase() {
if (this->accumulated) {
this->accumulated = this->accumulated->unref();
this->accumulated = 0;
@@ -88,7 +92,7 @@ SPCommonContext::~SPCommonContext() {
}
}
-void SPCommonContext::set(const Inkscape::Preferences::Entry& value) {
+void DynamicBase::set(const Inkscape::Preferences::Entry& value) {
Glib::ustring path = value.getEntryName();
// ignore preset modifications
@@ -125,7 +129,7 @@ void SPCommonContext::set(const Inkscape::Preferences::Entry& value) {
}
/* Get normalized point */
-Geom::Point SPCommonContext::getNormalizedPoint(Geom::Point v) const {
+Geom::Point DynamicBase::getNormalizedPoint(Geom::Point v) const {
Geom::Rect drect = this->desktop->get_display_area();
double const max = MAX ( drect.dimensions()[Geom::X], drect.dimensions()[Geom::Y] );
@@ -134,7 +138,7 @@ Geom::Point SPCommonContext::getNormalizedPoint(Geom::Point v) const {
}
/* Get view point */
-Geom::Point SPCommonContext::getViewPoint(Geom::Point n) const {
+Geom::Point DynamicBase::getViewPoint(Geom::Point n) const {
Geom::Rect drect = this->desktop->get_display_area();
double const max = MAX ( drect.dimensions()[Geom::X], drect.dimensions()[Geom::Y] );
@@ -142,6 +146,10 @@ Geom::Point SPCommonContext::getViewPoint(Geom::Point n) const {
return Geom::Point(n[Geom::X] * max + drect.min()[Geom::X], n[Geom::Y] * max + drect.min()[Geom::Y]);
}
+}
+}
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/common-context.h b/src/ui/tools/dynamic-base.h
index dc4c82251..9218eabd3 100644
--- a/src/common-context.h
+++ b/src/ui/tools/dynamic-base.h
@@ -19,16 +19,20 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "display/curve.h"
#include <2geom/point.h>
#define SAMPLING_SIZE 8 /* fixme: ?? */
-class SPCommonContext : public SPEventContext {
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class DynamicBase : public ToolBase {
public:
- SPCommonContext();
- virtual ~SPCommonContext();
+ DynamicBase();
+ virtual ~DynamicBase();
virtual void set(const Inkscape::Preferences::Entry& val);
@@ -100,6 +104,10 @@ protected:
Geom::Point getNormalizedPoint(Geom::Point v) const;
};
+}
+}
+}
+
#endif // COMMON_CONTEXT_H_SEEN
/*
diff --git a/src/eraser-context.cpp b/src/ui/tools/eraser-tool.cpp
index b2df86434..270987d27 100644
--- a/src/eraser-context.cpp
+++ b/src/ui/tools/eraser-tool.cpp
@@ -67,7 +67,7 @@
#include <2geom/math-utils.h>
#include <2geom/pathvector.h>
-#include "eraser-context.h"
+#include "ui/tools/eraser-tool.h"
using Inkscape::DocumentUndo;
@@ -85,31 +85,35 @@ using Inkscape::DocumentUndo;
#include "tool-factory.h"
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
namespace {
- SPEventContext* createEraserContext() {
- return new SPEraserContext();
+ ToolBase* createEraserContext() {
+ return new EraserTool();
}
bool eraserContextRegistered = ToolFactory::instance().registerObject("/tools/eraser", createEraserContext);
}
-const std::string& SPEraserContext::getPrefsPath() {
- return SPEraserContext::prefsPath;
+const std::string& EraserTool::getPrefsPath() {
+ return EraserTool::prefsPath;
}
-const std::string SPEraserContext::prefsPath = "/tools/eraser";
+const std::string EraserTool::prefsPath = "/tools/eraser";
-SPEraserContext::SPEraserContext() : SPCommonContext() {
+EraserTool::EraserTool() : DynamicBase() {
this->cursor_shape = cursor_eraser_xpm;
this->hot_x = 4;
this->hot_y = 4;
}
-SPEraserContext::~SPEraserContext() {
+EraserTool::~EraserTool() {
}
-void SPEraserContext::setup() {
- SPCommonContext::setup();
+void EraserTool::setup() {
+ DynamicBase::setup();
this->accumulated = new SPCurve();
this->currentcurve = new SPCurve();
@@ -167,7 +171,7 @@ flerp(double f0, double f1, double p)
return f0 + ( f1 - f0 ) * p;
}
-void SPEraserContext::reset(Geom::Point p) {
+void EraserTool::reset(Geom::Point p) {
this->last = this->cur = getNormalizedPoint(p);
this->vel = Geom::Point(0,0);
this->vel_max = 0;
@@ -176,7 +180,7 @@ void SPEraserContext::reset(Geom::Point p) {
this->del = Geom::Point(0,0);
}
-void SPEraserContext::extinput(GdkEvent *event) {
+void EraserTool::extinput(GdkEvent *event) {
if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &this->pressure))
this->pressure = CLAMP (this->pressure, ERC_MIN_PRESSURE, ERC_MAX_PRESSURE);
else
@@ -194,7 +198,7 @@ void SPEraserContext::extinput(GdkEvent *event) {
}
-bool SPEraserContext::apply(Geom::Point p) {
+bool EraserTool::apply(Geom::Point p) {
Geom::Point n = getNormalizedPoint(p);
/* Calculate mass and drag */
@@ -291,7 +295,7 @@ bool SPEraserContext::apply(Geom::Point p) {
return TRUE;
}
-void SPEraserContext::brush() {
+void EraserTool::brush() {
g_assert( this->npoints >= 0 && this->npoints < SAMPLING_SIZE );
// How much velocity thins strokestyle
@@ -357,7 +361,7 @@ sp_erc_update_toolbox (SPDesktop *desktop, const gchar *id, double value)
desktop->setToolboxAdjustmentValue (id, value);
}
-void SPEraserContext::cancel() {
+void EraserTool::cancel() {
SPDesktop *desktop = SP_EVENT_CONTEXT(this)->desktop;
this->dragging = FALSE;
this->is_drawing = false;
@@ -375,7 +379,7 @@ void SPEraserContext::cancel() {
}
}
-bool SPEraserContext::root_handler(GdkEvent* event) {
+bool EraserTool::root_handler(GdkEvent* event) {
gint ret = FALSE;
switch (event->type) {
@@ -614,13 +618,13 @@ bool SPEraserContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPCommonContext::root_handler(event);
+ ret = DynamicBase::root_handler(event);
}
return ret;
}
-void SPEraserContext::clear_current() {
+void EraserTool::clear_current() {
// reset bpath
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), NULL);
@@ -633,7 +637,7 @@ void SPEraserContext::clear_current() {
this->npoints = 0;
}
-void SPEraserContext::set_to_accumulated() {
+void EraserTool::set_to_accumulated() {
bool workDone = false;
if (!this->accumulated->is_empty()) {
@@ -801,7 +805,7 @@ add_cap(SPCurve *curve,
}
}
-void SPEraserContext::accumulate() {
+void EraserTool::accumulate() {
if ( !this->cal1->is_empty() && !this->cal2->is_empty() ) {
this->accumulated->reset(); /* Is this required ?? */
SPCurve *rev_cal2 = this->cal2->create_reverse();
@@ -843,7 +847,7 @@ static double square(double const x)
return x * x;
}
-void SPEraserContext::fit_and_split(bool release) {
+void EraserTool::fit_and_split(bool release) {
double const tolerance_sq = square( desktop->w2d().descrim() * TOLERANCE_ERASER );
#ifdef ERASER_VERBOSE
@@ -978,7 +982,7 @@ void SPEraserContext::fit_and_split(bool release) {
}
}
-void SPEraserContext::draw_temporary_box() {
+void EraserTool::draw_temporary_box() {
this->currentcurve->reset();
this->currentcurve->moveto(this->point1[this->npoints-1]);
@@ -999,6 +1003,10 @@ void SPEraserContext::draw_temporary_box() {
sp_canvas_bpath_set_bpath(SP_CANVAS_BPATH(this->currentshape), this->currentcurve);
}
+}
+}
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/eraser-context.h b/src/ui/tools/eraser-tool.h
index 7ff1cf712..eb7eb16e8 100644
--- a/src/eraser-context.h
+++ b/src/ui/tools/eraser-tool.h
@@ -19,7 +19,7 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "common-context.h"
+#include "ui/tools/dynamic-base.h"
#define ERC_MIN_PRESSURE 0.0
#define ERC_MAX_PRESSURE 1.0
@@ -29,10 +29,14 @@
#define ERC_MAX_TILT 1.0
#define ERC_DEFAULT_TILT 0.0
-class SPEraserContext : public SPCommonContext {
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class EraserTool : public DynamicBase {
public:
- SPEraserContext();
- virtual ~SPEraserContext();
+ EraserTool();
+ virtual ~EraserTool();
static const std::string prefsPath;
@@ -54,6 +58,10 @@ private:
void draw_temporary_box();
};
+}
+}
+}
+
#endif // SP_ERASER_CONTEXT_H_SEEN
/*
diff --git a/src/flood-context.cpp b/src/ui/tools/flood-tool.cpp
index dc89fb0a9..0b72bc9f2 100644
--- a/src/flood-context.cpp
+++ b/src/ui/tools/flood-tool.cpp
@@ -41,7 +41,7 @@
#include "display/sp-canvas.h"
#include "document.h"
#include "document-undo.h"
-#include "flood-context.h"
+#include "ui/tools/flood-tool.h"
#include "livarot/Path.h"
#include "livarot/Shape.h"
#include "macros.h"
@@ -76,21 +76,25 @@ using Inkscape::Display::AssembleARGB32;
#include "tool-factory.h"
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
namespace {
- SPEventContext* createPaintbucketContext() {
- return new SPFloodContext();
+ ToolBase* createPaintbucketContext() {
+ return new FloodTool();
}
bool paintbucketContextRegistered = ToolFactory::instance().registerObject("/tools/paintbucket", createPaintbucketContext);
}
-const std::string& SPFloodContext::getPrefsPath() {
- return SPFloodContext::prefsPath;
+const std::string& FloodTool::getPrefsPath() {
+ return FloodTool::prefsPath;
}
-const std::string SPFloodContext::prefsPath = "/tools/paintbucket";
+const std::string FloodTool::prefsPath = "/tools/paintbucket";
-SPFloodContext::SPFloodContext() : SPEventContext() {
+FloodTool::FloodTool() : ToolBase() {
this->cursor_shape = cursor_paintbucket_xpm;
this->hot_x = 11;
this->hot_y = 30;
@@ -103,7 +107,7 @@ SPFloodContext::SPFloodContext() : SPEventContext() {
this->item = NULL;
}
-SPFloodContext::~SPFloodContext() {
+FloodTool::~FloodTool() {
this->sel_changed_connection.disconnect();
delete this->shape_editor;
@@ -119,13 +123,13 @@ SPFloodContext::~SPFloodContext() {
* Callback that processes the "changed" signal on the selection;
* destroys old and creates new knotholder.
*/
-void SPFloodContext::selection_changed(Inkscape::Selection* selection) {
+void FloodTool::selection_changed(Inkscape::Selection* selection) {
this->shape_editor->unset_item(SH_KNOTHOLDER);
this->shape_editor->set_item(selection->singleItem(), SH_KNOTHOLDER);
}
-void SPFloodContext::setup() {
- SPEventContext::setup();
+void FloodTool::setup() {
+ ToolBase::setup();
this->shape_editor = new ShapeEditor(this->desktop);
@@ -136,7 +140,7 @@ void SPFloodContext::setup() {
this->sel_changed_connection.disconnect();
this->sel_changed_connection = sp_desktop_selection(this->desktop)->connectChanged(
- sigc::mem_fun(this, &SPFloodContext::selection_changed)
+ sigc::mem_fun(this, &FloodTool::selection_changed)
);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -739,7 +743,7 @@ static bool sort_fill_queue_horizontal(Geom::Point a, Geom::Point b) {
* @param is_point_fill If false, use the Rubberband "touch selection" to get the initial points for the fill.
* @param is_touch_fill If true, use only the initial contact point in the Rubberband "touch selection" as the fill target color.
*/
-static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *event, bool union_with_selection, bool is_point_fill, bool is_touch_fill) {
+static void sp_flood_do_flood_fill(ToolBase *event_context, GdkEvent *event, bool union_with_selection, bool is_point_fill, bool is_touch_fill) {
SPDesktop *desktop = event_context->desktop;
SPDocument *document = sp_desktop_document(desktop);
@@ -1084,7 +1088,7 @@ static void sp_flood_do_flood_fill(SPEventContext *event_context, GdkEvent *even
DocumentUndo::done(document, SP_VERB_CONTEXT_PAINTBUCKET, _("Fill bounded area"));
}
-bool SPFloodContext::item_handler(SPItem* item, GdkEvent* event) {
+bool FloodTool::item_handler(SPItem* item, GdkEvent* event) {
gint ret = FALSE;
switch (event->type) {
@@ -1107,16 +1111,16 @@ bool SPFloodContext::item_handler(SPItem* item, GdkEvent* event) {
break;
}
-// if (((SPEventContextClass *) sp_flood_context_parent_class)->item_handler) {
-// ret = ((SPEventContextClass *) sp_flood_context_parent_class)->item_handler(event_context, item, event);
+// if (((ToolBaseClass *) sp_flood_context_parent_class)->item_handler) {
+// ret = ((ToolBaseClass *) sp_flood_context_parent_class)->item_handler(event_context, item, event);
// }
// CPPIFY: ret is overwritten...
- ret = SPEventContext::item_handler(item, event);
+ ret = ToolBase::item_handler(item, event);
return ret;
}
-bool SPFloodContext::root_handler(GdkEvent* event) {
+bool FloodTool::root_handler(GdkEvent* event) {
static bool dragging;
gint ret = FALSE;
@@ -1216,13 +1220,13 @@ bool SPFloodContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPEventContext::root_handler(event);
+ ret = ToolBase::root_handler(event);
}
return ret;
}
-void SPFloodContext::finishItem() {
+void FloodTool::finishItem() {
this->message_context->clear();
if (this->item != NULL) {
@@ -1238,11 +1242,15 @@ void SPFloodContext::finishItem() {
}
}
-void SPFloodContext::set_channels(gint channels) {
+void FloodTool::set_channels(gint channels) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setInt("/tools/paintbucket/channels", channels);
}
+}
+}
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/flood-context.h b/src/ui/tools/flood-tool.h
index 48bf36f85..3ed670e8b 100644
--- a/src/flood-context.h
+++ b/src/ui/tools/flood-tool.h
@@ -14,21 +14,19 @@
#include <stddef.h>
#include <sigc++/sigc++.h>
#include <gtk/gtk.h>
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
-#define SP_FLOOD_CONTEXT(obj) (dynamic_cast<SPFloodContext*>((SPEventContext*)obj))
-#define SP_IS_FLOOD_CONTEXT(obj) (dynamic_cast<const SPFloodContext*>((const SPEventContext*)obj) != NULL)
+#define SP_FLOOD_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::FloodTool*>((Inkscape::UI::Tools::ToolBase*)obj))
+#define SP_IS_FLOOD_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::FloodTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL)
+namespace Inkscape {
+namespace UI {
+namespace Tools {
-#define FLOOD_COLOR_CHANNEL_R 1
-#define FLOOD_COLOR_CHANNEL_G 2
-#define FLOOD_COLOR_CHANNEL_B 4
-#define FLOOD_COLOR_CHANNEL_A 8
-
-class SPFloodContext : public SPEventContext {
+class FloodTool : public ToolBase {
public:
- SPFloodContext();
- virtual ~SPFloodContext();
+ FloodTool();
+ virtual ~FloodTool();
SPItem *item;
@@ -63,4 +61,8 @@ enum PaintBucketChannels {
FLOOD_CHANNELS_ALPHA
};
+}
+}
+}
+
#endif
diff --git a/src/draw-context.cpp b/src/ui/tools/freehand-base.cpp
index a73d4b715..6e3a04b59 100644
--- a/src/draw-context.cpp
+++ b/src/ui/tools/freehand-base.cpp
@@ -34,8 +34,8 @@
#include "draw-anchor.h"
#include "macros.h"
#include "message-stack.h"
-#include "pen-context.h"
-#include "lpe-tool-context.h"
+#include "ui/tools/pen-tool.h"
+#include "ui/tools/lpe-tool.h"
#include "preferences.h"
#include "selection.h"
#include "selection-chemistry.h"
@@ -45,16 +45,21 @@
#include "live_effects/lpe-powerstroke.h"
#include "style.h"
#include "ui/control-manager.h"
-#include "draw-context.h"
#include "ui/clipboard.h"
+#include "ui/tools/freehand-base.h"
+
#include <gdk/gdkkeysyms.h>
using Inkscape::DocumentUndo;
-static void spdc_selection_changed(Inkscape::Selection *sel, SPDrawContext *dc);
-static void spdc_selection_modified(Inkscape::Selection *sel, guint flags, SPDrawContext *dc);
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+static void spdc_selection_changed(Inkscape::Selection *sel, FreehandBase *dc);
+static void spdc_selection_modified(Inkscape::Selection *sel, guint flags, FreehandBase *dc);
-static void spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection *sel);
+static void spdc_attach_selection(FreehandBase *dc, Inkscape::Selection *sel);
/**
* Flushes white curve(s) and additional curve into object.
@@ -62,12 +67,12 @@ static void spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection *sel);
* No cleaning of colored curves - this has to be done by caller
* No rereading of white data, so if you cannot rely on ::modified, do it in caller
*/
-static void spdc_flush_white(SPDrawContext *dc, SPCurve *gc);
+static void spdc_flush_white(FreehandBase *dc, SPCurve *gc);
-static void spdc_reset_white(SPDrawContext *dc);
-static void spdc_free_colors(SPDrawContext *dc);
+static void spdc_reset_white(FreehandBase *dc);
+static void spdc_free_colors(FreehandBase *dc);
-SPDrawContext::SPDrawContext() : SPEventContext() {
+FreehandBase::FreehandBase() : ToolBase() {
this->selection = 0;
this->grab = 0;
this->anchor_statusbar = false;
@@ -100,7 +105,7 @@ SPDrawContext::SPDrawContext() : SPEventContext() {
this->waiting_LPE_type = Inkscape::LivePathEffect::INVALID_LPE;
}
-SPDrawContext::~SPDrawContext() {
+FreehandBase::~FreehandBase() {
if (this->grab) {
sp_canvas_item_ungrab(this->grab, GDK_CURRENT_TIME);
this->grab = NULL;
@@ -113,8 +118,8 @@ SPDrawContext::~SPDrawContext() {
spdc_free_colors(this);
}
-void SPDrawContext::setup() {
- SPEventContext::setup();
+void FreehandBase::setup() {
+ ToolBase::setup();
this->selection = sp_desktop_selection(desktop);
@@ -151,7 +156,7 @@ void SPDrawContext::setup() {
spdc_attach_selection(this, this->selection);
}
-void SPDrawContext::finish() {
+void FreehandBase::finish() {
this->sel_changed_connection.disconnect();
this->sel_modified_connection.disconnect();
@@ -166,10 +171,10 @@ void SPDrawContext::finish() {
spdc_free_colors(this);
}
-void SPDrawContext::set(const Inkscape::Preferences::Entry& /*value*/) {
+void FreehandBase::set(const Inkscape::Preferences::Entry& /*value*/) {
}
-bool SPDrawContext::root_handler(GdkEvent* event) {
+bool FreehandBase::root_handler(GdkEvent* event) {
gint ret = FALSE;
switch (event->type) {
@@ -193,20 +198,20 @@ bool SPDrawContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPEventContext::root_handler(event);
+ ret = ToolBase::root_handler(event);
}
return ret;
}
-static Glib::ustring const tool_name(SPDrawContext *dc)
+static Glib::ustring const tool_name(FreehandBase *dc)
{
return ( SP_IS_PEN_CONTEXT(dc)
? "/tools/freehand/pen"
: "/tools/freehand/pencil" );
}
-static void spdc_paste_curve_as_freehand_shape(const SPCurve *c, SPDrawContext *dc, SPItem *item)
+static void spdc_paste_curve_as_freehand_shape(const SPCurve *c, FreehandBase *dc, SPItem *item)
{
using namespace Inkscape::LivePathEffect;
@@ -218,7 +223,7 @@ static void spdc_paste_curve_as_freehand_shape(const SPCurve *c, SPDrawContext *
static_cast<LPEPatternAlongPath*>(lpe)->pattern.paste_param_path(svgd);
}
-static void spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points, SPDrawContext *dc, SPItem *item)
+static void spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points, FreehandBase *dc, SPItem *item)
{
using namespace Inkscape::LivePathEffect;
@@ -235,6 +240,7 @@ static void spdc_apply_powerstroke_shape(const std::vector<Geom::Point> & points
lpe->getRepr()->setAttribute("interpolator_beta", "0.2");
}
+<<<<<<< TREE
static void spdc_apply_bend_shape(gchar const *svgd, SPDrawContext *dc, SPItem *item)
{
using namespace Inkscape::LivePathEffect;
@@ -251,6 +257,9 @@ static void spdc_apply_bend_shape(gchar const *svgd, SPDrawContext *dc, SPItem *
static bool bend;
static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item, SPCurve *curve)
+=======
+static void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item, SPCurve *curve)
+>>>>>>> MERGE-SOURCE
{
using namespace Inkscape::LivePathEffect;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -472,7 +481,7 @@ static void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item
* Selection handlers
*/
-static void spdc_selection_changed(Inkscape::Selection *sel, SPDrawContext *dc)
+static void spdc_selection_changed(Inkscape::Selection *sel, FreehandBase *dc)
{
if (dc->attach) {
spdc_attach_selection(dc, sel);
@@ -481,14 +490,14 @@ static void spdc_selection_changed(Inkscape::Selection *sel, SPDrawContext *dc)
/* fixme: We have to ensure this is not delayed (Lauris) */
-static void spdc_selection_modified(Inkscape::Selection *sel, guint /*flags*/, SPDrawContext *dc)
+static void spdc_selection_modified(Inkscape::Selection *sel, guint /*flags*/, FreehandBase *dc)
{
if (dc->attach) {
spdc_attach_selection(dc, sel);
}
}
-static void spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection */*sel*/)
+static void spdc_attach_selection(FreehandBase *dc, Inkscape::Selection */*sel*/)
{
// We reset white and forget white/start/end anchors
spdc_reset_white(dc);
@@ -530,14 +539,14 @@ static void spdc_attach_selection(SPDrawContext *dc, Inkscape::Selection */*sel*
}
-void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p, Geom::Point const &o,
+void spdc_endpoint_snap_rotation(ToolBase const *const ec, Geom::Point &p, Geom::Point const &o,
guint state)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
unsigned const snaps = abs(prefs->getInt("/options/rotationsnapsperpi/value", 12));
- SnapManager &m = SP_EVENT_CONTEXT_DESKTOP(ec)->namedview->snap_manager;
- m.setup(SP_EVENT_CONTEXT_DESKTOP(ec));
+ SnapManager &m = ec->desktop->namedview->snap_manager;
+ m.setup(ec->desktop);
bool snap_enabled = m.snapprefs.getSnapEnabledGlobally();
if (state & GDK_SHIFT_MASK) {
@@ -559,9 +568,9 @@ void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p,
}
-void spdc_endpoint_snap_free(SPEventContext const * const ec, Geom::Point& p, boost::optional<Geom::Point> &start_of_line, guint const /*state*/)
+void spdc_endpoint_snap_free(ToolBase const * const ec, Geom::Point& p, boost::optional<Geom::Point> &start_of_line, guint const /*state*/)
{
- SPDesktop *dt = SP_EVENT_CONTEXT_DESKTOP(ec);
+ SPDesktop *dt = ec->desktop;
SnapManager &m = dt->namedview->snap_manager;
Inkscape::Selection *selection = sp_desktop_selection (dt);
@@ -587,7 +596,7 @@ static SPCurve *reverse_then_unref(SPCurve *orig)
return ret;
}
-void spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed)
+void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed)
{
// Concat RBG
SPCurve *c = dc->green_curve;
@@ -619,7 +628,7 @@ void spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed)
// Step A - test, whether we ended on green anchor
if ( forceclosed || ( dc->green_anchor && dc->green_anchor->active ) ) {
// We hit green anchor, closing Green-Blue-Red
- SP_EVENT_CONTEXT_DESKTOP(dc)->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Path is closed."));
+ dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Path is closed."));
c->closepath_current();
// Closed path, just flush
spdc_flush_white(dc, c);
@@ -634,7 +643,7 @@ void spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed)
|| dc->sa->curve->is_closed() ) )
{
// We hit bot start and end of single curve, closing paths
- SP_EVENT_CONTEXT_DESKTOP(dc)->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Closing path."));
+ dc->desktop->messageStack()->flash(Inkscape::NORMAL_MESSAGE, _("Closing path."));
if (dc->sa->start && !(dc->sa->curve->is_closed()) ) {
c = reverse_then_unref(c);
}
@@ -671,7 +680,7 @@ void spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed)
c->unref();
}
-static void spdc_flush_white(SPDrawContext *dc, SPCurve *gc)
+static void spdc_flush_white(FreehandBase *dc, SPCurve *gc)
{
SPCurve *c;
@@ -693,9 +702,9 @@ static void spdc_flush_white(SPDrawContext *dc, SPCurve *gc)
// Now we have to go back to item coordinates at last
c->transform( dc->white_item
? (dc->white_item)->dt2i_affine()
- : SP_EVENT_CONTEXT_DESKTOP(dc)->dt2doc() );
+ : dc->desktop->dt2doc() );
- SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(dc);
+ SPDesktop *desktop = dc->desktop;
SPDocument *doc = sp_desktop_document(desktop);
Inkscape::XML::Document *xml_doc = doc->getReprDoc();
@@ -752,7 +761,7 @@ static void spdc_flush_white(SPDrawContext *dc, SPCurve *gc)
doc->ensureUpToDate();
}
-SPDrawAnchor *spdc_test_inside(SPDrawContext *dc, Geom::Point p)
+SPDrawAnchor *spdc_test_inside(FreehandBase *dc, Geom::Point p)
{
SPDrawAnchor *active = NULL;
@@ -771,7 +780,7 @@ SPDrawAnchor *spdc_test_inside(SPDrawContext *dc, Geom::Point p)
return active;
}
-static void spdc_reset_white(SPDrawContext *dc)
+static void spdc_reset_white(FreehandBase *dc)
{
if (dc->white_item) {
// We do not hold refcount
@@ -787,7 +796,7 @@ static void spdc_reset_white(SPDrawContext *dc)
}
}
-static void spdc_free_colors(SPDrawContext *dc)
+static void spdc_free_colors(FreehandBase *dc)
{
// Red
if (dc->red_bpath) {
@@ -834,11 +843,11 @@ static void spdc_free_colors(SPDrawContext *dc)
}
}
-void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char const *tool, guint event_state) {
+void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *tool, guint event_state) {
g_return_if_fail(!strcmp(tool, "/tools/freehand/pen") || !strcmp(tool, "/tools/freehand/pencil"));
Glib::ustring tool_path = tool;
- SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(ec);
+ SPDesktop *desktop = ec->desktop;
Inkscape::XML::Document *xml_doc = desktop->doc()->getReprDoc();
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
repr->setAttribute("sodipodi:type", "arc");
@@ -897,6 +906,10 @@ void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char cons
DocumentUndo::done(sp_desktop_document(desktop), SP_VERB_NONE, _("Create single dot"));
}
+}
+}
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/draw-context.h b/src/ui/tools/freehand-base.h
index 534c706d6..7e53684e3 100644
--- a/src/draw-context.h
+++ b/src/ui/tools/freehand-base.h
@@ -17,13 +17,13 @@
#include <stddef.h>
#include <sigc++/sigc++.h>
#include <2geom/point.h>
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "live_effects/effect.h"
/* Freehand context */
-#define SP_DRAW_CONTEXT(obj) (dynamic_cast<SPDrawContext*>((SPEventContext*)obj))
-#define SP_IS_DRAW_CONTEXT(obj) (dynamic_cast<const SPDrawContext*>((const SPEventContext*)obj) != NULL)
+#define SP_DRAW_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::FreehandBase*>((Inkscape::UI::Tools::ToolBase*)obj))
+#define SP_IS_DRAW_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::FreehandBase*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL)
struct SPDrawAnchor;
namespace Inkscape
@@ -31,10 +31,14 @@ namespace Inkscape
class Selection;
}
-class SPDrawContext : public SPEventContext {
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class FreehandBase : public ToolBase {
public:
- SPDrawContext();
- virtual ~SPDrawContext();
+ FreehandBase();
+ virtual ~FreehandBase();
Inkscape::Selection *selection;
SPCanvasItem *grab;
@@ -90,14 +94,14 @@ protected:
/**
* Returns FIRST active anchor (the activated one).
*/
-SPDrawAnchor *spdc_test_inside(SPDrawContext *dc, Geom::Point p);
+SPDrawAnchor *spdc_test_inside(FreehandBase *dc, Geom::Point p);
/**
* Concats red, blue and green.
* If any anchors are defined, process these, optionally removing curves from white list
* Invoke _flush_white to write result back to object.
*/
-void spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed);
+void spdc_concat_colors_and_flush(FreehandBase *dc, gboolean forceclosed);
/**
* Snaps node or handle to PI/rotationsnapsperpi degree increments.
@@ -107,20 +111,24 @@ void spdc_concat_colors_and_flush(SPDrawContext *dc, gboolean forceclosed);
* @param o origin point.
* @param state keyboard state to check if ctrl or shift was pressed.
*/
-void spdc_endpoint_snap_rotation(SPEventContext const *const ec, Geom::Point &p, Geom::Point const &o, guint state);
+void spdc_endpoint_snap_rotation(ToolBase const *const ec, Geom::Point &p, Geom::Point const &o, guint state);
-void spdc_endpoint_snap_free(SPEventContext const *ec, Geom::Point &p, boost::optional<Geom::Point> &start_of_line, guint state);
+void spdc_endpoint_snap_free(ToolBase const *ec, Geom::Point &p, boost::optional<Geom::Point> &start_of_line, guint state);
/**
* If we have an item and a waiting LPE, apply the effect to the item
* (spiro spline mode is treated separately).
*/
-void spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item);
+void spdc_check_for_and_apply_waiting_LPE(FreehandBase *dc, SPItem *item);
/**
* Create a single dot represented by a circle.
*/
-void spdc_create_single_dot(SPEventContext *ec, Geom::Point const &pt, char const *tool, guint event_state);
+void spdc_create_single_dot(ToolBase *ec, Geom::Point const &pt, char const *tool, guint event_state);
+
+}
+}
+}
#endif // SEEN_SP_DRAW_CONTEXT_H
diff --git a/src/gradient-context.cpp b/src/ui/tools/gradient-tool.cpp
index 3456f33c3..e4ab7b424 100644
--- a/src/gradient-context.cpp
+++ b/src/ui/tools/gradient-tool.cpp
@@ -28,7 +28,7 @@
#include "message-stack.h"
#include "pixmaps/cursor-gradient.xpm"
#include "pixmaps/cursor-gradient-add.xpm"
-#include "gradient-context.h"
+#include "ui/tools/gradient-tool.h"
#include "gradient-chemistry.h"
#include <glibmm/i18n.h>
#include "preferences.h"
@@ -51,27 +51,30 @@
using Inkscape::DocumentUndo;
-static void sp_gradient_drag(SPGradientContext &rc, Geom::Point const pt, guint state, guint32 etime);
+#include "tool-factory.h"
+namespace Inkscape {
+namespace UI {
+namespace Tools {
-#include "tool-factory.h"
+static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint state, guint32 etime);
namespace {
- SPEventContext* createGradientContext() {
- return new SPGradientContext();
+ ToolBase* createGradientContext() {
+ return new GradientTool();
}
bool gradientContextRegistered = ToolFactory::instance().registerObject("/tools/gradient", createGradientContext);
}
-const std::string& SPGradientContext::getPrefsPath() {
- return SPGradientContext::prefsPath;
+const std::string& GradientTool::getPrefsPath() {
+ return GradientTool::prefsPath;
}
-const std::string SPGradientContext::prefsPath = "/tools/gradient";
+const std::string GradientTool::prefsPath = "/tools/gradient";
-SPGradientContext::SPGradientContext() : SPEventContext() {
+GradientTool::GradientTool() : ToolBase() {
this->node_added = false;
this->subselcon = 0;
this->selcon = 0;
@@ -87,7 +90,7 @@ SPGradientContext::SPGradientContext() : SPEventContext() {
this->item_to_select = NULL;
}
-SPGradientContext::~SPGradientContext() {
+GradientTool::~GradientTool() {
this->enableGrDrag(false);
this->selcon->disconnect();
@@ -109,8 +112,8 @@ const gchar *gr_handle_descr [] = {
N_("Radial gradient <b>mid stop</b>")
};
-void SPGradientContext::selection_changed(Inkscape::Selection*) {
- SPGradientContext *rc = (SPGradientContext *) this;
+void GradientTool::selection_changed(Inkscape::Selection*) {
+ GradientTool *rc = (GradientTool *) this;
GrDrag *drag = rc->_grdrag;
Inkscape::Selection *selection = sp_desktop_selection(SP_EVENT_CONTEXT(rc)->desktop);
@@ -158,8 +161,8 @@ void SPGradientContext::selection_changed(Inkscape::Selection*) {
}
}
-void SPGradientContext::setup() {
- SPEventContext::setup();
+void GradientTool::setup() {
+ ToolBase::setup();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -171,12 +174,12 @@ void SPGradientContext::setup() {
Inkscape::Selection *selection = sp_desktop_selection(this->desktop);
this->selcon = new sigc::connection(selection->connectChanged(
- sigc::mem_fun(this, &SPGradientContext::selection_changed)
+ sigc::mem_fun(this, &GradientTool::selection_changed)
));
this->subselcon = new sigc::connection(this->desktop->connectToolSubselectionChanged(
sigc::hide(sigc::bind(
- sigc::mem_fun(this, &SPGradientContext::selection_changed),
+ sigc::mem_fun(this, &GradientTool::selection_changed),
(Inkscape::Selection*)NULL
))
));
@@ -185,7 +188,7 @@ void SPGradientContext::setup() {
}
void
-sp_gradient_context_select_next (SPEventContext *event_context)
+sp_gradient_context_select_next (ToolBase *event_context)
{
GrDrag *drag = event_context->_grdrag;
g_assert (drag);
@@ -196,7 +199,7 @@ sp_gradient_context_select_next (SPEventContext *event_context)
}
void
-sp_gradient_context_select_prev (SPEventContext *event_context)
+sp_gradient_context_select_prev (ToolBase *event_context)
{
GrDrag *drag = event_context->_grdrag;
g_assert (drag);
@@ -207,7 +210,7 @@ sp_gradient_context_select_prev (SPEventContext *event_context)
}
static bool
-sp_gradient_context_is_over_line (SPGradientContext *rc, SPItem *item, Geom::Point event_p)
+sp_gradient_context_is_over_line (GradientTool *rc, SPItem *item, Geom::Point event_p)
{
SPDesktop *desktop = SP_EVENT_CONTEXT (rc)->desktop;
@@ -311,7 +314,7 @@ sp_gradient_context_get_stop_intervals (GrDrag *drag, GSList **these_stops, GSLi
}
void
-sp_gradient_context_add_stops_between_selected_stops (SPGradientContext *rc)
+sp_gradient_context_add_stops_between_selected_stops (GradientTool *rc)
{
SPDocument *doc = NULL;
GrDrag *drag = rc->_grdrag;
@@ -383,7 +386,7 @@ sp_gradient_context_add_stops_between_selected_stops (SPGradientContext *rc)
static double sqr(double x) {return x*x;}
static void
-sp_gradient_simplify(SPGradientContext *rc, double tolerance)
+sp_gradient_simplify(GradientTool *rc, double tolerance)
{
SPDocument *doc = NULL;
GrDrag *drag = rc->_grdrag;
@@ -449,11 +452,11 @@ sp_gradient_simplify(SPGradientContext *rc, double tolerance)
static void
-sp_gradient_context_add_stop_near_point (SPGradientContext *rc, SPItem *item, Geom::Point mouse_p, guint32 /*etime*/)
+sp_gradient_context_add_stop_near_point (GradientTool *rc, SPItem *item, Geom::Point mouse_p, guint32 /*etime*/)
{
// item is the selected item. mouse_p the location in doc coordinates of where to add the stop
- SPEventContext *ec = SP_EVENT_CONTEXT(rc);
+ ToolBase *ec = SP_EVENT_CONTEXT(rc);
SPDesktop *desktop = SP_EVENT_CONTEXT (rc)->desktop;
double tolerance = (double) ec->tolerance;
@@ -468,7 +471,7 @@ sp_gradient_context_add_stop_near_point (SPGradientContext *rc, SPItem *item, G
ec->get_drag()->selectByStop(newstop);
}
-bool SPGradientContext::root_handler(GdkEvent* event) {
+bool GradientTool::root_handler(GdkEvent* event) {
static bool dragging;
Inkscape::Selection *selection = sp_desktop_selection (desktop);
@@ -879,18 +882,18 @@ bool SPGradientContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPEventContext::root_handler(event);
+ ret = ToolBase::root_handler(event);
}
return ret;
}
-static void sp_gradient_drag(SPGradientContext &rc, Geom::Point const pt, guint /*state*/, guint32 etime)
+static void sp_gradient_drag(GradientTool &rc, Geom::Point const pt, guint /*state*/, guint32 etime)
{
SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop;
Inkscape::Selection *selection = sp_desktop_selection(desktop);
SPDocument *document = sp_desktop_document(desktop);
- SPEventContext *ec = SP_EVENT_CONTEXT(&rc);
+ ToolBase *ec = SP_EVENT_CONTEXT(&rc);
if (!selection->isEmpty()) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -957,6 +960,10 @@ static void sp_gradient_drag(SPGradientContext &rc, Geom::Point const pt, guint
}
}
+}
+}
+}
+
/*
Local Variables:
diff --git a/src/gradient-context.h b/src/ui/tools/gradient-tool.h
index 7a2918f3d..6fe3bca9f 100644
--- a/src/gradient-context.h
+++ b/src/ui/tools/gradient-tool.h
@@ -17,15 +17,19 @@
#include <stddef.h>
#include <sigc++/sigc++.h>
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
-#define SP_GRADIENT_CONTEXT(obj) (dynamic_cast<SPGradientContext*>((SPEventContext*)obj))
-#define SP_IS_GRADIENT_CONTEXT(obj) (dynamic_cast<const SPGradientContext*>((const SPEventContext*)obj) != NULL)
+#define SP_GRADIENT_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::GradientTool*>((Inkscape::UI::Tools::ToolBase*)obj))
+#define SP_IS_GRADIENT_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::GradientTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL)
-class SPGradientContext : public SPEventContext {
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class GradientTool : public ToolBase {
public:
- SPGradientContext();
- virtual ~SPGradientContext();
+ GradientTool();
+ virtual ~GradientTool();
Geom::Point origin;
@@ -49,9 +53,13 @@ private:
void selection_changed(Inkscape::Selection*);
};
-void sp_gradient_context_select_next (SPEventContext *event_context);
-void sp_gradient_context_select_prev (SPEventContext *event_context);
-void sp_gradient_context_add_stops_between_selected_stops (SPGradientContext *rc);
+void sp_gradient_context_select_next (ToolBase *event_context);
+void sp_gradient_context_select_prev (ToolBase *event_context);
+void sp_gradient_context_add_stops_between_selected_stops (GradientTool *rc);
+
+}
+}
+}
#endif
diff --git a/src/lpe-tool-context.cpp b/src/ui/tools/lpe-tool.cpp
index bf912746e..a5406f1c5 100644
--- a/src/lpe-tool-context.cpp
+++ b/src/ui/tools/lpe-tool.cpp
@@ -39,11 +39,10 @@
#include "sp-path.h"
#include "util/units.h"
-#include "lpe-tool-context.h"
+#include "ui/tools/lpe-tool.h"
using Inkscape::Util::unit_table;
-
-void sp_lpetool_context_selection_changed(Inkscape::Selection *selection, gpointer data);
+using Inkscape::UI::Tools::PenTool;
const int num_subtools = 8;
@@ -62,21 +61,27 @@ SubtoolEntry lpesubtools[] = {
#include "tool-factory.h"
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+void sp_lpetool_context_selection_changed(Inkscape::Selection *selection, gpointer data);
+
namespace {
- SPEventContext* createLPEToolContext() {
- return new SPLPEToolContext();
+ ToolBase* createLPEToolContext() {
+ return new LpeTool();
}
bool lpetoolContextRegistered = ToolFactory::instance().registerObject("/tools/lpetool", createLPEToolContext);
}
-const std::string& SPLPEToolContext::getPrefsPath() {
- return SPLPEToolContext::prefsPath;
+const std::string& LpeTool::getPrefsPath() {
+ return LpeTool::prefsPath;
}
-const std::string SPLPEToolContext::prefsPath = "/tools/lpetool";
+const std::string LpeTool::prefsPath = "/tools/lpetool";
-SPLPEToolContext::SPLPEToolContext() : SPPenContext() {
+LpeTool::LpeTool() : PenTool() {
this->mode = Inkscape::LivePathEffect::BEND_PATH;
this->shape_editor = 0;
@@ -88,7 +93,7 @@ SPLPEToolContext::SPLPEToolContext() : SPPenContext() {
this->measuring_items = new std::map<SPPath *, SPCanvasItem*>;
}
-SPLPEToolContext::~SPLPEToolContext() {
+LpeTool::~LpeTool() {
delete this->shape_editor;
this->shape_editor = NULL;
@@ -104,8 +109,8 @@ SPLPEToolContext::~SPLPEToolContext() {
this->sel_changed_connection.disconnect();
}
-void SPLPEToolContext::setup() {
- SPPenContext::setup();
+void LpeTool::setup() {
+ PenTool::setup();
Inkscape::Selection *selection = sp_desktop_selection (this->desktop);
SPItem *item = selection->singleItem();
@@ -141,21 +146,21 @@ void SPLPEToolContext::setup() {
*/
void sp_lpetool_context_selection_changed(Inkscape::Selection *selection, gpointer data)
{
- SPLPEToolContext *lc = SP_LPETOOL_CONTEXT(data);
+ LpeTool *lc = SP_LPETOOL_CONTEXT(data);
lc->shape_editor->unset_item(SH_KNOTHOLDER);
SPItem *item = selection->singleItem();
lc->shape_editor->set_item(item, SH_KNOTHOLDER);
}
-void SPLPEToolContext::set(const Inkscape::Preferences::Entry& val) {
+void LpeTool::set(const Inkscape::Preferences::Entry& val) {
if (val.getEntryName() == "mode") {
Inkscape::Preferences::get()->setString("/tools/geometric/mode", "drag");
- SP_PEN_CONTEXT(this)->mode = SPPenContext::MODE_DRAG;
+ SP_PEN_CONTEXT(this)->mode = PenTool::MODE_DRAG;
}
}
-bool SPLPEToolContext::item_handler(SPItem* item, GdkEvent* event) {
+bool LpeTool::item_handler(SPItem* item, GdkEvent* event) {
gint ret = FALSE;
switch (event->type) {
@@ -177,21 +182,21 @@ bool SPLPEToolContext::item_handler(SPItem* item, GdkEvent* event) {
}
if (!ret) {
- ret = SPPenContext::item_handler(item, event);
+ ret = PenTool::item_handler(item, event);
}
return ret;
}
-bool SPLPEToolContext::root_handler(GdkEvent* event) {
+bool LpeTool::root_handler(GdkEvent* event) {
Inkscape::Selection *selection = sp_desktop_selection (desktop);
bool ret = false;
if (sp_pen_context_has_waiting_LPE(this)) {
// quit when we are waiting for a LPE to be applied
- //ret = ((SPEventContextClass *) sp_lpetool_context_parent_class)->root_handler(event_context, event);
- return SPPenContext::root_handler(event);
+ //ret = ((ToolBaseClass *) sp_lpetool_context_parent_class)->root_handler(event_context, event);
+ return PenTool::root_handler(event);
}
switch (event->type) {
@@ -222,8 +227,8 @@ bool SPLPEToolContext::root_handler(GdkEvent* event) {
sp_pen_context_wait_for_LPE_mouse_clicks(this, type, Inkscape::LivePathEffect::Effect::acceptsNumClicks(type));
// we pass the mouse click on to pen tool as the first click which it should collect
- //ret = ((SPEventContextClass *) sp_lpetool_context_parent_class)->root_handler(event_context, event);
- ret = SPPenContext::root_handler(event);
+ //ret = ((ToolBaseClass *) sp_lpetool_context_parent_class)->root_handler(event_context, event);
+ ret = PenTool::root_handler(event);
}
break;
@@ -259,7 +264,7 @@ bool SPLPEToolContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPPenContext::root_handler(event);
+ ret = PenTool::root_handler(event);
}
return ret;
@@ -283,7 +288,7 @@ lpetool_mode_to_index(Inkscape::LivePathEffect::EffectType const type) {
* Checks whether an item has a construction applied as LPE and if so returns the index in
* lpesubtools of this construction
*/
-int lpetool_item_has_construction(SPLPEToolContext */*lc*/, SPItem *item)
+int lpetool_item_has_construction(LpeTool */*lc*/, SPItem *item)
{
if (!SP_IS_LPE_ITEM(item)) {
return -1;
@@ -301,7 +306,7 @@ int lpetool_item_has_construction(SPLPEToolContext */*lc*/, SPItem *item)
* a single selected item. Returns whether we succeeded.
*/
bool
-lpetool_try_construction(SPLPEToolContext *lc, Inkscape::LivePathEffect::EffectType const type)
+lpetool_try_construction(LpeTool *lc, Inkscape::LivePathEffect::EffectType const type)
{
Inkscape::Selection *selection = sp_desktop_selection(lc->desktop);
SPItem *item = selection->singleItem();
@@ -315,7 +320,7 @@ lpetool_try_construction(SPLPEToolContext *lc, Inkscape::LivePathEffect::EffectT
}
void
-lpetool_context_switch_mode(SPLPEToolContext *lc, Inkscape::LivePathEffect::EffectType const type)
+lpetool_context_switch_mode(LpeTool *lc, Inkscape::LivePathEffect::EffectType const type)
{
int index = lpetool_mode_to_index(type);
if (index != -1) {
@@ -347,7 +352,7 @@ lpetool_get_limiting_bbox_corners(SPDocument *document, Geom::Point &A, Geom::Po
*/
// TODO: Note that currently the bbox is not user-settable; we simply use the page borders
void
-lpetool_context_reset_limiting_bbox(SPLPEToolContext *lc)
+lpetool_context_reset_limiting_bbox(LpeTool *lc)
{
if (lc->canvas_bbox) {
sp_canvas_item_destroy(lc->canvas_bbox);
@@ -391,7 +396,7 @@ set_pos_and_anchor(SPCanvasText *canvas_text, const Geom::Piecewise<Geom::D2<Geo
}
void
-lpetool_create_measuring_items(SPLPEToolContext *lc, Inkscape::Selection *selection)
+lpetool_create_measuring_items(LpeTool *lc, Inkscape::Selection *selection)
{
if (!selection) {
selection = sp_desktop_selection(lc->desktop);
@@ -434,7 +439,7 @@ lpetool_create_measuring_items(SPLPEToolContext *lc, Inkscape::Selection *select
}
void
-lpetool_delete_measuring_items(SPLPEToolContext *lc)
+lpetool_delete_measuring_items(LpeTool *lc)
{
std::map<SPPath *, SPCanvasItem*>::iterator i;
for (i = lc->measuring_items->begin(); i != lc->measuring_items->end(); ++i) {
@@ -444,7 +449,7 @@ lpetool_delete_measuring_items(SPLPEToolContext *lc)
}
void
-lpetool_update_measuring_items(SPLPEToolContext *lc)
+lpetool_update_measuring_items(LpeTool *lc)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
for ( std::map<SPPath *, SPCanvasItem*>::iterator i = lc->measuring_items->begin();
@@ -470,7 +475,7 @@ lpetool_update_measuring_items(SPLPEToolContext *lc)
}
void
-lpetool_show_measuring_info(SPLPEToolContext *lc, bool show)
+lpetool_show_measuring_info(LpeTool *lc, bool show)
{
std::map<SPPath *, SPCanvasItem*>::iterator i;
for (i = lc->measuring_items->begin(); i != lc->measuring_items->end(); ++i) {
@@ -482,6 +487,10 @@ lpetool_show_measuring_info(SPLPEToolContext *lc, bool show)
}
}
+}
+}
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/lpe-tool-context.h b/src/ui/tools/lpe-tool.h
index 0e9851cdb..df78c205c 100644
--- a/src/lpe-tool-context.h
+++ b/src/ui/tools/lpe-tool.h
@@ -15,10 +15,10 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "pen-context.h"
+#include "ui/tools/pen-tool.h"
-#define SP_LPETOOL_CONTEXT(obj) (dynamic_cast<SPLPEToolContext*>((SPEventContext*)obj))
-#define SP_IS_LPETOOL_CONTEXT(obj) (dynamic_cast<const SPLPEToolContext*>((const SPEventContext*)obj) != NULL)
+#define SP_LPETOOL_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::LpeTool*>((Inkscape::UI::Tools::ToolBase*)obj))
+#define SP_IS_LPETOOL_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::LpeTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL)
/* This is the list of subtools from which the toolbar of the LPETool is built automatically */
extern const int num_subtools;
@@ -41,10 +41,14 @@ class Selection;
class ShapeEditor;
-class SPLPEToolContext : public SPPenContext {
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class LpeTool : public PenTool {
public:
- SPLPEToolContext();
- virtual ~SPLPEToolContext();
+ LpeTool();
+ virtual ~LpeTool();
ShapeEditor* shape_editor;
SPCanvasItem *canvas_bbox;
@@ -67,15 +71,19 @@ protected:
};
int lpetool_mode_to_index(Inkscape::LivePathEffect::EffectType const type);
-int lpetool_item_has_construction(SPLPEToolContext *lc, SPItem *item);
-bool lpetool_try_construction(SPLPEToolContext *lc, Inkscape::LivePathEffect::EffectType const type);
-void lpetool_context_switch_mode(SPLPEToolContext *lc, Inkscape::LivePathEffect::EffectType const type);
+int lpetool_item_has_construction(LpeTool *lc, SPItem *item);
+bool lpetool_try_construction(LpeTool *lc, Inkscape::LivePathEffect::EffectType const type);
+void lpetool_context_switch_mode(LpeTool *lc, Inkscape::LivePathEffect::EffectType const type);
void lpetool_get_limiting_bbox_corners(SPDocument *document, Geom::Point &A, Geom::Point &B);
-void lpetool_context_reset_limiting_bbox(SPLPEToolContext *lc);
-void lpetool_create_measuring_items(SPLPEToolContext *lc, Inkscape::Selection *selection = NULL);
-void lpetool_delete_measuring_items(SPLPEToolContext *lc);
-void lpetool_update_measuring_items(SPLPEToolContext *lc);
-void lpetool_show_measuring_info(SPLPEToolContext *lc, bool show = true);
+void lpetool_context_reset_limiting_bbox(LpeTool *lc);
+void lpetool_create_measuring_items(LpeTool *lc, Inkscape::Selection *selection = NULL);
+void lpetool_delete_measuring_items(LpeTool *lc);
+void lpetool_update_measuring_items(LpeTool *lc);
+void lpetool_show_measuring_info(LpeTool *lc, bool show = true);
+
+}
+}
+}
#endif // SP_LPETOOL_CONTEXT_H_SEEN
diff --git a/src/measure-context.cpp b/src/ui/tools/measure-tool.cpp
index 7570e36e7..0d823dfda 100644
--- a/src/measure-context.cpp
+++ b/src/ui/tools/measure-tool.cpp
@@ -30,8 +30,8 @@
#include "preferences.h"
#include "inkscape.h"
#include "desktop-handles.h"
-#include "measure-context.h"
-#include "draw-context.h"
+#include "ui/tools/measure-tool.h"
+#include "ui/tools/freehand-base.h"
#include "display/canvas-text.h"
#include "path-chemistry.h"
#include "2geom/line.h"
@@ -48,24 +48,27 @@ using Inkscape::ControlManager;
using Inkscape::CTLINE_SECONDARY;
using Inkscape::Util::unit_table;
-std::vector<Inkscape::Display::TemporaryItem*> measure_tmp_items;
+#include "tool-factory.h"
+namespace Inkscape {
+namespace UI {
+namespace Tools {
-#include "tool-factory.h"
+std::vector<Inkscape::Display::TemporaryItem*> measure_tmp_items;
namespace {
- SPEventContext* createMeasureContext() {
- return new SPMeasureContext();
+ ToolBase* createMeasureContext() {
+ return new MeasureTool();
}
bool measureContextRegistered = ToolFactory::instance().registerObject("/tools/measure", createMeasureContext);
}
-const std::string& SPMeasureContext::getPrefsPath() {
- return SPMeasureContext::prefsPath;
+const std::string& MeasureTool::getPrefsPath() {
+ return MeasureTool::prefsPath;
}
-const std::string SPMeasureContext::prefsPath = "/tools/measure";
+const std::string MeasureTool::prefsPath = "/tools/measure";
namespace
{
@@ -233,7 +236,7 @@ void createAngleDisplayCurve(SPDesktop *desktop, Geom::Point const &center, Geom
} // namespace
-SPMeasureContext::SPMeasureContext() : SPEventContext() {
+MeasureTool::MeasureTool() : ToolBase() {
this->grabbed = 0;
this->cursor_shape = cursor_measure_xpm;
@@ -241,10 +244,10 @@ SPMeasureContext::SPMeasureContext() : SPEventContext() {
this->hot_y = 4;
}
-SPMeasureContext::~SPMeasureContext() {
+MeasureTool::~MeasureTool() {
}
-void SPMeasureContext::finish() {
+void MeasureTool::finish() {
this->enableGrDrag(false);
if (this->grabbed) {
@@ -253,22 +256,22 @@ void SPMeasureContext::finish() {
}
}
-//void SPMeasureContext::setup() {
-// SPEventContext* ec = this;
+//void MeasureTool::setup() {
+// ToolBase* ec = this;
//
//// if (SP_EVENT_CONTEXT_CLASS(sp_measure_context_parent_class)->setup) {
//// SP_EVENT_CONTEXT_CLASS(sp_measure_context_parent_class)->setup(ec);
//// }
-// SPEventContext::setup();
+// ToolBase::setup();
//}
-//gint SPMeasureContext::item_handler(SPItem* item, GdkEvent* event) {
+//gint MeasureTool::item_handler(SPItem* item, GdkEvent* event) {
// gint ret = FALSE;
//
//// if (SP_EVENT_CONTEXT_CLASS(sp_measure_context_parent_class)->item_handler) {
//// ret = SP_EVENT_CONTEXT_CLASS(sp_measure_context_parent_class)->item_handler(event_context, item, event);
//// }
-// ret = SPEventContext::item_handler(item, event);
+// ret = ToolBase::item_handler(item, event);
//
// return ret;
//}
@@ -308,7 +311,7 @@ static void calculate_intersections(SPDesktop * /*desktop*/, SPItem* item, Geom:
}
}
-bool SPMeasureContext::root_handler(GdkEvent* event) {
+bool MeasureTool::root_handler(GdkEvent* event) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
@@ -752,12 +755,16 @@ bool SPMeasureContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPEventContext::root_handler(event);
+ ret = ToolBase::root_handler(event);
}
return ret;
}
+}
+}
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/measure-context.h b/src/ui/tools/measure-tool.h
index 7d5a88ab7..9701ba6ea 100644
--- a/src/measure-context.h
+++ b/src/ui/tools/measure-tool.h
@@ -12,17 +12,21 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include <2geom/point.h>
#include <boost/optional.hpp>
-#define SP_MEASURE_CONTEXT(obj) (dynamic_cast<SPMeasureContext*>((SPEventContext*)obj))
-#define SP_IS_MEASURE_CONTEXT(obj) (dynamic_cast<const SPMeasureContext*>((const SPEventContext*)obj) != NULL)
+#define SP_MEASURE_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::MeasureTool*>((Inkscape::UI::Tools::ToolBase*)obj))
+#define SP_IS_MEASURE_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::MeasureTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL)
-class SPMeasureContext : public SPEventContext {
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class MeasureTool : public ToolBase {
public:
- SPMeasureContext();
- virtual ~SPMeasureContext();
+ MeasureTool();
+ virtual ~MeasureTool();
static const std::string prefsPath;
@@ -39,4 +43,8 @@ private:
boost::optional<Geom::Point> lastEnd;
};
+}
+}
+}
+
#endif // SEEN_SP_MEASURING_CONTEXT_H
diff --git a/src/mesh-context.cpp b/src/ui/tools/mesh-tool.cpp
index 142c3d2b1..4e7617f44 100644
--- a/src/mesh-context.cpp
+++ b/src/ui/tools/mesh-tool.cpp
@@ -47,32 +47,35 @@
#include "pixmaps/cursor-gradient-add.xpm"
// Mesh specific
-#include "mesh-context.h"
+#include "ui/tools/mesh-tool.h"
#include "sp-mesh-gradient.h"
#include "display/sp-ctrlcurve.h"
using Inkscape::DocumentUndo;
-static void sp_mesh_drag(SPMeshContext &rc, Geom::Point const pt, guint state, guint32 etime);
+#include "tool-factory.h"
+namespace Inkscape {
+namespace UI {
+namespace Tools {
-#include "tool-factory.h"
+static void sp_mesh_drag(MeshTool &rc, Geom::Point const pt, guint state, guint32 etime);
namespace {
- SPEventContext* createMeshContext() {
- return new SPMeshContext();
+ ToolBase* createMeshContext() {
+ return new MeshTool();
}
bool meshContextRegistered = ToolFactory::instance().registerObject("/tools/mesh", createMeshContext);
}
-const std::string& SPMeshContext::getPrefsPath() {
- return SPMeshContext::prefsPath;
+const std::string& MeshTool::getPrefsPath() {
+ return MeshTool::prefsPath;
}
-const std::string SPMeshContext::prefsPath = "/tools/mesh";
+const std::string MeshTool::prefsPath = "/tools/mesh";
-SPMeshContext::SPMeshContext() : SPEventContext() {
+MeshTool::MeshTool() : ToolBase() {
this->selcon = 0;
this->node_added = false;
this->subselcon = 0;
@@ -88,7 +91,7 @@ SPMeshContext::SPMeshContext() : SPEventContext() {
this->item_to_select = NULL;
}
-SPMeshContext::~SPMeshContext() {
+MeshTool::~MeshTool() {
this->enableGrDrag(false);
this->selcon->disconnect();
@@ -104,7 +107,7 @@ const gchar *ms_handle_descr [] = {
N_("Mesh gradient <b>tensor</b>")
};
-void SPMeshContext::selection_changed(Inkscape::Selection* /*sel*/) {
+void MeshTool::selection_changed(Inkscape::Selection* /*sel*/) {
GrDrag *drag = this->_grdrag;
Inkscape::Selection *selection = sp_desktop_selection(this->desktop);
@@ -224,8 +227,8 @@ void SPMeshContext::selection_changed(Inkscape::Selection* /*sel*/) {
// }
}
-void SPMeshContext::setup() {
- SPEventContext::setup();
+void MeshTool::setup() {
+ ToolBase::setup();
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/tools/mesh/selcue", true)) {
@@ -236,12 +239,12 @@ void SPMeshContext::setup() {
Inkscape::Selection *selection = sp_desktop_selection(this->desktop);
this->selcon = new sigc::connection(selection->connectChanged(
- sigc::mem_fun(this, &SPMeshContext::selection_changed)
+ sigc::mem_fun(this, &MeshTool::selection_changed)
));
this->subselcon = new sigc::connection(this->desktop->connectToolSubselectionChanged(
sigc::hide(sigc::bind(
- sigc::mem_fun(*this, &SPMeshContext::selection_changed),
+ sigc::mem_fun(*this, &MeshTool::selection_changed),
(Inkscape::Selection*)NULL)
)
));
@@ -250,7 +253,7 @@ void SPMeshContext::setup() {
}
void
-sp_mesh_context_select_next (SPEventContext *event_context)
+sp_mesh_context_select_next (ToolBase *event_context)
{
GrDrag *drag = event_context->_grdrag;
g_assert (drag);
@@ -261,7 +264,7 @@ sp_mesh_context_select_next (SPEventContext *event_context)
}
void
-sp_mesh_context_select_prev (SPEventContext *event_context)
+sp_mesh_context_select_prev (ToolBase *event_context)
{
GrDrag *drag = event_context->_grdrag;
g_assert (drag);
@@ -275,7 +278,7 @@ sp_mesh_context_select_prev (SPEventContext *event_context)
Returns true if mouse cursor over mesh edge.
*/
static bool
-sp_mesh_context_is_over_line (SPMeshContext *rc, SPItem *item, Geom::Point event_p)
+sp_mesh_context_is_over_line (MeshTool *rc, SPItem *item, Geom::Point event_p)
{
SPDesktop *desktop = SP_EVENT_CONTEXT (rc)->desktop;
@@ -300,7 +303,7 @@ sp_mesh_context_is_over_line (SPMeshContext *rc, SPItem *item, Geom::Point event
/**
Split row/column near the mouse point.
*/
-static void sp_mesh_context_split_near_point(SPMeshContext *rc, SPItem *item, Geom::Point mouse_p, guint32 /*etime*/)
+static void sp_mesh_context_split_near_point(MeshTool *rc, SPItem *item, Geom::Point mouse_p, guint32 /*etime*/)
{
#ifdef DEBUG_MESH
@@ -309,7 +312,7 @@ static void sp_mesh_context_split_near_point(SPMeshContext *rc, SPItem *item, G
// item is the selected item. mouse_p the location in doc coordinates of where to add the stop
- SPEventContext *ec = SP_EVENT_CONTEXT(rc);
+ ToolBase *ec = SP_EVENT_CONTEXT(rc);
SPDesktop *desktop = SP_EVENT_CONTEXT (rc)->desktop;
double tolerance = (double) ec->tolerance;
@@ -326,7 +329,7 @@ static void sp_mesh_context_split_near_point(SPMeshContext *rc, SPItem *item, G
Wrapper for various mesh operations that require a list of selected corner nodes.
*/
static void
-sp_mesh_context_corner_operation (SPMeshContext *rc, MeshCornerOperation operation )
+sp_mesh_context_corner_operation (MeshTool *rc, MeshCornerOperation operation )
{
#ifdef DEBUG_MESH
@@ -436,7 +439,7 @@ sp_mesh_context_corner_operation (SPMeshContext *rc, MeshCornerOperation operati
/**
Handles all keyboard and mouse input for meshs.
*/
-bool SPMeshContext::root_handler(GdkEvent* event) {
+bool MeshTool::root_handler(GdkEvent* event) {
static bool dragging;
Inkscape::Selection *selection = sp_desktop_selection (desktop);
@@ -924,17 +927,17 @@ bool SPMeshContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPEventContext::root_handler(event);
+ ret = ToolBase::root_handler(event);
}
return ret;
}
-static void sp_mesh_drag(SPMeshContext &rc, Geom::Point const /*pt*/, guint /*state*/, guint32 /*etime*/) {
+static void sp_mesh_drag(MeshTool &rc, Geom::Point const /*pt*/, guint /*state*/, guint32 /*etime*/) {
SPDesktop *desktop = SP_EVENT_CONTEXT(&rc)->desktop;
Inkscape::Selection *selection = sp_desktop_selection(desktop);
SPDocument *document = sp_desktop_document(desktop);
- SPEventContext *ec = SP_EVENT_CONTEXT(&rc);
+ ToolBase *ec = SP_EVENT_CONTEXT(&rc);
if (!selection->isEmpty()) {
@@ -998,6 +1001,9 @@ static void sp_mesh_drag(SPMeshContext &rc, Geom::Point const /*pt*/, guint /*st
}
+}
+}
+}
/*
Local Variables:
diff --git a/src/mesh-context.h b/src/ui/tools/mesh-tool.h
index 531587654..d952c9010 100644
--- a/src/mesh-context.h
+++ b/src/ui/tools/mesh-tool.h
@@ -19,15 +19,19 @@
#include <stddef.h>
#include <sigc++/sigc++.h>
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
-#define SP_MESH_CONTEXT(obj) (dynamic_cast<SPMeshContext*>((SPEventContext*)obj))
-#define SP_IS_MESH_CONTEXT(obj) (dynamic_cast<const SPMeshContext*>((const SPEventContext*)obj) != NULL)
+#define SP_MESH_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::MeshTool*>((Inkscape::UI::Tools::ToolBase*)obj))
+#define SP_IS_MESH_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::MeshTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL)
-class SPMeshContext : public SPEventContext {
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class MeshTool : public ToolBase {
public:
- SPMeshContext();
- virtual ~SPMeshContext();
+ MeshTool();
+ virtual ~MeshTool();
Geom::Point origin;
@@ -51,8 +55,12 @@ private:
void selection_changed(Inkscape::Selection* sel);
};
-void sp_mesh_context_select_next(SPEventContext *event_context);
-void sp_mesh_context_select_prev(SPEventContext *event_context);
+void sp_mesh_context_select_next(ToolBase *event_context);
+void sp_mesh_context_select_prev(ToolBase *event_context);
+
+}
+}
+}
#endif // SEEN_SP_MESH_CONTEXT_H
diff --git a/src/ui/tool/node-tool.cpp b/src/ui/tools/node-tool.cpp
index 76e33e506..8a950b528 100644
--- a/src/ui/tool/node-tool.cpp
+++ b/src/ui/tools/node-tool.cpp
@@ -10,7 +10,7 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "curve-drag-point.h"
+#include "ui/tool/curve-drag-point.h"
#include <glib/gi18n.h>
#include "desktop.h"
#include "desktop-handles.h"
@@ -30,7 +30,7 @@
#include "sp-path.h"
#include "sp-text.h"
#include "ui/control-manager.h"
-#include "ui/tool/node-tool.h"
+#include "ui/tools/node-tool.h"
#include "ui/tool/control-point-selection.h"
#include "ui/tool/event-utils.h"
#include "ui/tool/manipulator.h"
@@ -45,7 +45,7 @@
#include <gdk/gdkkeysyms.h>
-/** @struct InkNodeTool
+/** @struct NodeTool
*
* Node tool event context.
*
@@ -104,25 +104,29 @@
using Inkscape::ControlManager;
-SPCanvasGroup *create_control_group(SPDesktop *d);
-
#include "tool-factory.h"
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
namespace {
- SPEventContext* createNodesContext() {
- return new InkNodeTool();
+ ToolBase* createNodesContext() {
+ return new NodeTool();
}
bool nodesContextRegistered = ToolFactory::instance().registerObject("/tools/nodes", createNodesContext);
}
-const std::string& InkNodeTool::getPrefsPath() {
- return InkNodeTool::prefsPath;
+const std::string& NodeTool::getPrefsPath() {
+ return NodeTool::prefsPath;
}
-const std::string InkNodeTool::prefsPath = "/tools/nodes";
+const std::string NodeTool::prefsPath = "/tools/nodes";
+
+SPCanvasGroup *create_control_group(SPDesktop *d);
-InkNodeTool::InkNodeTool() : SPEventContext() {
+NodeTool::NodeTool() : ToolBase() {
this->show_handles = false;
this->single_node_transform_handles = false;
this->show_transform_handles = false;
@@ -159,7 +163,7 @@ void destroy_group(SPCanvasGroup *g)
sp_canvas_item_destroy(SP_CANVAS_ITEM(g));
}
-InkNodeTool::~InkNodeTool() {
+NodeTool::~NodeTool() {
this->enableGrDrag(false);
if (this->flash_tempitem) {
@@ -184,8 +188,8 @@ InkNodeTool::~InkNodeTool() {
destroy_group(this->_transform_handle_group);
}
-void InkNodeTool::setup() {
- SPEventContext::setup();
+void NodeTool::setup() {
+ ToolBase::setup();
this->_path_data = new Inkscape::UI::PathSharedData();
@@ -208,14 +212,14 @@ void InkNodeTool::setup() {
this->_selection_changed_connection.disconnect();
this->_selection_changed_connection =
- selection->connectChanged(sigc::mem_fun(this, &InkNodeTool::selection_changed));
+ selection->connectChanged(sigc::mem_fun(this, &NodeTool::selection_changed));
this->_mouseover_changed_connection.disconnect();
this->_mouseover_changed_connection =
- Inkscape::UI::ControlPoint::signal_mouseover_change.connect(sigc::mem_fun(this, &InkNodeTool::mouseover_changed));
+ Inkscape::UI::ControlPoint::signal_mouseover_change.connect(sigc::mem_fun(this, &NodeTool::mouseover_changed));
this->_sizeUpdatedConn = ControlManager::getManager().connectCtrlSizeChanged(
- sigc::mem_fun(this, &InkNodeTool::handleControlUiStyleChange)
+ sigc::mem_fun(this, &NodeTool::handleControlUiStyleChange)
);
this->_selected_nodes = new Inkscape::UI::ControlPointSelection(this->desktop, this->_transform_handle_group);
@@ -224,8 +228,8 @@ void InkNodeTool::setup() {
this->_multipath = new Inkscape::UI::MultiPathManipulator(data, this->_selection_changed_connection);
- this->_selector->signal_point.connect(sigc::mem_fun(this, &InkNodeTool::select_point));
- this->_selector->signal_area.connect(sigc::mem_fun(this, &InkNodeTool::select_area));
+ this->_selector->signal_point.connect(sigc::mem_fun(this, &NodeTool::select_point));
+ this->_selector->signal_area.connect(sigc::mem_fun(this, &NodeTool::select_area));
this->_multipath->signal_coords_changed.connect(
sigc::bind(
@@ -240,7 +244,7 @@ void InkNodeTool::setup() {
// <=>
// void update_tip(GdkEvent *event)
sigc::hide(sigc::hide(sigc::bind(
- sigc::mem_fun(this, &InkNodeTool::update_tip),
+ sigc::mem_fun(this, &NodeTool::update_tip),
(GdkEvent*)NULL
)))
);
@@ -279,7 +283,7 @@ void InkNodeTool::setup() {
this->desktop->emitToolSubselectionChanged(NULL); // sets the coord entry fields to inactive
}
-void InkNodeTool::set(const Inkscape::Preferences::Entry& value) {
+void NodeTool::set(const Inkscape::Preferences::Entry& value) {
Glib::ustring entry_name = value.getEntryName();
if (entry_name == "show_handles") {
@@ -312,12 +316,12 @@ void InkNodeTool::set(const Inkscape::Preferences::Entry& value) {
this->edit_masks = value.getBool();
this->selection_changed(this->desktop->selection);
} else {
- SPEventContext::set(value);
+ ToolBase::set(value);
}
}
/** Recursively collect ShapeRecords */
-void gather_items(InkNodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::ShapeRole role,
+void gather_items(NodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::ShapeRole role,
std::set<Inkscape::UI::ShapeRecord> &s)
{
using namespace Inkscape::UI;
@@ -358,7 +362,7 @@ void gather_items(InkNodeTool *nt, SPItem *base, SPObject *obj, Inkscape::UI::Sh
}
}
-void InkNodeTool::selection_changed(Inkscape::Selection *sel) {
+void NodeTool::selection_changed(Inkscape::Selection *sel) {
using namespace Inkscape::UI;
std::set<ShapeRecord> shapes;
@@ -405,7 +409,7 @@ void InkNodeTool::selection_changed(Inkscape::Selection *sel) {
this->desktop->updateNow();
}
-bool InkNodeTool::root_handler(GdkEvent* event) {
+bool NodeTool::root_handler(GdkEvent* event) {
/* things to handle here:
* 1. selection of items
* 2. passing events to manipulators
@@ -534,10 +538,10 @@ bool InkNodeTool::root_handler(GdkEvent* event) {
break;
}
- return SPEventContext::root_handler(event);
+ return ToolBase::root_handler(event);
}
-void InkNodeTool::update_tip(GdkEvent *event) {
+void NodeTool::update_tip(GdkEvent *event) {
using namespace Inkscape::UI;
if (event && (event->type == GDK_KEY_PRESS || event->type == GDK_KEY_RELEASE)) {
@@ -603,7 +607,7 @@ void InkNodeTool::update_tip(GdkEvent *event) {
}
}
-void InkNodeTool::select_area(Geom::Rect const &sel, GdkEventButton *event) {
+void NodeTool::select_area(Geom::Rect const &sel, GdkEventButton *event) {
using namespace Inkscape::UI;
if (this->_multipath->empty()) {
@@ -621,7 +625,7 @@ void InkNodeTool::select_area(Geom::Rect const &sel, GdkEventButton *event) {
}
}
-void InkNodeTool::select_point(Geom::Point const &sel, GdkEventButton *event) {
+void NodeTool::select_point(Geom::Point const &sel, GdkEventButton *event) {
using namespace Inkscape::UI; // pull in event helpers
if (!event) {
@@ -659,7 +663,7 @@ void InkNodeTool::select_point(Geom::Point const &sel, GdkEventButton *event) {
}
}
-void InkNodeTool::mouseover_changed(Inkscape::UI::ControlPoint *p) {
+void NodeTool::mouseover_changed(Inkscape::UI::ControlPoint *p) {
using Inkscape::UI::CurveDragPoint;
CurveDragPoint *cdp = dynamic_cast<CurveDragPoint*>(p);
@@ -679,10 +683,14 @@ void InkNodeTool::mouseover_changed(Inkscape::UI::ControlPoint *p) {
}
}
-void InkNodeTool::handleControlUiStyleChange() {
+void NodeTool::handleControlUiStyleChange() {
this->_multipath->updateHandles();
}
+}
+}
+}
+
//} // anonymous namespace
/*
diff --git a/src/ui/tool/node-tool.h b/src/ui/tools/node-tool.h
index c41f50650..4d15ab70e 100644
--- a/src/ui/tool/node-tool.h
+++ b/src/ui/tools/node-tool.h
@@ -13,7 +13,7 @@
#include <boost/ptr_container/ptr_map.hpp>
#include <glib.h>
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
namespace Inkscape {
namespace Display {
@@ -30,13 +30,17 @@ namespace Inkscape {
}
}
-#define INK_NODE_TOOL(obj) (dynamic_cast<InkNodeTool*>((SPEventContext*)obj))
-#define INK_IS_NODE_TOOL(obj) (dynamic_cast<const InkNodeTool*>((const SPEventContext*)obj))
+#define INK_NODE_TOOL(obj) (dynamic_cast<Inkscape::UI::Tools::NodeTool*>((Inkscape::UI::Tools::ToolBase*)obj))
+#define INK_IS_NODE_TOOL(obj) (dynamic_cast<const Inkscape::UI::Tools::NodeTool*>((const Inkscape::UI::Tools::ToolBase*)obj))
-class InkNodeTool : public SPEventContext {
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class NodeTool : public ToolBase {
public:
- InkNodeTool();
- virtual ~InkNodeTool();
+ NodeTool();
+ virtual ~NodeTool();
Inkscape::UI::ControlPointSelection* _selected_nodes;
Inkscape::UI::MultiPathManipulator* _multipath;
@@ -83,6 +87,10 @@ private:
void handleControlUiStyleChange();
};
+}
+}
+}
+
#endif
/*
diff --git a/src/pen-context.cpp b/src/ui/tools/pen-tool.cpp
index 428ebd6d9..dc5e801c0 100644
--- a/src/pen-context.cpp
+++ b/src/ui/tools/pen-tool.cpp
@@ -20,7 +20,7 @@
#include <cstring>
#include <string>
-#include "pen-context.h"
+#include "ui/tools/pen-tool.h"
#include "sp-namedview.h"
#include "desktop.h"
#include "desktop-handles.h"
@@ -42,52 +42,54 @@
#include "context-fns.h"
#include "tools-switch.h"
#include "ui/control-manager.h"
+#include "tool-factory.h"
using Inkscape::ControlManager;
-static void spdc_pen_set_initial_point(SPPenContext *pc, Geom::Point const p);
-static void spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point const p, bool statusbar, guint status = 0);
-static void spdc_pen_set_ctrl(SPPenContext *pc, Geom::Point const p, guint state);
-static void spdc_pen_finish_segment(SPPenContext *pc, Geom::Point p, guint state);
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+static void spdc_pen_set_initial_point(PenTool *pc, Geom::Point const p);
+static void spdc_pen_set_subsequent_point(PenTool *const pc, Geom::Point const p, bool statusbar, guint status = 0);
+static void spdc_pen_set_ctrl(PenTool *pc, Geom::Point const p, guint state);
+static void spdc_pen_finish_segment(PenTool *pc, Geom::Point p, guint state);
-static void spdc_pen_finish(SPPenContext *pc, gboolean closed);
+static void spdc_pen_finish(PenTool *pc, gboolean closed);
-static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const &bevent);
-static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent);
-static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent);
-static gint pen_handle_2button_press(SPPenContext *const pc, GdkEventButton const &bevent);
-static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event);
-static void spdc_reset_colors(SPPenContext *pc);
+static gint pen_handle_button_press(PenTool *const pc, GdkEventButton const &bevent);
+static gint pen_handle_motion_notify(PenTool *const pc, GdkEventMotion const &mevent);
+static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &revent);
+static gint pen_handle_2button_press(PenTool *const pc, GdkEventButton const &bevent);
+static gint pen_handle_key_press(PenTool *const pc, GdkEvent *event);
+static void spdc_reset_colors(PenTool *pc);
-static void pen_disable_events(SPPenContext *const pc);
-static void pen_enable_events(SPPenContext *const pc);
+static void pen_disable_events(PenTool *const pc);
+static void pen_enable_events(PenTool *const pc);
static Geom::Point pen_drag_origin_w(0, 0);
static bool pen_within_tolerance = false;
-static int pen_next_paraxial_direction(const SPPenContext *const pc, Geom::Point const &pt, Geom::Point const &origin, guint state);
-static void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Point &pt, guint const state, bool snap);
+static int pen_next_paraxial_direction(const PenTool *const pc, Geom::Point const &pt, Geom::Point const &origin, guint state);
+static void pen_set_to_nearest_horiz_vert(const PenTool *const pc, Geom::Point &pt, guint const state, bool snap);
static int pen_last_paraxial_dir = 0; // last used direction in horizontal/vertical mode; 0 = horizontal, 1 = vertical
-
-#include "tool-factory.h"
-
namespace {
- SPEventContext* createPenContext() {
- return new SPPenContext();
+ ToolBase* createPenContext() {
+ return new PenTool();
}
bool penContextRegistered = ToolFactory::instance().registerObject("/tools/freehand/pen", createPenContext);
}
-const std::string& SPPenContext::getPrefsPath() {
- return SPPenContext::prefsPath;
+const std::string& PenTool::getPrefsPath() {
+ return PenTool::prefsPath;
}
-const std::string SPPenContext::prefsPath = "/tools/freehand/pen";
+const std::string PenTool::prefsPath = "/tools/freehand/pen";
-SPPenContext::SPPenContext() : SPDrawContext() {
+PenTool::PenTool() : FreehandBase() {
this->polylines_only = false;
this->polylines_paraxial = false;
this->expecting_clicks_for_LPE = 0;
@@ -112,7 +114,7 @@ SPPenContext::SPPenContext() : SPDrawContext() {
this->waiting_item = NULL;
}
-SPPenContext::~SPPenContext() {
+PenTool::~PenTool() {
if (this->c0) {
sp_canvas_item_destroy(this->c0);
this->c0 = NULL;
@@ -136,7 +138,7 @@ SPPenContext::~SPPenContext() {
}
}
-void sp_pen_context_set_polyline_mode(SPPenContext *const pc) {
+void sp_pen_context_set_polyline_mode(PenTool *const pc) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
guint mode = prefs->getInt("/tools/freehand/pen/freehand-mode", 0);
pc->polylines_only = (mode == 2 || mode == 3);
@@ -144,22 +146,22 @@ void sp_pen_context_set_polyline_mode(SPPenContext *const pc) {
}
/**
- * Callback to initialize SPPenContext object.
+ * Callback to initialize PenTool object.
*/
-void SPPenContext::setup() {
- SPDrawContext::setup();
+void PenTool::setup() {
+ FreehandBase::setup();
ControlManager &mgr = ControlManager::getManager();
// Pen indicators
- this->c0 = mgr.createControl(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(this)), Inkscape::CTRL_TYPE_ADJ_HANDLE);
+ this->c0 = mgr.createControl(sp_desktop_controls(this->desktop), Inkscape::CTRL_TYPE_ADJ_HANDLE);
mgr.track(this->c0);
- this->c1 = mgr.createControl(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(this)), Inkscape::CTRL_TYPE_ADJ_HANDLE);
+ this->c1 = mgr.createControl(sp_desktop_controls(this->desktop), Inkscape::CTRL_TYPE_ADJ_HANDLE);
mgr.track(this->c1);
- this->cl0 = mgr.createControlLine(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(this)));
- this->cl1 = mgr.createControlLine(sp_desktop_controls(SP_EVENT_CONTEXT_DESKTOP(this)));
+ this->cl0 = mgr.createControlLine(sp_desktop_controls(this->desktop));
+ this->cl1 = mgr.createControlLine(sp_desktop_controls(this->desktop));
sp_canvas_item_hide(this->c0);
sp_canvas_item_hide(this->c1);
@@ -178,10 +180,10 @@ void SPPenContext::setup() {
}
}
-static void pen_cancel (SPPenContext *const pc)
+static void pen_cancel (PenTool *const pc)
{
pc->num_clicks = 0;
- pc->state = SPPenContext::STOP;
+ pc->state = PenTool::STOP;
spdc_reset_colors(pc);
sp_canvas_item_hide(pc->c0);
sp_canvas_item_hide(pc->c1);
@@ -196,20 +198,20 @@ static void pen_cancel (SPPenContext *const pc)
/**
* Finalization callback.
*/
-void SPPenContext::finish() {
+void PenTool::finish() {
sp_event_context_discard_delayed_snap_event(this);
if (this->npoints != 0) {
pen_cancel(this);
}
- SPDrawContext::finish();
+ FreehandBase::finish();
}
/**
* Callback that sets key to value in pen context.
*/
-void SPPenContext::set(const Inkscape::Preferences::Entry& val) {
+void PenTool::set(const Inkscape::Preferences::Entry& val) {
Glib::ustring name = val.getEntryName();
if (name == "mode") {
@@ -224,7 +226,7 @@ void SPPenContext::set(const Inkscape::Preferences::Entry& val) {
/**
* Snaps new node relative to the previous node.
*/
-static void spdc_endpoint_snap(SPPenContext const *const pc, Geom::Point &p, guint const state)
+static void spdc_endpoint_snap(PenTool const *const pc, Geom::Point &p, guint const state)
{
if ((state & GDK_CONTROL_MASK) && !pc->polylines_paraxial) { //CTRL enables angular snapping
if (pc->npoints > 0) {
@@ -248,7 +250,7 @@ static void spdc_endpoint_snap(SPPenContext const *const pc, Geom::Point &p, gui
/**
* Snaps new node's handle relative to the new node.
*/
-static void spdc_endpoint_snap_handle(SPPenContext const *const pc, Geom::Point &p, guint const state)
+static void spdc_endpoint_snap_handle(PenTool const *const pc, Geom::Point &p, guint const state)
{
g_return_if_fail(( pc->npoints == 2 ||
pc->npoints == 5 ));
@@ -263,7 +265,7 @@ static void spdc_endpoint_snap_handle(SPPenContext const *const pc, Geom::Point
}
}
-bool SPPenContext::item_handler(SPItem* item, GdkEvent* event) {
+bool PenTool::item_handler(SPItem* item, GdkEvent* event) {
gint ret = FALSE;
switch (event->type) {
@@ -278,7 +280,7 @@ bool SPPenContext::item_handler(SPItem* item, GdkEvent* event) {
}
if (!ret) {
- ret = SPDrawContext::item_handler(item, event);
+ ret = FreehandBase::item_handler(item, event);
}
return ret;
@@ -287,7 +289,7 @@ bool SPPenContext::item_handler(SPItem* item, GdkEvent* event) {
/**
* Callback to handle all pen events.
*/
-bool SPPenContext::root_handler(GdkEvent* event) {
+bool PenTool::root_handler(GdkEvent* event) {
gint ret = FALSE;
switch (event->type) {
@@ -316,7 +318,7 @@ bool SPPenContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPDrawContext::root_handler(event);
+ ret = FreehandBase::root_handler(event);
}
return ret;
@@ -325,18 +327,18 @@ bool SPPenContext::root_handler(GdkEvent* event) {
/**
* Handle mouse button press event.
*/
-static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const &bevent)
+static gint pen_handle_button_press(PenTool *const pc, GdkEventButton const &bevent)
{
if (pc->events_disabled) {
// skip event processing if events are disabled
return FALSE;
}
- SPDrawContext * const dc = SP_DRAW_CONTEXT(pc);
- SPDesktop * const desktop = SP_EVENT_CONTEXT_DESKTOP(dc);
+ FreehandBase * const dc = SP_DRAW_CONTEXT(pc);
+ SPDesktop * const desktop = dc->desktop;
Geom::Point const event_w(bevent.x, bevent.y);
Geom::Point event_dt(desktop->w2d(event_w));
- SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
+ ToolBase *event_context = SP_EVENT_CONTEXT(pc);
gint ret = FALSE;
if (bevent.button == 1 && !event_context->space_panning
@@ -363,26 +365,26 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
SPDrawAnchor * const anchor = spdc_test_inside(pc, event_w);
switch (pc->mode) {
- case SPPenContext::MODE_CLICK:
+ case PenTool::MODE_CLICK:
// In click mode we add point on release
switch (pc->state) {
- case SPPenContext::POINT:
- case SPPenContext::CONTROL:
- case SPPenContext::CLOSE:
+ case PenTool::POINT:
+ case PenTool::CONTROL:
+ case PenTool::CLOSE:
break;
- case SPPenContext::STOP:
+ case PenTool::STOP:
// This is allowed, if we just canceled curve
- pc->state = SPPenContext::POINT;
+ pc->state = PenTool::POINT;
break;
default:
break;
}
break;
- case SPPenContext::MODE_DRAG:
+ case PenTool::MODE_DRAG:
switch (pc->state) {
- case SPPenContext::STOP:
+ case PenTool::STOP:
// This is allowed, if we just canceled curve
- case SPPenContext::POINT:
+ case PenTool::POINT:
if (pc->npoints == 0) {
Geom::Point p;
@@ -438,7 +440,7 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
p = anchor->dp;
// we hit an anchor, will finish the curve (either with or without closing)
// in release handler
- pc->state = SPPenContext::CLOSE;
+ pc->state = PenTool::CLOSE;
if (pc->green_anchor && pc->green_anchor->active) {
// we clicked on the current curve start, so close it even if
@@ -455,13 +457,13 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
}
}
- pc->state = pc->polylines_only ? SPPenContext::POINT : SPPenContext::CONTROL;
+ pc->state = pc->polylines_only ? PenTool::POINT : PenTool::CONTROL;
ret = TRUE;
break;
- case SPPenContext::CONTROL:
+ case PenTool::CONTROL:
g_warning("Button down in CONTROL state");
break;
- case SPPenContext::CLOSE:
+ case PenTool::CLOSE:
g_warning("Button down in CLOSE state");
break;
default:
@@ -499,12 +501,12 @@ static gint pen_handle_button_press(SPPenContext *const pc, GdkEventButton const
/**
* Handle motion_notify event.
*/
-static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion const &mevent)
+static gint pen_handle_motion_notify(PenTool *const pc, GdkEventMotion const &mevent)
{
gint ret = FALSE;
- SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
- SPDesktop * const dt = SP_EVENT_CONTEXT_DESKTOP(event_context);
+ ToolBase *event_context = SP_EVENT_CONTEXT(pc);
+ SPDesktop * const dt = event_context->desktop;
if (event_context->space_panning || mevent.state & GDK_BUTTON2_MASK || mevent.state & GDK_BUTTON3_MASK) {
// allow scrolling
@@ -537,9 +539,9 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons
SPDrawAnchor *anchor = spdc_test_inside(pc, event_w);
switch (pc->mode) {
- case SPPenContext::MODE_CLICK:
+ case PenTool::MODE_CLICK:
switch (pc->state) {
- case SPPenContext::POINT:
+ case PenTool::POINT:
if ( pc->npoints != 0 ) {
// Only set point, if we are already appending
spdc_endpoint_snap(pc, p, mevent.state);
@@ -552,23 +554,23 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons
m.unSetup();
}
break;
- case SPPenContext::CONTROL:
- case SPPenContext::CLOSE:
+ case PenTool::CONTROL:
+ case PenTool::CLOSE:
// Placing controls is last operation in CLOSE state
spdc_endpoint_snap(pc, p, mevent.state);
spdc_pen_set_ctrl(pc, p, mevent.state);
ret = TRUE;
break;
- case SPPenContext::STOP:
+ case PenTool::STOP:
// This is perfectly valid
break;
default:
break;
}
break;
- case SPPenContext::MODE_DRAG:
+ case PenTool::MODE_DRAG:
switch (pc->state) {
- case SPPenContext::POINT:
+ case PenTool::POINT:
if ( pc->npoints > 0 ) {
// Only set point, if we are already appending
@@ -604,8 +606,8 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons
}
}
break;
- case SPPenContext::CONTROL:
- case SPPenContext::CLOSE:
+ case PenTool::CONTROL:
+ case PenTool::CLOSE:
// Placing controls is last operation in CLOSE state
// snap the handle
@@ -619,7 +621,7 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons
gobble_motion_events(GDK_BUTTON1_MASK);
ret = TRUE;
break;
- case SPPenContext::STOP:
+ case PenTool::STOP:
// This is perfectly valid
break;
default:
@@ -641,7 +643,7 @@ static gint pen_handle_motion_notify(SPPenContext *const pc, GdkEventMotion cons
/**
* Handle mouse button release event.
*/
-static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton const &revent)
+static gint pen_handle_button_release(PenTool *const pc, GdkEventButton const &revent)
{
if (pc->events_disabled) {
// skip event processing if events are disabled
@@ -649,10 +651,10 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con
}
gint ret = FALSE;
- SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
+ ToolBase *event_context = SP_EVENT_CONTEXT(pc);
if ( revent.button == 1 && !event_context->space_panning) {
- SPDrawContext *dc = SP_DRAW_CONTEXT (pc);
+ FreehandBase *dc = SP_DRAW_CONTEXT (pc);
Geom::Point const event_w(revent.x,
revent.y);
@@ -663,9 +665,9 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con
SPDrawAnchor *anchor = spdc_test_inside(pc, event_w);
switch (pc->mode) {
- case SPPenContext::MODE_CLICK:
+ case PenTool::MODE_CLICK:
switch (pc->state) {
- case SPPenContext::POINT:
+ case PenTool::POINT:
if ( pc->npoints == 0 ) {
// Start new thread only with button release
if (anchor) {
@@ -680,43 +682,43 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con
p = anchor->dp;
}
}
- pc->state = SPPenContext::CONTROL;
+ pc->state = PenTool::CONTROL;
ret = TRUE;
break;
- case SPPenContext::CONTROL:
+ case PenTool::CONTROL:
// End current segment
spdc_endpoint_snap(pc, p, revent.state);
spdc_pen_finish_segment(pc, p, revent.state);
- pc->state = SPPenContext::POINT;
+ pc->state = PenTool::POINT;
ret = TRUE;
break;
- case SPPenContext::CLOSE:
+ case PenTool::CLOSE:
// End current segment
if (!anchor) { // Snap node only if not hitting anchor
spdc_endpoint_snap(pc, p, revent.state);
}
spdc_pen_finish_segment(pc, p, revent.state);
spdc_pen_finish(pc, TRUE);
- pc->state = SPPenContext::POINT;
+ pc->state = PenTool::POINT;
ret = TRUE;
break;
- case SPPenContext::STOP:
+ case PenTool::STOP:
// This is allowed, if we just canceled curve
- pc->state = SPPenContext::POINT;
+ pc->state = PenTool::POINT;
ret = TRUE;
break;
default:
break;
}
break;
- case SPPenContext::MODE_DRAG:
+ case PenTool::MODE_DRAG:
switch (pc->state) {
- case SPPenContext::POINT:
- case SPPenContext::CONTROL:
+ case PenTool::POINT:
+ case PenTool::CONTROL:
spdc_endpoint_snap(pc, p, revent.state);
spdc_pen_finish_segment(pc, p, revent.state);
break;
- case SPPenContext::CLOSE:
+ case PenTool::CLOSE:
spdc_endpoint_snap(pc, p, revent.state);
spdc_pen_finish_segment(pc, p, revent.state);
if (pc->green_closed) {
@@ -727,13 +729,13 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con
spdc_pen_finish(pc, FALSE);
}
break;
- case SPPenContext::STOP:
+ case PenTool::STOP:
// This is allowed, if we just cancelled curve
break;
default:
break;
}
- pc->state = SPPenContext::POINT;
+ pc->state = PenTool::POINT;
ret = TRUE;
break;
default:
@@ -756,7 +758,7 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con
if (pc->expecting_clicks_for_LPE == 0 && sp_pen_context_has_waiting_LPE(pc)) {
sp_pen_context_set_polyline_mode(pc);
- SPEventContext *ec = SP_EVENT_CONTEXT(pc);
+ ToolBase *ec = SP_EVENT_CONTEXT(pc);
Inkscape::Selection *selection = sp_desktop_selection (ec->desktop);
if (pc->waiting_LPE) {
@@ -773,7 +775,7 @@ static gint pen_handle_button_release(SPPenContext *const pc, GdkEventButton con
return ret;
}
-static gint pen_handle_2button_press(SPPenContext *const pc, GdkEventButton const &bevent)
+static gint pen_handle_2button_press(PenTool *const pc, GdkEventButton const &bevent)
{
gint ret = FALSE;
// only end on LMB double click. Otherwise horizontal scrolling causes ending of the path
@@ -784,7 +786,7 @@ static gint pen_handle_2button_press(SPPenContext *const pc, GdkEventButton cons
return ret;
}
-static void pen_redraw_all (SPPenContext *const pc)
+static void pen_redraw_all (PenTool *const pc)
{
// green
if (pc->green_bpaths) {
@@ -838,7 +840,7 @@ static void pen_redraw_all (SPPenContext *const pc)
}
}
-static void pen_lastpoint_move (SPPenContext *const pc, gdouble x, gdouble y)
+static void pen_lastpoint_move (PenTool *const pc, gdouble x, gdouble y)
{
if (pc->npoints != 5)
return;
@@ -859,12 +861,12 @@ static void pen_lastpoint_move (SPPenContext *const pc, gdouble x, gdouble y)
pen_redraw_all(pc);
}
-static void pen_lastpoint_move_screen (SPPenContext *const pc, gdouble x, gdouble y)
+static void pen_lastpoint_move_screen (PenTool *const pc, gdouble x, gdouble y)
{
pen_lastpoint_move (pc, x / pc->desktop->current_zoom(), y / pc->desktop->current_zoom());
}
-static void pen_lastpoint_tocurve (SPPenContext *const pc)
+static void pen_lastpoint_tocurve (PenTool *const pc)
{
if (pc->npoints != 5)
return;
@@ -879,7 +881,7 @@ static void pen_lastpoint_tocurve (SPPenContext *const pc)
pen_redraw_all(pc);
}
-static void pen_lastpoint_toline (SPPenContext *const pc)
+static void pen_lastpoint_toline (PenTool *const pc)
{
if (pc->npoints != 5)
return;
@@ -890,7 +892,7 @@ static void pen_lastpoint_toline (SPPenContext *const pc)
}
-static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event)
+static gint pen_handle_key_press(PenTool *const pc, GdkEvent *event)
{
gint ret = FALSE;
@@ -1075,7 +1077,7 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event)
sp_canvas_item_hide(pc->c1);
sp_canvas_item_hide(pc->cl0);
sp_canvas_item_hide(pc->cl1);
- pc->state = SPPenContext::POINT;
+ pc->state = PenTool::POINT;
spdc_pen_set_subsequent_point(pc, pt, true);
pen_last_paraxial_dir = !pen_last_paraxial_dir;
ret = TRUE;
@@ -1087,7 +1089,7 @@ static gint pen_handle_key_press(SPPenContext *const pc, GdkEvent *event)
return ret;
}
-static void spdc_reset_colors(SPPenContext *pc)
+static void spdc_reset_colors(PenTool *pc)
{
// Red
pc->red_curve->reset();
@@ -1111,7 +1113,7 @@ static void spdc_reset_colors(SPPenContext *pc)
}
-static void spdc_pen_set_initial_point(SPPenContext *const pc, Geom::Point const p)
+static void spdc_pen_set_initial_point(PenTool *const pc, Geom::Point const p)
{
g_assert( pc->npoints == 0 );
@@ -1128,7 +1130,7 @@ static void spdc_pen_set_initial_point(SPPenContext *const pc, Geom::Point const
* This type of message always shows angle/distance as the last
* two parameters ("angle %3.2f&#176;, distance %s").
*/
-static void spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, Geom::Point const p, int pc_point_to_compare, gchar const *message)
+static void spdc_pen_set_angle_distance_status_message(PenTool *const pc, Geom::Point const p, int pc_point_to_compare, gchar const *message)
{
g_assert(pc != NULL);
g_assert((pc_point_to_compare == 0) || (pc_point_to_compare == 3)); // exclude control handles
@@ -1151,7 +1153,7 @@ static void spdc_pen_set_angle_distance_status_message(SPPenContext *const pc, G
g_string_free(dist, FALSE);
}
-static void spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point const p, bool statusbar, guint status)
+static void spdc_pen_set_subsequent_point(PenTool *const pc, Geom::Point const p, bool statusbar, guint status)
{
g_assert( pc->npoints != 0 );
// todo: Check callers to see whether 2 <= npoints is guaranteed.
@@ -1196,7 +1198,7 @@ static void spdc_pen_set_subsequent_point(SPPenContext *const pc, Geom::Point co
}
}
-static void spdc_pen_set_ctrl(SPPenContext *const pc, Geom::Point const p, guint const state)
+static void spdc_pen_set_ctrl(PenTool *const pc, Geom::Point const p, guint const state)
{
sp_canvas_item_show(pc->c1);
sp_canvas_item_show(pc->cl1);
@@ -1214,8 +1216,8 @@ static void spdc_pen_set_ctrl(SPPenContext *const pc, Geom::Point const p, guint
sp_canvas_item_show(pc->c0);
sp_canvas_item_show(pc->cl0);
bool is_symm = false;
- if ( ( ( pc->mode == SPPenContext::MODE_CLICK ) && ( state & GDK_CONTROL_MASK ) ) ||
- ( ( pc->mode == SPPenContext::MODE_DRAG ) && !( state & GDK_SHIFT_MASK ) ) ) {
+ if ( ( ( pc->mode == PenTool::MODE_CLICK ) && ( state & GDK_CONTROL_MASK ) ) ||
+ ( ( pc->mode == PenTool::MODE_DRAG ) && !( state & GDK_SHIFT_MASK ) ) ) {
Geom::Point delta = p - pc->p[3];
pc->p[2] = pc->p[3] - delta;
is_symm = true;
@@ -1238,7 +1240,7 @@ static void spdc_pen_set_ctrl(SPPenContext *const pc, Geom::Point const p, guint
}
}
-static void spdc_pen_finish_segment(SPPenContext *const pc, Geom::Point const p, guint const state)
+static void spdc_pen_finish_segment(PenTool *const pc, Geom::Point const p, guint const state)
{
if (pc->polylines_paraxial) {
pen_last_paraxial_dir = pen_next_paraxial_direction(pc, p, pc->p[0], state);
@@ -1264,7 +1266,7 @@ static void spdc_pen_finish_segment(SPPenContext *const pc, Geom::Point const p,
}
}
-static void spdc_pen_finish(SPPenContext *const pc, gboolean const closed)
+static void spdc_pen_finish(PenTool *const pc, gboolean const closed)
{
if (pc->expecting_clicks_for_LPE > 1) {
// don't let the path be finished before we have collected the required number of mouse clicks
@@ -1285,7 +1287,7 @@ static void spdc_pen_finish(SPPenContext *const pc, gboolean const closed)
pc->ea = NULL;
pc->npoints = 0;
- pc->state = SPPenContext::POINT;
+ pc->state = PenTool::POINT;
sp_canvas_item_hide(pc->c0);
sp_canvas_item_hide(pc->c1);
@@ -1302,17 +1304,17 @@ static void spdc_pen_finish(SPPenContext *const pc, gboolean const closed)
pen_enable_events(pc);
}
-static void pen_disable_events(SPPenContext *const pc) {
+static void pen_disable_events(PenTool *const pc) {
pc->events_disabled++;
}
-static void pen_enable_events(SPPenContext *const pc) {
+static void pen_enable_events(PenTool *const pc) {
g_return_if_fail(pc->events_disabled != 0);
pc->events_disabled--;
}
-void sp_pen_context_wait_for_LPE_mouse_clicks(SPPenContext *pc, Inkscape::LivePathEffect::EffectType effect_type,
+void sp_pen_context_wait_for_LPE_mouse_clicks(PenTool *pc, Inkscape::LivePathEffect::EffectType effect_type,
unsigned int num_clicks, bool use_polylines)
{
if (effect_type == Inkscape::LivePathEffect::INVALID_LPE)
@@ -1324,14 +1326,14 @@ void sp_pen_context_wait_for_LPE_mouse_clicks(SPPenContext *pc, Inkscape::LivePa
pc->polylines_paraxial = false; // TODO: think if this is correct for all cases
}
-void sp_pen_context_cancel_waiting_for_LPE(SPPenContext *pc)
+void sp_pen_context_cancel_waiting_for_LPE(PenTool *pc)
{
pc->waiting_LPE_type = Inkscape::LivePathEffect::INVALID_LPE;
pc->expecting_clicks_for_LPE = 0;
sp_pen_context_set_polyline_mode(pc);
}
-static int pen_next_paraxial_direction(const SPPenContext *const pc,
+static int pen_next_paraxial_direction(const PenTool *const pc,
Geom::Point const &pt, Geom::Point const &origin, guint state) {
//
// after the first mouse click we determine whether the mouse pointer is closest to a
@@ -1355,7 +1357,7 @@ static int pen_next_paraxial_direction(const SPPenContext *const pc,
}
}
-void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Point &pt, guint const state, bool snap)
+void pen_set_to_nearest_horiz_vert(const PenTool *const pc, Geom::Point &pt, guint const state, bool snap)
{
Geom::Point const origin = pc->p[0];
@@ -1386,6 +1388,10 @@ void pen_set_to_nearest_horiz_vert(const SPPenContext *const pc, Geom::Point &pt
}
}
+}
+}
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/pen-context.h b/src/ui/tools/pen-tool.h
index c096865f1..4452dbd68 100644
--- a/src/pen-context.h
+++ b/src/ui/tools/pen-tool.h
@@ -2,24 +2,28 @@
#define SEEN_PEN_CONTEXT_H
/** \file
- * SPPenContext: a context for pen tool events.
+ * PenTool: a context for pen tool events.
*/
-#include "draw-context.h"
+#include "ui/tools/freehand-base.h"
#include "live_effects/effect.h"
-#define SP_PEN_CONTEXT(obj) (dynamic_cast<SPPenContext*>((SPEventContext*)obj))
-#define SP_IS_PEN_CONTEXT(obj) (dynamic_cast<const SPPenContext*>((const SPEventContext*)obj) != NULL)
+#define SP_PEN_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::PenTool*>((Inkscape::UI::Tools::ToolBase*)obj))
+#define SP_IS_PEN_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::PenTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL)
struct SPCtrlLine;
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
/**
- * SPPenContext: a context for pen tool events.
+ * PenTool: a context for pen tool events.
*/
-class SPPenContext : public SPDrawContext {
+class PenTool : public FreehandBase {
public:
- SPPenContext();
- virtual ~SPPenContext();
+ PenTool();
+ virtual ~PenTool();
enum Mode {
MODE_CLICK,
@@ -70,19 +74,23 @@ protected:
virtual bool item_handler(SPItem* item, GdkEvent* event);
};
-inline bool sp_pen_context_has_waiting_LPE(SPPenContext *pc) {
+inline bool sp_pen_context_has_waiting_LPE(PenTool *pc) {
// note: waiting_LPE_type is defined in SPDrawContext
return (pc->waiting_LPE != NULL ||
pc->waiting_LPE_type != Inkscape::LivePathEffect::INVALID_LPE);
}
-void sp_pen_context_set_polyline_mode(SPPenContext *const pc);
-void sp_pen_context_wait_for_LPE_mouse_clicks(SPPenContext *pc, Inkscape::LivePathEffect::EffectType effect_type,
+void sp_pen_context_set_polyline_mode(PenTool *const pc);
+void sp_pen_context_wait_for_LPE_mouse_clicks(PenTool *pc, Inkscape::LivePathEffect::EffectType effect_type,
unsigned int num_clicks, bool use_polylines = true);
-void sp_pen_context_cancel_waiting_for_LPE(SPPenContext *pc);
+void sp_pen_context_cancel_waiting_for_LPE(PenTool *pc);
void sp_pen_context_put_into_waiting_mode(SPDesktop *desktop, Inkscape::LivePathEffect::EffectType effect_type,
unsigned int num_clicks, bool use_polylines = true);
+}
+}
+}
+
#endif /* !SEEN_PEN_CONTEXT_H */
/*
diff --git a/src/pencil-context.cpp b/src/ui/tools/pencil-tool.cpp
index abd9af1d3..52779d551 100644
--- a/src/pencil-context.cpp
+++ b/src/ui/tools/pencil-tool.cpp
@@ -18,7 +18,7 @@
#include <gdk/gdkkeysyms.h>
-#include "pencil-context.h"
+#include "ui/tools/pencil-tool.h"
#include "desktop.h"
#include "desktop-handles.h"
#include "selection.h"
@@ -44,51 +44,54 @@
#include "display/sp-canvas.h"
#include "display/curve.h"
#include "livarot/Path.h"
+#include "tool-factory.h"
+
+namespace Inkscape {
+namespace UI {
+namespace Tools {
-static gint pencil_handle_button_press(SPPencilContext *const pc, GdkEventButton const &bevent);
-static gint pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mevent);
-static gint pencil_handle_button_release(SPPencilContext *const pc, GdkEventButton const &revent);
-static gint pencil_handle_key_press(SPPencilContext *const pc, guint const keyval, guint const state);
-static gint pencil_handle_key_release(SPPencilContext *const pc, guint const keyval, guint const state);
+static gint pencil_handle_button_press(PencilTool *const pc, GdkEventButton const &bevent);
+static gint pencil_handle_motion_notify(PencilTool *const pc, GdkEventMotion const &mevent);
+static gint pencil_handle_button_release(PencilTool *const pc, GdkEventButton const &revent);
+static gint pencil_handle_key_press(PencilTool *const pc, guint const keyval, guint const state);
+static gint pencil_handle_key_release(PencilTool *const pc, guint const keyval, guint const state);
-static void spdc_set_startpoint(SPPencilContext *pc, Geom::Point const &p);
-static void spdc_set_endpoint(SPPencilContext *pc, Geom::Point const &p);
-static void spdc_finish_endpoint(SPPencilContext *pc);
-static void spdc_add_freehand_point(SPPencilContext *pc, Geom::Point const &p, guint state);
-static void fit_and_split(SPPencilContext *pc);
-static void interpolate(SPPencilContext *pc);
-static void sketch_interpolate(SPPencilContext *pc);
+static void spdc_set_startpoint(PencilTool *pc, Geom::Point const &p);
+static void spdc_set_endpoint(PencilTool *pc, Geom::Point const &p);
+static void spdc_finish_endpoint(PencilTool *pc);
+static void spdc_add_freehand_point(PencilTool *pc, Geom::Point const &p, guint state);
+static void fit_and_split(PencilTool *pc);
+static void interpolate(PencilTool *pc);
+static void sketch_interpolate(PencilTool *pc);
static Geom::Point pencil_drag_origin_w(0, 0);
static bool pencil_within_tolerance = false;
static bool in_svg_plane(Geom::Point const &p) { return Geom::LInfty(p) < 1e18; }
-#include "tool-factory.h"
-
namespace {
- SPEventContext* createPencilContext() {
- return new SPPencilContext();
+ ToolBase* createPencilContext() {
+ return new PencilTool();
}
bool pencilContextRegistered = ToolFactory::instance().registerObject("/tools/freehand/pencil", createPencilContext);
}
-const std::string& SPPencilContext::getPrefsPath() {
- return SPPencilContext::prefsPath;
+const std::string& PencilTool::getPrefsPath() {
+ return PencilTool::prefsPath;
}
-const std::string SPPencilContext::prefsPath = "/tools/freehand/pencil";
+const std::string PencilTool::prefsPath = "/tools/freehand/pencil";
-SPPencilContext::SPPencilContext() :
- SPDrawContext(),
+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 SPPencilContext is not properly constructed...
+ sketch_interpolation(Geom::Piecewise<Geom::D2<Geom::SBasis> >())// since PencilTool is not properly constructed...
{
this->cursor_shape = cursor_pencil_xpm;
this->hot_x = 4;
@@ -96,24 +99,24 @@ SPPencilContext::SPPencilContext() :
this->sketch_n = 0;
}
-void SPPencilContext::setup() {
+void PencilTool::setup() {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/tools/freehand/pencil/selcue")) {
this->enableSelectionCue();
}
- SPDrawContext::setup();
+ FreehandBase::setup();
this->is_drawing = false;
this->anchor_statusbar = false;
}
-SPPencilContext::~SPPencilContext() {
+PencilTool::~PencilTool() {
}
/** Snaps new node relative to the previous node. */
static void
-spdc_endpoint_snap(SPPencilContext const *pc, Geom::Point &p, guint const state)
+spdc_endpoint_snap(PencilTool const *pc, Geom::Point &p, guint const state)
{
if ((state & GDK_CONTROL_MASK)) { //CTRL enables constrained snapping
if (pc->npoints > 0) {
@@ -132,7 +135,7 @@ spdc_endpoint_snap(SPPencilContext const *pc, Geom::Point &p, guint const state)
/**
* Callback for handling all pencil context events.
*/
-bool SPPencilContext::root_handler(GdkEvent* event) {
+bool PencilTool::root_handler(GdkEvent* event) {
gint ret = FALSE;
switch (event->type) {
@@ -161,21 +164,21 @@ bool SPPencilContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPDrawContext::root_handler(event);
+ ret = FreehandBase::root_handler(event);
}
return ret;
}
static gint
-pencil_handle_button_press(SPPencilContext *const pc, GdkEventButton const &bevent)
+pencil_handle_button_press(PencilTool *const pc, GdkEventButton const &bevent)
{
gint ret = FALSE;
- SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
+ ToolBase *event_context = SP_EVENT_CONTEXT(pc);
if ( bevent.button == 1 && !event_context->space_panning) {
- SPDrawContext *dc = SP_DRAW_CONTEXT (pc);
- SPDesktop *desktop = SP_EVENT_CONTEXT_DESKTOP(dc);
+ FreehandBase *dc = SP_DRAW_CONTEXT (pc);
+ SPDesktop *desktop = dc->desktop;
Inkscape::Selection *selection = sp_desktop_selection(desktop);
if (Inkscape::have_viable_layer(desktop, dc->message_context) == false) {
@@ -251,7 +254,7 @@ pencil_handle_button_press(SPPencilContext *const pc, GdkEventButton const &beve
}
static gint
-pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mevent)
+pencil_handle_motion_notify(PencilTool *const pc, GdkEventMotion const &mevent)
{
SPDesktop *const dt = pc->desktop;
@@ -263,7 +266,7 @@ pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mev
}
gint ret = FALSE;
- SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
+ ToolBase *event_context = SP_EVENT_CONTEXT(pc);
if (event_context->space_panning || mevent.state & GDK_BUTTON2_MASK || mevent.state & GDK_BUTTON3_MASK) {
// allow scrolling
return FALSE;
@@ -373,11 +376,11 @@ pencil_handle_motion_notify(SPPencilContext *const pc, GdkEventMotion const &mev
}
static gint
-pencil_handle_button_release(SPPencilContext *const pc, GdkEventButton const &revent)
+pencil_handle_button_release(PencilTool *const pc, GdkEventButton const &revent)
{
gint ret = FALSE;
- SPEventContext *event_context = SP_EVENT_CONTEXT(pc);
+ ToolBase *event_context = SP_EVENT_CONTEXT(pc);
if ( revent.button == 1 && pc->is_drawing && !event_context->space_panning) {
SPDesktop *const dt = pc->desktop;
@@ -474,7 +477,7 @@ pencil_handle_button_release(SPPencilContext *const pc, GdkEventButton const &re
}
static void
-pencil_cancel (SPPencilContext *const pc)
+pencil_cancel (PencilTool *const pc)
{
if (pc->grab) {
/* Release grab now */
@@ -504,7 +507,7 @@ pencil_cancel (SPPencilContext *const pc)
}
static gint
-pencil_handle_key_press(SPPencilContext *const pc, guint const keyval, guint const state)
+pencil_handle_key_press(PencilTool *const pc, guint const keyval, guint const state)
{
gint ret = FALSE;
switch (keyval) {
@@ -558,7 +561,7 @@ pencil_handle_key_press(SPPencilContext *const pc, guint const keyval, guint con
}
static gint
-pencil_handle_key_release(SPPencilContext *const pc, guint const keyval, guint const /*state*/)
+pencil_handle_key_release(PencilTool *const pc, guint const keyval, guint const /*state*/)
{
gint ret = FALSE;
switch (keyval) {
@@ -590,7 +593,7 @@ pencil_handle_key_release(SPPencilContext *const pc, guint const keyval, guint c
* Reset points and set new starting point.
*/
static void
-spdc_set_startpoint(SPPencilContext *const pc, Geom::Point const &p)
+spdc_set_startpoint(PencilTool *const pc, Geom::Point const &p)
{
pc->npoints = 0;
pc->red_curve_is_valid = false;
@@ -610,7 +613,7 @@ spdc_set_startpoint(SPPencilContext *const pc, Geom::Point const &p)
* We change RED curve.
*/
static void
-spdc_set_endpoint(SPPencilContext *const pc, Geom::Point const &p)
+spdc_set_endpoint(PencilTool *const pc, Geom::Point const &p)
{
if (pc->npoints == 0) {
return;
@@ -645,7 +648,7 @@ spdc_set_endpoint(SPPencilContext *const pc, Geom::Point const &p)
* Still not sure, how it will make most sense.
*/
static void
-spdc_finish_endpoint(SPPencilContext *const pc)
+spdc_finish_endpoint(PencilTool *const pc)
{
if ( ( pc->red_curve->is_empty() )
|| ( *(pc->red_curve->first_point()) == *(pc->red_curve->second_point()) ) )
@@ -662,7 +665,7 @@ spdc_finish_endpoint(SPPencilContext *const pc)
static void
-spdc_add_freehand_point(SPPencilContext *pc, Geom::Point const &p, guint /*state*/)
+spdc_add_freehand_point(PencilTool *pc, Geom::Point const &p, guint /*state*/)
{
g_assert( pc->npoints > 0 );
g_return_if_fail(unsigned(pc->npoints) < G_N_ELEMENTS(pc->p));
@@ -683,7 +686,7 @@ square(double const x)
}
static void
-interpolate(SPPencilContext *pc)
+interpolate(PencilTool *pc)
{
if ( pc->ps.size() <= 1 ) {
return;
@@ -749,7 +752,7 @@ interpolate(SPPencilContext *pc)
/* interpolates the sketched curve and tweaks the current sketch interpolation*/
static void
-sketch_interpolate(SPPencilContext *pc)
+sketch_interpolate(PencilTool *pc)
{
if ( pc->ps.size() <= 1 ) {
return;
@@ -841,7 +844,7 @@ sketch_interpolate(SPPencilContext *pc)
}
static void
-fit_and_split(SPPencilContext *pc)
+fit_and_split(PencilTool *pc)
{
g_assert( pc->npoints > 1 );
@@ -897,6 +900,9 @@ fit_and_split(SPPencilContext *pc)
}
}
+}
+}
+}
/*
Local Variables:
diff --git a/src/pencil-context.h b/src/ui/tools/pencil-tool.h
index b3ded0242..6ced9eb56 100644
--- a/src/pencil-context.h
+++ b/src/ui/tools/pencil-tool.h
@@ -2,13 +2,17 @@
#define SEEN_PENCIL_CONTEXT_H
/** \file
- * SPPencilContext: a context for pencil tool events
+ * PencilTool: a context for pencil tool events
*/
-#include "draw-context.h"
+#include "ui/tools/freehand-base.h"
-#define SP_PENCIL_CONTEXT(obj) (dynamic_cast<SPPencilContext*>((SPEventContext*)obj))
-#define SP_IS_PENCIL_CONTEXT(obj) (dynamic_cast<const SPPencilContext*>((const SPEventContext*)obj) != NULL)
+#define SP_PENCIL_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::PencilTool*>((ToolBase*)obj))
+#define SP_IS_PENCIL_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::PencilTool*>((const ToolBase*)obj) != NULL)
+
+namespace Inkscape {
+namespace UI {
+namespace Tools {
enum PencilState {
SP_PENCIL_CONTEXT_IDLE,
@@ -18,12 +22,12 @@ enum PencilState {
};
/**
- * SPPencilContext: a context for pencil tool events
+ * PencilTool: a context for pencil tool events
*/
-class SPPencilContext : public SPDrawContext {
+class PencilTool : public FreehandBase {
public:
- SPPencilContext();
- virtual ~SPPencilContext();
+ PencilTool();
+ virtual ~PencilTool();
Geom::Point p[16];
gint npoints;
@@ -46,6 +50,10 @@ protected:
virtual bool root_handler(GdkEvent* event);
};
+}
+}
+}
+
#endif /* !SEEN_PENCIL_CONTEXT_H */
/*
diff --git a/src/rect-context.cpp b/src/ui/tools/rect-tool.cpp
index a0e751359..263fdea84 100644
--- a/src/rect-context.cpp
+++ b/src/ui/tools/rect-tool.cpp
@@ -34,7 +34,7 @@
#include "desktop-style.h"
#include "message-context.h"
#include "pixmaps/cursor-rect.xpm"
-#include "rect-context.h"
+#include "ui/tools/rect-tool.h"
#include <glibmm/i18n.h>
#include "xml/repr.h"
#include "xml/node-event-vector.h"
@@ -48,21 +48,25 @@ using Inkscape::DocumentUndo;
#include "tool-factory.h"
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
namespace {
- SPEventContext* createRectContext() {
- return new SPRectContext();
+ ToolBase* createRectContext() {
+ return new RectTool();
}
bool rectContextRegistered = ToolFactory::instance().registerObject("/tools/shapes/rect", createRectContext);
}
-const std::string& SPRectContext::getPrefsPath() {
- return SPRectContext::prefsPath;
+const std::string& RectTool::getPrefsPath() {
+ return RectTool::prefsPath;
}
-const std::string SPRectContext::prefsPath = "/tools/shapes/rect";
+const std::string RectTool::prefsPath = "/tools/shapes/rect";
-SPRectContext::SPRectContext() : SPEventContext() {
+RectTool::RectTool() : ToolBase() {
this->cursor_shape = cursor_rect_xpm;
this->hot_x = 4;
this->hot_y = 4;
@@ -78,16 +82,16 @@ SPRectContext::SPRectContext() : SPEventContext() {
this->ry = 0.0;
}
-void SPRectContext::finish() {
+void RectTool::finish() {
sp_canvas_item_ungrab(SP_CANVAS_ITEM(this->desktop->acetate), GDK_CURRENT_TIME);
this->finishItem();
this->sel_changed_connection.disconnect();
- SPEventContext::finish();
+ ToolBase::finish();
}
-SPRectContext::~SPRectContext() {
+RectTool::~RectTool() {
this->enableGrDrag(false);
this->sel_changed_connection.disconnect();
@@ -105,13 +109,13 @@ SPRectContext::~SPRectContext() {
* Callback that processes the "changed" signal on the selection;
* destroys old and creates new knotholder.
*/
-void SPRectContext::selection_changed(Inkscape::Selection* selection) {
+void RectTool::selection_changed(Inkscape::Selection* selection) {
this->shape_editor->unset_item(SH_KNOTHOLDER);
this->shape_editor->set_item(selection->singleItem(), SH_KNOTHOLDER);
}
-void SPRectContext::setup() {
- SPEventContext::setup();
+void RectTool::setup() {
+ ToolBase::setup();
this->shape_editor = new ShapeEditor(this->desktop);
@@ -122,7 +126,7 @@ void SPRectContext::setup() {
this->sel_changed_connection.disconnect();
this->sel_changed_connection = sp_desktop_selection(this->desktop)->connectChanged(
- sigc::mem_fun(this, &SPRectContext::selection_changed)
+ sigc::mem_fun(this, &RectTool::selection_changed)
);
sp_event_context_read(this, "rx");
@@ -138,7 +142,7 @@ void SPRectContext::setup() {
}
}
-void SPRectContext::set(const Inkscape::Preferences::Entry& val) {
+void RectTool::set(const Inkscape::Preferences::Entry& val) {
/* fixme: Proper error handling for non-numeric data. Use a locale-independent function like
* g_ascii_strtod (or a thin wrapper that does the right thing for invalid values inf/nan). */
Glib::ustring name = val.getEntryName();
@@ -150,7 +154,7 @@ void SPRectContext::set(const Inkscape::Preferences::Entry& val) {
}
}
-bool SPRectContext::item_handler(SPItem* item, GdkEvent* event) {
+bool RectTool::item_handler(SPItem* item, GdkEvent* event) {
gint ret = FALSE;
switch (event->type) {
@@ -165,12 +169,12 @@ bool SPRectContext::item_handler(SPItem* item, GdkEvent* event) {
break;
}
- ret = SPEventContext::item_handler(item, event);
+ ret = ToolBase::item_handler(item, event);
return ret;
}
-bool SPRectContext::root_handler(GdkEvent* event) {
+bool RectTool::root_handler(GdkEvent* event) {
static bool dragging;
SPDesktop *desktop = this->desktop;
@@ -375,13 +379,13 @@ bool SPRectContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPEventContext::root_handler(event);
+ ret = ToolBase::root_handler(event);
}
return ret;
}
-void SPRectContext::drag(Geom::Point const pt, guint state) {
+void RectTool::drag(Geom::Point const pt, guint state) {
SPDesktop *desktop = this->desktop;
if (!this->rect) {
@@ -466,7 +470,7 @@ void SPRectContext::drag(Geom::Point const pt, guint state) {
g_string_free(ys, FALSE);
}
-void SPRectContext::finishItem() {
+void RectTool::finishItem() {
this->message_context->clear();
if (this->rect != NULL) {
@@ -488,7 +492,7 @@ void SPRectContext::finishItem() {
}
}
-void SPRectContext::cancel(){
+void RectTool::cancel(){
sp_desktop_selection(this->desktop)->clear();
sp_canvas_item_ungrab(SP_CANVAS_ITEM(this->desktop->acetate), 0);
@@ -507,6 +511,9 @@ void SPRectContext::cancel(){
DocumentUndo::cancel(sp_desktop_document(this->desktop));
}
+}
+}
+}
/*
Local Variables:
diff --git a/src/rect-context.h b/src/ui/tools/rect-tool.h
index a85968b1c..a50fd7b24 100644
--- a/src/rect-context.h
+++ b/src/ui/tools/rect-tool.h
@@ -17,17 +17,21 @@
#include <stddef.h>
#include <sigc++/sigc++.h>
#include <2geom/point.h>
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "sp-rect.h"
-#define SP_RECT_CONTEXT(obj) (dynamic_cast<SPRectContext*>((SPEventContext*)obj))
-#define SP_IS_RECT_CONTEXT(obj) (dynamic_cast<const SPRectContext*>((const SPEventContext*)obj) != NULL)
+#define SP_RECT_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::RectTool*>((Inkscape::UI::Tools::ToolBase*)obj))
+#define SP_IS_RECT_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::RectTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL)
-class SPRectContext : public SPEventContext {
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class RectTool : public ToolBase {
public:
- SPRectContext();
- virtual ~SPRectContext();
+ RectTool();
+ virtual ~RectTool();
static const std::string prefsPath;
@@ -54,4 +58,8 @@ private:
void selection_changed(Inkscape::Selection* selection);
};
+}
+}
+}
+
#endif
diff --git a/src/select-context.cpp b/src/ui/tools/select-tool.cpp
index 99eb01fea..498882417 100644
--- a/src/select-context.cpp
+++ b/src/ui/tools/select-tool.cpp
@@ -32,7 +32,7 @@
#include "pixmaps/handles.xpm"
#include <glibmm/i18n.h>
-#include "select-context.h"
+#include "ui/tools/select-tool.h"
#include "selection-chemistry.h"
#ifdef WITH_DBUS
#include "extension/dbus/document-interface.h"
@@ -49,30 +49,35 @@
#include "display/sp-canvas.h"
#include "display/sp-canvas-item.h"
#include "display/drawing-item.h"
+#include "tool-factory.h"
using Inkscape::DocumentUndo;
+GdkPixbuf *handles[13];
+
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
static GdkCursor *CursorSelectMouseover = NULL;
static GdkCursor *CursorSelectDragging = NULL;
-GdkPixbuf *handles[13];
static gint rb_escaped = 0; // if non-zero, rubberband was canceled by esc, so the next button release should not deselect
static gint drag_escaped = 0; // if non-zero, drag was canceled by esc
-#include "tool-factory.h"
namespace {
- SPEventContext* createSelectContext() {
- return new SPSelectContext();
+ ToolBase* createSelectContext() {
+ return new SelectTool();
}
bool selectContextRegistered = ToolFactory::instance().registerObject("/tools/select", createSelectContext);
}
-const std::string& SPSelectContext::getPrefsPath() {
- return SPSelectContext::prefsPath;
+const std::string& SelectTool::getPrefsPath() {
+ return SelectTool::prefsPath;
}
-const std::string SPSelectContext::prefsPath = "/tools/select";
+const std::string SelectTool::prefsPath = "/tools/select";
//Creates rotated variations for handles
@@ -85,7 +90,7 @@ sp_load_handles(int start, int count, char const **xpm) {
}
}
-SPSelectContext::SPSelectContext() : SPEventContext() {
+SelectTool::SelectTool() : ToolBase() {
this->grabbed = 0;
this->item = 0;
@@ -120,10 +125,10 @@ SPSelectContext::SPSelectContext() : SPEventContext() {
//static bool within_tolerance = false;
static bool is_cycling = false;
static bool moved_while_cycling = false;
-SPEventContext *prev_event_context = NULL;
+ToolBase *prev_event_context = NULL;
-SPSelectContext::~SPSelectContext() {
+SelectTool::~SelectTool() {
this->enableGrDrag(false);
if (this->grabbed) {
@@ -156,8 +161,8 @@ SPSelectContext::~SPSelectContext() {
}
}
-void SPSelectContext::setup() {
- SPEventContext::setup();
+void SelectTool::setup() {
+ ToolBase::setup();
this->_describer = new Inkscape::SelectionDescriber(
desktop->selection,
@@ -178,7 +183,7 @@ void SPSelectContext::setup() {
}
}
-void SPSelectContext::set(const Inkscape::Preferences::Entry& val) {
+void SelectTool::set(const Inkscape::Preferences::Entry& val) {
Glib::ustring path = val.getEntryName();
if (path == "show") {
@@ -190,7 +195,7 @@ void SPSelectContext::set(const Inkscape::Preferences::Entry& val) {
}
}
-bool SPSelectContext::sp_select_context_abort() {
+bool SelectTool::sp_select_context_abort() {
Inkscape::SelTrans *seltrans = this->_seltrans;
if (this->dragging) {
@@ -273,7 +278,7 @@ sp_select_context_up_one_layer(SPDesktop *desktop)
}
}
-bool SPSelectContext::item_handler(SPItem* item, GdkEvent* event) {
+bool SelectTool::item_handler(SPItem* item, GdkEvent* event) {
gint ret = FALSE;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -387,13 +392,13 @@ bool SPSelectContext::item_handler(SPItem* item, GdkEvent* event) {
}
if (!ret) {
- ret = SPEventContext::item_handler(item, event);
+ ret = ToolBase::item_handler(item, event);
}
return ret;
}
-void SPSelectContext::sp_select_context_cycle_through_items(Inkscape::Selection *selection, GdkEventScroll *scroll_event, bool shift_pressed) {
+void SelectTool::sp_select_context_cycle_through_items(Inkscape::Selection *selection, GdkEventScroll *scroll_event, bool shift_pressed) {
if (!this->cycling_cur_item) {
return;
}
@@ -438,10 +443,10 @@ void SPSelectContext::sp_select_context_cycle_through_items(Inkscape::Selection
static void
-sp_select_context_reset_opacities(SPEventContext *event_context)
+sp_select_context_reset_opacities(ToolBase *event_context)
{
// SPDesktop *desktop = event_context->desktop;
- SPSelectContext *sc = SP_SELECT_CONTEXT(event_context);
+ SelectTool *sc = SP_SELECT_CONTEXT(event_context);
Inkscape::DrawingItem *arenaitem;
for (GList *l = sc->cycling_items; l != NULL; l = g_list_next(l)) {
arenaitem = SP_ITEM(l->data)->get_arenaitem(event_context->desktop->dkey);
@@ -456,7 +461,7 @@ sp_select_context_reset_opacities(SPEventContext *event_context)
sc->cycling_items_cmp = NULL;
}
-bool SPSelectContext::root_handler(GdkEvent* event) {
+bool SelectTool::root_handler(GdkEvent* event) {
SPItem *item = NULL;
SPItem *item_at_point = NULL, *group_at_point = NULL, *item_in_group = NULL;
gint ret = FALSE;
@@ -1225,12 +1230,16 @@ bool SPSelectContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPEventContext::root_handler(event);
+ ret = ToolBase::root_handler(event);
}
return ret;
}
+}
+}
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/select-context.h b/src/ui/tools/select-tool.h
index bcea8537a..b26fc03bc 100644
--- a/src/select-context.h
+++ b/src/ui/tools/select-tool.h
@@ -12,11 +12,11 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include <gtk/gtk.h>
-#define SP_SELECT_CONTEXT(obj) (dynamic_cast<SPSelectContext*>((SPEventContext*)obj))
-#define SP_IS_SELECT_CONTEXT(obj) (dynamic_cast<const SPSelectContext*>((const SPEventContext*)obj) != NULL)
+#define SP_SELECT_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::SelectTool*>((Inkscape::UI::Tools::ToolBase*)obj))
+#define SP_IS_SELECT_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::SelectTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL)
struct SPCanvasItem;
@@ -26,10 +26,14 @@ namespace Inkscape {
class SelectionDescriber;
}
-class SPSelectContext : public SPEventContext {
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class SelectTool : public ToolBase {
public:
- SPSelectContext();
- virtual ~SPSelectContext();
+ SelectTool();
+ virtual ~SelectTool();
guint dragging : 1;
guint moved : 1;
@@ -62,4 +66,8 @@ private:
void sp_select_context_cycle_through_items(Inkscape::Selection *selection, GdkEventScroll *scroll_event, bool shift_pressed);
};
+}
+}
+}
+
#endif
diff --git a/src/spiral-context.cpp b/src/ui/tools/spiral-tool.cpp
index 9d44b5adb..005b2d239 100644
--- a/src/spiral-context.cpp
+++ b/src/ui/tools/spiral-tool.cpp
@@ -33,7 +33,7 @@
#include "desktop-style.h"
#include "message-context.h"
#include "pixmaps/cursor-spiral.xpm"
-#include "spiral-context.h"
+#include "ui/tools/spiral-tool.h"
#include <glibmm/i18n.h>
#include "xml/repr.h"
#include "xml/node-event-vector.h"
@@ -47,21 +47,25 @@ using Inkscape::DocumentUndo;
#include "tool-factory.h"
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
namespace {
- SPEventContext* createSpiralContext() {
- return new SPSpiralContext();
+ ToolBase* createSpiralContext() {
+ return new SpiralTool();
}
bool spiralContextRegistered = ToolFactory::instance().registerObject("/tools/shapes/spiral", createSpiralContext);
}
-const std::string& SPSpiralContext::getPrefsPath() {
- return SPSpiralContext::prefsPath;
+const std::string& SpiralTool::getPrefsPath() {
+ return SpiralTool::prefsPath;
}
-const std::string SPSpiralContext::prefsPath = "/tools/shapes/spiral";
+const std::string SpiralTool::prefsPath = "/tools/shapes/spiral";
-SPSpiralContext::SPSpiralContext() : SPEventContext() {
+SpiralTool::SpiralTool() : ToolBase() {
this->cursor_shape = cursor_spiral_xpm;
this->hot_x = 4;
this->hot_y = 4;
@@ -78,7 +82,7 @@ SPSpiralContext::SPSpiralContext() : SPEventContext() {
this->t0 = 0.0;
}
-void SPSpiralContext::finish() {
+void SpiralTool::finish() {
SPDesktop *desktop = this->desktop;
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), GDK_CURRENT_TIME);
@@ -86,10 +90,10 @@ void SPSpiralContext::finish() {
this->finishItem();
this->sel_changed_connection.disconnect();
- SPEventContext::finish();
+ ToolBase::finish();
}
-SPSpiralContext::~SPSpiralContext() {
+SpiralTool::~SpiralTool() {
this->enableGrDrag(false);
this->sel_changed_connection.disconnect();
@@ -107,13 +111,13 @@ SPSpiralContext::~SPSpiralContext() {
* Callback that processes the "changed" signal on the selection;
* destroys old and creates new knotholder.
*/
-void SPSpiralContext::selection_changed(Inkscape::Selection *selection) {
+void SpiralTool::selection_changed(Inkscape::Selection *selection) {
this->shape_editor->unset_item(SH_KNOTHOLDER);
this->shape_editor->set_item(selection->singleItem(), SH_KNOTHOLDER);
}
-void SPSpiralContext::setup() {
- SPEventContext::setup();
+void SpiralTool::setup() {
+ ToolBase::setup();
sp_event_context_read(this, "expansion");
sp_event_context_read(this, "revolution");
@@ -129,7 +133,7 @@ void SPSpiralContext::setup() {
Inkscape::Selection *selection = sp_desktop_selection(this->desktop);
this->sel_changed_connection.disconnect();
- this->sel_changed_connection = selection->connectChanged(sigc::mem_fun(this, &SPSpiralContext::selection_changed));
+ this->sel_changed_connection = selection->connectChanged(sigc::mem_fun(this, &SpiralTool::selection_changed));
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -142,7 +146,7 @@ void SPSpiralContext::setup() {
}
}
-void SPSpiralContext::set(const Inkscape::Preferences::Entry& val) {
+void SpiralTool::set(const Inkscape::Preferences::Entry& val) {
Glib::ustring name = val.getEntryName();
if (name == "expansion") {
@@ -154,7 +158,7 @@ void SPSpiralContext::set(const Inkscape::Preferences::Entry& val) {
}
}
-bool SPSpiralContext::root_handler(GdkEvent* event) {
+bool SpiralTool::root_handler(GdkEvent* event) {
static gboolean dragging;
SPDesktop *desktop = this->desktop;
@@ -340,13 +344,13 @@ bool SPSpiralContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPEventContext::root_handler(event);
+ ret = ToolBase::root_handler(event);
}
return ret;
}
-void SPSpiralContext::drag(Geom::Point const &p, guint state) {
+void SpiralTool::drag(Geom::Point const &p, guint state) {
SPDesktop *desktop = SP_EVENT_CONTEXT(this)->desktop;
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -358,7 +362,7 @@ void SPSpiralContext::drag(Geom::Point const &p, guint state) {
}
// Create object
- Inkscape::XML::Document *xml_doc = SP_EVENT_CONTEXT_DOCUMENT(this)->getReprDoc();
+ Inkscape::XML::Document *xml_doc = this->desktop->doc()->getReprDoc();
Inkscape::XML::Node *repr = xml_doc->createElement("svg:path");
repr->setAttribute("sodipodi:type", "spiral");
@@ -406,7 +410,7 @@ void SPSpiralContext::drag(Geom::Point const &p, guint state) {
g_string_free(rads, FALSE);
}
-void SPSpiralContext::finishItem() {
+void SpiralTool::finishItem() {
this->message_context->clear();
if (this->spiral != NULL) {
@@ -428,7 +432,7 @@ void SPSpiralContext::finishItem() {
}
}
-void SPSpiralContext::cancel() {
+void SpiralTool::cancel() {
sp_desktop_selection(this->desktop)->clear();
sp_canvas_item_ungrab(SP_CANVAS_ITEM(this->desktop->acetate), 0);
@@ -447,6 +451,10 @@ void SPSpiralContext::cancel() {
DocumentUndo::cancel(sp_desktop_document(this->desktop));
}
+}
+}
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/spiral-context.h b/src/ui/tools/spiral-tool.h
index d5bd15941..416aeb7e4 100644
--- a/src/spiral-context.h
+++ b/src/ui/tools/spiral-tool.h
@@ -19,17 +19,21 @@
#include <stddef.h>
#include <sigc++/sigc++.h>
#include <2geom/point.h>
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "sp-spiral.h"
-#define SP_SPIRAL_CONTEXT(obj) (dynamic_cast<SPSpiralContext*>((SPEventContext*)obj))
-#define SP_IS_SPIRAL_CONTEXT(obj) (dynamic_cast<const SPSpiralContext*>((const SPEventContext*)obj) != NULL)
+#define SP_SPIRAL_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::SpiralTool*>((Inkscape::UI::Tools::ToolBase*)obj))
+#define SP_IS_SPIRAL_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::SpiralTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL)
-class SPSpiralContext : public SPEventContext {
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class SpiralTool : public ToolBase {
public:
- SPSpiralContext();
- virtual ~SPSpiralContext();
+ SpiralTool();
+ virtual ~SpiralTool();
static const std::string prefsPath;
@@ -55,4 +59,8 @@ private:
void selection_changed(Inkscape::Selection *selection);
};
+}
+}
+}
+
#endif
diff --git a/src/spray-context.cpp b/src/ui/tools/spray-tool.cpp
index 6b97dcc17..0ded1e44b 100644
--- a/src/spray-context.cpp
+++ b/src/ui/tools/spray-tool.cpp
@@ -63,7 +63,7 @@
#include "sp-item-transform.h"
#include "filter-chemistry.h"
-#include "spray-context.h"
+#include "ui/tools/spray-tool.h"
#include "helper/action.h"
#include "verbs.h"
@@ -81,19 +81,23 @@ using namespace std;
#include "tool-factory.h"
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
namespace {
- SPEventContext* createSprayContext() {
- return new SPSprayContext();
+ ToolBase* createSprayContext() {
+ return new SprayTool();
}
bool sprayContextRegistered = ToolFactory::instance().registerObject("/tools/spray", createSprayContext);
}
-const std::string& SPSprayContext::getPrefsPath() {
- return SPSprayContext::prefsPath;
+const std::string& SprayTool::getPrefsPath() {
+ return SprayTool::prefsPath;
}
-const std::string SPSprayContext::prefsPath = "/tools/spray";
+const std::string SprayTool::prefsPath = "/tools/spray";
/**
* This function returns pseudo-random numbers from a normal distribution
@@ -130,7 +134,7 @@ static void sp_spray_scale_rel(Geom::Point c, SPDesktop */*desktop*/, SPItem *it
item->doWriteTransform(item->getRepr(), item->transform);
}
-SPSprayContext::SPSprayContext() : SPEventContext() {
+SprayTool::SprayTool() : ToolBase() {
this->usetilt = 0;
this->dilate_area = 0;
this->usetext = false;
@@ -161,7 +165,7 @@ SPSprayContext::SPSprayContext() : SPEventContext() {
this->has_dilated = false;
}
-SPSprayContext::~SPSprayContext() {
+SprayTool::~SprayTool() {
this->enableGrDrag(false);
this->style_set_connection.disconnect();
@@ -179,7 +183,7 @@ static bool is_transform_modes(gint mode)
mode == SPRAY_OPTION);
}
-void SPSprayContext::update_cursor(bool /*with_shift*/) {
+void SprayTool::update_cursor(bool /*with_shift*/) {
guint num = 0;
gchar *sel_message = NULL;
@@ -208,8 +212,8 @@ void SPSprayContext::update_cursor(bool /*with_shift*/) {
g_free(sel_message);
}
-void SPSprayContext::setup() {
- SPEventContext::setup();
+void SprayTool::setup() {
+ ToolBase::setup();
{
/* TODO: have a look at sp_dyna_draw_context_setup where the same is done.. generalize? at least make it an arcto! */
@@ -250,7 +254,7 @@ void SPSprayContext::setup() {
}
}
-void SPSprayContext::set(const Inkscape::Preferences::Entry& val) {
+void SprayTool::set(const Inkscape::Preferences::Entry& val) {
Glib::ustring path = val.getEntryName();
if (path == "mode") {
@@ -282,7 +286,7 @@ void SPSprayContext::set(const Inkscape::Preferences::Entry& val) {
}
}
-static void sp_spray_extinput(SPSprayContext *tc, GdkEvent *event)
+static void sp_spray_extinput(SprayTool *tc, GdkEvent *event)
{
if (gdk_event_get_axis(event, GDK_AXIS_PRESSURE, &tc->pressure)) {
tc->pressure = CLAMP(tc->pressure, TC_MIN_PRESSURE, TC_MAX_PRESSURE);
@@ -291,12 +295,12 @@ static void sp_spray_extinput(SPSprayContext *tc, GdkEvent *event)
}
}
-static double get_dilate_radius(SPSprayContext *tc)
+static double get_dilate_radius(SprayTool *tc)
{
return 250 * tc->width/SP_EVENT_CONTEXT(tc)->desktop->current_zoom();
}
-static double get_path_force(SPSprayContext *tc)
+static double get_path_force(SprayTool *tc)
{
double force = 8 * (tc->usepressure? tc->pressure : TC_DEFAULT_PRESSURE)
/sqrt(SP_EVENT_CONTEXT(tc)->desktop->current_zoom());
@@ -306,28 +310,28 @@ static double get_path_force(SPSprayContext *tc)
return force * tc->force;
}
-static double get_path_mean(SPSprayContext *tc)
+static double get_path_mean(SprayTool *tc)
{
return tc->mean;
}
-static double get_path_standard_deviation(SPSprayContext *tc)
+static double get_path_standard_deviation(SprayTool *tc)
{
return tc->standard_deviation;
}
-static double get_move_force(SPSprayContext *tc)
+static double get_move_force(SprayTool *tc)
{
double force = (tc->usepressure? tc->pressure : TC_DEFAULT_PRESSURE);
return force * tc->force;
}
-static double get_move_mean(SPSprayContext *tc)
+static double get_move_mean(SprayTool *tc)
{
return tc->mean;
}
-static double get_move_standard_deviation(SPSprayContext *tc)
+static double get_move_standard_deviation(SprayTool *tc)
{
return tc->standard_deviation;
}
@@ -523,7 +527,7 @@ static bool sp_spray_recursive(SPDesktop *desktop,
return did;
}
-static bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::Point p, Geom::Point vector, bool reverse)
+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;
@@ -568,7 +572,7 @@ static bool sp_spray_dilate(SPSprayContext *tc, Geom::Point /*event_p*/, Geom::P
return did;
}
-static void sp_spray_update_area(SPSprayContext *tc)
+static void sp_spray_update_area(SprayTool *tc)
{
double radius = get_dilate_radius(tc);
Geom::Affine const sm ( Geom::Scale(radius/(1-tc->ratio), radius/(1+tc->ratio)) );
@@ -576,7 +580,7 @@ static void sp_spray_update_area(SPSprayContext *tc)
sp_canvas_item_show(tc->dilate_area);
}
-static void sp_spray_switch_mode(SPSprayContext *tc, gint mode, bool with_shift)
+static void sp_spray_switch_mode(SprayTool *tc, gint mode, bool with_shift)
{
// select the button mode
SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue("spray_tool_mode", mode);
@@ -585,7 +589,7 @@ static void sp_spray_switch_mode(SPSprayContext *tc, gint mode, bool with_shift)
tc->update_cursor(with_shift);
}
-bool SPSprayContext::root_handler(GdkEvent* event) {
+bool SprayTool::root_handler(GdkEvent* event) {
gint ret = FALSE;
switch (event->type) {
@@ -863,12 +867,16 @@ bool SPSprayContext::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 = SPEventContext::root_handler(event);
+ ret = ToolBase::root_handler(event);
}
return ret;
}
+}
+}
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/spray-context.h b/src/ui/tools/spray-tool.h
index 4e1ab9dc0..e7362fd50 100644
--- a/src/spray-context.h
+++ b/src/ui/tools/spray-tool.h
@@ -19,10 +19,10 @@
*/
#include <2geom/point.h>
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
-#define SP_SPRAY_CONTEXT(obj) (dynamic_cast<SPSprayContext*>((SPEventContext*)obj))
-#define SP_IS_SPRAY_CONTEXT(obj) (dynamic_cast<const SPSprayContext*>((const SPEventContext*)obj) != NULL)
+#define SP_SPRAY_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::SprayTool*>((Inkscape::UI::Tools::ToolBase*)obj))
+#define SP_IS_SPRAY_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::SprayTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL)
namespace Inkscape {
namespace UI {
@@ -39,6 +39,10 @@ namespace Inkscape {
#define TC_MAX_PRESSURE 1.0
#define TC_DEFAULT_PRESSURE 0.35
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
enum {
SPRAY_MODE_COPY,
SPRAY_MODE_CLONE,
@@ -46,12 +50,12 @@ enum {
SPRAY_OPTION,
};
-class SPSprayContext : public SPEventContext {
+class SprayTool : public ToolBase {
public:
- SPSprayContext();
- virtual ~SPSprayContext();
+ SprayTool();
+ virtual ~SprayTool();
- //SPEventContext event_context;
+ //ToolBase event_context;
//Inkscape::UI::Dialog::Dialog *dialog_option;//Attribut de type SprayOptionClass, localisé dans scr/ui/dialog
/* extended input data */
gdouble pressure;
@@ -98,6 +102,10 @@ public:
void update_cursor(bool /*with_shift*/);
};
+}
+}
+}
+
#endif
/*
diff --git a/src/star-context.cpp b/src/ui/tools/star-tool.cpp
index d801ad0a0..b5d8c4418 100644
--- a/src/star-context.cpp
+++ b/src/ui/tools/star-tool.cpp
@@ -45,27 +45,31 @@
#include "verbs.h"
#include "display/sp-canvas-item.h"
-#include "star-context.h"
+#include "ui/tools/star-tool.h"
using Inkscape::DocumentUndo;
#include "tool-factory.h"
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
namespace {
- SPEventContext* createStarContext() {
- return new SPStarContext();
+ ToolBase* createStarContext() {
+ return new StarTool();
}
bool starContextRegistered = ToolFactory::instance().registerObject("/tools/shapes/star", createStarContext);
}
-const std::string& SPStarContext::getPrefsPath() {
- return SPStarContext::prefsPath;
+const std::string& StarTool::getPrefsPath() {
+ return StarTool::prefsPath;
}
-const std::string SPStarContext::prefsPath = "/tools/shapes/star";
+const std::string StarTool::prefsPath = "/tools/shapes/star";
-SPStarContext::SPStarContext() : SPEventContext() {
+StarTool::StarTool() : ToolBase() {
this->randomized = 0;
this->rounded = 0;
@@ -86,16 +90,16 @@ SPStarContext::SPStarContext() : SPEventContext() {
this->isflatsided = false;
}
-void SPStarContext::finish() {
+void StarTool::finish() {
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), GDK_CURRENT_TIME);
this->finishItem();
this->sel_changed_connection.disconnect();
- SPEventContext::finish();
+ ToolBase::finish();
}
-SPStarContext::~SPStarContext() {
+StarTool::~StarTool() {
this->enableGrDrag(false);
this->sel_changed_connection.disconnect();
@@ -115,15 +119,15 @@ SPStarContext::~SPStarContext() {
*
* @param selection Should not be NULL.
*/
-void SPStarContext::selection_changed(Inkscape::Selection* selection) {
+void StarTool::selection_changed(Inkscape::Selection* selection) {
g_assert (selection != NULL);
this->shape_editor->unset_item(SH_KNOTHOLDER);
this->shape_editor->set_item(selection->singleItem(), SH_KNOTHOLDER);
}
-void SPStarContext::setup() {
- SPEventContext::setup();
+void StarTool::setup() {
+ ToolBase::setup();
sp_event_context_read(this, "magnitude");
sp_event_context_read(this, "proportion");
@@ -142,7 +146,7 @@ void SPStarContext::setup() {
this->sel_changed_connection.disconnect();
- this->sel_changed_connection = selection->connectChanged(sigc::mem_fun(this, &SPStarContext::selection_changed));
+ this->sel_changed_connection = selection->connectChanged(sigc::mem_fun(this, &StarTool::selection_changed));
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/tools/shapes/selcue")) {
@@ -154,7 +158,7 @@ void SPStarContext::setup() {
}
}
-void SPStarContext::set(const Inkscape::Preferences::Entry& val) {
+void StarTool::set(const Inkscape::Preferences::Entry& val) {
Glib::ustring path = val.getEntryName();
if (path == "magnitude") {
@@ -170,7 +174,7 @@ void SPStarContext::set(const Inkscape::Preferences::Entry& val) {
}
}
-bool SPStarContext::root_handler(GdkEvent* event) {
+bool StarTool::root_handler(GdkEvent* event) {
static bool dragging;
SPDesktop *desktop = this->desktop;
@@ -356,13 +360,13 @@ bool SPStarContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPEventContext::root_handler(event);
+ ret = ToolBase::root_handler(event);
}
return ret;
}
-void SPStarContext::drag(Geom::Point p, guint state)
+void StarTool::drag(Geom::Point p, guint state)
{
SPDesktop *desktop = this->desktop;
@@ -427,7 +431,7 @@ void SPStarContext::drag(Geom::Point p, guint state)
g_string_free(rads, FALSE);
}
-void SPStarContext::finishItem() {
+void StarTool::finishItem() {
this->message_context->clear();
if (this->star != NULL) {
@@ -455,7 +459,7 @@ void SPStarContext::finishItem() {
}
}
-void SPStarContext::cancel() {
+void StarTool::cancel() {
sp_desktop_selection(desktop)->clear();
sp_canvas_item_ungrab(SP_CANVAS_ITEM(desktop->acetate), 0);
@@ -474,6 +478,10 @@ void SPStarContext::cancel() {
DocumentUndo::cancel(sp_desktop_document(desktop));
}
+}
+}
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/star-context.h b/src/ui/tools/star-tool.h
index af66f3201..da3774e68 100644
--- a/src/star-context.h
+++ b/src/ui/tools/star-tool.h
@@ -17,14 +17,18 @@
#include <stddef.h>
#include <sigc++/sigc++.h>
#include <2geom/point.h>
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "sp-star.h"
-class SPStarContext : public SPEventContext {
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class StarTool : public ToolBase {
public:
- SPStarContext();
- virtual ~SPStarContext();
+ StarTool();
+ virtual ~StarTool();
static const std::string prefsPath;
@@ -63,4 +67,8 @@ private:
void selection_changed(Inkscape::Selection* selection);
};
+}
+}
+}
+
#endif
diff --git a/src/text-context.cpp b/src/ui/tools/text-tool.cpp
index 7d9b9848f..2927606a7 100644
--- a/src/text-context.cpp
+++ b/src/ui/tools/text-tool.cpp
@@ -1,5 +1,5 @@
/*
- * SPTextContext
+ * TextTool
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
@@ -45,51 +45,53 @@
#include "sp-namedview.h"
#include "sp-text.h"
#include "style.h"
-#include "text-context.h"
+#include "ui/tools/text-tool.h"
#include "text-editing.h"
#include "ui/control-manager.h"
#include "verbs.h"
#include "xml/node-event-vector.h"
#include "xml/repr.h"
#include <gtk/gtk.h>
+#include "tool-factory.h"
using Inkscape::ControlManager;
using Inkscape::DocumentUndo;
-static void sp_text_context_selection_changed(Inkscape::Selection *selection, SPTextContext *tc);
-static void sp_text_context_selection_modified(Inkscape::Selection *selection, guint flags, SPTextContext *tc);
-static bool sp_text_context_style_set(SPCSSAttr const *css, SPTextContext *tc);
-static int sp_text_context_style_query(SPStyle *style, int property, SPTextContext *tc);
-
-static void sp_text_context_validate_cursor_iterators(SPTextContext *tc);
-static void sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see = true);
-static void sp_text_context_update_text_selection(SPTextContext *tc);
-static gint sp_text_context_timeout(SPTextContext *tc);
-static void sp_text_context_forget_text(SPTextContext *tc);
+namespace Inkscape {
+namespace UI {
+namespace Tools {
-static gint sptc_focus_in(GtkWidget *widget, GdkEventFocus *event, SPTextContext *tc);
-static gint sptc_focus_out(GtkWidget *widget, GdkEventFocus *event, SPTextContext *tc);
-static void sptc_commit(GtkIMContext *imc, gchar *string, SPTextContext *tc);
+static void sp_text_context_selection_changed(Inkscape::Selection *selection, TextTool *tc);
+static void sp_text_context_selection_modified(Inkscape::Selection *selection, guint flags, TextTool *tc);
+static bool sp_text_context_style_set(SPCSSAttr const *css, TextTool *tc);
+static int sp_text_context_style_query(SPStyle *style, int property, TextTool *tc);
+static void sp_text_context_validate_cursor_iterators(TextTool *tc);
+static void sp_text_context_update_cursor(TextTool *tc, bool scroll_to_see = true);
+static void sp_text_context_update_text_selection(TextTool *tc);
+static gint sp_text_context_timeout(TextTool *tc);
+static void sp_text_context_forget_text(TextTool *tc);
-#include "tool-factory.h"
+static gint sptc_focus_in(GtkWidget *widget, GdkEventFocus *event, TextTool *tc);
+static gint sptc_focus_out(GtkWidget *widget, GdkEventFocus *event, TextTool *tc);
+static void sptc_commit(GtkIMContext *imc, gchar *string, TextTool *tc);
namespace {
- SPEventContext* createTextContext() {
- return new SPTextContext();
+ ToolBase* createTextContext() {
+ return new TextTool();
}
bool textContextRegistered = ToolFactory::instance().registerObject("/tools/text", createTextContext);
}
-const std::string& SPTextContext::getPrefsPath() {
- return SPTextContext::prefsPath;
+const std::string& TextTool::getPrefsPath() {
+ return TextTool::prefsPath;
}
-const std::string SPTextContext::prefsPath = "/tools/text";
+const std::string TextTool::prefsPath = "/tools/text";
-SPTextContext::SPTextContext() : SPEventContext() {
+TextTool::TextTool() : ToolBase() {
this->preedit_string = 0;
this->unipos = 0;
@@ -122,7 +124,7 @@ SPTextContext::SPTextContext() : SPEventContext() {
this->creating = 0;
}
-SPTextContext::~SPTextContext() {
+TextTool::~TextTool() {
delete this->shape_editor;
this->shape_editor = NULL;
@@ -134,7 +136,7 @@ SPTextContext::~SPTextContext() {
Inkscape::Rubberband::get(this->desktop)->stop();
}
-void SPTextContext::setup() {
+void TextTool::setup() {
GtkSettings* settings = gtk_settings_get_default();
gint timeout = 0;
g_object_get( settings, "gtk-cursor-blink-time", &timeout, NULL );
@@ -184,7 +186,7 @@ void SPTextContext::setup() {
}
}
- SPEventContext::setup();
+ ToolBase::setup();
this->shape_editor = new ShapeEditor(this->desktop);
@@ -217,7 +219,7 @@ void SPTextContext::setup() {
}
}
-void SPTextContext::finish() {
+void TextTool::finish() {
if (this->desktop) {
sp_signal_disconnect_by_data(sp_desktop_canvas(this->desktop), this);
}
@@ -265,7 +267,7 @@ void SPTextContext::finish() {
this->text_selection_quads.clear();
}
-bool SPTextContext::item_handler(SPItem* item, GdkEvent* event) {
+bool TextTool::item_handler(SPItem* item, GdkEvent* event) {
SPItem *item_ungrouped;
gint ret = FALSE;
@@ -402,23 +404,23 @@ bool SPTextContext::item_handler(SPItem* item, GdkEvent* event) {
}
if (!ret) {
- ret = SPEventContext::item_handler(item, event);
+ ret = ToolBase::item_handler(item, event);
}
return ret;
}
-static void sp_text_context_setup_text(SPTextContext *tc)
+static void sp_text_context_setup_text(TextTool *tc)
{
- SPEventContext *ec = SP_EVENT_CONTEXT(tc);
+ ToolBase *ec = SP_EVENT_CONTEXT(tc);
/* Create <text> */
- Inkscape::XML::Document *xml_doc = SP_EVENT_CONTEXT_DESKTOP(ec)->doc()->getReprDoc();
+ Inkscape::XML::Document *xml_doc = ec->desktop->doc()->getReprDoc();
Inkscape::XML::Node *rtext = xml_doc->createElement("svg:text");
rtext->setAttribute("xml:space", "preserve"); // we preserve spaces in the text objects we create
/* Set style */
- sp_desktop_apply_style_tool(SP_EVENT_CONTEXT_DESKTOP(ec), rtext, "/tools/text", true);
+ sp_desktop_apply_style_tool(ec->desktop, rtext, "/tools/text", true);
sp_repr_set_svg_double(rtext, "x", tc->pdoc[Geom::X]);
sp_repr_set_svg_double(rtext, "y", tc->pdoc[Geom::Y]);
@@ -452,7 +454,7 @@ static void sp_text_context_setup_text(SPTextContext *tc)
*
* \pre tc.uni/tc.unipos non-empty.
*/
-static void insert_uni_char(SPTextContext *const tc)
+static void insert_uni_char(TextTool *const tc)
{
g_return_if_fail(tc->unipos
&& tc->unipos < sizeof(tc->uni)
@@ -500,7 +502,7 @@ static void hex_to_printable_utf8_buf(char const *const ehex, char *utf8)
utf8[len] = '\0';
}
-static void show_curr_uni_char(SPTextContext *const tc)
+static void show_curr_uni_char(TextTool *const tc)
{
g_return_if_fail(tc->unipos < sizeof(tc->uni)
&& tc->uni[tc->unipos] == '\0');
@@ -524,7 +526,7 @@ static void show_curr_uni_char(SPTextContext *const tc)
}
}
-bool SPTextContext::root_handler(GdkEvent* event) {
+bool TextTool::root_handler(GdkEvent* event) {
sp_canvas_item_hide(this->indicator);
sp_text_context_validate_cursor_iterators(this);
@@ -1290,19 +1292,19 @@ bool SPTextContext::root_handler(GdkEvent* event) {
// } else {
// return FALSE; // return "I did nothing" value so that global shortcuts can be activated
// }
- return SPEventContext::root_handler(event);
+ return ToolBase::root_handler(event);
}
/**
Attempts to paste system clipboard into the currently edited text, returns true on success
*/
-bool sp_text_paste_inline(SPEventContext *ec)
+bool sp_text_paste_inline(ToolBase *ec)
{
if (!SP_IS_TEXT_CONTEXT(ec))
return false;
- SPTextContext *tc = SP_TEXT_CONTEXT(ec);
+ TextTool *tc = SP_TEXT_CONTEXT(ec);
if ((tc->text) || (tc->nascent_object)) {
// there is an active text object in this context, or a new object was just created
@@ -1370,22 +1372,22 @@ bool sp_text_paste_inline(SPEventContext *ec)
Gets the raw characters that comprise the currently selected text, converting line
breaks into lf characters.
*/
-Glib::ustring sp_text_get_selected_text(SPEventContext const *ec)
+Glib::ustring sp_text_get_selected_text(ToolBase const *ec)
{
if (!SP_IS_TEXT_CONTEXT(ec))
return "";
- SPTextContext const *tc = SP_TEXT_CONTEXT(ec);
+ TextTool const *tc = SP_TEXT_CONTEXT(ec);
if (tc->text == NULL)
return "";
return sp_te_get_string_multiline(tc->text, tc->text_sel_start, tc->text_sel_end);
}
-SPCSSAttr *sp_text_get_style_at_cursor(SPEventContext const *ec)
+SPCSSAttr *sp_text_get_style_at_cursor(ToolBase const *ec)
{
if (!SP_IS_TEXT_CONTEXT(ec))
return NULL;
- SPTextContext const *tc = SP_TEXT_CONTEXT(ec);
+ TextTool const *tc = SP_TEXT_CONTEXT(ec);
if (tc->text == NULL)
return NULL;
@@ -1402,11 +1404,11 @@ SPCSSAttr *sp_text_get_style_at_cursor(SPEventContext const *ec)
Deletes the currently selected characters. Returns false if there is no
text selection currently.
*/
-bool sp_text_delete_selection(SPEventContext *ec)
+bool sp_text_delete_selection(ToolBase *ec)
{
if (!SP_IS_TEXT_CONTEXT(ec))
return false;
- SPTextContext *tc = SP_TEXT_CONTEXT(ec);
+ TextTool *tc = SP_TEXT_CONTEXT(ec);
if (tc->text == NULL)
return false;
@@ -1434,11 +1436,11 @@ bool sp_text_delete_selection(SPEventContext *ec)
* \param selection Should not be NULL.
*/
static void
-sp_text_context_selection_changed(Inkscape::Selection *selection, SPTextContext *tc)
+sp_text_context_selection_changed(Inkscape::Selection *selection, TextTool *tc)
{
g_assert(selection != NULL);
- SPEventContext *ec = SP_EVENT_CONTEXT(tc);
+ ToolBase *ec = SP_EVENT_CONTEXT(tc);
ec->shape_editor->unset_item(SH_KNOTHOLDER);
SPItem *item = selection->singleItem();
@@ -1467,13 +1469,13 @@ sp_text_context_selection_changed(Inkscape::Selection *selection, SPTextContext
}
static void
-sp_text_context_selection_modified(Inkscape::Selection */*selection*/, guint /*flags*/, SPTextContext *tc)
+sp_text_context_selection_modified(Inkscape::Selection */*selection*/, guint /*flags*/, TextTool *tc)
{
sp_text_context_update_cursor(tc);
sp_text_context_update_text_selection(tc);
}
-static bool sp_text_context_style_set(SPCSSAttr const *css, SPTextContext *tc)
+static bool sp_text_context_style_set(SPCSSAttr const *css, TextTool *tc)
{
if (tc->text == NULL)
return false;
@@ -1490,7 +1492,7 @@ static bool sp_text_context_style_set(SPCSSAttr const *css, SPTextContext *tc)
}
static int
-sp_text_context_style_query(SPStyle *style, int property, SPTextContext *tc)
+sp_text_context_style_query(SPStyle *style, int property, TextTool *tc)
{
if (tc->text == NULL) {
return QUERY_STYLE_NOTHING;
@@ -1536,7 +1538,7 @@ sp_text_context_style_query(SPStyle *style, int property, SPTextContext *tc)
return result;
}
-static void sp_text_context_validate_cursor_iterators(SPTextContext *tc)
+static void sp_text_context_validate_cursor_iterators(TextTool *tc)
{
if (tc->text == NULL)
return;
@@ -1547,7 +1549,7 @@ static void sp_text_context_validate_cursor_iterators(SPTextContext *tc)
}
}
-static void sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see)
+static void sp_text_context_update_cursor(TextTool *tc, bool scroll_to_see)
{
// due to interruptible display, tc may already be destroyed during a display update before
// the cursor update (can't do both atomically, alas)
@@ -1611,9 +1613,9 @@ static void sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see
}
}
- SP_EVENT_CONTEXT(tc)->message_context->setF(Inkscape::NORMAL_MESSAGE, _("Type or edit flowed text (%d characters%s); <b>Enter</b> to start new paragraph."), nChars, trunc);
+ SP_EVENT_CONTEXT(tc)->message_context->setF(Inkscape::NORMAL_MESSAGE, ngettext("Type or edit flowed text (%d character%s); <b>Enter</b> to start new paragraph.", "Type or edit flowed text (%d characters%s); <b>Enter</b> to start new paragraph.", nChars), nChars, trunc);
} else {
- SP_EVENT_CONTEXT(tc)->message_context->setF(Inkscape::NORMAL_MESSAGE, _("Type or edit text (%d characters%s); <b>Enter</b> to start new line."), nChars, trunc);
+ SP_EVENT_CONTEXT(tc)->message_context->setF(Inkscape::NORMAL_MESSAGE, ngettext("Type or edit text (%d character%s); <b>Enter</b> to start new line.", "Type or edit text (%d characters%s); <b>Enter</b> to start new line.", nChars), nChars, trunc);
}
} else {
@@ -1628,7 +1630,7 @@ static void sp_text_context_update_cursor(SPTextContext *tc, bool scroll_to_see
SP_EVENT_CONTEXT(tc)->desktop->emitToolSubselectionChanged((gpointer)tc);
}
-static void sp_text_context_update_text_selection(SPTextContext *tc)
+static void sp_text_context_update_text_selection(TextTool *tc)
{
// due to interruptible display, tc may already be destroyed during a display update before
// the selection update (can't do both atomically, alas)
@@ -1655,7 +1657,7 @@ static void sp_text_context_update_text_selection(SPTextContext *tc)
}
}
-static gint sp_text_context_timeout(SPTextContext *tc)
+static gint sp_text_context_timeout(TextTool *tc)
{
if (tc->show) {
sp_canvas_item_show(tc->cursor);
@@ -1671,7 +1673,7 @@ static gint sp_text_context_timeout(SPTextContext *tc)
return TRUE;
}
-static void sp_text_context_forget_text(SPTextContext *tc)
+static void sp_text_context_forget_text(TextTool *tc)
{
if (! tc->text) return;
SPItem *ti = tc->text;
@@ -1699,19 +1701,19 @@ static void sp_text_context_forget_text(SPTextContext *tc)
*/
}
-gint sptc_focus_in(GtkWidget */*widget*/, GdkEventFocus */*event*/, SPTextContext *tc)
+gint sptc_focus_in(GtkWidget */*widget*/, GdkEventFocus */*event*/, TextTool *tc)
{
gtk_im_context_focus_in(tc->imc);
return FALSE;
}
-gint sptc_focus_out(GtkWidget */*widget*/, GdkEventFocus */*event*/, SPTextContext *tc)
+gint sptc_focus_out(GtkWidget */*widget*/, GdkEventFocus */*event*/, TextTool *tc)
{
gtk_im_context_focus_out(tc->imc);
return FALSE;
}
-static void sptc_commit(GtkIMContext */*imc*/, gchar *string, SPTextContext *tc)
+static void sptc_commit(GtkIMContext */*imc*/, gchar *string, TextTool *tc)
{
if (!tc->text) {
sp_text_context_setup_text(tc);
@@ -1726,27 +1728,30 @@ static void sptc_commit(GtkIMContext */*imc*/, gchar *string, SPTextContext *tc)
_("Type text"));
}
-void sp_text_context_place_cursor (SPTextContext *tc, SPObject *text, Inkscape::Text::Layout::iterator where)
+void sp_text_context_place_cursor (TextTool *tc, SPObject *text, Inkscape::Text::Layout::iterator where)
{
- SP_EVENT_CONTEXT_DESKTOP (tc)->selection->set (text);
+ tc->desktop->selection->set (text);
tc->text_sel_start = tc->text_sel_end = where;
sp_text_context_update_cursor(tc);
sp_text_context_update_text_selection(tc);
}
-void sp_text_context_place_cursor_at (SPTextContext *tc, SPObject *text, Geom::Point const p)
+void sp_text_context_place_cursor_at (TextTool *tc, SPObject *text, Geom::Point const p)
{
- SP_EVENT_CONTEXT_DESKTOP (tc)->selection->set (text);
+ tc->desktop->selection->set (text);
sp_text_context_place_cursor (tc, text, sp_te_get_position_by_coords(tc->text, p));
}
-Inkscape::Text::Layout::iterator *sp_text_context_get_cursor_position(SPTextContext *tc, SPObject *text)
+Inkscape::Text::Layout::iterator *sp_text_context_get_cursor_position(TextTool *tc, SPObject *text)
{
if (text != tc->text)
return NULL;
return &(tc->text_sel_end);
}
+}
+}
+}
/*
Local Variables:
diff --git a/src/text-context.h b/src/ui/tools/text-tool.h
index 95b812c2b..ef8a67984 100644
--- a/src/text-context.h
+++ b/src/ui/tools/text-tool.h
@@ -2,7 +2,7 @@
#define __SP_TEXT_CONTEXT_H__
/*
- * SPTextContext
+ * TextTool
*
* Authors:
* Lauris Kaplinski <lauris@kaplinski.com>
@@ -19,19 +19,23 @@
#include <sigc++/sigc++.h>
#include <gtk/gtk.h>
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include <2geom/point.h>
#include "libnrtype/Layout-TNG.h"
-#define SP_TEXT_CONTEXT(obj) (dynamic_cast<SPTextContext*>((SPEventContext*)obj))
-#define SP_IS_TEXT_CONTEXT(obj) (dynamic_cast<const SPTextContext*>((const SPEventContext*)obj) != NULL)
+#define SP_TEXT_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::TextTool*>((Inkscape::UI::Tools::ToolBase*)obj))
+#define SP_IS_TEXT_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::TextTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL)
struct SPCtrlLine;
-class SPTextContext : public SPEventContext {
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class TextTool : public ToolBase {
public:
- SPTextContext();
- virtual ~SPTextContext();
+ TextTool();
+ virtual ~TextTool();
sigc::connection sel_changed_connection;
sigc::connection sel_modified_connection;
@@ -82,12 +86,16 @@ public:
virtual const std::string& getPrefsPath();
};
-bool sp_text_paste_inline(SPEventContext *ec);
-Glib::ustring sp_text_get_selected_text(SPEventContext const *ec);
-SPCSSAttr *sp_text_get_style_at_cursor(SPEventContext const *ec);
-bool sp_text_delete_selection(SPEventContext *ec);
-void sp_text_context_place_cursor (SPTextContext *tc, SPObject *text, Inkscape::Text::Layout::iterator where);
-void sp_text_context_place_cursor_at (SPTextContext *tc, SPObject *text, Geom::Point const p);
-Inkscape::Text::Layout::iterator *sp_text_context_get_cursor_position(SPTextContext *tc, SPObject *text);
+bool sp_text_paste_inline(ToolBase *ec);
+Glib::ustring sp_text_get_selected_text(ToolBase const *ec);
+SPCSSAttr *sp_text_get_style_at_cursor(ToolBase const *ec);
+bool sp_text_delete_selection(ToolBase *ec);
+void sp_text_context_place_cursor (TextTool *tc, SPObject *text, Inkscape::Text::Layout::iterator where);
+void sp_text_context_place_cursor_at (TextTool *tc, SPObject *text, Geom::Point const p);
+Inkscape::Text::Layout::iterator *sp_text_context_get_cursor_position(TextTool *tc, SPObject *text);
+
+}
+}
+}
#endif
diff --git a/src/event-context.cpp b/src/ui/tools/tool-base.cpp
index 398d3b0e3..6c7867633 100644
--- a/src/event-context.cpp
+++ b/src/ui/tools/tool-base.cpp
@@ -24,7 +24,7 @@
#include "shortcuts.h"
#include "file.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include <string.h>
#include <gdk/gdkkeysyms.h>
@@ -52,14 +52,12 @@
#include "attributes.h"
#include "rubberband.h"
#include "selcue.h"
-#include "lpe-tool-context.h"
+#include "ui/tools/lpe-tool.h"
#include "ui/tool/control-point.h"
#include "shape-editor.h"
#include "sp-guide.h"
#include "color.h"
-static void set_event_location(SPDesktop * desktop, GdkEvent * event);
-
// globals for temporary switching to selector by space
static bool selector_toggled = FALSE;
static int switch_selector_to = 0;
@@ -68,29 +66,31 @@ static int switch_selector_to = 0;
static bool dropper_toggled = FALSE;
static int switch_dropper_to = 0;
-//static gint xp = 0, yp = 0; // where drag started
-//static gint tolerance = 0;
-//static bool within_tolerance = false;
-
// globals for keeping track of keyboard scroll events in order to accelerate
static guint32 scroll_event_time = 0;
static gdouble scroll_multiply = 1;
static guint scroll_keyval = 0;
-void SPEventContext::set(const Inkscape::Preferences::Entry& /*val*/) {
-}
-void SPEventContext::activate() {
-}
+namespace Inkscape {
+namespace UI {
+namespace Tools {
-void SPEventContext::deactivate() {
+static void set_event_location(SPDesktop * desktop, GdkEvent * event);
+
+
+void ToolBase::set(const Inkscape::Preferences::Entry& /*val*/) {
}
-void SPEventContext::finish() {
+void ToolBase::finish() {
this->enableSelectionCue(false);
}
-SPEventContext::SPEventContext() {
+SPDesktop const& ToolBase::getDesktop() const {
+ return *desktop;
+}
+
+ToolBase::ToolBase() {
this->hot_y = 0;
this->xp = 0;
this->cursor_shape = 0;
@@ -114,7 +114,7 @@ SPEventContext::SPEventContext() {
//this->tool_url = NULL;
}
-SPEventContext::~SPEventContext() {
+ToolBase::~ToolBase() {
if (this->message_context) {
delete this->message_context;
}
@@ -145,7 +145,7 @@ SPEventContext::~SPEventContext() {
/**
* Set the cursor to a standard GDK cursor
*/
-static void sp_event_context_set_cursor(SPEventContext *event_context, GdkCursorType cursor_type) {
+static void sp_event_context_set_cursor(ToolBase *event_context, GdkCursorType cursor_type) {
GtkWidget *w = GTK_WIDGET(sp_desktop_canvas(event_context->desktop));
GdkDisplay *display = gdk_display_get_default();
@@ -164,9 +164,9 @@ static void sp_event_context_set_cursor(SPEventContext *event_context, GdkCursor
}
/**
- * Recreates and draws cursor on desktop related to SPEventContext.
+ * Recreates and draws cursor on desktop related to ToolBase.
*/
-void SPEventContext::sp_event_context_update_cursor() {
+void ToolBase::sp_event_context_update_cursor() {
GtkWidget *w = GTK_WIDGET(sp_desktop_canvas(this->desktop));
if (gtk_widget_get_window (w)) {
@@ -223,14 +223,12 @@ void SPEventContext::sp_event_context_update_cursor() {
}
/**
- * Callback that gets called on initialization of SPEventContext object.
+ * Callback that gets called on initialization of ToolBase object.
* Redraws mouse cursor, at the moment.
- */
-
-/**
+ *
* When you override it, call this method first.
*/
-void SPEventContext::setup() {
+void ToolBase::setup() {
this->pref_observer = new ToolPrefObserver(this->getPrefsPath(), this);
Inkscape::Preferences::get()->addObserver(*(this->pref_observer));
@@ -352,16 +350,7 @@ static gdouble accelerate_scroll(GdkEvent *event, gdouble acceleration,
return scroll_multiply;
}
-/**
- * Main event dispatch, gets called from Gdk.
- */
-//static gint sp_event_context_private_root_handler(
-// SPEventContext *event_context, GdkEvent *event) {
-//
-// return event_context->ceventcontext->root_handler(event);
-//}
-
-bool SPEventContext::root_handler(GdkEvent* event) {
+bool ToolBase::root_handler(GdkEvent* event) {
static Geom::Point button_w;
static unsigned int panning = 0;
static unsigned int panning_cursor = 0;
@@ -866,13 +855,7 @@ bool SPEventContext::root_handler(GdkEvent* event) {
* Only reacts to right mouse button at the moment.
* \todo Fixme: do context sensitive popup menu on items.
*/
-//gint sp_event_context_private_item_handler(SPEventContext *ec, SPItem *item,
-// GdkEvent *event) {
-//
-// return ec->ceventcontext->item_handler(item, event);
-//}
-
-bool SPEventContext::item_handler(SPItem* item, GdkEvent* event) {
+bool ToolBase::item_handler(SPItem* item, GdkEvent* event) {
int ret = FALSE;
switch (event->type) {
@@ -893,7 +876,7 @@ bool SPEventContext::item_handler(SPItem* item, GdkEvent* event) {
/**
* Returns true if we're hovering above a knot (needed because we don't want to pre-snap in that case).
*/
-bool sp_event_context_knot_mouseover(SPEventContext *ec)
+bool sp_event_context_knot_mouseover(ToolBase *ec)
{
if (ec->shape_editor) {
return ec->shape_editor->knot_mouseover();
@@ -903,61 +886,9 @@ bool sp_event_context_knot_mouseover(SPEventContext *ec)
}
/**
- * Creates new SPEventContext object and calls its virtual setup() function.
- * @todo This is bogus. pref_path should be a private property of the inheriting objects.
- */
-//SPEventContext *
-//sp_event_context_new(GType type, SPDesktop *desktop, gchar const *pref_path,
-// unsigned int key) {
-// g_return_val_if_fail(g_type_is_a(type, SP_TYPE_EVENT_CONTEXT), NULL);
-// g_return_val_if_fail(desktop != NULL, NULL);
-//
-// SPEventContext * const ec = static_cast<SPEventContext*>(g_object_new(type, NULL));
-//
-// ec->desktop = desktop;
-// ec->_message_context
-// = new Inkscape::MessageContext(desktop->messageStack());
-// ec->key = key;
-// ec->pref_observer = NULL;
-//
-// if (pref_path) {
-// ec->pref_observer = new ToolPrefObserver(pref_path, ec);
-//
-// Inkscape::Preferences *prefs = Inkscape::Preferences::get();
-// prefs->addObserver(*(ec->pref_observer));
-// }
-//
-//// if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->setup)
-//// (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->setup(ec);
-// ec->ceventcontext->setup();
-//
-// return ec;
-//}
-
-/**
- * Finishes SPEventContext.
+ * Enables/disables the ToolBase's SelCue.
*/
-//void sp_event_context_finish(SPEventContext *ec) {
-// g_return_if_fail(ec != NULL);
-// g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
-//
-// ec->enableSelectionCue(false);
-//
-//// if (ec->next) {
-//// g_warning("Finishing event context with active link\n");
-//// }
-//
-//// if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->finish)
-//// (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->finish(ec);
-// ec->finish();
-//}
-
-//-------------------------------member functions
-
-/**
- * Enables/disables the SPEventContext's SelCue.
- */
-void SPEventContext::enableSelectionCue(bool enable) {
+void ToolBase::enableSelectionCue(bool enable) {
if (enable) {
if (!_selcue) {
_selcue = new Inkscape::SelCue(desktop);
@@ -969,9 +900,9 @@ void SPEventContext::enableSelectionCue(bool enable) {
}
/**
- * Enables/disables the SPEventContext's GrDrag.
+ * Enables/disables the ToolBase's GrDrag.
*/
-void SPEventContext::enableGrDrag(bool enable) {
+void ToolBase::enableGrDrag(bool enable) {
if (enable) {
if (!_grdrag) {
_grdrag = new GrDrag(desktop);
@@ -987,7 +918,7 @@ void SPEventContext::enableGrDrag(bool enable) {
/**
* Delete a selected GrDrag point
*/
-bool SPEventContext::deleteSelectedDrag(bool just_one) {
+bool ToolBase::deleteSelectedDrag(bool just_one) {
if (_grdrag && _grdrag->selected) {
_grdrag->deleteSelected(just_one);
@@ -998,58 +929,22 @@ bool SPEventContext::deleteSelectedDrag(bool just_one) {
}
/**
- * Calls virtual set() function of SPEventContext.
+ * Calls virtual set() function of ToolBase.
*/
-void sp_event_context_read(SPEventContext *ec, gchar const *key) {
+void sp_event_context_read(ToolBase *ec, gchar const *key) {
g_return_if_fail(ec != NULL);
g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
g_return_if_fail(key != NULL);
-// if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->set) {
-// Inkscape::Preferences *prefs = Inkscape::Preferences::get();
-// Inkscape::Preferences::Entry val = prefs->getEntry(
-// ec->pref_observer->observed_path + '/' + key);
-// (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->set(ec, &val);
-// }
-
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
Inkscape::Preferences::Entry val = prefs->getEntry(ec->pref_observer->observed_path + '/' + key);
ec->set(val);
}
/**
- * Calls virtual activate() function of SPEventContext.
- */
-void sp_event_context_activate(SPEventContext *ec) {
- g_return_if_fail(ec != NULL);
- g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
-
- // Make sure no delayed snapping events are carried over after switching contexts
- // (this is only an additional safety measure against sloppy coding, because each
- // context should take care of this by itself.
- sp_event_context_discard_delayed_snap_event(ec);
-
-// if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->activate)
-// (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->activate(ec);
- ec->activate();
-}
-
-/**
- * Calls virtual deactivate() function of SPEventContext.
- */
-//void sp_event_context_deactivate(SPEventContext *ec) {
-// g_return_if_fail(ec != NULL);
-// g_return_if_fail(SP_IS_EVENT_CONTEXT(ec));
-//
-//// if ((SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->deactivate)
-//// (SP_EVENT_CONTEXT_CLASS(G_OBJECT_GET_CLASS(ec)))->deactivate(ec);
-// ec->deactivate();
-//}
-
-/**
* Calls virtual root_handler(), the main event handling function.
*/
-gint sp_event_context_root_handler(SPEventContext * event_context,
+gint sp_event_context_root_handler(ToolBase * event_context,
GdkEvent * event)
{
switch (event->type) {
@@ -1080,7 +975,7 @@ gint sp_event_context_root_handler(SPEventContext * event_context,
return sp_event_context_virtual_root_handler(event_context, event);
}
-gint sp_event_context_virtual_root_handler(SPEventContext * event_context, GdkEvent * event) {
+gint sp_event_context_virtual_root_handler(ToolBase * event_context, GdkEvent * event) {
gint ret = false;
if (event_context) { // If no event-context is available then do nothing, otherwise Inkscape would crash
// (see the comment in SPDesktop::set_event_context, and bug LP #622350)
@@ -1095,7 +990,7 @@ gint sp_event_context_virtual_root_handler(SPEventContext * event_context, GdkEv
/**
* Calls virtual item_handler(), the item event handling function.
*/
-gint sp_event_context_item_handler(SPEventContext * event_context,
+gint sp_event_context_item_handler(ToolBase * event_context,
SPItem * item, GdkEvent * event) {
switch (event->type) {
case GDK_MOTION_NOTIFY:
@@ -1121,7 +1016,7 @@ gint sp_event_context_item_handler(SPEventContext * event_context,
return sp_event_context_virtual_item_handler(event_context, item, event);
}
-gint sp_event_context_virtual_item_handler(SPEventContext * event_context, SPItem * item, GdkEvent * event) {
+gint sp_event_context_virtual_item_handler(ToolBase * event_context, SPItem * item, GdkEvent * event) {
gint ret = false;
if (event_context) { // If no event-context is available then do nothing, otherwise Inkscape would crash
// (see the comment in SPDesktop::set_event_context, and bug LP #622350)
@@ -1269,7 +1164,7 @@ sp_event_context_over_item(SPDesktop *desktop, SPItem *item,
}
ShapeEditor *
-sp_event_context_get_shape_editor(SPEventContext *ec) {
+sp_event_context_get_shape_editor(ToolBase *ec) {
return ec->shape_editor;
}
@@ -1326,7 +1221,7 @@ void event_context_print_event_info(GdkEvent *event, bool print_return) {
* @param event Pointer to the motion event.
* @param origin Identifier (enum) specifying where the delay (and the call to this method) were initiated.
*/
-void sp_event_context_snap_delay_handler(SPEventContext *ec,
+void sp_event_context_snap_delay_handler(ToolBase *ec,
gpointer const dse_item, gpointer const dse_item2, GdkEventMotion *event,
DelayedSnapEvent::DelayedSnapEventOrigin origin)
{
@@ -1415,7 +1310,7 @@ gboolean sp_event_context_snap_watchdog_callback(gpointer data) {
return FALSE;
}
- SPEventContext *ec = dse->getEventContext();
+ ToolBase *ec = dse->getEventContext();
if (ec == NULL) {
delete dse;
return false;
@@ -1513,12 +1408,16 @@ gboolean sp_event_context_snap_watchdog_callback(gpointer data) {
return FALSE; //Kills the timer and stops it from executing this callback over and over again.
}
-void sp_event_context_discard_delayed_snap_event(SPEventContext *ec) {
+void sp_event_context_discard_delayed_snap_event(ToolBase *ec) {
delete ec->_delayed_snap_event;
ec->_delayed_snap_event = NULL;
ec->desktop->namedview->snap_manager.snapprefs.setSnapPostponedGlobally(false);
}
+}
+}
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/event-context.h b/src/ui/tools/tool-base.h
index 33bab5e3e..7ed5875b1 100644
--- a/src/event-context.h
+++ b/src/ui/tools/tool-base.h
@@ -23,7 +23,6 @@ class GrDrag;
class SPDesktop;
class SPItem;
class ShapeEditor;
-class SPEventContext;
namespace Inkscape {
class MessageContext;
@@ -33,11 +32,17 @@ namespace Inkscape {
}
}
-#define SP_EVENT_CONTEXT(obj) (dynamic_cast<SPEventContext*>((SPEventContext*)obj))
-#define SP_IS_EVENT_CONTEXT(obj) (dynamic_cast<const SPEventContext*>((const SPEventContext*)obj) != NULL)
+#define SP_EVENT_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::ToolBase*>((Inkscape::UI::Tools::ToolBase*)obj))
+#define SP_IS_EVENT_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::ToolBase*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL)
+
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class ToolBase;
gboolean sp_event_context_snap_watchdog_callback(gpointer data);
-void sp_event_context_discard_delayed_snap_event(SPEventContext *ec);
+void sp_event_context_discard_delayed_snap_event(ToolBase *ec);
class DelayedSnapEvent
{
@@ -53,7 +58,7 @@ public:
GUIDE_VRULER
};
- DelayedSnapEvent(SPEventContext *event_context, gpointer const dse_item, gpointer dse_item2, GdkEventMotion const *event, DelayedSnapEvent::DelayedSnapEventOrigin const origin)
+ DelayedSnapEvent(ToolBase *event_context, gpointer const dse_item, gpointer dse_item2, GdkEventMotion const *event, DelayedSnapEvent::DelayedSnapEventOrigin const origin)
: _timer_id(0), _event(NULL), _item(dse_item), _item2(dse_item2), _origin(origin), _event_context(event_context)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -68,7 +73,7 @@ public:
if (_event != NULL) gdk_event_free(_event); // Remove the copy of the original event
}
- SPEventContext* getEventContext() {return _event_context;}
+ ToolBase* getEventContext() {return _event_context;}
DelayedSnapEventOrigin getOrigin() {return _origin;}
GdkEvent* getEvent() {return _event;}
gpointer getItem() {return _item;}
@@ -80,10 +85,10 @@ private:
gpointer _item;
gpointer _item2;
DelayedSnapEventOrigin _origin;
- SPEventContext* _event_context;
+ ToolBase* _event_context;
};
-void sp_event_context_snap_delay_handler(SPEventContext *ec, gpointer const dse_item, gpointer const dse_item2, GdkEventMotion *event, DelayedSnapEvent::DelayedSnapEventOrigin origin);
+void sp_event_context_snap_delay_handler(ToolBase *ec, gpointer const dse_item, gpointer const dse_item2, GdkEventMotion *event, DelayedSnapEvent::DelayedSnapEventOrigin origin);
/**
@@ -92,26 +97,23 @@ void sp_event_context_snap_delay_handler(SPEventContext *ec, gpointer const dse_
* This is per desktop object, which (its derivatives) implements
* different actions bound to mouse events.
*
- * SPEventContext is an abstract base class of all tools. As the name
+ * ToolBase is an abstract base class of all tools. As the name
* indicates, event context implementations process UI events (mouse
* movements and keypresses) and take actions (like creating or modifying
* objects). There is one event context implementation for each tool,
* plus few abstract base classes. Writing a new tool involves
- * subclassing SPEventContext.
+ * subclassing ToolBase.
*/
-class SPEventContext {
+class ToolBase {
public:
void enableSelectionCue (bool enable=true);
void enableGrDrag (bool enable=true);
bool deleteSelectedDrag(bool just_one);
- SPEventContext();
- virtual ~SPEventContext();
+ ToolBase();
+ virtual ~ToolBase();
- SPDesktop *desktop;
Inkscape::Preferences::Observer *pref_observer;
- gchar const *const *cursor_shape;
- gint hot_x, hot_y; ///< indicates the cursor's hot spot
GdkCursor *cursor;
gint xp, yp; ///< where drag started
@@ -145,9 +147,6 @@ public:
// Is called by our pref_observer if a preference has been changed.
virtual void set(const Inkscape::Preferences::Entry& val);
- virtual void activate();
- virtual void deactivate();
-
virtual bool root_handler(GdkEvent* event);
virtual bool item_handler(SPItem* item, GdkEvent* event);
@@ -158,7 +157,7 @@ public:
*/
class ToolPrefObserver: public Inkscape::Preferences::Observer {
public:
- ToolPrefObserver(Glib::ustring const &path, SPEventContext *ec) :
+ ToolPrefObserver(Glib::ustring const &path, ToolBase *ec) :
Inkscape::Preferences::Observer(path), ec(ec) {
}
@@ -167,40 +166,38 @@ public:
}
private:
- SPEventContext * const ec;
+ ToolBase * const ec;
};
+ SPDesktop const& getDesktop() const;
+
+
//protected:
void sp_event_context_update_cursor();
-private:
- SPEventContext(const SPEventContext&);
- SPEventContext& operator=(const SPEventContext&);
-};
+ SPDesktop *desktop;
-#define SP_EVENT_CONTEXT_DESKTOP(e) (SP_EVENT_CONTEXT(e)->desktop)
-#define SP_EVENT_CONTEXT_DOCUMENT(e) ((SP_EVENT_CONTEXT_DESKTOP(e))->doc())
+protected:
+ gchar const *const *cursor_shape;
+ gint hot_x, hot_y; ///< indicates the cursor's hot spot
-#define SP_EVENT_CONTEXT_STATIC 0
+private:
+ ToolBase(const ToolBase&);
+ ToolBase& operator=(const ToolBase&);
+};
-//SPEventContext *sp_event_context_new(GType type, SPDesktop *desktop, gchar const *pref_path, unsigned key);
-//void sp_event_context_finish(SPEventContext *ec);
-void sp_event_context_read(SPEventContext *ec, gchar const *key);
-void sp_event_context_activate(SPEventContext *ec);
-//void sp_event_context_deactivate(SPEventContext *ec);
+void sp_event_context_read(ToolBase *ec, gchar const *key);
-gint sp_event_context_root_handler(SPEventContext *ec, GdkEvent *event);
-gint sp_event_context_virtual_root_handler(SPEventContext *ec, GdkEvent *event);
-gint sp_event_context_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event);
-gint sp_event_context_virtual_item_handler(SPEventContext *ec, SPItem *item, GdkEvent *event);
+gint sp_event_context_root_handler(ToolBase *ec, GdkEvent *event);
+gint sp_event_context_virtual_root_handler(ToolBase *ec, GdkEvent *event);
+gint sp_event_context_item_handler(ToolBase *ec, SPItem *item, GdkEvent *event);
+gint sp_event_context_virtual_item_handler(ToolBase *ec, SPItem *item, GdkEvent *event);
void sp_event_root_menu_popup(SPDesktop *desktop, SPItem *item, GdkEvent *event);
gint gobble_key_events(guint keyval, gint mask);
gint gobble_motion_events(gint mask);
-//void sp_event_context_update_cursor(SPEventContext *ec);
-
void sp_event_show_modifier_tip(Inkscape::MessageContext *message_context, GdkEvent *event,
gchar const *ctrl_tip, gchar const *shift_tip, gchar const *alt_tip);
@@ -211,14 +208,11 @@ SPItem *sp_event_context_over_item (SPDesktop *desktop, SPItem *item, Geom::Poin
void sp_toggle_dropper(SPDesktop *dt);
-//ShapeEditor *sp_event_context_get_shape_editor (SPEventContext *ec);
-bool sp_event_context_knot_mouseover(SPEventContext *ec);
+bool sp_event_context_knot_mouseover(ToolBase *ec);
-//void ec_shape_event_attr_changed(Inkscape::XML::Node *shape_repr,
-// gchar const *name, gchar const *old_value, gchar const *new_value,
-// bool const is_interactive, gpointer const data);
-//
-//void event_context_print_event_info(GdkEvent *event, bool print_return = true);
+}
+}
+}
#endif // SEEN_SP_EVENT_CONTEXT_H
diff --git a/src/tweak-context.cpp b/src/ui/tools/tweak-tool.cpp
index a8841985d..0791eff5a 100644
--- a/src/tweak-context.cpp
+++ b/src/ui/tools/tweak-tool.cpp
@@ -83,7 +83,7 @@
#include "filters/gaussian-blur.h"
#include "verbs.h"
-#include "tweak-context.h"
+#include "ui/tools/tweak-tool.h"
using Inkscape::DocumentUndo;
@@ -93,21 +93,25 @@ using Inkscape::DocumentUndo;
#include "tool-factory.h"
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
namespace {
- SPEventContext* createTweakContext() {
- return new SPTweakContext();
+ ToolBase* createTweakContext() {
+ return new TweakTool();
}
bool tweakContextRegistered = ToolFactory::instance().registerObject("/tools/tweak", createTweakContext);
}
-const std::string& SPTweakContext::getPrefsPath() {
- return SPTweakContext::prefsPath;
+const std::string& TweakTool::getPrefsPath() {
+ return TweakTool::prefsPath;
}
-const std::string SPTweakContext::prefsPath = "/tools/tweak";
+const std::string TweakTool::prefsPath = "/tools/tweak";
-SPTweakContext::SPTweakContext() : SPEventContext() {
+TweakTool::TweakTool() : ToolBase() {
this->mode = 0;
this->dilate_area = 0;
this->usetilt = 0;
@@ -135,7 +139,7 @@ SPTweakContext::SPTweakContext() : SPEventContext() {
this->do_o = false;
}
-SPTweakContext::~SPTweakContext() {
+TweakTool::~TweakTool() {
this->enableGrDrag(false);
this->style_set_connection.disconnect();
@@ -161,7 +165,7 @@ static bool is_color_mode (gint mode)
return (mode == TWEAK_MODE_COLORPAINT || mode == TWEAK_MODE_COLORJITTER || mode == TWEAK_MODE_BLUR);
}
-void SPTweakContext::update_cursor (bool with_shift) {
+void TweakTool::update_cursor (bool with_shift) {
guint num = 0;
gchar *sel_message = NULL;
@@ -255,7 +259,7 @@ void SPTweakContext::update_cursor (bool with_shift) {
g_free(sel_message);
}
-bool SPTweakContext::set_style(const SPCSSAttr* css) {
+bool TweakTool::set_style(const SPCSSAttr* css) {
if (this->mode == TWEAK_MODE_COLORPAINT) { // intercept color setting only in this mode
// we cannot store properties with uris
css = sp_css_attr_unset_uris(const_cast<SPCSSAttr *>(css));
@@ -267,8 +271,8 @@ bool SPTweakContext::set_style(const SPCSSAttr* css) {
return false;
}
-void SPTweakContext::setup() {
- SPEventContext::setup();
+void TweakTool::setup() {
+ ToolBase::setup();
{
/* TODO: have a look at sp_dyna_draw_context_setup where the same is done.. generalize? at least make it an arcto! */
@@ -298,7 +302,7 @@ void SPTweakContext::setup() {
this->style_set_connection = this->desktop->connectSetStyle( // catch style-setting signal in this tool
//sigc::bind(sigc::ptr_fun(&sp_tweak_context_style_set), this)
- sigc::mem_fun(this, &SPTweakContext::set_style)
+ sigc::mem_fun(this, &TweakTool::set_style)
);
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
@@ -310,7 +314,7 @@ void SPTweakContext::setup() {
}
}
-void SPTweakContext::set(const Inkscape::Preferences::Entry& val) {
+void TweakTool::set(const Inkscape::Preferences::Entry& val) {
Glib::ustring path = val.getEntryName();
if (path == "width") {
@@ -336,7 +340,7 @@ void SPTweakContext::set(const Inkscape::Preferences::Entry& val) {
}
static void
-sp_tweak_extinput(SPTweakContext *tc, GdkEvent *event)
+sp_tweak_extinput(TweakTool *tc, GdkEvent *event)
{
if (gdk_event_get_axis (event, GDK_AXIS_PRESSURE, &tc->pressure)) {
tc->pressure = CLAMP (tc->pressure, TC_MIN_PRESSURE, TC_MAX_PRESSURE);
@@ -346,14 +350,14 @@ sp_tweak_extinput(SPTweakContext *tc, GdkEvent *event)
}
static double
-get_dilate_radius (SPTweakContext *tc)
+get_dilate_radius (TweakTool *tc)
{
// 10 times the pen width:
return 500 * tc->width/SP_EVENT_CONTEXT(tc)->desktop->current_zoom();
}
static double
-get_path_force (SPTweakContext *tc)
+get_path_force (TweakTool *tc)
{
double force = 8 * (tc->usepressure? tc->pressure : TC_DEFAULT_PRESSURE)
/sqrt(SP_EVENT_CONTEXT(tc)->desktop->current_zoom());
@@ -364,7 +368,7 @@ get_path_force (SPTweakContext *tc)
}
static double
-get_move_force (SPTweakContext *tc)
+get_move_force (TweakTool *tc)
{
double force = (tc->usepressure? tc->pressure : TC_DEFAULT_PRESSURE);
return force * tc->force;
@@ -1021,7 +1025,7 @@ sp_tweak_color_recursive (guint mode, SPItem *item, SPItem *item_at_point,
static bool
-sp_tweak_dilate (SPTweakContext *tc, Geom::Point event_p, Geom::Point p, Geom::Point vector, bool reverse)
+sp_tweak_dilate (TweakTool *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;
@@ -1111,7 +1115,7 @@ sp_tweak_dilate (SPTweakContext *tc, Geom::Point event_p, Geom::Point p, Geom::P
}
static void
-sp_tweak_update_area (SPTweakContext *tc)
+sp_tweak_update_area (TweakTool *tc)
{
double radius = get_dilate_radius(tc);
Geom::Affine const sm (Geom::Scale(radius, radius) * Geom::Translate(SP_EVENT_CONTEXT(tc)->desktop->point()));
@@ -1120,7 +1124,7 @@ sp_tweak_update_area (SPTweakContext *tc)
}
static void
-sp_tweak_switch_mode (SPTweakContext *tc, gint mode, bool with_shift)
+sp_tweak_switch_mode (TweakTool *tc, gint mode, bool with_shift)
{
SP_EVENT_CONTEXT(tc)->desktop->setToolboxSelectOneValue ("tweak_tool_mode", mode);
// need to set explicitly, because the prefs may not have changed by the previous
@@ -1129,7 +1133,7 @@ sp_tweak_switch_mode (SPTweakContext *tc, gint mode, bool with_shift)
}
static void
-sp_tweak_switch_mode_temporarily (SPTweakContext *tc, gint mode, bool with_shift)
+sp_tweak_switch_mode_temporarily (TweakTool *tc, gint mode, bool with_shift)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
// Juggling about so that prefs have the old value but tc->mode and the button show new mode:
@@ -1142,7 +1146,7 @@ sp_tweak_switch_mode_temporarily (SPTweakContext *tc, gint mode, bool with_shift
tc->update_cursor(with_shift);
}
-bool SPTweakContext::root_handler(GdkEvent* event) {
+bool TweakTool::root_handler(GdkEvent* event) {
gint ret = FALSE;
switch (event->type) {
@@ -1498,12 +1502,15 @@ bool SPTweakContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPEventContext::root_handler(event);
+ ret = ToolBase::root_handler(event);
}
return ret;
}
+}
+}
+}
/*
Local Variables:
diff --git a/src/tweak-context.h b/src/ui/tools/tweak-tool.h
index da1a50a79..6cbb9aded 100644
--- a/src/tweak-context.h
+++ b/src/ui/tools/tweak-tool.h
@@ -12,7 +12,7 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include <2geom/point.h>
#define SAMPLING_SIZE 8 /* fixme: ?? */
@@ -21,6 +21,10 @@
#define TC_MAX_PRESSURE 1.0
#define TC_DEFAULT_PRESSURE 0.35
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
enum {
TWEAK_MODE_MOVE,
TWEAK_MODE_MOVE_IN_OUT,
@@ -37,10 +41,10 @@ enum {
TWEAK_MODE_BLUR
};
-class SPTweakContext : public SPEventContext {
+class TweakTool : public ToolBase {
public:
- SPTweakContext();
- virtual ~SPTweakContext();
+ TweakTool();
+ virtual ~TweakTool();
/* extended input data */
gdouble pressure;
@@ -84,6 +88,10 @@ private:
bool set_style(const SPCSSAttr* css);
};
+}
+}
+}
+
#endif
/*
diff --git a/src/zoom-context.cpp b/src/ui/tools/zoom-tool.cpp
index 6efc122f7..d4ede1053 100644
--- a/src/zoom-context.cpp
+++ b/src/ui/tools/zoom-tool.cpp
@@ -24,24 +24,28 @@
#include "preferences.h"
#include "selection-chemistry.h"
-#include "zoom-context.h"
+#include "ui/tools/zoom-tool.h"
#include "tool-factory.h"
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
namespace {
- SPEventContext* createZoomContext() {
- return new SPZoomContext();
+ ToolBase* createZoomContext() {
+ return new ZoomTool();
}
bool zoomContextRegistered = ToolFactory::instance().registerObject("/tools/zoom", createZoomContext);
}
-const std::string& SPZoomContext::getPrefsPath() {
- return SPZoomContext::prefsPath;
+const std::string& ZoomTool::getPrefsPath() {
+ return ZoomTool::prefsPath;
}
-const std::string SPZoomContext::prefsPath = "/tools/zoom";
+const std::string ZoomTool::prefsPath = "/tools/zoom";
-SPZoomContext::SPZoomContext() : SPEventContext() {
+ZoomTool::ZoomTool() : ToolBase() {
this->grabbed = 0;
this->cursor_shape = cursor_zoom_xpm;
this->hot_x = 6;
@@ -49,10 +53,10 @@ SPZoomContext::SPZoomContext() : SPEventContext() {
this->escaped = false;
}
-SPZoomContext::~SPZoomContext() {
+ZoomTool::~ZoomTool() {
}
-void SPZoomContext::finish() {
+void ZoomTool::finish() {
this->enableGrDrag(false);
if (this->grabbed) {
@@ -61,7 +65,7 @@ void SPZoomContext::finish() {
}
}
-void SPZoomContext::setup() {
+void ZoomTool::setup() {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
if (prefs->getBool("/tools/zoom/selcue")) {
@@ -72,10 +76,10 @@ void SPZoomContext::setup() {
this->enableGrDrag();
}
- SPEventContext::setup();
+ ToolBase::setup();
}
-bool SPZoomContext::root_handler(GdkEvent* event) {
+bool ZoomTool::root_handler(GdkEvent* event) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
tolerance = prefs->getIntLimited("/options/dragtolerance/value", 0, 0, 100);
@@ -224,12 +228,16 @@ bool SPZoomContext::root_handler(GdkEvent* event) {
}
if (!ret) {
- ret = SPEventContext::root_handler(event);
+ ret = ToolBase::root_handler(event);
}
return ret;
}
+}
+}
+}
+
/*
Local Variables:
mode:c++
diff --git a/src/zoom-context.h b/src/ui/tools/zoom-tool.h
index 3e98915af..6e5cca7aa 100644
--- a/src/zoom-context.h
+++ b/src/ui/tools/zoom-tool.h
@@ -13,15 +13,19 @@
* Released under GNU GPL, read the file 'COPYING' for more information
*/
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
-#define SP_ZOOM_CONTEXT(obj) (dynamic_cast<SPZoomContext*>((SPEventContext*)obj))
-#define SP_IS_ZOOM_CONTEXT(obj) (dynamic_cast<const SPZoomContext*>((const SPEventContext*)obj) != NULL)
+#define SP_ZOOM_CONTEXT(obj) (dynamic_cast<Inkscape::UI::Tools::ZoomTool*>((Inkscape::UI::Tools::ToolBase*)obj))
+#define SP_IS_ZOOM_CONTEXT(obj) (dynamic_cast<const Inkscape::UI::Tools::ZoomTool*>((const Inkscape::UI::Tools::ToolBase*)obj) != NULL)
-class SPZoomContext : public SPEventContext {
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class ZoomTool : public ToolBase {
public:
- SPZoomContext();
- virtual ~SPZoomContext();
+ ZoomTool();
+ virtual ~ZoomTool();
static const std::string prefsPath;
@@ -36,4 +40,8 @@ private:
bool escaped;
};
+}
+}
+}
+
#endif
diff --git a/src/ui/widget/rotateable.cpp b/src/ui/widget/rotateable.cpp
index 18d53bf5c..72ec69362 100644
--- a/src/ui/widget/rotateable.cpp
+++ b/src/ui/widget/rotateable.cpp
@@ -19,7 +19,7 @@
#include <gtkmm/eventbox.h>
#include <glibmm/i18n.h>
#include <2geom/point.h>
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "rotateable.h"
namespace Inkscape {
@@ -111,7 +111,7 @@ bool Rotateable::on_motion(GdkEventMotion *event) {
do_motion(force, modifier);
}
}
- gobble_motion_events(GDK_BUTTON1_MASK);
+ Inkscape::UI::Tools::gobble_motion_events(GDK_BUTTON1_MASK);
return true;
}
return false;
diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp
index 3a6b0c7df..aa617353c 100644
--- a/src/ui/widget/selected-style.cpp
+++ b/src/ui/widget/selected-style.cpp
@@ -39,7 +39,7 @@
#include "sp-gradient.h"
#include "svg/svg-color.h"
#include "svg/css-ostringstream.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "message-context.h"
#include "verbs.h"
#include "color.h"
@@ -1439,9 +1439,7 @@ RotateableStrokeWidth::RotateableStrokeWidth(SelectedStyle *parent) :
parent(parent),
startvalue(0),
startvalue_set(false),
- undokey("swrot1"),
- cr(0),
- cr_set(false)
+ undokey("swrot1")
{
}
diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h
index 21e5575ed..9557a8d74 100644
--- a/src/ui/widget/selected-style.h
+++ b/src/ui/widget/selected-style.h
@@ -115,9 +115,6 @@ private:
bool startvalue_set;
gchar const *undokey;
-
- GdkCursor *cr;
- bool cr_set;
};
/**
diff --git a/src/ui/widget/spinbutton.cpp b/src/ui/widget/spinbutton.cpp
index 6cbc15c1b..7709a837b 100644
--- a/src/ui/widget/spinbutton.cpp
+++ b/src/ui/widget/spinbutton.cpp
@@ -16,7 +16,7 @@
#include "unit-menu.h"
#include "unit-tracker.h"
#include "util/expression-evaluator.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
namespace Inkscape {
namespace UI {
@@ -71,7 +71,7 @@ bool SpinButton::on_my_focus_in_event(GdkEventFocus* /*event*/)
bool SpinButton::on_my_key_press_event(GdkEventKey* event)
{
- switch (get_group0_keyval (event)) {
+ switch (Inkscape::UI::Tools::get_group0_keyval (event)) {
case GDK_KEY_Escape:
undo();
return true; // I consumed the event
diff --git a/src/vanishing-point.cpp b/src/vanishing-point.cpp
index 3adcfbb40..361a7a0de 100644
--- a/src/vanishing-point.cpp
+++ b/src/vanishing-point.cpp
@@ -19,7 +19,7 @@
#include "desktop.h"
#include "display/sp-canvas-item.h"
#include "display/sp-ctrlline.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "xml/repr.h"
#include "perspective-line.h"
#include "shape-editor.h"
@@ -632,7 +632,7 @@ VPDrag::updateBoxHandles ()
return;
}
- SPEventContext *ec = inkscape_active_event_context();
+ Inkscape::UI::Tools::ToolBase *ec = inkscape_active_event_context();
g_assert (ec != NULL);
if (ec->shape_editor != NULL) {
ec->shape_editor->update_knotholder();
diff --git a/src/verbs.cpp b/src/verbs.cpp
index bdef0526a..329e63115 100644
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
@@ -44,9 +44,9 @@
#include "desktop-handles.h"
#include "display/curve.h"
#include "document.h"
-#include "draw-context.h"
+#include "ui/tools/freehand-base.h"
#include "extension/effect.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
#include "file.h"
#include "gradient-drag.h"
#include "helper/action.h"
@@ -59,7 +59,7 @@
#include "message-stack.h"
#include "path-chemistry.h"
#include "preferences.h"
-#include "select-context.h"
+#include "ui/tools/select-tool.h"
#include "selection-chemistry.h"
#include "seltrans.h"
#include "shape-editor.h"
@@ -86,7 +86,7 @@
#include "ui/dialog/symbols.h"
#include "ui/dialog/spellcheck.h"
#include "ui/icon-names.h"
-#include "ui/tool/node-tool.h"
+#include "ui/tools/node-tool.h"
#include "selection.h"
#include <gtk/gtk.h>
@@ -1473,7 +1473,7 @@ void ObjectVerb::perform( SPAction *action, void *data)
g_return_if_fail(ensure_desktop_valid(action));
- SPEventContext *ec = dt->event_context;
+ Inkscape::UI::Tools::ToolBase *ec = dt->event_context;
if (sel->isEmpty())
return;
@@ -1622,7 +1622,7 @@ void ContextVerb::perform(SPAction *action, void *data)
tools_switch(dt, TOOLS_MEASURE);
break;
case SP_VERB_CONTEXT_DROPPER:
- sp_toggle_dropper(dt); // Functionality defined in event-context.cpp
+ Inkscape::UI::Tools::sp_toggle_dropper(dt); // Functionality defined in event-context.cpp
break;
case SP_VERB_CONTEXT_CONNECTOR:
tools_switch(dt, TOOLS_CONNECTOR);
@@ -1767,7 +1767,7 @@ void ZoomVerb::perform(SPAction *action, void *data)
{
g_return_if_fail(ensure_desktop_valid(action));
SPDesktop *dt = sp_action_get_desktop(action);
- SPEventContext *ec = dt->event_context;
+ Inkscape::UI::Tools::ToolBase *ec = dt->event_context;
SPDocument *doc = sp_desktop_document(dt);
@@ -1780,7 +1780,7 @@ void ZoomVerb::perform(SPAction *action, void *data)
switch (reinterpret_cast<std::size_t>(data)) {
case SP_VERB_ZOOM_IN:
{
- gint mul = 1 + gobble_key_events(
+ gint mul = 1 + Inkscape::UI::Tools::gobble_key_events(
GDK_KEY_KP_Add, 0); // with any mask
// While drawing with the pen/pencil tool, zoom towards the end of the unfinished path
if (tools_isactive(dt, TOOLS_FREEHAND_PENCIL) || tools_isactive(dt, TOOLS_FREEHAND_PEN)) {
@@ -1798,7 +1798,7 @@ void ZoomVerb::perform(SPAction *action, void *data)
}
case SP_VERB_ZOOM_OUT:
{
- gint mul = 1 + gobble_key_events(
+ gint mul = 1 + Inkscape::UI::Tools::gobble_key_events(
GDK_KEY_KP_Subtract, 0); // with any mask
// While drawing with the pen/pencil tool, zoom away from the end of the unfinished path
if (tools_isactive(dt, TOOLS_FREEHAND_PENCIL) || tools_isactive(dt, TOOLS_FREEHAND_PEN)) {
diff --git a/src/widgets/arc-toolbar.cpp b/src/widgets/arc-toolbar.cpp
index 5569780e7..69b540762 100644
--- a/src/widgets/arc-toolbar.cpp
+++ b/src/widgets/arc-toolbar.cpp
@@ -56,7 +56,7 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../pen-context.h"
+#include "ui/tools/pen-tool.h"
#include "../sp-ellipse.h"
#include "../mod360.h"
diff --git a/src/widgets/box3d-toolbar.cpp b/src/widgets/box3d-toolbar.cpp
index 91d4ebdec..32516bbfb 100644
--- a/src/widgets/box3d-toolbar.cpp
+++ b/src/widgets/box3d-toolbar.cpp
@@ -58,9 +58,9 @@
#include "../ui/icon-names.h"
-#include "../pen-context.h"
+#include "ui/tools/pen-tool.h"
-#include "../box3d-context.h"
+#include "ui/tools/box3d-tool.h"
#include "../box3d.h"
using Inkscape::UI::UXManager;
diff --git a/src/widgets/calligraphy-toolbar.cpp b/src/widgets/calligraphy-toolbar.cpp
index 12228ce56..9f08d3462 100644
--- a/src/widgets/calligraphy-toolbar.cpp
+++ b/src/widgets/calligraphy-toolbar.cpp
@@ -57,7 +57,7 @@
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../pen-context.h"
+#include "ui/tools/pen-tool.h"
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
diff --git a/src/widgets/connector-toolbar.cpp b/src/widgets/connector-toolbar.cpp
index 2e5c2ade1..7230f521c 100644
--- a/src/widgets/connector-toolbar.cpp
+++ b/src/widgets/connector-toolbar.cpp
@@ -55,10 +55,10 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../pen-context.h"
+#include "ui/tools/pen-tool.h"
#include "../sp-namedview.h"
#include "../conn-avoid-ref.h"
-#include "../connector-context.h"
+#include "ui/tools/connector-tool.h"
#include "../graphlayout.h"
#include "../sp-path.h"
@@ -76,13 +76,13 @@ using Inkscape::UI::PrefPusher;
static void sp_connector_path_set_avoid(void)
{
- cc_selection_set_avoid(true);
+ Inkscape::UI::Tools::cc_selection_set_avoid(true);
}
static void sp_connector_path_set_ignore(void)
{
- cc_selection_set_avoid(false);
+ Inkscape::UI::Tools::cc_selection_set_avoid(false);
}
static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl )
@@ -114,7 +114,7 @@ static void sp_connector_orthogonal_toggled( GtkToggleAction* act, GObject *tbl
while (l) {
SPItem *item = SP_ITEM(l->data);
- if (cc_item_is_connector(item)) {
+ if (Inkscape::UI::Tools::cc_item_is_connector(item)) {
item->setAttribute( "inkscape:connector-type",
value, NULL);
item->avoidRef->handleSettingChange();
@@ -163,7 +163,7 @@ static void connector_curvature_changed(GtkAdjustment *adj, GObject* tbl)
while (l) {
SPItem *item = SP_ITEM(l->data);
- if (cc_item_is_connector(item)) {
+ if (Inkscape::UI::Tools::cc_item_is_connector(item)) {
item->setAttribute( "inkscape:connector-curvature",
value, NULL);
item->avoidRef->handleSettingChange();
diff --git a/src/widgets/desktop-widget.cpp b/src/widgets/desktop-widget.cpp
index 3ca433586..7e254cdcd 100644
--- a/src/widgets/desktop-widget.cpp
+++ b/src/widgets/desktop-widget.cpp
@@ -27,7 +27,7 @@
#include <2geom/rect.h>
#include "ui/dialog/dialog-manager.h"
-#include "box3d-context.h"
+#include "ui/tools/box3d-tool.h"
#include "cms-system.h"
#include "conn-avoid-ref.h"
#include "desktop.h"
diff --git a/src/widgets/dropper-toolbar.cpp b/src/widgets/dropper-toolbar.cpp
index 054955d8f..991489b86 100644
--- a/src/widgets/dropper-toolbar.cpp
+++ b/src/widgets/dropper-toolbar.cpp
@@ -54,7 +54,7 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../pen-context.h"
+#include "ui/tools/pen-tool.h"
#include "../tools-switch.h"
using Inkscape::UI::UXManager;
diff --git a/src/widgets/eraser-toolbar.cpp b/src/widgets/eraser-toolbar.cpp
index 1af574ed6..5e09521c9 100644
--- a/src/widgets/eraser-toolbar.cpp
+++ b/src/widgets/eraser-toolbar.cpp
@@ -55,7 +55,7 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../pen-context.h"
+#include "ui/tools/pen-tool.h"
using Inkscape::UI::UXManager;
diff --git a/src/widgets/fill-style.cpp b/src/widgets/fill-style.cpp
index d9d62d3ec..d1d318abe 100644
--- a/src/widgets/fill-style.cpp
+++ b/src/widgets/fill-style.cpp
@@ -88,7 +88,7 @@ private:
static void fillruleChangedCB( SPPaintSelector *psel, SPPaintSelector::FillRule mode, FillNStroke *self );
void selectionModifiedCB(guint flags);
- void eventContextCB(SPDesktop *desktop, SPEventContext *eventcontext);
+ void eventContextCB(SPDesktop *desktop, Inkscape::UI::Tools::ToolBase *eventcontext);
void dragFromPaint();
void updateFromPaint();
@@ -211,7 +211,7 @@ void FillNStroke::setDesktop(SPDesktop *desktop)
if (desktop && desktop->selection) {
selectChangedConn = desktop->selection->connectChanged(sigc::hide(sigc::mem_fun(*this, &FillNStroke::performUpdate)));
subselChangedConn = desktop->connectToolSubselectionChanged(sigc::hide(sigc::mem_fun(*this, &FillNStroke::performUpdate)));
- eventContextConn = desktop->connectEventContextChanged(sigc::hide(sigc::bind(sigc::mem_fun(*this, &FillNStroke::eventContextCB), (SPEventContext *)NULL)));
+ eventContextConn = desktop->connectEventContextChanged(sigc::hide(sigc::bind(sigc::mem_fun(*this, &FillNStroke::eventContextCB), (Inkscape::UI::Tools::ToolBase *)NULL)));
// Must check flags, so can't call performUpdate() directly.
selectModifiedConn = desktop->selection->connectModified(sigc::hide<0>(sigc::mem_fun(*this, &FillNStroke::selectionModifiedCB)));
@@ -224,7 +224,7 @@ void FillNStroke::setDesktop(SPDesktop *desktop)
* Listen to this "change in tool" event, in case a subselection tool (such as Gradient or Node) selection
* is changed back to a selection tool - especially needed for selected gradient stops.
*/
-void FillNStroke::eventContextCB(SPDesktop * /*desktop*/, SPEventContext * /*eventcontext*/)
+void FillNStroke::eventContextCB(SPDesktop * /*desktop*/, Inkscape::UI::Tools::ToolBase * /*eventcontext*/)
{
performUpdate();
}
diff --git a/src/widgets/gradient-toolbar.cpp b/src/widgets/gradient-toolbar.cpp
index f7d2b2bd5..f02185a15 100644
--- a/src/widgets/gradient-toolbar.cpp
+++ b/src/widgets/gradient-toolbar.cpp
@@ -35,7 +35,7 @@
#include "desktop-handles.h"
#include <glibmm/i18n.h>
-#include "gradient-context.h"
+#include "ui/tools/gradient-tool.h"
#include "gradient-drag.h"
#include "sp-linear-gradient.h"
#include "sp-radial-gradient.h"
@@ -54,13 +54,14 @@
#include "svg/css-ostringstream.h"
#include "svg/svg-color.h"
#include "desktop-style.h"
-#include "gradient-context.h"
+#include "ui/tools/gradient-tool.h"
#include "gradient-toolbar.h"
#include "toolbox.h"
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
+using Inkscape::UI::Tools::ToolBase;
void gr_apply_gradient_to_item( SPItem *item, SPGradient *gr, SPGradientType initialType, Inkscape::PaintTarget initialMode, Inkscape::PaintTarget mode );
void gr_apply_gradient(Inkscape::Selection *selection, GrDrag *drag, SPGradient *gr);
@@ -70,8 +71,8 @@ void gr_read_selection( Inkscape::Selection *selection, GrDrag *drag, SPGradient
static gboolean update_stop_list( GtkWidget *stop_combo, SPGradient *gradient, SPStop *new_stop, GtkWidget *widget, bool gr_multi);
static void sp_gradient_vector_widget_load_gradient(GtkWidget *widget, SPGradient *gradient);
static void select_stop_in_list( GtkWidget *combo_box, SPGradient *gradient, SPStop *new_stop, GtkWidget *data, gboolean block);
-static void select_stop_by_drag( GtkWidget *combo_box, SPGradient *gradient, SPEventContext *ev, GtkWidget *data);
-static void select_drag_by_stop( GtkWidget *combo_box, SPGradient *gradient, SPEventContext *ev);
+static void select_stop_by_drag( GtkWidget *combo_box, SPGradient *gradient, ToolBase *ev, GtkWidget *data);
+static void select_drag_by_stop( GtkWidget *combo_box, SPGradient *gradient, ToolBase *ev);
static SPGradient *gr_get_selected_gradient(GtkWidget *widget);
static void gr_stop_set_offset(GtkComboBox *widget, GtkWidget *data);
void add_toolbar_widget(GtkWidget *tbl, GtkWidget *widget);
@@ -373,7 +374,7 @@ static void gr_tb_selection_changed(Inkscape::Selection * /*selection*/, gpointe
Inkscape::Selection *selection = sp_desktop_selection(desktop); // take from desktop, not from args
if (selection) {
- SPEventContext *ev = desktop->getEventContext();
+ ToolBase *ev = desktop->getEventContext();
GrDrag *drag = NULL;
if (ev) {
drag = ev->get_drag();
@@ -585,8 +586,8 @@ static void gr_add_stop(GtkWidget * /*button*/, GtkWidget *vb)
return;
}
- SPEventContext *ev = desktop->getEventContext();
- SPGradientContext *rc = SP_GRADIENT_CONTEXT(ev);
+ ToolBase *ev = desktop->getEventContext();
+ Inkscape::UI::Tools::GradientTool *rc = SP_GRADIENT_CONTEXT(ev);
if (rc) {
sp_gradient_context_add_stops_between_selected_stops(rc);
@@ -607,7 +608,7 @@ static void gr_remove_stop(GtkWidget * /*button*/, GtkWidget *vb)
return;
}
- SPEventContext *ev = desktop->getEventContext();
+ ToolBase *ev = desktop->getEventContext();
GrDrag *drag = NULL;
if (ev) {
drag = ev->get_drag();
@@ -641,7 +642,7 @@ static void gr_reverse(GtkWidget * /*button*/, gpointer data)
/*
* Change desktop drag selection to this stop
*/
-static void select_drag_by_stop( GtkWidget *data, SPGradient *gradient, SPEventContext *ev)
+static void select_drag_by_stop( GtkWidget *data, SPGradient *gradient, ToolBase *ev)
{
if (blocked || !ev || !gradient)
return;
@@ -657,7 +658,7 @@ static void select_drag_by_stop( GtkWidget *data, SPGradient *gradient, SPEventC
blocked = FALSE;
}
-static void select_stop_by_drag(GtkWidget *combo_box, SPGradient *gradient, SPEventContext *ev, GtkWidget *data)
+static void select_stop_by_drag(GtkWidget *combo_box, SPGradient *gradient, ToolBase *ev, GtkWidget *data)
{
if (blocked || !ev || !gradient)
return;
@@ -939,7 +940,7 @@ static void gr_gradient_combo_changed(EgeSelectOneAction *act, gpointer data)
SPDesktop *desktop = static_cast<SPDesktop *>(data);
Inkscape::Selection *selection = sp_desktop_selection(desktop);
- SPEventContext *ev = desktop->getEventContext();
+ ToolBase *ev = desktop->getEventContext();
gr_apply_gradient(selection, ev? ev->get_drag() : NULL, gr);
@@ -981,7 +982,7 @@ static void gr_stop_combo_changed(GtkComboBox * /*widget*/, GtkWidget *data)
}
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(G_OBJECT(data), "desktop"));
- SPEventContext *ev = desktop->getEventContext();
+ ToolBase *ev = desktop->getEventContext();
SPGradient *gr = gr_get_selected_gradient(data);
select_drag_by_stop(data, gr, ev);
diff --git a/src/widgets/lpe-toolbar.cpp b/src/widgets/lpe-toolbar.cpp
index 045d7aa78..559f3fc3c 100644
--- a/src/widgets/lpe-toolbar.cpp
+++ b/src/widgets/lpe-toolbar.cpp
@@ -59,12 +59,12 @@
#include "../helper/action-context.h"
#include "util/units.h"
#include "ui/widget/unit-tracker.h"
-#include "../pen-context.h"
+#include "ui/tools/pen-tool.h"
#include "../sp-namedview.h"
#include "../tools-switch.h"
#include "../live_effects/effect.h"
#include "../live_effects/lpe-angle_bisector.h"
-#include "../lpe-tool-context.h"
+#include "ui/tools/lpe-tool.h"
using Inkscape::UI::Widget::UnitTracker;
using Inkscape::Util::Unit;
@@ -73,6 +73,8 @@ using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
using Inkscape::UI::PrefPusher;
+using Inkscape::UI::Tools::ToolBase;
+using Inkscape::UI::Tools::LpeTool;
//########################
@@ -87,7 +89,7 @@ static void sp_lpetool_mode_changed(EgeSelectOneAction *act, GObject *tbl)
using namespace Inkscape::LivePathEffect;
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data(tbl, "desktop"));
- SPEventContext *ec = desktop->event_context;
+ ToolBase *ec = desktop->event_context;
if (!SP_IS_LPETOOL_CONTEXT(ec)) {
return;
}
@@ -100,7 +102,7 @@ static void sp_lpetool_mode_changed(EgeSelectOneAction *act, GObject *tbl)
gint mode = ege_select_one_action_get_active(act);
EffectType type = lpesubtools[mode].type;
- SPLPEToolContext *lc = SP_LPETOOL_CONTEXT(desktop->event_context);
+ LpeTool *lc = SP_LPETOOL_CONTEXT(desktop->event_context);
bool success = lpetool_try_construction(lc, type);
if (success) {
// since the construction was already performed, we set the state back to inactive
@@ -122,7 +124,7 @@ static void sp_lpetool_mode_changed(EgeSelectOneAction *act, GObject *tbl)
static void sp_lpetool_toolbox_sel_modified(Inkscape::Selection *selection, guint /*flags*/, GObject * /*tbl*/)
{
- SPEventContext *ec = selection->desktop()->event_context;
+ ToolBase *ec = selection->desktop()->event_context;
if (SP_IS_LPETOOL_CONTEXT(ec)) {
lpetool_update_measuring_items(SP_LPETOOL_CONTEXT(ec));
}
@@ -131,11 +133,11 @@ static void sp_lpetool_toolbox_sel_modified(Inkscape::Selection *selection, guin
static void sp_lpetool_toolbox_sel_changed(Inkscape::Selection *selection, GObject *tbl)
{
using namespace Inkscape::LivePathEffect;
- SPEventContext *ec = selection->desktop()->event_context;
+ ToolBase *ec = selection->desktop()->event_context;
if (!SP_IS_LPETOOL_CONTEXT(ec)) {
return;
}
- SPLPEToolContext *lc = SP_LPETOOL_CONTEXT(ec);
+ LpeTool *lc = SP_LPETOOL_CONTEXT(ec);
lpetool_delete_measuring_items(lc);
lpetool_create_measuring_items(lc, selection);
@@ -172,7 +174,7 @@ static void lpetool_toggle_show_bbox(GtkToggleAction *act, gpointer data) {
prefs->setBool("/tools/lpetool/show_bbox", show);
if (tools_isactive(desktop, TOOLS_LPETOOL)) {
- SPLPEToolContext *lc = SP_LPETOOL_CONTEXT(desktop->event_context);
+ LpeTool *lc = SP_LPETOOL_CONTEXT(desktop->event_context);
lpetool_context_reset_limiting_bbox(lc);
}
}
@@ -185,7 +187,7 @@ static void lpetool_toggle_show_measuring_info(GtkToggleAction *act, GObject *tb
}
GtkAction *unitact = static_cast<GtkAction*>(g_object_get_data(tbl, "lpetool_units_action"));
- SPLPEToolContext *lc = SP_LPETOOL_CONTEXT(desktop->event_context);
+ LpeTool *lc = SP_LPETOOL_CONTEXT(desktop->event_context);
if (tools_isactive(desktop, TOOLS_LPETOOL)) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
bool show = gtk_toggle_action_get_active( act );
@@ -204,7 +206,7 @@ static void lpetool_unit_changed(GtkAction* /*act*/, GObject* tbl)
SPDesktop *desktop = static_cast<SPDesktop *>(g_object_get_data( tbl, "desktop" ));
if (SP_IS_LPETOOL_CONTEXT(desktop->event_context)) {
- SPLPEToolContext *lc = SP_LPETOOL_CONTEXT(desktop->event_context);
+ LpeTool *lc = SP_LPETOOL_CONTEXT(desktop->event_context);
lpetool_delete_measuring_items(lc);
lpetool_create_measuring_items(lc);
}
diff --git a/src/widgets/measure-toolbar.cpp b/src/widgets/measure-toolbar.cpp
index 58244566d..a75dd7600 100644
--- a/src/widgets/measure-toolbar.cpp
+++ b/src/widgets/measure-toolbar.cpp
@@ -52,7 +52,7 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../pen-context.h"
+#include "ui/tools/pen-tool.h"
#include "../sp-namedview.h"
#include "ui/widget/unit-tracker.h"
diff --git a/src/widgets/mesh-toolbar.cpp b/src/widgets/mesh-toolbar.cpp
index 582243870..15dda94f0 100644
--- a/src/widgets/mesh-toolbar.cpp
+++ b/src/widgets/mesh-toolbar.cpp
@@ -41,7 +41,7 @@
#include "desktop-handles.h"
#include <glibmm/i18n.h>
-#include "gradient-context.h"
+#include "ui/tools/gradient-tool.h"
#include "gradient-drag.h"
#include "sp-mesh-gradient.h"
#include "gradient-chemistry.h"
@@ -59,7 +59,7 @@
#include "svg/css-ostringstream.h"
#include "svg/svg-color.h"
#include "desktop-style.h"
-#include "gradient-context.h"
+#include "ui/tools/gradient-tool.h"
#include "toolbox.h"
@@ -94,7 +94,7 @@ static void ms_tb_selection_changed(Inkscape::Selection * /*selection*/, gpointe
// Inkscape::Selection *selection = sp_desktop_selection(desktop); // take from desktop, not from args
// if (selection) {
- // SPEventContext *ev = sp_desktop_event_context(desktop);
+ // ToolBase *ev = sp_desktop_event_context(desktop);
// GrDrag *drag = NULL;
// if (ev) {
// drag = ev->get_drag();
diff --git a/src/widgets/node-toolbar.cpp b/src/widgets/node-toolbar.cpp
index 0d4868642..6a0968424 100644
--- a/src/widgets/node-toolbar.cpp
+++ b/src/widgets/node-toolbar.cpp
@@ -55,12 +55,12 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/tool/control-point-selection.h"
-#include "../ui/tool/node-tool.h"
+#include "ui/tools/node-tool.h"
#include "../ui/tool/multi-path-manipulator.h"
#include "../ui/icon-names.h"
#include "util/units.h"
#include "ui/widget/unit-tracker.h"
-#include "../lpe-tool-context.h"
+#include "ui/tools/lpe-tool.h"
#include "../sp-namedview.h"
using Inkscape::UI::Widget::UnitTracker;
@@ -71,6 +71,7 @@ using Inkscape::DocumentUndo;
using Inkscape::UI::ToolboxFactory;
using Inkscape::UI::PrefPusher;
using Inkscape::Util::unit_table;
+using Inkscape::UI::Tools::NodeTool;
//####################################
//# node editing callbacks
@@ -78,13 +79,13 @@ using Inkscape::Util::unit_table;
/** Temporary hack: Returns the node tool in the active desktop.
* Will go away during tool refactoring. */
-static InkNodeTool *get_node_tool()
+static NodeTool *get_node_tool()
{
- InkNodeTool *tool = 0;
+ NodeTool *tool = 0;
if (SP_ACTIVE_DESKTOP ) {
- SPEventContext *ec = SP_ACTIVE_DESKTOP->event_context;
+ Inkscape::UI::Tools::ToolBase *ec = SP_ACTIVE_DESKTOP->event_context;
if (INK_IS_NODE_TOOL(ec)) {
- tool = static_cast<InkNodeTool*>(ec);
+ tool = static_cast<NodeTool*>(ec);
}
}
return tool;
@@ -92,7 +93,7 @@ static InkNodeTool *get_node_tool()
static void sp_node_path_edit_add(void)
{
- InkNodeTool *nt = get_node_tool();
+ NodeTool *nt = get_node_tool();
if (nt) {
nt->_multipath->insertNodes();
}
@@ -100,28 +101,28 @@ static void sp_node_path_edit_add(void)
static void sp_node_path_edit_add_min_x(void)
{
- InkNodeTool *nt = get_node_tool();
+ NodeTool *nt = get_node_tool();
if (nt) {
nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MIN_X);
}
}
static void sp_node_path_edit_add_max_x(void)
{
- InkNodeTool *nt = get_node_tool();
+ NodeTool *nt = get_node_tool();
if (nt) {
nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MAX_X);
}
}
static void sp_node_path_edit_add_min_y(void)
{
- InkNodeTool *nt = get_node_tool();
+ NodeTool *nt = get_node_tool();
if (nt) {
nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MIN_Y);
}
}
static void sp_node_path_edit_add_max_y(void)
{
- InkNodeTool *nt = get_node_tool();
+ NodeTool *nt = get_node_tool();
if (nt) {
nt->_multipath->insertNodesAtExtrema(Inkscape::UI::PointManipulator::EXTR_MAX_Y);
}
@@ -129,7 +130,7 @@ static void sp_node_path_edit_add_max_y(void)
static void sp_node_path_edit_delete(void)
{
- InkNodeTool *nt = get_node_tool();
+ NodeTool *nt = get_node_tool();
if (nt) {
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
nt->_multipath->deleteNodes(prefs->getBool("/tools/nodes/delete_preserves_shape", true));
@@ -138,7 +139,7 @@ static void sp_node_path_edit_delete(void)
static void sp_node_path_edit_delete_segment(void)
{
- InkNodeTool *nt = get_node_tool();
+ NodeTool *nt = get_node_tool();
if (nt) {
nt->_multipath->deleteSegments();
}
@@ -146,7 +147,7 @@ static void sp_node_path_edit_delete_segment(void)
static void sp_node_path_edit_break(void)
{
- InkNodeTool *nt = get_node_tool();
+ NodeTool *nt = get_node_tool();
if (nt) {
nt->_multipath->breakNodes();
}
@@ -154,7 +155,7 @@ static void sp_node_path_edit_break(void)
static void sp_node_path_edit_join(void)
{
- InkNodeTool *nt = get_node_tool();
+ NodeTool *nt = get_node_tool();
if (nt) {
nt->_multipath->joinNodes();
}
@@ -162,7 +163,7 @@ static void sp_node_path_edit_join(void)
static void sp_node_path_edit_join_segment(void)
{
- InkNodeTool *nt = get_node_tool();
+ NodeTool *nt = get_node_tool();
if (nt) {
nt->_multipath->joinSegments();
}
@@ -170,7 +171,7 @@ static void sp_node_path_edit_join_segment(void)
static void sp_node_path_edit_toline(void)
{
- InkNodeTool *nt = get_node_tool();
+ NodeTool *nt = get_node_tool();
if (nt) {
nt->_multipath->setSegmentType(Inkscape::UI::SEGMENT_STRAIGHT);
}
@@ -178,7 +179,7 @@ static void sp_node_path_edit_toline(void)
static void sp_node_path_edit_tocurve(void)
{
- InkNodeTool *nt = get_node_tool();
+ NodeTool *nt = get_node_tool();
if (nt) {
nt->_multipath->setSegmentType(Inkscape::UI::SEGMENT_CUBIC_BEZIER);
}
@@ -186,7 +187,7 @@ static void sp_node_path_edit_tocurve(void)
static void sp_node_path_edit_cusp(void)
{
- InkNodeTool *nt = get_node_tool();
+ NodeTool *nt = get_node_tool();
if (nt) {
nt->_multipath->setNodeType(Inkscape::UI::NODE_CUSP);
}
@@ -194,7 +195,7 @@ static void sp_node_path_edit_cusp(void)
static void sp_node_path_edit_smooth(void)
{
- InkNodeTool *nt = get_node_tool();
+ NodeTool *nt = get_node_tool();
if (nt) {
nt->_multipath->setNodeType(Inkscape::UI::NODE_SMOOTH);
}
@@ -202,7 +203,7 @@ static void sp_node_path_edit_smooth(void)
static void sp_node_path_edit_symmetrical(void)
{
- InkNodeTool *nt = get_node_tool();
+ NodeTool *nt = get_node_tool();
if (nt) {
nt->_multipath->setNodeType(Inkscape::UI::NODE_SYMMETRIC);
}
@@ -210,7 +211,7 @@ static void sp_node_path_edit_symmetrical(void)
static void sp_node_path_edit_auto(void)
{
- InkNodeTool *nt = get_node_tool();
+ NodeTool *nt = get_node_tool();
if (nt) {
nt->_multipath->setNodeType(Inkscape::UI::NODE_AUTO);
}
@@ -242,7 +243,7 @@ static void sp_node_toolbox_coord_changed(gpointer /*shape_editor*/, GObject *tb
}
Unit const *unit = tracker->getActiveUnit();
- InkNodeTool *nt = get_node_tool();
+ NodeTool *nt = get_node_tool();
if (!nt || nt->_selected_nodes->empty()) {
// no path selected
gtk_action_set_sensitive(xact, FALSE);
@@ -289,7 +290,7 @@ static void sp_node_path_value_changed(GtkAdjustment *adj, GObject *tbl, Geom::D
// in turn, prevent listener from responding
g_object_set_data( tbl, "freeze", GINT_TO_POINTER(TRUE));
- InkNodeTool *nt = get_node_tool();
+ NodeTool *nt = get_node_tool();
if (nt && !nt->_selected_nodes->empty()) {
double val = Quantity::convert(gtk_adjustment_get_value(adj), unit, "px");
double oldval = nt->_selected_nodes->pointwiseBounds()->midpoint()[d];
diff --git a/src/widgets/paintbucket-toolbar.cpp b/src/widgets/paintbucket-toolbar.cpp
index 363fadd3d..8c4de2b32 100644
--- a/src/widgets/paintbucket-toolbar.cpp
+++ b/src/widgets/paintbucket-toolbar.cpp
@@ -56,9 +56,9 @@
#include "../ui/icon-names.h"
#include "util/units.h"
#include "ui/widget/unit-tracker.h"
-#include "../pen-context.h"
+#include "ui/tools/pen-tool.h"
#include "../sp-namedview.h"
-#include "../flood-context.h"
+#include "ui/tools/flood-tool.h"
#include <gtk/gtk.h>
@@ -80,7 +80,7 @@ static void paintbucket_channels_changed(EgeSelectOneAction* act, GObject* /*tbl
{
gint channels = ege_select_one_action_get_active( act );
//flood_channels_set_channels( channels );
- SPFloodContext::set_channels(channels);
+ Inkscape::UI::Tools::FloodTool::set_channels(channels);
}
static void paintbucket_threshold_changed(GtkAdjustment *adj, GObject * /*tbl*/)
@@ -127,7 +127,7 @@ static void paintbucket_defaults(GtkWidget *, GObject *tbl)
}
EgeSelectOneAction* channels_action = EGE_SELECT_ONE_ACTION( g_object_get_data (tbl, "channels_action" ) );
- ege_select_one_action_set_active( channels_action, FLOOD_CHANNELS_RGB );
+ ege_select_one_action_set_active( channels_action, Inkscape::UI::Tools::FLOOD_CHANNELS_RGB );
EgeSelectOneAction* autogap_action = EGE_SELECT_ONE_ACTION( g_object_get_data (tbl, "autogap_action" ) );
ege_select_one_action_set_active( autogap_action, 0 );
}
@@ -142,7 +142,7 @@ void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
GList* items = 0;
gint count = 0;
- for ( items = flood_channels_dropdown_items_list(); items ; items = g_list_next(items) )
+ for ( items = Inkscape::UI::Tools::flood_channels_dropdown_items_list(); items ; items = g_list_next(items) )
{
GtkTreeIter iter;
gtk_list_store_append( model, &iter );
@@ -209,7 +209,7 @@ void sp_paintbucket_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions
GList* items = 0;
gint count = 0;
- for ( items = flood_autogap_dropdown_items_list(); items ; items = g_list_next(items) )
+ for ( items = Inkscape::UI::Tools::flood_autogap_dropdown_items_list(); items ; items = g_list_next(items) )
{
GtkTreeIter iter;
gtk_list_store_append( model, &iter );
diff --git a/src/widgets/pencil-toolbar.cpp b/src/widgets/pencil-toolbar.cpp
index 783d8dd4d..8abf35fb3 100644
--- a/src/widgets/pencil-toolbar.cpp
+++ b/src/widgets/pencil-toolbar.cpp
@@ -63,11 +63,11 @@
#include "ui/uxmanager.h"
//#include "../ui/tool/control-point-selection.h"
-//#include "../ui/tool/node-tool.h"
+//#include "ui/tools/node-tool.h"
//#include "../ui/tool/multi-path-manipulator.h"
#include "../ui/icon-names.h"
-#include "../pen-context.h"
+#include "ui/tools/pen-tool.h"
//#include "../sp-namedview.h"
#include "../tools-switch.h"
@@ -103,7 +103,7 @@ 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)) {
- SPPenContext *pc = SP_PEN_CONTEXT(desktop->event_context);
+ Inkscape::UI::Tools::PenTool *pc = SP_PEN_CONTEXT(desktop->event_context);
sp_pen_context_set_polyline_mode(pc);
}
}
diff --git a/src/widgets/rect-toolbar.cpp b/src/widgets/rect-toolbar.cpp
index 0287a9aeb..f5a509db3 100644
--- a/src/widgets/rect-toolbar.cpp
+++ b/src/widgets/rect-toolbar.cpp
@@ -55,7 +55,7 @@
#include "../ui/icon-names.h"
#include "util/units.h"
#include "ui/widget/unit-tracker.h"
-#include "../pen-context.h"
+#include "ui/tools/pen-tool.h"
#include "../sp-namedview.h"
#include "../sp-rect.h"
diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp
index c709e9775..e081f98e0 100644
--- a/src/widgets/sp-color-notebook.cpp
+++ b/src/widgets/sp-color-notebook.cpp
@@ -39,7 +39,7 @@
#include "color-profile.h"
#include "cms-system.h"
#include "tools-switch.h"
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
using Inkscape::CMSSystem;
@@ -542,7 +542,7 @@ void ColorNotebook::_picker_clicked(GtkWidget * /*widget*/, SPColorNotebook * /*
// Set the dropper into a "one click" mode, so it reverts to the previous tool after a click
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
prefs->setBool("/tools/dropper/onetimepick", true);
- sp_toggle_dropper(SP_ACTIVE_DESKTOP);
+ Inkscape::UI::Tools::sp_toggle_dropper(SP_ACTIVE_DESKTOP);
}
void ColorNotebook::_rgbaEntryChangedHook(GtkEntry *entry, SPColorNotebook *colorbook)
diff --git a/src/widgets/spinbutton-events.cpp b/src/widgets/spinbutton-events.cpp
index 7a481aea8..0280694f6 100644
--- a/src/widgets/spinbutton-events.cpp
+++ b/src/widgets/spinbutton-events.cpp
@@ -18,7 +18,7 @@
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
-#include "../event-context.h"
+#include "ui/tools/tool-base.h"
#include "sp-widget.h"
#include "widget-sizes.h"
@@ -67,7 +67,7 @@ gboolean spinbutton_keypress(GtkWidget *w, GdkEventKey *event, gpointer /*data*/
{
gboolean result = FALSE; // I didn't consume the event
- switch (get_group0_keyval(event)) {
+ switch (Inkscape::UI::Tools::get_group0_keyval(event)) {
case GDK_KEY_Escape: // defocus
spinbutton_undo(w);
spinbutton_defocus(w);
diff --git a/src/widgets/spiral-toolbar.cpp b/src/widgets/spiral-toolbar.cpp
index b4e8e68a7..6b10bfce9 100644
--- a/src/widgets/spiral-toolbar.cpp
+++ b/src/widgets/spiral-toolbar.cpp
@@ -53,7 +53,7 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../pen-context.h"
+#include "ui/tools/pen-tool.h"
#include "../sp-spiral.h"
using Inkscape::UI::UXManager;
diff --git a/src/widgets/spray-toolbar.cpp b/src/widgets/spray-toolbar.cpp
index 247df53e2..2a8c85475 100644
--- a/src/widgets/spray-toolbar.cpp
+++ b/src/widgets/spray-toolbar.cpp
@@ -52,8 +52,8 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../pen-context.h"
-#include "../spray-context.h"
+#include "ui/tools/pen-tool.h"
+#include "ui/tools/spray-tool.h"
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
diff --git a/src/widgets/star-toolbar.cpp b/src/widgets/star-toolbar.cpp
index 9e26988ff..bac0271db 100644
--- a/src/widgets/star-toolbar.cpp
+++ b/src/widgets/star-toolbar.cpp
@@ -53,7 +53,7 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../pen-context.h"
+#include "ui/tools/pen-tool.h"
#include "../sp-star.h"
diff --git a/src/widgets/text-toolbar.cpp b/src/widgets/text-toolbar.cpp
index 6b9fc900c..750fa1de6 100644
--- a/src/widgets/text-toolbar.cpp
+++ b/src/widgets/text-toolbar.cpp
@@ -56,7 +56,7 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../pen-context.h"
+#include "ui/tools/pen-tool.h"
#include "../sp-namedview.h"
#include "../svg/css-ostringstream.h"
#include "../sp-flowtext.h"
@@ -64,7 +64,7 @@
#include "../style.h"
#include "../libnrtype/font-lister.h"
#include "../libnrtype/font-instance.h"
-#include "../text-context.h"
+#include "ui/tools/text-tool.h"
#include "../text-editing.h"
#include "widgets/font-selector.h"
@@ -652,7 +652,7 @@ static void sp_text_dx_value_changed( GtkAdjustment *adj, GObject *tbl )
bool modmade = false;
if( SP_IS_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context) ) {
- SPTextContext *const tc = SP_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context);
+ Inkscape::UI::Tools::TextTool *const tc = SP_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context);
if( tc ) {
unsigned char_index = -1;
TextTagAttributes *attributes =
@@ -686,7 +686,7 @@ static void sp_text_dy_value_changed( GtkAdjustment *adj, GObject *tbl )
bool modmade = false;
if( SP_IS_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context) ) {
- SPTextContext *const tc = SP_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context);
+ Inkscape::UI::Tools::TextTool *const tc = SP_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context);
if( tc ) {
unsigned char_index = -1;
TextTagAttributes *attributes =
@@ -721,7 +721,7 @@ static void sp_text_rotation_value_changed( GtkAdjustment *adj, GObject *tbl )
bool modmade = false;
if( SP_IS_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context) ) {
- SPTextContext *const tc = SP_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context);
+ Inkscape::UI::Tools::TextTool *const tc = SP_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context);
if( tc ) {
unsigned char_index = -1;
TextTagAttributes *attributes =
@@ -1091,7 +1091,7 @@ static void sp_text_toolbox_selection_changed(Inkscape::Selection */*selection*/
// Kerning (xshift), yshift, rotation. NB: These are not CSS attributes.
if( SP_IS_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context) ) {
- SPTextContext *const tc = SP_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context);
+ Inkscape::UI::Tools::TextTool *const tc = SP_TEXT_CONTEXT((SP_ACTIVE_DESKTOP)->event_context);
if( tc ) {
unsigned char_index = -1;
TextTagAttributes *attributes =
diff --git a/src/widgets/toolbox.cpp b/src/widgets/toolbox.cpp
index ddbe77fbb..02da805bf 100644
--- a/src/widgets/toolbox.cpp
+++ b/src/widgets/toolbox.cpp
@@ -96,7 +96,7 @@
#include "toolbox.h"
#include <gtk/gtk.h>
-#include "event-context.h"
+#include "ui/tools/tool-base.h"
//#define DEBUG_TEXT
@@ -104,9 +104,10 @@ using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
using Inkscape::UI::PrefPusher;
using Inkscape::UI::ToolboxFactory;
+using Inkscape::UI::Tools::ToolBase;
typedef void (*SetupFunction)(GtkWidget *toolbox, SPDesktop *desktop);
-typedef void (*UpdateFunction)(SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox);
+typedef void (*UpdateFunction)(SPDesktop *desktop, ToolBase *eventcontext, GtkWidget *toolbox);
enum BarId {
BAR_TOOL = 0,
@@ -550,13 +551,13 @@ static Glib::RefPtr<Gtk::ActionGroup> create_or_fetch_actions( SPDesktop* deskto
static void setup_snap_toolbox(GtkWidget *toolbox, SPDesktop *desktop);
static void setup_tool_toolbox(GtkWidget *toolbox, SPDesktop *desktop);
-static void update_tool_toolbox(SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox);
+static void update_tool_toolbox(SPDesktop *desktop, ToolBase *eventcontext, GtkWidget *toolbox);
static void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop);
-static void update_aux_toolbox(SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox);
+static void update_aux_toolbox(SPDesktop *desktop, ToolBase *eventcontext, GtkWidget *toolbox);
static void setup_commands_toolbox(GtkWidget *toolbox, SPDesktop *desktop);
-static void update_commands_toolbox(SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox);
+static void update_commands_toolbox(SPDesktop *desktop, ToolBase *eventcontext, GtkWidget *toolbox);
static GtkToolItem * sp_toolbox_button_item_new_from_verb_with_doubleclick( GtkWidget *t, Inkscape::IconSize size, SPButtonType type,
Inkscape::Verb *verb, Inkscape::Verb *doubleclick_verb,
@@ -1310,7 +1311,7 @@ void setup_tool_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
"/toolbox/tools/small");
}
-void update_tool_toolbox( SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget * /*toolbox*/ )
+void update_tool_toolbox( SPDesktop *desktop, ToolBase *eventcontext, GtkWidget * /*toolbox*/ )
{
gchar const *const tname = ( eventcontext
? eventcontext->getPrefsPath().c_str() //g_type_name(G_OBJECT_TYPE(eventcontext))
@@ -1432,7 +1433,7 @@ void setup_aux_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
g_object_unref( G_OBJECT(grouper) );
}
-void update_aux_toolbox(SPDesktop * /*desktop*/, SPEventContext *eventcontext, GtkWidget *toolbox)
+void update_aux_toolbox(SPDesktop * /*desktop*/, ToolBase *eventcontext, GtkWidget *toolbox)
{
gchar const *tname = ( eventcontext
? eventcontext->getPrefsPath().c_str() //g_type_name(G_OBJECT_TYPE(eventcontext))
@@ -1495,7 +1496,7 @@ void setup_commands_toolbox(GtkWidget *toolbox, SPDesktop *desktop)
"/toolbox/small" );
}
-void update_commands_toolbox(SPDesktop * /*desktop*/, SPEventContext * /*eventcontext*/, GtkWidget * /*toolbox*/)
+void update_commands_toolbox(SPDesktop * /*desktop*/, ToolBase * /*eventcontext*/, GtkWidget * /*toolbox*/)
{
}
@@ -1864,7 +1865,7 @@ Glib::ustring ToolboxFactory::getToolboxName(GtkWidget* toolbox)
return name;
}
-void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, SPEventContext * /*eventcontext*/, GtkWidget *toolbox)
+void ToolboxFactory::updateSnapToolbox(SPDesktop *desktop, ToolBase * /*eventcontext*/, GtkWidget *toolbox)
{
g_assert(desktop != NULL);
g_assert(toolbox != NULL);
diff --git a/src/widgets/toolbox.h b/src/widgets/toolbox.h
index e9ffcda4a..fb749bfb5 100644
--- a/src/widgets/toolbox.h
+++ b/src/widgets/toolbox.h
@@ -23,7 +23,16 @@
#define TOOLBAR_SLIDER_HINT "full"
class SPDesktop;
-class SPEventContext;
+
+namespace Inkscape {
+namespace UI {
+namespace Tools {
+
+class ToolBase;
+
+}
+}
+}
namespace Inkscape {
namespace UI {
@@ -50,7 +59,7 @@ public:
static Glib::ustring getToolboxName(GtkWidget* toolbox);
- static void updateSnapToolbox(SPDesktop *desktop, SPEventContext *eventcontext, GtkWidget *toolbox);
+ static void updateSnapToolbox(SPDesktop *desktop, Inkscape::UI::Tools::ToolBase *eventcontext, GtkWidget *toolbox);
static Inkscape::IconSize prefToSize(Glib::ustring const &path, int base = 0 );
diff --git a/src/widgets/tweak-toolbar.cpp b/src/widgets/tweak-toolbar.cpp
index 6da7608bd..6999b057d 100644
--- a/src/widgets/tweak-toolbar.cpp
+++ b/src/widgets/tweak-toolbar.cpp
@@ -52,8 +52,8 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../pen-context.h"
-#include "../tweak-context.h"
+#include "ui/tools/pen-tool.h"
+#include "ui/tools/tweak-tool.h"
using Inkscape::UI::UXManager;
using Inkscape::DocumentUndo;
@@ -92,7 +92,7 @@ static void sp_tweak_mode_changed( EgeSelectOneAction *act, GObject *tbl )
prefs->setInt("/tools/tweak/mode", mode);
static gchar const* names[] = {"tweak_doh", "tweak_dos", "tweak_dol", "tweak_doo", "tweak_channels_label"};
- bool flag = ((mode == TWEAK_MODE_COLORPAINT) || (mode == TWEAK_MODE_COLORJITTER));
+ bool flag = ((mode == Inkscape::UI::Tools::TWEAK_MODE_COLORPAINT) || (mode == Inkscape::UI::Tools::TWEAK_MODE_COLORJITTER));
for (size_t i = 0; i < G_N_ELEMENTS(names); ++i) {
GtkAction *act = GTK_ACTION(g_object_get_data( tbl, names[i] ));
if (act) {
@@ -289,7 +289,7 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
EgeOutputAction* act = ege_output_action_new( "TweakChannelsLabel", _("Channels:"), "", 0 );
ege_output_action_set_use_markup( act, TRUE );
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
- if (mode != TWEAK_MODE_COLORPAINT && mode != TWEAK_MODE_COLORJITTER) {
+ if (mode != Inkscape::UI::Tools::TWEAK_MODE_COLORPAINT && mode != Inkscape::UI::Tools::TWEAK_MODE_COLORJITTER) {
gtk_action_set_sensitive (GTK_ACTION(act), FALSE);
}
g_object_set_data( holder, "tweak_channels_label", act);
@@ -306,7 +306,7 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(tweak_toggle_doh), desktop );
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/tweak/doh", true) );
- if (mode != TWEAK_MODE_COLORPAINT && mode != TWEAK_MODE_COLORJITTER) {
+ if (mode != Inkscape::UI::Tools::TWEAK_MODE_COLORPAINT && mode != Inkscape::UI::Tools::TWEAK_MODE_COLORJITTER) {
gtk_action_set_sensitive (GTK_ACTION(act), FALSE);
}
g_object_set_data( holder, "tweak_doh", act);
@@ -322,7 +322,7 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(tweak_toggle_dos), desktop );
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/tweak/dos", true) );
- if (mode != TWEAK_MODE_COLORPAINT && mode != TWEAK_MODE_COLORJITTER) {
+ if (mode != Inkscape::UI::Tools::TWEAK_MODE_COLORPAINT && mode != Inkscape::UI::Tools::TWEAK_MODE_COLORJITTER) {
gtk_action_set_sensitive (GTK_ACTION(act), FALSE);
}
g_object_set_data( holder, "tweak_dos", act );
@@ -338,7 +338,7 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(tweak_toggle_dol), desktop );
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/tweak/dol", true) );
- if (mode != TWEAK_MODE_COLORPAINT && mode != TWEAK_MODE_COLORJITTER) {
+ if (mode != Inkscape::UI::Tools::TWEAK_MODE_COLORPAINT && mode != Inkscape::UI::Tools::TWEAK_MODE_COLORJITTER) {
gtk_action_set_sensitive (GTK_ACTION(act), FALSE);
}
g_object_set_data( holder, "tweak_dol", act );
@@ -354,7 +354,7 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
gtk_action_group_add_action( mainActions, GTK_ACTION( act ) );
g_signal_connect_after( G_OBJECT(act), "toggled", G_CALLBACK(tweak_toggle_doo), desktop );
gtk_toggle_action_set_active( GTK_TOGGLE_ACTION(act), prefs->getBool("/tools/tweak/doo", true) );
- if (mode != TWEAK_MODE_COLORPAINT && mode != TWEAK_MODE_COLORJITTER) {
+ if (mode != Inkscape::UI::Tools::TWEAK_MODE_COLORPAINT && mode != Inkscape::UI::Tools::TWEAK_MODE_COLORJITTER) {
gtk_action_set_sensitive (GTK_ACTION(act), FALSE);
}
g_object_set_data( holder, "tweak_doo", act );
@@ -373,7 +373,7 @@ void sp_tweak_toolbox_prep(SPDesktop *desktop, GtkActionGroup* mainActions, GObj
sp_tweak_fidelity_value_changed, NULL /*unit tracker*/, 0.01, 0, 100 );
gtk_action_group_add_action( mainActions, GTK_ACTION(eact) );
gtk_action_set_sensitive( GTK_ACTION(eact), TRUE );
- if (mode == TWEAK_MODE_COLORPAINT || mode == TWEAK_MODE_COLORJITTER) {
+ if (mode == Inkscape::UI::Tools::TWEAK_MODE_COLORPAINT || mode == Inkscape::UI::Tools::TWEAK_MODE_COLORJITTER) {
gtk_action_set_sensitive (GTK_ACTION(eact), FALSE);
}
g_object_set_data( holder, "tweak_fidelity", eact );
diff --git a/src/widgets/zoom-toolbar.cpp b/src/widgets/zoom-toolbar.cpp
index 9cdbc3d6a..a5ab6e211 100644
--- a/src/widgets/zoom-toolbar.cpp
+++ b/src/widgets/zoom-toolbar.cpp
@@ -51,8 +51,8 @@
#include "../xml/repr.h"
#include "ui/uxmanager.h"
#include "../ui/icon-names.h"
-#include "../pen-context.h"
-#include "../tweak-context.h"
+#include "ui/tools/pen-tool.h"
+#include "ui/tools/tweak-tool.h"
using Inkscape::UI::UXManager;