summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/selcue.cpp48
-rw-r--r--src/selcue.h17
-rw-r--r--src/seltrans.cpp25
-rw-r--r--src/seltrans.h15
4 files changed, 99 insertions, 6 deletions
diff --git a/src/selcue.cpp b/src/selcue.cpp
index 4c35307f7..3f8a93e21 100644
--- a/src/selcue.cpp
+++ b/src/selcue.cpp
@@ -25,8 +25,20 @@
#include "preferences.h"
#include "selcue.h"
+Inkscape::SelCue::BoundingBoxPrefsObserver::BoundingBoxPrefsObserver(SelCue &sel_cue) :
+ Observer("/tools/bounding_box"),
+ _sel_cue(sel_cue)
+{
+}
+
+void Inkscape::SelCue::BoundingBoxPrefsObserver::notify(Preferences::Entry const &val)
+{
+ _sel_cue._boundingBoxPrefsChanged(static_cast<int>(val.getBool()));
+}
+
Inkscape::SelCue::SelCue(SPDesktop *desktop)
- : _desktop(desktop)
+ : _desktop(desktop),
+ _bounding_box_prefs_observer(*this)
{
_selection = sp_desktop_selection(_desktop);
@@ -34,11 +46,16 @@ Inkscape::SelCue::SelCue(SPDesktop *desktop)
sigc::hide(sigc::mem_fun(*this, &Inkscape::SelCue::_newItemBboxes))
);
- _sel_modified_connection = _selection->connectModified(
- sigc::hide(sigc::hide(sigc::mem_fun(*this, &Inkscape::SelCue::_updateItemBboxes)))
+ {
+ void(SelCue::*modifiedSignal)() = &SelCue::_updateItemBboxes;
+ _sel_modified_connection = _selection->connectModified(
+ sigc::hide(sigc::hide(sigc::mem_fun(*this, modifiedSignal)))
);
+ }
- _updateItemBboxes();
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ _updateItemBboxes(prefs);
+ prefs->addObserver(_bounding_box_prefs_observer);
}
Inkscape::SelCue::~SelCue()
@@ -59,7 +76,11 @@ Inkscape::SelCue::~SelCue()
void Inkscape::SelCue::_updateItemBboxes()
{
- Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ _updateItemBboxes(Inkscape::Preferences::get());
+}
+
+void Inkscape::SelCue::_updateItemBboxes(Inkscape::Preferences *prefs)
+{
gint mode = prefs->getInt("/options/selcue/value", MARK);
if (mode == NONE) {
return;
@@ -69,6 +90,11 @@ void Inkscape::SelCue::_updateItemBboxes()
int prefs_bbox = prefs->getBool("/tools/bounding_box");
+ _updateItemBboxes(mode, prefs_bbox);
+}
+
+void Inkscape::SelCue::_updateItemBboxes(gint mode, int prefs_bbox)
+{
GSList const *items = _selection->itemList();
if (_item_bboxes.size() != g_slist_length((GSList *) items)) {
_newItemBboxes();
@@ -201,6 +227,18 @@ void Inkscape::SelCue::_newTextBaselines()
}
}
+void Inkscape::SelCue::_boundingBoxPrefsChanged(int prefs_bbox)
+{
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ gint mode = prefs->getInt("/options/selcue/value", MARK);
+ if (mode == NONE) {
+ return;
+ }
+
+ g_return_if_fail(_selection != NULL);
+
+ _updateItemBboxes(mode, prefs_bbox);
+}
/*
Local Variables:
diff --git a/src/selcue.h b/src/selcue.h
index f62ef768a..bcac7315f 100644
--- a/src/selcue.h
+++ b/src/selcue.h
@@ -37,10 +37,25 @@ public:
};
private:
+ class BoundingBoxPrefsObserver: public Preferences::Observer
+ {
+ public:
+ BoundingBoxPrefsObserver(SelCue &sel_cue);
+
+ void notify(Preferences::Entry const &val);
+
+ private:
+ SelCue &_sel_cue;
+ };
+
+ friend class Inkscape::SelCue::BoundingBoxPrefsObserver;
void _updateItemBboxes();
+ void _updateItemBboxes(Inkscape::Preferences *prefs);
+ void _updateItemBboxes(gint mode, int prefs_bbox);
void _newItemBboxes();
void _newTextBaselines();
+ void _boundingBoxPrefsChanged(int prefs_bbox);
SPDesktop *_desktop;
Selection *_selection;
@@ -48,6 +63,8 @@ private:
sigc::connection _sel_modified_connection;
std::vector<SPCanvasItem*> _item_bboxes;
std::vector<SPCanvasItem*> _text_baselines;
+
+ BoundingBoxPrefsObserver _bounding_box_prefs_observer;
};
}
diff --git a/src/seltrans.cpp b/src/seltrans.cpp
index b6c6baaf7..84c73e452 100644
--- a/src/seltrans.cpp
+++ b/src/seltrans.cpp
@@ -86,6 +86,17 @@ static gboolean sp_seltrans_handle_event(SPKnot *knot, GdkEvent *event, gpointer
return FALSE;
}
+Inkscape::SelTrans::BoundingBoxPrefsObserver::BoundingBoxPrefsObserver(SelTrans &sel_trans) :
+ Observer("/tools/bounding_box"),
+ _sel_trans(sel_trans)
+{
+}
+
+void Inkscape::SelTrans::BoundingBoxPrefsObserver::notify(Preferences::Entry const &val)
+{
+ _sel_trans._boundingBoxPrefsChanged(static_cast<int>(val.getBool()));
+}
+
Inkscape::SelTrans::SelTrans(SPDesktop *desktop) :
_desktop(desktop),
_selcue(desktop),
@@ -103,7 +114,8 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) :
_origin_for_bboxpoints(Geom::Point(0,0)),
_chandle(NULL),
_stamp_cache(NULL),
- _message_context(desktop->messageStack())
+ _message_context(desktop->messageStack()),
+ _bounding_box_prefs_observer(*this)
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
int prefs_bbox = prefs->getBool("/tools/bounding_box");
@@ -169,6 +181,8 @@ Inkscape::SelTrans::SelTrans(SPDesktop *desktop) :
);
_all_snap_sources_iter = _all_snap_sources_sorted.end();
+
+ prefs->addObserver(_bounding_box_prefs_observer);
}
Inkscape::SelTrans::~SelTrans()
@@ -873,6 +887,15 @@ void Inkscape::SelTrans::_selModified(Inkscape::Selection */*selection*/, guint
}
}
+void Inkscape::SelTrans::_boundingBoxPrefsChanged(int prefs_bbox)
+{
+ _snap_bbox_type = !prefs_bbox ?
+ SPItem::VISUAL_BBOX : SPItem::GEOMETRIC_BBOX;
+
+ _updateVolatileState();
+ _updateHandles();
+}
+
/*
* handlers for handle move-request
*/
diff --git a/src/seltrans.h b/src/seltrans.h
index effc767e3..10860f58f 100644
--- a/src/seltrans.h
+++ b/src/seltrans.h
@@ -97,10 +97,24 @@ public:
void getNextClosestPoint(bool reverse);
private:
+ class BoundingBoxPrefsObserver: public Preferences::Observer
+ {
+ public:
+ BoundingBoxPrefsObserver(SelTrans &sel_trans);
+
+ void notify(Preferences::Entry const &val);
+
+ private:
+ SelTrans &_sel_trans;
+ };
+
+ friend class Inkscape::SelTrans::BoundingBoxPrefsObserver;
+
void _updateHandles();
void _updateVolatileState();
void _selChanged(Inkscape::Selection *selection);
void _selModified(Inkscape::Selection *selection, guint flags);
+ void _boundingBoxPrefsChanged(int prefs_bbox);
void _showHandles(SPKnot *knot[], SPSelTransHandle const handle[], gint num,
gchar const *even_tip, gchar const *odd_tip);
Geom::Point _getGeomHandlePos(Geom::Point const &visual_handle_pos);
@@ -179,6 +193,7 @@ private:
Inkscape::MessageContext _message_context;
sigc::connection _sel_changed_connection;
sigc::connection _sel_modified_connection;
+ BoundingBoxPrefsObserver _bounding_box_prefs_observer;
};
}