summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2019-07-17 22:57:15 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2019-07-19 21:33:23 +0000
commit44911fb71708f71feea4c853de856a14af4fbccf (patch)
tree264c3b8651b9d58915616986792cf4cd8d117dae /src/live_effects
parentFix translations and coding style (diff)
downloadinkscape-44911fb71708f71feea4c853de856a14af4fbccf.tar.gz
inkscape-44911fb71708f71feea4c853de856a14af4fbccf.zip
Improvements finish pointed by Maren
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/effect.cpp7
-rw-r--r--src/live_effects/effect.h1
-rw-r--r--src/live_effects/lpe-powerstroke.cpp34
-rw-r--r--src/live_effects/lpe-powerstroke.h3
-rw-r--r--src/live_effects/lpe-simplify.cpp2
-rw-r--r--src/live_effects/lpe-simplify.h2
-rw-r--r--src/live_effects/parameter/togglebutton.cpp38
-rw-r--r--src/live_effects/parameter/togglebutton.h4
8 files changed, 65 insertions, 26 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index f5b291635..e547e709d 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -1250,6 +1250,13 @@ void Effect::doAfterEffect (SPLPEItem const* /*lpeitem*/)
is_load = false;
}
+void Effect::doOnException (SPLPEItem const* /*lpeitem*/)
+{
+ has_exception = true;
+ pathvector_after_effect = pathvector_before_effect;
+}
+
+
void Effect::doOnRemove (SPLPEItem const* /*lpeitem*/)
{
}
diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h
index 725aae6c4..6ef65fe3c 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -75,6 +75,7 @@ public:
virtual void doBeforeEffect (SPLPEItem const* lpeitem);
virtual void doAfterEffect (SPLPEItem const* lpeitem);
+ virtual void doOnException (SPLPEItem const* lpeitem);
virtual void doOnRemove (SPLPEItem const* lpeitem);
virtual void doOnVisibilityToggled(SPLPEItem const* lpeitem);
void writeParamsToSVG();
diff --git a/src/live_effects/lpe-powerstroke.cpp b/src/live_effects/lpe-powerstroke.cpp
index 0a13e4661..5eb5afc75 100644
--- a/src/live_effects/lpe-powerstroke.cpp
+++ b/src/live_effects/lpe-powerstroke.cpp
@@ -12,7 +12,9 @@
*/
#include "live_effects/lpe-powerstroke.h"
+#include "live_effects/lpe-simplify.h"
#include "live_effects/lpe-powerstroke-interpolators.h"
+#include "live_effects/lpeobject.h"
#include "svg/svg-color.h"
#include "desktop-style.h"
@@ -182,17 +184,25 @@ LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) :
scale_width.param_set_range(0.0, Geom::infinity());
scale_width.param_set_increments(0.1, 0.1);
scale_width.param_set_digits(4);
+ recusion_limit = 0;
+ previous_size = 0;
}
-LPEPowerStroke::~LPEPowerStroke()
-= default;
+LPEPowerStroke::~LPEPowerStroke() = default;
+
void
LPEPowerStroke::doBeforeEffect(SPLPEItem const *lpeItem)
{
offset_points.set_scale_width(scale_width);
+ size_t psize = pathvector_before_effect.size();
+ if (!is_load && previous_size != psize) {
+ adjustForNewPath(pathvector_before_effect);
+ }
+ previous_size = psize;
}
-void LPEPowerStroke::applyStyle(SPLPEItem *lpeitem)
+void
+LPEPowerStroke::applyStyle(SPLPEItem *lpeitem)
{
SPCSSAttr *css = sp_repr_css_attr_new();
if (lpeitem->style) {
@@ -755,6 +765,24 @@ LPEPowerStroke::doEffect_path (Geom::PathVector const & path_in)
return path_out;
}
+void
+LPEPowerStroke::doAfterEffect (SPLPEItem const* lpeitem){
+ is_load = false;
+ if (pathvector_before_effect[0].size() == pathvector_after_effect[0].size()) {
+ if (recusion_limit < 6) {
+ Inkscape::LivePathEffect::Effect* effect = sp_lpe_item->getPathEffectOfType(Inkscape::LivePathEffect::SIMPLIFY);
+ if(effect){
+ LivePathEffect::LPESimplify *simplify = dynamic_cast<LivePathEffect::LPESimplify*>(effect->getLPEObj()->get_lpe());
+ double threshold = simplify->threshold * 1.2;
+ simplify->threshold.param_set_value(threshold);
+ simplify->threshold.write_to_SVG();
+ }
+ }
+ ++recusion_limit;
+ } else {
+ recusion_limit = 0;
+ }
+}
/* ######################## */
diff --git a/src/live_effects/lpe-powerstroke.h b/src/live_effects/lpe-powerstroke.h
index 945a2ffe7..4cb4e5a69 100644
--- a/src/live_effects/lpe-powerstroke.h
+++ b/src/live_effects/lpe-powerstroke.h
@@ -42,6 +42,7 @@ public:
void doBeforeEffect(SPLPEItem const *lpeItem) override;
void doOnApply(SPLPEItem const* lpeitem) override;
void doOnRemove(SPLPEItem const* lpeitem) override;
+ void doAfterEffect (SPLPEItem const* lpeitem) override;
void applyStyle(SPLPEItem *lpeitem);
// methods called by path-manipulator upon edits
void adjustForNewPath(Geom::PathVector const & path_in);
@@ -57,6 +58,8 @@ private:
EnumParam<unsigned> linejoin_type;
ScalarParam miter_limit;
EnumParam<unsigned> end_linecap_type;
+ size_t recusion_limit;
+ size_t previous_size;
};
} //namespace LivePathEffect
diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp
index 56647e4e2..da36b184e 100644
--- a/src/live_effects/lpe-simplify.cpp
+++ b/src/live_effects/lpe-simplify.cpp
@@ -27,7 +27,7 @@ LPESimplify::LPESimplify(LivePathEffectObject *lpeobject)
simplify_individual_paths(_("Paths separately"), _("Simplifying paths (separately)"), "simplify_individual_paths", &wr, this, false,
"", INKSCAPE_ICON("on"), INKSCAPE_ICON("off")),
simplify_just_coalesce(_("Just coalesce"), _("Simplify just coalesce"), "simplify_just_coalesce", &wr, this, false,
- "", INKSCAPE_ICON("on"), INKSCAPE_ICON("off"))
+ "", INKSCAPE_ICON("on"), INKSCAPE_ICON("off"))
{
registerParameter(&steps);
registerParameter(&threshold);
diff --git a/src/live_effects/lpe-simplify.h b/src/live_effects/lpe-simplify.h
index a04fff76c..08561b3e4 100644
--- a/src/live_effects/lpe-simplify.h
+++ b/src/live_effects/lpe-simplify.h
@@ -35,13 +35,13 @@ public:
virtual void drawHandle(Geom::Point p);
virtual void drawHandleLine(Geom::Point p,Geom::Point p2);
+ ScalarParam threshold;
protected:
void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) override;
private:
ScalarParam steps;
- ScalarParam threshold;
ScalarParam smooth_angles;
ScalarParam helper_size;
ToggleButtonParam simplify_individual_paths;
diff --git a/src/live_effects/parameter/togglebutton.cpp b/src/live_effects/parameter/togglebutton.cpp
index bc275e876..555b1222a 100644
--- a/src/live_effects/parameter/togglebutton.cpp
+++ b/src/live_effects/parameter/togglebutton.cpp
@@ -29,7 +29,7 @@ ToggleButtonParam::ToggleButtonParam( const Glib::ustring& label, const Glib::us
const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,
Effect* effect, bool default_value, Glib::ustring inactive_label,
char const * _icon_active, char const * _icon_inactive,
- GtkIconSize _icon_size)
+ Gtk::BuiltinIconSize _icon_size)
: Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value),
inactive_label(std::move(inactive_label)), _icon_active(_icon_active), _icon_inactive(_icon_inactive), _icon_size(_icon_size)
{
@@ -95,38 +95,38 @@ ToggleButtonParam::param_newWidget()
false,
param_effect->getRepr(),
param_effect->getSPDoc()) );
- auto box_button = gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
- gtk_box_set_homogeneous(GTK_BOX(box_button), false);
- GtkWidget * label_button = gtk_label_new ("");
+ auto box_button = new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL);
+ box_button->set_homogeneous(false);
+ Gtk::Label * label = new Gtk::Label("");
if (!param_label.empty()) {
if(value || inactive_label.empty()){
- gtk_label_set_text(GTK_LABEL(label_button), param_label.c_str());
+ label->set_text(param_label.c_str());
}else{
- gtk_label_set_text(GTK_LABEL(label_button), inactive_label.c_str());
+ label->set_text(inactive_label.c_str());
}
}
- gtk_widget_show(label_button);
+ label->show();
if ( _icon_active ) {
if(!_icon_inactive){
_icon_inactive = _icon_active;
}
- gtk_widget_show(box_button);
- GtkWidget *icon_button = nullptr;
+ box_button->show();
+ Gtk::Widget *icon_button = nullptr;
if (!value) {
icon_button = sp_get_icon_image(_icon_inactive, _icon_size);
} else {
icon_button = sp_get_icon_image(_icon_active, _icon_size);
}
- gtk_widget_show(icon_button);
- gtk_box_pack_start (GTK_BOX(box_button), icon_button, false, false, 1);
+ icon_button->show();
+ box_button->pack_start(*icon_button, false, false, 1);
if (!param_label.empty()) {
- gtk_box_pack_start (GTK_BOX(box_button), label_button, false, false, 1);
+ box_button->pack_start (*label, false, false, 1);
}
}else{
- gtk_box_pack_start (GTK_BOX(box_button), label_button, false, false, 1);
+ box_button->pack_start(*label, false, false, 1);
}
- checkwdg->add(*Gtk::manage(Glib::wrap(box_button)));
+ checkwdg->add(*Gtk::manage(box_button));
checkwdg->setActive(value);
checkwdg->setProgrammatically = false;
checkwdg->set_undo_parameters(SP_VERB_DIALOG_LIVE_PATH_EFFECT, _("Change togglebutton parameter"));
@@ -145,11 +145,11 @@ ToggleButtonParam::refresh_button()
if(!checkwdg){
return;
}
- Gtk::Widget * box_button = checkwdg->get_child();
+ Gtk::Container *box_button = dynamic_cast<Gtk::Container *>(checkwdg->get_child());
if(!box_button){
return;
}
- std::vector<Gtk::Widget*> children = Glib::wrap(GTK_CONTAINER(box_button))->get_children();
+ std::vector<Gtk::Widget*> children = box_button->get_children();
if (!param_label.empty()) {
Gtk::Label *lab = dynamic_cast<Gtk::Label*>(children[children.size()-1]);
if (!lab) return;
@@ -160,13 +160,13 @@ ToggleButtonParam::refresh_button()
}
}
if ( _icon_active ) {
- GdkPixbuf * icon_pixbuf = nullptr;
+ Gdk::Pixbuf * icon_pixbuf = nullptr;
Gtk::Widget *im = dynamic_cast<Gtk::Image *>(children[0]);
if (!im) return;
if (!value) {
- im = Glib::wrap(sp_get_icon_image(_icon_inactive, _icon_size));
+ im = sp_get_icon_image(_icon_inactive, _icon_size);
} else {
- im = Glib::wrap(sp_get_icon_image(_icon_active, _icon_size));
+ im = sp_get_icon_image(_icon_active, _icon_size);
}
}
}
diff --git a/src/live_effects/parameter/togglebutton.h b/src/live_effects/parameter/togglebutton.h
index d1845de5b..d21c9ac37 100644
--- a/src/live_effects/parameter/togglebutton.h
+++ b/src/live_effects/parameter/togglebutton.h
@@ -34,7 +34,7 @@ public:
Glib::ustring inactive_label = "",
char const * icon_active = nullptr,
char const * icon_inactive = nullptr,
- GtkIconSize icon_size = GTK_ICON_SIZE_SMALL_TOOLBAR);
+ Gtk::BuiltinIconSize icon_size = Gtk::ICON_SIZE_SMALL_TOOLBAR);
~ToggleButtonParam() override;
ToggleButtonParam(const ToggleButtonParam&) = delete;
ToggleButtonParam& operator=(const ToggleButtonParam&) = delete;
@@ -64,7 +64,7 @@ private:
const Glib::ustring inactive_label;
const char * _icon_active;
const char * _icon_inactive;
- GtkIconSize _icon_size;
+ Gtk::BuiltinIconSize _icon_size;
Inkscape::UI::Widget::RegisteredToggleButton * checkwdg;
sigc::signal<void> _signal_toggled;