From 212bed15e375396b2ceb7a19841af6c6c67d8a58 Mon Sep 17 00:00:00 2001 From: Jabiertxof Date: Mon, 18 Feb 2019 19:16:22 +0100 Subject: Update issues on CI --- src/desktop.cpp | 6 +- src/live_effects/effect-enum.h | 5 +- src/live_effects/effect.cpp | 16 +-- src/live_effects/lpe-dashed-stroke.cpp | 32 +++--- src/live_effects/lpe-dashed-stroke.h | 2 +- src/ui/dialog/livepatheffect-add.cpp | 185 ++++++++++++++++++-------------- src/ui/dialog/livepatheffect-add.h | 50 ++++----- src/ui/dialog/livepatheffect-editor.cpp | 3 +- 8 files changed, 158 insertions(+), 141 deletions(-) (limited to 'src') diff --git a/src/desktop.cpp b/src/desktop.cpp index 52abef1f3..db861b796 100644 --- a/src/desktop.cpp +++ b/src/desktop.cpp @@ -1300,11 +1300,7 @@ SPDesktop::iconify() _widget->setIconified(); } -bool -SPDesktop::is_darktheme() -{ - return getToplevel()->get_style_context()->has_class("dark"); -} +bool SPDesktop::is_darktheme() { return getToplevel()->get_style_context()->has_class("dark"); } bool SPDesktop::is_maximized() diff --git a/src/live_effects/effect-enum.h b/src/live_effects/effect-enum.h index 3ac25bd18..887f02343 100644 --- a/src/live_effects/effect-enum.h +++ b/src/live_effects/effect-enum.h @@ -72,7 +72,8 @@ enum EffectType { RECURSIVE_SKELETON, TANGENT_TO_CURVE, TEXT_LABEL, - INVALID_LPE // This must be last (I made it such that it is not needed anymore I think..., Don't trust on it being last. - johan) + INVALID_LPE // This must be last (I made it such that it is not needed anymore I think..., Don't trust on it being + // last. - johan) }; template @@ -267,7 +268,7 @@ class EnumEffectDataConverter { const EnumEffectData *_data; }; -extern const EnumEffectData LPETypeData[]; /// defined in effect.cpp +extern const EnumEffectData LPETypeData[]; /// defined in effect.cpp extern const EnumEffectDataConverter LPETypeConverter; /// defined in effect.cpp } //namespace LivePathEffect diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp index ca166c0c2..63895ed61 100644 --- a/src/live_effects/effect.cpp +++ b/src/live_effects/effect.cpp @@ -13,10 +13,10 @@ //#define LPE_ENABLE_TEST_EFFECTS //uncomment for toy effects // include effects: -#include "live_effects/lpe-patternalongpath.h" #include "live_effects/lpe-angle_bisector.h" #include "live_effects/lpe-attach-path.h" #include "live_effects/lpe-bendpath.h" +#include "live_effects/lpe-bool.h" #include "live_effects/lpe-bounding-box.h" #include "live_effects/lpe-bspline.h" #include "live_effects/lpe-circle_3pts.h" @@ -28,6 +28,7 @@ #include "live_effects/lpe-dashed-stroke.h" #include "live_effects/lpe-dynastroke.h" #include "live_effects/lpe-ellipse_5pts.h" +#include "live_effects/lpe-embrodery-stitch.h" #include "live_effects/lpe-envelope.h" #include "live_effects/lpe-extrude.h" #include "live_effects/lpe-fill-between-many.h" @@ -38,36 +39,35 @@ #include "live_effects/lpe-interpolate_points.h" #include "live_effects/lpe-jointype.h" #include "live_effects/lpe-knot.h" -#include "live_effects/lpe-lattice2.h" #include "live_effects/lpe-lattice.h" +#include "live_effects/lpe-lattice2.h" #include "live_effects/lpe-line_segment.h" #include "live_effects/lpe-measure-segments.h" #include "live_effects/lpe-mirror_symmetry.h" #include "live_effects/lpe-offset.h" #include "live_effects/lpe-parallel.h" #include "live_effects/lpe-path_length.h" +#include "live_effects/lpe-patternalongpath.h" #include "live_effects/lpe-perp_bisector.h" #include "live_effects/lpe-perspective-envelope.h" #include "live_effects/lpe-powerclip.h" #include "live_effects/lpe-powermask.h" #include "live_effects/lpe-powerstroke.h" +#include "live_effects/lpe-pts2ellipse.h" #include "live_effects/lpe-recursiveskeleton.h" -#include "live_effects/lpe-roughen.h" #include "live_effects/lpe-rough-hatches.h" +#include "live_effects/lpe-roughen.h" #include "live_effects/lpe-ruler.h" #include "live_effects/lpe-show_handles.h" #include "live_effects/lpe-simplify.h" #include "live_effects/lpe-sketch.h" #include "live_effects/lpe-spiro.h" #include "live_effects/lpe-tangent_to_curve.h" -#include "live_effects/lpe-transform_2pts.h" #include "live_effects/lpe-taperstroke.h" #include "live_effects/lpe-test-doEffect-stack.h" #include "live_effects/lpe-text_label.h" +#include "live_effects/lpe-transform_2pts.h" #include "live_effects/lpe-vonkoch.h" -#include "live_effects/lpe-embrodery-stitch.h" -#include "live_effects/lpe-bool.h" -#include "live_effects/lpe-pts2ellipse.h" #include "live_effects/lpeobject.h" @@ -1060,7 +1060,7 @@ Effect::New(EffectType lpenr, LivePathEffectObject *lpeobj) neweffect = static_cast ( new LPEPts2Ellipse(lpeobj) ); break; case DASHED_STROKE: - neweffect = static_cast ( new LPEDashedStroke(lpeobj) ); + neweffect = static_cast(new LPEDashedStroke(lpeobj)); break; default: g_warning("LivePathEffect::Effect::New called with invalid patheffect type (%d)", lpenr); diff --git a/src/live_effects/lpe-dashed-stroke.cpp b/src/live_effects/lpe-dashed-stroke.cpp index fcc38f9e4..fe6390430 100644 --- a/src/live_effects/lpe-dashed-stroke.cpp +++ b/src/live_effects/lpe-dashed-stroke.cpp @@ -3,8 +3,8 @@ * Released under GNU GPL v2+, read the file 'COPYING' for more information. */ #include "live_effects/lpe-dashed-stroke.h" -#include "2geom/pathvector.h" #include "2geom/path.h" +#include "2geom/pathvector.h" #include "helper/geom.h" // TODO due to internal breakage in glibmm headers, this must be last: @@ -14,13 +14,15 @@ namespace Inkscape { namespace LivePathEffect { LPEDashedStroke::LPEDashedStroke(LivePathEffectObject *lpeobject) - : Effect(lpeobject), - numberdashes(_("Number of dashes"), _("Number of dashes"), "numberdashes", &wr, this, 3), - holefactor(_("Hole factor"), _("Hole factor"), "holefactor", &wr, this, 0.0), - splitsegments(_("Use segments"), _("Use segments"), "splitsegments", &wr, this, true), - halfextreme(_("Half start/end"), _("Start and end of each segment has half size"), "halfextreme", &wr, this, true), - unifysegment(_("Unify dashes"), _("Approximately unify the dashes length using the minimal length segment"), "unifysegment", &wr, this, true), - message(_("Info Box"), _("Important messages"), "message", &wr, this, _("Add \"Fill Between Many LPE\" to add fill.")) + : Effect(lpeobject) + , numberdashes(_("Number of dashes"), _("Number of dashes"), "numberdashes", &wr, this, 3) + , holefactor(_("Hole factor"), _("Hole factor"), "holefactor", &wr, this, 0.0) + , splitsegments(_("Use segments"), _("Use segments"), "splitsegments", &wr, this, true) + , halfextreme(_("Half start/end"), _("Start and end of each segment has half size"), "halfextreme", &wr, this, true) + , unifysegment(_("Unify dashes"), _("Approximately unify the dashes length using the minimal length segment"), + "unifysegment", &wr, this, true) + , message(_("Info Box"), _("Important messages"), "message", &wr, this, + _("Add \"Fill Between Many LPE\" to add fill.")) { registerParameter(&numberdashes); registerParameter(&holefactor); @@ -39,14 +41,11 @@ LPEDashedStroke::LPEDashedStroke(LivePathEffectObject *lpeobject) LPEDashedStroke::~LPEDashedStroke() = default; -void -LPEDashedStroke::doBeforeEffect (SPLPEItem const* lpeitem){ -} +void LPEDashedStroke::doBeforeEffect(SPLPEItem const *lpeitem) {} ///Calculate the time in curve_in with a real time of A //TODO: find a better place to it -double -LPEDashedStroke::timeAtLength(double const A, Geom::Path const &segment) +double LPEDashedStroke::timeAtLength(double const A, Geom::Path const &segment) { if ( A == 0 || segment[0].isDegenerate()) { return 0; @@ -58,8 +57,7 @@ LPEDashedStroke::timeAtLength(double const A, Geom::Path const &segment) ///Calculate the time in curve_in with a real time of A //TODO: find a better place to it -double -LPEDashedStroke::timeAtLength(double const A, Geom::Piecewise > pwd2) +double LPEDashedStroke::timeAtLength(double const A, Geom::Piecewise> pwd2) { if ( A == 0 || pwd2.size() == 0) { return 0; @@ -73,8 +71,8 @@ LPEDashedStroke::timeAtLength(double const A, Geom::Piecewise +#include "preferences.h" +#include #include namespace Inkscape { namespace UI { namespace Dialog { -bool sp_has_fav(Glib::ustring effect){ +bool sp_has_fav(Glib::ustring effect) +{ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Glib::ustring favlist = prefs->getString("/dialogs/livepatheffect/favs"); size_t pos = favlist.find(effect); - if (pos != std::string::npos){ + if (pos != std::string::npos) { return true; } return false; } -void sp_add_fav(Glib::ustring effect){ +void sp_add_fav(Glib::ustring effect) +{ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Glib::ustring favlist = prefs->getString("/dialogs/livepatheffect/favs"); if (!sp_has_fav(effect)) { @@ -46,31 +48,29 @@ void sp_add_fav(Glib::ustring effect){ } } -void sp_remove_fav(Glib::ustring effect){ +void sp_remove_fav(Glib::ustring effect) +{ Inkscape::Preferences *prefs = Inkscape::Preferences::get(); Glib::ustring favlist = prefs->getString("/dialogs/livepatheffect/favs"); effect += ";"; size_t pos = favlist.find(effect); - if (pos != std::string::npos) - { - favlist.erase(pos, effect.length()); + if (pos != std::string::npos) { + favlist.erase(pos, effect.length()); prefs->setString("/dialogs/livepatheffect/favs", favlist); - } + } } -bool -LivePathEffectAdd::mouseover(GdkEventCrossing* evt, GtkWidget *wdg) +bool LivePathEffectAdd::mouseover(GdkEventCrossing *evt, GtkWidget *wdg) { GdkDisplay *display = gdk_display_get_default(); - GdkCursor *cursor = gdk_cursor_new_for_display(display, GDK_HAND2); + GdkCursor *cursor = gdk_cursor_new_for_display(display, GDK_HAND2); GdkWindow *window = gtk_widget_get_window(wdg); gdk_window_set_cursor(window, cursor); g_object_unref(cursor); return true; } -bool -LivePathEffectAdd::mouseout(GdkEventCrossing* evt, GtkWidget *wdg) +bool LivePathEffectAdd::mouseout(GdkEventCrossing *evt, GtkWidget *wdg) { GdkWindow *window = gtk_widget_get_window(wdg); gdk_window_set_cursor(window, nullptr); @@ -100,7 +100,8 @@ LivePathEffectAdd::LivePathEffectAdd() _builder->get_widget("LPESelectorEffectInfoEventBox", _LPESelectorEffectInfoEventBox); _LPEFilter->signal_search_changed().connect(sigc::mem_fun(*this, &LivePathEffectAdd::on_search)); _LPESelectorFlowBox->signal_child_activated().connect(sigc::mem_fun(*this, &LivePathEffectAdd::on_activate)); - _LPEDialogSelector->add_events(Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK ); + _LPEDialogSelector->add_events(Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | + Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK); Glib::ustring effectgladefile = get_filename(Inkscape::IO::Resource::UIS, "dialog-livepatheffect-add-effect.ui"); for (int i = 0; i < static_cast(converter._length); ++i) { Glib::RefPtr builder_effect; @@ -113,7 +114,9 @@ LivePathEffectAdd::LivePathEffectAdd() const LivePathEffect::EnumEffectData *data = &converter.data(i); Gtk::EventBox *LPESelectorEffect; builder_effect->get_widget("LPESelectorEffect", LPESelectorEffect); - LPESelectorEffect->signal_button_press_event().connect(sigc::bind, const LivePathEffect::EnumEffectData * >(sigc::mem_fun(*this, &LivePathEffectAdd::apply), builder_effect, &converter.data(i))); + LPESelectorEffect->signal_button_press_event().connect( + sigc::bind, const LivePathEffect::EnumEffectData *>( + sigc::mem_fun(*this, &LivePathEffectAdd::apply), builder_effect, &converter.data(i))); Gtk::Label *LPEName; builder_effect->get_widget("LPEName", LPEName); const Glib::ustring label = converter.get_label(data->id); @@ -128,52 +131,70 @@ LivePathEffectAdd::LivePathEffectAdd() LPEDescription->set_text(converter.get_description(data->id)); Gtk::ToggleButton *LPEExperimental; builder_effect->get_widget("LPEExperimental", LPEExperimental); - bool active = converter.get_experimental(data->id)?true:false; + bool active = converter.get_experimental(data->id) ? true : false; LPEExperimental->set_active(active); Gtk::Image *LPEIcon; builder_effect->get_widget("LPEIcon", LPEIcon); LPEIcon->set_from_icon_name(converter.get_icon(data->id), Gtk::BuiltinIconSize(Gtk::ICON_SIZE_DIALOG)); Gtk::EventBox *LPESelectorEffectEventInfo; builder_effect->get_widget("LPESelectorEffectEventInfo", LPESelectorEffectEventInfo); - LPESelectorEffectEventInfo->signal_button_press_event().connect(sigc::bind >(sigc::mem_fun(*this, &LivePathEffectAdd::pop_description), builder_effect)); + LPESelectorEffectEventInfo->signal_button_press_event().connect(sigc::bind>( + sigc::mem_fun(*this, &LivePathEffectAdd::pop_description), builder_effect)); Gtk::EventBox *LPESelectorEffectEventFav; builder_effect->get_widget("LPESelectorEffectEventFav", LPESelectorEffectEventFav); - if (sp_has_fav(LPEName->get_text())){ + if (sp_has_fav(LPEName->get_text())) { Gtk::Image *fav = dynamic_cast(LPESelectorEffectEventFav->get_child()); fav->set_from_icon_name("draw-star", Gtk::IconSize(25)); } Gtk::EventBox *LPESelectorEffectEventFavTop; builder_effect->get_widget("LPESelectorEffectEventFavTop", LPESelectorEffectEventFavTop); - LPESelectorEffectEventFav->signal_button_press_event().connect(sigc::bind >(sigc::mem_fun(*this, &LivePathEffectAdd::fav_toggler), builder_effect)); - LPESelectorEffectEventFavTop->signal_button_press_event().connect(sigc::bind >(sigc::mem_fun(*this, &LivePathEffectAdd::fav_toggler), builder_effect)); - + LPESelectorEffectEventFav->signal_button_press_event().connect(sigc::bind>( + sigc::mem_fun(*this, &LivePathEffectAdd::fav_toggler), builder_effect)); + LPESelectorEffectEventFavTop->signal_button_press_event().connect(sigc::bind>( + sigc::mem_fun(*this, &LivePathEffectAdd::fav_toggler), builder_effect)); + Gtk::EventBox *LPESelectorEffectEventApply; builder_effect->get_widget("LPESelectorEffectEventApply", LPESelectorEffectEventApply); - LPESelectorEffectEventApply->signal_button_press_event().connect(sigc::bind, const LivePathEffect::EnumEffectData * >(sigc::mem_fun(*this, &LivePathEffectAdd::apply), builder_effect, &converter.data(i))); - LPESelectorEffectEventApply->signal_enter_notify_event().connect(sigc::bind(sigc::mem_fun(*this, &LivePathEffectAdd::mouseover), GTK_WIDGET(LPESelectorEffectEventApply->gobj()))); - LPESelectorEffectEventApply->signal_leave_notify_event().connect(sigc::bind(sigc::mem_fun(*this, &LivePathEffectAdd::mouseout), GTK_WIDGET(LPESelectorEffectEventApply->gobj()))); + LPESelectorEffectEventApply->signal_button_press_event().connect( + sigc::bind, const LivePathEffect::EnumEffectData *>( + sigc::mem_fun(*this, &LivePathEffectAdd::apply), builder_effect, &converter.data(i))); + LPESelectorEffectEventApply->signal_enter_notify_event().connect(sigc::bind( + sigc::mem_fun(*this, &LivePathEffectAdd::mouseover), GTK_WIDGET(LPESelectorEffectEventApply->gobj()))); + LPESelectorEffectEventApply->signal_leave_notify_event().connect(sigc::bind( + sigc::mem_fun(*this, &LivePathEffectAdd::mouseout), GTK_WIDGET(LPESelectorEffectEventApply->gobj()))); Gtk::ButtonBox *LPESelectorButtonBox; builder_effect->get_widget("LPESelectorButtonBox", LPESelectorButtonBox); - LPESelectorButtonBox->signal_enter_notify_event().connect(sigc::bind(sigc::mem_fun(*this, &LivePathEffectAdd::mouseover), GTK_WIDGET(LPESelectorEffect->gobj()))); - LPESelectorButtonBox->signal_leave_notify_event().connect(sigc::bind(sigc::mem_fun(*this, &LivePathEffectAdd::mouseout), GTK_WIDGET(LPESelectorEffect->gobj()))); - LPESelectorEffect->signal_enter_notify_event().connect(sigc::bind(sigc::mem_fun(*this, &LivePathEffectAdd::mouseover), GTK_WIDGET(LPESelectorEffect->gobj()))); - LPESelectorEffect->signal_leave_notify_event().connect(sigc::bind(sigc::mem_fun(*this, &LivePathEffectAdd::mouseout), GTK_WIDGET(LPESelectorEffect->gobj()))); + LPESelectorButtonBox->signal_enter_notify_event().connect(sigc::bind( + sigc::mem_fun(*this, &LivePathEffectAdd::mouseover), GTK_WIDGET(LPESelectorEffect->gobj()))); + LPESelectorButtonBox->signal_leave_notify_event().connect(sigc::bind( + sigc::mem_fun(*this, &LivePathEffectAdd::mouseout), GTK_WIDGET(LPESelectorEffect->gobj()))); + LPESelectorEffect->signal_enter_notify_event().connect(sigc::bind( + sigc::mem_fun(*this, &LivePathEffectAdd::mouseover), GTK_WIDGET(LPESelectorEffect->gobj()))); + LPESelectorEffect->signal_leave_notify_event().connect(sigc::bind( + sigc::mem_fun(*this, &LivePathEffectAdd::mouseout), GTK_WIDGET(LPESelectorEffect->gobj()))); _LPESelectorFlowBox->insert(*LPESelectorEffect, i); - LPESelectorEffect->get_parent()->get_style_context()->add_class(("LPEIndex" + Glib::ustring::format(i)).c_str()); + LPESelectorEffect->get_parent()->get_style_context()->add_class( + ("LPEIndex" + Glib::ustring::format(i)).c_str()); } _visiblelpe = _LPESelectorFlowBox->get_children().size(); _LPEInfo->set_visible(false); - _LPESelectorEffectEventFavShow->signal_enter_notify_event().connect(sigc::bind(sigc::mem_fun(*this, &LivePathEffectAdd::mouseover), GTK_WIDGET(_LPESelectorEffectEventFavShow->gobj()))); - _LPESelectorEffectEventFavShow->signal_leave_notify_event().connect(sigc::bind(sigc::mem_fun(*this, &LivePathEffectAdd::mouseout), GTK_WIDGET(_LPESelectorEffectEventFavShow->gobj()))); - _LPESelectorEffectEventFavShow->signal_button_press_event().connect(sigc::mem_fun(*this, &LivePathEffectAdd::show_fav_toggler)); - _LPESelectorEffectInfoEventBox->signal_button_press_event().connect(sigc::mem_fun(*this, &LivePathEffectAdd::hide_pop_description)); - _LPESelectorEffectInfoEventBox->signal_enter_notify_event().connect(sigc::bind(sigc::mem_fun(*this, &LivePathEffectAdd::mouseover), GTK_WIDGET(_LPESelectorEffectInfoEventBox->gobj()))); - _LPESelectorEffectInfoEventBox->signal_leave_notify_event().connect(sigc::bind(sigc::mem_fun(*this, &LivePathEffectAdd::mouseout), GTK_WIDGET(_LPESelectorEffectInfoEventBox->gobj()))); - _LPEExperimental->property_active().signal_changed().connect(sigc::mem_fun(*this, &LivePathEffectAdd::reload_effect_list)); + _LPESelectorEffectEventFavShow->signal_enter_notify_event().connect(sigc::bind( + sigc::mem_fun(*this, &LivePathEffectAdd::mouseover), GTK_WIDGET(_LPESelectorEffectEventFavShow->gobj()))); + _LPESelectorEffectEventFavShow->signal_leave_notify_event().connect(sigc::bind( + sigc::mem_fun(*this, &LivePathEffectAdd::mouseout), GTK_WIDGET(_LPESelectorEffectEventFavShow->gobj()))); + _LPESelectorEffectEventFavShow->signal_button_press_event().connect( + sigc::mem_fun(*this, &LivePathEffectAdd::show_fav_toggler)); + _LPESelectorEffectInfoEventBox->signal_button_press_event().connect( + sigc::mem_fun(*this, &LivePathEffectAdd::hide_pop_description)); + _LPESelectorEffectInfoEventBox->signal_enter_notify_event().connect(sigc::bind( + sigc::mem_fun(*this, &LivePathEffectAdd::mouseover), GTK_WIDGET(_LPESelectorEffectInfoEventBox->gobj()))); + _LPESelectorEffectInfoEventBox->signal_leave_notify_event().connect(sigc::bind( + sigc::mem_fun(*this, &LivePathEffectAdd::mouseout), GTK_WIDGET(_LPESelectorEffectInfoEventBox->gobj()))); + _LPEExperimental->property_active().signal_changed().connect( + sigc::mem_fun(*this, &LivePathEffectAdd::reload_effect_list)); _LPEDialogSelector->show_all_children(); } -const LivePathEffect::EnumEffectData* -LivePathEffectAdd::getActiveData() +const LivePathEffect::EnumEffectData *LivePathEffectAdd::getActiveData() { return instance()._to_add; } @@ -202,43 +223,43 @@ void LivePathEffectAdd::on_activate(Gtk::FlowBoxChild *child) child->show_all_children(); } -bool LivePathEffectAdd::pop_description(GdkEventButton* evt, Glib::RefPtr builder_effect) +bool LivePathEffectAdd::pop_description(GdkEventButton *evt, Glib::RefPtr builder_effect) { Gtk::Image *LPESelectorEffectInfo; builder_effect->get_widget("LPESelectorEffectInfo", LPESelectorEffectInfo); _LPESelectorEffectInfoPop->set_relative_to(*LPESelectorEffectInfo); - + Gtk::Label *LPEName; builder_effect->get_widget("LPEName", LPEName); Gtk::Label *LPEDescription; builder_effect->get_widget("LPEDescription", LPEDescription); Gtk::Image *LPEIcon; - builder_effect->get_widget("LPEIcon", LPEIcon); + builder_effect->get_widget("LPEIcon", LPEIcon); Gtk::Image *LPESelectorEffectInfoIcon; _builder->get_widget("LPESelectorEffectInfoIcon", LPESelectorEffectInfoIcon); LPESelectorEffectInfoIcon->set_from_icon_name(LPEIcon->get_icon_name(), Gtk::IconSize(60)); - + Gtk::Label *LPESelectorEffectInfoName; _builder->get_widget("LPESelectorEffectInfoName", LPESelectorEffectInfoName); LPESelectorEffectInfoName->set_text(LPEName->get_text()); - + Gtk::Label *LPESelectorEffectInfoDescription; _builder->get_widget("LPESelectorEffectInfoDescription", LPESelectorEffectInfoDescription); LPESelectorEffectInfoDescription->set_text(LPEDescription->get_text()); - + _LPESelectorEffectInfoPop->show(); - + return true; } -bool LivePathEffectAdd::hide_pop_description(GdkEventButton* evt) +bool LivePathEffectAdd::hide_pop_description(GdkEventButton *evt) { _LPESelectorEffectInfoPop->hide(); return true; } -bool LivePathEffectAdd::fav_toggler(GdkEventButton* evt, Glib::RefPtr builder_effect) +bool LivePathEffectAdd::fav_toggler(GdkEventButton *evt, Glib::RefPtr builder_effect) { Gtk::EventBox *LPESelectorEffect; builder_effect->get_widget("LPESelectorEffect", LPESelectorEffect); @@ -249,13 +270,13 @@ bool LivePathEffectAdd::fav_toggler(GdkEventButton* evt, Glib::RefPtrget_widget("LPESelectorEffectEventFavTop", LPESelectorEffectEventFavTop); if (LPESelectorEffectFav && LPESelectorEffectEventFavTop) { - if (sp_has_fav(LPEName->get_text())){ + if (sp_has_fav(LPEName->get_text())) { LPESelectorEffectEventFavTop->set_visible(false); LPESelectorEffectEventFavTop->hide(); LPESelectorEffectFav->set_from_icon_name("draw-star-outline", Gtk::IconSize(25)); sp_remove_fav(LPEName->get_text()); LPESelectorEffect->get_parent()->get_style_context()->remove_class("lpefav"); - if (_showfavs){ + if (_showfavs) { reload_effect_list(); } } else { @@ -269,7 +290,7 @@ bool LivePathEffectAdd::fav_toggler(GdkEventButton* evt, Glib::RefPtr(_LPESelectorEffectEventFavShow->get_child()); @@ -284,15 +305,15 @@ bool LivePathEffectAdd::show_fav_toggler(GdkEventButton* evt) return true; } -bool LivePathEffectAdd::apply(GdkEventButton* evt, Glib::RefPtr builder_effect, const LivePathEffect::EnumEffectData* to_add) +bool LivePathEffectAdd::apply(GdkEventButton *evt, Glib::RefPtr builder_effect, + const LivePathEffect::EnumEffectData *to_add) { _to_add = to_add; Gtk::EventBox *LPESelectorEffect; builder_effect->get_widget("LPESelectorEffect", LPESelectorEffect); - if(!LPESelectorEffect->get_parent()->get_style_context()->has_class("lpeactive") || - LPESelectorEffect->get_parent()->get_style_context()->has_class("lpedisabled")) - { - Gtk::FlowBoxChild * child = dynamic_cast(LPESelectorEffect->get_parent()); + if (!LPESelectorEffect->get_parent()->get_style_context()->has_class("lpeactive") || + LPESelectorEffect->get_parent()->get_style_context()->has_class("lpedisabled")) { + Gtk::FlowBoxChild *child = dynamic_cast(LPESelectorEffect->get_parent()); if (child) { on_activate(child); } @@ -310,10 +331,10 @@ bool LivePathEffectAdd::on_filter(Gtk::FlowBoxChild *child) { std::vector classes = child->get_style_context()->list_classes(); int pos = 0; - for (auto childclass:classes) { + for (auto childclass : classes) { size_t s = childclass.find("LPEIndex", 0); if (s != -1) { - childclass = childclass.erase(0,8); + childclass = childclass.erase(0, 8); pos = std::stoi(childclass); } } @@ -338,7 +359,7 @@ bool LivePathEffectAdd::on_filter(Gtk::FlowBoxChild *child) if (box) { std::vector contents = box->get_children(); Gtk::Label *lpename = dynamic_cast(contents[1]); - if (!sp_has_fav(lpename->get_text()) && _showfavs){ + if (!sp_has_fav(lpename->get_text()) && _showfavs) { return false; } Gtk::ToggleButton *experimental = dynamic_cast(contents[3]); @@ -443,7 +464,7 @@ int LivePathEffectAdd::on_sort(Gtk::FlowBoxChild *child1, Gtk::FlowBoxChild *chi std::vector contents_overlay = overlay->get_children(); Gtk::EventBox *LPESelectorEffectEventFavTop = dynamic_cast(contents_overlay[1]); if (LPESelectorEffectEventFavTop) { - if (sp_has_fav(name1)){ + if (sp_has_fav(name1)) { LPESelectorEffectEventFavTop->set_visible(true); LPESelectorEffectEventFavTop->show(); child1->get_style_context()->add_class("lpefav"); @@ -465,18 +486,18 @@ int LivePathEffectAdd::on_sort(Gtk::FlowBoxChild *child1, Gtk::FlowBoxChild *chi name2 = lpename->get_text(); } } - + std::vector effect; effect.push_back(name1); effect.push_back(name2); sort(effect.begin(), effect.end()); -/* if (sp_has_fav(name1) && sp_has_fav(name2)) { - return effect[0] == name1?-1:1; - } - if (sp_has_fav(name1)) { - return -1; - } */ - if (effect[0] == name1) {//&& !sp_has_fav(name2)) { + /* if (sp_has_fav(name1) && sp_has_fav(name2)) { + return effect[0] == name1?-1:1; + } + if (sp_has_fav(name1)) { + return -1; + } */ + if (effect[0] == name1) { //&& !sp_has_fav(name2)) { return -1; } return 1; @@ -485,10 +506,10 @@ int LivePathEffectAdd::on_sort(Gtk::FlowBoxChild *child1, Gtk::FlowBoxChild *chi void LivePathEffectAdd::onClose() { _LPEDialogSelector->hide(); } -void LivePathEffectAdd::onKeyEvent(GdkEventKey* evt) +void LivePathEffectAdd::onKeyEvent(GdkEventKey *evt) { if (evt->keyval == GDK_KEY_Escape) { - onClose(); + onClose(); } } @@ -496,18 +517,18 @@ void LivePathEffectAdd::show(SPDesktop *desktop) { LivePathEffectAdd &dial = instance(); Inkscape::Selection *sel = desktop->getSelection(); - if ( sel && !sel->isEmpty() ) { + if (sel && !sel->isEmpty()) { SPItem *item = sel->singleItem(); if (item) { SPShape *shape = dynamic_cast(item); - SPPath *path = dynamic_cast(item); + SPPath *path = dynamic_cast(item); SPGroup *group = dynamic_cast(item); dial._item_type = ""; if (group) { dial._item_type = "group"; } else if (path) { dial._item_type = "path"; - } else if (shape){ + } else if (shape) { dial._item_type = "shape"; } else { dial._LPEDialogSelector->hide(); @@ -519,20 +540,20 @@ void LivePathEffectAdd::show(SPDesktop *desktop) int height; int width_2; int height_2; - dial._LPEDialogSelector->get_default_size (width_2, height_2); - dial._LPEDialogSelector->get_size (width, height); - if( width == width_2 && height == height_2 ){ + dial._LPEDialogSelector->get_default_size(width_2, height_2); + dial._LPEDialogSelector->get_size(width, height); + if (width == width_2 && height == height_2) { Gtk::Window *window = desktop->getToplevel(); - window->get_size (width, height); + window->get_size(width, height); std::cout << "dsdgsgdsdgsgdgdsgsdgsdgds" << std::endl; - dial._LPEDialogSelector->resize(std::min( width - 300, 1440), std::min( height - 300, 900)); + dial._LPEDialogSelector->resize(std::min(width - 300, 1440), std::min(height - 300, 900)); } - dial._applied=false; + dial._applied = false; dial._LPESelectorFlowBox->unset_sort_func(); dial._LPESelectorFlowBox->unset_filter_func(); dial._LPESelectorFlowBox->set_filter_func(sigc::mem_fun(dial, &LivePathEffectAdd::on_filter)); dial._LPESelectorFlowBox->set_sort_func(sigc::mem_fun(dial, &LivePathEffectAdd::on_sort)); - Glib::RefPtr< Gtk::Adjustment > vadjust = dial._LPEScrolled->get_vadjustment(); + Glib::RefPtr vadjust = dial._LPEScrolled->get_vadjustment(); vadjust->set_value(vadjust->get_lower()); dial._LPEDialogSelector->run(); dial._LPEDialogSelector->hide(); diff --git a/src/ui/dialog/livepatheffect-add.h b/src/ui/dialog/livepatheffect-add.h index 28c2c8b5b..d1767ca3e 100644 --- a/src/ui/dialog/livepatheffect-add.h +++ b/src/ui/dialog/livepatheffect-add.h @@ -13,22 +13,22 @@ #define INKSCAPE_DIALOG_LIVEPATHEFFECT_ADD_H #include "live_effects/effect-enum.h" +#include #include #include -#include -#include #include -#include +#include #include -#include #include -#include +#include #include +#include +#include +#include #include -#include #include -#include -#include +#include +#include class SPDesktop; @@ -41,9 +41,10 @@ namespace Dialog { * */ class LivePathEffectAdd { -public: + public: LivePathEffectAdd(); - ~LivePathEffectAdd()= default;; + ~LivePathEffectAdd() = default; + ; /** * Show the dialog @@ -52,11 +53,9 @@ public: /** * Returns true is the "Add" button was pressed */ - static bool isApplied() { - return instance()._applied; - } + static bool isApplied() { return instance()._applied; } - static const LivePathEffect::EnumEffectData* getActiveData(); + static const LivePathEffect::EnumEffectData *getActiveData(); protected: /** @@ -64,16 +63,17 @@ public: */ void onClose(); bool on_filter(Gtk::FlowBoxChild *child); - int on_sort(Gtk::FlowBoxChild *child1, Gtk::FlowBoxChild *child2); + int on_sort(Gtk::FlowBoxChild *child1, Gtk::FlowBoxChild *child2); void on_search(); void on_activate(Gtk::FlowBoxChild *child); - bool pop_description(GdkEventButton* evt, Glib::RefPtr builder_effect); - bool hide_pop_description(GdkEventButton* evt); - bool fav_toggler(GdkEventButton* evt, Glib::RefPtr builder_effect); - bool apply(GdkEventButton* evt, Glib::RefPtr builder_effect, const LivePathEffect::EnumEffectData* to_add); - bool show_fav_toggler(GdkEventButton* evt); - bool mouseover(GdkEventCrossing* evt, GtkWidget *wdg); - bool mouseout(GdkEventCrossing* evt, GtkWidget *wdg); + bool pop_description(GdkEventButton *evt, Glib::RefPtr builder_effect); + bool hide_pop_description(GdkEventButton *evt); + bool fav_toggler(GdkEventButton *evt, Glib::RefPtr builder_effect); + bool apply(GdkEventButton *evt, Glib::RefPtr builder_effect, + const LivePathEffect::EnumEffectData *to_add); + bool show_fav_toggler(GdkEventButton *evt); + bool mouseover(GdkEventCrossing *evt, GtkWidget *wdg); + bool mouseout(GdkEventCrossing *evt, GtkWidget *wdg); void reload_effect_list(); /** * Add button was clicked @@ -104,7 +104,7 @@ private: Gtk::Box *_LPESelector; guint _visiblelpe; Glib::ustring _item_type; - const LivePathEffect::EnumEffectData* _to_add; + const LivePathEffect::EnumEffectData *_to_add; bool _showfavs; bool _applied; class Effect; @@ -114,8 +114,8 @@ private: static LivePathEffectAdd instance_; return instance_; } - LivePathEffectAdd(LivePathEffectAdd const &) = delete; // no copy - LivePathEffectAdd &operator=(LivePathEffectAdd const &) = delete; // no assign + LivePathEffectAdd(LivePathEffectAdd const &) = delete; // no copy + LivePathEffectAdd &operator=(LivePathEffectAdd const &) = delete; // no assign }; } // namespace Dialog diff --git a/src/ui/dialog/livepatheffect-editor.cpp b/src/ui/dialog/livepatheffect-editor.cpp index d5568f8e9..13d4f3dc4 100644 --- a/src/ui/dialog/livepatheffect-editor.cpp +++ b/src/ui/dialog/livepatheffect-editor.cpp @@ -432,7 +432,8 @@ LivePathEffectEditor::onAdd() SPDocument *doc = current_desktop->doc(); - const LivePathEffect::EnumEffectData* data = LivePathEffectAdd::getActiveData(); + const LivePathEffect::EnumEffectData *data = + LivePathEffectAdd::getActiveData(); if (!data) { return; } -- cgit v1.2.3