diff options
| author | Michael Soegtrop <MSoegtrop@yahoo.de> | 2017-06-05 13:01:17 +0000 |
|---|---|---|
| committer | Michael Soegtrop <MSoegtrop@yahoo.de> | 2017-06-05 13:01:17 +0000 |
| commit | e7248b2fa042f42a5c4dd14cd86ab6a5b4524059 (patch) | |
| tree | 9097520c54e355ded9bd0b4d6618af4e8dacdd91 /src/ui/widget/selected-style.cpp | |
| parent | updated to latest trunk (diff) | |
| parent | [Bug #1695016] Xaml export misses some radialGradients. (diff) | |
| download | inkscape-e7248b2fa042f42a5c4dd14cd86ab6a5b4524059.tar.gz inkscape-e7248b2fa042f42a5c4dd14cd86ab6a5b4524059.zip | |
updated to latest trunk
(bzr r14876.2.4)
Diffstat (limited to 'src/ui/widget/selected-style.cpp')
| -rw-r--r-- | src/ui/widget/selected-style.cpp | 125 |
1 files changed, 11 insertions, 114 deletions
diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index f7fd63f51..65d68195c 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -10,11 +10,10 @@ */ #ifdef HAVE_CONFIG_H -# include <config.h> +#include <config.h> #endif #include "selected-style.h" -#include <gtkmm/separatormenuitem.h> #include "widgets/spw-utilities.h" #include "ui/widget/color-preview.h" @@ -26,24 +25,19 @@ #include "sp-namedview.h" #include "sp-linear-gradient.h" #include "sp-radial-gradient.h" -#include "sp-mesh.h" +#include "sp-mesh-gradient.h" #include "sp-pattern.h" #include "ui/dialog/dialog-manager.h" #include "ui/dialog/fill-and-stroke.h" #include "ui/dialog/panel-dialog.h" -#include "xml/repr.h" -#include "document.h" #include "document-undo.h" #include "widgets/widget-sizes.h" #include "widgets/spinbutton-events.h" #include "widgets/gradient-image.h" -#include "sp-gradient.h" #include "svg/svg-color.h" #include "svg/css-ostringstream.h" #include "ui/tools/tool-base.h" #include "message-context.h" -#include "verbs.h" -#include "color.h" #include <display/sp-canvas.h> #include "pixmaps/cursor-adj-h.xpm" #include "pixmaps/cursor-adj-s.xpm" @@ -51,7 +45,8 @@ #include "pixmaps/cursor-adj-a.xpm" #include "sp-cursor.h" #include "gradient-chemistry.h" -#include "util/units.h" + +#include <gtkmm/separatormenuitem.h> using Inkscape::Util::unit_table; @@ -123,11 +118,7 @@ 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:")), @@ -139,11 +130,7 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _stroke_flag_place (), _opacity_place (), -#if WITH_GTKMM_3_0 _opacity_adjustment(Gtk::Adjustment::create(100, 0.0, 100, 1.0, 10.0)), -#else - _opacity_adjustment (100, 0.0, 100, 1.0, 10.0), -#endif _opacity_sb (0.02, 0), _stroke (), @@ -166,13 +153,8 @@ 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++) { @@ -379,7 +361,6 @@ 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); @@ -388,26 +369,11 @@ SelectedStyle::SelectedStyle(bool /*layout*/) _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); - - _table.attach(_fill_flag_place, 1,2, 0,1, Gtk::SHRINK, Gtk::SHRINK); - _table.attach(_stroke_flag_place, 1,2, 1,2, Gtk::SHRINK, Gtk::SHRINK); - - _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); @@ -815,56 +781,7 @@ void SelectedStyle::on_stroke_paste() { } void SelectedStyle::on_fillstroke_swap() { - SPCSSAttr *css = sp_repr_css_attr_new (); - - switch (_mode[SS_FILL]) { - case SS_NA: - case SS_MANY: - break; - case SS_NONE: - sp_repr_css_set_property (css, "stroke", "none"); - break; - case SS_UNSET: - sp_repr_css_unset_property (css, "stroke"); - break; - case SS_COLOR: - gchar c[64]; - sp_svg_write_color (c, sizeof(c), _thisselected[SS_FILL]); - sp_repr_css_set_property (css, "stroke", c); - break; - case SS_LGRADIENT: - case SS_RGRADIENT: - case SS_PATTERN: - sp_repr_css_set_property (css, "stroke", _paintserver_id[SS_FILL].c_str()); - break; - } - - switch (_mode[SS_STROKE]) { - case SS_NA: - case SS_MANY: - break; - case SS_NONE: - sp_repr_css_set_property (css, "fill", "none"); - break; - case SS_UNSET: - sp_repr_css_unset_property (css, "fill"); - break; - case SS_COLOR: - gchar c[64]; - sp_svg_write_color (c, sizeof(c), _thisselected[SS_STROKE]); - sp_repr_css_set_property (css, "fill", c); - break; - case SS_LGRADIENT: - case SS_RGRADIENT: - case SS_PATTERN: - sp_repr_css_set_property (css, "fill", _paintserver_id[SS_STROKE].c_str()); - break; - } - - sp_desktop_set_style (_desktop, css); - sp_repr_css_attr_unref (css); - DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE, - _("Swap fill and stroke")); + _desktop->getSelection()->swapFillStroke(); } void SelectedStyle::on_fill_edit() { @@ -1044,9 +961,9 @@ SelectedStyle::update() place->set_tooltip_text(__rgradient[i]); _mode[i] = SS_RGRADIENT; #ifdef WITH_MESH - } else if (SP_IS_MESH(server)) { - SPGradient *vector = SP_GRADIENT(server)->getVector(); - sp_gradient_image_set_gradient(SP_GRADIENT_IMAGE(_gradient_preview_m[i]), vector); + } else if (SP_IS_MESHGRADIENT(server)) { + SPGradient *array = SP_GRADIENT(server)->getArray(); + sp_gradient_image_set_gradient(SP_GRADIENT_IMAGE(_gradient_preview_m[i]), array); place->add(_gradient_box_m[i]); place->set_tooltip_text(__mgradient[i]); _mode[i] = SS_MGRADIENT; @@ -1120,11 +1037,7 @@ SelectedStyle::update() if (_opacity_blocked) break; _opacity_blocked = true; _opacity_sb.set_sensitive(true); -#if WITH_GTKMM_3_0 _opacity_adjustment->set_value(SP_SCALE24_TO_FLOAT(query.opacity.value) * 100); -#else - _opacity_adjustment.set_value(SP_SCALE24_TO_FLOAT(query.opacity.value) * 100); -#endif _opacity_blocked = false; break; } @@ -1224,11 +1137,7 @@ void SelectedStyle::on_opacity_changed () _opacity_blocked = true; SPCSSAttr *css = sp_repr_css_attr_new (); Inkscape::CSSOStringStream os; -#if WITH_GTKMM_3_0 os << CLAMP ((_opacity_adjustment->get_value() / 100), 0.0, 1.0); -#else - os << CLAMP ((_opacity_adjustment.get_value() / 100), 0.0, 1.0); -#endif sp_repr_css_set_property (css, "opacity", os.str().c_str()); // FIXME: workaround for GTK breakage: display interruptibility sometimes results in GTK // sending multiple value-changed events. As if when Inkscape interrupts redraw for main loop @@ -1357,11 +1266,7 @@ RotateableSwatch::do_motion(double by, guint modifier) { 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; } @@ -1425,11 +1330,7 @@ RotateableSwatch::do_release(double by, guint modifier) { GtkWidget *w = GTK_WIDGET(gobj()); gdk_window_set_cursor(gtk_widget_get_window(w), NULL); if (cr) { -#if GTK_CHECK_VERSION(3,0,0) g_object_unref(cr); -#else - gdk_cursor_unref (cr); -#endif cr = NULL; } cr_set = false; @@ -1479,13 +1380,8 @@ RotateableStrokeWidth::value_adjust(double current, double by, guint /*modifier* { double newval; // by is -1..1 - if (by < 0) { - // map negative 0..-1 to current..0 - newval = current * (1 + by); - } else { - // map positive 0..1 to current..4*current - newval = current * (1 + by) * (1 + by); - } + double max_f = 50; // maximum width is (current * max_f), minimum - zero + newval = current * (std::exp(std::log(max_f-1) * (by+1)) - 1) / (max_f-2); SPCSSAttr *css = sp_repr_css_attr_new (); if (final && newval < 1e-6) { @@ -1493,6 +1389,7 @@ RotateableStrokeWidth::value_adjust(double current, double by, guint /*modifier* // if it's not final, leave it a chance to increase again (which is not possible with "none") sp_repr_css_set_property (css, "stroke", "none"); } else { + newval = Inkscape::Util::Quantity::convert(newval, parent->_sw_unit, "px"); Inkscape::CSSOStringStream os; os << newval; sp_repr_css_set_property (css, "stroke-width", os.str().c_str()); |
