summaryrefslogtreecommitdiffstats
path: root/src/live_effects
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2019-07-18 22:02:00 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2019-07-19 21:33:23 +0000
commit6a1663ece896e790ab6de408abdddaca0d2a5e5c (patch)
treedb3f9a5c5dc781e99624e54c1b5a32073a00beb3 /src/live_effects
parentImprovements finish pointed by Maren (diff)
downloadinkscape-6a1663ece896e790ab6de408abdddaca0d2a5e5c.tar.gz
inkscape-6a1663ece896e790ab6de408abdddaca0d2a5e5c.zip
Fixes for pressure pencil
Diffstat (limited to 'src/live_effects')
-rw-r--r--src/live_effects/effect.cpp4
-rw-r--r--src/live_effects/effect.h2
-rw-r--r--src/live_effects/lpe-powerstroke.cpp27
-rw-r--r--src/live_effects/lpe-powerstroke.h4
-rw-r--r--src/live_effects/lpe-simplify.cpp19
-rw-r--r--src/live_effects/lpe-simplify.h2
-rw-r--r--src/live_effects/parameter/togglebutton.cpp76
-rw-r--r--src/live_effects/parameter/togglebutton.h58
8 files changed, 96 insertions, 96 deletions
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index e547e709d..acc9dfaa9 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -1250,10 +1250,10 @@ void Effect::doAfterEffect (SPLPEItem const* /*lpeitem*/)
is_load = false;
}
-void Effect::doOnException (SPLPEItem const* /*lpeitem*/)
+void Effect::doOnException(SPLPEItem const * /*lpeitem*/)
{
has_exception = true;
- pathvector_after_effect = pathvector_before_effect;
+ pathvector_after_effect = pathvector_before_effect;
}
diff --git a/src/live_effects/effect.h b/src/live_effects/effect.h
index 6ef65fe3c..de237b8bb 100644
--- a/src/live_effects/effect.h
+++ b/src/live_effects/effect.h
@@ -75,7 +75,7 @@ public:
virtual void doBeforeEffect (SPLPEItem const* lpeitem);
virtual void doAfterEffect (SPLPEItem const* lpeitem);
- virtual void doOnException (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 5eb5afc75..fa961c9af 100644
--- a/src/live_effects/lpe-powerstroke.cpp
+++ b/src/live_effects/lpe-powerstroke.cpp
@@ -12,8 +12,8 @@
*/
#include "live_effects/lpe-powerstroke.h"
-#include "live_effects/lpe-simplify.h"
#include "live_effects/lpe-powerstroke-interpolators.h"
+#include "live_effects/lpe-simplify.h"
#include "live_effects/lpeobject.h"
#include "svg/svg-color.h"
@@ -185,7 +185,7 @@ LPEPowerStroke::LPEPowerStroke(LivePathEffectObject *lpeobject) :
scale_width.param_set_increments(0.1, 0.1);
scale_width.param_set_digits(4);
recusion_limit = 0;
- previous_size = 0;
+ has_recursion = false;
}
LPEPowerStroke::~LPEPowerStroke() = default;
@@ -194,15 +194,13 @@ 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) {
+ if (has_recursion) {
+ has_recursion = false;
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) {
@@ -765,17 +763,20 @@ LPEPowerStroke::doEffect_path (Geom::PathVector const & path_in)
return path_out;
}
-void
-LPEPowerStroke::doAfterEffect (SPLPEItem const* lpeitem){
+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());
+ 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.param_set_value(threshold);
simplify->threshold.write_to_SVG();
+ has_recursion = true;
}
}
++recusion_limit;
diff --git a/src/live_effects/lpe-powerstroke.h b/src/live_effects/lpe-powerstroke.h
index 4cb4e5a69..caf84b2db 100644
--- a/src/live_effects/lpe-powerstroke.h
+++ b/src/live_effects/lpe-powerstroke.h
@@ -42,7 +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 doAfterEffect(SPLPEItem const *lpeitem) override;
void applyStyle(SPLPEItem *lpeitem);
// methods called by path-manipulator upon edits
void adjustForNewPath(Geom::PathVector const & path_in);
@@ -59,7 +59,7 @@ private:
ScalarParam miter_limit;
EnumParam<unsigned> end_linecap_type;
size_t recusion_limit;
- size_t previous_size;
+ bool has_recursion;
};
} //namespace LivePathEffect
diff --git a/src/live_effects/lpe-simplify.cpp b/src/live_effects/lpe-simplify.cpp
index da36b184e..f101e63f2 100644
--- a/src/live_effects/lpe-simplify.cpp
+++ b/src/live_effects/lpe-simplify.cpp
@@ -19,15 +19,16 @@ namespace Inkscape {
namespace LivePathEffect {
LPESimplify::LPESimplify(LivePathEffectObject *lpeobject)
- : Effect(lpeobject),
- steps(_("Steps:"),_("Change number of simplify steps "), "steps", &wr, this,1),
- threshold(_("Roughly threshold:"), _("Roughly threshold:"), "threshold", &wr, this, 0.002),
- smooth_angles(_("Smooth angles:"), _("Max degree difference on handles to perform a smooth"), "smooth_angles", &wr, this, 0.),
- helper_size(_("Helper size:"), _("Helper size"), "helper_size", &wr, this, 5),
- 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"))
+ : Effect(lpeobject)
+ , steps(_("Steps:"), _("Change number of simplify steps "), "steps", &wr, this, 1)
+ , threshold(_("Roughly threshold:"), _("Roughly threshold:"), "threshold", &wr, this, 0.002)
+ , smooth_angles(_("Smooth angles:"), _("Max degree difference on handles to perform a smooth"), "smooth_angles",
+ &wr, this, 0.)
+ , helper_size(_("Helper size:"), _("Helper size"), "helper_size", &wr, this, 5)
+ , 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"))
{
registerParameter(&steps);
registerParameter(&threshold);
diff --git a/src/live_effects/lpe-simplify.h b/src/live_effects/lpe-simplify.h
index 08561b3e4..9eb3d15e9 100644
--- a/src/live_effects/lpe-simplify.h
+++ b/src/live_effects/lpe-simplify.h
@@ -37,7 +37,7 @@ public:
virtual void drawHandleLine(Geom::Point p,Geom::Point p2);
ScalarParam threshold;
-protected:
+ protected:
void addCanvasIndicators(SPLPEItem const */*lpeitem*/, std::vector<Geom::PathVector> &hp_vec) override;
private:
diff --git a/src/live_effects/parameter/togglebutton.cpp b/src/live_effects/parameter/togglebutton.cpp
index 555b1222a..06a67eae6 100644
--- a/src/live_effects/parameter/togglebutton.cpp
+++ b/src/live_effects/parameter/togglebutton.cpp
@@ -25,13 +25,17 @@ namespace Inkscape {
namespace LivePathEffect {
-ToggleButtonParam::ToggleButtonParam( const Glib::ustring& label, const Glib::ustring& tip,
- 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,
- 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)
+ToggleButtonParam::ToggleButtonParam(const Glib::ustring &label, const Glib::ustring &tip, 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,
+ 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)
{
checkwdg = nullptr;
}
@@ -95,33 +99,33 @@ ToggleButtonParam::param_newWidget()
false,
param_effect->getRepr(),
param_effect->getSPDoc()) );
- 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()){
- label->set_text(param_label.c_str());
- }else{
- label->set_text(inactive_label.c_str());
- }
- }
- label->show();
- if ( _icon_active ) {
- if(!_icon_inactive){
- _icon_inactive = _icon_active;
- }
- 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);
- }
- icon_button->show();
- box_button->pack_start(*icon_button, false, false, 1);
- if (!param_label.empty()) {
- box_button->pack_start (*label, false, false, 1);
- }
+ 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()) {
+ label->set_text(param_label.c_str());
+ } else {
+ label->set_text(inactive_label.c_str());
+ }
+ }
+ label->show();
+ if (_icon_active) {
+ if (!_icon_inactive) {
+ _icon_inactive = _icon_active;
+ }
+ 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);
+ }
+ icon_button->show();
+ box_button->pack_start(*icon_button, false, false, 1);
+ if (!param_label.empty()) {
+ box_button->pack_start(*label, false, false, 1);
+ }
}else{
box_button->pack_start(*label, false, false, 1);
}
@@ -149,7 +153,7 @@ ToggleButtonParam::refresh_button()
if(!box_button){
return;
}
- std::vector<Gtk::Widget*> children = 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,7 +164,7 @@ ToggleButtonParam::refresh_button()
}
}
if ( _icon_active ) {
- Gdk::Pixbuf * icon_pixbuf = nullptr;
+ Gdk::Pixbuf *icon_pixbuf = nullptr;
Gtk::Widget *im = dynamic_cast<Gtk::Image *>(children[0]);
if (!im) return;
if (!value) {
diff --git a/src/live_effects/parameter/togglebutton.h b/src/live_effects/parameter/togglebutton.h
index d21c9ac37..b76a2d7c8 100644
--- a/src/live_effects/parameter/togglebutton.h
+++ b/src/live_effects/parameter/togglebutton.h
@@ -25,37 +25,31 @@ namespace LivePathEffect {
*/
class ToggleButtonParam : public Parameter {
public:
- ToggleButtonParam( const Glib::ustring& label,
- const Glib::ustring& tip,
- const Glib::ustring& key,
- Inkscape::UI::Widget::Registry* wr,
- Effect* effect,
- bool default_value = false,
- Glib::ustring inactive_label = "",
- char const * icon_active = nullptr,
- char const * icon_inactive = nullptr,
- Gtk::BuiltinIconSize icon_size = Gtk::ICON_SIZE_SMALL_TOOLBAR);
- ~ToggleButtonParam() override;
- ToggleButtonParam(const ToggleButtonParam&) = delete;
- ToggleButtonParam& operator=(const ToggleButtonParam&) = delete;
-
- Gtk::Widget * param_newWidget() override;
-
- bool param_readSVGValue(const gchar * strvalue) override;
- gchar * param_getSVGValue() const override;
- gchar * param_getDefaultSVGValue() const override;
-
- void param_setValue(bool newvalue);
- void param_set_default() override;
-
- bool get_value() const { return value; };
-
- inline operator bool() const { return value; };
-
- sigc::signal<void>& signal_toggled() { return _signal_toggled; }
- virtual void toggled();
- void param_update_default(bool default_value);
- void param_update_default(const gchar * default_value) override;
+ ToggleButtonParam(const Glib::ustring &label, const Glib::ustring &tip, const Glib::ustring &key,
+ Inkscape::UI::Widget::Registry *wr, Effect *effect, bool default_value = false,
+ Glib::ustring inactive_label = "", char const *icon_active = nullptr,
+ char const *icon_inactive = nullptr, Gtk::BuiltinIconSize icon_size = Gtk::ICON_SIZE_SMALL_TOOLBAR);
+ ~ToggleButtonParam() override;
+ ToggleButtonParam(const ToggleButtonParam &) = delete;
+ ToggleButtonParam &operator=(const ToggleButtonParam &) = delete;
+
+ Gtk::Widget *param_newWidget() override;
+
+ bool param_readSVGValue(const gchar *strvalue) override;
+ gchar *param_getSVGValue() const override;
+ gchar *param_getDefaultSVGValue() const override;
+
+ void param_setValue(bool newvalue);
+ void param_set_default() override;
+
+ bool get_value() const { return value; };
+
+ inline operator bool() const { return value; };
+
+ sigc::signal<void> &signal_toggled() { return _signal_toggled; }
+ virtual void toggled();
+ void param_update_default(bool default_value);
+ void param_update_default(const gchar *default_value) override;
private:
void refresh_button();
@@ -64,7 +58,7 @@ private:
const Glib::ustring inactive_label;
const char * _icon_active;
const char * _icon_inactive;
- Gtk::BuiltinIconSize _icon_size;
+ Gtk::BuiltinIconSize _icon_size;
Inkscape::UI::Widget::RegisteredToggleButton * checkwdg;
sigc::signal<void> _signal_toggled;