~valavanisalex/ubuntu/precise/inkscape/fix-943984

« back to all changes in this revision

Viewing changes to inkscape-0.47pre1/src/shape-editor.h

  • Committer: Bazaar Package Importer
  • Author(s): Bryce Harrington
  • Date: 2009-07-02 17:09:45 UTC
  • mfrom: (1.1.9 upstream)
  • Revision ID: james.westby@ubuntu.com-20090702170945-nn6d6zswovbwju1t
Tags: 0.47~pre1-0ubuntu1
* New upstream release.
  - Don't constrain maximization on small resolution devices (pre0)
    (LP: #348842)
  - Fixes segfault on startup (pre0)
    (LP: #391149)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#ifndef __SHAPE_EDITOR_H__
 
2
#define __SHAPE_EDITOR_H__
 
3
 
 
4
/*
 
5
 * Inkscape::ShapeEditor
 
6
 *
 
7
 * This is a container class which contains either knotholder (for shapes) or nodepath (for
 
8
 * paths). It is attached to a single item so only one of these is active at a time.
 
9
 *
 
10
 * Authors:
 
11
 *   bulia byak <buliabyak@users.sf.net>
 
12
 *
 
13
 */
 
14
 
 
15
#include <forward.h>
 
16
#include <2geom/forward.h>
 
17
 
 
18
namespace Inkscape { namespace NodePath { class Path; } }
 
19
namespace Inkscape { namespace XML { class Node; } }
 
20
 
 
21
class KnotHolder;
 
22
class SPDesktop;
 
23
class SPNodeContext;
 
24
class ShapeEditorsCollective;
 
25
class LivePathEffectObject;
 
26
 
 
27
#include "libnr/nr-path-code.h"
 
28
#include <2geom/point.h>
 
29
#include <boost/optional.hpp>
 
30
#include <vector>
 
31
 
 
32
enum SubType{
 
33
    SH_NODEPATH,
 
34
    SH_KNOTHOLDER
 
35
};
 
36
 
 
37
class ShapeEditor {
 
38
public:
 
39
 
 
40
    ShapeEditor(SPDesktop *desktop);
 
41
    ~ShapeEditor();
 
42
 
 
43
    void set_item (SPItem *item, SubType type, bool keep_knotholder = false);
 
44
    void set_item_lpe_path_parameter(SPItem *item, LivePathEffectObject *lpeobject, const char * key);
 
45
    void unset_item (SubType type, bool keep_knotholder = false);
 
46
 
 
47
    bool has_nodepath (); //((deprecated))
 
48
    void update_knotholder (); //((deprecated))
 
49
 
 
50
    bool has_local_change (SubType type);
 
51
    void decrement_local_change (SubType type);
 
52
 
 
53
    GList *save_nodepath_selection ();
 
54
    void restore_nodepath_selection (GList *saved);
 
55
 
 
56
    void nodepath_destroyed ();
 
57
 
 
58
    void update_statusbar ();
 
59
 
 
60
    bool is_over_stroke (Geom::Point event_p, bool remember);
 
61
 
 
62
    void add_node_near_point(); // uses the shapeeditor's remembered point, if any
 
63
 
 
64
    void select_segment_near_point(bool toggle); // uses the shapeeditor's remembered point, if any
 
65
 
 
66
    void cancel_hit ();
 
67
 
 
68
    bool hits_curve ();
 
69
 
 
70
    void curve_drag (gdouble eventx, gdouble eventy);
 
71
 
 
72
    void finish_drag ();
 
73
 
 
74
    void select_rect (Geom::Rect  const &rect, bool add);
 
75
 
 
76
    bool has_selection ();
 
77
    void deselect ();
 
78
 
 
79
    Inkscape::NodePath::Path *get_nodepath() {return nodepath;} //((deprecated))
 
80
    ShapeEditorsCollective *get_container() {return container;}
 
81
 
 
82
    void add_node();
 
83
 
 
84
    void delete_nodes();
 
85
    void delete_nodes_preserving_shape();
 
86
    void delete_segment();
 
87
 
 
88
    void set_node_type(int type);
 
89
 
 
90
    void break_at_nodes();
 
91
    void join_nodes();
 
92
    void join_segments();
 
93
 
 
94
    void duplicate_nodes();
 
95
 
 
96
    void set_type_of_segments(NRPathcode code);
 
97
 
 
98
    void move_nodes(gdouble dx, gdouble dy);
 
99
    void move_nodes_screen(SPDesktop *desktop, gdouble dx, gdouble dy);
 
100
 
 
101
    void rotate_nodes(gdouble angle, int which, bool screen);
 
102
 
 
103
    void scale_nodes(gdouble const grow, int const which);
 
104
    void scale_nodes_screen(gdouble const grow, int const which);
 
105
 
 
106
    void select_all (bool invert);
 
107
    void select_all_from_subpath (bool invert);
 
108
    void select_next ();
 
109
    void select_prev ();
 
110
 
 
111
    void show_handles (bool show);
 
112
    void show_helperpath (bool show);
 
113
 
 
114
    void flip (Geom::Dim2 axis, boost::optional<Geom::Point> center = boost::optional<Geom::Point>());
 
115
 
 
116
    void distribute (Geom::Dim2 axis);
 
117
    void align (Geom::Dim2 axis);
 
118
 
 
119
    bool nodepath_edits_repr_key(gchar const *name);
 
120
 
 
121
    // this one is only public because it's called from non-C++ repr changed callback
 
122
    void shapeeditor_event_attr_changed(gchar const *name);
 
123
 
 
124
private:
 
125
    bool has_knotholder ();
 
126
    void reset_item (SubType type, bool keep_knotholder = true);
 
127
    const SPItem *get_item (SubType type);
 
128
 
 
129
    SPDesktop *desktop;
 
130
 
 
131
    Inkscape::NodePath::Path *nodepath;
 
132
 
 
133
    // TODO: std::list<KnotHolder *> knotholders;
 
134
    KnotHolder *knotholder;
 
135
 
 
136
    ShapeEditorsCollective *container;
 
137
 
 
138
    //Inkscape::XML::Node *lidtened_repr;
 
139
 
 
140
    double grab_t;
 
141
    int grab_node; // number of node grabbed by sp_node_context_is_over_stroke
 
142
    bool hit;
 
143
    Geom::Point curvepoint_event; // int coords from event
 
144
    Geom::Point curvepoint_doc; // same, in doc coords
 
145
 
 
146
    Inkscape::XML::Node *listener_attached_for;
 
147
};
 
148
 
 
149
 
 
150
/* As the next stage, this will be a collection of multiple ShapeEditors,
 
151
with the same interface as the single ShapeEditor, passing the actions to all its
 
152
contained ShapeEditors. Thus it should be easy to switch node context from 
 
153
using a single ShapeEditor to using a ShapeEditorsCollective. */
 
154
 
 
155
class ShapeEditorsCollective {
 
156
public:
 
157
 
 
158
    ShapeEditorsCollective(SPDesktop *desktop);
 
159
    ~ShapeEditorsCollective();
 
160
 
 
161
    void update_statusbar();
 
162
 
 
163
private:
 
164
    std::vector<ShapeEditor> editors;
 
165
 
 
166
    SPNodeContext *nc; // who holds us
 
167
};
 
168
 
 
169
#endif
 
170
 
 
171
 
 
172
/*
 
173
  Local Variables:
 
174
  mode:c++
 
175
  c-file-style:"stroustrup"
 
176
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
 
177
  indent-tabs-mode:nil
 
178
  fill-column:99
 
179
  End:
 
180
*/
 
181
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4 :
 
182