summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: f793f6a)
raw | patch | inline | side by side (parent: f793f6a)
author | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Wed, 12 Dec 2007 18:50:47 +0000 (18:50 +0000) | ||
committer | dvlierop2 <dvlierop2@users.sourceforge.net> | |
Wed, 12 Dec 2007 18:50:47 +0000 (18:50 +0000) |
index e16e1fdf2db7fd11ea7f047602508eec664a5fa7..b4d27084afa4c8c4100c8cff21ef84217e2331d8 100644 (file)
}
if ( (value = repr->attribute("snap_enabled")) ) {
- snap_enabled = (strcmp(value,"true") == 0);
+ g_assert(snapper != NULL);
+ snapper->setEnabled(strcmp(value,"true") == 0);
}
for (GSList *l = canvasitems; l != NULL; l = l->next) {
_wr.setUpdating (true);
_rcb_visible.setActive(visible);
- _rcb_snap_enabled.setActive(snap_enabled);
+ if (snapper != NULL) {
+ _rcb_snap_enabled.setActive(snapper->getEnabled());
+ }
_rumg.setUnit (gridunit);
index 183b299d17a1b7314126ea926138a81f2d1c655a..d4a78f265ca95e5c88c0d33a68afa798afd20995 100644 (file)
@@ -159,7 +159,7 @@ grid_canvasitem_update (SPCanvasItem *item, NR::Matrix const &affine, unsigned i
};
CanvasGrid::CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument *in_doc, GridType type)
- : namelabel("", Gtk::ALIGN_CENTER), visible(true), snap_enabled(true), gridtype(type)
+ : namelabel("", Gtk::ALIGN_CENTER), visible(true), gridtype(type)
{
repr = in_repr;
doc = in_doc;
@@ -336,6 +336,14 @@ CanvasGrid::on_repr_attr_changed(Inkscape::XML::Node *repr, gchar const *key, gc
((CanvasGrid*) data)->onReprAttrChanged(repr, key, oldval, newval, is_interactive);
}
+bool CanvasGrid::isSnapEnabled()
+{
+ if (snapper == NULL) {
+ return false;
+ }
+
+ return snapper->getEnabled();
+}
// ##########################################################
// CanvasXYGrid
if ( (value = repr->attribute("visible")) ) {
visible = (strcmp(value,"true") == 0);
}
+
+ if ( (value = repr->attribute("snap_enabled")) ) {
+ g_assert(snapper != NULL);
+ snapper->setEnabled(strcmp(value,"true") == 0);
+ }
for (GSList *l = canvasitems; l != NULL; l = l->next) {
sp_canvas_item_request_update ( SP_CANVAS_ITEM(l->data) );
_wr.setUpdating (true);
_rcb_visible.setActive(visible);
- _rcb_snap_enabled.setActive(snap_enabled);
+ if (snapper != NULL) {
+ _rcb_snap_enabled.setActive(snapper->getEnabled());
+ }
_rumg.setUnit (gridunit);
@@ -906,6 +921,15 @@ void CanvasXYGridSnapper::_addSnappedLine(SnappedConstraints &sc, NR::Point cons
sc.grid_lines.push_back(dummy);
}
+/**
+ * \return true if this Snapper will snap at least one kind of point.
+ */
+bool CanvasXYGridSnapper::ThisSnapperMightSnap() const
+{
+ return _named_view == NULL ? false : (_snap_enabled && _snap_from != 0);
+}
+
+
index 07e27cb4a4a0a390ee7da625c2c21e8a09fbf416..bc21a14aa9a3e233a0fd9fa45b07661f82dc3253 100644 (file)
static void on_repr_attr_changed (Inkscape::XML::Node * repr, const gchar *key, const gchar *oldval, const gchar *newval, bool is_interactive, void * data);
bool isVisible() { return visible; };
- bool isSnapEnabled() { return snap_enabled; };
+ bool isSnapEnabled();
protected:
CanvasGrid(SPNamedView * nv, Inkscape::XML::Node * in_repr, SPDocument *in_doc, GridType type);
Inkscape::UI::Widget::RegisteredCheckButton _rcb_visible;
bool visible;
Inkscape::UI::Widget::RegisteredCheckButton _rcb_snap_enabled;
- bool snap_enabled;
-
+
GridType gridtype;
private:
{
public:
CanvasXYGridSnapper(CanvasXYGrid *grid, SPNamedView const *nv, NR::Coord const d);
+ bool ThisSnapperMightSnap() const;
private:
LineList _getSnapLines(NR::Point const &p) const;
diff --git a/src/guide-snapper.cpp b/src/guide-snapper.cpp
index 0d7dffd0071472758f35f42a36bfb2862f723696..b660bab9da473b163acc99bc54a12d94b566e1a8 100644 (file)
--- a/src/guide-snapper.cpp
+++ b/src/guide-snapper.cpp
*/
bool Inkscape::GuideSnapper::ThisSnapperMightSnap() const
{
- return _named_view == NULL ? false : (_enabled && _snap_from != 0 && _named_view->showguides);
+ return _named_view == NULL ? false : (_snap_enabled && _snap_from != 0 && _named_view->showguides);
}
void Inkscape::GuideSnapper::_addSnappedLine(SnappedConstraints &sc, NR::Point const snapped_point, NR::Coord const snapped_distance, NR::Point const normal_to_line, NR::Point const point_on_line) const
diff --git a/src/object-snapper.cpp b/src/object-snapper.cpp
index 58ef71595a289e0a1ebc51c0a904799e28371a88..84955cf6d64ad9dbd93902a21de13555cd4c7970 100644 (file)
--- a/src/object-snapper.cpp
+++ b/src/object-snapper.cpp
bool Inkscape::ObjectSnapper::ThisSnapperMightSnap() const
{
bool snap_to_something = _snap_to_itempath || _snap_to_itemnode || _snap_to_bboxpath || _snap_to_bboxnode;
- return (_enabled && _snap_from != 0 && snap_to_something);
+ return (_snap_enabled && _snap_from != 0 && snap_to_something);
}
diff --git a/src/snapper.cpp b/src/snapper.cpp
index 6eb4b5204e5b5f91f139445c22cfa152e3bc6191..096a224d1ca5ef6ec0f1acb868f7f96e14be2e9e 100644 (file)
--- a/src/snapper.cpp
+++ b/src/snapper.cpp
* \param nv Named view.
* \param d Snap distance.
*/
-Inkscape::Snapper::Snapper(SPNamedView const *nv, NR::Coord const d) : _named_view(nv), _enabled(true), _distance(d)
+Inkscape::Snapper::Snapper(SPNamedView const *nv, NR::Coord const d) : _named_view(nv), _snap_enabled(true), _distance(d)
{
g_assert(_named_view != NULL);
g_assert(SP_IS_NAMEDVIEW(_named_view));
void Inkscape::Snapper::setEnabled(bool s)
{
- _enabled = s;
+ _snap_enabled = s;
}
std::vector<NR::Point> &points_to_snap,
std::list<SPItem const *> const &it) const
{
- if (_enabled == false || getSnapFrom(t) == false) {
+ if (_snap_enabled == false || getSnapFrom(t) == false) {
return;
}
ConstraintLine const &c,
std::list<SPItem const *> const &it) const
{
- if (_enabled == false || getSnapFrom(t) == false) {
+ if (_snap_enabled == false || getSnapFrom(t) == false) {
return;
}
diff --git a/src/snapper.h b/src/snapper.h
index c5c111cffe3ee914b99639f2002b39147cde2bcd..cf2533f22fb3ebb1898c1ac33517b2ac99305ba9 100644 (file)
--- a/src/snapper.h
+++ b/src/snapper.h
/**
* \return true if this Snapper will snap at least one kind of point.
*/
- virtual bool ThisSnapperMightSnap() const {return (_enabled && _snap_from != 0);} // will likely be overridden by derived classes
+ virtual bool ThisSnapperMightSnap() const {return (_snap_enabled && _snap_from != 0);} // will likely be overridden by derived classes
void setEnabled(bool s);
+ bool getEnabled() const {return _snap_enabled;}
void freeSnap(SnappedConstraints &sc,
PointType const &t,
protected:
SPNamedView const *_named_view;
int _snap_from; ///< bitmap of point types that we will snap from
- bool _enabled; ///< true if this snapper is enabled, otherwise false
+ bool _snap_enabled; ///< true if this snapper is enabled, otherwise false
private: