From 1b7827f2519b38d72174d744f9795392d538d64f Mon Sep 17 00:00:00 2001 From: JazzyNico Date: Wed, 17 Nov 2010 20:57:36 +0100 Subject: [PATCH] Extensions. Removing tooltips from color>randomize (see Bug #676419). Filters. Experimental filters cleanup. --- share/extensions/color_randomize.inx | 6 +- src/extension/internal/filter/color.h | 146 ++++--------------- src/extension/internal/filter/filter-all.cpp | 1 - 3 files changed, 31 insertions(+), 122 deletions(-) diff --git a/share/extensions/color_randomize.inx b/share/extensions/color_randomize.inx index 8584722fa..82691f0f4 100644 --- a/share/extensions/color_randomize.inx +++ b/share/extensions/color_randomize.inx @@ -7,9 +7,9 @@ simplestyle.py - true - true - true + true + true + true <_param name="instructions" type="description" xml:space="preserve">Converts to HSL, randomizes hue and/or saturation and/or lightness and converts it back to RGB. diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 17815f006..1a1644276 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -35,108 +35,13 @@ public: "\n" "" N_("Duochrome, custom -EXP-") "\n" "org.inkscape.effect.filter.Duochrome\n" -// Using color widgets in tabs makes Inkscape crash... -// "\n" -// "\n" - "false\n" - "false\n" - "<_param name=\"header1\" type=\"groupheader\">Color 1\n" - "1364325887\n" -// "\n" -// "\n" - "<_param name=\"header2\" type=\"groupheader\">Color 2\n" - "-65281\n" -// "\n" -// "\n" - "\n" - "all\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "" N_("Change colors to a two colors palette") "\n" - "\n" - "\n", new Duochrome()); - }; - -}; - -gchar const * -Duochrome::get_filter_text (Inkscape::Extension::Extension * ext) -{ - if (_filter != NULL) g_free((void *)_filter); - - std::ostringstream a1; - std::ostringstream r1; - std::ostringstream g1; - std::ostringstream b1; - std::ostringstream a2; - std::ostringstream r2; - std::ostringstream g2; - std::ostringstream b2; - std::ostringstream fluo; - std::ostringstream swapc; - - guint32 color1 = ext->get_param_color("color1"); - guint32 color2 = ext->get_param_color("color2"); - bool fluorescence = ext->get_param_bool("fluo"); - bool swapcolors = ext->get_param_bool("swapcolors"); - - a1 << (color1 & 0xff) / 255.0F; - r1 << ((color1 >> 24) & 0xff); - g1 << ((color1 >> 16) & 0xff); - b1 << ((color1 >> 8) & 0xff); - a2 << (color2 & 0xff) / 255.0F; - r2 << ((color2 >> 24) & 0xff); - g2 << ((color2 >> 16) & 0xff); - b2 << ((color2 >> 8) & 0xff); - if (fluorescence) - fluo << ""; - else - fluo << " in=\"blend\""; - if (swapcolors) - swapc << "in"; - else - swapc << "out"; - - _filter = g_strdup_printf( - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n" - "\n", a1.str().c_str(), r1.str().c_str(), g1.str().c_str(), b1.str().c_str(), swapc.str().c_str(), a2.str().c_str(), r2.str().c_str(), g2.str().c_str(), b2.str().c_str(), fluo.str().c_str()); - - return _filter; -}; - - -class Duochrome2 : public Inkscape::Extension::Internal::Filter::Filter { -protected: - virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); - -public: - Duochrome2 ( ) : Filter() { }; - virtual ~Duochrome2 ( ) { if (_filter != NULL) g_free((void *)_filter); return; } - - static void init (void) { - Inkscape::Extension::build_from_mem( - "\n" - "" N_("Duochrome2, custom -EXP-") "\n" - "org.inkscape.effect.filter.Duochrome2\n" "0\n" - "1\n" - "1\n" - "false\n" + "\n" + "<_item value=\"none\">No swap\n" + "<_item value=\"full\">Color and alpha\n" + "<_item value=\"color\">Color only\n" + "<_item value=\"alpha\">Alpha only\n" + "\n" "<_param name=\"header1\" type=\"groupheader\">Color 1\n" "1364325887\n" "<_param name=\"header2\" type=\"groupheader\">Color 2\n" @@ -150,13 +55,13 @@ public: "\n" "" N_("Convert luminance values to a duochrome palette") "\n" "\n" - "\n", new Duochrome2()); + "\n", new Duochrome()); }; }; gchar const * -Duochrome2::get_filter_text (Inkscape::Extension::Extension * ext) +Duochrome::get_filter_text (Inkscape::Extension::Extension * ext) { if (_filter != NULL) g_free((void *)_filter); @@ -169,51 +74,56 @@ Duochrome2::get_filter_text (Inkscape::Extension::Extension * ext) std::ostringstream g2; std::ostringstream b2; std::ostringstream fluo; - std::ostringstream pres1; - std::ostringstream pres2; std::ostringstream swap1; std::ostringstream swap2; - guint32 color1 = ext->get_param_color("color1"); guint32 color2 = ext->get_param_color("color2"); float fluorescence = ext->get_param_float("fluo"); - float presence1 = ext->get_param_float("pres1"); - float presence2 = ext->get_param_float("pres2"); - bool swapcolors = ext->get_param_bool("swapcolors"); + const gchar *swaptype = ext->get_param_enum("swap"); - a1 << (color1 & 0xff) / 255.0F; r1 << ((color1 >> 24) & 0xff); g1 << ((color1 >> 16) & 0xff); b1 << ((color1 >> 8) & 0xff); - a2 << (color2 & 0xff) / 255.0F; r2 << ((color2 >> 24) & 0xff); g2 << ((color2 >> 16) & 0xff); b2 << ((color2 >> 8) & 0xff); fluo << fluorescence; - pres1 << presence1; - pres2 << presence2; - if (swapcolors) { + if((g_ascii_strcasecmp("full", swaptype) == 0)) { swap1 << "in"; swap2 << "out"; - } else { + a1 << (color1 & 0xff) / 255.0F; + a2 << (color2 & 0xff) / 255.0F; + } else if((g_ascii_strcasecmp("color", swaptype) == 0)) { + swap1 << "in"; + swap2 << "out"; + a1 << (color2 & 0xff) / 255.0F; + a2 << (color1 & 0xff) / 255.0F; + } else if((g_ascii_strcasecmp("alpha", swaptype) == 0)) { + swap1 << "out"; swap2 << "in"; + a1 << (color2 & 0xff) / 255.0F; + a2 << (color1 & 0xff) / 255.0F; + } else { swap1 << "out"; + swap2 << "in"; + a1 << (color1 & 0xff) / 255.0F; + a2 << (color2 & 0xff) / 255.0F; } _filter = g_strdup_printf( - "\n" + "\n" "\n" "\n" "\n" "\n" "\n" - "\n" + "\n" "\n" "\n" "\n" "\n" - "\n", a1.str().c_str(), r1.str().c_str(), g1.str().c_str(), b1.str().c_str(), swap1.str().c_str(), a2.str().c_str(), r2.str().c_str(), g2.str().c_str(), b2.str().c_str(), swap2.str().c_str(), pres2.str().c_str(), pres1.str().c_str(), fluo.str().c_str()); + "\n", a1.str().c_str(), r1.str().c_str(), g1.str().c_str(), b1.str().c_str(), swap1.str().c_str(), a2.str().c_str(), r2.str().c_str(), g2.str().c_str(), b2.str().c_str(), swap2.str().c_str(), fluo.str().c_str()); return _filter; }; diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 287d0a097..6920e1bac 100644 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -24,7 +24,6 @@ Filter::filters_all (void ) { // Here come the filters which are coded in C++ in order to present a parameters dialog Duochrome::init(); - Duochrome2::init(); DropShadow::init(); DropGlow::init(); ColorizableDropShadow::init(); -- 2.30.2