summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThomas Holder <thomas@thomas-holder.de>2019-10-28 11:30:14 +0000
committerThomas Holder <thomas@thomas-holder.de>2019-10-28 11:30:14 +0000
commit1a12c0f5f163794584dfe7b25d4f1feb3156cb6d (patch)
treed6c79997499865b493f1986042a4b3f23f945f1e /src
parentUpdate cs.po (diff)
downloadinkscape-1a12c0f5f163794584dfe7b25d4f1feb3156cb6d.tar.gz
inkscape-1a12c0f5f163794584dfe7b25d4f1feb3156cb6d.zip
refactor SPIEnum: more type safety
fixes ungrouping of "font-weight:bolder" fixes "titling-caps" parsing fixes a casting error in CairoRenderContext::renderGlyphtext
Diffstat (limited to 'src')
-rw-r--r--src/desktop-style.cpp63
-rw-r--r--src/display/cairo-utils.cpp9
-rw-r--r--src/display/cairo-utils.h4
-rw-r--r--src/display/drawing-item.cpp4
-rw-r--r--src/display/drawing-item.h12
-rw-r--r--src/extension/internal/cairo-render-context.cpp4
-rw-r--r--src/extension/internal/cairo-render-context.h2
-rw-r--r--src/extension/internal/emf-inout.cpp58
-rw-r--r--src/extension/internal/wmf-inout.cpp60
-rw-r--r--src/object/sp-text.cpp2
-rw-r--r--src/style-enums.h2
-rw-r--r--src/style-internal.cpp223
-rw-r--r--src/style-internal.h89
-rw-r--r--src/style.cpp49
-rw-r--r--src/style.h64
-rw-r--r--src/ui/dialog/objects.cpp6
-rw-r--r--src/ui/widget/filter-effect-chooser.cpp8
-rw-r--r--src/ui/widget/filter-effect-chooser.h8
-rw-r--r--src/ui/widget/object-composite-settings.cpp4
19 files changed, 366 insertions, 305 deletions
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index 160000a78..dc4f0d774 100644
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
@@ -895,7 +895,7 @@ objects_query_strokecap (const std::vector<SPItem*> &objects, SPStyle *style_res
return QUERY_STYLE_NOTHING;
}
- int prev_cap = -1;
+ auto prev_cap = SP_STROKE_LINECAP_BUTT;
bool same_cap = true;
int n_stroked = 0;
@@ -914,7 +914,7 @@ objects_query_strokecap (const std::vector<SPItem*> &objects, SPStyle *style_res
n_stroked ++;
- if (prev_cap != -1 && style->stroke_linecap.value != prev_cap)
+ if (n_stroked > 1 && style->stroke_linecap.value != prev_cap)
same_cap = false;
prev_cap = style->stroke_linecap.value;
}
@@ -945,7 +945,7 @@ objects_query_strokejoin (const std::vector<SPItem*> &objects, SPStyle *style_re
return QUERY_STYLE_NOTHING;
}
- int prev_join = -1;
+ auto prev_join = SP_STROKE_LINEJOIN_MITER;
bool same_join = true;
int n_stroked = 0;
@@ -964,7 +964,7 @@ objects_query_strokejoin (const std::vector<SPItem*> &objects, SPStyle *style_re
n_stroked ++;
- if (prev_join != -1 && style->stroke_linejoin.value != prev_join) {
+ if (n_stroked > 1 && style->stroke_linejoin.value != prev_join) {
same_join = false;
}
prev_join = style->stroke_linejoin.value;
@@ -1299,22 +1299,20 @@ objects_query_fontvariants (const std::vector<SPItem*> &objects, SPStyle *style_
int texts = 0;
SPILigatures* ligatures_res = &(style_res->font_variant_ligatures);
- SPIEnum* position_res = &(style_res->font_variant_position);
- SPIEnum* caps_res = &(style_res->font_variant_caps);
SPINumeric* numeric_res = &(style_res->font_variant_numeric);
SPIEastAsian* asian_res = &(style_res->font_variant_east_asian);
// Stores 'and' of all values
ligatures_res->computed = SP_CSS_FONT_VARIANT_LIGATURES_NORMAL;
- position_res->computed = SP_CSS_FONT_VARIANT_POSITION_NORMAL;
- caps_res->computed = SP_CSS_FONT_VARIANT_CAPS_NORMAL;
+ int position_computed = SP_CSS_FONT_VARIANT_POSITION_NORMAL;
+ int caps_computed = SP_CSS_FONT_VARIANT_CAPS_NORMAL;
numeric_res->computed = SP_CSS_FONT_VARIANT_NUMERIC_NORMAL;
asian_res->computed = SP_CSS_FONT_VARIANT_EAST_ASIAN_NORMAL;
// Stores only differences
ligatures_res->value = 0;
- position_res->value = 0;
- caps_res->value = 0;
+ int position_value = 0;
+ int caps_value = 0;
numeric_res->value = 0;
asian_res->value = 0;
@@ -1331,8 +1329,8 @@ objects_query_fontvariants (const std::vector<SPItem*> &objects, SPStyle *style_
texts ++;
SPILigatures* ligatures_in = &(style->font_variant_ligatures);
- SPIEnum* position_in = &(style->font_variant_position);
- SPIEnum* caps_in = &(style->font_variant_caps);
+ auto* position_in = &(style->font_variant_position);
+ auto* caps_in = &(style->font_variant_caps);
SPINumeric* numeric_in = &(style->font_variant_numeric);
SPIEastAsian* asian_in = &(style->font_variant_east_asian);
@@ -1343,11 +1341,11 @@ objects_query_fontvariants (const std::vector<SPItem*> &objects, SPStyle *style_
ligatures_res->value |= (ligatures_res->computed ^ ligatures_in->computed );
ligatures_res->computed &= ligatures_in->computed;
- position_res->value |= (position_res->computed ^ position_in->computed );
- position_res->computed &= position_in->computed;
+ position_value |= (position_computed ^ position_in->computed);
+ position_computed &= position_in->computed;
- caps_res->value |= (caps_res->computed ^ caps_in->computed );
- caps_res->computed &= caps_in->computed;
+ caps_value |= (caps_computed ^ caps_in->computed);
+ caps_computed &= caps_in->computed;
numeric_res->value |= (numeric_res->computed ^ numeric_in->computed );
numeric_res->computed &= numeric_in->computed;
@@ -1357,8 +1355,8 @@ objects_query_fontvariants (const std::vector<SPItem*> &objects, SPStyle *style_
} else {
ligatures_res->computed = ligatures_in->computed;
- position_res->computed = position_in->computed;
- caps_res->computed = caps_in->computed;
+ position_computed = position_in->computed;
+ caps_computed = caps_in->computed;
numeric_res->computed = numeric_in->computed;
asian_res->computed = asian_in->computed;
}
@@ -1366,9 +1364,15 @@ objects_query_fontvariants (const std::vector<SPItem*> &objects, SPStyle *style_
set = true;
}
+ // violates enum type safety!
+ style_res->font_variant_position.value = static_cast<SPCSSFontVariantPosition>(position_value);
+ style_res->font_variant_position.computed = static_cast<SPCSSFontVariantPosition>(position_computed);
+ style_res->font_variant_caps.value = static_cast<SPCSSFontVariantCaps>(caps_value);
+ style_res->font_variant_caps.computed = static_cast<SPCSSFontVariantCaps>(caps_computed);
+
bool different = (style_res->font_variant_ligatures.value != 0 ||
- style_res->font_variant_position.value != 0 ||
- style_res->font_variant_caps.value != 0 ||
+ position_value != 0 ||
+ caps_value != 0 ||
style_res->font_variant_numeric.value != 0 ||
style_res->font_variant_east_asian.value != 0);
@@ -1704,9 +1708,8 @@ objects_query_fontspecification (const std::vector<SPItem*> &objects, SPStyle *s
int
objects_query_blend (const std::vector<SPItem*> &objects, SPStyle *style_res)
{
- const int empty_prev = -2;
- int blend = 0;
- float blend_prev = empty_prev;
+ auto blend = SP_CSS_BLEND_NORMAL;
+ auto blend_prev = blend;
bool same_blend = true;
guint items = 0;
@@ -1726,10 +1729,10 @@ objects_query_blend (const std::vector<SPItem*> &objects, SPStyle *style_res)
}
// defaults to blend mode = "normal"
else {
- blend = 0;
+ blend = SP_CSS_BLEND_NORMAL;
}
- if(blend_prev != empty_prev && blend_prev != blend)
+ if (items > 1 && blend_prev != blend)
same_blend = false;
blend_prev = blend;
}
@@ -1752,9 +1755,8 @@ objects_query_blend (const std::vector<SPItem*> &objects, SPStyle *style_res)
int objects_query_isolation(const std::vector<SPItem *> &objects, SPStyle *style_res)
{
- const int empty_prev = -2;
- int isolation = 0;
- float isolation_prev = empty_prev;
+ auto isolation = SP_CSS_ISOLATION_AUTO;
+ auto isolation_prev = isolation;
bool same_isolation = true;
guint items = 0;
@@ -1772,12 +1774,11 @@ int objects_query_isolation(const std::vector<SPItem *> &objects, SPStyle *style
if (style->isolation.set) {
isolation = style->isolation.value;
}
- // defaults to blend mode = "normal"
else {
- isolation = 0;
+ isolation = SP_CSS_ISOLATION_AUTO;
}
- if (isolation_prev != empty_prev && isolation_prev != isolation)
+ if (items > 1 && isolation_prev != isolation)
same_isolation = false;
isolation_prev = isolation;
}
diff --git a/src/display/cairo-utils.cpp b/src/display/cairo-utils.cpp
index f560b9f19..f061a22d3 100644
--- a/src/display/cairo-utils.cpp
+++ b/src/display/cairo-utils.cpp
@@ -1252,12 +1252,12 @@ private:
/* None */
};
-unsigned ink_cairo_operator_to_css_blend(cairo_operator_t cairo_operator)
+SPBlendMode ink_cairo_operator_to_css_blend(cairo_operator_t cairo_operator)
{
// All of the blend modes are implemented in Cairo as of 1.10.
// For a detailed description, see:
// http://cairographics.org/operators/
- unsigned res = SP_CSS_BLEND_NORMAL;
+ auto res = SP_CSS_BLEND_NORMAL;
switch (cairo_operator) {
case CAIRO_OPERATOR_MULTIPLY:
res = SP_CSS_BLEND_MULTIPLY;
@@ -1312,7 +1312,7 @@ unsigned ink_cairo_operator_to_css_blend(cairo_operator_t cairo_operator)
return res;
}
-cairo_operator_t ink_css_blend_to_cairo_operator(unsigned css_blend)
+cairo_operator_t ink_css_blend_to_cairo_operator(SPBlendMode css_blend)
{
// All of the blend modes are implemented in Cairo as of 1.10.
// For a detailed description, see:
@@ -1366,9 +1366,10 @@ cairo_operator_t ink_css_blend_to_cairo_operator(unsigned css_blend)
res = CAIRO_OPERATOR_HSL_LUMINOSITY;
break;
case SP_CSS_BLEND_NORMAL:
- default:
res = CAIRO_OPERATOR_OVER;
break;
+ default:
+ g_error("Invalid SPBlendMode %d", css_blend);
}
return res;
}
diff --git a/src/display/cairo-utils.h b/src/display/cairo-utils.h
index 36800f699..232e66600 100644
--- a/src/display/cairo-utils.h
+++ b/src/display/cairo-utils.h
@@ -156,8 +156,8 @@ void ink_cairo_pattern_set_matrix(cairo_pattern_t *cp, Geom::Affine const &m);
void ink_matrix_to_2geom(Geom::Affine &, cairo_matrix_t const &);
void ink_matrix_to_cairo(cairo_matrix_t &, Geom::Affine const &);
-cairo_operator_t ink_css_blend_to_cairo_operator(unsigned blend_mode);
-unsigned ink_cairo_operator_to_css_blend(cairo_operator_t cairo_operator);
+cairo_operator_t ink_css_blend_to_cairo_operator(SPBlendMode blend_mode);
+SPBlendMode ink_cairo_operator_to_css_blend(cairo_operator_t cairo_operator);
cairo_surface_t *ink_cairo_surface_copy(cairo_surface_t *s);
cairo_surface_t *ink_cairo_surface_create_identical(cairo_surface_t *s);
cairo_surface_t *ink_cairo_surface_create_same_size(cairo_surface_t *s, cairo_content_t c);
diff --git a/src/display/drawing-item.cpp b/src/display/drawing-item.cpp
index eba5fb6e2..3cdfc72a9 100644
--- a/src/display/drawing-item.cpp
+++ b/src/display/drawing-item.cpp
@@ -243,7 +243,7 @@ DrawingItem::setAntialiasing(unsigned a)
}
void
-DrawingItem::setIsolation(unsigned isolation)
+DrawingItem::setIsolation(bool isolation)
{
_isolation = isolation;
//if( isolation != 0 ) std::cout << "isolation: " << isolation << std::endl;
@@ -251,7 +251,7 @@ DrawingItem::setIsolation(unsigned isolation)
}
void
-DrawingItem::setBlendMode(unsigned mix_blend_mode)
+DrawingItem::setBlendMode(SPBlendMode mix_blend_mode)
{
_mix_blend_mode = mix_blend_mode;
//if( mix_blend_mode != 0 ) std::cout << "setBlendMode: " << mix_blend_mode << std::endl;
diff --git a/src/display/drawing-item.h b/src/display/drawing-item.h
index 7c8b0cefe..8dd4fc5dc 100644
--- a/src/display/drawing-item.h
+++ b/src/display/drawing-item.h
@@ -21,6 +21,8 @@
#include <exception>
#include <list>
+#include "style-enums.h"
+
namespace Glib {
class ustring;
}
@@ -94,9 +96,6 @@ public:
DrawingItem(Drawing &drawing);
virtual ~DrawingItem();
- unsigned _isolation : 1;
- unsigned _mix_blend_mode : 4;
-
Geom::OptIntRect geometricBounds() const { return _bbox; }
Geom::OptIntRect visualBounds() const { return _drawbox; }
Geom::OptRect itemBounds() const { return _item_bbox; }
@@ -121,8 +120,8 @@ public:
virtual void setChildrenStyle(SPStyle *context_style);
void setOpacity(float opacity);
void setAntialiasing(unsigned a);
- void setIsolation(unsigned isolation); // CSS Compositing and Blending
- void setBlendMode(unsigned blend_mode);
+ void setIsolation(bool isolation); // CSS Compositing and Blending
+ void setBlendMode(SPBlendMode blend_mode);
void setTransform(Geom::Affine const &trans);
void setClip(DrawingItem *item);
void setMask(DrawingItem *item);
@@ -231,6 +230,9 @@ protected:
/// otherwise the group is returned
unsigned _antialias : 2; ///< antialiasing level (NONE/FAST/GOOD(DEFAULT)/BEST)
+ bool _isolation : 1;
+ SPBlendMode _mix_blend_mode;
+
friend class Drawing;
};
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index a1e5b91a8..4d02ec3e3 100644
--- a/src/extension/internal/cairo-render-context.cpp
+++ b/src/extension/internal/cairo-render-context.cpp
@@ -765,7 +765,7 @@ void CairoRenderContext::tagEnd(){
void
-CairoRenderContext::addClipPath(Geom::PathVector const &pv, SPIEnum const *fill_rule)
+CairoRenderContext::addClipPath(Geom::PathVector const &pv, SPIEnum<SPWindRule> const *fill_rule)
{
g_assert( _is_valid );
@@ -1837,7 +1837,7 @@ CairoRenderContext::renderGlyphtext(PangoFont *font, Geom::Affine const &font_ma
}
if (style->mix_blend_mode.set && style->mix_blend_mode.value) {
- cairo_set_operator(_cr, (cairo_operator_t)style->mix_blend_mode.value);
+ cairo_set_operator(_cr, ink_css_blend_to_cairo_operator(style->mix_blend_mode.value));
}
// Text never has markers
diff --git a/src/extension/internal/cairo-render-context.h b/src/extension/internal/cairo-render-context.h
index 1ff5ddeec..12918e66b 100644
--- a/src/extension/internal/cairo-render-context.h
+++ b/src/extension/internal/cairo-render-context.h
@@ -156,7 +156,7 @@ public:
Geom::Affine getParentTransform() const;
/* Clipping methods */
- void addClipPath(Geom::PathVector const &pv, SPIEnum const *fill_rule);
+ void addClipPath(Geom::PathVector const &pv, SPIEnum<SPWindRule> const *fill_rule);
void addClippingRect(double x, double y, double width, double height);
/* Rendering methods */
diff --git a/src/extension/internal/emf-inout.cpp b/src/extension/internal/emf-inout.cpp
index 4be021e9e..27c9cc181 100644
--- a/src/extension/internal/emf-inout.cpp
+++ b/src/extension/internal/emf-inout.cpp
@@ -903,7 +903,7 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType)
snprintf(
tmp, 1023,
"fill-rule:%s;",
- (d->dc[d->level].style.fill_rule.value == 0 ? "evenodd" : "nonzero")
+ (d->dc[d->level].style.fill_rule.value == SP_WIND_RULE_NONZERO ? "evenodd" : "nonzero")
);
tmp_style << tmp;
tmp_style << "fill-opacity:1;";
@@ -958,17 +958,17 @@ Emf::output_style(PEMF_CALLBACK_DATA d, int iType)
tmp_style << "stroke-linecap:" <<
(
- d->dc[d->level].style.stroke_linecap.computed == 0 ? "butt" :
- d->dc[d->level].style.stroke_linecap.computed == 1 ? "round" :
- d->dc[d->level].style.stroke_linecap.computed == 2 ? "square" :
+ d->dc[d->level].style.stroke_linecap.computed == SP_STROKE_LINECAP_BUTT ? "butt" :
+ d->dc[d->level].style.stroke_linecap.computed == SP_STROKE_LINECAP_ROUND ? "round" :
+ d->dc[d->level].style.stroke_linecap.computed == SP_STROKE_LINECAP_SQUARE ? "square" :
"unknown"
) << ";";
tmp_style << "stroke-linejoin:" <<
(
- d->dc[d->level].style.stroke_linejoin.computed == 0 ? "miter" :
- d->dc[d->level].style.stroke_linejoin.computed == 1 ? "round" :
- d->dc[d->level].style.stroke_linejoin.computed == 2 ? "bevel" :
+ d->dc[d->level].style.stroke_linejoin.computed == SP_STROKE_LINEJOIN_MITER ? "miter" :
+ d->dc[d->level].style.stroke_linejoin.computed == SP_STROKE_LINEJOIN_ROUND ? "round" :
+ d->dc[d->level].style.stroke_linejoin.computed == SP_STROKE_LINEJOIN_BEVEL ? "bevel" :
"unknown"
) << ";";
@@ -1114,30 +1114,30 @@ Emf::select_pen(PEMF_CALLBACK_DATA d, int index)
d->dc[d->level].style.stroke_dasharray.values.push_back(spilength);
}
- d->dc[d->level].style.stroke_dasharray.set = 1;
+ d->dc[d->level].style.stroke_dasharray.set = true;
break;
}
case U_PS_SOLID:
default:
{
- d->dc[d->level].style.stroke_dasharray.set = 0;
+ d->dc[d->level].style.stroke_dasharray.set = false;
break;
}
}
switch (pEmr->lopn.lopnStyle & U_PS_ENDCAP_MASK) {
- case U_PS_ENDCAP_ROUND: { d->dc[d->level].style.stroke_linecap.computed = 1; break; }
- case U_PS_ENDCAP_SQUARE: { d->dc[d->level].style.stroke_linecap.computed = 2; break; }
+ case U_PS_ENDCAP_ROUND: { d->dc[d->level].style.stroke_linecap.computed = SP_STROKE_LINECAP_ROUND; break; }
+ case U_PS_ENDCAP_SQUARE: { d->dc[d->level].style.stroke_linecap.computed = SP_STROKE_LINECAP_SQUARE; break; }
case U_PS_ENDCAP_FLAT:
- default: { d->dc[d->level].style.stroke_linecap.computed = 0; break; }
+ default: { d->dc[d->level].style.stroke_linecap.computed = SP_STROKE_LINECAP_BUTT; break; }
}
switch (pEmr->lopn.lopnStyle & U_PS_JOIN_MASK) {
- case U_PS_JOIN_BEVEL: { d->dc[d->level].style.stroke_linejoin.computed = 2; break; }
- case U_PS_JOIN_MITER: { d->dc[d->level].style.stroke_linejoin.computed = 0; break; }
+ case U_PS_JOIN_BEVEL: { d->dc[d->level].style.stroke_linejoin.computed = SP_STROKE_LINEJOIN_BEVEL; break; }
+ case U_PS_JOIN_MITER: { d->dc[d->level].style.stroke_linejoin.computed = SP_STROKE_LINEJOIN_MITER; break; }
case U_PS_JOIN_ROUND:
- default: { d->dc[d->level].style.stroke_linejoin.computed = 1; break; }
+ default: { d->dc[d->level].style.stroke_linejoin.computed = SP_STROKE_LINEJOIN_ROUND; break; }
}
d->dc[d->level].stroke_set = true;
@@ -1191,9 +1191,9 @@ Emf::select_extpen(PEMF_CALLBACK_DATA d, int index)
double dash_length = pix_to_abs_size( d, pEmr->elp.elpStyleEntry[i] );
d->dc[d->level].style.stroke_dasharray.values.emplace_back("temp", dash_length);
}
- d->dc[d->level].style.stroke_dasharray.set = 1;
+ d->dc[d->level].style.stroke_dasharray.set = true;
} else {
- d->dc[d->level].style.stroke_dasharray.set = 0;
+ d->dc[d->level].style.stroke_dasharray.set = false;
}
break;
}
@@ -1228,7 +1228,7 @@ Emf::select_extpen(PEMF_CALLBACK_DATA d, int index)
d->dc[d->level].style.stroke_dasharray.values.push_back(spilength);
}
- d->dc[d->level].style.stroke_dasharray.set = 1;
+ d->dc[d->level].style.stroke_dasharray.set = true;
break;
}
case U_PS_SOLID:
@@ -1240,7 +1240,7 @@ Emf::select_extpen(PEMF_CALLBACK_DATA d, int index)
*/
default:
{
- d->dc[d->level].style.stroke_dasharray.set = 0;
+ d->dc[d->level].style.stroke_dasharray.set = false;
break;
}
}
@@ -1248,18 +1248,18 @@ Emf::select_extpen(PEMF_CALLBACK_DATA d, int index)
switch (pEmr->elp.elpPenStyle & U_PS_ENDCAP_MASK) {
case U_PS_ENDCAP_ROUND:
{
- d->dc[d->level].style.stroke_linecap.computed = 1;
+ d->dc[d->level].style.stroke_linecap.computed = SP_STROKE_LINECAP_ROUND;
break;
}
case U_PS_ENDCAP_SQUARE:
{
- d->dc[d->level].style.stroke_linecap.computed = 2;
+ d->dc[d->level].style.stroke_linecap.computed = SP_STROKE_LINECAP_SQUARE;
break;
}
case U_PS_ENDCAP_FLAT:
default:
{
- d->dc[d->level].style.stroke_linecap.computed = 0;
+ d->dc[d->level].style.stroke_linecap.computed = SP_STROKE_LINECAP_BUTT;
break;
}
}
@@ -1267,18 +1267,18 @@ Emf::select_extpen(PEMF_CALLBACK_DATA d, int index)
switch (pEmr->elp.elpPenStyle & U_PS_JOIN_MASK) {
case U_PS_JOIN_BEVEL:
{
- d->dc[d->level].style.stroke_linejoin.computed = 2;
+ d->dc[d->level].style.stroke_linejoin.computed = SP_STROKE_LINEJOIN_BEVEL;
break;
}
case U_PS_JOIN_MITER:
{
- d->dc[d->level].style.stroke_linejoin.computed = 0;
+ d->dc[d->level].style.stroke_linejoin.computed = SP_STROKE_LINEJOIN_MITER;
break;
}
case U_PS_JOIN_ROUND:
default:
{
- d->dc[d->level].style.stroke_linejoin.computed = 1;
+ d->dc[d->level].style.stroke_linejoin.computed = SP_STROKE_LINEJOIN_ROUND;
break;
}
}
@@ -1431,7 +1431,7 @@ Emf::select_font(PEMF_CALLBACK_DATA d, int index)
pEmr->elfw.elfLogFont.lfWeight == U_FW_BOLD ? SP_CSS_FONT_WEIGHT_BOLD :
pEmr->elfw.elfLogFont.lfWeight == U_FW_EXTRALIGHT ? SP_CSS_FONT_WEIGHT_LIGHTER :
pEmr->elfw.elfLogFont.lfWeight == U_FW_EXTRABOLD ? SP_CSS_FONT_WEIGHT_BOLDER :
- U_FW_NORMAL;
+ SP_CSS_FONT_WEIGHT_NORMAL;
d->dc[d->level].style.font_style.value = (pEmr->elfw.elfLogFont.lfItalic ? SP_CSS_FONT_STYLE_ITALIC : SP_CSS_FONT_STYLE_NORMAL);
d->dc[d->level].style.text_decoration_line.underline = pEmr->elfw.elfLogFont.lfUnderline;
d->dc[d->level].style.text_decoration_line.line_through = pEmr->elfw.elfLogFont.lfStrikeOut;
@@ -2199,7 +2199,9 @@ std::cout << "BEFORE DRAW"
PU_EMRSETPOLYFILLMODE pEmr = (PU_EMRSETPOLYFILLMODE) lpEMFR;
d->dc[d->level].style.fill_rule.value =
- (pEmr->iMode == U_ALTERNATE ? 0 : (pEmr->iMode == U_WINDING ? 1 : 0));
+ (pEmr->iMode == U_ALTERNATE
+ ? SP_WIND_RULE_NONZERO
+ : (pEmr->iMode == U_WINDING ? SP_WIND_RULE_INTERSECT : SP_WIND_RULE_NONZERO));
break;
}
case U_EMR_SETROP2:
@@ -2542,7 +2544,7 @@ std::cout << "BEFORE DRAW"
case U_WHITE_PEN:
{
float val = index == U_BLACK_PEN ? 0 : 1;
- d->dc[d->level].style.stroke_dasharray.set = 0;
+ d->dc[d->level].style.stroke_dasharray.set = false;
d->dc[d->level].style.stroke_width.value = 1.0;
d->dc[d->level].style.stroke.value.color.set( val, val, val );
diff --git a/src/extension/internal/wmf-inout.cpp b/src/extension/internal/wmf-inout.cpp
index f62c41d44..b8c5d6341 100644
--- a/src/extension/internal/wmf-inout.cpp
+++ b/src/extension/internal/wmf-inout.cpp
@@ -808,7 +808,7 @@ Wmf::output_style(PWMF_CALLBACK_DATA d)
snprintf(
tmp, 1023,
"fill-rule:%s;",
- (d->dc[d->level].style.fill_rule.value == 0 ? "evenodd" : "nonzero")
+ (d->dc[d->level].style.fill_rule.value == SP_WIND_RULE_NONZERO ? "evenodd" : "nonzero")
);
tmp_style << tmp;
tmp_style << "fill-opacity:1;";
@@ -867,17 +867,17 @@ Wmf::output_style(PWMF_CALLBACK_DATA d)
tmp_style << "stroke-linecap:" <<
(
- d->dc[d->level].style.stroke_linecap.computed == 0 ? "butt" :
- d->dc[d->level].style.stroke_linecap.computed == 1 ? "round" :
- d->dc[d->level].style.stroke_linecap.computed == 2 ? "square" :
+ d->dc[d->level].style.stroke_linecap.computed == SP_STROKE_LINECAP_BUTT ? "butt" :
+ d->dc[d->level].style.stroke_linecap.computed == SP_STROKE_LINECAP_ROUND ? "round" :
+ d->dc[d->level].style.stroke_linecap.computed == SP_STROKE_LINECAP_SQUARE ? "square" :
"unknown"
) << ";";
tmp_style << "stroke-linejoin:" <<
(
- d->dc[d->level].style.stroke_linejoin.computed == 0 ? "miter" :
- d->dc[d->level].style.stroke_linejoin.computed == 1 ? "round" :
- d->dc[d->level].style.stroke_linejoin.computed == 2 ? "bevel" :
+ d->dc[d->level].style.stroke_linejoin.computed == SP_STROKE_LINEJOIN_MITER ? "miter" :
+ d->dc[d->level].style.stroke_linejoin.computed == SP_STROKE_LINEJOIN_ROUND ? "round" :
+ d->dc[d->level].style.stroke_linejoin.computed == SP_STROKE_LINEJOIN_BEVEL ? "bevel" :
"unknown"
) << ";";
@@ -1005,30 +1005,30 @@ Wmf::select_pen(PWMF_CALLBACK_DATA d, int index)
d->dc[d->level].style.stroke_dasharray.values.push_back(spilength);
}
- d->dc[d->level].style.stroke_dasharray.set = 1;
+ d->dc[d->level].style.stroke_dasharray.set = true;
break;
}
case U_PS_SOLID:
default:
{
- d->dc[d->level].style.stroke_dasharray.set = 0;
+ d->dc[d->level].style.stroke_dasharray.set = false;
break;
}
}
switch (up.Style & U_PS_ENDCAP_MASK) {
- case U_PS_ENDCAP_ROUND: { d->dc[d->level].style.stroke_linecap.computed = 1; break; }
- case U_PS_ENDCAP_SQUARE: { d->dc[d->level].style.stroke_linecap.computed = 2; break; }
+ case U_PS_ENDCAP_ROUND: { d->dc[d->level].style.stroke_linecap.computed = SP_STROKE_LINECAP_ROUND; break; }
+ case U_PS_ENDCAP_SQUARE: { d->dc[d->level].style.stroke_linecap.computed = SP_STROKE_LINECAP_SQUARE; break; }
case U_PS_ENDCAP_FLAT:
- default: { d->dc[d->level].style.stroke_linecap.computed = 0; break; }
+ default: { d->dc[d->level].style.stroke_linecap.computed = SP_STROKE_LINECAP_BUTT; break; }
}
switch (up.Style & U_PS_JOIN_MASK) {
- case U_PS_JOIN_BEVEL: { d->dc[d->level].style.stroke_linejoin.computed = 2; break; }
- case U_PS_JOIN_MITER: { d->dc[d->level].style.stroke_linejoin.computed = 0; break; }
+ case U_PS_JOIN_BEVEL: { d->dc[d->level].style.stroke_linejoin.computed = SP_STROKE_LINEJOIN_BEVEL; break; }
+ case U_PS_JOIN_MITER: { d->dc[d->level].style.stroke_linejoin.computed = SP_STROKE_LINEJOIN_MITER; break; }
case U_PS_JOIN_ROUND:
- default: { d->dc[d->level].style.stroke_linejoin.computed = 1; break; }
+ default: { d->dc[d->level].style.stroke_linejoin.computed = SP_STROKE_LINEJOIN_ROUND; break; }
}
@@ -1202,7 +1202,7 @@ Wmf::select_font(PWMF_CALLBACK_DATA d, int index)
font.Weight == U_FW_BOLD ? SP_CSS_FONT_WEIGHT_BOLD :
font.Weight == U_FW_EXTRALIGHT ? SP_CSS_FONT_WEIGHT_LIGHTER :
font.Weight == U_FW_EXTRABOLD ? SP_CSS_FONT_WEIGHT_BOLDER :
- U_FW_NORMAL;
+ SP_CSS_FONT_WEIGHT_NORMAL;
d->dc[d->level].style.font_style.value = (font.Italic ? SP_CSS_FONT_STYLE_ITALIC : SP_CSS_FONT_STYLE_NORMAL);
d->dc[d->level].style.text_decoration_line.underline = font.Underline;
d->dc[d->level].style.text_decoration_line.line_through = font.StrikeOut;
@@ -1239,9 +1239,9 @@ Wmf::delete_object(PWMF_CALLBACK_DATA d, int index)
// If the active object is deleted set default draw values
if(index == d->dc[d->level].active_pen){ // Use default pen: solid, black, 1 pixel wide
d->dc[d->level].active_pen = -1;
- d->dc[d->level].style.stroke_dasharray.set = 0;
- d->dc[d->level].style.stroke_linecap.computed = 2; // U_PS_ENDCAP_SQUARE
- d->dc[d->level].style.stroke_linejoin.computed = 0; // U_PS_JOIN_MITER;
+ d->dc[d->level].style.stroke_dasharray.set = false;
+ d->dc[d->level].style.stroke_linecap.computed = SP_STROKE_LINECAP_SQUARE; // U_PS_ENDCAP_SQUARE
+ d->dc[d->level].style.stroke_linejoin.computed = SP_STROKE_LINEJOIN_MITER; // U_PS_JOIN_MITER;
d->dc[d->level].stroke_set = true;
d->dc[d->level].style.stroke_width.value = 1.0;
d->dc[d->level].style.stroke.value.color.set( 0, 0, 0 );
@@ -1891,7 +1891,9 @@ std::cout << "BEFORE DRAW"
{
dbg_str << "<!-- U_WMR_SETPOLYFILLMODE -->\n";
nSize = U_WMRSETPOLYFILLMODE_get(contents, &utmp16);
- d->dc[d->level].style.fill_rule.value = (utmp16 == U_ALTERNATE ? 0 : utmp16 == U_WINDING ? 1 : 0);
+ d->dc[d->level].style.fill_rule.value =
+ (utmp16 == U_ALTERNATE ? SP_WIND_RULE_NONZERO
+ : utmp16 == U_WINDING ? SP_WIND_RULE_INTERSECT : SP_WIND_RULE_NONZERO);
break;
}
case U_WMR_SETSTRETCHBLTMODE:
@@ -2405,18 +2407,18 @@ std::cout << "BEFORE DRAW"
memcpy(&utmp4, text ,4);
if(Escape == U_MFE_SETLINECAP){
switch (utmp4 & U_PS_ENDCAP_MASK) {
- case U_PS_ENDCAP_ROUND: { d->dc[d->level].style.stroke_linecap.computed = 1; break; }
- case U_PS_ENDCAP_SQUARE: { d->dc[d->level].style.stroke_linecap.computed = 2; break; }
+ case U_PS_ENDCAP_ROUND: { d->dc[d->level].style.stroke_linecap.computed = SP_STROKE_LINECAP_ROUND; break; }
+ case U_PS_ENDCAP_SQUARE: { d->dc[d->level].style.stroke_linecap.computed = SP_STROKE_LINECAP_SQUARE; break; }
case U_PS_ENDCAP_FLAT:
- default: { d->dc[d->level].style.stroke_linecap.computed = 0; break; }
+ default: { d->dc[d->level].style.stroke_linecap.computed = SP_STROKE_LINECAP_BUTT; break; }
}
}
else if(Escape == U_MFE_SETLINEJOIN){
switch (utmp4 & U_PS_JOIN_MASK) {
- case U_PS_JOIN_BEVEL: { d->dc[d->level].style.stroke_linejoin.computed = 2; break; }
- case U_PS_JOIN_MITER: { d->dc[d->level].style.stroke_linejoin.computed = 0; break; }
+ case U_PS_JOIN_BEVEL: { d->dc[d->level].style.stroke_linejoin.computed = SP_STROKE_LINEJOIN_BEVEL; break; }
+ case U_PS_JOIN_MITER: { d->dc[d->level].style.stroke_linejoin.computed = SP_STROKE_LINEJOIN_MITER; break; }
case U_PS_JOIN_ROUND:
- default: { d->dc[d->level].style.stroke_linejoin.computed = 1; break; }
+ default: { d->dc[d->level].style.stroke_linejoin.computed = SP_STROKE_LINEJOIN_ROUND; break; }
}
}
else if(Escape == U_MFE_SETMITERLIMIT){
@@ -3131,9 +3133,9 @@ Wmf::open( Inkscape::Extension::Input * /*mod*/, const gchar *uri )
d.dc[0].style.baseline_shift.value = 0;
// Default pen, WMF files that do not specify a pen are unlikely to look very good!
- d.dc[0].style.stroke_dasharray.set = 0;
- d.dc[0].style.stroke_linecap.computed = 2; // U_PS_ENDCAP_SQUARE;
- d.dc[0].style.stroke_linejoin.computed = 0; // U_PS_JOIN_MITER;
+ d.dc[0].style.stroke_dasharray.set = false;
+ d.dc[0].style.stroke_linecap.computed = SP_STROKE_LINECAP_SQUARE; // U_PS_ENDCAP_SQUARE;
+ d.dc[0].style.stroke_linejoin.computed = SP_STROKE_LINEJOIN_MITER; // U_PS_JOIN_MITER;
d.dc[0].style.stroke_width.value = 1.0; // will be reset to something reasonable once WMF drawing size is known
d.dc[0].style.stroke.value.color.set( 0, 0, 0 );
d.dc[0].stroke_set = true;
diff --git a/src/object/sp-text.cpp b/src/object/sp-text.cpp
index 94c35169c..3cfae54cb 100644
--- a/src/object/sp-text.cpp
+++ b/src/object/sp-text.cpp
@@ -896,7 +896,7 @@ void SPText::_adjustFontsizeRecursive(SPItem *item, double ex, bool is_root)
if (style && !Geom::are_near(ex, 1.0)) {
if (!style->font_size.set && is_root) {
- style->font_size.set = 1;
+ style->font_size.set = true;
}
style->font_size.type = SP_FONT_SIZE_LENGTH;
style->font_size.computed *= ex;
diff --git a/src/style-enums.h b/src/style-enums.h
index 9ead8e7fb..1e74e3eba 100644
--- a/src/style-enums.h
+++ b/src/style-enums.h
@@ -430,7 +430,7 @@ static SPStyleEnum const enum_font_variant_caps[] = {
{"petite-caps", SP_CSS_FONT_VARIANT_CAPS_PETITE},
{"all-petite-caps", SP_CSS_FONT_VARIANT_CAPS_ALL_PETITE},
{"unicase", SP_CSS_FONT_VARIANT_CAPS_UNICASE},
- {"titling", SP_CSS_FONT_VARIANT_CAPS_TITLING},
+ {"titling-caps", SP_CSS_FONT_VARIANT_CAPS_TITLING},
{nullptr, -1}
};
diff --git a/src/style-internal.cpp b/src/style-internal.cpp
index 3fe9fcb81..8e226c698 100644
--- a/src/style-internal.cpp
+++ b/src/style-internal.cpp
@@ -613,8 +613,28 @@ SPIFontVariationSettings::toString() const {
// SPIEnum --------------------------------------------------------------
-void
-SPIEnum::read( gchar const *str ) {
+template <typename T>
+void SPIEnum<T>::update_computed()
+{
+ computed = value;
+}
+
+template <>
+void SPIEnum<SPCSSFontWeight>::update_computed()
+{
+ // The following is defined in CSS 2.1
+ if (value == SP_CSS_FONT_WEIGHT_NORMAL) {
+ computed = SP_CSS_FONT_WEIGHT_400;
+ } else if (value == SP_CSS_FONT_WEIGHT_BOLD) {
+ computed = SP_CSS_FONT_WEIGHT_700;
+ } else {
+ computed = value;
+ }
+}
+
+template <typename T>
+void SPIEnum<T>::read(gchar const *str)
+{
if( !str ) return;
@@ -626,24 +646,19 @@ SPIEnum::read( gchar const *str ) {
if (!strcmp(str, enums[i].key)) {
set = true;
inherit = false;
- value = enums[i].value;
+ value = static_cast<T>(enums[i].value);
/* Save copying for values not needing it */
- computed = value;
break;
}
}
- // The following is defined in CSS 2.1
- if( name.compare("font-weight" ) == 0 ) {
- if( value == SP_CSS_FONT_WEIGHT_NORMAL ) {
- computed = SP_CSS_FONT_WEIGHT_400;
- } else if (value == SP_CSS_FONT_WEIGHT_BOLD ) {
- computed = SP_CSS_FONT_WEIGHT_700;
- }
- }
+
+ // type-specialized subroutine
+ update_computed();
}
}
-const Glib::ustring SPIEnum::get_value() const
+template <typename T>
+const Glib::ustring SPIEnum<T>::get_value() const
{
if (this->inherit) return Glib::ustring("inherit");
for (unsigned i = 0; enums[i].key; ++i) {
@@ -654,45 +669,79 @@ const Glib::ustring SPIEnum::get_value() const
return Glib::ustring("");
}
-void
-SPIEnum::cascade( const SPIBase* const parent ) {
- if( const SPIEnum* p = dynamic_cast<const SPIEnum*>(parent) ) {
+template <>
+void SPIEnum<SPCSSFontWeight>::update_computed_cascade(SPCSSFontWeight const &p_computed)
+{
+ // strictly, 'bolder' and 'lighter' should go to the next weight
+ // expressible in the current font family, but that's difficult to
+ // find out, so jumping by 3 seems an appropriate approximation
+ if (value == SP_CSS_FONT_WEIGHT_LIGHTER) {
+ computed = static_cast<SPCSSFontWeight>(std::max<int>(SP_CSS_FONT_WEIGHT_100, int(p_computed) - 3));
+ } else if (value == SP_CSS_FONT_WEIGHT_BOLDER) {
+ computed = static_cast<SPCSSFontWeight>(std::min<int>(SP_CSS_FONT_WEIGHT_900, p_computed + 3));
+ }
+}
+
+template <>
+void SPIEnum<SPCSSFontStretch>::update_computed_cascade(SPCSSFontStretch const &p_computed)
+{
+ if (value == SP_CSS_FONT_STRETCH_NARROWER) {
+ computed =
+ static_cast<SPCSSFontStretch>(std::max<int>(SP_CSS_FONT_STRETCH_ULTRA_CONDENSED, int(p_computed) - 1));
+ } else if (value == SP_CSS_FONT_STRETCH_WIDER) {
+ computed = static_cast<SPCSSFontStretch>(std::min<int>(SP_CSS_FONT_STRETCH_ULTRA_EXPANDED, p_computed + 1));
+ }
+}
+
+template <typename T>
+void SPIEnum<T>::cascade(const SPIBase *const parent)
+{
+ if (const auto *p = dynamic_cast<const SPIEnum<T> *>(parent)) {
if( inherits && (!set || inherit) ) {
computed = p->computed;
} else {
- if( name.compare("font-stretch" ) == 0 ) {
- unsigned const parent_val = p->computed;
- if( value == SP_CSS_FONT_STRETCH_NARROWER ) {
- computed = (parent_val == SP_CSS_FONT_STRETCH_ULTRA_CONDENSED ?
- parent_val : parent_val - 1);
- } else if (value == SP_CSS_FONT_STRETCH_WIDER ) {
- computed = (parent_val == SP_CSS_FONT_STRETCH_ULTRA_EXPANDED ?
- parent_val : parent_val + 1);
- }
- }
- // strictly, 'bolder' and 'lighter' should go to the next weight
- // expressible in the current font family, but that's difficult to
- // find out, so jumping by 3 seems an appropriate approximation
- if( name.compare("font-weight" ) == 0 ) {
- unsigned const parent_val = p->computed;
- if( value == SP_CSS_FONT_WEIGHT_LIGHTER ) {
- computed = (parent_val <= SP_CSS_FONT_WEIGHT_100 + 3 ?
- (unsigned)SP_CSS_FONT_WEIGHT_100 : parent_val - 3);
- } else if (value == SP_CSS_FONT_WEIGHT_BOLDER ) {
- computed = (parent_val >= SP_CSS_FONT_WEIGHT_900 - 3 ?
- (unsigned)SP_CSS_FONT_WEIGHT_900 : parent_val + 3);
- }
- }
+ // type-specialized subroutine
+ update_computed_cascade(p->computed);
}
} else {
- std::cerr << "SPIEnum::cascade(): Incorrect parent type" << std::endl;
+ std::cerr << "SPIEnum<T>::cascade(): Incorrect parent type" << std::endl;
}
}
// FIXME Handle font_stretch and font_weight (relative values) New derived class?
-void
-SPIEnum::merge( const SPIBase* const parent ) {
- if( const SPIEnum* p = dynamic_cast<const SPIEnum*>(parent) ) {
+template <typename T>
+void SPIEnum<T>::update_value_merge(SPIEnum<T> const &p, T smaller, T larger)
+{
+ g_assert(set);
+
+ if (value == p.value) {
+ // Leave as is, what does applying "wider" twice do?
+ } else if ((value == smaller && p.value == larger) || //
+ (value == larger && p.value == smaller)) {
+ // Values cancel, unset
+ set = false;
+ } else if (value == smaller || value == larger) {
+ value = computed;
+ inherit = false;
+ }
+}
+
+template <>
+void SPIEnum<SPCSSFontWeight>::update_value_merge(SPIEnum<SPCSSFontWeight> const &p)
+{
+ update_value_merge(p, SP_CSS_FONT_WEIGHT_LIGHTER, SP_CSS_FONT_WEIGHT_BOLDER);
+}
+
+template <>
+void SPIEnum<SPCSSFontStretch>::update_value_merge(SPIEnum<SPCSSFontStretch> const &p)
+{
+ update_value_merge(p, SP_CSS_FONT_STRETCH_NARROWER, SP_CSS_FONT_STRETCH_WIDER);
+}
+
+template <typename T>
+void SPIEnum<T>::merge(const SPIBase *const parent)
+{
+ if (const auto *p = dynamic_cast<const SPIEnum<T> *>(parent)) {
if( inherits ) {
if( p->set && !p->inherit ) {
if( !set || inherit ) {
@@ -701,46 +750,18 @@ SPIEnum::merge( const SPIBase* const parent ) {
value = p->value;
computed = p->computed; // Different from value for font-weight and font-stretch
} else {
- // The following is to special case 'font-stretch' and 'font-weight'
- unsigned max_computed_val = 100;
- unsigned smaller_val = 100;
- if( name.compare("font-stretch" ) == 0 ) {
- max_computed_val = SP_CSS_FONT_STRETCH_ULTRA_EXPANDED;
- smaller_val = SP_CSS_FONT_STRETCH_NARROWER;
- } else if( name.compare("font-weight" ) == 0 ) {
- max_computed_val = SP_CSS_FONT_WEIGHT_900;
- smaller_val = SP_CSS_FONT_WEIGHT_LIGHTER;
- }
- unsigned const min_computed_val = 0;
- unsigned const larger_val = smaller_val + 1;
- if( value < smaller_val ) {
- // Child has absolute value, leave as is.
- // Works for all enum properties
- } else if( (value == smaller_val && p->value == larger_val ) ||
- (value == larger_val && p->value == smaller_val) ) {
- // Values cancel, unset
- set = false;
- } else if( value == p->value ) {
- // Leave as is, what does applying "wider" twice do?
- } else {
- // Child is smaller or larger, adjust parent value accordingly
- unsigned const parent_val = p->computed;
- value = (value == smaller_val ?
- ( parent_val == min_computed_val ? parent_val : parent_val - 1 ) :
- ( parent_val == max_computed_val ? parent_val : parent_val + 1 ) );
- g_assert(value <= max_computed_val);
- inherit = false;
- g_assert(set);
- }
+ // type-specialized subroutine
+ update_value_merge(*p);
}
}
}
}
}
-bool
-SPIEnum::operator==(const SPIBase& rhs) {
- if( const SPIEnum* r = dynamic_cast<const SPIEnum*>(&rhs) ) {
+template <typename T>
+bool SPIEnum<T>::operator==(const SPIBase &rhs)
+{
+ if (auto *r = dynamic_cast<const SPIEnum<T> *>(&rhs)) {
return (computed == r->computed && SPIBase::operator==(rhs));
} else {
return false;
@@ -748,6 +769,7 @@ SPIEnum::operator==(const SPIBase& rhs) {
}
+#if 0
// SPIEnumBits ----------------------------------------------------------
// Used for 'font-variant-xxx'
void
@@ -762,11 +784,11 @@ SPIEnumBits::read( gchar const *str ) {
if (!strcmp(str, enums[i].key)) {
set = true;
inherit = false;
- value += enums[i].value;
- /* Save copying for values not needing it */
- computed = value;
+ value |= enums[i].value;
}
}
+ /* Save copying for values not needing it */
+ computed = value;
}
}
@@ -776,13 +798,14 @@ const Glib::ustring SPIEnumBits::get_value() const
if (this->value == 0) return Glib::ustring("normal");
auto ret = Glib::ustring("");
for (unsigned i = 0; enums[i].key; ++i) {
- if (this->value & (1 << i)) {
+ if (this->value & enums[i].value) {
if (!ret.empty()) ret += " ";
ret += enums[i].key;
}
}
return ret;
}
+#endif
// SPILigatures -----------------------------------------------------
// Used for 'font-variant-ligatures'
@@ -2209,7 +2232,7 @@ SPIFont::read( gchar const *str ) {
} else {
// Try to parse each property in turn
- SPIEnum test_style("font-style", enum_font_style);
+ SPIEnum<SPCSSFontStyle> test_style("font-style", enum_font_style);
test_style.read( lparam.c_str() );
if( test_style.set ) {
style->font_style = test_style;
@@ -2217,7 +2240,7 @@ SPIFont::read( gchar const *str ) {
}
// font-variant (Note: only CSS2.1 value small-caps is valid in shortcut.)
- SPIEnum test_variant("font-variant", enum_font_variant);
+ SPIEnum<SPCSSFontVariant> test_variant("font-variant", enum_font_variant);
test_variant.read( lparam.c_str() );
if( test_variant.set ) {
style->font_variant = test_variant;
@@ -2225,7 +2248,7 @@ SPIFont::read( gchar const *str ) {
}
// font-weight
- SPIEnum test_weight("font-weight", enum_font_weight);
+ SPIEnum<SPCSSFontWeight> test_weight("font-weight", enum_font_weight);
test_weight.read( lparam.c_str() );
if( test_weight.set ) {
style->font_weight = test_weight;
@@ -2233,7 +2256,7 @@ SPIFont::read( gchar const *str ) {
}
// font-stretch (added in CSS 3 Fonts)
- SPIEnum test_stretch("font-stretch", enum_font_stretch);
+ SPIEnum<SPCSSFontStretch> test_stretch("font-stretch", enum_font_stretch);
test_stretch.read( lparam.c_str() );
if( test_stretch.set ) {
style->font_stretch = test_stretch;
@@ -2947,6 +2970,36 @@ SPIVectorEffect::operator==(const SPIBase& rhs) {
}
+// template instantiation
+template class SPIEnum<SPBlendMode>;
+template class SPIEnum<SPColorInterpolation>;
+template class SPIEnum<SPColorRendering>;
+template class SPIEnum<SPCSSBaseline>;
+template class SPIEnum<SPCSSDirection>;
+template class SPIEnum<SPCSSDisplay>;
+template class SPIEnum<SPCSSFontVariantAlternates>;
+template class SPIEnum<SPCSSTextAlign>;
+template class SPIEnum<SPCSSTextOrientation>;
+template class SPIEnum<SPCSSTextTransform>;
+template class SPIEnum<SPCSSWritingMode>;
+template class SPIEnum<SPEnableBackground>;
+template class SPIEnum<SPImageRendering>;
+template class SPIEnum<SPIsolation>;
+template class SPIEnum<SPOverflow>;
+template class SPIEnum<SPShapeRendering>;
+template class SPIEnum<SPStrokeCapType>;
+template class SPIEnum<SPStrokeJoinType>;
+template class SPIEnum<SPTextAnchor>;
+template class SPIEnum<SPTextRendering>;
+template class SPIEnum<SPVisibility>;
+template class SPIEnum<SPWhiteSpace>;
+template class SPIEnum<SPWindRule>;
+template class SPIEnum<SPCSSFontStretch>;
+template class SPIEnum<SPCSSFontStyle>;
+template class SPIEnum<SPCSSFontVariant>;
+template class SPIEnum<SPCSSFontVariantPosition>;
+template class SPIEnum<SPCSSFontVariantCaps>;
+template class SPIEnum<_SPCSSFontVariantLigatures_int>;
diff --git a/src/style-internal.h b/src/style-internal.h
index 8cdf29144..1450f71b9 100644
--- a/src/style-internal.h
+++ b/src/style-internal.h
@@ -37,8 +37,6 @@
#include "xml/repr.h"
-struct SPStyleEnum;
-
static const unsigned SP_STYLE_FLAG_ALWAYS (1 << 2);
static const unsigned SP_STYLE_FLAG_IFSET (1 << 0);
static const unsigned SP_STYLE_FLAG_IFDIFF (1 << 1);
@@ -127,7 +125,7 @@ class SPIBase
{
public:
- SPIBase( Glib::ustring name, bool inherits = true )
+ SPIBase( Glib::ustring name="anonymous", bool inherits = true )
: name(std::move(name)),
inherits(inherits),
set(false),
@@ -212,10 +210,10 @@ public:
// To do: make private
public:
Glib::ustring name; // Make const
- unsigned inherits : 1; // Property inherits by default from parent.
- unsigned set : 1; // Property has been explicitly set (vs. inherited).
- unsigned inherit : 1; // Property value set to 'inherit'.
- unsigned important : 1; // Property rule 'important' has been explicitly set.
+ bool inherits : 1; // Property inherits by default from parent.
+ bool set : 1; // Property has been explicitly set (vs. inherited).
+ bool inherit : 1; // Property value set to 'inherit'.
+ bool important : 1; // Property rule 'important' has been explicitly set.
SPStyleSrc style_src : 2; // Source (attribute, style attribute, style-sheet).
// To do: make private after g_asserts removed
@@ -508,35 +506,21 @@ public:
/// Enum type internal to SPStyle.
// Used for many properties. 'font-stretch' and 'font-weight' must be special cased.
+template <typename T>
class SPIEnum : public SPIBase
{
public:
- SPIEnum() :
- SPIBase( "anonymous_enum" ),
- enums( nullptr ),
- value(0),
- computed(0)
- {}
+ SPIEnum() = delete;
- SPIEnum( Glib::ustring const &name, SPStyleEnum const *enums, unsigned value = 0, bool inherits = true ) :
+ SPIEnum( Glib::ustring const &name, SPStyleEnum const *enums, T value = T(), bool inherits = true ) :
SPIBase( name, inherits ),
enums( enums ),
value(value),
- computed(value),
- value_default(value),
- computed_default(value)
- {}
-
- // Following is needed for font-weight
- SPIEnum( Glib::ustring const &name, SPStyleEnum const *enums, SPCSSFontWeight value, SPCSSFontWeight computed ) :
- SPIBase( name ),
- enums( enums ),
- value(value),
- computed(computed),
- value_default(value),
- computed_default(computed)
- {}
+ value_default(value)
+ {
+ update_computed();
+ }
~SPIEnum() override
= default;
@@ -545,7 +529,8 @@ public:
const Glib::ustring get_value() const override;
void clear() override {
SPIBase::clear();
- value = value_default, computed = computed_default;
+ value = value_default;
+ update_computed();
}
void cascade( const SPIBase* const parent ) override;
@@ -556,7 +541,6 @@ public:
value = rhs.value;
computed = rhs.computed;
value_default = rhs.value_default;
- computed_default = rhs.computed_default;
return *this;
}
@@ -569,15 +553,24 @@ public:
public:
SPStyleEnum const *enums;
- unsigned value : 16; // 9 bits required for 'font-variant-east-asian'
- unsigned computed: 16;
+ T value{};
+ T computed{};
private:
- unsigned value_default : 16;
- unsigned computed_default: 16; // for font-weight
+ T value_default{};
+
+ //! Update computed from value
+ void update_computed();
+ //! Update computed from parent computed
+ void update_computed_cascade(T const &parent_computed) {}
+ //! Update value from parent
+ //! @pre computed is up to date
+ void update_value_merge(SPIEnum<T> const &) {}
+ void update_value_merge(SPIEnum<T> const &, T, T);
};
+#if 0
/// SPIEnum w/ bits, allows values with multiple key words.
class SPIEnumBits : public SPIEnum
{
@@ -597,22 +590,22 @@ public:
void read( gchar const *str ) override;
const Glib::ustring get_value() const override;
};
+#endif
/// SPIEnum w/ extra bits. The 'font-variants-ligatures' property is a complete mess that needs
/// special handling. For OpenType fonts the values 'common-ligatures', 'contextual',
/// 'no-discretionary-ligatures', and 'no-historical-ligatures' are not useful but we still must be
/// able to parse them.
-class SPILigatures : public SPIEnum
+using _SPCSSFontVariantLigatures_int = typename std::underlying_type<SPCSSFontVariantLigatures>::type;
+class SPILigatures : public SPIEnum<_SPCSSFontVariantLigatures_int>
{
public:
- SPILigatures() :
- SPIEnum( "anonymous_enumligatures", nullptr )
- {}
+ SPILigatures() = delete;
SPILigatures( Glib::ustring const &name, SPStyleEnum const *enums) :
- SPIEnum( name, enums, SP_CSS_FONT_VARIANT_LIGATURES_NORMAL )
+ SPIEnum<_SPCSSFontVariantLigatures_int>( name, enums, SP_CSS_FONT_VARIANT_LIGATURES_NORMAL )
{}
~SPILigatures() override
@@ -625,16 +618,15 @@ public:
/// SPIEnum w/ extra bits. The 'font-variants-numeric' property is a complete mess that needs
/// special handling. Multiple key words can be specified, some exclusive of others.
-class SPINumeric : public SPIEnum
+using _SPCSSFontVariantNumeric_int = typename std::underlying_type<SPCSSFontVariantNumeric>::type;
+class SPINumeric : public SPIEnum<_SPCSSFontVariantNumeric_int>
{
public:
- SPINumeric() :
- SPIEnum( "anonymous_enumnumeric", nullptr )
- {}
+ SPINumeric() = delete;
SPINumeric( Glib::ustring const &name, SPStyleEnum const *enums) :
- SPIEnum( name, enums, SP_CSS_FONT_VARIANT_NUMERIC_NORMAL )
+ SPIEnum<_SPCSSFontVariantNumeric_int>( name, enums, SP_CSS_FONT_VARIANT_NUMERIC_NORMAL )
{}
~SPINumeric() override
@@ -647,16 +639,15 @@ public:
/// SPIEnum w/ extra bits. The 'font-variants-east-asian' property is a complete mess that needs
/// special handling. Multiple key words can be specified, some exclusive of others.
-class SPIEastAsian : public SPIEnum
+using _SPCSSFontVariantEastAsian_int = typename std::underlying_type<SPCSSFontVariantEastAsian>::type;
+class SPIEastAsian : public SPIEnum<_SPCSSFontVariantEastAsian_int>
{
public:
- SPIEastAsian() :
- SPIEnum( "anonymous_enumeastasian", nullptr )
- {}
+ SPIEastAsian() = delete;
SPIEastAsian( Glib::ustring const &name, SPStyleEnum const *enums) :
- SPIEnum( name, enums, SP_CSS_FONT_VARIANT_EAST_ASIAN_NORMAL )
+ SPIEnum<_SPCSSFontVariantEastAsian_int>( name, enums, SP_CSS_FONT_VARIANT_EAST_ASIAN_NORMAL )
{}
~SPIEastAsian() override
diff --git a/src/style.cpp b/src/style.cpp
index a985908b1..b75cc898e 100644
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -278,7 +278,7 @@ SPStyle::SPStyle(SPDocument *document_in, SPObject *object_in) :
// Font related properties and 'font' shorthand
font_style( "font-style", enum_font_style, SP_CSS_FONT_STYLE_NORMAL ),
font_variant( "font-variant", enum_font_variant, SP_CSS_FONT_VARIANT_NORMAL ),
- font_weight( "font-weight", enum_font_weight, SP_CSS_FONT_WEIGHT_NORMAL, SP_CSS_FONT_WEIGHT_400 ),
+ font_weight( "font-weight", enum_font_weight, SP_CSS_FONT_WEIGHT_NORMAL ),
font_stretch( "font-stretch", enum_font_stretch, SP_CSS_FONT_STRETCH_NORMAL ),
font_size(),
line_height( "line-height", 1.25 ), // SPILengthOrNormal
@@ -979,23 +979,33 @@ SPStyle::getFontFeatureString() {
if ( !(font_variant_ligatures.value & SP_CSS_FONT_VARIANT_LIGATURES_CONTEXTUAL) )
feature_string += "calt 0, ";
- if ( font_variant_position.value & SP_CSS_FONT_VARIANT_POSITION_SUB )
- feature_string += "subs, ";
- if ( font_variant_position.value & SP_CSS_FONT_VARIANT_POSITION_SUPER )
- feature_string += "sups, ";
-
- if ( font_variant_caps.value & SP_CSS_FONT_VARIANT_CAPS_SMALL )
- feature_string += "smcp, ";
- if ( font_variant_caps.value & SP_CSS_FONT_VARIANT_CAPS_ALL_SMALL )
- feature_string += "smcp, c2sc, ";
- if ( font_variant_caps.value & SP_CSS_FONT_VARIANT_CAPS_PETITE )
- feature_string += "pcap, ";
- if ( font_variant_caps.value & SP_CSS_FONT_VARIANT_CAPS_ALL_PETITE )
- feature_string += "pcap, c2pc, ";
- if ( font_variant_caps.value & SP_CSS_FONT_VARIANT_CAPS_UNICASE )
- feature_string += "unic, ";
- if ( font_variant_caps.value & SP_CSS_FONT_VARIANT_CAPS_TITLING )
- feature_string += "titl, ";
+ switch (font_variant_position.value) {
+ case SP_CSS_FONT_VARIANT_POSITION_SUB:
+ feature_string += "subs, ";
+ break;
+ case SP_CSS_FONT_VARIANT_POSITION_SUPER:
+ feature_string += "sups, ";
+ }
+
+ switch (font_variant_caps.value) {
+ case SP_CSS_FONT_VARIANT_CAPS_SMALL:
+ feature_string += "smcp, ";
+ break;
+ case SP_CSS_FONT_VARIANT_CAPS_ALL_SMALL:
+ feature_string += "smcp, c2sc, ";
+ break;
+ case SP_CSS_FONT_VARIANT_CAPS_PETITE:
+ feature_string += "pcap, ";
+ break;
+ case SP_CSS_FONT_VARIANT_CAPS_ALL_PETITE:
+ feature_string += "pcap, c2pc, ";
+ break;
+ case SP_CSS_FONT_VARIANT_CAPS_UNICASE:
+ feature_string += "unic, ";
+ break;
+ case SP_CSS_FONT_VARIANT_CAPS_TITLING:
+ feature_string += "titl, ";
+ }
if ( font_variant_numeric.value & SP_CSS_FONT_VARIANT_NUMERIC_LINING_NUMS )
feature_string += "lnum, ";
@@ -1043,8 +1053,7 @@ SPStyle::getFontFeatureString() {
feature_string = "normal";
} else {
// Remove last ", "
- feature_string.erase( feature_string.size() - 1 );
- feature_string.erase( feature_string.size() - 1 );
+ feature_string.resize(feature_string.size() - 2);
}
return feature_string;
diff --git a/src/style.h b/src/style.h
index 3179c781b..c2213f308 100644
--- a/src/style.h
+++ b/src/style.h
@@ -102,13 +102,13 @@ public:
/* Font ---------------------------- */
/** Font style */
- SPIEnum font_style;
+ SPIEnum<SPCSSFontStyle> font_style;
/** Which substyle of the font (CSS 2. CSS 3 redefines as shorthand) */
- SPIEnum font_variant;
+ SPIEnum<SPCSSFontVariant> font_variant;
/** Weight of the font */
- SPIEnum font_weight;
+ SPIEnum<SPCSSFontWeight> font_weight;
/** Stretch of the font */
- SPIEnum font_stretch;
+ SPIEnum<SPCSSFontStretch> font_stretch;
/** Size of the font */
SPIFontSize font_size;
/** Line height (css2 10.8.1) */
@@ -124,13 +124,13 @@ public:
/** Font variant ligatures */
SPILigatures font_variant_ligatures;
/** Font variant position (subscript/superscript) */
- SPIEnum font_variant_position;
+ SPIEnum<SPCSSFontVariantPosition> font_variant_position;
/** Font variant caps (small caps) */
- SPIEnum font_variant_caps;
+ SPIEnum<SPCSSFontVariantCaps> font_variant_caps;
/** Font variant numeric (numerical formatting) */
SPINumeric font_variant_numeric;
/** Font variant alternates (alternates/swatches) */
- SPIEnum font_variant_alternates;
+ SPIEnum<SPCSSFontVariantAlternates> font_variant_alternates;
/** Font variant East Asian */
SPIEastAsian font_variant_east_asian;
/** Font feature settings (Low level access to TrueType tables) */
@@ -144,33 +144,33 @@ public:
/** First line indent of paragraphs (css2 16.1) */
SPILength text_indent;
/** text alignment (css2 16.2) (not to be confused with text-anchor) */
- SPIEnum text_align;
+ SPIEnum<SPCSSTextAlign> text_align;
/** letter spacing (css2 16.4) */
SPILengthOrNormal letter_spacing;
/** word spacing (also css2 16.4) */
SPILengthOrNormal word_spacing;
/** capitalization (css2 16.5) */
- SPIEnum text_transform;
+ SPIEnum<SPCSSTextTransform> text_transform;
/* CSS3 Text */
/** text direction (svg1.1) */
- SPIEnum direction;
+ SPIEnum<SPCSSDirection> direction;
/** Writing mode (svg1.1 10.7.2, CSS Writing Modes 3) */
- SPIEnum writing_mode;
+ SPIEnum<SPCSSWritingMode> writing_mode;
/** Text orientation (CSS Writing Modes 3) */
- SPIEnum text_orientation;
+ SPIEnum<SPCSSTextOrientation> text_orientation;
/** Dominant baseline (svg1.1) */
- SPIEnum dominant_baseline;
+ SPIEnum<SPCSSBaseline> dominant_baseline;
/** Baseline shift (svg1.1 10.9.2) */
SPIBaselineShift baseline_shift;
/* SVG */
/** Anchor of the text (svg1.1 10.9.1) */
- SPIEnum text_anchor;
+ SPIEnum<SPTextAnchor> text_anchor;
/** white space (svg2) */
- SPIEnum white_space;
+ SPIEnum<SPWhiteSpace> white_space;
/** SVG2 Text Wrapping */
SPIShapes shape_inside;
@@ -198,32 +198,32 @@ public:
/* General visual properties ------------- */
/** clip-rule: 0 nonzero, 1 evenodd */
- SPIEnum clip_rule;
+ SPIEnum<SPWindRule> clip_rule;
/** display */
- SPIEnum display;
+ SPIEnum<SPCSSDisplay> display;
/** overflow */
- SPIEnum overflow;
+ SPIEnum<SPOverflow> overflow;
/** visibility */
- SPIEnum visibility;
+ SPIEnum<SPVisibility> visibility;
/** opacity */
SPIScale24 opacity;
/** mix-blend-mode: CSS Compositing and Blending Level 1 */
- SPIEnum isolation;
- SPIEnum mix_blend_mode;
+ SPIEnum<SPIsolation> isolation;
+ SPIEnum<SPBlendMode> mix_blend_mode;
SPIPaintOrder paint_order;
/** color */
SPIColor color;
/** color-interpolation */
- SPIEnum color_interpolation;
+ SPIEnum<SPColorInterpolation> color_interpolation;
/** color-interpolation-filters */
- SPIEnum color_interpolation_filters;
+ SPIEnum<SPColorInterpolation> color_interpolation_filters;
/** solid-color */
SPIColor solid_color;
@@ -238,16 +238,16 @@ public:
/** fill-opacity */
SPIScale24 fill_opacity;
/** fill-rule: 0 nonzero, 1 evenodd */
- SPIEnum fill_rule;
+ SPIEnum<SPWindRule> fill_rule;
/** stroke */
SPIPaint stroke;
/** stroke-width */
SPILength stroke_width;
/** stroke-linecap */
- SPIEnum stroke_linecap;
+ SPIEnum<SPStrokeCapType> stroke_linecap;
/** stroke-linejoin */
- SPIEnum stroke_linejoin;
+ SPIEnum<SPStrokeJoinType> stroke_linejoin;
/** stroke-miterlimit */
SPIFloat stroke_miterlimit;
/** stroke-dasharray */
@@ -269,12 +269,12 @@ public:
/** Filter effect */
SPIFilter filter;
/** Filter blend mode */
- SPIEnum filter_blend_mode;
+ SPIEnum<SPBlendMode> filter_blend_mode;
/** normally not used, but duplicates the Gaussian blur deviation (if any) from the attached
filter when the style is used for querying */
SPILength filter_gaussianBlur_deviation;
/** enable-background, used for defining where filter effects get their background image */
- SPIEnum enable_background;
+ SPIEnum<SPEnableBackground> enable_background;
/** gradient-stop */
SPIColor stop_color;
@@ -284,10 +284,10 @@ public:
/** hints on how to render: e.g. speed vs. accuracy.
* As of April, 2013, only image_rendering used. */
- SPIEnum color_rendering;
- SPIEnum image_rendering;
- SPIEnum shape_rendering;
- SPIEnum text_rendering;
+ SPIEnum<SPColorRendering> color_rendering;
+ SPIEnum<SPImageRendering> image_rendering;
+ SPIEnum<SPShapeRendering> shape_rendering;
+ SPIEnum<SPTextRendering> text_rendering;
/* ----------------------- END PROPERTIES ------------------------- */
diff --git a/src/ui/dialog/objects.cpp b/src/ui/dialog/objects.cpp
index 13e6c97bc..821037a8d 100644
--- a/src/ui/dialog/objects.cpp
+++ b/src/ui/dialog/objects.cpp
@@ -501,7 +501,7 @@ void ObjectsPanel::_setCompositingValues(SPItem *item)
_blurConnection.block();
// Set the isolation
- int isolation = item->style->isolation.set ? item->style->isolation.value : SP_CSS_ISOLATION_AUTO;
+ auto isolation = item->style->isolation.set ? item->style->isolation.value : SP_CSS_ISOLATION_AUTO;
_filter_modifier.set_isolation_mode(isolation, true);
// Set the opacity
double opacity = (item->style->opacity.set ? SP_SCALE24_TO_FLOAT(item->style->opacity.value) : 1);
@@ -1574,7 +1574,7 @@ void ObjectsPanel::_isolationChangedIter(const Gtk::TreeIter &iter)
if (item->style->isolation.value == SP_CSS_ISOLATION_ISOLATE) {
item->style->mix_blend_mode.set = TRUE;
item->style->mix_blend_mode.value = SP_CSS_BLEND_NORMAL;
- _filter_modifier.set_blend_mode(0, false);
+ _filter_modifier.set_blend_mode(SP_CSS_BLEND_NORMAL, false);
}
item->updateRepr(SP_OBJECT_WRITE_NO_CHILDREN | SP_OBJECT_WRITE_EXT);
}
@@ -1607,7 +1607,7 @@ void ObjectsPanel::_blendChangedIter(const Gtk::TreeIter &iter)
item->style->isolation.value == SP_CSS_ISOLATION_ISOLATE)
{
item->style->mix_blend_mode.value = SP_CSS_BLEND_NORMAL;
- _filter_modifier.set_blend_mode(0, false);
+ _filter_modifier.set_blend_mode(SP_CSS_BLEND_NORMAL, false);
} else {
item->style->mix_blend_mode.value = _filter_modifier.get_blend_mode();
}
diff --git a/src/ui/widget/filter-effect-chooser.cpp b/src/ui/widget/filter-effect-chooser.cpp
index d0442bddd..a3e2368f1 100644
--- a/src/ui/widget/filter-effect-chooser.cpp
+++ b/src/ui/widget/filter-effect-chooser.cpp
@@ -142,18 +142,18 @@ sigc::signal<void>& SimpleFilterModifier::signal_opacity_changed()
return _signal_opacity_changed;
}
-int SimpleFilterModifier::get_isolation_mode()
+SPIsolation SimpleFilterModifier::get_isolation_mode()
{
return _isolation.get_active() ? SP_CSS_ISOLATION_ISOLATE : SP_CSS_ISOLATION_AUTO;
}
-void SimpleFilterModifier::set_isolation_mode(const int val, bool notify)
+void SimpleFilterModifier::set_isolation_mode(const SPIsolation val, bool notify)
{
_notify = notify;
_isolation.set_active(val == SP_CSS_ISOLATION_ISOLATE);
}
-int SimpleFilterModifier::get_blend_mode()
+SPBlendMode SimpleFilterModifier::get_blend_mode()
{
const Util::EnumData<SPBlendMode> *d = _blend.get_active_data();
if (d) {
@@ -163,7 +163,7 @@ int SimpleFilterModifier::get_blend_mode()
}
}
-void SimpleFilterModifier::set_blend_mode(const int val, bool notify)
+void SimpleFilterModifier::set_blend_mode(const SPBlendMode val, bool notify)
{
_notify = notify;
_blend.set_active(val);
diff --git a/src/ui/widget/filter-effect-chooser.h b/src/ui/widget/filter-effect-chooser.h
index 1892ba463..c19303e95 100644
--- a/src/ui/widget/filter-effect-chooser.h
+++ b/src/ui/widget/filter-effect-chooser.h
@@ -42,11 +42,11 @@ public:
sigc::signal<void> &signal_opacity_changed();
sigc::signal<void> &signal_isolation_changed();
- int get_isolation_mode();
- void set_isolation_mode(const int, bool notify);
+ SPIsolation get_isolation_mode();
+ void set_isolation_mode(const SPIsolation, bool notify);
- int get_blend_mode();
- void set_blend_mode(const int, bool notify);
+ SPBlendMode get_blend_mode();
+ void set_blend_mode(const SPBlendMode, bool notify);
double get_blur_value() const;
void set_blur_value(const double);
diff --git a/src/ui/widget/object-composite-settings.cpp b/src/ui/widget/object-composite-settings.cpp
index 974c46b18..d628870e2 100644
--- a/src/ui/widget/object-composite-settings.cpp
+++ b/src/ui/widget/object-composite-settings.cpp
@@ -259,14 +259,14 @@ ObjectCompositeSettings::_subjectChanged() {
const int blend_result = _subject->queryStyle(&query, QUERY_STYLE_PROPERTY_BLEND);
switch(blend_result) {
case QUERY_STYLE_NOTHING:
- _filter_modifier.set_blend_mode(0, false);
+ _filter_modifier.set_blend_mode(SP_CSS_BLEND_NORMAL, false);
break;
case QUERY_STYLE_SINGLE:
case QUERY_STYLE_MULTIPLE_SAME:
_filter_modifier.set_blend_mode(query.mix_blend_mode.value, true); // here dont work mix_blend_mode.set
break;
case QUERY_STYLE_MULTIPLE_DIFFERENT:
- _filter_modifier.set_blend_mode(0, false);
+ _filter_modifier.set_blend_mode(SP_CSS_BLEND_NORMAL, false);
break;
}