diff options
| author | Jabier Arraiza Cenoz <jabier.arraiza@marker.es> | 2015-03-10 18:30:08 +0000 |
|---|---|---|
| committer | Jabiertxof <jtx@jtx.marker.es> | 2015-03-10 18:30:08 +0000 |
| commit | 7ea4a00c4dde3a60943ed0438afb9f0539d26db6 (patch) | |
| tree | 81dfb8a0889dbe858c0e5f34113aa0d154c09070 /src | |
| parent | Fix new added simplify parameter (diff) | |
| parent | Remove redundant buttons on simplify LPE (diff) | |
| download | inkscape-7ea4a00c4dde3a60943ed0438afb9f0539d26db6.tar.gz inkscape-7ea4a00c4dde3a60943ed0438afb9f0539d26db6.zip | |
update to trunk
(bzr r13973.1.8)
Diffstat (limited to 'src')
| -rw-r--r-- | src/extension/internal/filter/color.h | 77 | ||||
| -rw-r--r-- | src/extension/internal/filter/filter-all.cpp | 1 | ||||
| -rw-r--r-- | src/live_effects/lpe-simplify.cpp | 37 | ||||
| -rw-r--r-- | src/live_effects/lpe-simplify.h | 2 | ||||
| -rw-r--r-- | src/ui/dialog/filedialogimpl-win32.cpp | 8 |
5 files changed, 91 insertions, 34 deletions
diff --git a/src/extension/internal/filter/color.h b/src/extension/internal/filter/color.h index 19af6e969..c3c26bf8b 100644 --- a/src/extension/internal/filter/color.h +++ b/src/extension/internal/filter/color.h @@ -3,13 +3,14 @@ /* Change the 'COLOR' above to be your file name */ /* - * Copyright (C) 2013 Authors: + * Copyright (C) 2013-2015 Authors: * Ivan Louette (filters) * Nicolas Dufour (UI) <nicoduf@yahoo.fr> * * Color filters * Brilliance * Channel painting + * Color blindness * Color shift * Colorize * Component transfer @@ -231,6 +232,80 @@ ChannelPaint::get_filter_text (Inkscape::Extension::Extension * ext) }; /* Channel Painting filter */ /** + \brief Custom predefined Color Blindness filter. + + Color Blindness filter. + Based on https://openclipart.org/detail/22299/Color%20Blindness%20filters + + Filter's parameters: + * Blindness type (enum, default Achromatomaly) -> colormatrix +*/ +class ColorBlindness : public Inkscape::Extension::Internal::Filter::Filter { +protected: + virtual gchar const * get_filter_text (Inkscape::Extension::Extension * ext); + +public: + ColorBlindness ( ) : Filter() { }; + virtual ~ColorBlindness ( ) { if (_filter != NULL) g_free((void *)_filter); return; } + + static void init (void) { + Inkscape::Extension::build_from_mem( + "<inkscape-extension xmlns=\"" INKSCAPE_EXTENSION_URI "\">\n" + "<name>" N_("Color Blindness") "</name>\n" + "<id>org.inkscape.effect.filter.ColorBlindness</id>\n" + "<param name=\"tab\" type=\"notebook\">\n" + "<page name=\"optionstab\" _gui-text=\"Options\">\n" + "<param name=\"type\" gui-text=\"" N_("Blindness type:") "\" type=\"enum\">\n" + "<_item value=\"0.618 0.32 0.062 0 0 0.163 0.775 0.062 0 0 0.163 0.32 0.516 0 0 0 0 0 1 0 \">" N_("Rod monochromacy (atypical achromatopsia)") "</_item>\n" + "<_item value=\"0.299 0.587 0.114 0 0 0.299 0.587 0.114 0 0 0.299 0.587 0.114 0 0 0 0 0 1 0 \">" N_("Cone monochromacy (typical achromatopsia)") "</_item>\n" + "<_item value=\"0.8 0.2 0 0 0 0.2583 0.74167 0 0 0 0 0.14167 0.85833 0 0 0 0 0 1 0 \">" N_("Geen weak (deuteranomaly)") "</_item>\n" + "<_item value=\"0.625 0.375 0 0 0 0.7 0.3 0 0 0 0 0.3 0.7 0 0 0 0 0 1 0 \">" N_("Green blind (deuteranopia)") "</_item>\n" + "<_item value=\"0.8166 0.1833 0 0 0 0.333 0.666 0 0 0 0 0.125 0.875 0 0 0 0 0 1 0 \">" N_("Red weak (protanomaly)") "</_item>\n" + "<_item value=\"0.566 0.43333 0 0 0 0.55833 0.4416 0 0 0 0 0.24167 0.75833 0 0 0 0 0 1 0 \">" N_("Red blind (protanopia)") "</_item>\n" + "<_item value=\"0.966 0.033 0 0 0 0 0.733 0.266 0 0 0 0.1833 0.816 0 0 0 0 0 1 0 \">" N_("Blue weak (tritanomaly)") "</_item>\n" + "<_item value=\"0.95 0.05 0 0 0 0.2583 0.4333 0.5667 0 0 0 0.475 0.525 0 0 0 0 0 1 0 \">" N_("Blue blind (tritanopia)") "</_item>\n" + "</param>\n" + "</page>\n" + "<page name=\"helptab\" _gui-text=\"Help\">\n" + "<param name=\"help\" xml:space=\"preserve\" type=\"description\">\n" +"Filters based on https://openclipart.org/detail/22299/Color%20Blindness%20filters\n" +"\n" +"These filters don't correctly reflect actual color blindness for two main reasons:\n" +" * Everyone is different, and is not affected exactly the same way.\n" +" * The filters are in the RGB color space, and ignore confusion lines.\n" + "</param>\n" + "</page>\n" + "</param>\n" + "<effect>\n" + "<object-type>all</object-type>\n" + "<effects-menu>\n" + "<submenu name=\"" N_("Filters") "\">\n" + "<submenu name=\"" N_("Color") "\"/>\n" + "</submenu>\n" + "</effects-menu>\n" + "<menu-tip>" N_("Simulate color blindness") "</menu-tip>\n" + "</effect>\n" + "</inkscape-extension>\n", new ColorBlindness()); + }; +}; + +gchar const * +ColorBlindness::get_filter_text (Inkscape::Extension::Extension * ext) +{ + if (_filter != NULL) g_free((void *)_filter); + + std::ostringstream type; + type << ext->get_param_enum("type"); + + _filter = g_strdup_printf( + "<filter xmlns:inkscape=\"http://www.inkscape.org/namespaces/inkscape\" style=\"color-interpolation-filters:sRGB;\" height=\"1\" width=\"1\" y=\"0\" x=\"0\" inkscape:label=\"Color Blindness\">\n" + "<feColorMatrix values=\"%s\" type=\"matrix\" result=\"colormatrix1\" />\n" + "</filter>\n", type.str().c_str()); + + return _filter; +}; /* Color Blindness filter */ + +/** \brief Custom predefined Color shift filter. Rotate and desaturate hue diff --git a/src/extension/internal/filter/filter-all.cpp b/src/extension/internal/filter/filter-all.cpp index 0273d1669..35504d37f 100644 --- a/src/extension/internal/filter/filter-all.cpp +++ b/src/extension/internal/filter/filter-all.cpp @@ -54,6 +54,7 @@ Filter::filters_all (void ) // Color Brilliance::init(); ChannelPaint::init(); + ColorBlindness::init(); ColorShift::init(); Colorize::init(); ComponentTransfer::init(); diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp index 3a0659244..1fe18dd5e 100644 --- a/src/live_effects/lpe-simplify.cpp +++ b/src/live_effects/lpe-simplify.cpp @@ -31,10 +31,6 @@ LPESimplify::LPESimplify(LivePathEffectObject *lpeobject) threshold(_("Roughly threshold:"), _("Roughly threshold:"), "threshold", &wr, this, 0.003), smooth_angles(_("Smooth angles:"), _("Max degree difference on handles to preform a smooth"), "smooth_angles", &wr, this, 20.), helper_size(_("Helper size:"), _("Helper size"), "helper_size", &wr, this, 5), - nodes(_("Helper nodes"), _("Show helper nodes"), "nodes", &wr, this, false, - "", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), - handles(_("Helper handles"), _("Show helper handles"), "handles", &wr, this, false, - "", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), simplifyindividualpaths(_("Paths separately"), _("Simplifying paths (separately)"), "simplifyindividualpaths", &wr, this, false, "", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")), simplifyJustCoalesce(_("Just coalesce"), _("Simplify just coalesce"), "simplifyJustCoalesce", &wr, this, false, @@ -44,8 +40,6 @@ LPESimplify::LPESimplify(LivePathEffectObject *lpeobject) registerParameter(&threshold); registerParameter(&smooth_angles); registerParameter(&helper_size); - registerParameter(&nodes); - registerParameter(&handles); registerParameter(&simplifyindividualpaths); registerParameter(&simplifyJustCoalesce); @@ -78,11 +72,7 @@ LPESimplify::doBeforeEffect (SPLPEItem const* lpeitem) } bbox = SP_ITEM(lpeitem)->visualBounds(); SPLPEItem * item = const_cast<SPLPEItem*>(lpeitem); - if(nodes || handles){ - radiusHelperNodes = helper_size; - } else { - radiusHelperNodes = 0; - } + radiusHelperNodes = helper_size; item->apply_to_clippath(item); item->apply_to_mask(item); } @@ -97,7 +87,6 @@ LPESimplify::newWidget() vbox->set_spacing(2); std::vector<Parameter *>::iterator it = param_vector.begin(); Gtk::HBox * buttons = Gtk::manage(new Gtk::HBox(true,0)); - Gtk::HBox * buttonsBottom = Gtk::manage(new Gtk::HBox(true,0)); while (it != param_vector.end()) { if ((*it)->widget_is_visible) { Parameter * param = *it; @@ -107,19 +96,6 @@ LPESimplify::newWidget() { Glib::ustring * tip = param->param_getTooltip(); if (widg) { - buttonsBottom->pack_start(*widg, true, true, 2); - if (tip) { - widg->set_tooltip_text(*tip); - } else { - widg->set_tooltip_text(""); - widg->set_has_tooltip(false); - } - } - } else if (param->param_key == "nodes" || - param->param_key == "handles") - { - Glib::ustring * tip = param->param_getTooltip(); - if (widg) { buttons->pack_start(*widg, true, true, 2); if (tip) { widg->set_tooltip_text(*tip); @@ -128,7 +104,7 @@ LPESimplify::newWidget() widg->set_has_tooltip(false); } } - }else{ + } else{ Glib::ustring * tip = param->param_getTooltip(); if (widg) { Gtk::HBox * scalarParameter = dynamic_cast<Gtk::HBox *>(widg); @@ -149,7 +125,6 @@ LPESimplify::newWidget() ++it; } vbox->pack_start(*buttons,true, true, 2); - vbox->pack_start(*buttonsBottom,true, true, 2); return dynamic_cast<Gtk::Widget *>(vbox); } @@ -212,7 +187,7 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) curve_endit = path_it->end_open(); } } - if(nodes){ + if(helper_size > 0){ drawNode(curve_it1->initialPoint()); } nCurve->moveto(curve_it1->initialPoint()); @@ -255,7 +230,7 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) if (cubic) { pointAt1 = (*cubic)[1]; pointAt2 = (*cubic)[2]; - if(handles) { + if(helper_size > 0) { if(!are_near((*cubic)[0],(*cubic)[1])){ drawHandle((*cubic)[1]); drawHandleLine((*cubic)[0],(*cubic)[1]); @@ -266,7 +241,7 @@ LPESimplify::generateHelperPathAndSmooth(Geom::PathVector &result) } } } - if(nodes) { + if(helper_size > 0) { drawNode(curve_it1->finalPoint()); } ++curve_it1; @@ -314,7 +289,7 @@ LPESimplify::drawHandleLine(Geom::Point p,Geom::Point p2) Geom::Path path; path.start( p ); double diameter = radiusHelperNodes; - if(handles && Geom::distance(p,p2) > (diameter * 0.35)){ + if(helper_size > 0 && Geom::distance(p,p2) > (diameter * 0.35)){ Geom::Ray ray2(p, p2); p2 = p2 - Geom::Point::polar(ray2.angle(),(diameter * 0.35)); } diff --git a/src/live_effects/lpe-simplify.h b/src/live_effects/lpe-simplify.h index 0b48867d8..c18c3ecdf 100644 --- a/src/live_effects/lpe-simplify.h +++ b/src/live_effects/lpe-simplify.h @@ -42,8 +42,6 @@ private: ScalarParam threshold; ScalarParam smooth_angles; ScalarParam helper_size; - ToggleButtonParam nodes; - ToggleButtonParam handles; ToggleButtonParam simplifyindividualpaths; ToggleButtonParam simplifyJustCoalesce; diff --git a/src/ui/dialog/filedialogimpl-win32.cpp b/src/ui/dialog/filedialogimpl-win32.cpp index 34339dab2..cafc3be4f 100644 --- a/src/ui/dialog/filedialogimpl-win32.cpp +++ b/src/ui/dialog/filedialogimpl-win32.cpp @@ -44,6 +44,7 @@ #include "filedialog.h" #include "sp-root.h" +#include "preferences.h" #include <zlib.h> #include <cairomm/win32_surface.h> @@ -272,6 +273,9 @@ void FileOpenDialogImplWin32::createFilterMenu() } if (dialogType != EXE_TYPES) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + _show_preview = prefs->getBool("/dialogs/open/enable_preview", true); + // Compose the filter string Inkscape::Extension::DB::InputList extension_list; Inkscape::Extension::db.get_input_list(extension_list); @@ -842,6 +846,10 @@ LRESULT CALLBACK FileOpenDialogImplWin32::preview_wnd_proc(HWND hwnd, UINT uMsg, void FileOpenDialogImplWin32::enable_preview(bool enable) { + if (_show_preview != enable) { + Inkscape::Preferences *prefs = Inkscape::Preferences::get(); + prefs->setBool("/dialogs/open/enable_preview", enable); + } _show_preview = enable; // Relayout the dialog |
