From 9b00d76637485b69ec18c05dd4ec38200491ed7e Mon Sep 17 00:00:00 2001 From: kiirala Date: Wed, 26 Jul 2006 09:18:55 +0000 Subject: [PATCH] Added support for enable-background to SPStyle --- src/display/nr-arena-item.h | 5 ----- src/display/nr-filter.h | 4 +++- src/style.cpp | 42 ++++++++++++++++++++++++++++++++++--- src/style.h | 9 ++++++++ 4 files changed, 51 insertions(+), 9 deletions(-) diff --git a/src/display/nr-arena-item.h b/src/display/nr-arena-item.h index 7a6c67602..d38e44929 100644 --- a/src/display/nr-arena-item.h +++ b/src/display/nr-arena-item.h @@ -59,11 +59,6 @@ #include "gc-soft-ptr.h" #include "nr-arena-forward.h" #include "display/nr-filter.h" -/* TODO: without this, gcc barfs on clause "NR::Filter *filter" later on. - * Obviously we shouldn't need to have the next three rows */ -namespace NR { -class Filter; -} // My testing shows that disabling cache reduces the amount // of leaked memory when many documents are loaded one from the other, diff --git a/src/display/nr-filter.h b/src/display/nr-filter.h index 15a852d10..c1012475c 100644 --- a/src/display/nr-filter.h +++ b/src/display/nr-filter.h @@ -12,7 +12,7 @@ * Released under GNU GPL, read the file 'COPYING' for more information */ -#include "display/nr-arena-item.h" +//#include "display/nr-arena-item.h" #include "display/nr-filter-primitive.h" #include "display/nr-filter-types.h" #include "libnr/nr-pixblock.h" @@ -22,6 +22,8 @@ #include "sp-filter-units.h" #include "gc-managed.h" +struct NRArenaItem; + namespace NR { class Filter : public Inkscape::GC::Managed<> { diff --git a/src/style.cpp b/src/style.cpp index e0d6532d4..6b5a953fd 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -372,6 +372,12 @@ static SPStyleEnum const enum_text_rendering[] = { {NULL, -1} }; +static SPStyleEnum const enum_enable_background[] = { + {"accumulate", SP_CSS_BACKGROUND_ACCUMULATE}, + {"new", SP_CSS_BACKGROUND_NEW}, + {NULL, -1} +}; + /** * Release callback. */ @@ -669,9 +675,12 @@ sp_style_read(SPStyle *style, SPObject *object, Inkscape::XML::Node *repr) if (!style->filter.set) { val = repr->attribute("filter"); if (val) { - sp_style_read_ifilter(&style->filter, val, (object) ? SP_OBJECT_DOCUMENT(object) : NULL); + sp_style_read_ifilter(&style->filter, val, + (object) ? SP_OBJECT_DOCUMENT(object) : NULL); } } + SPS_READ_PENUM_IF_UNSET(&style->enable_background, repr, + "enable-background", enum_enable_background, true); /* 3. Merge from parent */ if (object) { @@ -901,7 +910,8 @@ sp_style_merge_property(SPStyle *style, gint id, gchar const *val) } break; case SP_PROP_ENABLE_BACKGROUND: - g_warning("Unimplemented style property SP_PROP_ENABLE_BACKGROUND: value: %s", val); + SPS_READ_IENUM_IF_UNSET(&style->enable_background, val, + enum_enable_background, true); break; /* Filter */ case SP_PROP_FILTER: @@ -1447,6 +1457,10 @@ sp_style_merge_from_parent(SPStyle *const style, SPStyle const *const parent) if(style->filter.set && style->filter.inherit) { sp_style_merge_ifilter(&style->filter, &parent->filter); } + + if(style->enable_background.inherit) { + style->enable_background.value = parent->enable_background.value; + } } template @@ -1900,6 +1914,18 @@ sp_style_merge_from_dying_parent(SPStyle *const style, SPStyle const *const pare /* Leave as is. (display doesn't inherit by default.) */ } + /* enable-background - this is rather complicated, because + * it is valid only when applied to container elements. + * Let's check a simple case anyhow. */ + if (parent->enable_background.set + && !parent->enable_background.inherit + && style->enable_background.inherit) + { + style->enable_background.set = true; + style->enable_background.inherit = false; + style->enable_background.value = parent->enable_background.value; + } + /** \todo * fixme: Check that we correctly handle all properties that don't * inherit by default (as shown in @@ -2218,6 +2244,8 @@ sp_style_write_string(SPStyle const *const style, guint const flags) /* filter: */ p += sp_style_write_ifilter(p, c + BMAX - p, "filter", &style->filter, NULL, flags); + p += sp_style_write_ienum(p, c + BMAX - p, "enable-background", enum_enable_background, &style->enable_background, NULL, flags); + /* fixme: */ p += sp_text_style_write(p, c + BMAX - p, style->text, flags); @@ -2335,6 +2363,8 @@ sp_style_write_difference(SPStyle const *const from, SPStyle const *const to) /* filter: */ p += sp_style_write_ifilter(p, c + BMAX - p, "filter", &from->filter, &to->filter, SP_STYLE_FLAG_IFDIFF); + p += sp_style_write_ienum(p, c + BMAX - p, "enable-background", enum_enable_background, &from->enable_background, &to->enable_background, SP_STYLE_FLAG_IFSET); + p += sp_text_style_write(p, c + BMAX - p, from->text, SP_STYLE_FLAG_IFDIFF); /** \todo @@ -2487,11 +2517,14 @@ sp_style_clear(SPStyle *style) } style->filter.set = FALSE; -//Are these really needed? + //Are these really needed? style->filter.inherit = FALSE; style->filter.uri = NULL; style->filter.filter = FALSE; + style->enable_background.value = SP_CSS_BACKGROUND_ACCUMULATE; + style->enable_background.set = false; + style->enable_background.inherit = false; } @@ -3704,6 +3737,9 @@ sp_style_unset_property_attrs(SPObject *o) if (style->filter.set) { repr->setAttribute("filter", NULL); } + if (style->enable_background.set) { + repr->setAttribute("enable-background", NULL); + } } /** diff --git a/src/style.h b/src/style.h index ad1459a73..9a70881de 100644 --- a/src/style.h +++ b/src/style.h @@ -336,6 +336,10 @@ struct SPStyle { /** Filter effect */ SPIFilter filter; + /** enable-background, used for defining where filter effects get + * their background image */ + SPIEnum enable_background; + /// style belongs to a cloned object, must not href anything bool cloned; /// style has hreffed its fill/stroke paintservers, needs to release. @@ -501,6 +505,11 @@ enum SPCSSDisplay { SP_CSS_DISPLAY_TABLE_CAPTION }; +enum SPEnableBackground { + SP_CSS_BACKGROUND_ACCUMULATE, + SP_CSS_BACKGROUND_NEW +}; + /// An SPTextStyle has a refcount, a font family, and a font name. struct SPTextStyle { int refcount; -- 2.30.2