summaryrefslogtreecommitdiffstats
path: root/src/snap-preferences.h
blob: 35d05c40e6fed65b4e16a702517edbef8b0edc78 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
#ifndef SNAPPREFERENCES_H_
#define SNAPPREFERENCES_H_

/**
 *  \file snap-preferences.cpp
 *  \brief Storing of snapping preferences
 *
 * Authors:
 *   Diederik van Lierop <mail@diedenrezi.nl>
 *
 * Copyright (C) 2008 - 2011 Authors
 *
 * Released under GNU GPL, read the file 'COPYING' for more information
 */

#include "helper/units.h"
#include "snap-enums.h"

namespace Inkscape
{

class SnapPreferences
{
public:
    SnapPreferences();

    void setSnapModeBBox(bool enabled);
    void setSnapModeNode(bool enabled);
    void setSnapModeOthers(bool enabled);
    void setSnapModeGuide(bool enabled);
    bool getSnapModeBBox() const;
    bool getSnapModeNode() const;
    bool getSnapModeOthers() const;
    //bool getSnapModeBBoxOrNodes() const;
    bool getSnapModeAny() const;
    bool getSnapModeGuide() const;

    void setSnapIntersectionGG(bool enabled) {_intersectionGG = enabled;}
    void setSnapIntersectionCS(bool enabled) {_intersectionCS = enabled;}
    void setSnapSmoothNodes(bool enabled) {_smoothNodes = enabled;}
    void setSnapLineMidpoints(bool enabled) {_line_midpoints = enabled;}
    void setSnapObjectMidpoints(bool enabled) {_object_midpoints = enabled;}
    void setSnapTextBaseline(bool enabled) {_text_baseline = enabled;}
    void setSnapBBoxEdgeMidpoints(bool enabled) {_bbox_edge_midpoints = enabled;}
    void setSnapBBoxMidpoints(bool enabled) {_bbox_midpoints = enabled;}
    bool getSnapIntersectionGG() const {return _intersectionGG;}
    bool getSnapIntersectionCS() const {return _intersectionCS;}
    bool getSnapSmoothNodes() const {return _smoothNodes;}
    bool getSnapLineMidpoints() const {return _line_midpoints;}
    bool getSnapObjectMidpoints() const {return _object_midpoints;}
    bool getSnapTextBaseline() const {return _text_baseline;}
    bool getSnapBBoxEdgeMidpoints() const {return _bbox_edge_midpoints;}
    bool getSnapBBoxMidpoints() const {return _bbox_midpoints;}

    void setSnapToGrids(bool enabled) {_snap_to_grids = enabled;}
    bool getSnapToGrids() const {return _snap_to_grids;}

    void setSnapToGuides(bool enabled) {_snap_to_guides = enabled;}
    bool getSnapToGuides() const {return _snap_to_guides;}

    void setIncludeItemCenter(bool enabled) {_include_item_center = enabled;}
    bool getIncludeItemCenter() const {return _include_item_center;}

    void setSnapEnabledGlobally(bool enabled) {_snap_enabled_globally = enabled;}
    bool getSnapEnabledGlobally() const {return _snap_enabled_globally;}

    void setSnapPostponedGlobally(bool postponed) {_snap_postponed_globally = postponed;}
    bool getSnapPostponedGlobally() const {return _snap_postponed_globally;}

    void setSnapFrom(Inkscape::SnapSourceType t, bool s);
    bool getSnapFrom(Inkscape::SnapSourceType t) const;

    // These will only be used for the object snapper
    void setSnapToItemNode(bool s) {_snap_to_itemnode = s;}
    bool getSnapToItemNode() const {return _snap_to_itemnode;}
    void setSnapToItemPath(bool s) {_snap_to_itempath = s;}
    bool getSnapToItemPath() const {return _snap_to_itempath;}
    void setSnapToBBoxNode(bool s) {_snap_to_bboxnode = s;}
    bool getSnapToBBoxNode() const {return _snap_to_bboxnode;}
    void setSnapToBBoxPath(bool s) {_snap_to_bboxpath = s;}
    bool getSnapToBBoxPath() const {return _snap_to_bboxpath;}
    void setSnapToPageBorder(bool s) {_snap_to_page_border = s;}
    bool getSnapToPageBorder() const {return _snap_to_page_border;}
    bool getStrictSnapping() const {return _strict_snapping;}

    gdouble getGridTolerance() const {return _grid_tolerance;}
    gdouble getGuideTolerance() const {return _guide_tolerance;}
    gdouble getObjectTolerance() const {return _object_tolerance;}

    void setGridTolerance(gdouble val) {_grid_tolerance = val;}
    void setGuideTolerance(gdouble val) {_guide_tolerance = val;}
    void setObjectTolerance(gdouble val) {_object_tolerance = val;}

private:
    bool _include_item_center; //If true, snapping nodes will also snap the item's center
    bool _intersectionGG; //Consider snapping to intersections of grid and guides
    bool _intersectionCS; //Consider snapping to intersections of curves
    bool _smoothNodes;
    bool _line_midpoints;
    bool _object_midpoints; // the midpoint of shapes (e.g. a circle, rect, polygon) or of any other shape (at [h/2, w/2])
    bool _text_baseline; // both anchor point and baseline of the text
    bool _bbox_edge_midpoints;
    bool _bbox_midpoints;
    bool _snap_to_grids;
    bool _snap_to_guides;
    bool _snap_enabled_globally; // Toggles ALL snapping
    bool _snap_postponed_globally; // Hold all snapping temporarily when the mouse is moving fast
    SnapSourceType _snap_from; ///< bitmap of point types that we will snap from

    // These will only be used for the object snapper
    bool _snap_to_itemnode;
    bool _snap_to_itempath;
    bool _snap_to_bboxnode;
    bool _snap_to_bboxpath;
    bool _snap_to_page_border;
    //If enabled, then bbox corners will only snap to bboxes,
    //and nodes will only snap to nodes and paths. We will not
    //snap bbox corners to nodes, or nodes to bboxes.
    //(snapping to grids and guides is not affected by this)
    bool _strict_snapping;

    gdouble _grid_tolerance;
    gdouble _guide_tolerance;
    gdouble _object_tolerance;
};

}
#endif /*SNAPPREFERENCES_H_*/

/*
  Local Variables:
  mode:c++
  c-file-style:"stroustrup"
  c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
  indent-tabs-mode:nil
  fill-column:99
  End:
*/
// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:fileencoding=utf-8:textwidth=99 :