summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authoralexandru.roman <alexroman5g@gmail.com>2017-01-21 22:28:05 +0000
committerMarc Jeanmougin <marcjeanmougin@free.fr>2017-01-21 22:28:05 +0000
commite8dcb5062f6114a9fb06d496ab5d906aec405c78 (patch)
treea65d2125ceae6bd4ee9f5074962755e932dadaf1
parentFixes typos in strings. Some typos in Inkscape 0.92 LPE UI (diff)
downloadinkscape-e8dcb5062f6114a9fb06d496ab5d906aec405c78.tar.gz
inkscape-e8dcb5062f6114a9fb06d496ab5d906aec405c78.zip
Fix "swap fill and stroke" for multiple objects in selection
Add verb and shortcut possibility Fixed bugs: - https://launchpad.net/bugs/367360 - https://launchpad.net/bugs/675690 (bzr r15428)
-rw-r--r--share/keys/default.xml2
-rw-r--r--share/keys/inkscape.xml1
-rw-r--r--src/object-set.h2
-rw-r--r--src/selection-chemistry.cpp71
-rw-r--r--src/ui/widget/selected-style.cpp57
-rw-r--r--src/verbs.cpp5
-rw-r--r--src/verbs.h1
7 files changed, 81 insertions, 58 deletions
diff --git a/share/keys/default.xml b/share/keys/default.xml
index 581716d12..134251752 100644
--- a/share/keys/default.xml
+++ b/share/keys/default.xml
@@ -383,6 +383,8 @@ override) the bindings in the main default.xml.
<bind key="7" action="EditNextPathEffectParameter" display="true" />
+ <bind action="EditSwapFillStroke" display="true" />
+
<bind key="r" modifiers="Ctrl,Shift" action="FitCanvasToSelectionOrDrawing" display="true" />
<bind key="R" modifiers="Ctrl,Shift" action="FitCanvasToSelectionOrDrawing" display="true" />
diff --git a/share/keys/inkscape.xml b/share/keys/inkscape.xml
index 581716d12..4461dee69 100644
--- a/share/keys/inkscape.xml
+++ b/share/keys/inkscape.xml
@@ -382,6 +382,7 @@ override) the bindings in the main default.xml.
<bind key="Escape" action="EditDeselect" />
<bind key="7" action="EditNextPathEffectParameter" display="true" />
+ <bind action="EditSwapFillStroke" display="true" />
<bind key="r" modifiers="Ctrl,Shift" action="FitCanvasToSelectionOrDrawing" display="true" />
<bind key="R" modifiers="Ctrl,Shift" action="FitCanvasToSelectionOrDrawing" display="true" />
diff --git a/src/object-set.h b/src/object-set.h
index a89a299bd..7c224f640 100644
--- a/src/object-set.h
+++ b/src/object-set.h
@@ -447,7 +447,7 @@ public:
// various
void getExportHints(Glib::ustring &filename, float *xdpi, float *ydpi);
bool fitCanvas(bool with_margins, bool skip_undo = false);
-
+ void swapFillStroke();
protected:
virtual void _connectSignals(SPObject* object) {};
diff --git a/src/selection-chemistry.cpp b/src/selection-chemistry.cpp
index f8ab33ac4..67972cabb 100644
--- a/src/selection-chemistry.cpp
+++ b/src/selection-chemistry.cpp
@@ -97,6 +97,7 @@ SPCycleType SP_CYCLING = SP_CYCLE_FOCUS;
#include "live_effects/parameter/originalpath.h"
#include "layer-manager.h"
#include "object-set.h"
+#include "svg/svg-color.h"
// For clippath editing
#include "ui/tools/node-tool.h"
@@ -1242,7 +1243,6 @@ void ObjectSet::pasteStyle()
}
}
-
void ObjectSet::pastePathEffect()
{
Inkscape::UI::ClipboardManager *cm = Inkscape::UI::ClipboardManager::get();
@@ -4169,6 +4169,75 @@ bool ObjectSet::fitCanvas(bool with_margins, bool skip_undo)
}
}
+void ObjectSet::swapFillStroke()
+{
+ if (desktop() == NULL) {
+ return;
+ }
+
+ SPIPaint *paint;
+ SPPaintServer *server;
+ Glib::ustring _paintserver_id;
+
+ auto list= items();
+ for (auto itemlist=list.begin();itemlist!=list.end();++itemlist) {
+ SPItem *item = *itemlist;
+
+ SPCSSAttr *css = sp_repr_css_attr_new ();
+
+ _paintserver_id.clear();
+ paint = &(item->style->fill);
+ if (paint->set && paint->isNone())
+ sp_repr_css_set_property (css, "stroke", "none");
+ else if (paint->set && paint->isColor()) {
+ guint32 color = paint->value.color.toRGBA32(SP_SCALE24_TO_FLOAT (item->style->fill_opacity.value));
+ gchar c[64];
+ sp_svg_write_color (c, sizeof(c), color);
+ sp_repr_css_set_property (css, "stroke", c);
+ }
+ else if (!paint->set)
+ sp_repr_css_unset_property (css, "stroke");
+ else if (paint->set && paint->isPaintserver()) {
+ server = SP_STYLE_FILL_SERVER(item->style);
+ if (server) {
+ Inkscape::XML::Node *srepr = server->getRepr();
+ _paintserver_id += "url(#";
+ _paintserver_id += srepr->attribute("id");
+ _paintserver_id += ")";
+ sp_repr_css_set_property (css, "stroke", _paintserver_id.c_str());
+ }
+ }
+
+ _paintserver_id.clear();
+ paint = &(item->style->stroke);
+ if (paint->set && paint->isNone())
+ sp_repr_css_set_property (css, "fill", "none");
+ else if (paint->set && paint->isColor()) {
+ guint32 color = paint->value.color.toRGBA32(SP_SCALE24_TO_FLOAT (item->style->stroke_opacity.value));
+ gchar c[64];
+ sp_svg_write_color (c, sizeof(c), color);
+ sp_repr_css_set_property (css, "fill", c);
+ }
+ else if (!paint->set)
+ sp_repr_css_unset_property (css, "fill");
+ else if (paint->set && paint->isPaintserver()) {
+ server = SP_STYLE_STROKE_SERVER(item->style);
+ if (server) {
+ Inkscape::XML::Node *srepr = server->getRepr();
+ _paintserver_id += "url(#";
+ _paintserver_id += srepr->attribute("id");
+ _paintserver_id += ")";
+ sp_repr_css_set_property (css, "fill", _paintserver_id.c_str());
+ }
+ }
+
+ sp_desktop_apply_css_recursive(item, css, true);
+ sp_repr_css_attr_unref (css);
+ }
+
+ DocumentUndo::done(document(), SP_VERB_EDIT_SWAP_FILL_STROKE,
+ _("Swap fill and stroke of an object"));
+}
/**
* \param with_margins margins defined in the xml under <sodipodi:namedview>
diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp
index fa7a83732..0370d55db 100644
--- a/src/ui/widget/selected-style.cpp
+++ b/src/ui/widget/selected-style.cpp
@@ -781,62 +781,7 @@ void SelectedStyle::on_stroke_paste() {
}
void SelectedStyle::on_fillstroke_swap() {
- SPCSSAttr *css = sp_repr_css_attr_new ();
-
- switch (_mode[SS_FILL]) {
- case SS_NA:
- case SS_MANY:
- break;
- case SS_NONE:
- sp_repr_css_set_property (css, "stroke", "none");
- break;
- case SS_UNSET:
- sp_repr_css_unset_property (css, "stroke");
- break;
- case SS_COLOR:
- gchar c[64];
- sp_svg_write_color (c, sizeof(c), _thisselected[SS_FILL]);
- sp_repr_css_set_property (css, "stroke", c);
- break;
- case SS_LGRADIENT:
- case SS_RGRADIENT:
-#ifdef WITH_MESH
- case SS_MGRADIENT:
-#endif
- case SS_PATTERN:
- sp_repr_css_set_property (css, "stroke", _paintserver_id[SS_FILL].c_str());
- break;
- }
-
- switch (_mode[SS_STROKE]) {
- case SS_NA:
- case SS_MANY:
- break;
- case SS_NONE:
- sp_repr_css_set_property (css, "fill", "none");
- break;
- case SS_UNSET:
- sp_repr_css_unset_property (css, "fill");
- break;
- case SS_COLOR:
- gchar c[64];
- sp_svg_write_color (c, sizeof(c), _thisselected[SS_STROKE]);
- sp_repr_css_set_property (css, "fill", c);
- break;
- case SS_LGRADIENT:
- case SS_RGRADIENT:
-#ifdef WITH_MESH
- case SS_MGRADIENT:
-#endif
- case SS_PATTERN:
- sp_repr_css_set_property (css, "fill", _paintserver_id[SS_STROKE].c_str());
- break;
- }
-
- sp_desktop_set_style (_desktop, css);
- sp_repr_css_attr_unref (css);
- DocumentUndo::done(_desktop->getDocument(), SP_VERB_DIALOG_FILL_STROKE,
- _("Swap fill and stroke"));
+ _desktop->getSelection()->swapFillStroke();
}
void SelectedStyle::on_fill_edit() {
diff --git a/src/verbs.cpp b/src/verbs.cpp
index 975a3679e..aeb742105 100644
--- a/src/verbs.cpp
+++ b/src/verbs.cpp
@@ -1086,6 +1086,9 @@ void EditVerb::perform(SPAction *action, void *data)
case SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER:
sp_selection_next_patheffect_param(dt);
break;
+ case SP_VERB_EDIT_SWAP_FILL_STROKE:
+ dt->selection->swapFillStroke();
+ break;
case SP_VERB_EDIT_LINK_COLOR_PROFILE:
break;
case SP_VERB_EDIT_REMOVE_COLOR_PROFILE:
@@ -2585,6 +2588,8 @@ Verb *Verb::_base_verbs[] = {
N_("Create four guides aligned with the page borders"), NULL),
new EditVerb(SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER, "EditNextPathEffectParameter", N_("Next path effect parameter"),
N_("Show next editable path effect parameter"), INKSCAPE_ICON("path-effect-parameter-next")),
+ new EditVerb(SP_VERB_EDIT_SWAP_FILL_STROKE, "EditSwapFillStroke", N_("Swap fill and stroke"),
+ N_("Swap fill and stroke of an object"), NULL),
// Selection
new SelectionVerb(SP_VERB_SELECTION_TO_FRONT, "SelectionToFront", N_("Raise to _Top"),
diff --git a/src/verbs.h b/src/verbs.h
index d7e966ae4..76a7d19a6 100644
--- a/src/verbs.h
+++ b/src/verbs.h
@@ -110,6 +110,7 @@ enum {
SP_VERB_EDIT_GUIDES_TOGGLE_LOCK,
SP_VERB_EDIT_GUIDES_AROUND_PAGE,
SP_VERB_EDIT_NEXT_PATHEFFECT_PARAMETER,
+ SP_VERB_EDIT_SWAP_FILL_STROKE,
/* Selection */
SP_VERB_SELECTION_TO_FRONT,
SP_VERB_SELECTION_TO_BACK,