From 732b61f8a63db0f01ea3e524f20e74ddcbab5c48 Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Mon, 28 May 2012 00:56:59 +0100 Subject: Stop using deprecated GdkBitmap in custom cursors Fixed bugs: - https://launchpad.net/bugs/943200 (bzr r11429) --- src/ui/widget/selected-style.cpp | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index a60e3cc31..37b3f8a1a 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -1253,30 +1253,27 @@ RotateableSwatch::do_motion(double by, guint modifier) { if (!cr_set && modifier != 3) { GtkWidget *w = GTK_WIDGET(gobj()); + GdkPixbuf *pixbuf = NULL; - GdkBitmap *bitmap = NULL; - GdkBitmap *mask = NULL; if (modifier == 2) { // saturation - sp_cursor_bitmap_and_mask_from_xpm(&bitmap, &mask, cursor_adj_s_xpm); + pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)cursor_adj_s_xpm); } else if (modifier == 1) { // lightness - sp_cursor_bitmap_and_mask_from_xpm(&bitmap, &mask, cursor_adj_l_xpm); + pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)cursor_adj_l_xpm); } else { // hue - sp_cursor_bitmap_and_mask_from_xpm(&bitmap, &mask, cursor_adj_h_xpm); + pixbuf = gdk_pixbuf_new_from_xpm_data((const gchar **)cursor_adj_h_xpm); } - if ((bitmap != NULL) && (mask != NULL)) { - GtkStyle *style = gtk_widget_get_style(w); - cr = gdk_cursor_new_from_pixmap(bitmap, mask, - &style->black, - &style->white, - 16, 16); - g_object_unref (bitmap); - g_object_unref (mask); + + if (pixbuf != NULL) { + cr = gdk_cursor_new_from_pixbuf(gdk_display_get_default(), pixbuf, 16, 16); + + g_object_unref(pixbuf); gdk_window_set_cursor(gtk_widget_get_window(w), cr); #if GTK_CHECK_VERSION(3,0,0) g_object_unref(cr); #else gdk_cursor_unref(cr); #endif + cr = NULL; cr_set = true; } } -- cgit v1.2.3 From 37706949227c13b309baa9ce49201d4c536a662e Mon Sep 17 00:00:00 2001 From: John Smith Date: Tue, 10 Jul 2012 10:19:23 +0900 Subject: Fix for 167781 : opacity in selected style loses focus on kbd value scroll (bzr r11534) --- src/ui/widget/selected-style.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 37b3f8a1a..88341a0e8 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -336,6 +336,8 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _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 + g_signal_connect (G_OBJECT (_opacity_sb.gobj()), "key-press-event", G_CALLBACK (spinbutton_keypress), _opacity_sb.gobj()); _fill_place.add(_na[SS_FILL]); _fill_place.set_tooltip_text(__na[SS_FILL]); -- cgit v1.2.3 From 6fc47b613fb0b33b4866a5e54c231e9426e2ca3d Mon Sep 17 00:00:00 2001 From: John Smith Date: Wed, 11 Jul 2012 09:42:57 +0900 Subject: Fix for 167781 : opacity in selected style loses focus on kbd value scroll, fix for Esc (bzr r11540) --- src/ui/widget/selected-style.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 88341a0e8..867ec62a9 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -338,6 +338,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _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 g_signal_connect (G_OBJECT (_opacity_sb.gobj()), "key-press-event", G_CALLBACK (spinbutton_keypress), _opacity_sb.gobj()); + g_signal_connect (G_OBJECT (_opacity_sb.gobj()), "focus-in-event", G_CALLBACK (spinbutton_focus_in), _opacity_sb.gobj()); _fill_place.add(_na[SS_FILL]); _fill_place.set_tooltip_text(__na[SS_FILL]); -- cgit v1.2.3 From 1ddcf4688a13701d9de2bcf9c970226e9fba2ddd Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 5 Aug 2012 16:26:21 +0900 Subject: Fix for 484135 : clicking on the stroke size doesn't open the dialog box (bzr r11592) --- src/ui/widget/selected-style.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 867ec62a9..a37f36eea 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -333,6 +333,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _stroke_place.signal_button_release_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_stroke_click)); _opacity_place.signal_button_press_event().connect(sigc::mem_fun(*this, &SelectedStyle::on_opacity_click)); _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)); -- cgit v1.2.3 From a8e76949f48267a704af633032e33d6982c682cc Mon Sep 17 00:00:00 2001 From: John Smith Date: Sat, 22 Sep 2012 18:59:01 +0900 Subject: Fix for 367548 : Invert doesnt work on objects with gradients (bzr r11694) --- src/ui/widget/selected-style.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index a37f36eea..b3c4fbdcd 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -48,6 +48,7 @@ #include "pixmaps/cursor-adj-s.xpm" #include "pixmaps/cursor-adj-l.xpm" #include "sp-cursor.h" +#include "gradient-chemistry.h" static gdouble const _sw_presets[] = { 32 , 16 , 10 , 8 , 6 , 4 , 3 , 2 , 1.5 , 1 , 0.75 , 0.5 , 0.25 , 0.1 }; static gchar const *const _sw_presets_str[] = {"32", "16", "10", "8", "6", "4", "3", "2", "1.5", "1", "0.75", "0.5", "0.25", "0.1"}; @@ -598,6 +599,12 @@ void SelectedStyle::on_fill_invert() { SPCSSAttr *css = sp_repr_css_attr_new (); guint32 color = _thisselected[SS_FILL]; gchar c[64]; + if (_mode[SS_FILL] == SS_LGRADIENT || _mode[SS_FILL] == SS_RGRADIENT) { + g_message("Gradient"); + sp_gradient_invert_selected_gradients(_desktop, Inkscape::FOR_FILL); + return; + } + if (_mode[SS_FILL] != SS_COLOR) return; sp_svg_write_color (c, sizeof(c), SP_RGBA32_U_COMPOSE( @@ -618,6 +625,11 @@ void SelectedStyle::on_stroke_invert() { SPCSSAttr *css = sp_repr_css_attr_new (); guint32 color = _thisselected[SS_STROKE]; gchar c[64]; + if (_mode[SS_FILL] == SS_LGRADIENT || _mode[SS_FILL] == SS_RGRADIENT) { + g_message("Gradient"); + sp_gradient_invert_selected_gradients(_desktop, Inkscape::FOR_STROKE); + return; + } if (_mode[SS_STROKE] != SS_COLOR) return; sp_svg_write_color (c, sizeof(c), SP_RGBA32_U_COMPOSE( -- cgit v1.2.3 From a01a3fa9d658218f3afbe5ab9922deb9c3ce38be Mon Sep 17 00:00:00 2001 From: John Smith Date: Sun, 23 Sep 2012 11:19:28 +0900 Subject: Fix for 367548 : Invert doesnt work on objects with gradients (bzr r11696) --- src/ui/widget/selected-style.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index b3c4fbdcd..a4313f677 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -600,9 +600,9 @@ void SelectedStyle::on_fill_invert() { guint32 color = _thisselected[SS_FILL]; gchar c[64]; if (_mode[SS_FILL] == SS_LGRADIENT || _mode[SS_FILL] == SS_RGRADIENT) { - g_message("Gradient"); sp_gradient_invert_selected_gradients(_desktop, Inkscape::FOR_FILL); return; + } if (_mode[SS_FILL] != SS_COLOR) return; @@ -625,8 +625,7 @@ void SelectedStyle::on_stroke_invert() { SPCSSAttr *css = sp_repr_css_attr_new (); guint32 color = _thisselected[SS_STROKE]; gchar c[64]; - if (_mode[SS_FILL] == SS_LGRADIENT || _mode[SS_FILL] == SS_RGRADIENT) { - g_message("Gradient"); + if (_mode[SS_STROKE] == SS_LGRADIENT || _mode[SS_STROKE] == SS_RGRADIENT) { sp_gradient_invert_selected_gradients(_desktop, Inkscape::FOR_STROKE); return; } -- cgit v1.2.3 From b137c6fc5e4d80891b6376e09ba6319b93a145c8 Mon Sep 17 00:00:00 2001 From: John Smith Date: Mon, 1 Oct 2012 18:32:48 +0900 Subject: Fix for 831008 : Line width menu only show Px,Pt and mm (bzr r11719) --- src/ui/widget/selected-style.cpp | 70 +++++++++++++++++++++------------------- 1 file changed, 37 insertions(+), 33 deletions(-) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index a4313f677..e5992958b 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -23,6 +23,7 @@ #include "desktop-handles.h" #include "style.h" #include "desktop-style.h" +#include "sp-namedview.h" #include "sp-linear-gradient-fns.h" #include "sp-radial-gradient-fns.h" #include "sp-pattern.h" @@ -38,7 +39,6 @@ #include "sp-gradient.h" #include "svg/svg-color.h" #include "svg/css-ostringstream.h" -#include "helper/units.h" #include "event-context.h" #include "message-context.h" #include "verbs.h" @@ -144,10 +144,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _opacity_blocked (false), - _popup_px(_sw_group), - _popup_pt(_sw_group), - _popup_mm(_sw_group), - + _unit_mis(NULL), _sw_unit(NULL) { _drop[0] = _drop[1] = 0; @@ -298,34 +295,39 @@ SelectedStyle::SelectedStyle(bool /*layout*/) } { - _popup_px.add(*(new Gtk::Label(_("px"), 0.0, 0.5))); - _popup_px.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_popup_px)); - _popup_sw.attach(_popup_px, 0,1, 0,1); - - _popup_pt.add(*(new Gtk::Label(_("pt"), 0.0, 0.5))); - _popup_pt.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_popup_pt)); - _popup_sw.attach(_popup_pt, 0,1, 1,2); - - _popup_mm.add(*(new Gtk::Label(_("mm"), 0.0, 0.5))); - _popup_mm.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_popup_mm)); - _popup_sw.attach(_popup_mm, 0,1, 2,3); + int row = 0; + + // 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; + 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); + mi->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &SelectedStyle::on_popup_units), u->unit_id)); + _popup_sw.attach(*mi, 0,1, row, row+1); + row++; + } - _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, 3,4); + _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, row, row+1); + row++; for (guint i = 0; i < G_N_ELEMENTS(_sw_presets_str); ++i) { Gtk::MenuItem *mi = Gtk::manage(new Gtk::MenuItem()); mi->add(*(new Gtk::Label(_sw_presets_str[i], 0.0, 0.5))); mi->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &SelectedStyle::on_popup_preset), i)); - _popup_sw.attach(*mi, 0,1, 4+i, 5+i); + _popup_sw.attach(*mi, 0,1, row, row+1); + row++; } - guint i = G_N_ELEMENTS(_sw_presets_str) + 5; - - _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, i,i+1); + _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, row, row+1); + row++; _popup_sw_remove.add(*(new Gtk::Label(_("Remove"), 0.0, 0.5))); _popup_sw_remove.signal_activate().connect(sigc::mem_fun(*this, &SelectedStyle::on_stroke_remove)); - _popup_sw.attach(_popup_sw_remove, 0,1, i+1,i+2); + _popup_sw.attach(_popup_sw_remove, 0,1, row, row+1); + row++; + + sp_set_font_size_smaller (GTK_WIDGET(_popup_sw.gobj())); _popup_sw.show_all(); } @@ -447,7 +449,17 @@ SelectedStyle::setDesktop(SPDesktop *desktop) this ) )); - //_sw_unit = (SPUnit *) sp_desktop_namedview(desktop)->doc_units; + _sw_unit = (SPUnit *) sp_desktop_namedview(desktop)->doc_units; + + // Set the doc default unit active in the units list + gint length = g_slist_length(_unit_mis); + for (int i = 0; i < length; i++) { + Gtk::RadioMenuItem *mi = (Gtk::RadioMenuItem *) g_slist_nth_data(_unit_mis, i); + if (mi && mi->get_label() == Glib::ustring(_sw_unit->abbr)) { + mi->set_active(); + break; + } + } } void SelectedStyle::dragDataReceived( GtkWidget */*widget*/, @@ -887,16 +899,8 @@ SelectedStyle::on_opacity_click(GdkEventButton *event) return false; } -void SelectedStyle::on_popup_px() { - _sw_unit = (SPUnit *) &(sp_unit_get_by_id(SP_UNIT_PX)); - update(); -} -void SelectedStyle::on_popup_pt() { - _sw_unit = (SPUnit *) &(sp_unit_get_by_id(SP_UNIT_PT)); - update(); -} -void SelectedStyle::on_popup_mm() { - _sw_unit = (SPUnit *) &(sp_unit_get_by_id(SP_UNIT_MM)); +void SelectedStyle::on_popup_units(SPUnitId id) { + _sw_unit = (SPUnit *) &(sp_unit_get_by_id(id)); update(); } -- cgit v1.2.3 From 3c8f6b5ed34852b06b38b1046d4d9042155c96a2 Mon Sep 17 00:00:00 2001 From: John Smith Date: Tue, 23 Oct 2012 14:43:40 +0900 Subject: Fix for 171890 : Mouse wheel on swatches (bzr r11822) --- src/ui/widget/selected-style.cpp | 109 ++++++++++++++++++++++++--------------- 1 file changed, 68 insertions(+), 41 deletions(-) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index e5992958b..ee835216d 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" @@ -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 @@ -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 alpha: was %.3g, now %.3g (diff %.3g); with Ctrl to adjust lightness, with Shift 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 saturation: was %.3g, now %.3g (diff %.3g); with Ctrl 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 saturation: was %.3g, now %.3g (diff %.3g); with Ctrl to adjust lightness, with Alt 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 lightness: was %.3g, now %.3g (diff %.3g); with Shift 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 lightness: was %.3g, now %.3g (diff %.3g); with Shift to adjust saturation, with Alt 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 hue: was %.3g, now %.3g (diff %.3g); with Shift to adjust saturation, with Ctrl to adjust lightness"), ch - diff, ch, diff); + double ch = hsla[0]; + parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting hue: was %.3g, now %.3g (diff %.3g); with Shift to adjust saturation, with Alt to adjust alpha, with Ctrl 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) { -- cgit v1.2.3 From f02cd4f80de3b2d54d62958c3f4747908d43eecd Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Thu, 15 Nov 2012 11:19:41 +0000 Subject: cppcheck: Simple fixes for src/ui/widget (bzr r11873) --- src/ui/widget/selected-style.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index ee835216d..41d7c8be2 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -300,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(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); @@ -451,7 +451,7 @@ SelectedStyle::setDesktop(SPDesktop *desktop) this ) )); - _sw_unit = (SPUnit *) sp_desktop_namedview(desktop)->doc_units; + _sw_unit = const_cast(sp_desktop_namedview(desktop)->doc_units); // Set the doc default unit active in the units list gint length = g_slist_length(_unit_mis); @@ -988,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; -- cgit v1.2.3 From 0c7f8357aeb104034b81e6bbb68231713c78ff1f Mon Sep 17 00:00:00 2001 From: Alex Valavanis Date: Sat, 9 Mar 2013 13:24:32 +0000 Subject: Use Gtk::Grid in PreviewHolder. Fixes color preview in RegisteredColorPicker Fixed bugs: - https://launchpad.net/bugs/1094504 (bzr r12185) --- src/ui/widget/selected-style.cpp | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 41d7c8be2..18dbb984b 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -119,8 +119,11 @@ SelectedStyle::SelectedStyle(bool /*layout*/) current_stroke_width(0), _desktop (NULL), - +#if WITH_GTKMM_3_0 + _table(), +#else _table(2, 6), +#endif _fill_label (_("Fill:")), _stroke_label (_("Stroke:")), _opacity_label (_("O:")), @@ -158,8 +161,13 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _opacity_label.set_alignment(0.0, 0.5); _opacity_label.set_padding(0, 0); +#if WITH_GTKMM_3_0 + _table.set_column_spacing(2); + _table.set_row_spacing(0); +#else _table.set_col_spacings (2); _table.set_row_spacings (0); +#endif for (int i = SS_FILL; i <= SS_STROKE; i++) { @@ -361,6 +369,16 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _opacity_sb.set_size_request (SELECTED_STYLE_SB_WIDTH, -1); _opacity_sb.set_sensitive (false); +#if WITH_GTKMM_3_0 + _table.attach(_fill_label, 0, 0, 1, 1); + _table.attach(_stroke_label, 0, 1, 1, 1); + + _table.attach(_fill_flag_place, 1, 0, 1, 1); + _table.attach(_stroke_flag_place, 1, 1, 1, 1); + + _table.attach(_fill_place, 2, 0, 1, 1); + _table.attach(_stroke, 2, 1, 1, 1); +#else _table.attach(_fill_label, 0,1, 0,1, Gtk::FILL, Gtk::SHRINK); _table.attach(_stroke_label, 0,1, 1,2, Gtk::FILL, Gtk::SHRINK); @@ -369,10 +387,17 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _table.attach(_fill_place, 2,3, 0,1); _table.attach(_stroke, 2,3, 1,2); +#endif _opacity_place.add(_opacity_label); + +#if WITH_GTKMM_3_0 + _table.attach(_opacity_place, 4, 0, 1, 2); + _table.attach(_opacity_sb, 5, 0, 1, 2); +#else _table.attach(_opacity_place, 4,5, 0,2, Gtk::SHRINK, Gtk::SHRINK); _table.attach(_opacity_sb, 5,6, 0,2, Gtk::SHRINK, Gtk::SHRINK); +#endif pack_start(_table, true, true, 2); -- cgit v1.2.3 From b0cc47554b385fb68643d07efe6e42366c7121ad Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 6 Apr 2013 01:36:16 +0200 Subject: Merged PaintServer and subclasses; moved Gradient classes to own files. (bzr r11608.1.82) --- src/ui/widget/selected-style.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 18dbb984b..8cb0c5588 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -24,8 +24,8 @@ #include "style.h" #include "desktop-style.h" #include "sp-namedview.h" -#include "sp-linear-gradient-fns.h" -#include "sp-radial-gradient-fns.h" +#include "sp-linear-gradient.h" +#include "sp-radial-gradient.h" #include "sp-pattern.h" #include "ui/dialog/dialog-manager.h" #include "ui/dialog/fill-and-stroke.h" -- cgit v1.2.3 From 9dc7b786c9ef31060012ea4ae13a8188548b4f62 Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Tue, 9 Jul 2013 16:42:04 -0400 Subject: Ported sp-namedview.cpp (todo: fix a bunch of things). (bzr r12380.1.8) --- src/ui/widget/selected-style.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 18dbb984b..d6e2406c9 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -476,7 +476,7 @@ SelectedStyle::setDesktop(SPDesktop *desktop) this ) )); - _sw_unit = const_cast(sp_desktop_namedview(desktop)->doc_units); + //_sw_unit = const_cast(sp_desktop_namedview(desktop)->doc_units); // Set the doc default unit active in the units list gint length = g_slist_length(_unit_mis); -- cgit v1.2.3 From 7af2b98550f3389d08773addca07cd943ec6e2bb Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Wed, 17 Jul 2013 01:00:49 -0400 Subject: Temporary fixes/kludges. (bzr r12380.1.16) --- src/ui/widget/selected-style.cpp | 1 + 1 file changed, 1 insertion(+) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index d6e2406c9..102132158 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -477,6 +477,7 @@ SelectedStyle::setDesktop(SPDesktop *desktop) )); //_sw_unit = const_cast(sp_desktop_namedview(desktop)->doc_units); + _sw_unit = const_cast(&sp_unit_get_by_id(SP_UNIT_PX)); // Set the doc default unit active in the units list gint length = g_slist_length(_unit_mis); -- cgit v1.2.3 From 4f6415189dc97ccb8b8dfaa5ad515b56dd72de0f Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Fri, 19 Jul 2013 15:48:48 -0400 Subject: Ported "ui/widget/selected-style.*". (bzr r12380.1.39) --- src/ui/widget/selected-style.cpp | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 102132158..edf53d25c 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -50,6 +50,7 @@ #include "pixmaps/cursor-adj-a.xpm" #include "sp-cursor.h" #include "gradient-chemistry.h" +#include "util/units.h" static gdouble const _sw_presets[] = { 32 , 16 , 10 , 8 , 6 , 4 , 3 , 2 , 1.5 , 1 , 0.75 , 0.5 , 0.25 , 0.1 }; static gchar const *const _sw_presets_str[] = {"32", "16", "10", "8", "6", "4", "3", "2", "1.5", "1", "0.75", "0.5", "0.25", "0.1"}; @@ -306,15 +307,18 @@ SelectedStyle::SelectedStyle(bool /*layout*/) { int row = 0; - // 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 = static_cast(l->data); + Inkscape::Util::UnitTable unit_table; + Inkscape::Util::UnitTable::UnitMap m = unit_table.units(Inkscape::Util::UNIT_TYPE_LINEAR); + Inkscape::Util::UnitTable::UnitMap::iterator iter = m.begin(); + while(iter != m.end()) { Gtk::RadioMenuItem *mi = Gtk::manage(new Gtk::RadioMenuItem(_sw_group)); - mi->add(*(new Gtk::Label(u->abbr, 0.0, 0.5))); + mi->add(*(new Gtk::Label((*iter).first, 0.0, 0.5))); _unit_mis = g_slist_append(_unit_mis, mi); - mi->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &SelectedStyle::on_popup_units), u->unit_id)); + Inkscape::Util::Unit const *u = new Inkscape::Util::Unit(unit_table.getUnit(iter->first)); + mi->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &SelectedStyle::on_popup_units), *u)); _popup_sw.attach(*mi, 0,1, row, row+1); row++; + ++iter; } _popup_sw.attach(*(new Gtk::SeparatorMenuItem()), 0,1, row, row+1); @@ -476,14 +480,13 @@ SelectedStyle::setDesktop(SPDesktop *desktop) this ) )); - //_sw_unit = const_cast(sp_desktop_namedview(desktop)->doc_units); - _sw_unit = const_cast(&sp_unit_get_by_id(SP_UNIT_PX)); + _sw_unit = const_cast(sp_desktop_namedview(desktop)->doc_units); // Set the doc default unit active in the units list gint length = g_slist_length(_unit_mis); for (int i = 0; i < length; i++) { Gtk::RadioMenuItem *mi = (Gtk::RadioMenuItem *) g_slist_nth_data(_unit_mis, i); - if (mi && mi->get_label() == Glib::ustring(_sw_unit->abbr)) { + if (mi && mi->get_label() == _sw_unit->abbr) { mi->set_active(); break; } @@ -927,8 +930,8 @@ SelectedStyle::on_opacity_click(GdkEventButton *event) return false; } -void SelectedStyle::on_popup_units(SPUnitId id) { - _sw_unit = (SPUnit *) &(sp_unit_get_by_id(id)); +void SelectedStyle::on_popup_units(Inkscape::Util::Unit &unit) { + _sw_unit = new Inkscape::Util::Unit(unit); update(); } @@ -936,7 +939,7 @@ void SelectedStyle::on_popup_preset(int i) { SPCSSAttr *css = sp_repr_css_attr_new (); gdouble w; if (_sw_unit) { - w = sp_units_get_pixels (_sw_presets[i], *_sw_unit); + w = Inkscape::Util::Quantity::convert(_sw_presets[i], *_sw_unit, "px"); } else { w = _sw_presets[i]; } @@ -1115,7 +1118,7 @@ SelectedStyle::update() { double w; if (_sw_unit) { - w = sp_pixels_get_units(query->stroke_width.computed, *_sw_unit); + w = Inkscape::Util::Quantity::convert(query->stroke_width.computed, "px", *_sw_unit); } else { w = query->stroke_width.computed; } @@ -1129,7 +1132,7 @@ SelectedStyle::update() { gchar *str = g_strdup_printf(_("Stroke width: %.5g%s%s"), w, - _sw_unit? sp_unit_get_abbreviation(_sw_unit) : "px", + _sw_unit? _sw_unit->abbr.c_str() : "px", (result_sw == QUERY_STYLE_MULTIPLE_AVERAGED)? _(" (averaged)") : ""); _stroke_width_place.set_tooltip_text(str); -- cgit v1.2.3 From 989abbac025a8b3349748d19a613a08586c5fdcd Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Wed, 31 Jul 2013 21:11:20 +0200 Subject: Fixed SPObject ctor and dtor; removed singleton.h; some smaller changes. (bzr r11608.1.110) --- src/ui/widget/selected-style.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 8cb0c5588..08589a0b6 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -1351,25 +1351,25 @@ RotateableSwatch::do_motion(double by, guint modifier) { 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 alpha: was %.3g, now %.3g (diff %.3g); with Ctrl to adjust lightness, with Shift to adjust saturation, without modifiers to adjust hue"), ch - diff, ch, diff); + parent->getDesktop()->event_context->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting alpha: was %.3g, now %.3g (diff %.3g); with Ctrl to adjust lightness, with Shift 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 = hsla[1]; - parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting saturation: was %.3g, now %.3g (diff %.3g); with Ctrl to adjust lightness, with Alt to adjust alpha, without modifiers to adjust hue"), ch - diff, ch, diff); + parent->getDesktop()->event_context->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting saturation: was %.3g, now %.3g (diff %.3g); with Ctrl to adjust lightness, with Alt 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 = hsla[2]; - parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting lightness: was %.3g, now %.3g (diff %.3g); with Shift to adjust saturation, with Alt to adjust alpha, without modifiers to adjust hue"), ch - diff, ch, diff); + parent->getDesktop()->event_context->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting lightness: was %.3g, now %.3g (diff %.3g); with Shift to adjust saturation, with Alt 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 = hsla[0]; - parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting hue: was %.3g, now %.3g (diff %.3g); with Shift to adjust saturation, with Alt to adjust alpha, with Ctrl to adjust lightness"), ch - diff, ch, diff); + parent->getDesktop()->event_context->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting hue: was %.3g, now %.3g (diff %.3g); with Shift to adjust saturation, with Alt to adjust alpha, with Ctrl to adjust lightness"), ch - diff, ch, diff); } } @@ -1424,7 +1424,7 @@ RotateableSwatch::do_release(double by, guint modifier) { undokey = "ssrot1"; } - parent->getDesktop()->event_context->_message_context->clear(); + parent->getDesktop()->event_context->message_context->clear(); startcolor_set = false; } @@ -1490,7 +1490,7 @@ RotateableStrokeWidth::do_motion(double by, guint modifier) { double diff = value_adjust(startvalue, by, modifier, false); DocumentUndo::maybeDone(sp_desktop_document(parent->getDesktop()), undokey, SP_VERB_DIALOG_FILL_STROKE, (_("Adjust stroke width"))); - parent->getDesktop()->event_context->_message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting stroke width: was %.3g, now %.3g (diff %.3g)"), startvalue, startvalue + diff, diff); + parent->getDesktop()->event_context->message_context->setF(Inkscape::IMMEDIATE_MESSAGE, _("Adjusting stroke width: was %.3g, now %.3g (diff %.3g)"), startvalue, startvalue + diff, diff); } } @@ -1511,7 +1511,7 @@ RotateableStrokeWidth::do_release(double by, guint modifier) { } else { undokey = "swrot1"; } - parent->getDesktop()->event_context->_message_context->clear(); + parent->getDesktop()->event_context->message_context->clear(); } void -- cgit v1.2.3 From 6ae6c0bea96eef09907091279e0678aa5f83102d Mon Sep 17 00:00:00 2001 From: Matthew Petroff Date: Sun, 4 Aug 2013 18:01:18 -0400 Subject: Switched to global UnitTable. (bzr r12380.1.62) --- src/ui/widget/selected-style.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index edf53d25c..388a0bcea 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -52,6 +52,8 @@ #include "gradient-chemistry.h" #include "util/units.h" +using Inkscape::Util::unit_table; + static gdouble const _sw_presets[] = { 32 , 16 , 10 , 8 , 6 , 4 , 3 , 2 , 1.5 , 1 , 0.75 , 0.5 , 0.25 , 0.1 }; static gchar const *const _sw_presets_str[] = {"32", "16", "10", "8", "6", "4", "3", "2", "1.5", "1", "0.75", "0.5", "0.25", "0.1"}; @@ -307,7 +309,6 @@ SelectedStyle::SelectedStyle(bool /*layout*/) { int row = 0; - Inkscape::Util::UnitTable unit_table; Inkscape::Util::UnitTable::UnitMap m = unit_table.units(Inkscape::Util::UNIT_TYPE_LINEAR); Inkscape::Util::UnitTable::UnitMap::iterator iter = m.begin(); while(iter != m.end()) { -- cgit v1.2.3 From 706294ff1fa82c86089221d8ee4a0d5bd032925a Mon Sep 17 00:00:00 2001 From: Krzysztof Kosi??ski Date: Sat, 5 Oct 2013 05:54:43 +0200 Subject: Rewrite the internals of the unit code for somewhat better performance (bzr r12661) --- src/ui/widget/selected-style.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 894700046..97581aa83 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -313,7 +313,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/) Inkscape::Util::UnitTable::UnitMap::iterator iter = m.begin(); while(iter != m.end()) { Gtk::RadioMenuItem *mi = Gtk::manage(new Gtk::RadioMenuItem(_sw_group)); - mi->add(*(new Gtk::Label((*iter).first, 0.0, 0.5))); + mi->add(*(new Gtk::Label(iter->first, 0.0, 0.5))); _unit_mis = g_slist_append(_unit_mis, mi); Inkscape::Util::Unit const *u = new Inkscape::Util::Unit(unit_table.getUnit(iter->first)); mi->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &SelectedStyle::on_popup_units), *u)); -- cgit v1.2.3 From a970dc423d59ea844bdb1af48d5d9419a5e2a287 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Sun, 13 Oct 2013 00:24:05 +0200 Subject: Units: stop newing Unit objects. pass around pointers to "undeletable" Unit objects in the UnitTable. I think we should move to using indexed units, and pass around the index of the unit in the unittable, or smth like that... ? (bzr r12679) --- src/ui/widget/selected-style.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 97581aa83..3a6b0c7df 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -315,8 +315,8 @@ SelectedStyle::SelectedStyle(bool /*layout*/) Gtk::RadioMenuItem *mi = Gtk::manage(new Gtk::RadioMenuItem(_sw_group)); mi->add(*(new Gtk::Label(iter->first, 0.0, 0.5))); _unit_mis = g_slist_append(_unit_mis, mi); - Inkscape::Util::Unit const *u = new Inkscape::Util::Unit(unit_table.getUnit(iter->first)); - mi->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &SelectedStyle::on_popup_units), *u)); + Inkscape::Util::Unit const *u = unit_table.getUnit(iter->first); + mi->signal_activate().connect(sigc::bind(sigc::mem_fun(*this, &SelectedStyle::on_popup_units), u)); _popup_sw.attach(*mi, 0,1, row, row+1); row++; ++iter; @@ -481,7 +481,7 @@ SelectedStyle::setDesktop(SPDesktop *desktop) this ) )); - _sw_unit = const_cast(sp_desktop_namedview(desktop)->doc_units); + _sw_unit = sp_desktop_namedview(desktop)->doc_units; // Set the doc default unit active in the units list gint length = g_slist_length(_unit_mis); @@ -931,8 +931,8 @@ SelectedStyle::on_opacity_click(GdkEventButton *event) return false; } -void SelectedStyle::on_popup_units(Inkscape::Util::Unit &unit) { - _sw_unit = new Inkscape::Util::Unit(unit); +void SelectedStyle::on_popup_units(Inkscape::Util::Unit const *unit) { + _sw_unit = unit; update(); } @@ -940,7 +940,7 @@ void SelectedStyle::on_popup_preset(int i) { SPCSSAttr *css = sp_repr_css_attr_new (); gdouble w; if (_sw_unit) { - w = Inkscape::Util::Quantity::convert(_sw_presets[i], *_sw_unit, "px"); + w = Inkscape::Util::Quantity::convert(_sw_presets[i], _sw_unit, "px"); } else { w = _sw_presets[i]; } @@ -1119,7 +1119,7 @@ SelectedStyle::update() { double w; if (_sw_unit) { - w = Inkscape::Util::Quantity::convert(query->stroke_width.computed, "px", *_sw_unit); + w = Inkscape::Util::Quantity::convert(query->stroke_width.computed, "px", _sw_unit); } else { w = query->stroke_width.computed; } -- cgit v1.2.3 From abb4c451c9fcbba48752bbe6ad22d7d4baccced7 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Tue, 5 Nov 2013 22:04:36 +0100 Subject: remove unused private members (bzr r12779) --- src/ui/widget/selected-style.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 3a6b0c7df..000fdee4b 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -1439,9 +1439,7 @@ RotateableStrokeWidth::RotateableStrokeWidth(SelectedStyle *parent) : parent(parent), startvalue(0), startvalue_set(false), - undokey("swrot1"), - cr(0), - cr_set(false) + undokey("swrot1") { } -- cgit v1.2.3 From c04e30df241a3ee039077425bab9b9c37abe2854 Mon Sep 17 00:00:00 2001 From: Markus Engel Date: Sat, 9 Nov 2013 23:36:13 +0100 Subject: Moved and renamed some tool-related files. (bzr r12785) --- src/ui/widget/selected-style.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 000fdee4b..aa617353c 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -39,7 +39,7 @@ #include "sp-gradient.h" #include "svg/svg-color.h" #include "svg/css-ostringstream.h" -#include "event-context.h" +#include "ui/tools/tool-base.h" #include "message-context.h" #include "verbs.h" #include "color.h" -- cgit v1.2.3 From bd7ce1e72dae8f5c93e7845dd4b81524ef3db9a5 Mon Sep 17 00:00:00 2001 From: "Johan B. C. Engelen" Date: Wed, 8 Jan 2014 21:57:27 +0100 Subject: small code clarification, doesn't change anything, but makes intent more clear (bzr r12895) --- src/ui/widget/selected-style.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index aa617353c..d29554c41 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -107,7 +107,7 @@ typedef enum { // pointers/types used need to be read-only. So until we correct the using // code, those warnings are actually desired. They say "Hey! Fix this". We // definitely don't want to hide/ignore them. --JonCruz -static GtkTargetEntry ui_drop_target_entries [] = { +static const GtkTargetEntry ui_drop_target_entries [] = { {"application/x-color", 0, APP_X_COLOR} }; -- cgit v1.2.3 From dd29914fcfe97975ce7145adc24cc556d67b83d2 Mon Sep 17 00:00:00 2001 From: Nicolas Dufour Date: Fri, 28 Feb 2014 14:56:31 +0100 Subject: Fix for Bug #1281859 (color gesture problems, alpha values below 0 and above 1). Fixed bugs: - https://launchpad.net/bugs/1281859 (bzr r13074) --- src/ui/widget/selected-style.cpp | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/ui/widget/selected-style.cpp') diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index d29554c41..042a6614e 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -1267,6 +1267,11 @@ RotateableSwatch::color_adjust(float *hsla, double by, guint32 cc, guint modifie } else if (modifier == 3) { // alpha double old = hsla[3]; hsla[3] += by/2; + if (hsla[3] < 0) { + hsla[3] = 0; + } else if (hsla[3] > 1) { + hsla[3] = 1; + } diff = hsla[3] - old; } else { // hue double old = hsla[0]; -- cgit v1.2.3