summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJabier Arraiza <jabier.arraiza@marker.es>2019-02-03 01:11:32 +0000
committerJabier Arraiza <jabier.arraiza@marker.es>2019-02-18 21:18:27 +0000
commit7d9c5a51c80a0c044558eb941a6bd86a0a9b49d3 (patch)
treef4880739f68c371c85625a13482c25cb3b84de95
parentAdded all Ramón Miranda symbolic icons to LPE selector (diff)
downloadinkscape-7d9c5a51c80a0c044558eb941a6bd86a0a9b49d3.tar.gz
inkscape-7d9c5a51c80a0c044558eb941a6bd86a0a9b49d3.zip
add sorting and favorites
-rw-r--r--share/ui/dialog-livepatheffect-add-effect.ui93
-rw-r--r--share/ui/dialog-livepatheffect-add.ui77
-rw-r--r--share/ui/style.css22
-rw-r--r--src/live_effects/effect-enum.h21
-rw-r--r--src/live_effects/effect.cpp55
-rw-r--r--src/ui/dialog/livepatheffect-add.cpp164
-rw-r--r--src/ui/dialog/livepatheffect-add.h13
7 files changed, 394 insertions, 51 deletions
diff --git a/share/ui/dialog-livepatheffect-add-effect.ui b/share/ui/dialog-livepatheffect-add-effect.ui
index 300f01be2..77a11b4b8 100644
--- a/share/ui/dialog-livepatheffect-add-effect.ui
+++ b/share/ui/dialog-livepatheffect-add-effect.ui
@@ -12,19 +12,53 @@
<property name="orientation">vertical</property>
<property name="baseline_position">top</property>
<child>
- <object class="GtkImage" id="LPEIcon">
+ <object class="GtkOverlay">
<property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="halign">center</property>
- <property name="valign">start</property>
- <property name="pixel_size">80</property>
- <property name="icon_name">align-vertical-baseline</property>
- <property name="icon_size">6</property>
+ <child>
+ <object class="GtkImage" id="LPEIcon">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">center</property>
+ <property name="valign">start</property>
+ <property name="pixel_size">80</property>
+ <property name="icon_name">align-vertical-baseline</property>
+ <property name="icon_size">6</property>
+ </object>
+ <packing>
+ <property name="index">1</property>
+ </packing>
+ </child>
+ <child type="overlay">
+ <object class="GtkEventBox" id="LPESelectorEffectFavLauncherTop">
+ <property name="can_focus">False</property>
+ <property name="no_show_all">True</property>
+ <property name="halign">end</property>
+ <property name="valign">start</property>
+ <child>
+ <object class="GtkImage">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="halign">start</property>
+ <property name="valign">start</property>
+ <property name="pixel_size">30</property>
+ <property name="icon_name">draw-star</property>
+ <property name="icon_size">2</property>
+ <style>
+ <class name="fab"/>
+ </style>
+ </object>
+ </child>
+ </object>
+ <packing>
+ <property name="index">2</property>
+ </packing>
+ </child>
</object>
<packing>
<property name="expand">False</property>
- <property name="fill">False</property>
- <property name="position">1</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
</packing>
</child>
<child>
@@ -57,7 +91,7 @@
<property name="expand">False</property>
<property name="fill">False</property>
<property name="padding">10</property>
- <property name="position">2</property>
+ <property name="position">3</property>
</packing>
</child>
<child>
@@ -91,20 +125,25 @@
</packing>
</child>
<child>
- <object class="GtkImage">
+ <object class="GtkEventBox" id="LPESelectorEffectFavLauncher">
+ <property name="visible">True</property>
<property name="can_focus">False</property>
- <property name="halign">end</property>
- <property name="pixel_size">30</property>
- <property name="icon_name">draw-star-outline</property>
- <property name="icon_size">2</property>
- <style>
- <class name="fab"/>
- </style>
+ <child>
+ <object class="GtkImage">
+ <property name="can_focus">False</property>
+ <property name="halign">end</property>
+ <property name="pixel_size">30</property>
+ <property name="icon_name">draw-star-outline</property>
+ <property name="icon_size">2</property>
+ <style>
+ <class name="fab"/>
+ </style>
+ </object>
+ </child>
</object>
<packing>
- <property name="expand">False</property>
- <property name="fill">False</property>
- <property name="pack_type">end</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
<property name="position">1</property>
<property name="non_homogeneous">True</property>
</packing>
@@ -136,6 +175,20 @@
<property name="position">3</property>
</packing>
</child>
+ <child>
+ <object class="GtkCheckButton" id="LPEExperimental">
+ <property name="label" translatable="yes">Experimental</property>
+ <property name="can_focus">True</property>
+ <property name="receives_default">False</property>
+ <property name="no_show_all">True</property>
+ <property name="draw_indicator">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">5</property>
+ </packing>
+ </child>
<style>
<class name="lpeselectoreffect"/>
</style>
diff --git a/share/ui/dialog-livepatheffect-add.ui b/share/ui/dialog-livepatheffect-add.ui
index 62484731a..0fbdb6a6f 100644
--- a/share/ui/dialog-livepatheffect-add.ui
+++ b/share/ui/dialog-livepatheffect-add.ui
@@ -6,14 +6,18 @@
<property name="name">LPEDialogSelector</property>
<property name="height_request">500</property>
<property name="visible">True</property>
- <property name="can_focus">False</property>
- <property name="title" translatable="yes">Live Path Effect Selector</property>
+ <property name="can_focus">True</property>
+ <property name="has_focus">True</property>
+ <property name="can_default">True</property>
+ <property name="title" translatable="yes">Live Path Effects Selector</property>
<property name="modal">True</property>
<property name="window_position">center-on-parent</property>
<property name="destroy_with_parent">True</property>
<property name="type_hint">dialog</property>
+ <property name="skip_taskbar_hint">True</property>
<property name="gravity">center</property>
- <child>
+ <property name="has_resize_grip">True</property>
+ <child type="titlebar">
<placeholder/>
</child>
<child internal-child="vbox">
@@ -51,16 +55,63 @@
<property name="can_focus">False</property>
<property name="search_mode_enabled">True</property>
<child>
- <object class="GtkSearchEntry" id="LPEFilter">
- <property name="width_request">400</property>
+ <object class="GtkBox">
<property name="visible">True</property>
- <property name="can_focus">True</property>
- <property name="primary_icon_name">edit-find-symbolic</property>
- <property name="primary_icon_activatable">False</property>
- <property name="primary_icon_sensitive">False</property>
- <style>
- <class name="iconymbolic"/>
- </style>
+ <property name="can_focus">False</property>
+ <child>
+ <object class="GtkSearchEntry" id="LPEFilter">
+ <property name="width_request">400</property>
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ <property name="primary_icon_name">edit-find-symbolic</property>
+ <property name="primary_icon_activatable">False</property>
+ <property name="primary_icon_sensitive">False</property>
+ <style>
+ <class name="iconymbolic"/>
+ </style>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">0</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSeparator">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="padding">5</property>
+ <property name="position">1</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkSwitch" id="LPEExperimentals">
+ <property name="visible">True</property>
+ <property name="can_focus">True</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">2</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkLabel">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="margin_left">10</property>
+ <property name="label" translatable="yes">Experimental effects</property>
+ </object>
+ <packing>
+ <property name="expand">False</property>
+ <property name="fill">True</property>
+ <property name="position">4</property>
+ </packing>
+ </child>
</object>
</child>
<style>
@@ -91,7 +142,7 @@
</packing>
</child>
<child>
- <object class="GtkScrolledWindow">
+ <object class="GtkScrolledWindow" id="LPEScrolled">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">never</property>
diff --git a/share/ui/style.css b/share/ui/style.css
index 5534e1214..64779bd39 100644
--- a/share/ui/style.css
+++ b/share/ui/style.css
@@ -239,9 +239,29 @@ spinbutton undershoot {
border-width:0;
}
+#lpeflow GtkFlowBoxChild,
+#lpeflow flowboxchild{
+ border-width:0px;
+ border-radius:6px;
+ margin:10px;
+ padding:10px;
+ margin-bottom:30px;
+ padding-bottom:10px;
+}
+
+#lpeflow GtkFlowBoxChild.lpeactive,
+#lpeflow flowboxchild.lpeactive{
+ margin-bottom:0px;
+ padding-bottom:10px;
+ outline:none;
+}
+.lpefav{
+ background-color: @theme_base_color;
+ padding-bottom:0px;
+}
.lpename{
font-size:22px;
- margin-bottom:20px;
+ margin-bottom:5px;
}
.lpeinfo{
font-size:16px;
diff --git a/src/live_effects/effect-enum.h b/src/live_effects/effect-enum.h
index b160aa161..2939766fd 100644
--- a/src/live_effects/effect-enum.h
+++ b/src/live_effects/effect-enum.h
@@ -88,6 +88,7 @@ struct EnumEffectData {
const bool on_use;
const bool on_image;
const bool on_text;
+ const bool experimental;
};
const Glib::ustring empty_string("");
@@ -188,7 +189,7 @@ class EnumEffectDataConverter {
return empty_string;
}
- const bool &get_on_path(const E id) const
+ const bool get_on_path(const E id) const
{
for (unsigned int i = 0; i < _length; ++i) {
if (_data[i].id == id)
@@ -198,7 +199,7 @@ class EnumEffectDataConverter {
return false;
}
- const bool &get_on_shape(const E id) const
+ const bool get_on_shape(const E id) const
{
for (unsigned int i = 0; i < _length; ++i) {
if (_data[i].id == id)
@@ -208,7 +209,7 @@ class EnumEffectDataConverter {
return false;
}
- const bool &get_on_group(const E id) const
+ const bool get_on_group(const E id) const
{
for (unsigned int i = 0; i < _length; ++i) {
if (_data[i].id == id)
@@ -218,7 +219,7 @@ class EnumEffectDataConverter {
return false;
}
- const bool &get_on_text(const E id) const
+ const bool get_on_text(const E id) const
{
for (unsigned int i = 0; i < _length; ++i) {
if (_data[i].id == id)
@@ -228,7 +229,7 @@ class EnumEffectDataConverter {
return false;
}
- const bool &get_on_use(const E id) const
+ const bool get_on_use(const E id) const
{
for (unsigned int i = 0; i < _length; ++i) {
if (_data[i].id == id)
@@ -238,6 +239,16 @@ class EnumEffectDataConverter {
return false;
}
+ const bool get_experimental(const E id) const
+ {
+ for (unsigned int i = 0; i < _length; ++i) {
+ if (_data[i].id == id)
+ return _data[i].experimental;
+ }
+
+ return false;
+ }
+
const EnumEffectData<E> &data(const unsigned int i) const { return _data[i]; }
const unsigned int _length;
diff --git a/src/live_effects/effect.cpp b/src/live_effects/effect.cpp
index 87f943ee2..0bc576ecb 100644
--- a/src/live_effects/effect.cpp
+++ b/src/live_effects/effect.cpp
@@ -109,6 +109,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
GEARS
@@ -122,6 +123,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, false //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
PATTERN_ALONG_PATH
@@ -135,6 +137,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
}, // for historic reasons, this effect is called skeletal(strokes) in Inkscape:SVG
{
CURVE_STITCH
@@ -148,6 +151,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
/* 0.47 */
{
@@ -162,6 +166,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
KNOT
@@ -175,6 +180,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
CONSTRUCT_GRID
@@ -188,6 +194,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
SPIRO
@@ -201,6 +208,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
ENVELOPE
@@ -214,6 +222,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
INTERPOLATE
@@ -227,6 +236,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
ROUGH_HATCHES
@@ -240,6 +250,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
SKETCH
@@ -253,6 +264,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
RULER
@@ -266,6 +278,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
/* 0.91 */
{
@@ -280,6 +293,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
CLONE_ORIGINAL
@@ -293,6 +307,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
/* 0.92 */
{
@@ -307,6 +322,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
LATTICE2
@@ -320,6 +336,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
PERSPECTIVE_ENVELOPE
@@ -333,6 +350,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
INTERPOLATE_POINTS
@@ -346,6 +364,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
TRANSFORM_2PTS
@@ -359,6 +378,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
SHOW_HANDLES
@@ -372,6 +392,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
ROUGHEN
@@ -385,6 +406,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
BSPLINE
@@ -398,6 +420,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
JOIN_TYPE
@@ -411,6 +434,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
TAPER_STROKE
@@ -424,6 +448,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
MIRROR_SYMMETRY
@@ -437,6 +462,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
COPY_ROTATE
@@ -450,6 +476,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
/* Ponyscape -> Inkscape 0.92*/
{
@@ -464,6 +491,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
FILL_BETWEEN_STROKES
@@ -477,6 +505,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
FILL_BETWEEN_MANY
@@ -490,6 +519,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
ELLIPSE_5PTS
@@ -503,6 +533,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
BOUNDING_BOX
@@ -516,6 +547,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
/* 1.0 */
{
@@ -530,6 +562,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
FILLET_CHAMFER
@@ -543,6 +576,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
BOOL_OP
@@ -556,6 +590,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
EMBRODERY_STITCH
@@ -569,6 +604,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
POWERCLIP
@@ -582,6 +618,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
POWERMASK
@@ -595,6 +632,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
PTS2ELLIPSE
@@ -608,6 +646,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
OFFSET
@@ -621,6 +660,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
{
DASH_STROKE
@@ -634,6 +674,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , false //experimental
},
#ifdef LPE_ENABLE_TEST_EFFECTS
{
@@ -648,6 +689,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , true //experimental
},
{
ANGLE_BISECTOR
@@ -661,6 +703,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , true //experimental
},
{
CIRCLE_WITH_RADIUS
@@ -674,6 +717,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , true //experimental
},
{
CIRCLE_3PTS
@@ -687,6 +731,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , true //experimental
},
{
DYNASTROKE
@@ -700,6 +745,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , true //experimental
},
{
EXTRUDE
@@ -713,6 +759,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , true //experimental
},
{
LATTICE
@@ -726,6 +773,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , true //experimental
},
{
LINE_SEGMENT
@@ -739,6 +787,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , true //experimental
},
{
PARALLEL
@@ -752,6 +801,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , true //experimental
},
{
PATH_LENGTH
@@ -765,6 +815,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , true //experimental
},
{
PERP_BISECTOR
@@ -778,6 +829,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , true //experimental
},
{
RECURSIVE_SKELETON
@@ -791,6 +843,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , true //experimental
},
{
TANGENT_TO_CURVE
@@ -804,6 +857,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , true //experimental
},
{
TEXT_LABEL
@@ -817,6 +871,7 @@ const EnumEffectData<EffectType> LPETypeData[] = {
, true //on_use
, false //on_image
, false //on_text
+ , true //experimental
},
#endif
diff --git a/src/ui/dialog/livepatheffect-add.cpp b/src/ui/dialog/livepatheffect-add.cpp
index e72ca745d..9137f529d 100644
--- a/src/ui/dialog/livepatheffect-add.cpp
+++ b/src/ui/dialog/livepatheffect-add.cpp
@@ -18,15 +18,45 @@
#include "live_effects/effect.h"
#include "livepatheffect-add.h"
#include <glibmm/i18n.h>
+#include "preferences.h"
namespace Inkscape {
namespace UI {
namespace Dialog {
+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){
+ return true;
+ }
+ return false;
+}
+
+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)) {
+ prefs->setString("/dialogs/livepatheffect/favs", favlist + 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());
+ prefs->setString("/dialogs/livepatheffect/favs", favlist);
+ }
+}
+
LivePathEffectAdd::LivePathEffectAdd()
: converter(Inkscape::LivePathEffect::LPETypeConverter)
{
- add_events(Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK );
Glib::ustring gladefile = get_filename(Inkscape::IO::Resource::UIS, "dialog-livepatheffect-add.ui");
try {
_builder = Gtk::Builder::create_from_file(gladefile);
@@ -39,6 +69,8 @@ LivePathEffectAdd::LivePathEffectAdd()
_builder->get_widget("LPESelectorEffectInfo", _LPESelectorEffectInfo);
_builder->get_widget("LPEFilter", _LPEFilter);
_builder->get_widget("LPEInfo", _LPEInfo);
+ _builder->get_widget("LPEExperimentals", _LPEExperimentals);
+ _builder->get_widget("LPEScrolled", _LPEScrolled);
_LPEFilter->signal_search_changed().connect(sigc::mem_fun(*this, &LivePathEffectAdd::on_search));
Glib::ustring effectgladefile = get_filename(Inkscape::IO::Resource::UIS, "dialog-livepatheffect-add-effect.ui");
for (int i = 0; i < static_cast<int>(converter._length); ++i) {
@@ -49,6 +81,8 @@ LivePathEffectAdd::LivePathEffectAdd()
g_warning("Glade file loading failed for filter effect dialog");
return;
}
+ Gtk::Box *LPESelectorEffect;
+ builder_effect->get_widget("LPESelectorEffect", LPESelectorEffect);
const LivePathEffect::EnumEffectData<LivePathEffect::EffectType> *data = &converter.data(i);
Gtk::Label *LPEName;
builder_effect->get_widget("LPEName", LPEName);
@@ -56,21 +90,32 @@ LivePathEffectAdd::LivePathEffectAdd()
Gtk::Label *LPEDescription;
builder_effect->get_widget("LPEDescription", LPEDescription);
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;
+ 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 *LPESelectorEffectInfoLauncher;
builder_effect->get_widget("LPESelectorEffectInfoLauncher", LPESelectorEffectInfoLauncher);
LPESelectorEffectInfoLauncher->signal_button_press_event().connect(sigc::bind<Glib::RefPtr<Gtk::Builder> >(sigc::mem_fun(*this, &LivePathEffectAdd::pop_description), builder_effect));
- Gtk::Box *LPESelectorEffect;
- builder_effect->get_widget("LPESelectorEffect", LPESelectorEffect);
+ Gtk::EventBox *LPESelectorEffectFavLauncher;
+ builder_effect->get_widget("LPESelectorEffectFavLauncher", LPESelectorEffectFavLauncher);
+ Gtk::EventBox *LPESelectorEffectFavLauncherTop;
+ builder_effect->get_widget("LPESelectorEffectFavLauncherTop", LPESelectorEffectFavLauncherTop);
+ LPESelectorEffectFavLauncher ->signal_button_press_event().connect(sigc::bind<Glib::RefPtr<Gtk::Builder> >(sigc::mem_fun(*this, &LivePathEffectAdd::fav_toggler), builder_effect));
+ LPESelectorEffectFavLauncherTop->signal_button_press_event().connect(sigc::bind<Glib::RefPtr<Gtk::Builder> >(sigc::mem_fun(*this, &LivePathEffectAdd::fav_toggler), builder_effect));
_LPESelectorFlowBox->insert(*LPESelectorEffect, i);
}
_visiblelpe = _LPESelectorFlowBox->get_children().size();
_LPESelectorFlowBox->signal_child_activated().connect(sigc::mem_fun(*this, &LivePathEffectAdd::on_activate));
- _LPEDialogSelector->set_title(_("Live Efects Selector"));
_LPEDialogSelector->show_all_children();
+ _LPEDialogSelector->add_events(Gdk::POINTER_MOTION_MASK | Gdk::BUTTON_PRESS_MASK | Gdk::BUTTON_RELEASE_MASK | Gdk::ENTER_NOTIFY_MASK | Gdk::LEAVE_NOTIFY_MASK );
_LPEInfo->set_visible(false);
+ _LPESelectorFlowBox->set_sort_func(sigc::mem_fun(*this, &LivePathEffectAdd::on_sort));
+ _LPESelectorFlowBox->set_filter_func(sigc::mem_fun(*this, &LivePathEffectAdd::on_filter));
+ _LPEExperimentals->property_active().signal_changed().connect(sigc::mem_fun(*this, &LivePathEffectAdd::reload_effect_list));
}
void LivePathEffectAdd::on_activate(Gtk::FlowBoxChild *child)
@@ -83,7 +128,7 @@ void LivePathEffectAdd::on_activate(Gtk::FlowBoxChild *child)
Gtk::Box *box = dynamic_cast<Gtk::Box *>(leitem->get_child());
if (box) {
std::vector<Gtk::Widget *> contents = box->get_children();
- Gtk::Box *actions = dynamic_cast<Gtk::Box *>(contents[3]);
+ Gtk::Box *actions = dynamic_cast<Gtk::Box *>(contents[4]);
if (actions) {
actions->set_visible(false);
}
@@ -125,15 +170,55 @@ bool LivePathEffectAdd::pop_description(GdkEventButton* evt, Glib::RefPtr<Gtk::B
return true;
}
-bool LivePathEffectAdd::on_filter(Gtk::FlowBoxChild *child)
+bool LivePathEffectAdd::fav_toggler(GdkEventButton* evt, Glib::RefPtr<Gtk::Builder> builder_effect)
{
- if (_LPEFilter->get_text().length() < 4) {
- _visiblelpe = _LPESelectorFlowBox->get_children().size();
- return true;
+ Gtk::Box *LPESelectorEffect;
+ builder_effect->get_widget("LPESelectorEffect", LPESelectorEffect);
+ Gtk::Label *LPEName;
+ builder_effect->get_widget("LPEName", LPEName);
+ Gtk::EventBox *LPESelectorEffectFavLauncher;
+ builder_effect->get_widget("LPESelectorEffectFavLauncher", LPESelectorEffectFavLauncher);
+ Gtk::Image *favimg = dynamic_cast<Gtk::Image *>(LPESelectorEffectFavLauncher->get_child());
+ Gtk::EventBox *LPESelectorEffectFavLauncherTop;
+ builder_effect->get_widget("LPESelectorEffectFavLauncherTop", LPESelectorEffectFavLauncherTop);
+ Gtk::Image *favimgtop = dynamic_cast<Gtk::Image *>(LPESelectorEffectFavLauncherTop->get_child());
+ if (favimg && favimgtop) {
+ if (sp_has_fav(LPEName->get_text())){
+ //favimg->set_from_icon_name("draw-star-outline", Gtk::IconSize(30));
+ LPESelectorEffectFavLauncherTop->set_visible(false);
+ LPESelectorEffectFavLauncherTop->hide();
+ sp_remove_fav(LPEName->get_text());
+ LPESelectorEffect->get_parent()->get_style_context()->remove_class("lpefav");
+ _LPESelectorFlowBox->invalidate_sort();
+ } else {
+ //favimg->set_from_icon_name("draw-star", Gtk::IconSize(30));
+ LPESelectorEffectFavLauncherTop->set_visible(true);
+ LPESelectorEffectFavLauncherTop->show();
+ sp_add_fav(LPEName->get_text());
+ LPESelectorEffect->get_parent()->get_style_context()->add_class("lpefav");
+ Glib::RefPtr< Gtk::Adjustment > vadjust = _LPEScrolled->get_vadjustment();
+ vadjust->set_value(vadjust->get_lower());
+ _LPESelectorFlowBox->invalidate_sort();
+ }
}
+ return true;
+}
+
+bool LivePathEffectAdd::on_filter(Gtk::FlowBoxChild *child)
+{
Gtk::Box *box = dynamic_cast<Gtk::Box *>(child->get_child());
if (box) {
std::vector<Gtk::Widget *> contents = box->get_children();
+ Gtk::ToggleButton *experimental = dynamic_cast<Gtk::ToggleButton *>(contents[3]);
+ if (experimental) {
+ if (experimental->get_active() && !_LPEExperimentals->get_active()) {
+ return false;
+ }
+ }
+ if (_LPEFilter->get_text().length() < 1) {
+ _visiblelpe++;
+ return true;
+ }
Gtk::Label *lpename = dynamic_cast<Gtk::Label *>(contents[1]);
if (lpename) {
size_t s = lpename->get_text().uppercase().find(_LPEFilter->get_text().uppercase(), 0);
@@ -154,10 +239,15 @@ bool LivePathEffectAdd::on_filter(Gtk::FlowBoxChild *child)
return false;
}
+void LivePathEffectAdd::reload_effect_list()
+{
+ _LPESelectorFlowBox->invalidate_filter();
+}
+
void LivePathEffectAdd::on_search()
{
_visiblelpe = 0;
- _LPESelectorFlowBox->set_filter_func(sigc::mem_fun(*this, &LivePathEffectAdd::on_filter));
+ _LPESelectorFlowBox->invalidate_filter();
if (_visiblelpe == 0) {
_LPEInfo->set_text(_("Your search do a empty result, please try again"));
_LPEInfo->set_visible(true);
@@ -168,6 +258,55 @@ void LivePathEffectAdd::on_search()
}
}
+int LivePathEffectAdd::on_sort(Gtk::FlowBoxChild *child1, Gtk::FlowBoxChild *child2)
+{
+ Glib::ustring name1 = "";
+ Glib::ustring name2 = "";
+ Gtk::Box *box = dynamic_cast<Gtk::Box *>(child1->get_child());
+ if (box) {
+ std::vector<Gtk::Widget *> contents = box->get_children();
+ Gtk::Label *lpename = dynamic_cast<Gtk::Label *>(contents[1]);
+ name1 = lpename->get_text();
+ Gtk::Overlay *overlay = dynamic_cast<Gtk::Overlay *>(contents[0]);
+ if (overlay) {
+ std::vector<Gtk::Widget *> contents_overlay = overlay->get_children();
+ Gtk::EventBox *LPESelectorEffectFavLauncherTop = dynamic_cast<Gtk::EventBox *>(contents_overlay[1]);
+ if (LPESelectorEffectFavLauncherTop) {
+ if (sp_has_fav(name1)){
+ LPESelectorEffectFavLauncherTop->set_visible(true);
+ LPESelectorEffectFavLauncherTop->show();
+ child1->get_style_context()->add_class("lpefav");
+ } else {
+ LPESelectorEffectFavLauncherTop->set_visible(false);
+ LPESelectorEffectFavLauncherTop->hide();
+ child1->get_style_context()->remove_class("lpefav");
+ }
+ }
+ }
+ }
+ box = dynamic_cast<Gtk::Box *>(child2->get_child());
+ if (box) {
+ std::vector<Gtk::Widget *> contents = box->get_children();
+ Gtk::Label *lpename = dynamic_cast<Gtk::Label *>(contents[1]);
+ name2 = lpename->get_text();
+ }
+
+ std::vector<Glib::ustring> 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)) {
+ return -1;
+ }
+ return 1;
+}
+
void LivePathEffectAdd::onAdd()
{
onClose();
@@ -188,7 +327,12 @@ void LivePathEffectAdd::onKeyEvent(GdkEventKey* evt)
void LivePathEffectAdd::show(SPDesktop *desktop)
{
LivePathEffectAdd &dial = instance();
+ dial._LPESelectorFlowBox->invalidate_filter();
+ dial._LPESelectorFlowBox->invalidate_sort();
+ Glib::RefPtr< Gtk::Adjustment > vadjust = dial._LPEScrolled->get_vadjustment();
+ vadjust->set_value(vadjust->get_lower());
dial._LPEDialogSelector->run();
+ dial._LPEDialogSelector->hide();
}
} // namespace Dialog
diff --git a/src/ui/dialog/livepatheffect-add.h b/src/ui/dialog/livepatheffect-add.h
index d6369a314..b99c40ece 100644
--- a/src/ui/dialog/livepatheffect-add.h
+++ b/src/ui/dialog/livepatheffect-add.h
@@ -20,10 +20,14 @@
#include <gtkmm/dialog.h>
#include <gtkmm/popover.h>
#include <gtkmm/flowbox.h>
+#include <gtkmm/switch.h>
#include <gtkmm/flowboxchild.h>
+#include <gtkmm/scrolledwindow.h>
#include <gtkmm/label.h>
#include <gtkmm/searchentry.h>
#include <gtkmm/stylecontext.h>
+#include <gtkmm/overlay.h>
+#include <gtkmm/adjustment.h>
class SPDesktop;
@@ -35,10 +39,10 @@ namespace Dialog {
* A dialog widget to list the live path effects that can be added
*
*/
-class LivePathEffectAdd : public Gtk::Dialog {
+class LivePathEffectAdd {
public:
LivePathEffectAdd();
- ~LivePathEffectAdd() override = default;
+ ~LivePathEffectAdd(){};
/**
* Show the dialog
@@ -54,9 +58,12 @@ public:
*/
void onClose();
bool on_filter(Gtk::FlowBoxChild *child);
+ 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<Gtk::Builder> builder_effect);
+ bool fav_toggler(GdkEventButton* evt, Glib::RefPtr<Gtk::Builder> builder_effect);
+ void reload_effect_list();
/**
* Add button was clicked
*/
@@ -77,7 +84,9 @@ private:
Glib::RefPtr<Gtk::Builder> _builder;
Gtk::FlowBox *_LPESelectorFlowBox;
Gtk::Popover *_LPESelectorEffectInfo;
+ Gtk::Switch * _LPEExperimentals;
Gtk::SearchEntry *_LPEFilter;
+ Gtk::ScrolledWindow *_LPEScrolled;
Gtk::Label *_LPEInfo;
Gtk::Box *_LPESelector;
guint _visiblelpe;