Code

Implement keyboard shortcuts for single handle adjustments.
[inkscape.git] / src / ui / tool / multi-path-manipulator.h
1 /** @file
2  * Multi path manipulator - a tool component that edits multiple paths at once
3  */
4 /* Authors:
5  *   Krzysztof KosiƄski <tweenk.pl@gmail.com>
6  *
7  * Copyright (C) 2009 Authors
8  * Released under GNU GPL, read the file 'COPYING' for more information
9  */
11 #ifndef SEEN_UI_TOOL_MULTI_PATH_MANIPULATOR_H
12 #define SEEN_UI_TOOL_MULTI_PATH_MANIPULATOR_H
14 #include <sigc++/connection.h>
15 #include "display/display-forward.h"
16 #include "forward.h"
17 #include "ui/tool/commit-events.h"
18 #include "ui/tool/manipulator.h"
19 #include "ui/tool/modifier-tracker.h"
20 #include "ui/tool/node.h"
21 #include "ui/tool/node-types.h"
22 #include "ui/tool/shape-record.h"
24 struct SPCanvasGroup;
26 namespace Inkscape {
27 namespace UI {
29 class PathManipulator;
30 class MultiPathManipulator;
31 struct PathSharedData;
33 /**
34  * Manipulator that manages multiple path manipulators active at the same time.
35  */
36 class MultiPathManipulator : public PointManipulator {
37 public:
38     MultiPathManipulator(PathSharedData &data, sigc::connection &chg);
39     virtual ~MultiPathManipulator();
40     virtual bool event(GdkEvent *event);
42     bool empty() { return _mmap.empty(); }
43     unsigned size() { return _mmap.empty(); }
44     void setItems(std::set<ShapeRecord> const &);
45     void clear() { _mmap.clear(); }
46     void cleanup();
48     void selectSubpaths();
49     void shiftSelection(int dir);
50     void invertSelectionInSubpaths();
52     void setNodeType(NodeType t);
53     void setSegmentType(SegmentType t);
55     void insertNodes();
56     void joinNodes();
57     void breakNodes();
58     void deleteNodes(bool keep_shape = true);
59     void joinSegments();
60     void deleteSegments();
61     void alignNodes(Geom::Dim2 d);
62     void distributeNodes(Geom::Dim2 d);
63     void reverseSubpaths();
64     void move(Geom::Point const &delta);
66     void showOutline(bool show);
67     void showHandles(bool show);
68     void showPathDirection(bool show);
69     void setLiveOutline(bool set);
70     void setLiveObjects(bool set);
71     void updateOutlineColors();
72     
73     sigc::signal<void> signal_coords_changed; /// Emitted whenever the coordinates
74         /// shown in the status bar need updating
75 private:
76     typedef std::pair<ShapeRecord, boost::shared_ptr<PathManipulator> > MapPair;
77     typedef std::map<ShapeRecord, boost::shared_ptr<PathManipulator> > MapType;
79     template <typename R>
80     void invokeForAll(R (PathManipulator::*method)()) {
81         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
82             ((i->second.get())->*method)();
83         }
84     }
85     template <typename R, typename A>
86     void invokeForAll(R (PathManipulator::*method)(A), A a) {
87         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
88             ((i->second.get())->*method)(a);
89         }
90     }
91     template <typename R, typename A>
92     void invokeForAll(R (PathManipulator::*method)(A const &), A const &a) {
93         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
94             ((i->second.get())->*method)(a);
95         }
96     }
97     template <typename R, typename A, typename B>
98     void invokeForAll(R (PathManipulator::*method)(A,B), A a, B b) {
99         for (MapType::iterator i = _mmap.begin(); i != _mmap.end(); ++i) {
100             ((i->second.get())->*method)(a, b);
101         }
102     }
104     void _commit(CommitEvent cps);
105     void _done(gchar const *);
106     void _doneWithCleanup(gchar const *);
107     guint32 _getOutlineColor(ShapeRole role);
109     MapType _mmap;
110 public:
111     PathSharedData const &_path_data;
112 private:
113     sigc::connection &_changed;
114     ModifierTracker _tracker;
115     bool _show_handles;
116     bool _show_outline;
117     bool _show_path_direction;
118     bool _live_outline;
119     bool _live_objects;
121     friend class PathManipulator;
122 };
124 } // namespace UI
125 } // namespace Inkscape
127 #endif
129 /*
130   Local Variables:
131   mode:c++
132   c-file-style:"stroustrup"
133   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
134   indent-tabs-mode:nil
135   fill-column:99
136   End:
137 */
138 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :