Code

Other tools now also retain there specific statusbar text when pressing alt/shift...
[inkscape.git] / src / seltrans.h
1 #ifndef __SELTRANS_H__
2 #define __SELTRANS_H__
4 /*
5  * Helper object for transforming selected items
6  *
7  * Author:
8  *   Lauris Kaplinski <lauris@kaplinski.com>
9  *   Carl Hetherington <inkscape@carlh.net>
10  *
11  * Copyright (C) 2006      Johan Engelen <johan@shouraizou.nl>
12  * Copyright (C) 1999-2002 Lauris Kaplinski
13  *
14  * Released under GNU GPL, read the file 'COPYING' for more information
15  */
17 #include <sigc++/sigc++.h>
18 #include <libnr/nr-point.h>
19 #include <libnr/nr-matrix.h>
20 #include <libnr/nr-rect.h>
21 #include "forward.h"
22 #include "selcue.h"
23 #include "message-context.h"
24 #include <vector>
26 struct SPKnot;
27 class SPDesktop;
28 class SPCanvasItem;
29 class SPSelTransHandle;
31 namespace Inkscape
32 {
34 namespace XML
35 {
36   class Node;
37 }
39 class SelTrans
40 {
41 public:
42     SelTrans(SPDesktop *desktop);
43     ~SelTrans();
45     Inkscape::MessageContext &messageContext() {
46         return _message_context;
47     }
49     void increaseState();
50     void resetState();
51     void setCenter(NR::Point const &p);
52     void grab(NR::Point const &p, gdouble x, gdouble y, bool show_handles);
53     void transform(NR::Matrix const &rel_affine, NR::Point const &norm);
54     void ungrab();
55     void stamp();
56     void moveTo(NR::Point const &xy, guint state);
57     void stretch(SPSelTransHandle const &handle, NR::Point &pt, guint state);
58     void scale(NR::Point &pt, guint state);
59     void skew(SPSelTransHandle const &handle, NR::Point &pt, guint state);
60     void rotate(NR::Point &pt, guint state);
61     gboolean scaleRequest(NR::Point &pt, guint state);
62     gboolean stretchRequest(SPSelTransHandle const &handle, NR::Point &pt, guint state);
63     gboolean skewRequest(SPSelTransHandle const &handle, NR::Point &pt, guint state);
64     gboolean rotateRequest(NR::Point &pt, guint state);
65     gboolean centerRequest(NR::Point &pt, guint state);
67     gboolean handleRequest(SPKnot *knot, NR::Point *position, guint state, SPSelTransHandle const &handle);
68     void handleGrab(SPKnot *knot, guint state, SPSelTransHandle const &handle);
69     void handleClick(SPKnot *knot, guint state, SPSelTransHandle const &handle);
70     void handleNewEvent(SPKnot *knot, NR::Point *position, guint state, SPSelTransHandle const &handle);
72     enum Show
73     {
74         SHOW_CONTENT,
75         SHOW_OUTLINE
76     };
78     void setShow(Show s) {
79         _show = s;
80     }
81     bool isEmpty() {
82         return _empty;
83     }
84     bool isGrabbed() {
85         return _grabbed;    
86     }
87     
88 private:
89     void _updateHandles();
90     void _updateVolatileState();
91     void _selChanged(Inkscape::Selection *selection);
92     void _selModified(Inkscape::Selection *selection, guint flags);
93     void _showHandles(SPKnot *knot[], SPSelTransHandle const handle[], gint num,
94                       gchar const *even_tip, gchar const *odd_tip);
96     enum State {
97         STATE_SCALE,
98         STATE_ROTATE
99     };
100     
101     SPDesktop *_desktop;
103     std::vector<std::pair<SPItem *, NR::Matrix> > _items;
104     std::vector<std::pair<SPItem *, NR::Point> > _items_centers;
105     
106     std::vector<NR::Point> _snap_points;
107     std::vector<NR::Point> _bbox_points;
108     
109     Inkscape::SelCue _selcue;
111     Inkscape::Selection *_selection;
112     State _state;
113     Show _show;
115     bool _grabbed;
116     bool _show_handles;
117     bool _empty;
118     bool _changed;
120     NR::Rect _box;
121     gdouble _strokewidth;
122     NR::Matrix _current;
123     NR::Point _opposite; ///< opposite point to where a scale is taking place
125     NR::Point _center;
126     bool _center_is_set; ///< we've already set _center, no need to reread it from items
128     SPKnot *_shandle[8];
129     SPKnot *_rhandle[8];
130     SPKnot *_chandle;
131     SPCanvasItem *_norm;
132     SPCanvasItem *_grip;
133     SPCanvasItem *_l[4];
134     guint _sel_changed_id;
135     guint _sel_modified_id;
136     GSList *_stamp_cache;    
138     NR::Point _origin; ///< position of origin for transforms
139     NR::Point _point; ///< original position of the knot being used for the current transform
140     Inkscape::MessageContext _message_context;
141     SigC::Connection _sel_changed_connection;
142     SigC::Connection _sel_modified_connection;
143 };
147 #endif
150 /*
151   Local Variables:
152   mode:c++
153   c-file-style:"stroustrup"
154   c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
155   indent-tabs-mode:nil
156   fill-column:99
157   End:
158 */
159 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :