diff options
| author | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-11-02 20:14:20 +0000 |
|---|---|---|
| committer | Jabier Arraiza <jabier.arraiza@marker.es> | 2017-11-02 20:14:20 +0000 |
| commit | cba70f5669c6a38321157fbb84a8511033b7b41e (patch) | |
| tree | f3f614e4b7bad52f610f02dd673bd4fa2fed1d4a /src | |
| parent | Merge branch 'master' into menuInverseClipMask (diff) | |
| download | inkscape-cba70f5669c6a38321157fbb84a8511033b7b41e.tar.gz inkscape-cba70f5669c6a38321157fbb84a8511033b7b41e.zip | |
Remove unrelated code
Diffstat (limited to 'src')
| -rw-r--r-- | src/live_effects/lpe-powermask.cpp | 220 | ||||
| -rw-r--r-- | src/live_effects/lpe-powermask.h | 9 |
2 files changed, 114 insertions, 115 deletions
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 <bad-uri-exception.h> + // TODO due to internal breakage in glibmm headers, this must be last: #include <glibmm/i18n.h> @@ -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<Geom::LineSegment>(topright); - mask_box.appendNew<Geom::LineSegment>(bottomright); - mask_box.appendNew<Geom::LineSegment>(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<Geom::LineSegment>(topright); + mask_box.appendNew<Geom::LineSegment>(bottomright); + mask_box.appendNew<Geom::LineSegment>(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<SPObject*> mask_list = mask->childList(true); -// container->setPosition(-1); -// Inkscape::GC::release(container); -// for ( std::vector<SPObject*>::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<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(elemref)); - for ( std::vector<SPItem*>::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<SPObject*> mask_list = mask->childList(true); + container->setPosition(-1); + Inkscape::GC::release(container); + for ( std::vector<SPObject*>::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<SPItem*> item_list = sp_item_group_item_list(SP_GROUP(elemref)); + for ( std::vector<SPItem*>::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<SPObject*> mask_list = mask->childList(true); for ( std::vector<SPObject*>::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<SPObject*> 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<SPObject*>::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<Parameter *>::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 |
