Code

When drawing with activated shape in pencil/pen tool, apply the original stroke color...
authorcilix42 <cilix42@users.sourceforge.net>
Thu, 3 Jul 2008 09:40:29 +0000 (09:40 +0000)
committercilix42 <cilix42@users.sourceforge.net>
Thu, 3 Jul 2008 09:40:29 +0000 (09:40 +0000)
src/draw-context.cpp

index d54ccc7788dc1fb092cb41cccaf69c628cb71d2f..92bba8104f339587fc23ef8affef3b7a46d6fffa 100644 (file)
@@ -42,6 +42,7 @@
 #include "sp-path.h"
 #include "sp-namedview.h"
 #include "live_effects/lpe-patternalongpath.h"
+#include "style.h"
 
 static void sp_draw_context_class_init(SPDrawContextClass *klass);
 static void sp_draw_context_init(SPDrawContext *dc);
@@ -271,6 +272,11 @@ spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item)
     if (item) {
         int shape = prefs_get_int_attribute("tools.freehand", "shape", 0);
 
+        bool shape_applied = false;
+        SPCSSAttr *css_item = sp_css_attr_from_object (SP_OBJECT(item), SP_STYLE_FLAG_ALWAYS);
+        const char *cfill = sp_repr_css_property(css_item, "fill", "none");
+        const char *cstroke = sp_repr_css_property(css_item, "stroke", "none");
+
         switch (shape) {
             case 0:
                 break;
@@ -279,7 +285,8 @@ spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item)
                 Effect::createAndApply(PATTERN_ALONG_PATH, dc->desktop->doc(), item);
                 Effect* lpe = sp_lpe_item_get_current_lpe(SP_LPE_ITEM(item));
                 static_cast<LPEPatternAlongPath*>(lpe)->pattern.on_paste_button_click();
-                return;
+
+                shape_applied = true;
             }
             case 2:
             {
@@ -292,11 +299,21 @@ spdc_check_for_and_apply_waiting_LPE(SPDrawContext *dc, SPItem *item)
                 c->closepath();
                 spdc_paste_curve_as_param_path(c, dc, item);
                 c->unref();
-                return;
+
+                shape_applied = true;
             }
             default:
                 break;
         }
+        if (shape_applied) {
+            // apply original stroke color as fill and unset stroke; then return
+            SPCSSAttr *css = sp_repr_css_attr_new();
+            sp_repr_css_set_property (css, "fill", cstroke);
+            sp_repr_css_set_property (css, "stroke", "none");
+            sp_desktop_apply_css_recursive(SP_OBJECT(item), css, true);
+            sp_repr_css_attr_unref(css);
+            return;
+        }
 
         if (prefs_get_int_attribute("tools.freehand", "spiro-spline-mode", 0)) {
             Effect::createAndApply(SPIRO, dc->desktop->doc(), item);