From: dvlierop2 Date: Mon, 6 Aug 2007 18:40:50 +0000 (+0000) Subject: 1) Make snapping of object's center optional 2) Optimize snapping preferences dialog X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=34b288929138cc33cd8fe2c8559493e5e770e2a0;p=inkscape.git 1) Make snapping of object's center optional 2) Optimize snapping preferences dialog --- diff --git a/src/attributes.cpp b/src/attributes.cpp index 90f3e0280..3810cb0f7 100644 --- a/src/attributes.cpp +++ b/src/attributes.cpp @@ -84,6 +84,7 @@ static SPStyleProp const props[] = { {SP_ATTR_INKSCAPE_WINDOW_Y, "inkscape:window-y"}, {SP_ATTR_INKSCAPE_SNAP_BBOX, "inkscape:snap-bbox"}, {SP_ATTR_INKSCAPE_SNAP_NODES, "inkscape:snap-nodes"}, + {SP_ATTR_INKSCAPE_SNAP_CENTER, "inkscape:snap-center"}, {SP_ATTR_INKSCAPE_OBJECT_PATHS, "inkscape:object-paths"}, {SP_ATTR_INKSCAPE_OBJECT_NODES, "inkscape:object-nodes"}, {SP_ATTR_INKSCAPE_CURRENT_LAYER, "inkscape:current-layer"}, diff --git a/src/attributes.h b/src/attributes.h index 9a969dc8c..752500e24 100644 --- a/src/attributes.h +++ b/src/attributes.h @@ -85,6 +85,7 @@ enum SPAttributeEnum { SP_ATTR_INKSCAPE_WINDOW_Y, SP_ATTR_INKSCAPE_SNAP_BBOX, SP_ATTR_INKSCAPE_SNAP_NODES, + SP_ATTR_INKSCAPE_SNAP_CENTER, SP_ATTR_INKSCAPE_OBJECT_PATHS, SP_ATTR_INKSCAPE_OBJECT_NODES, SP_ATTR_INKSCAPE_CURRENT_LAYER, diff --git a/src/snap.cpp b/src/snap.cpp index f5c1c9589..651da788f 100644 --- a/src/snap.cpp +++ b/src/snap.cpp @@ -137,7 +137,7 @@ void SnapManager::setSnapModeNode(bool enabled) object.setSnapFrom(Inkscape::Snapper::SNAPPOINT_NODE, enabled); //object.setSnapToItemNode(enabled); // On second thought, these should be controlled //object.setSnapToItemPath(enabled); // separately by the snapping prefs dialog - object.setStrictSnapping(true); + object.setStrictSnapping(true); } bool SnapManager::getSnapModeNode() const diff --git a/src/sp-namedview.cpp b/src/sp-namedview.cpp index af30b3ed1..084e61b47 100644 --- a/src/sp-namedview.cpp +++ b/src/sp-namedview.cpp @@ -155,6 +155,7 @@ static void sp_namedview_build(SPObject *object, SPDocument *document, Inkscape: sp_object_read_attr(object, "inkscape:window-y"); sp_object_read_attr(object, "inkscape:snap-bbox"); sp_object_read_attr(object, "inkscape:snap-nodes"); + sp_object_read_attr(object, "inkscape:snap-center"); sp_object_read_attr(object, "inkscape:object-paths"); sp_object_read_attr(object, "inkscape:object-nodes"); sp_object_read_attr(object, "inkscape:current-layer"); @@ -350,6 +351,10 @@ static void sp_namedview_set(SPObject *object, unsigned int key, const gchar *va nv->snap_manager.setSnapModeNode(value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); break; + case SP_ATTR_INKSCAPE_SNAP_CENTER: + nv->snap_manager.setIncludeItemCenter(value ? sp_str_to_bool(value) : FALSE); + object->requestModified(SP_OBJECT_MODIFIED_FLAG); + break; case SP_ATTR_INKSCAPE_OBJECT_PATHS: nv->snap_manager.object.setSnapToItemPath(value ? sp_str_to_bool(value) : TRUE); object->requestModified(SP_OBJECT_MODIFIED_FLAG); diff --git a/src/ui/dialog/document-properties.cpp b/src/ui/dialog/document-properties.cpp index 807d4129f..062f838f9 100644 --- a/src/ui/dialog/document-properties.cpp +++ b/src/ui/dialog/document-properties.cpp @@ -272,6 +272,9 @@ DocumentProperties::build_snap() _rcbsnn.init (_("Snap _nodes"), _("Snap nodes to grid lines, to guides, to paths, and to other nodes"), "inkscape:snap-nodes", _wr); + _rcbic.init (_("Include the object's center"), + _("Also snap the rotation center of an object when snapping nodes"), + "inkscape:snap-center", _wr); //Options for snapping to objects _rcbsnop.init (_("Snap to _paths"), @@ -280,23 +283,30 @@ DocumentProperties::build_snap() _rcbsnon.init (_("Snap to n_odes"), _("Snap nodes to object nodes"), "inkscape:object-nodes", _wr); - _rsu_sno.init (_(" Snap _distance"), _("Snap at any dist_ance"), + _rsu_sno.init (_("Snap _distance"), _("Snap at any dist_ance"), _("Snapping distance, in screen pixels, for snapping to objects"), _("If set, objects snap to the nearest object, regardless of distance"), "objecttolerance", _wr); //Options for snapping to grids - _rsu_sn.init (_(" Snap d_istance"), _("Snap at any distan_ce"), + _rsu_sn.init (_("Snap d_istance"), _("Snap at any distan_ce"), _("Snapping distance, in screen pixels, for snapping to grid"), _("If set, objects snap to the nearest grid line, regardless of distance"), "gridtolerance", _wr); //Options for snapping to guides - _rsu_gusn.init (_(" Snap di_stance"), _("Snap at any distanc_e"), + _rsu_gusn.init (_("Snap di_stance"), _("Snap at any distanc_e"), _("Snapping distance, in screen pixels, for snapping to guides"), _("If set, objects snap to the nearest guide, regardless of distance"), "guidetolerance", _wr); + std::list list; + list.push_back(_rcbic._button); + list.push_back(_rcbsnop._button); + list.push_back(_rcbsnon._button); + _rcbsnn.setSlaveButton(list); + + Gtk::Label *label_g = manage (new Gtk::Label); label_g->set_markup (_("General")); Gtk::Label *label_o = manage (new Gtk::Label); @@ -310,21 +320,25 @@ DocumentProperties::build_snap() { label_g, 0, 0, _rcbsnn._button, + 0, 0, //_rcbic._button will be inserted here 0, _rcbsnbb._button, - 0, 0, + 0, 0, label_o, 0, 0, _rcbsnop._button, 0, _rcbsnon._button, 0, _rsu_sno._vbox, - 0, 0, + 0, 0, label_gr, 0, 0, _rsu_sn._vbox, - 0, 0, + 0, 0, label_gu, 0, 0, _rsu_gusn._vbox, }; attach_all(_page_snap.table(), array, G_N_ELEMENTS(array)); + + // add _rcbic manually to get some additional indenting + _page_snap.table().attach(*_rcbic._button, 1, 3, 2, 3, Gtk::FILL|Gtk::EXPAND, (Gtk::AttachOptions)0, 18, 0); } /** @@ -432,8 +446,10 @@ DocumentProperties::update() _rcp_hgui.setRgba32 (nv->guidehicolor); //-----------------------------------------------------------snap + _rcbsnbb.setActive (nv->snap_manager.getSnapModeBBox()); _rcbsnn.setActive (nv->snap_manager.getSnapModeNode()); + _rcbic.setActive (nv->snap_manager.getIncludeItemCenter()); _rcbsnop.setActive(nv->snap_manager.object.getSnapToItemPath()); _rcbsnon.setActive(nv->snap_manager.object.getSnapToItemNode()); _rsu_sno.setValue (nv->objecttolerance); diff --git a/src/ui/dialog/document-properties.h b/src/ui/dialog/document-properties.h index d2f8776e4..5db1c734f 100644 --- a/src/ui/dialog/document-properties.h +++ b/src/ui/dialog/document-properties.h @@ -73,7 +73,7 @@ protected: RegisteredUnitMenu _rum_gusn; RegisteredColorPicker _rcp_gui, _rcp_hgui; //--------------------------------------------------------------- - RegisteredCheckButton _rcbsnbb, _rcbsnn, _rcbsnop, _rcbsnon; + RegisteredCheckButton _rcbsnbb, _rcbsnn, _rcbic, _rcbsnop, _rcbsnon; RegisteredUnitMenu _rumso; ToleranceSlider _rsu_sno, _rsu_sn, _rsu_gusn; RegisteredRadioButtonPair _rrb_pix; diff --git a/src/ui/widget/registered-widget.cpp b/src/ui/widget/registered-widget.cpp index 86c76b236..6ef264b0d 100644 --- a/src/ui/widget/registered-widget.cpp +++ b/src/ui/widget/registered-widget.cpp @@ -81,6 +81,10 @@ void RegisteredCheckButton::setActive (bool b) { _button->set_active (b); + //The slave button is greyed out if the master button is unchecked + for (std::list::const_iterator i = _slavebuttons.begin(); i != _slavebuttons.end(); i++) { + (*i)->set_sensitive(b); + } } void @@ -104,6 +108,11 @@ RegisteredCheckButton::on_toggled() _wr->setUpdating (true); + //The slave button is greyed out if the master button is unchecked + for (std::list::const_iterator i = _slavebuttons.begin(); i != _slavebuttons.end(); i++) { + (*i)->set_sensitive(_button->get_active()); + } + bool saved = sp_document_get_undo_sensitive (local_doc); sp_document_set_undo_sensitive (local_doc, false); sp_repr_set_boolean(local_repr, _key.c_str(), _button->get_active()); diff --git a/src/ui/widget/registered-widget.h b/src/ui/widget/registered-widget.h index 43588a831..8e54e1bbd 100644 --- a/src/ui/widget/registered-widget.h +++ b/src/ui/widget/registered-widget.h @@ -42,6 +42,15 @@ public: void setActive (bool); Gtk::ToggleButton *_button; + std::list _slavebuttons; + + // a slave button is only sensitive when the master button is active + // i.e. a slave button is greyed-out when the master button is not checked + + void setSlaveButton(std::list btns) { + _slavebuttons = btns; + } + protected: Gtk::Tooltips _tt; diff --git a/src/ui/widget/tolerance-slider.cpp b/src/ui/widget/tolerance-slider.cpp index 92a6f76bb..d89d4cf5c 100644 --- a/src/ui/widget/tolerance-slider.cpp +++ b/src/ui/widget/tolerance-slider.cpp @@ -72,7 +72,8 @@ ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& label2, Gtk::Label *theLabel1 = manage (new Gtk::Label (label1)); theLabel1->set_use_underline(); theLabel1->set_alignment(0, 0.5); - _hbox->add (*theLabel1); + // align the label with the checkbox text above by indenting 22 px. + _hbox->pack_start(*theLabel1, Gtk::PACK_EXPAND_WIDGET, 22); _hscale = manage (new Gtk::HScale (1.0, 51, 1.0)); theLabel1->set_mnemonic_widget (*_hscale); _hscale->set_draw_value (true); @@ -83,6 +84,7 @@ ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& label2, _tt.set_tip (*_hscale, tip1); _hbox->add (*_hscale); + Gtk::Label *theLabel2 = manage (new Gtk::Label (label2)); theLabel2->set_use_underline(); _button = manage (new Gtk::CheckButton); @@ -91,7 +93,8 @@ ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& label2, _button->set_alignment (0.0, 0.5); _vbox->add (*_button); - _vbox->add (*_hbox); + // Here we need some extra pixels to get the vertical spacing right. Why? + _vbox->pack_end(*_hbox, true, true, 3); // add 3 px. _key = key; _scale_changed_connection = _hscale->signal_value_changed().connect (sigc::mem_fun (*this, &ToleranceSlider::on_scale_changed)); _btn_toggled_connection = _button->signal_toggled().connect (sigc::mem_fun (*this, &ToleranceSlider::on_toggled));