From 2c971fd0dd67269a5ecd6c3323071e8b0b08bf1b Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Wed, 1 Nov 2017 11:23:50 +0100 Subject: Add widget to color and some refactoring --- src/live_effects/lpe-powermask.cpp | 160 ++++++++++++++++++------------------- src/live_effects/lpe-powermask.h | 8 +- 2 files changed, 81 insertions(+), 87 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index 05510f258..a0ba42ddf 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -13,6 +13,7 @@ #include "style.h" #include "sp-item-group.h" #include "svg/svg.h" +#include "svg/svg-color.h" #include "ui/tools-switch.h" #include "path-chemistry.h" #include "uri.h" @@ -29,19 +30,17 @@ LPEPowerMask::LPEPowerMask(LivePathEffectObject *lpeobject) : Effect(lpeobject), uri("Store the uri of mask", "", "uri", &wr, this, "false", false), invert(_("Invert mask"), _("Invert mask"), "invert", &wr, this, false), - wrap(_("Wrap mask data"), _("Wrap mask data allowing previous filters"), "wrap", &wr, this, false), + //wrap(_("Wrap mask data"), _("Wrap mask data allowing previous filters"), "wrap", &wr, this, false), hide_mask(_("Hide mask"), _("Hide mask"), "hide_mask", &wr, this, false), background(_("Add background to mask"), _("Add background to mask"), "background", &wr, this, false), - background_style(_("Background Style"), _("CSS to background"), "background_style", &wr, this,"fill:#ffffff;opacity:1;") + background_color(_("Background color and opacity"), _("Set color and opacity of the background"), "background_color", &wr, this, 0xffffffff) { registerParameter(&uri); registerParameter(&invert); - registerParameter(&wrap); + //registerParameter(&wrap); registerParameter(&hide_mask); registerParameter(&background); - registerParameter(&background_style); - //lock.param_setValue(false); - background_style.param_hide_canvas_text(); + registerParameter(&background_color); } LPEPowerMask::~LPEPowerMask() {} @@ -145,56 +144,57 @@ LPEPowerMask::setMask(){ filter->appendChild(primitive2); Inkscape::GC::release(primitive2); } - if(wrap && is_visible){ - Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; - if((elemref = document->getObjectById(g_data_id))){ - elemref->getRepr()->setPosition(-1); - } else { - Inkscape::XML::Node * container = xml_doc->createElement("svg:g"); - container->setAttribute("id", g_data_id.c_str()); - mask->appendChildRepr(container); - std::vector mask_list = mask->childList(true); - container->setPosition(-1); - Inkscape::GC::release(container); - for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { - SPItem * mask_data = SP_ITEM(*iter); - Inkscape::XML::Node *mask_node = mask_data->getRepr(); - if (! strcmp(mask_data->getId(), box_id.c_str()) || - ! strcmp(mask_data->getId(), g_data_id.c_str())) - { - continue; - } - SPCSSAttr *css = sp_repr_css_attr_new(); - if(mask_node->attribute("style")) { - sp_repr_css_attr_add_from_string(css, mask_node->attribute("style")); - } - char const* filter = sp_repr_css_property (css, "filter", NULL); - if(!filter || !strcmp(filter, filter_uri.c_str())) { - sp_repr_css_set_property (css, "filter", NULL); - } - Glib::ustring css_str; - sp_repr_css_write_string(css, css_str); - mask_node->setAttribute("style", css_str.c_str()); - mask->getRepr()->removeChild(mask_node); - container->appendChild(mask_node); - Inkscape::GC::release(mask_node); - } - } - } else { - Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; - if((elemref = document->getObjectById(g_data_id))){ - std::vector item_list = sp_item_group_item_list(SP_GROUP(elemref)); - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { - Inkscape::XML::Node *mask_node = (*iter)->getRepr(); - elemref->getRepr()->removeChild(mask_node); - mask->getRepr()->appendChild(mask_node); - Inkscape::GC::release(mask_node); - } - sp_object_ref(elemref, 0 ); - elemref->deleteObject(true); - sp_object_unref(elemref); +//Not sure if finaly need to resurrect this +// if(wrap && is_visible){ +// Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; +// if((elemref = document->getObjectById(g_data_id))){ +// elemref->getRepr()->setPosition(-1); +// } else { +// Inkscape::XML::Node * container = xml_doc->createElement("svg:g"); +// container->setAttribute("id", g_data_id.c_str()); +// mask->appendChildRepr(container); +// std::vector mask_list = mask->childList(true); +// container->setPosition(-1); +// Inkscape::GC::release(container); +// for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { +// SPItem * mask_data = SP_ITEM(*iter); +// Inkscape::XML::Node *mask_node = mask_data->getRepr(); +// if (! strcmp(mask_data->getId(), box_id.c_str()) || +// ! strcmp(mask_data->getId(), g_data_id.c_str())) +// { +// continue; +// } +// SPCSSAttr *css = sp_repr_css_attr_new(); +// if(mask_node->attribute("style")) { +// sp_repr_css_attr_add_from_string(css, mask_node->attribute("style")); +// } +// char const* filter = sp_repr_css_property (css, "filter", NULL); +// if(!filter || !strcmp(filter, filter_uri.c_str())) { +// sp_repr_css_set_property (css, "filter", NULL); +// } +// Glib::ustring css_str; +// sp_repr_css_write_string(css, css_str); +// mask_node->setAttribute("style", css_str.c_str()); +// mask->getRepr()->removeChild(mask_node); +// container->appendChild(mask_node); +// Inkscape::GC::release(mask_node); +// } +// } +// } else { + Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; + if((elemref = document->getObjectById(g_data_id))){ + std::vector item_list = sp_item_group_item_list(SP_GROUP(elemref)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { + Inkscape::XML::Node *mask_node = (*iter)->getRepr(); + elemref->getRepr()->removeChild(mask_node); + mask->getRepr()->appendChild(mask_node); + Inkscape::GC::release(mask_node); } + sp_object_ref(elemref, 0 ); + elemref->deleteObject(true); + sp_object_unref(elemref); } +// } std::vector mask_list = mask->childList(true); for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { SPItem * mask_data = SP_ITEM(*iter); @@ -229,7 +229,28 @@ LPEPowerMask::setMask(){ box->setAttribute("id", box_id.c_str()); exist = false; } - box->setAttribute("style", background_style.param_getSVGValue()); + Glib::ustring style; + gchar c[32]; + unsigned const rgb24 = background_color.get_value() >> 8; + sprintf(c, "#%06x", rgb24); + style = Glib::ustring("fill:") + Glib::ustring(c); + Inkscape::SVGOStringStream os; + os << SP_RGBA32_A_F(background_color.get_value()); + style = style + Glib::ustring(";fill-opacity:") + Glib::ustring(os.str()); + SPCSSAttr *css = sp_repr_css_attr_new(); + sp_repr_css_attr_add_from_string(css, style.c_str()); + char const* filter = sp_repr_css_property (css, "filter", NULL); + if(!filter || !strcmp(filter, filter_uri.c_str())) { + if (invert && is_visible) { + sp_repr_css_set_property (css, "filter", filter_uri.c_str()); + } else { + sp_repr_css_set_property (css, "filter", NULL); + } + + } + Glib::ustring css_str; + sp_repr_css_write_string(css, css_str); + box->setAttribute("style", css_str.c_str()); gchar * box_str = sp_svg_write_path( mask_box ); box->setAttribute("d" , box_str); g_free(box_str); @@ -255,33 +276,6 @@ LPEPowerMask::doEffect (SPCurve * curve) { } -//void -//LPEPowerMask::transform_multiply(Geom::Affine const& postmul, bool set) -//{ -// SPMask *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); -// if (mask_path && lock) { -// SPMask *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); -// std::vector mask_path_list = mask_path->childList(true); -// Glib::ustring mask_id = (Glib::ustring)mask_path->getId(); -// Glib::ustring box_id = mask_id + (Glib::ustring)"_box"; -// for ( std::vector::const_iterator iter=mask_path_list.begin();iter!=mask_path_list.end();++iter) { -// SPObject * mask_data = *iter; -// if (! strcmp(mask_data->getId(), box_id.c_str())){ -// continue; -// } -// SP_ITEM(mask_data)->transform *= postmul.inverse(); -// } -// } -// //cycle through all parameters. Most parameters will not need transformation, but path and point params -// for (std::vector::iterator it = param_vector.begin(); it != param_vector.end(); ++it) { -// Parameter * param = *it; -// param->param_transform_multiply(postmul, set); -// } -// sp_lpe_item_update_patheffect(SP_LPE_ITEM(sp_lpe_item), false, false); -//} - - - void LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) { @@ -289,7 +283,7 @@ LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) SPMask *mask = lpeitem->mask_ref->getObject(); if (mask) { invert.param_setValue(false); - wrap.param_setValue(false); + //wrap.param_setValue(false); background.param_setValue(false); setMask(); SPObject *elemref = NULL; diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h index a54424e2f..44bf56333 100644 --- a/src/live_effects/lpe-powermask.h +++ b/src/live_effects/lpe-powermask.h @@ -6,10 +6,11 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ - #include "live_effects/effect.h" +#include "live_effects/parameter/bool.h" #include "live_effects/parameter/text.h" #include "live_effects/parameter/hidden.h" +#include "live_effects/parameter/colorpicker.h" namespace Inkscape { namespace LivePathEffect { @@ -22,16 +23,15 @@ public: virtual void doEffect (SPCurve * curve); virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem); - //virtual void transform_multiply(Geom::Affine const& postmul, bool set); void toggleMaskVisibility(); void setMask(); private: HiddenParam uri; BoolParam invert; - BoolParam wrap; + //BoolParam wrap; BoolParam hide_mask; BoolParam background; - TextParam background_style; + ColorPickerParam background_color; Geom::Path mask_box; }; -- cgit v1.2.3 From 66b464e2f07106e2b270517c13205464727f281f Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Wed, 1 Nov 2017 22:13:21 +0100 Subject: Added inverse mask and clippath --- src/live_effects/lpe-powermask.cpp | 60 +++++++++++++++++++++----------------- src/live_effects/lpe-powermask.h | 1 + 2 files changed, 34 insertions(+), 27 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index a0ba42ddf..0d48b1b77 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -19,7 +19,6 @@ #include "uri.h" #include "extract-uri.h" #include - // TODO due to internal breakage in glibmm headers, this must be last: #include @@ -41,12 +40,14 @@ LPEPowerMask::LPEPowerMask(LivePathEffectObject *lpeobject) registerParameter(&hide_mask); registerParameter(&background); registerParameter(&background_color); + previous_color = background_color.get_value(); } LPEPowerMask::~LPEPowerMask() {} void LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ + //To avoid close of color dialog and better performance on change color SPObject * mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); if(hide_mask && mask) { SP_ITEM(sp_lpe_item)->mask_ref->detach(); @@ -60,35 +61,40 @@ LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ } mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); if (mask) { - uri.param_setValue(Glib::ustring(extract_uri(sp_lpe_item->getRepr()->attribute("mask"))), true); - SP_ITEM(sp_lpe_item)->mask_ref->detach(); - Geom::OptRect bbox = sp_lpe_item->visualBounds(); - if(!bbox) { - return; - } - if (uri.param_getSVGValue()) { - try { - SP_ITEM(sp_lpe_item)->mask_ref->attach(Inkscape::URI(uri.param_getSVGValue())); - } catch (Inkscape::BadURIException &e) { - g_warning("%s", e.what()); - SP_ITEM(sp_lpe_item)->mask_ref->detach(); - } + if (previous_color != background_color.get_value()) { + previous_color = background_color.get_value(); + setMask(); } else { + uri.param_setValue(Glib::ustring(extract_uri(sp_lpe_item->getRepr()->attribute("mask"))), true); SP_ITEM(sp_lpe_item)->mask_ref->detach(); + Geom::OptRect bbox = sp_lpe_item->visualBounds(); + if(!bbox) { + return; + } + if (uri.param_getSVGValue()) { + try { + SP_ITEM(sp_lpe_item)->mask_ref->attach(Inkscape::URI(uri.param_getSVGValue())); + } catch (Inkscape::BadURIException &e) { + g_warning("%s", e.what()); + SP_ITEM(sp_lpe_item)->mask_ref->detach(); + } + } else { + SP_ITEM(sp_lpe_item)->mask_ref->detach(); + } + Geom::Rect bboxrect = (*bbox); + bboxrect.expandBy(1); + Geom::Point topleft = bboxrect.corner(0); + Geom::Point topright = bboxrect.corner(1); + Geom::Point bottomright = bboxrect.corner(2); + Geom::Point bottomleft = bboxrect.corner(3); + mask_box.clear(); + mask_box.start(topleft); + mask_box.appendNew(topright); + mask_box.appendNew(bottomright); + mask_box.appendNew(bottomleft); + mask_box.close(); + setMask(); } - Geom::Rect bboxrect = (*bbox); - bboxrect.expandBy(1); - Geom::Point topleft = bboxrect.corner(0); - Geom::Point topright = bboxrect.corner(1); - Geom::Point bottomright = bboxrect.corner(2); - Geom::Point bottomleft = bboxrect.corner(3); - mask_box.clear(); - mask_box.start(topleft); - mask_box.appendNew(topright); - mask_box.appendNew(bottomright); - mask_box.appendNew(bottomleft); - mask_box.close(); - setMask(); } } diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h index 44bf56333..eb2640867 100644 --- a/src/live_effects/lpe-powermask.h +++ b/src/live_effects/lpe-powermask.h @@ -33,6 +33,7 @@ private: BoolParam background; ColorPickerParam background_color; Geom::Path mask_box; + guint32 previous_color; }; } //namespace LivePathEffect -- cgit v1.2.3 From cba70f5669c6a38321157fbb84a8511033b7b41e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Thu, 2 Nov 2017 21:14:20 +0100 Subject: Remove unrelated code --- src/live_effects/lpe-powermask.cpp | 220 ++++++++++++++++++------------------- src/live_effects/lpe-powermask.h | 9 +- 2 files changed, 114 insertions(+), 115 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index 0d48b1b77..05510f258 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -13,12 +13,12 @@ #include "style.h" #include "sp-item-group.h" #include "svg/svg.h" -#include "svg/svg-color.h" #include "ui/tools-switch.h" #include "path-chemistry.h" #include "uri.h" #include "extract-uri.h" #include + // TODO due to internal breakage in glibmm headers, this must be last: #include @@ -29,25 +29,25 @@ LPEPowerMask::LPEPowerMask(LivePathEffectObject *lpeobject) : Effect(lpeobject), uri("Store the uri of mask", "", "uri", &wr, this, "false", false), invert(_("Invert mask"), _("Invert mask"), "invert", &wr, this, false), - //wrap(_("Wrap mask data"), _("Wrap mask data allowing previous filters"), "wrap", &wr, this, false), + wrap(_("Wrap mask data"), _("Wrap mask data allowing previous filters"), "wrap", &wr, this, false), hide_mask(_("Hide mask"), _("Hide mask"), "hide_mask", &wr, this, false), background(_("Add background to mask"), _("Add background to mask"), "background", &wr, this, false), - background_color(_("Background color and opacity"), _("Set color and opacity of the background"), "background_color", &wr, this, 0xffffffff) + background_style(_("Background Style"), _("CSS to background"), "background_style", &wr, this,"fill:#ffffff;opacity:1;") { registerParameter(&uri); registerParameter(&invert); - //registerParameter(&wrap); + registerParameter(&wrap); registerParameter(&hide_mask); registerParameter(&background); - registerParameter(&background_color); - previous_color = background_color.get_value(); + registerParameter(&background_style); + //lock.param_setValue(false); + background_style.param_hide_canvas_text(); } LPEPowerMask::~LPEPowerMask() {} void LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ - //To avoid close of color dialog and better performance on change color SPObject * mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); if(hide_mask && mask) { SP_ITEM(sp_lpe_item)->mask_ref->detach(); @@ -61,40 +61,35 @@ LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ } mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); if (mask) { - if (previous_color != background_color.get_value()) { - previous_color = background_color.get_value(); - setMask(); - } else { - uri.param_setValue(Glib::ustring(extract_uri(sp_lpe_item->getRepr()->attribute("mask"))), true); - SP_ITEM(sp_lpe_item)->mask_ref->detach(); - Geom::OptRect bbox = sp_lpe_item->visualBounds(); - if(!bbox) { - return; - } - if (uri.param_getSVGValue()) { - try { - SP_ITEM(sp_lpe_item)->mask_ref->attach(Inkscape::URI(uri.param_getSVGValue())); - } catch (Inkscape::BadURIException &e) { - g_warning("%s", e.what()); - SP_ITEM(sp_lpe_item)->mask_ref->detach(); - } - } else { + uri.param_setValue(Glib::ustring(extract_uri(sp_lpe_item->getRepr()->attribute("mask"))), true); + SP_ITEM(sp_lpe_item)->mask_ref->detach(); + Geom::OptRect bbox = sp_lpe_item->visualBounds(); + if(!bbox) { + return; + } + if (uri.param_getSVGValue()) { + try { + SP_ITEM(sp_lpe_item)->mask_ref->attach(Inkscape::URI(uri.param_getSVGValue())); + } catch (Inkscape::BadURIException &e) { + g_warning("%s", e.what()); SP_ITEM(sp_lpe_item)->mask_ref->detach(); } - Geom::Rect bboxrect = (*bbox); - bboxrect.expandBy(1); - Geom::Point topleft = bboxrect.corner(0); - Geom::Point topright = bboxrect.corner(1); - Geom::Point bottomright = bboxrect.corner(2); - Geom::Point bottomleft = bboxrect.corner(3); - mask_box.clear(); - mask_box.start(topleft); - mask_box.appendNew(topright); - mask_box.appendNew(bottomright); - mask_box.appendNew(bottomleft); - mask_box.close(); - setMask(); + } else { + SP_ITEM(sp_lpe_item)->mask_ref->detach(); } + Geom::Rect bboxrect = (*bbox); + bboxrect.expandBy(1); + Geom::Point topleft = bboxrect.corner(0); + Geom::Point topright = bboxrect.corner(1); + Geom::Point bottomright = bboxrect.corner(2); + Geom::Point bottomleft = bboxrect.corner(3); + mask_box.clear(); + mask_box.start(topleft); + mask_box.appendNew(topright); + mask_box.appendNew(bottomright); + mask_box.appendNew(bottomleft); + mask_box.close(); + setMask(); } } @@ -150,57 +145,56 @@ LPEPowerMask::setMask(){ filter->appendChild(primitive2); Inkscape::GC::release(primitive2); } -//Not sure if finaly need to resurrect this -// if(wrap && is_visible){ -// Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; -// if((elemref = document->getObjectById(g_data_id))){ -// elemref->getRepr()->setPosition(-1); -// } else { -// Inkscape::XML::Node * container = xml_doc->createElement("svg:g"); -// container->setAttribute("id", g_data_id.c_str()); -// mask->appendChildRepr(container); -// std::vector mask_list = mask->childList(true); -// container->setPosition(-1); -// Inkscape::GC::release(container); -// for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { -// SPItem * mask_data = SP_ITEM(*iter); -// Inkscape::XML::Node *mask_node = mask_data->getRepr(); -// if (! strcmp(mask_data->getId(), box_id.c_str()) || -// ! strcmp(mask_data->getId(), g_data_id.c_str())) -// { -// continue; -// } -// SPCSSAttr *css = sp_repr_css_attr_new(); -// if(mask_node->attribute("style")) { -// sp_repr_css_attr_add_from_string(css, mask_node->attribute("style")); -// } -// char const* filter = sp_repr_css_property (css, "filter", NULL); -// if(!filter || !strcmp(filter, filter_uri.c_str())) { -// sp_repr_css_set_property (css, "filter", NULL); -// } -// Glib::ustring css_str; -// sp_repr_css_write_string(css, css_str); -// mask_node->setAttribute("style", css_str.c_str()); -// mask->getRepr()->removeChild(mask_node); -// container->appendChild(mask_node); -// Inkscape::GC::release(mask_node); -// } -// } -// } else { - Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; - if((elemref = document->getObjectById(g_data_id))){ - std::vector item_list = sp_item_group_item_list(SP_GROUP(elemref)); - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { - Inkscape::XML::Node *mask_node = (*iter)->getRepr(); - elemref->getRepr()->removeChild(mask_node); - mask->getRepr()->appendChild(mask_node); - Inkscape::GC::release(mask_node); + if(wrap && is_visible){ + Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; + if((elemref = document->getObjectById(g_data_id))){ + elemref->getRepr()->setPosition(-1); + } else { + Inkscape::XML::Node * container = xml_doc->createElement("svg:g"); + container->setAttribute("id", g_data_id.c_str()); + mask->appendChildRepr(container); + std::vector mask_list = mask->childList(true); + container->setPosition(-1); + Inkscape::GC::release(container); + for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { + SPItem * mask_data = SP_ITEM(*iter); + Inkscape::XML::Node *mask_node = mask_data->getRepr(); + if (! strcmp(mask_data->getId(), box_id.c_str()) || + ! strcmp(mask_data->getId(), g_data_id.c_str())) + { + continue; + } + SPCSSAttr *css = sp_repr_css_attr_new(); + if(mask_node->attribute("style")) { + sp_repr_css_attr_add_from_string(css, mask_node->attribute("style")); + } + char const* filter = sp_repr_css_property (css, "filter", NULL); + if(!filter || !strcmp(filter, filter_uri.c_str())) { + sp_repr_css_set_property (css, "filter", NULL); + } + Glib::ustring css_str; + sp_repr_css_write_string(css, css_str); + mask_node->setAttribute("style", css_str.c_str()); + mask->getRepr()->removeChild(mask_node); + container->appendChild(mask_node); + Inkscape::GC::release(mask_node); + } + } + } else { + Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; + if((elemref = document->getObjectById(g_data_id))){ + std::vector item_list = sp_item_group_item_list(SP_GROUP(elemref)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { + Inkscape::XML::Node *mask_node = (*iter)->getRepr(); + elemref->getRepr()->removeChild(mask_node); + mask->getRepr()->appendChild(mask_node); + Inkscape::GC::release(mask_node); + } + sp_object_ref(elemref, 0 ); + elemref->deleteObject(true); + sp_object_unref(elemref); } - sp_object_ref(elemref, 0 ); - elemref->deleteObject(true); - sp_object_unref(elemref); } -// } std::vector mask_list = mask->childList(true); for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { SPItem * mask_data = SP_ITEM(*iter); @@ -235,28 +229,7 @@ LPEPowerMask::setMask(){ box->setAttribute("id", box_id.c_str()); exist = false; } - Glib::ustring style; - gchar c[32]; - unsigned const rgb24 = background_color.get_value() >> 8; - sprintf(c, "#%06x", rgb24); - style = Glib::ustring("fill:") + Glib::ustring(c); - Inkscape::SVGOStringStream os; - os << SP_RGBA32_A_F(background_color.get_value()); - style = style + Glib::ustring(";fill-opacity:") + Glib::ustring(os.str()); - SPCSSAttr *css = sp_repr_css_attr_new(); - sp_repr_css_attr_add_from_string(css, style.c_str()); - char const* filter = sp_repr_css_property (css, "filter", NULL); - if(!filter || !strcmp(filter, filter_uri.c_str())) { - if (invert && is_visible) { - sp_repr_css_set_property (css, "filter", filter_uri.c_str()); - } else { - sp_repr_css_set_property (css, "filter", NULL); - } - - } - Glib::ustring css_str; - sp_repr_css_write_string(css, css_str); - box->setAttribute("style", css_str.c_str()); + box->setAttribute("style", background_style.param_getSVGValue()); gchar * box_str = sp_svg_write_path( mask_box ); box->setAttribute("d" , box_str); g_free(box_str); @@ -282,6 +255,33 @@ LPEPowerMask::doEffect (SPCurve * curve) { } +//void +//LPEPowerMask::transform_multiply(Geom::Affine const& postmul, bool set) +//{ +// SPMask *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); +// if (mask_path && lock) { +// SPMask *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); +// std::vector mask_path_list = mask_path->childList(true); +// Glib::ustring mask_id = (Glib::ustring)mask_path->getId(); +// Glib::ustring box_id = mask_id + (Glib::ustring)"_box"; +// for ( std::vector::const_iterator iter=mask_path_list.begin();iter!=mask_path_list.end();++iter) { +// SPObject * mask_data = *iter; +// if (! strcmp(mask_data->getId(), box_id.c_str())){ +// continue; +// } +// SP_ITEM(mask_data)->transform *= postmul.inverse(); +// } +// } +// //cycle through all parameters. Most parameters will not need transformation, but path and point params +// for (std::vector::iterator it = param_vector.begin(); it != param_vector.end(); ++it) { +// Parameter * param = *it; +// param->param_transform_multiply(postmul, set); +// } +// sp_lpe_item_update_patheffect(SP_LPE_ITEM(sp_lpe_item), false, false); +//} + + + void LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) { @@ -289,7 +289,7 @@ LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) SPMask *mask = lpeitem->mask_ref->getObject(); if (mask) { invert.param_setValue(false); - //wrap.param_setValue(false); + wrap.param_setValue(false); background.param_setValue(false); setMask(); SPObject *elemref = NULL; diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h index eb2640867..a54424e2f 100644 --- a/src/live_effects/lpe-powermask.h +++ b/src/live_effects/lpe-powermask.h @@ -6,11 +6,10 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ + #include "live_effects/effect.h" -#include "live_effects/parameter/bool.h" #include "live_effects/parameter/text.h" #include "live_effects/parameter/hidden.h" -#include "live_effects/parameter/colorpicker.h" namespace Inkscape { namespace LivePathEffect { @@ -23,17 +22,17 @@ public: virtual void doEffect (SPCurve * curve); virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem); + //virtual void transform_multiply(Geom::Affine const& postmul, bool set); void toggleMaskVisibility(); void setMask(); private: HiddenParam uri; BoolParam invert; - //BoolParam wrap; + BoolParam wrap; BoolParam hide_mask; BoolParam background; - ColorPickerParam background_color; + TextParam background_style; Geom::Path mask_box; - guint32 previous_color; }; } //namespace LivePathEffect -- cgit v1.2.3 From b54fa2d1333e52f5fac87c904b55ce3789a0881e Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Thu, 2 Nov 2017 21:17:50 +0100 Subject: Allow color widget instead text input in powermask. Simplify the UI --- src/live_effects/lpe-powermask.cpp | 220 ++++++++++++++++++------------------- src/live_effects/lpe-powermask.h | 9 +- 2 files changed, 115 insertions(+), 114 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index 05510f258..0d48b1b77 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -13,12 +13,12 @@ #include "style.h" #include "sp-item-group.h" #include "svg/svg.h" +#include "svg/svg-color.h" #include "ui/tools-switch.h" #include "path-chemistry.h" #include "uri.h" #include "extract-uri.h" #include - // TODO due to internal breakage in glibmm headers, this must be last: #include @@ -29,25 +29,25 @@ LPEPowerMask::LPEPowerMask(LivePathEffectObject *lpeobject) : Effect(lpeobject), uri("Store the uri of mask", "", "uri", &wr, this, "false", false), invert(_("Invert mask"), _("Invert mask"), "invert", &wr, this, false), - wrap(_("Wrap mask data"), _("Wrap mask data allowing previous filters"), "wrap", &wr, this, false), + //wrap(_("Wrap mask data"), _("Wrap mask data allowing previous filters"), "wrap", &wr, this, false), hide_mask(_("Hide mask"), _("Hide mask"), "hide_mask", &wr, this, false), background(_("Add background to mask"), _("Add background to mask"), "background", &wr, this, false), - background_style(_("Background Style"), _("CSS to background"), "background_style", &wr, this,"fill:#ffffff;opacity:1;") + background_color(_("Background color and opacity"), _("Set color and opacity of the background"), "background_color", &wr, this, 0xffffffff) { registerParameter(&uri); registerParameter(&invert); - registerParameter(&wrap); + //registerParameter(&wrap); registerParameter(&hide_mask); registerParameter(&background); - registerParameter(&background_style); - //lock.param_setValue(false); - background_style.param_hide_canvas_text(); + registerParameter(&background_color); + previous_color = background_color.get_value(); } LPEPowerMask::~LPEPowerMask() {} void LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ + //To avoid close of color dialog and better performance on change color SPObject * mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); if(hide_mask && mask) { SP_ITEM(sp_lpe_item)->mask_ref->detach(); @@ -61,35 +61,40 @@ LPEPowerMask::doBeforeEffect (SPLPEItem const* lpeitem){ } mask = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); if (mask) { - uri.param_setValue(Glib::ustring(extract_uri(sp_lpe_item->getRepr()->attribute("mask"))), true); - SP_ITEM(sp_lpe_item)->mask_ref->detach(); - Geom::OptRect bbox = sp_lpe_item->visualBounds(); - if(!bbox) { - return; - } - if (uri.param_getSVGValue()) { - try { - SP_ITEM(sp_lpe_item)->mask_ref->attach(Inkscape::URI(uri.param_getSVGValue())); - } catch (Inkscape::BadURIException &e) { - g_warning("%s", e.what()); - SP_ITEM(sp_lpe_item)->mask_ref->detach(); - } + if (previous_color != background_color.get_value()) { + previous_color = background_color.get_value(); + setMask(); } else { + uri.param_setValue(Glib::ustring(extract_uri(sp_lpe_item->getRepr()->attribute("mask"))), true); SP_ITEM(sp_lpe_item)->mask_ref->detach(); + Geom::OptRect bbox = sp_lpe_item->visualBounds(); + if(!bbox) { + return; + } + if (uri.param_getSVGValue()) { + try { + SP_ITEM(sp_lpe_item)->mask_ref->attach(Inkscape::URI(uri.param_getSVGValue())); + } catch (Inkscape::BadURIException &e) { + g_warning("%s", e.what()); + SP_ITEM(sp_lpe_item)->mask_ref->detach(); + } + } else { + SP_ITEM(sp_lpe_item)->mask_ref->detach(); + } + Geom::Rect bboxrect = (*bbox); + bboxrect.expandBy(1); + Geom::Point topleft = bboxrect.corner(0); + Geom::Point topright = bboxrect.corner(1); + Geom::Point bottomright = bboxrect.corner(2); + Geom::Point bottomleft = bboxrect.corner(3); + mask_box.clear(); + mask_box.start(topleft); + mask_box.appendNew(topright); + mask_box.appendNew(bottomright); + mask_box.appendNew(bottomleft); + mask_box.close(); + setMask(); } - Geom::Rect bboxrect = (*bbox); - bboxrect.expandBy(1); - Geom::Point topleft = bboxrect.corner(0); - Geom::Point topright = bboxrect.corner(1); - Geom::Point bottomright = bboxrect.corner(2); - Geom::Point bottomleft = bboxrect.corner(3); - mask_box.clear(); - mask_box.start(topleft); - mask_box.appendNew(topright); - mask_box.appendNew(bottomright); - mask_box.appendNew(bottomleft); - mask_box.close(); - setMask(); } } @@ -145,56 +150,57 @@ LPEPowerMask::setMask(){ filter->appendChild(primitive2); Inkscape::GC::release(primitive2); } - if(wrap && is_visible){ - Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; - if((elemref = document->getObjectById(g_data_id))){ - elemref->getRepr()->setPosition(-1); - } else { - Inkscape::XML::Node * container = xml_doc->createElement("svg:g"); - container->setAttribute("id", g_data_id.c_str()); - mask->appendChildRepr(container); - std::vector mask_list = mask->childList(true); - container->setPosition(-1); - Inkscape::GC::release(container); - for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { - SPItem * mask_data = SP_ITEM(*iter); - Inkscape::XML::Node *mask_node = mask_data->getRepr(); - if (! strcmp(mask_data->getId(), box_id.c_str()) || - ! strcmp(mask_data->getId(), g_data_id.c_str())) - { - continue; - } - SPCSSAttr *css = sp_repr_css_attr_new(); - if(mask_node->attribute("style")) { - sp_repr_css_attr_add_from_string(css, mask_node->attribute("style")); - } - char const* filter = sp_repr_css_property (css, "filter", NULL); - if(!filter || !strcmp(filter, filter_uri.c_str())) { - sp_repr_css_set_property (css, "filter", NULL); - } - Glib::ustring css_str; - sp_repr_css_write_string(css, css_str); - mask_node->setAttribute("style", css_str.c_str()); - mask->getRepr()->removeChild(mask_node); - container->appendChild(mask_node); - Inkscape::GC::release(mask_node); - } - } - } else { - Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; - if((elemref = document->getObjectById(g_data_id))){ - std::vector item_list = sp_item_group_item_list(SP_GROUP(elemref)); - for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { - Inkscape::XML::Node *mask_node = (*iter)->getRepr(); - elemref->getRepr()->removeChild(mask_node); - mask->getRepr()->appendChild(mask_node); - Inkscape::GC::release(mask_node); - } - sp_object_ref(elemref, 0 ); - elemref->deleteObject(true); - sp_object_unref(elemref); +//Not sure if finaly need to resurrect this +// if(wrap && is_visible){ +// Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; +// if((elemref = document->getObjectById(g_data_id))){ +// elemref->getRepr()->setPosition(-1); +// } else { +// Inkscape::XML::Node * container = xml_doc->createElement("svg:g"); +// container->setAttribute("id", g_data_id.c_str()); +// mask->appendChildRepr(container); +// std::vector mask_list = mask->childList(true); +// container->setPosition(-1); +// Inkscape::GC::release(container); +// for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { +// SPItem * mask_data = SP_ITEM(*iter); +// Inkscape::XML::Node *mask_node = mask_data->getRepr(); +// if (! strcmp(mask_data->getId(), box_id.c_str()) || +// ! strcmp(mask_data->getId(), g_data_id.c_str())) +// { +// continue; +// } +// SPCSSAttr *css = sp_repr_css_attr_new(); +// if(mask_node->attribute("style")) { +// sp_repr_css_attr_add_from_string(css, mask_node->attribute("style")); +// } +// char const* filter = sp_repr_css_property (css, "filter", NULL); +// if(!filter || !strcmp(filter, filter_uri.c_str())) { +// sp_repr_css_set_property (css, "filter", NULL); +// } +// Glib::ustring css_str; +// sp_repr_css_write_string(css, css_str); +// mask_node->setAttribute("style", css_str.c_str()); +// mask->getRepr()->removeChild(mask_node); +// container->appendChild(mask_node); +// Inkscape::GC::release(mask_node); +// } +// } +// } else { + Glib::ustring g_data_id = mask_id + (Glib::ustring)"_container"; + if((elemref = document->getObjectById(g_data_id))){ + std::vector item_list = sp_item_group_item_list(SP_GROUP(elemref)); + for ( std::vector::const_iterator iter=item_list.begin();iter!=item_list.end();++iter) { + Inkscape::XML::Node *mask_node = (*iter)->getRepr(); + elemref->getRepr()->removeChild(mask_node); + mask->getRepr()->appendChild(mask_node); + Inkscape::GC::release(mask_node); } + sp_object_ref(elemref, 0 ); + elemref->deleteObject(true); + sp_object_unref(elemref); } +// } std::vector mask_list = mask->childList(true); for ( std::vector::const_iterator iter=mask_list.begin();iter!=mask_list.end();++iter) { SPItem * mask_data = SP_ITEM(*iter); @@ -229,7 +235,28 @@ LPEPowerMask::setMask(){ box->setAttribute("id", box_id.c_str()); exist = false; } - box->setAttribute("style", background_style.param_getSVGValue()); + Glib::ustring style; + gchar c[32]; + unsigned const rgb24 = background_color.get_value() >> 8; + sprintf(c, "#%06x", rgb24); + style = Glib::ustring("fill:") + Glib::ustring(c); + Inkscape::SVGOStringStream os; + os << SP_RGBA32_A_F(background_color.get_value()); + style = style + Glib::ustring(";fill-opacity:") + Glib::ustring(os.str()); + SPCSSAttr *css = sp_repr_css_attr_new(); + sp_repr_css_attr_add_from_string(css, style.c_str()); + char const* filter = sp_repr_css_property (css, "filter", NULL); + if(!filter || !strcmp(filter, filter_uri.c_str())) { + if (invert && is_visible) { + sp_repr_css_set_property (css, "filter", filter_uri.c_str()); + } else { + sp_repr_css_set_property (css, "filter", NULL); + } + + } + Glib::ustring css_str; + sp_repr_css_write_string(css, css_str); + box->setAttribute("style", css_str.c_str()); gchar * box_str = sp_svg_write_path( mask_box ); box->setAttribute("d" , box_str); g_free(box_str); @@ -255,33 +282,6 @@ LPEPowerMask::doEffect (SPCurve * curve) { } -//void -//LPEPowerMask::transform_multiply(Geom::Affine const& postmul, bool set) -//{ -// SPMask *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); -// if (mask_path && lock) { -// SPMask *mask_path = SP_ITEM(sp_lpe_item)->mask_ref->getObject(); -// std::vector mask_path_list = mask_path->childList(true); -// Glib::ustring mask_id = (Glib::ustring)mask_path->getId(); -// Glib::ustring box_id = mask_id + (Glib::ustring)"_box"; -// for ( std::vector::const_iterator iter=mask_path_list.begin();iter!=mask_path_list.end();++iter) { -// SPObject * mask_data = *iter; -// if (! strcmp(mask_data->getId(), box_id.c_str())){ -// continue; -// } -// SP_ITEM(mask_data)->transform *= postmul.inverse(); -// } -// } -// //cycle through all parameters. Most parameters will not need transformation, but path and point params -// for (std::vector::iterator it = param_vector.begin(); it != param_vector.end(); ++it) { -// Parameter * param = *it; -// param->param_transform_multiply(postmul, set); -// } -// sp_lpe_item_update_patheffect(SP_LPE_ITEM(sp_lpe_item), false, false); -//} - - - void LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) { @@ -289,7 +289,7 @@ LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) SPMask *mask = lpeitem->mask_ref->getObject(); if (mask) { invert.param_setValue(false); - wrap.param_setValue(false); + //wrap.param_setValue(false); background.param_setValue(false); setMask(); SPObject *elemref = NULL; diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h index a54424e2f..eb2640867 100644 --- a/src/live_effects/lpe-powermask.h +++ b/src/live_effects/lpe-powermask.h @@ -6,10 +6,11 @@ * * Released under GNU GPL, read the file 'COPYING' for more information */ - #include "live_effects/effect.h" +#include "live_effects/parameter/bool.h" #include "live_effects/parameter/text.h" #include "live_effects/parameter/hidden.h" +#include "live_effects/parameter/colorpicker.h" namespace Inkscape { namespace LivePathEffect { @@ -22,17 +23,17 @@ public: virtual void doEffect (SPCurve * curve); virtual void doOnRemove (SPLPEItem const* /*lpeitem*/); virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem); - //virtual void transform_multiply(Geom::Affine const& postmul, bool set); void toggleMaskVisibility(); void setMask(); private: HiddenParam uri; BoolParam invert; - BoolParam wrap; + //BoolParam wrap; BoolParam hide_mask; BoolParam background; - TextParam background_style; + ColorPickerParam background_color; Geom::Path mask_box; + guint32 previous_color; }; } //namespace LivePathEffect -- cgit v1.2.3 From 08382df305f91a07349031e785500eb7be34872c Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Fri, 3 Nov 2017 00:14:28 +0100 Subject: Move finctions away object sets --- src/live_effects/lpe-powerclip.cpp | 19 +++++++++++++++++++ src/live_effects/lpe-powerclip.h | 2 ++ src/live_effects/lpe-powermask.cpp | 18 ++++++++++++++++++ src/live_effects/lpe-powermask.h | 3 +++ 4 files changed, 42 insertions(+) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-powerclip.cpp b/src/live_effects/lpe-powerclip.cpp index 40a9cdbfb..18276270d 100644 --- a/src/live_effects/lpe-powerclip.cpp +++ b/src/live_effects/lpe-powerclip.cpp @@ -395,6 +395,25 @@ LPEPowerClip::flattenClip(SPItem * clip_data, Geom::PathVector &path_in) } } +void sp_inverse_powerclip(Inkscape::Selection *sel) { + if (!sel->isEmpty()) { + auto selList = sel->items(); + for(auto i = boost::rbegin(selList); i != boost::rend(selList); ++i) { + SPLPEItem* lpeitem = dynamic_cast(*i); + if (lpeitem) { + Effect::createAndApply(POWERCLIP, SP_ACTIVE_DOCUMENT, lpeitem); + Effect* lpe = lpeitem->getCurrentLPE(); + lpe->getRepr()->setAttribute("is_inverse", "false"); + lpe->getRepr()->setAttribute("is_visible", "true"); + lpe->getRepr()->setAttribute("inverse", "true"); + lpe->getRepr()->setAttribute("flatten", "false"); + lpe->getRepr()->setAttribute("hide_clip", "false"); + dynamic_cast(lpe)->convertShapes(); + } + } + } +} + }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/live_effects/lpe-powerclip.h b/src/live_effects/lpe-powerclip.h index 38485b798..6f99d220f 100644 --- a/src/live_effects/lpe-powerclip.h +++ b/src/live_effects/lpe-powerclip.h @@ -38,6 +38,8 @@ private: bool convert_shapes; }; +void sp_inverse_powerclip(Inkscape::Selection *sel); + } //namespace LivePathEffect } //namespace Inkscape #endif diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index 05510f258..b7c88584b 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -303,6 +303,24 @@ LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) } } +void sp_inverse_powerclip(Inkscape::Selection *sel) { + if (!sel->isEmpty()) { + auto selList = sel->items(); + for(auto i = boost::rbegin(selList); i != boost::rend(selList); ++i) { + SPLPEItem* lpeitem = dynamic_cast(*i); + if (lpeitem) { + Effect::createAndApply(POWERMASK, SP_ACTIVE_DOCUMENT, lpeitem); + Effect* lpe = lpeitem->getCurrentLPE(); + lpe->getRepr()->setAttribute("invert", "false"); + lpe->getRepr()->setAttribute("is_visible", "true"); + lpe->getRepr()->setAttribute("hide_mask", "false"); + lpe->getRepr()->setAttribute("background", "true"); + lpe->getRepr()->setAttribute("background_color", "#ffffffff"); + } + } + } +} + }; //namespace LivePathEffect }; /* namespace Inkscape */ diff --git a/src/live_effects/lpe-powermask.h b/src/live_effects/lpe-powermask.h index a54424e2f..d2d87fd41 100644 --- a/src/live_effects/lpe-powermask.h +++ b/src/live_effects/lpe-powermask.h @@ -35,6 +35,9 @@ private: Geom::Path mask_box; }; +void sp_inverse_powermask(Inkscape::Selection *sel); + } //namespace LivePathEffect } //namespace Inkscape + #endif -- cgit v1.2.3 From bc776cf2ee8744fb0b49cb3ef9f53e835515624b Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Fri, 3 Nov 2017 02:17:35 +0100 Subject: Rename wrong named function --- src/live_effects/lpe-powermask.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-powermask.cpp b/src/live_effects/lpe-powermask.cpp index b7c88584b..396a3b3ca 100644 --- a/src/live_effects/lpe-powermask.cpp +++ b/src/live_effects/lpe-powermask.cpp @@ -303,7 +303,7 @@ LPEPowerMask::doOnRemove (SPLPEItem const* lpeitem) } } -void sp_inverse_powerclip(Inkscape::Selection *sel) { +void sp_inverse_powermask(Inkscape::Selection *sel) { if (!sel->isEmpty()) { auto selList = sel->items(); for(auto i = boost::rbegin(selList); i != boost::rend(selList); ++i) { -- cgit v1.2.3 From 8e1c696fd91a7d3d1740e6e76617a75068245057 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 4 Nov 2017 16:08:32 +0100 Subject: Fix meessage parameter to allow min height request --- src/live_effects/lpe-measure-segments.cpp | 1 + src/live_effects/parameter/message.cpp | 24 ++++++++++++++++++------ src/live_effects/parameter/message.h | 4 +++- 3 files changed, 22 insertions(+), 7 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/lpe-measure-segments.cpp b/src/live_effects/lpe-measure-segments.cpp index 5ed587922..4bc9278fc 100644 --- a/src/live_effects/lpe-measure-segments.cpp +++ b/src/live_effects/lpe-measure-segments.cpp @@ -139,6 +139,7 @@ LPEMeasureSegments::LPEMeasureSegments(LivePathEffectObject *lpeobject) : helpline_overlap.param_set_increments(1, 1); helpline_overlap.param_set_digits(2); star_ellipse_fix = Geom::identity(); + message.param_set_min_height(95); } LPEMeasureSegments::~LPEMeasureSegments() {} diff --git a/src/live_effects/parameter/message.cpp b/src/live_effects/parameter/message.cpp index 39d8f12c7..28e94a900 100644 --- a/src/live_effects/parameter/message.cpp +++ b/src/live_effects/parameter/message.cpp @@ -20,7 +20,8 @@ MessageParam::MessageParam( const Glib::ustring& label, const Glib::ustring& tip message(g_strdup(default_message)), defmessage(g_strdup(default_message)) { - + _label = NULL; + _min_min_height = -1; } void @@ -54,6 +55,16 @@ MessageParam::param_getDefaultSVGValue() const return defmessage; } +void +MessageParam::param_set_min_height(int height) +{ + _min_height = height; + if (_label) { + _label->set_size_request(-1, _min_height); + } +} + + Gtk::Widget * MessageParam::param_newWidget() { @@ -61,11 +72,12 @@ MessageParam::param_newWidget() Gtk::Widget * widg_frame = frame->get_label_widget(); widg_frame->set_margin_right(5); widg_frame->set_margin_left(5); - Gtk::Label * label = new Gtk::Label (message, Gtk::ALIGN_END); - label->set_use_underline (true); - label->set_use_markup(); - label->set_line_wrap(true); - Gtk::Widget * widg_label = dynamic_cast (label); + _label = new Gtk::Label (message, Gtk::ALIGN_END); + _label->set_use_underline (true); + _label->set_use_markup(); + _label->set_line_wrap(true); + _label->set_size_request(-1, _min_height); + Gtk::Widget* widg_label = dynamic_cast (_label); widg_label->set_margin_top(8); widg_label->set_margin_bottom(10); widg_label->set_margin_right(6); diff --git a/src/live_effects/parameter/message.h b/src/live_effects/parameter/message.h index 63075cf96..2ac2c791a 100644 --- a/src/live_effects/parameter/message.h +++ b/src/live_effects/parameter/message.h @@ -33,10 +33,12 @@ public: void param_setValue(const gchar * message); virtual void param_set_default(); - + void param_set_min_height(int height); const gchar * get_value() const { return message; }; private: + Gtk::Label * _label; + int _min_height; MessageParam(const MessageParam&); MessageParam& operator=(const MessageParam&); gchar * message; -- cgit v1.2.3 From 3361a26a8f144b4baa95847e7801ed46468b6867 Mon Sep 17 00:00:00 2001 From: Jabier Arraiza Date: Sat, 4 Nov 2017 16:46:17 +0100 Subject: Fix typo crash building --- src/live_effects/parameter/message.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/live_effects') diff --git a/src/live_effects/parameter/message.cpp b/src/live_effects/parameter/message.cpp index 28e94a900..0e19c07e1 100644 --- a/src/live_effects/parameter/message.cpp +++ b/src/live_effects/parameter/message.cpp @@ -21,7 +21,7 @@ MessageParam::MessageParam( const Glib::ustring& label, const Glib::ustring& tip defmessage(g_strdup(default_message)) { _label = NULL; - _min_min_height = -1; + _min_height = -1; } void -- cgit v1.2.3 From 2659ce5a325688a3db9900d6d662e92048f0539e Mon Sep 17 00:00:00 2001 From: Unknown Date: Tue, 7 Nov 2017 13:55:26 -0500 Subject: Misc. typos Found using `codespell -q 3 -w --skip="*.svg,*.po,*.ts,./share/tutorials,./src/libavoid,./packaging/win32/languages,./man,./src/2geom" -I ../inkscape-whitelist.txt` whereby whitelist file contained: ``` dum iff glight substract te upto ``` --- src/live_effects/effect.cpp | 8 ++++---- src/live_effects/lpe-bool.cpp | 2 +- src/live_effects/lpe-dynastroke.cpp | 4 ++-- src/live_effects/lpe-embrodery-stitch-ordering.h | 2 +- src/live_effects/lpe-embrodery-stitch.cpp | 2 +- src/live_effects/lpe-envelope.cpp | 2 +- src/live_effects/lpe-fillet-chamfer.cpp | 6 +++--- src/live_effects/lpe-knot.cpp | 2 +- src/live_effects/lpe-lattice2.cpp | 2 +- src/live_effects/lpe-ruler.cpp | 2 +- src/live_effects/lpe-sketch.cpp | 2 +- src/live_effects/lpe-vonkoch.cpp | 2 +- src/live_effects/lpe-vonkoch.h | 2 +- src/live_effects/lpeobject-reference.h | 2 +- src/live_effects/parameter/path.cpp | 2 +- src/live_effects/parameter/satellitesarray.h | 10 +++++----- 16 files changed, 26 insertions(+), 26 deletions(-) (limited to 'src/live_effects') diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index 5674e29dc..f4aad4f53 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -835,13 +835,13 @@ Effect::defaultParamSet() bool valid = prefs->getEntry(pref_path).isValid(); const gchar * set_or_upd; Glib::ustring def = Glib::ustring(_("Default value: ")) + Glib::ustring(param->param_getDefaultSVGValue()) + Glib::ustring("\n"); - Glib::ustring ove = Glib::ustring(_("Default value overrided: ")) + Glib::ustring(prefs->getString(pref_path)) + Glib::ustring("\n"); + Glib::ustring ove = Glib::ustring(_("Default value overridden: ")) + Glib::ustring(prefs->getString(pref_path)) + Glib::ustring("\n"); if (valid) { set_or_upd = _("Update"); def = Glib::ustring(_("Default value: ")) + Glib::ustring(param->param_getDefaultSVGValue()) + Glib::ustring("\n"); } else { set_or_upd = _("Set"); - ove = Glib::ustring(_("Default value overrided: None\n")); + ove = Glib::ustring(_("Default value overridden: None\n")); } Glib::ustring cur = Glib::ustring(_("Current parameter value: ")) + Glib::ustring(param->param_getSVGValue()); Gtk::HBox * vbox_param = Gtk::manage( new Gtk::HBox(true) ); @@ -892,7 +892,7 @@ Effect::setDefaultParam(Glib::ustring pref_path, Glib::ustring tooltip, gchar * set->set_label((Glib::ustring)label); unset->set_sensitive(true); Glib::ustring def = Glib::ustring(_("Default value: ")) + Glib::ustring(defvalue) + Glib::ustring("\n"); - Glib::ustring ove = Glib::ustring(_("Default value overrided: ")) + Glib::ustring(value) + Glib::ustring("\n"); + Glib::ustring ove = Glib::ustring(_("Default value overridden: ")) + Glib::ustring(value) + Glib::ustring("\n"); Glib::ustring cur = Glib::ustring(_("Current parameter value: ")) + Glib::ustring(value); parameter_label->set_tooltip_markup((tooltip + def + ove + cur).c_str()); } @@ -906,7 +906,7 @@ Effect::unsetDefaultParam(Glib::ustring pref_path, Glib::ustring tooltip, gchar set->set_label((Glib::ustring)label); unset->set_sensitive(false); Glib::ustring def = Glib::ustring(_("Default value: ")) + Glib::ustring(defvalue) + Glib::ustring("\n"); - Glib::ustring ove = Glib::ustring(_("Default value overrided: None\n")); + Glib::ustring ove = Glib::ustring(_("Default value overridden: None\n")); Glib::ustring cur = Glib::ustring(_("Current parameter value: ")) + Glib::ustring(value); parameter_label->set_tooltip_markup((tooltip + def + ove + cur).c_str()); } diff --git a/src/live_effects/lpe-bool.cpp b/src/live_effects/lpe-bool.cpp index 2930414b3..6299b282b 100644 --- a/src/live_effects/lpe-bool.cpp +++ b/src/live_effects/lpe-bool.cpp @@ -121,7 +121,7 @@ sp_pathvector_boolop_slice_intersect(Geom::PathVector const &pathva, Geom::PathV // (i) filter the descr_cmd of the result path with this bool vector // // The main inefficieny here is step (e) because I use a winding function of the area-shape which goes - // through teh complete edge list for each point I ask for, so effort is n-edges-contour * n-edges-area. + // through the complete edge list for each point I ask for, so effort is n-edges-contour * n-edges-area. // It is tricky to improve this without building into the livarot code. // One way might be to decide at the intersection points which edges touching the intersection points are // in by making a loop through all edges on the intersection vertex. Since this is a directed non intersecting diff --git a/src/live_effects/lpe-dynastroke.cpp b/src/live_effects/lpe-dynastroke.cpp index 33e754a8a..d0655d9bd 100644 --- a/src/live_effects/lpe-dynastroke.cpp +++ b/src/live_effects/lpe-dynastroke.cpp @@ -22,7 +22,7 @@ namespace Inkscape { namespace LivePathEffect { //TODO: growfor/fadefor can be expressed in unit of width. -//TODO: make round/sharp end choices independant for start and end. +//TODO: make round/sharp end choices independent for start and end. //TODO: define more styles like in calligtool. //TODO: allow fancy ends. @@ -166,7 +166,7 @@ LPEDynastroke::doEffect_pwd2 (Geom::Piecewise > const & p // General formula: n1 = w*u with ||u||=1 and u.v = -dw/dt Piecewise dw = derivative(w); Piecewise ncomp = sqrt(dot(v,v)-dw*dw,.1,3); - //FIXME: is force continuity usefull? compatible with corners? + //FIXME: is force continuity useful? compatible with corners? // std::cout<<"ici\n"; n1 = -dw*v + ncomp*rot90(v); n1 = w*force_continuity(unitVector(n1),.1); diff --git a/src/live_effects/lpe-embrodery-stitch-ordering.h b/src/live_effects/lpe-embrodery-stitch-ordering.h index b2b5d36db..c307ec555 100644 --- a/src/live_effects/lpe-embrodery-stitch-ordering.h +++ b/src/live_effects/lpe-embrodery-stitch-ordering.h @@ -195,7 +195,7 @@ struct OrderingGroupConnection { Connect(1, toIn); } - // Connect one of the conection endpoints to the given point + // Connect one of the connection endpoints to the given point void Connect(int index, OrderingGroupPoint *point) { assert(point); diff --git a/src/live_effects/lpe-embrodery-stitch.cpp b/src/live_effects/lpe-embrodery-stitch.cpp index f2342032b..282419fd8 100644 --- a/src/live_effects/lpe-embrodery-stitch.cpp +++ b/src/live_effects/lpe-embrodery-stitch.cpp @@ -345,7 +345,7 @@ PathVector LPEEmbroderyStitch::doEffect_path(PathVector const &path_in) Piecewise > pwOneEqdist = arc_length_parametrization(pwOne); Interval pwdomain = pwOneEqdist.domain(); - // Compute the points of teh shortened piece + // Compute the points of the shortened piece Coord len = pwdomain.max() - pwdomain.min(); Coord offs = 0.5 * (show_stitch_gap < 0.5 * len ? show_stitch_gap : 0.5 * len); Point p1 = pwOneEqdist.valueAt(pwdomain.min() + offs); diff --git a/src/live_effects/lpe-envelope.cpp b/src/live_effects/lpe-envelope.cpp index 8528ab14d..688841617 100644 --- a/src/live_effects/lpe-envelope.cpp +++ b/src/live_effects/lpe-envelope.cpp @@ -205,7 +205,7 @@ LPEEnvelope::doEffect_pwd2 (Geom::Piecewise > const & pwd output /= 2.; return output; - /*Of course, the result is not perfect, but on a graphical point of view, this is sufficent.*/ + /*Of course, the result is not perfect, but on a graphical point of view, this is sufficient.*/ } diff --git a/src/live_effects/lpe-fillet-chamfer.cpp b/src/live_effects/lpe-fillet-chamfer.cpp index 2b052ace1..fb78c2065 100644 --- a/src/live_effects/lpe-fillet-chamfer.cpp +++ b/src/live_effects/lpe-fillet-chamfer.cpp @@ -131,7 +131,7 @@ void LPEFilletChamfer::doOnApply(SPLPEItem const *lpeItem) } //we add the last satellite on open path because _pathvector_satellites is related to nodes, not curves //so maybe in the future we can need this last satellite in other effects - //dont remove for this effect because _pathvector_satellites class has methods when the path is modiffied + //don't remove for this effect because _pathvector_satellites class has methods when the path is modiffied //and we want one method for all uses if (!path_it->closed()) { Satellite satellite(satellite_type); @@ -323,7 +323,7 @@ void LPEFilletChamfer::doBeforeEffect(SPLPEItem const *lpeItem) //mandatory call satellites_param.setEffectType(effectType()); Geom::PathVector const pathv = pathv_to_linear_and_cubic_beziers(sp_curve->get_pathvector()); - //if are diferent sizes call to recalculate + //if are different sizes call to recalculate //TODO: Update the satellite data in paths modified, Satellites satellites = satellites_param.data(); if (satellites.empty()) { @@ -468,7 +468,7 @@ LPEFilletChamfer::doEffect_path(Geom::PathVector const &path_in) Satellite satellite = satellites[path][next_index]; if (Geom::are_near((*curve_it1).initialPoint(), (*curve_it1).finalPoint())) { _degenerate_hide = true; - g_warning("Knots hidded if consecutive nodes has the same position."); + g_warning("Knots hidden if consecutive nodes has the same position."); return path_in; } if (!curve) { //curve == 0 diff --git a/src/live_effects/lpe-knot.cpp b/src/live_effects/lpe-knot.cpp index 22c548c1d..b21181ffc 100644 --- a/src/live_effects/lpe-knot.cpp +++ b/src/live_effects/lpe-knot.cpp @@ -520,7 +520,7 @@ collectPathsAndWidths (SPLPEItem const *lpeitem, Geom::PathVector &paths, std::v Geom::PathVector subpaths = pathv_to_linear_and_cubic_beziers(c->get_pathvector()); for (unsigned i=0; istyle->stroke_width.computed); } } diff --git a/src/live_effects/lpe-lattice2.cpp b/src/live_effects/lpe-lattice2.cpp index e827491c0..e8642d4e7 100644 --- a/src/live_effects/lpe-lattice2.cpp +++ b/src/live_effects/lpe-lattice2.cpp @@ -103,7 +103,7 @@ Geom::Piecewise > LPELattice2::doEffect_pwd2 (Geom::Piecewise > const & pwd2_in) { PathVector pathv = path_from_piecewise(pwd2_in,0.001); - //this is because strange problems whith sb2 and LineSegment + //this is because strange problems with sb2 and LineSegment PathVector cubic = pathv_to_cubicbezier(pathv); Geom::Piecewise > const &pwd2_in_linear_and_cubic = paths_to_pw(cubic); D2 sb2; diff --git a/src/live_effects/lpe-ruler.cpp b/src/live_effects/lpe-ruler.cpp index 7ba5a7913..7726af176 100644 --- a/src/live_effects/lpe-ruler.cpp +++ b/src/live_effects/lpe-ruler.cpp @@ -171,7 +171,7 @@ LPERuler::doEffect_pwd2 (Geom::Piecewise > const & pwd2_i if (border_marks == BORDERMARK_END || border_marks == BORDERMARK_BOTH){ Point A = pwd2_in.lastValue(); Point n = rot90(unit_vector(speed.lastValue()))*sign; - //speed.lastValue() is somtimes wrong when the path is closed: a tiny line seg might added at the end to fix rounding errors... + //speed.lastValue() is sometimes wrong when the path is closed: a tiny line seg might added at the end to fix rounding errors... //TODO: Find a better fix!! (How do we know if the path was closed?) if ( A == pwd2_in.firstValue() && speed.segs.size() > 1 && diff --git a/src/live_effects/lpe-sketch.cpp b/src/live_effects/lpe-sketch.cpp index e3376b7e5..dfb860de8 100644 --- a/src/live_effects/lpe-sketch.cpp +++ b/src/live_effects/lpe-sketch.cpp @@ -107,7 +107,7 @@ LPESketch::LPESketch(LivePathEffectObject *lpeobject) : tgtlength_rdm.param_set_range(0, 1.); tgt_places_rdmness.param_set_range(0, 1.); //this is not very smart, but required to avoid having lot of tangents stacked on short components. - //Nota: we could specify a density instead of an absolute number, but this would be scale dependant. + //Note: we could specify a density instead of an absolute number, but this would be scale dependent. concatenate_before_pwd2 = true; #endif } diff --git a/src/live_effects/lpe-vonkoch.cpp b/src/live_effects/lpe-vonkoch.cpp index b9fd8908a..f04c243f6 100644 --- a/src/live_effects/lpe-vonkoch.cpp +++ b/src/live_effects/lpe-vonkoch.cpp @@ -169,7 +169,7 @@ LPEVonKoch::doEffect_path (Geom::PathVector const & path_in) } -//Usefull?? +//Useful?? //void //LPEVonKoch::addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector &hp_vec) /*{ diff --git a/src/live_effects/lpe-vonkoch.h b/src/live_effects/lpe-vonkoch.h index bffbebd54..c0cb7ce42 100644 --- a/src/live_effects/lpe-vonkoch.h +++ b/src/live_effects/lpe-vonkoch.h @@ -55,7 +55,7 @@ public: virtual void doBeforeEffect(SPLPEItem const* item); - //Usefull?? + //Useful?? // protected: //virtual void addCanvasIndicators(SPLPEItem const *lpeitem, std::vector &hp_vec); diff --git a/src/live_effects/lpeobject-reference.h b/src/live_effects/lpeobject-reference.h index 374e715ec..baee35614 100644 --- a/src/live_effects/lpeobject-reference.h +++ b/src/live_effects/lpeobject-reference.h @@ -32,7 +32,7 @@ public: SPObject *owner; - // concerning the LPEObject that is refered to: + // concerning the LPEObject that is referred to: char *lpeobject_href; Inkscape::XML::Node *lpeobject_repr; LivePathEffectObject *lpeobject; diff --git a/src/live_effects/parameter/path.cpp b/src/live_effects/parameter/path.cpp index bd6608737..f89fad3ee 100644 --- a/src/live_effects/parameter/path.cpp +++ b/src/live_effects/parameter/path.cpp @@ -343,7 +343,7 @@ PathParam::set_new_value (Geom::Piecewise > const & newpa * * If write_to_svg = true : * The new path data is written to SVG. In this case the signal_path_changed signal - * is not directly emited in this method, because writing to SVG + * is not directly emitted in this method, because writing to SVG * triggers the LPEObject to which this belongs to call Effect::setParameter which calls * PathParam::readSVGValue, which finally emits the signal_path_changed signal. * If write_to_svg = false : diff --git a/src/live_effects/parameter/satellitesarray.h b/src/live_effects/parameter/satellitesarray.h index 5ae372ac2..3039eb432 100644 --- a/src/live_effects/parameter/satellitesarray.h +++ b/src/live_effects/parameter/satellitesarray.h @@ -5,14 +5,14 @@ * Inkscape::LivePathEffectParameters * Copyright (C) Jabiertxo Arraiza Cenoz * Special thanks to Johan Engelen for the base of the effect -powerstroke- - * Also to ScislaC for point me to the idea - * Also su_v for his construvtive feedback and time + * Also to ScislaC for pointing me to the idea + * Also su_v for his constructive feedback and time * To Nathan Hurst for his review and help on refactor - * and finaly to Liam P. White for his big help on coding, that save me a lot of - * hours + * and finally to Liam P. White for his big help on coding, + * that saved me a lot of hours * * - * This parameter act as bridge from pathVectorSatellites class to serialize it as a LPE + * This parameter acts as a bridge from pathVectorSatellites class to serialize it as a LPE * parameter * * Released under GNU GPL, read the file 'COPYING' for more information -- cgit v1.2.3