summaryrefslogtreecommitdiffstats
path: root/src/ui/widget
diff options
context:
space:
mode:
authorTed Gould <ted@gould.cx>2012-11-25 19:41:24 +0000
committerTed Gould <ted@gould.cx>2012-11-25 19:41:24 +0000
commit18be0e5e3ab74823043e19dd6ea46c4b6b130e86 (patch)
treea62925ec4473c1a21e1c99d1415f4cccab59b432 /src/ui/widget
parentGetting all the filter headers (diff)
parentFix for 1036059 : Keyboard shortcut editor (diff)
downloadinkscape-18be0e5e3ab74823043e19dd6ea46c4b6b130e86.tar.gz
inkscape-18be0e5e3ab74823043e19dd6ea46c4b6b130e86.zip
Update to current trunk
(bzr r11804.1.8)
Diffstat (limited to 'src/ui/widget')
-rw-r--r--src/ui/widget/color-picker.cpp2
-rw-r--r--src/ui/widget/layer-selector.cpp6
-rw-r--r--src/ui/widget/licensor.cpp18
-rw-r--r--src/ui/widget/page-sizer.cpp4
-rw-r--r--src/ui/widget/preferences-widget.cpp2
-rw-r--r--src/ui/widget/rotateable.cpp31
-rw-r--r--src/ui/widget/rotateable.h3
-rw-r--r--src/ui/widget/selected-style.cpp117
-rw-r--r--src/ui/widget/selected-style.h3
9 files changed, 129 insertions, 57 deletions
diff --git a/src/ui/widget/color-picker.cpp b/src/ui/widget/color-picker.cpp
index e5c542a7c..31fb3096c 100644
--- a/src/ui/widget/color-picker.cpp
+++ b/src/ui/widget/color-picker.cpp
@@ -55,7 +55,7 @@ void ColorPicker::setupDialog(const Glib::ustring &title)
_colorSelectorDialog.hide();
_colorSelectorDialog.set_title (title);
_colorSelectorDialog.set_border_width (4);
- _colorSelector = (SPColorSelector*)sp_color_selector_new(SP_TYPE_COLOR_NOTEBOOK);
+ _colorSelector = SP_COLOR_SELECTOR(sp_color_selector_new(SP_TYPE_COLOR_NOTEBOOK));
_colorSelectorDialog.get_vbox()->pack_start (
*Glib::wrap(&_colorSelector->vbox), true, true, 0);
diff --git a/src/ui/widget/layer-selector.cpp b/src/ui/widget/layer-selector.cpp
index c06f70185..fbb9c0e24 100644
--- a/src/ui/widget/layer-selector.cpp
+++ b/src/ui/widget/layer-selector.cpp
@@ -241,7 +241,11 @@ private:
void LayerSelector::_layersChanged()
{
if (_desktop) {
- _selectLayer(_desktop->currentLayer());
+ /*
+ * This code fixes #166691 but causes issues #1066543 and #1080378.
+ * Comment out until solution found.
+ */
+ //_selectLayer(_desktop->currentLayer());
}
}
diff --git a/src/ui/widget/licensor.cpp b/src/ui/widget/licensor.cpp
index 7fff7d87f..8ecd36af2 100644
--- a/src/ui/widget/licensor.cpp
+++ b/src/ui/widget/licensor.cpp
@@ -44,7 +44,7 @@ const struct rdf_license_t _other_license =
class LicenseItem : public Gtk::RadioButton {
public:
- LicenseItem (struct rdf_license_t const* license, EntityEntry* entity, Registry &wr);
+ LicenseItem (struct rdf_license_t const* license, EntityEntry* entity, Registry &wr, Gtk::RadioButtonGroup *group);
protected:
void on_toggled();
struct rdf_license_t const *_lic;
@@ -52,13 +52,12 @@ protected:
Registry &_wr;
};
-LicenseItem::LicenseItem (struct rdf_license_t const* license, EntityEntry* entity, Registry &wr)
+LicenseItem::LicenseItem (struct rdf_license_t const* license, EntityEntry* entity, Registry &wr, Gtk::RadioButtonGroup *group)
: Gtk::RadioButton(_(license->name)), _lic(license), _eep(entity), _wr(wr)
{
- static Gtk::RadioButtonGroup group = get_group();
- static bool first = true;
- if (first) first = false;
- else set_group (group);
+ if (group) {
+ set_group (*group);
+ }
}
/// \pre it is assumed that the license URI entry is a Gtk::Entry
@@ -97,18 +96,19 @@ void Licensor::init (Registry& wr)
LicenseItem *i;
wr.setUpdating (true);
- i = manage (new LicenseItem (&_proprietary_license, _eentry, wr));
+ i = manage (new LicenseItem (&_proprietary_license, _eentry, wr, NULL));
+ Gtk::RadioButtonGroup group = i->get_group();
add (*i);
LicenseItem *pd = i;
for (struct rdf_license_t * license = rdf_licenses;
license && license->name;
license++) {
- i = manage (new LicenseItem (license, _eentry, wr));
+ i = manage (new LicenseItem (license, _eentry, wr, &group));
add(*i);
}
// add Other at the end before the URI field for the confused ppl.
- LicenseItem *io = manage (new LicenseItem (&_other_license, _eentry, wr));
+ LicenseItem *io = manage (new LicenseItem (&_other_license, _eentry, wr, &group));
add (*io);
pd->set_active();
diff --git a/src/ui/widget/page-sizer.cpp b/src/ui/widget/page-sizer.cpp
index 90eb6a3fd..2ab72d6c7 100644
--- a/src/ui/widget/page-sizer.cpp
+++ b/src/ui/widget/page-sizer.cpp
@@ -245,12 +245,14 @@ PageSizer::PageSizer(Registry & _wr)
_widgetRegistry(&_wr)
{
// set precision of scalar entry boxes
+ _wr.setUpdating (true);
_dimensionWidth.setDigits(5);
_dimensionHeight.setDigits(5);
_marginTop.setDigits(5);
_marginLeft.setDigits(5);
_marginRight.setDigits(5);
_marginBottom.setDigits(5);
+ _wr.setUpdating (false);
//# Set up the Paper Size combo box
_paperSizeListStore = Gtk::ListStore::create(_paperSizeListColumns);
@@ -315,11 +317,13 @@ PageSizer::PageSizer(Registry & _wr)
// Setting default custom unit to document unit
SPDesktop *dt = SP_ACTIVE_DESKTOP;
SPNamedView *nv = sp_desktop_namedview(dt);
+ _wr.setUpdating (true);
if (nv->units) {
_dimensionUnits.setUnit(nv->units);
} else if (nv->doc_units) {
_dimensionUnits.setUnit(nv->doc_units);
}
+ _wr.setUpdating (false);
//## Set up custom size frame
_customFrame.set_label(_("Custom size"));
diff --git a/src/ui/widget/preferences-widget.cpp b/src/ui/widget/preferences-widget.cpp
index 07145f5f3..b793893c7 100644
--- a/src/ui/widget/preferences-widget.cpp
+++ b/src/ui/widget/preferences-widget.cpp
@@ -640,7 +640,7 @@ void PrefCombo::on_changed()
if (this->get_visible()) //only take action if user changed value
{
Inkscape::Preferences *prefs = Inkscape::Preferences::get();
- if(_values.size() > 0)
+ if(!_values.empty())
{
prefs->setInt(_prefs_path, _values[this->get_active_row_number()]);
}
diff --git a/src/ui/widget/rotateable.cpp b/src/ui/widget/rotateable.cpp
index 7be666843..1d91515e5 100644
--- a/src/ui/widget/rotateable.cpp
+++ b/src/ui/widget/rotateable.cpp
@@ -24,12 +24,15 @@ Rotateable::Rotateable():
{
dragging = false;
working = false;
+ scrolling = false;
modifier = 0;
current_axis = axis;
signal_button_press_event().connect(sigc::mem_fun(*this, &Rotateable::on_click));
signal_motion_notify_event().connect(sigc::mem_fun(*this, &Rotateable::on_motion));
signal_button_release_event().connect(sigc::mem_fun(*this, &Rotateable::on_release));
+ signal_scroll_event().connect(sigc::mem_fun(*this, &Rotateable::on_scroll));
+
}
bool Rotateable::on_click(GdkEventButton *event) {
@@ -124,6 +127,34 @@ bool Rotateable::on_release(GdkEventButton *event) {
return false;
}
+bool Rotateable::on_scroll(GdkEventScroll* event)
+{
+ double change = 0.0;
+
+ if (event->direction == GDK_SCROLL_UP) {
+ change = 1.0;
+ } else if (event->direction == GDK_SCROLL_DOWN) {
+ change = -1.0;
+ } else {
+ return FALSE;
+ }
+
+ drag_started_x = event->x;
+ drag_started_y = event->y;
+ modifier = get_single_modifier(modifier, event->state);
+ dragging = false;
+ working = false;
+ scrolling = true;
+ current_axis = axis;
+
+ do_scroll(change, modifier);
+
+ dragging = false;
+ working = false;
+ scrolling = false;
+
+ return TRUE;
+}
Rotateable::~Rotateable() {
}
diff --git a/src/ui/widget/rotateable.h b/src/ui/widget/rotateable.h
index 15e0bf71c..52fb5306c 100644
--- a/src/ui/widget/rotateable.h
+++ b/src/ui/widget/rotateable.h
@@ -31,10 +31,12 @@ public:
bool on_click(GdkEventButton *event);
bool on_motion(GdkEventMotion *event);
bool on_release(GdkEventButton *event);
+ bool on_scroll(GdkEventScroll* event);
double axis;
double current_axis;
double maxdecl;
+ bool scrolling;
private:
double drag_started_x;
@@ -47,6 +49,7 @@ private:
virtual void do_motion (double /*by*/, guint /*state*/) {}
virtual void do_release (double /*by*/, guint /*state*/) {}
+ virtual void do_scroll (double /*by*/, guint /*state*/) {}
};
} // namespace Widget
diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp
index e5992958b..41d7c8be2 100644
--- a/src/ui/widget/selected-style.cpp
+++ b/src/ui/widget/selected-style.cpp
@@ -47,6 +47,7 @@
#include "pixmaps/cursor-adj-h.xpm"
#include "pixmaps/cursor-adj-s.xpm"
#include "pixmaps/cursor-adj-l.xpm"
+#include "pixmaps/cursor-adj-a.xpm"
#include "sp-cursor.h"
#include "gradient-chemistry.h"
@@ -299,7 +300,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
// List of units should match with Fill/Stroke dialog stroke style width list
for (GSList *l = sp_unit_get_list(SP_UNIT_ABSOLUTE | SP_UNIT_DEVICE); l != NULL; l = l->next) {
- SPUnit const *u = (SPUnit*)l->data;
+ SPUnit const *u = static_cast<SPUnit*>(l->data);
Gtk::RadioMenuItem *mi = Gtk::manage(new Gtk::RadioMenuItem(_sw_group));
mi->add(*(new Gtk::Label(u->abbr, 0.0, 0.5)));
_unit_mis = g_slist_append(_unit_mis, mi);
@@ -338,6 +339,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/)
_stroke_width_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_sw_click));
_stroke_width_place.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_sw_click));
+
_opacity_sb.signal_populate_popup().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_menu));
_opacity_sb.signal_value_changed().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_changed));
// Connect to key-press to ensure focus is consistent with other spin buttons when using the keys vs mouse-click
@@ -449,7 +451,7 @@ SelectedStyle::setDesktop(SPDesktop *desktop)
this )
));
- _sw_unit = (SPUnit *) sp_desktop_namedview(desktop)->doc_units;
+ _sw_unit = const_cast<SPUnit*>(sp_desktop_namedview(desktop)->doc_units);
// Set the doc default unit active in the units list
gint length = g_slist_length(_unit_mis);
@@ -986,13 +988,13 @@ SelectedStyle::update()
if (SP_IS_LINEARGRADIENT (server)) {
SPGradient *vector = SP_GRADIENT(server)->getVector();
- sp_gradient_image_set_gradient ((SPGradientImage *) _gradient_preview_l[i], vector);
+ sp_gradient_image_set_gradient(SP_GRADIENT_IMAGE(_gradient_preview_l[i]), vector);
place->add(_gradient_box_l[i]);
place->set_tooltip_text(__lgradient[i]);
_mode[i] = SS_LGRADIENT;
} else if (SP_IS_RADIALGRADIENT (server)) {
SPGradient *vector = SP_GRADIENT(server)->getVector();
- sp_gradient_image_set_gradient ((SPGradientImage *) _gradient_preview_r[i], vector);
+ sp_gradient_image_set_gradient(SP_GRADIENT_IMAGE(_gradient_preview_r[i]), vector);
place->add(_gradient_box_r[i]);
place->set_tooltip_text(__rgradient[i]);
_mode[i] = SS_RGRADIENT;
@@ -1008,7 +1010,7 @@ SelectedStyle::update()
guint32 color = paint->value.color.toRGBA32(
SP_SCALE24_TO_FLOAT ((i == SS_FILL)? query->fill_opacity.value : query->stroke_opacity.value));
_lastselected[i] = _thisselected[i];
- _thisselected[i] = color | 0xff; // only color, opacity === 1
+ _thisselected[i] = color; // include opacity
((Inkscape::UI::Widget::ColorPreview*)_color_preview[i])->setRgba32 (color);
_color_preview[i]->show_all();
place->add(*_color_preview[i]);
@@ -1211,39 +1213,43 @@ RotateableSwatch::~RotateableSwatch() {
}
double
-RotateableSwatch::color_adjust(float *hsl, double by, guint32 cc, guint modifier)
+RotateableSwatch::color_adjust(float *hsla, double by, guint32 cc, guint modifier)
{
- sp_color_rgb_to_hsl_floatv (hsl, SP_RGBA32_R_F(cc), SP_RGBA32_G_F(cc), SP_RGBA32_B_F(cc));
-
+ sp_color_rgb_to_hsl_floatv (hsla, SP_RGBA32_R_F(cc), SP_RGBA32_G_F(cc), SP_RGBA32_B_F(cc));
+ hsla[3] = SP_RGBA32_A_F(cc);
double diff = 0;
if (modifier == 2) { // saturation
- double old = hsl[1];
+ double old = hsla[1];
if (by > 0) {
- hsl[1] += by * (1 - hsl[1]);
+ hsla[1] += by * (1 - hsla[1]);
} else {
- hsl[1] += by * (hsl[1]);
+ hsla[1] += by * (hsla[1]);
}
- diff = hsl[1] - old;
+ diff = hsla[1] - old;
} else if (modifier == 1) { // lightness
- double old = hsl[2];
+ double old = hsla[2];
if (by > 0) {
- hsl[2] += by * (1 - hsl[2]);
+ hsla[2] += by * (1 - hsla[2]);
} else {
- hsl[2] += by * (hsl[2]);
+ hsla[2] += by * (hsla[2]);
}
- diff = hsl[2] - old;
+ diff = hsla[2] - old;
+ } else if (modifier == 3) { // alpha
+ double old = hsla[3];
+ hsla[3] += by/2;
+ diff = hsla[3] - old;
} else { // hue
- double old = hsl[0];
- hsl[0] += by/2;
- while (hsl[0] < 0)
- hsl[0] += 1;
- while (hsl[0] > 1)
- hsl[0] -= 1;
- diff = hsl[0] - old;
+ double old = hsla[0];
+ hsla[0] += by/2;
+ while (hsla[0] < 0)
+ hsla[0] += 1;
+ while (hsla[0] > 1)
+ hsla[0] -= 1;
+ diff = hsla[0] - old;
}
float rgb[3];
- sp_color_hsl_to_rgb_floatv (rgb, hsl[0], hsl[1], hsl[2]);
+ sp_color_hsl_to_rgb_floatv (rgb, hsla[0], hsla[1], hsla[2]);
gchar c[64];
sp_svg_write_color (c, sizeof(c),
@@ -1256,10 +1262,14 @@ RotateableSwatch::color_adjust(float *hsl, double by, guint32 cc, guint modifier
);
SPCSSAttr *css = sp_repr_css_attr_new ();
- if (fillstroke == SS_FILL)
- sp_repr_css_set_property (css, "fill", c);
- else
- sp_repr_css_set_property (css, "stroke", c);
+
+ if (modifier == 3) { // alpha
+ Inkscape::CSSOStringStream osalpha;
+ osalpha << hsla[3];
+ sp_repr_css_set_property(css, (fillstroke == SS_FILL) ? "fill-opacity" : "stroke-opacity", osalpha.str().c_str());
+ } else {
+ sp_repr_css_set_property (css, (fillstroke == SS_FILL) ? "fill" : "stroke", c);
+ }
sp_desktop_set_style (parent->getDesktop(), css);
sp_repr_css_attr_unref (css);
return diff;
@@ -1270,7 +1280,7 @@ RotateableSwatch::do_motion(double by, guint modifier) {
if (parent->_mode[fillstroke] != SS_COLOR)
return;
- if (!cr_set && modifier != 3) {
+ if (!scrolling && !cr_set) {
GtkWidget *w = GTK_WIDGET(gobj());
GdkPixbuf *pixbuf = NULL;
@@ -1278,6 +1288,8 @@ RotateableSwatch::do_motion(double by, guint modifier) {
pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)cursor_adj_s_xpm);
} else if (modifier == 1) { // lightness
pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)cursor_adj_l_xpm);
+ } else if (modifier == 3) { // alpha
+ pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)cursor_adj_a_xpm);
} else { // hue
pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)cursor_adj_h_xpm);
}
@@ -1305,43 +1317,51 @@ RotateableSwatch::do_motion(double by, guint modifier) {
cc = startcolor;
}
- float hsl[3];
+ float hsla[4];
double diff = 0;
- if (modifier != 3) {
- diff = color_adjust(hsl, by, cc, modifier);
- }
- if (modifier == 3) { // Alt, do nothing
+ diff = color_adjust(hsla, by, cc, modifier);
+
+ if (modifier == 3) { // alpha
+ DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
+ SP_VERB_DIALOG_FILL_STROKE, (_("Adjust alpha")));
+ double ch = hsla[3];
+ parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>alpha</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Ctrl</b> to adjust lightness, with <b>Shift</b> to adjust saturation, without modifiers to adjust hue"), ch - diff, ch, diff);
} else if (modifier == 2) { // saturation
DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
SP_VERB_DIALOG_FILL_STROKE, (_("Adjust saturation")));
- double ch = hsl[1];
- parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>saturation</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Ctrl</b> to adjust lightness, without modifiers to adjust hue"), ch - diff, ch, diff);
+ double ch = hsla[1];
+ parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>saturation</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Ctrl</b> to adjust lightness, with <b>Alt</b> to adjust alpha, without modifiers to adjust hue"), ch - diff, ch, diff);
} else if (modifier == 1) { // lightness
DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
SP_VERB_DIALOG_FILL_STROKE, (_("Adjust lightness")));
- double ch = hsl[2];
- parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>lightness</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, without modifiers to adjust hue"), ch - diff, ch, diff);
+ double ch = hsla[2];
+ parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>lightness</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, with <b>Alt</b> to adjust alpha, without modifiers to adjust hue"), ch - diff, ch, diff);
} else { // hue
DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
SP_VERB_DIALOG_FILL_STROKE, (_("Adjust hue")));
- double ch = hsl[0];
- parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>hue</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, with <b>Ctrl</b> to adjust lightness"), ch - diff, ch, diff);
+ double ch = hsla[0];
+ parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting <b>hue</b>: was %.3g, now <b>%.3g</b> (diff %.3g); with <b>Shift</b> to adjust saturation, with <b>Alt</b> to adjust alpha, with <b>Ctrl</b> to adjust lightness"), ch - diff, ch, diff);
}
}
+
+void
+RotateableSwatch::do_scroll(double by, guint modifier) {
+ do_motion(by/30.0, modifier);
+ do_release(by/30.0, modifier);
+}
+
void
RotateableSwatch::do_release(double by, guint modifier) {
if (parent->_mode[fillstroke] != SS_COLOR)
return;
- float hsl[3];
- if (modifier != 3) {
- color_adjust(hsl, by, startcolor, modifier);
- }
+ float hsla[4];
+ color_adjust(hsla, by, startcolor, modifier);
if (cr_set) {
GtkWidget *w = GTK_WIDGET(gobj());
@@ -1357,7 +1377,9 @@ RotateableSwatch::do_release(double by, guint modifier) {
cr_set = false;
}
- if (modifier == 3) { // Alt, do nothing
+ if (modifier == 3) { // alpha
+ DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
+ SP_VERB_DIALOG_FILL_STROKE, ("Adjust alpha"));
} else if (modifier == 2) { // saturation
DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey,
SP_VERB_DIALOG_FILL_STROKE, ("Adjust saturation"));
@@ -1467,6 +1489,11 @@ RotateableStrokeWidth::do_release(double by, guint modifier) {
parent->getDesktop()->event_context->_message_context->clear();
}
+void
+RotateableStrokeWidth::do_scroll(double by, guint modifier) {
+ do_motion(by/10.0, modifier);
+ startvalue_set = false;
+}
Dialog::FillAndStroke *get_fill_and_stroke_panel(SPDesktop *desktop)
{
diff --git a/src/ui/widget/selected-style.h b/src/ui/widget/selected-style.h
index a9e9d7274..fac4f22e6 100644
--- a/src/ui/widget/selected-style.h
+++ b/src/ui/widget/selected-style.h
@@ -61,8 +61,10 @@ public:
~RotateableSwatch();
double color_adjust (float *hsl, double by, guint32 cc, guint state);
+
virtual void do_motion (double by, guint state);
virtual void do_release (double by, guint state);
+ virtual void do_scroll (double by, guint state);
private:
guint fillstroke;
@@ -87,6 +89,7 @@ public:
double value_adjust(double current, double by, guint modifier, bool final);
virtual void do_motion (double by, guint state);
virtual void do_release (double by, guint state);
+ virtual void do_scroll (double by, guint state);
private:
SelectedStyle *parent;