summaryrefslogtreecommitdiffstats
path: root/src/ui/widget
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2008-11-21 05:24:08 +0000
committerTed Gould <ted@canonical.com>2008-11-21 05:24:08 +0000
commit44a3a78fb6a3863c0c7f3c1193837337e68a67e4 (patch)
tree1722ee5ec6f88c881cd4124923354b3c1311501b /src/ui/widget
parentMerge from trunk (diff)
downloadinkscape-44a3a78fb6a3863c0c7f3c1193837337e68a67e4.tar.gz
inkscape-44a3a78fb6a3863c0c7f3c1193837337e68a67e4.zip
Merge from fe-moved
(bzr r6891)
Diffstat (limited to 'src/ui/widget')
-rw-r--r--src/ui/widget/object-composite-settings.cpp4
-rw-r--r--src/ui/widget/preferences-widget.cpp60
-rw-r--r--src/ui/widget/preferences-widget.h17
-rw-r--r--src/ui/widget/style-subject.cpp8
-rw-r--r--src/ui/widget/style-subject.h6
5 files changed, 86 insertions, 9 deletions
diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp
index 9e39af75f..3ef4c7328 100644
--- a/src/ui/widget/object-composite-settings.cpp
+++ b/src/ui/widget/object-composite-settings.cpp
@@ -125,7 +125,7 @@ ObjectCompositeSettings::_blendBlurValueChanged()
// FIXME: fix for GTK breakage, see comment in SelectedStyle::on_opacity_changed; here it results in crash 1580903
sp_canvas_force_full_redraw_after_interruptions(sp_desktop_canvas(desktop), 0);
- boost::optional<Geom::Rect> bbox = _subject->getBounds(SPItem::GEOMETRIC_BBOX);
+ Geom::OptRect bbox = _subject->getBounds(SPItem::GEOMETRIC_BBOX);
double radius;
if (bbox) {
double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y]; // fixme: this is only half the perimeter, is that correct?
@@ -271,7 +271,7 @@ ObjectCompositeSettings::_subjectChanged() {
case QUERY_STYLE_SINGLE:
case QUERY_STYLE_MULTIPLE_AVERAGED:
case QUERY_STYLE_MULTIPLE_SAME:
- boost::optional<Geom::Rect> bbox = _subject->getBounds(SPItem::GEOMETRIC_BBOX);
+ Geom::OptRect bbox = _subject->getBounds(SPItem::GEOMETRIC_BBOX);
if (bbox) {
double perimeter = bbox->dimensions()[Geom::X] + bbox->dimensions()[Geom::Y]; // fixme: this is only half the perimeter, is that correct?
_fe_cb.set_blur_sensitive(true);
diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp
index 72df1baab..395726511 100644
--- a/src/ui/widget/preferences-widget.cpp
+++ b/src/ui/widget/preferences-widget.cpp
@@ -461,6 +461,66 @@ ZoomCorrRulerSlider::init(int ruler_width, int ruler_height, double lower, doubl
this->pack_start(*table, Gtk::PACK_EXPAND_WIDGET);
}
+void
+PrefSlider::on_slider_value_changed()
+{
+ if (this->is_visible() || freeze) //only take action if user changed value
+ {
+ freeze = true;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble(_prefs_path, _slider.get_value());
+ _sb.set_value(_slider.get_value());
+ freeze = false;
+ }
+}
+
+void
+PrefSlider::on_spinbutton_value_changed()
+{
+ if (this->is_visible() || freeze) //only take action if user changed value
+ {
+ freeze = true;
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ prefs->setDouble(_prefs_path, _sb.get_value());
+ _slider.set_value(_sb.get_value());
+ freeze = false;
+ }
+}
+
+void
+PrefSlider::init(Glib::ustring const &prefs_path,
+ double lower, double upper, double step_increment, double page_increment, double default_value, int digits)
+{
+ _prefs_path = prefs_path;
+
+ Inkscape::Preferences *prefs = Inkscape::Preferences::get();
+ double value = prefs->getDoubleLimited(prefs_path, default_value, lower, upper);
+
+ freeze = false;
+
+ _slider.set_range (lower, upper);
+ _slider.set_increments (step_increment, page_increment);
+ _slider.set_value (value);
+ _slider.set_digits(digits);
+ _slider.signal_value_changed().connect(sigc::mem_fun(*this, &PrefSlider::on_slider_value_changed));
+
+ _sb.signal_value_changed().connect(sigc::mem_fun(*this, &PrefSlider::on_spinbutton_value_changed));
+ _sb.set_range (lower, upper);
+ _sb.set_increments (step_increment, page_increment);
+ _sb.set_value (value);
+ _sb.set_digits(digits);
+
+ Gtk::Table *table = Gtk::manage(new Gtk::Table());
+ Gtk::Alignment *alignment1 = Gtk::manage(new Gtk::Alignment(0.5,1,0,0));
+ Gtk::Alignment *alignment2 = Gtk::manage(new Gtk::Alignment(0.5,1,0,0));
+ alignment1->add(_sb);
+
+ table->attach(_slider, 0, 1, 0, 1);
+ table->attach(*alignment1, 1, 2, 0, 1, static_cast<Gtk::AttachOptions>(0));
+
+ this->pack_start(*table, Gtk::PACK_EXPAND_WIDGET);
+}
+
void PrefCombo::init(Glib::ustring const &prefs_path,
Glib::ustring labels[], int values[], int num_items, int default_value)
{
diff --git a/src/ui/widget/preferences-widget.h b/src/ui/widget/preferences-widget.h
index dbc319c1a..1576184ac 100644
--- a/src/ui/widget/preferences-widget.h
+++ b/src/ui/widget/preferences-widget.h
@@ -122,6 +122,23 @@ private:
bool freeze; // used to block recursive updates of slider and spinbutton
};
+class PrefSlider : public Gtk::HBox
+{
+public:
+ void init(Glib::ustring const &prefs_path,
+ double lower, double upper, double step_increment, double page_increment, double default_value, int digits);
+
+private:
+ void on_slider_value_changed();
+ void on_spinbutton_value_changed();
+
+ Glib::ustring _prefs_path;
+ Gtk::SpinButton _sb;
+ Gtk::HScale _slider;
+ bool freeze; // used to block recursive updates of slider and spinbutton
+};
+
+
class PrefCombo : public Gtk::ComboBoxText
{
public:
diff --git a/src/ui/widget/style-subject.cpp b/src/ui/widget/style-subject.cpp
index a2e8a2547..a7359242d 100644
--- a/src/ui/widget/style-subject.cpp
+++ b/src/ui/widget/style-subject.cpp
@@ -65,12 +65,12 @@ StyleSubject::iterator StyleSubject::Selection::begin() {
}
}
-boost::optional<Geom::Rect> StyleSubject::Selection::getBounds(SPItem::BBoxType type) {
+Geom::OptRect StyleSubject::Selection::getBounds(SPItem::BBoxType type) {
Inkscape::Selection *selection = _getSelection();
if (selection) {
return selection->bounds(type);
} else {
- return boost::optional<Geom::Rect>();
+ return Geom::OptRect();
}
}
@@ -143,12 +143,12 @@ StyleSubject::iterator StyleSubject::CurrentLayer::begin() {
return iterator(_getLayerSList());
}
-boost::optional<Geom::Rect> StyleSubject::CurrentLayer::getBounds(SPItem::BBoxType type) {
+Geom::OptRect StyleSubject::CurrentLayer::getBounds(SPItem::BBoxType type) {
SPObject *layer = _getLayer();
if (layer && SP_IS_ITEM(layer)) {
return sp_item_bbox_desktop(SP_ITEM(layer), type);
} else {
- return boost::optional<Geom::Rect>();
+ return Geom::OptRect();
}
}
diff --git a/src/ui/widget/style-subject.h b/src/ui/widget/style-subject.h
index 231a88728..6f46efff5 100644
--- a/src/ui/widget/style-subject.h
+++ b/src/ui/widget/style-subject.h
@@ -44,7 +44,7 @@ public:
virtual iterator begin() = 0;
virtual iterator end() { return iterator(NULL); }
- virtual boost::optional<Geom::Rect> getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) = 0;
+ virtual Geom::OptRect getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX) = 0;
virtual int queryStyle(SPStyle *query, int property) = 0;
virtual void setCSS(SPCSSAttr *css) = 0;
@@ -67,7 +67,7 @@ public:
~Selection();
virtual iterator begin();
- virtual boost::optional<Geom::Rect> getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX);
+ virtual Geom::OptRect getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX);
virtual int queryStyle(SPStyle *query, int property);
virtual void setCSS(SPCSSAttr *css);
@@ -88,7 +88,7 @@ public:
~CurrentLayer();
virtual iterator begin();
- virtual boost::optional<Geom::Rect> getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX);
+ virtual Geom::OptRect getBounds(SPItem::BBoxType type = SPItem::APPROXIMATE_BBOX);
virtual int queryStyle(SPStyle *query, int property);
virtual void setCSS(SPCSSAttr *css);