Code

RegisteredScalar subclassed from RegisteredWidget<Scalar> instead of old RegisteredWdg
[inkscape.git] / src / ui / widget / tolerance-slider.cpp
index f9a991c245694657771ccda5463a59611cb26684..0110a6c4c55c536bfc77aedda642305ce3d6314e 100644 (file)
@@ -56,11 +56,24 @@ ToleranceSlider::~ToleranceSlider()
 void
 ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& label2, const Glib::ustring& tip1, const Glib::ustring& tip2, const Glib::ustring& key, Registry& wr)
 {
+    // hbox = label + slider
+    //
+    // e.g. 
+    //
+    // snap distance |-------X---| 37
+    
+    // vbox = checkbutton
+    //             +
+    //           hbox
+    
     _vbox = new Gtk::VBox;
     _hbox = manage (new Gtk::HBox);
+    
     Gtk::Label *theLabel1 = manage (new Gtk::Label (label1));
     theLabel1->set_use_underline();
-    _hbox->add (*theLabel1);
+    theLabel1->set_alignment(0, 0.5);
+    // 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);
@@ -69,15 +82,19 @@ ToleranceSlider::init (const Glib::ustring& label1, const Glib::ustring& label2,
     _old_val = 10;
     _hscale->set_value (_old_val);
     _tt.set_tip (*_hscale, tip1);
-    _hbox->add (*_hscale);
-    _vbox->add (*_hbox);
+    _hbox->add (*_hscale);    
+    
+    
     Gtk::Label *theLabel2 = manage (new Gtk::Label (label2));
     theLabel2->set_use_underline();
     _button = manage (new Gtk::CheckButton);
     _tt.set_tip (*_button, tip2);
     _button->add (*theLabel2);
     _button->set_alignment (0.0, 0.5);
+    
     _vbox->add (*_button);
+    // 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));
@@ -96,13 +113,13 @@ ToleranceSlider::setValue (double val)
 
     if (val > 9999.9) // magic value 10000.0
     {
-        _button->set_active (true);
+        _button->set_active (false);
         _hbox->set_sensitive (false);
         val = 50.0;
     }
     else
     {
-        _button->set_active (false);
+        _button->set_active (true);
         _hbox->set_sensitive (true);
     }
     _hscale->set_value (val);
@@ -125,7 +142,7 @@ ToleranceSlider::on_scale_changed()
 void
 ToleranceSlider::on_toggled()
 {
-    if (_button->get_active())
+    if (!_button->get_active())
     {
         _old_val = _hscale->get_value();
         _hbox->set_sensitive (false);
@@ -162,8 +179,9 @@ ToleranceSlider::update (double val)
     sp_document_set_undo_sensitive (doc, false);
     Inkscape::XML::Node *repr = SP_OBJECT_REPR (sp_desktop_namedview(dt));
     repr->setAttribute(_key.c_str(), os.str().c_str());
-    doc->rroot->setAttribute("sodipodi:modified", "true");
     sp_document_set_undo_sensitive (doc, saved);
+
+    doc->setModifiedSinceSave();
     
     _wr->setUpdating (false);
 }