Code

Filter effects dialog:
[inkscape.git] / src / selcue.cpp
index 845561d1876a3388215eff4de41d492c25c80ffb..5a831d831ce173e9e32fade63c1df0be1a06d1d8 100644 (file)
@@ -27,7 +27,7 @@
 Inkscape::SelCue::SelCue(SPDesktop *desktop)
     : _desktop(desktop)
 {
-    _selection = SP_DT_SELECTION(_desktop);
+    _selection = sp_desktop_selection(_desktop);
 
     _sel_changed_connection = _selection->connectChanged(
         sigc::hide(sigc::mem_fun(*this, &Inkscape::SelCue::_updateItemBboxes))
@@ -78,40 +78,43 @@ void Inkscape::SelCue::_updateItemBboxes()
     for (GSList const *l = _selection->itemList(); l != NULL; l = l->next) {
         SPItem *item = (SPItem *) l->data;
 
-        NR::Rect const b = sp_item_bbox_desktop(item);
+        gchar const *prefs_bbox = prefs_get_string_attribute("tools.select", "bounding_box");
+        SPItem::BBoxType bbox_type = (prefs_bbox != NULL && strcmp(prefs_bbox, "geometric")==0)? SPItem::GEOMETRIC_BBOX : SPItem::APPROXIMATE_BBOX;
+
+        NR::Maybe<NR::Rect> const b = sp_item_bbox_desktop(item, bbox_type);
 
         SPCanvasItem* box = NULL;
 
-        if (mode == MARK) {
-            box = sp_canvas_item_new(SP_DT_CONTROLS(_desktop),
-                                      SP_TYPE_CTRL,
-                                      "mode", SP_CTRL_MODE_XOR,
-                                      "shape", SP_CTRL_SHAPE_DIAMOND,
-                                      "size", 5.0,
-                                      "filled", TRUE,
-                                      "fill_color", 0x000000ff,
-                                      "stroked", FALSE,
-                                      "stroke_color", 0x000000ff,
-                                      NULL);
-            sp_canvas_item_show(box);
-            SP_CTRL(box)->moveto(NR::Point(b.min()[NR::X], b.max()[NR::Y]));
-            
-            sp_canvas_item_move_to_z(box, 0); // just low enough to not get in the way of other draggable knots
-
-        } else if (mode == BBOX) {
-            box = sp_canvas_item_new(
-                SP_DT_CONTROLS(_desktop),
-                SP_TYPE_CTRLRECT,
-                NULL
-                );
-            
-            SP_CTRLRECT(box)->setRectangle(b);
-            SP_CTRLRECT(box)->setColor(0x000000a0, 0, 0);
-            SP_CTRLRECT(box)->setDashed(true);
-            
-            sp_canvas_item_move_to_z(box, 0);
+        if (b) {
+            if (mode == MARK) {
+                box = sp_canvas_item_new(sp_desktop_controls(_desktop),
+                                         SP_TYPE_CTRL,
+                                         "mode", SP_CTRL_MODE_XOR,
+                                         "shape", SP_CTRL_SHAPE_DIAMOND,
+                                         "size", 5.0,
+                                         "filled", TRUE,
+                                         "fill_color", 0x000000ff,
+                                         "stroked", FALSE,
+                                         "stroke_color", 0x000000ff,
+                                         NULL);
+                sp_canvas_item_show(box);
+                SP_CTRL(box)->moveto(NR::Point(b->min()[NR::X], b->max()[NR::Y]));
+
+                sp_canvas_item_move_to_z(box, 0); // just low enough to not get in the way of other draggable knots
+
+            } else if (mode == BBOX) {
+                box = sp_canvas_item_new(sp_desktop_controls(_desktop),
+                                         SP_TYPE_CTRLRECT,
+                                         NULL);
+
+                SP_CTRLRECT(box)->setRectangle(*b);
+                SP_CTRLRECT(box)->setColor(0x000000a0, 0, 0);
+                SP_CTRLRECT(box)->setDashed(true);
+
+                sp_canvas_item_move_to_z(box, 0);
+            }
         }
-                
+
         if (box) {
             _item_bboxes.push_back(box);
         }
@@ -121,20 +124,20 @@ void Inkscape::SelCue::_updateItemBboxes()
             Inkscape::Text::Layout const *layout = te_get_layout(item);
             if (layout != NULL) {
                 NR::Point a = layout->characterAnchorPoint(layout->begin()) * sp_item_i2d_affine(item);
-                baseline_point = sp_canvas_item_new(SP_DT_CONTROLS(_desktop), SP_TYPE_CTRL,
+                baseline_point = sp_canvas_item_new(sp_desktop_controls(_desktop), SP_TYPE_CTRL,
                                                     "mode", SP_CTRL_MODE_XOR,
                                                     "size", 4.0,
                                                     "filled", 0,
                                                     "stroked", 1,
                                                     "stroke_color", 0x000000ff,
                                                     NULL);
-                
+
                 sp_canvas_item_show(baseline_point);
                 SP_CTRL(baseline_point)->moveto(a);
                 sp_canvas_item_move_to_z(baseline_point, 0);
             }
         }
-        
+
         if (baseline_point) {
                _text_baselines.push_back(baseline_point);
         }