summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 8fbc250)
raw | patch | inline | side by side (parent: 8fbc250)
author | joncruz <joncruz@users.sourceforge.net> | |
Mon, 10 Sep 2007 06:33:47 +0000 (06:33 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Mon, 10 Sep 2007 06:33:47 +0000 (06:33 +0000) |
30 files changed:
diff --git a/src/desktop-style.cpp b/src/desktop-style.cpp
index 56fc9d4be7fc14552b7103587d249e8a3ab53b02..a68c99d65c887ed3e095a9876e15eceaaa88e019 100644 (file)
--- a/src/desktop-style.cpp
+++ b/src/desktop-style.cpp
double
sp_desktop_get_font_size_tool(SPDesktop *desktop)
{
+ (void)desktop; // TODO cleanup
gchar const *desktop_style = inkscape_get_repr(INKSCAPE, "desktop")->attribute("style");
gchar const *style_str = NULL;
if ((prefs_get_int_attribute("tools.text", "usecurrent", 0) != 0) && desktop_style) {
SPObject *object = SP_OBJECT(l->data);
- if ( object->style->stroke.type == SP_PAINT_TYPE_NONE ) {
+ if ( object->style->stroke.isNone() ) {
++n_notstroked; // do not count nonstroked objects
continue;
} else {
@@ -420,7 +421,7 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill
}
SPIPaint *paint_res = isfill? &style_res->fill : &style_res->stroke;
- paint_res->type = SP_PAINT_TYPE_IMPOSSIBLE;
+ bool paintImpossible = true;
paint_res->set = TRUE;
gfloat c[4];
@@ -440,18 +441,18 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill
// We consider paint "effectively set" for anything within text hierarchy
SPObject *parent = SP_OBJECT_PARENT (obj);
- bool paint_effectively_set =
+ bool paint_effectively_set =
paint->set || (SP_IS_TEXT(parent) || SP_IS_TEXTPATH(parent) || SP_IS_TSPAN(parent)
- || SP_IS_FLOWTEXT(parent) || SP_IS_FLOWDIV(parent) || SP_IS_FLOWPARA(parent)
+ || SP_IS_FLOWTEXT(parent) || SP_IS_FLOWDIV(parent) || SP_IS_FLOWPARA(parent)
|| SP_IS_FLOWTSPAN(parent) || SP_IS_FLOWLINE(parent));
// 1. Bail out with QUERY_STYLE_MULTIPLE_DIFFERENT if necessary
- if ((paint_res->type != SP_PAINT_TYPE_IMPOSSIBLE) && (paint->type != paint_res->type || (paint_res->set != paint_effectively_set))) {
+ if ((!paintImpossible) && (!paint->isSameType(*paint_res) || (paint_res->set != paint_effectively_set))) {
return QUERY_STYLE_MULTIPLE_DIFFERENT; // different types of paint
}
- if (paint_res->set && paint->set && paint_res->type == SP_PAINT_TYPE_PAINTSERVER) {
+ if (paint_res->set && paint->set && paint_res->isPaintserver()) {
// both previous paint and this paint were a server, see if the servers are compatible
SPPaintServer *server_res = isfill? SP_STYLE_FILL_SERVER (style_res) : SP_STYLE_STROKE_SERVER (style_res);
@@ -491,16 +492,16 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill
// 2. Sum color, copy server from paint to paint_res
- if (paint_res->set && paint_effectively_set && paint->type == SP_PAINT_TYPE_COLOR) {
-
+ if (paint_res->set && paint_effectively_set && paint->isColor()) {
gfloat d[3];
sp_color_get_rgb_floatv (&paint->value.color, d);
// Check if this color is the same as previous
- if (paint_res->type == SP_PAINT_TYPE_IMPOSSIBLE) {
+ if (paintImpossible) {
prev[0] = d[0];
prev[1] = d[1];
prev[2] = d[2];
+ paint_res->setColor(d[0], d[1], d[2]);
} else {
if (same_color && (prev[0] != d[0] || prev[1] != d[1] || prev[2] != d[2]))
same_color = false;
@@ -514,8 +515,8 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill
num ++;
}
- paint_res->type = paint->type;
- if (paint_res->set && paint_effectively_set && paint->type == SP_PAINT_TYPE_PAINTSERVER) { // copy the server
+ paintImpossible = false;
+ if (paint_res->set && paint_effectively_set && paint->isPaintserver()) { // copy the server
if (isfill) {
sp_style_set_to_uri_string (style_res, true, style->getFillURI());
} else {
@@ -527,14 +528,14 @@ objects_query_fillstroke (GSList *objects, SPStyle *style_res, bool const isfill
}
// After all objects processed, divide the color if necessary and return
- if (paint_res->set && paint_res->type == SP_PAINT_TYPE_COLOR) { // set the color
+ if (paint_res->set && paint_res->isColor()) { // set the color
g_assert (num >= 1);
c[0] /= num;
c[1] /= num;
c[2] /= num;
c[3] /= num;
- sp_color_set_rgb_float(&paint_res->value.color, c[0], c[1], c[2]);
+ paint_res->setColor(c[0], c[1], c[2]);
if (isfill) {
style_res->fill_opacity.value = SP_SCALE24_FROM_FLOAT (c[3]);
} else {
SPStyle *style = SP_OBJECT_STYLE (obj);
if (!style) continue;
- if ( style->stroke.type == SP_PAINT_TYPE_NONE ) {
+ if ( style->stroke.isNone() ) {
continue;
}
SPStyle *style = SP_OBJECT_STYLE (obj);
if (!style) continue;
- if ( style->stroke.type == SP_PAINT_TYPE_NONE ) {
+ if ( style->stroke.isNone() ) {
continue;
}
SPStyle *style = SP_OBJECT_STYLE (obj);
if (!style) continue;
- if ( style->stroke.type == SP_PAINT_TYPE_NONE ) {
+ if ( style->stroke.isNone() ) {
continue;
}
SPStyle *style = SP_OBJECT_STYLE (obj);
if (!style) continue;
- if ( style->stroke.type == SP_PAINT_TYPE_NONE ) {
+ if ( style->stroke.isNone() ) {
continue;
}
index 7ff5ebc96d7f9542c5089da53fdbe444dac05476..3d830027c60fa5438e86103233c7c5fe63e98443 100644 (file)
sp_paint_selector_set_fillrule (psel, query->fill_rule.computed == ART_WIND_RULE_NONZERO?
SP_PAINT_SELECTOR_FILLRULE_NONZERO : SP_PAINT_SELECTOR_FILLRULE_EVENODD);
- if (query->fill.set && query->fill.type == SP_PAINT_TYPE_COLOR) {
+ if (query->fill.set && query->fill.isColor()) {
gfloat d[3];
sp_color_get_rgb_floatv (&query->fill.value.color, d);
SPColor color;
sp_color_set_rgb_float (&color, d[0], d[1], d[2]);
sp_paint_selector_set_color_alpha (psel, &color, SP_SCALE24_TO_FLOAT (query->fill_opacity.value));
- } else if (query->fill.set && query->fill.type == SP_PAINT_TYPE_PAINTSERVER) {
+ } else if (query->fill.set && query->fill.isPaintserver()) {
SPPaintServer *server = SP_STYLE_FILL_SERVER (query);
int result = objects_query_fillstroke ((GSList *) items, query, true);
guint32 common_rgb = 0;
if (result == QUERY_STYLE_MULTIPLE_SAME) {
- if (query->fill.type != SP_PAINT_TYPE_COLOR) {
+ if (!query->fill.isColor()) {
common_rgb = sp_desktop_get_color(desktop, true);
} else {
common_rgb = sp_color_get_rgba32_ualpha(&query->fill.value.color, 0xff);
SPObject *selobj = SP_OBJECT (i->data);
SPStyle *style = SP_OBJECT_STYLE (selobj);
- if (style && style->fill.type == SP_PAINT_TYPE_PAINTSERVER) {
+ if (style && style->fill.isPaintserver()) {
SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (selobj);
if (SP_IS_PATTERN (server) && pattern_getroot (SP_PATTERN(server)) == pattern)
// only if this object's pattern is not rooted in our selected pattern, apply
index c7e8d8989287631654fc70d93b3de813fedc3b1d..de367b66f929554ecdb678fe2c4b82e6e6a223ed 100644 (file)
SPPaintSelectorMode pselmode = sp_style_determine_paint_selector_mode (query, false);
sp_paint_selector_set_mode (psel, pselmode);
- if (query->stroke.set && query->stroke.type == SP_PAINT_TYPE_COLOR) {
- gfloat d[3];
- sp_color_get_rgb_floatv (&query->stroke.value.color, d);
- SPColor color;
- sp_color_set_rgb_float (&color, d[0], d[1], d[2]);
- sp_paint_selector_set_color_alpha (psel, &color, SP_SCALE24_TO_FLOAT (query->stroke_opacity.value));
-
- } else if (query->stroke.set && query->stroke.type == SP_PAINT_TYPE_PAINTSERVER) {
+ if (query->stroke.set && query->stroke.isPaintserver()) {
SPPaintServer *server = SP_STYLE_STROKE_SERVER (query);
SPPattern *pat = pattern_getroot (SP_PATTERN (server));
sp_update_pattern_list (psel, pat);
}
+ } else if (query->stroke.set && query->stroke.isColor()) {
+ gfloat d[3];
+ sp_color_get_rgb_floatv (&query->stroke.value.color, d);
+ SPColor color;
+ sp_color_set_rgb_float (&color, d[0], d[1], d[2]);
+ sp_paint_selector_set_color_alpha (psel, &color, SP_SCALE24_TO_FLOAT (query->stroke_opacity.value));
+
}
break;
}
int result = objects_query_fillstroke ((GSList *) items, query, false);
guint32 common_rgb = 0;
if (result == QUERY_STYLE_MULTIPLE_SAME) {
- if (query->fill.type != SP_PAINT_TYPE_COLOR) {
+ if (!query->fill.isColor()) {
common_rgb = sp_desktop_get_color(desktop, false);
} else {
common_rgb = sp_color_get_rgba32_ualpha(&query->stroke.value.color, 0xff);
continue;
SPStyle *style = SP_OBJECT_STYLE (selobj);
- if (style && style->stroke.type == SP_PAINT_TYPE_PAINTSERVER) {
+ if (style && style->stroke.isPaintserver()) {
SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (selobj);
if (SP_IS_PATTERN (server) && pattern_getroot (SP_PATTERN(server)) == pattern)
// only if this object's pattern is not rooted in our selected pattern, apply
index 65c5b378f7a7ae18fb5bd770f8d88898197b6526..3933625c39ed6702c4f303defcfb52a90eb30665 100644 (file)
@@ -129,8 +129,10 @@ nr_arena_glyphs_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint state,
glyphs = NR_ARENA_GLYPHS(item);
- if (!glyphs->font || !glyphs->style) return NR_ARENA_ITEM_STATE_ALL;
- if ((glyphs->style->fill.type == SP_PAINT_TYPE_NONE) && (glyphs->style->stroke.type == SP_PAINT_TYPE_NONE)) return NR_ARENA_ITEM_STATE_ALL;
+ if (!glyphs->font || !glyphs->style)
+ return NR_ARENA_ITEM_STATE_ALL;
+ if ((glyphs->style->fill.isNone()) && (glyphs->style->stroke.isNone()))
+ return NR_ARENA_ITEM_STATE_ALL;
NRRect bbox;
bbox.x0 = bbox.y0 = NR_HUGE;
float const scale = NR_MATRIX_DF_EXPANSION(&gc->transform);
- if (glyphs->style->fill.type != SP_PAINT_TYPE_NONE) {
+ if (!glyphs->style->fill.isNone()) {
NRMatrix t;
nr_matrix_multiply(&t, &glyphs->g_transform, &gc->transform);
glyphs->x = t.c[4];
if (glyphs->rfont) glyphs->rfont->Unref();
glyphs->rfont = rfont;
- if (glyphs->style->stroke.type == SP_PAINT_TYPE_NONE || fabs(glyphs->style->stroke_width.computed * scale) <= 0.01) { // Optimization: do fill bbox only if there's no stroke
+ if (glyphs->style->stroke.isNone() || fabs(glyphs->style->stroke_width.computed * scale) <= 0.01) { // Optimization: do fill bbox only if there's no stroke
NRRect narea;
if ( glyphs->rfont ) glyphs->rfont->BBox(glyphs->glyph, &narea);
bbox.x0 = narea.x0 + glyphs->x;
bbox.x1 = narea.x1 + glyphs->x;
bbox.y1 = narea.y1 + glyphs->y;
}
- }
+ }
- if (glyphs->style->stroke.type != SP_PAINT_TYPE_NONE) {
+ if (!glyphs->style->stroke.isNone()) {
/* Build state data */
NRMatrix t;
nr_matrix_multiply(&t, &glyphs->g_transform, &gc->transform);
@@ -404,21 +406,21 @@ nr_arena_glyphs_group_update(NRArenaItem *item, NRRectL *area, NRGC *gc, guint s
}
item->render_opacity = TRUE;
- if (group->style->fill.type == SP_PAINT_TYPE_PAINTSERVER) {
+ if (group->style->fill.isPaintserver()) {
group->fill_painter = sp_paint_server_painter_new(SP_STYLE_FILL_SERVER(group->style),
NR::Matrix(&gc->transform), NR::Matrix(&gc->parent->transform),
&group->paintbox);
item->render_opacity = FALSE;
}
- if (group->style->stroke.type == SP_PAINT_TYPE_PAINTSERVER) {
+ if (group->style->stroke.isPaintserver()) {
group->stroke_painter = sp_paint_server_painter_new(SP_STYLE_STROKE_SERVER(group->style),
NR::Matrix(&gc->transform), NR::Matrix(&gc->parent->transform),
&group->paintbox);
item->render_opacity = FALSE;
}
- if ( item->render_opacity == TRUE && group->style->stroke.type != SP_PAINT_TYPE_NONE && group->style->fill.type != SP_PAINT_TYPE_NONE ) {
+ if ( item->render_opacity == TRUE && !group->style->stroke.isNone() && !group->style->fill.isNone() ) {
item->render_opacity=FALSE;
}
@@ -469,7 +471,7 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi
/* Fill */
- if (style->fill.type != SP_PAINT_TYPE_NONE || item->arena->rendermode == RENDERMODE_OUTLINE) {
+ if (!style->fill.isNone() || item->arena->rendermode == RENDERMODE_OUTLINE) {
NRPixBlock m;
nr_pixblock_setup_fast(&m, NR_PIXBLOCK_MODE_A8, area->x0, area->y0, area->x1, area->y1, TRUE);
@@ -491,7 +493,11 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi
}
/* Composite into buffer */
- if (style->fill.type == SP_PAINT_TYPE_COLOR || item->arena->rendermode == RENDERMODE_OUTLINE) {
+ if (style->fill.isPaintserver()) {
+ if (ggroup->fill_painter) {
+ nr_arena_render_paintserver_fill(pb, area, ggroup->fill_painter, SP_SCALE24_TO_FLOAT(style->fill_opacity.value), &m);
+ }
+ } else if (style->fill.isColor() || item->arena->rendermode == RENDERMODE_OUTLINE) {
guint32 rgba;
if (item->arena->rendermode == RENDERMODE_OUTLINE) {
// In outline mode, render fill only, using outlinecolor
@@ -505,17 +511,13 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi
}
nr_blit_pixblock_mask_rgba32(pb, &m, rgba);
pb->empty = FALSE;
- } else if (style->fill.type == SP_PAINT_TYPE_PAINTSERVER) {
- if (ggroup->fill_painter) {
- nr_arena_render_paintserver_fill(pb, area, ggroup->fill_painter, SP_SCALE24_TO_FLOAT(style->fill_opacity.value), &m);
- }
}
nr_pixblock_release(&m);
}
/* Stroke */
- if (style->stroke.type != SP_PAINT_TYPE_NONE && !(item->arena->rendermode == RENDERMODE_OUTLINE)) {
+ if (!style->stroke.isNone() && !(item->arena->rendermode == RENDERMODE_OUTLINE)) {
NRPixBlock m;
guint32 rgba;
nr_pixblock_setup_fast(&m, NR_PIXBLOCK_MODE_A8, area->x0, area->y0, area->x1, area->y1, TRUE);
@@ -536,26 +538,23 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi
}
}
/* Composite into buffer */
- switch (style->stroke.type) {
- case SP_PAINT_TYPE_COLOR:
- if ( item->render_opacity ) {
- rgba = sp_color_get_rgba32_falpha(&style->stroke.value.color,
- SP_SCALE24_TO_FLOAT(style->stroke_opacity.value) *
- SP_SCALE24_TO_FLOAT(style->opacity.value));
- } else {
- rgba = sp_color_get_rgba32_falpha(&style->stroke.value.color,
- SP_SCALE24_TO_FLOAT(style->stroke_opacity.value));
- }
- nr_blit_pixblock_mask_rgba32(pb, &m, rgba);
- pb->empty = FALSE;
- break;
- case SP_PAINT_TYPE_PAINTSERVER:
- if (ggroup->stroke_painter) {
- nr_arena_render_paintserver_fill(pb, area, ggroup->stroke_painter, SP_SCALE24_TO_FLOAT(style->stroke_opacity.value), &m);
- }
- break;
- default:
- break;
+ if (style->stroke.isPaintserver()) {
+ if (ggroup->stroke_painter) {
+ nr_arena_render_paintserver_fill(pb, area, ggroup->stroke_painter, SP_SCALE24_TO_FLOAT(style->stroke_opacity.value), &m);
+ }
+ } else if (style->stroke.isColor()) {
+ if ( item->render_opacity ) {
+ rgba = sp_color_get_rgba32_falpha(&style->stroke.value.color,
+ SP_SCALE24_TO_FLOAT(style->stroke_opacity.value) *
+ SP_SCALE24_TO_FLOAT(style->opacity.value));
+ } else {
+ rgba = sp_color_get_rgba32_falpha(&style->stroke.value.color,
+ SP_SCALE24_TO_FLOAT(style->stroke_opacity.value));
+ }
+ nr_blit_pixblock_mask_rgba32(pb, &m, rgba);
+ pb->empty = FALSE;
+ } else {
+ // nothing
}
nr_pixblock_release(&m);
}
index f0de2d26f7bc55ee6a4a89c3cab4d4e8dd4bab2d..d245e39283ed32f584e14716ae9b96d0b74f885e 100644 (file)
if (shape->style) sp_style_unref(shape->style);
shape->style = style;
- switch (style->fill.type) {
- case SP_PAINT_TYPE_NONE: {
- shape->setFill(NULL);
- break;
- }
- case SP_PAINT_TYPE_COLOR: {
- shape->setFill(style->fill.value.color);
- break;
- }
- case SP_PAINT_TYPE_PAINTSERVER: {
- shape->setFill(style->getFillPaintServer());
- break;
- }
- default: {
- g_assert_not_reached();
- }
+ if ( style->fill.isPaintserver() ) {
+ shape->setFill(style->getFillPaintServer());
+ } else if ( style->fill.isColor() ) {
+ shape->setFill(style->fill.value.color);
+ } else if ( style->fill.isNone() ) {
+ shape->setFill(NULL);
+ } else {
+ g_assert_not_reached();
}
shape->setFillOpacity(SP_SCALE24_TO_FLOAT(style->fill_opacity.value));
switch (style->fill_rule.computed) {
}
}
- switch (style->stroke.type) {
- case SP_PAINT_TYPE_NONE: {
- shape->setStroke(NULL);
- break;
- }
- case SP_PAINT_TYPE_COLOR: {
- shape->setStroke(style->stroke.value.color);
- break;
- }
- case SP_PAINT_TYPE_PAINTSERVER: {
- shape->setStroke(style->getStrokePaintServer());
- break;
- }
- default: {
- g_assert_not_reached();
- }
+ if ( style->stroke.isPaintserver() ) {
+ shape->setStroke(style->getStrokePaintServer());
+ } else if ( style->stroke.isColor() ) {
+ shape->setStroke(style->stroke.value.color);
+ } else if ( style->stroke.isNone() ) {
+ shape->setStroke(NULL);
+ } else {
+ g_assert_not_reached();
}
shape->setStrokeWidth(style->stroke_width.computed);
shape->setStrokeOpacity(SP_SCALE24_TO_FLOAT(style->stroke_opacity.value));
diff --git a/src/extension/internal/cairo-render-context.cpp b/src/extension/internal/cairo-render-context.cpp
index b13b95643279d740e2458e421ce99d9b846abec3..61d40ea4eca2bea2d18e5210ca065e6a88866535 100644 (file)
_state->opacity = SP_SCALE24_TO_FLOAT(style->opacity.value);
_state->has_overflow = (style->overflow.set && style->overflow.value != SP_CSS_OVERFLOW_VISIBLE);
- if (style->fill.type == SP_PAINT_TYPE_PAINTSERVER || style->stroke.type == SP_PAINT_TYPE_PAINTSERVER)
+ if (style->fill.isPaintserver() || style->stroke.isPaintserver())
_state->merge_opacity = FALSE;
// disable rendering of opacity if there's a stroke on the fill
if (_state->merge_opacity
- && style->fill.type != SP_PAINT_TYPE_NONE
- && style->stroke.type != SP_PAINT_TYPE_NONE)
+ && !style->fill.isNone()
+ && !style->stroke.isNone())
_state->merge_opacity = FALSE;
}
@@ -1059,8 +1059,8 @@ CairoRenderContext::_createPatternForPaintServer(SPPaintServer const *const pain
void
CairoRenderContext::_setFillStyle(SPStyle const *const style, NRRect const *pbox)
{
- g_return_if_fail( style->fill.type == SP_PAINT_TYPE_COLOR
- || style->fill.type == SP_PAINT_TYPE_PAINTSERVER );
+ g_return_if_fail( style->fill.isColor()
+ || style->fill.isPaintserver() );
float alpha = SP_SCALE24_TO_FLOAT(style->fill_opacity.value);
if (_state->merge_opacity) {
@@ -1068,13 +1068,13 @@ CairoRenderContext::_setFillStyle(SPStyle const *const style, NRRect const *pbox
TRACE(("merged op=%f\n", alpha));
}
- if (style->fill.type == SP_PAINT_TYPE_COLOR) {
+ if (style->fill.isColor()) {
float rgb[3];
sp_color_get_rgb_floatv(&style->fill.value.color, rgb);
cairo_set_source_rgba(_cr, rgb[0], rgb[1], rgb[2], alpha);
} else {
- g_assert( style->fill.type == SP_PAINT_TYPE_PAINTSERVER
+ g_assert( style->fill.isPaintserver()
|| SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style))
|| SP_IS_PATTERN(SP_STYLE_FILL_SERVER(style)) );
@@ -1094,13 +1094,13 @@ CairoRenderContext::_setStrokeStyle(SPStyle const *style, NRRect const *pbox)
if (_state->merge_opacity)
alpha *= _state->opacity;
- if (style->stroke.type == SP_PAINT_TYPE_COLOR) {
+ if (style->stroke.isColor()) {
float rgb[3];
sp_color_get_rgb_floatv(&style->stroke.value.color, rgb);
cairo_set_source_rgba(_cr, rgb[0], rgb[1], rgb[2], alpha);
} else {
- g_assert( style->fill.type == SP_PAINT_TYPE_PAINTSERVER
+ g_assert( style->fill.isPaintserver()
|| SP_IS_GRADIENT(SP_STYLE_STROKE_SERVER(style))
|| SP_IS_PATTERN(SP_STYLE_STROKE_SERVER(style)) );
@@ -1175,7 +1175,7 @@ CairoRenderContext::renderPath(NRBPath const *bpath, SPStyle const *style, NRRec
return true;
}
- if (style->fill.type == SP_PAINT_TYPE_NONE && style->stroke.type == SP_PAINT_TYPE_NONE)
+ if (style->fill.isNone() && style->stroke.isNone())
return true;
bool need_layer = ( !_state->merge_opacity && !_state->need_layer &&
@@ -1186,7 +1186,7 @@ CairoRenderContext::renderPath(NRBPath const *bpath, SPStyle const *style, NRRec
else
pushLayer();
- if (style->fill.type != SP_PAINT_TYPE_NONE) {
+ if (!style->fill.isNone()) {
_setFillStyle(style, pbox);
setBpath(bpath->path);
@@ -1196,15 +1196,15 @@ CairoRenderContext::renderPath(NRBPath const *bpath, SPStyle const *style, NRRec
cairo_set_fill_rule(_cr, CAIRO_FILL_RULE_WINDING);
}
- if (style->stroke.type == SP_PAINT_TYPE_NONE)
+ if (style->stroke.isNone())
cairo_fill(_cr);
else
cairo_fill_preserve(_cr);
}
- if (style->stroke.type != SP_PAINT_TYPE_NONE) {
+ if (!style->stroke.isNone()) {
_setStrokeStyle(style, pbox);
- if (style->fill.type == SP_PAINT_TYPE_NONE)
+ if (style->fill.isNone())
setBpath(bpath->path);
cairo_stroke(_cr);
index 990c094a421fb9a931985250fffa898256c38baf..116cccb3be45a30d1e9dee8fd2fa551499074aae 100644 (file)
{
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
- if (style->fill.type == SP_PAINT_TYPE_COLOR) {
+ if (style->fill.isColor()) {
Inkscape::SVGOStringStream os;
float rgb[3];
@@ -233,7 +233,7 @@ PrintLatex::stroke (Inkscape::Extension::Print *mod, const NRBPath *bpath, const
{
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
- if (style->stroke.type == SP_PAINT_TYPE_COLOR) {
+ if (style->stroke.isColor()) {
Inkscape::SVGOStringStream os;
float rgb[3];
NR::Matrix tr_stack = m_tr_stack.top();
index f67800ca56db66b11f85ae68f2b108aed4f16d36..61e3e593e2fb5968aaedcb08fd51ce9ed10f3087 100644 (file)
StyleInfo si;
//## FILL
- if (style->fill.type == SP_PAINT_TYPE_COLOR)
+ if (style->fill.isColor())
{
guint32 fillCol =
sp_color_get_rgba32_ualpha(&style->fill.value.color, 0);
}
//## STROKE
- if (style->stroke.type == SP_PAINT_TYPE_COLOR)
+ if (style->stroke.isColor())
{
guint32 strokeCol =
sp_color_get_rgba32_ualpha(&style->stroke.value.color, 0);
if (!style)
return false;
- if (style->fill.type != SP_PAINT_TYPE_PAINTSERVER)
+ if (!style->fill.isPaintserver())
return false;
//## Gradient. Look in writeStyle() below to see what info
index 0b500864d14c189b1a9bab81a4b0adcac55adae5..e1a168c27065fbd900753adf54b08dfe3a6245bd 100644 (file)
@@ -533,11 +533,11 @@ PrintCairoPDF::create_pattern_for_paint(SPPaintServer const *const paintserver,
void
PrintCairoPDF::print_fill_style(cairo_t *cr, SPStyle const *const style, NRRect const *pbox)
{
- g_return_if_fail( style->fill.type == SP_PAINT_TYPE_COLOR
- || ( style->fill.type == SP_PAINT_TYPE_PAINTSERVER
+ g_return_if_fail( style->fill.isColor()
+ || ( style->fill.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) ) );
- if (style->fill.type == SP_PAINT_TYPE_COLOR) {
+ if (style->fill.isColor()) {
float rgb[3];
sp_color_get_rgb_floatv(&style->fill.value.color, rgb);
cairo_set_source_rgba(cr, rgb[0], rgb[1], rgb[2], alpha);
} else {
- g_assert( style->fill.type == SP_PAINT_TYPE_PAINTSERVER
+ g_assert( style->fill.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) );
cairo_pattern_t *pattern = create_pattern_for_paint(SP_STYLE_FILL_SERVER(style), pbox, 1.0);
@@ -564,14 +564,14 @@ PrintCairoPDF::fill(Inkscape::Extension::Print *mod, NRBPath const *bpath, NRMat
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
if (_bitmap) return 0;
- if ( style->fill.type == SP_PAINT_TYPE_COLOR
- || ( style->fill.type == SP_PAINT_TYPE_PAINTSERVER
- && SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) ) ) {
-
+ if ( style->fill.isColor()
+ || ( style->fill.isPaintserver()
+ && SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) ) ) {
+
float alpha = SP_SCALE24_TO_FLOAT(style->fill_opacity.value);
-
+
cairo_save(cr);
-
+
print_fill_style(cr, style, pbox);
print_bpath(cr, bpath->path);
if (style->fill_rule.value == SP_WIND_RULE_EVENODD) {
@@ -580,7 +580,7 @@ PrintCairoPDF::fill(Inkscape::Extension::Print *mod, NRBPath const *bpath, NRMat
cairo_set_fill_rule(cr, CAIRO_FILL_RULE_WINDING);
}
if (alpha != 1.0 &&
- style->fill.type != SP_PAINT_TYPE_COLOR) {
+ !style->fill.isColor()) {
cairo_clip (cr);
cairo_paint_with_alpha (cr, alpha);
@@ -599,12 +599,12 @@ PrintCairoPDF::print_stroke_style(cairo_t *cr, SPStyle const *style, NRRect cons
{
float alpha = SP_SCALE24_TO_FLOAT(style->stroke_opacity.value);
- if ( style->stroke.type == SP_PAINT_TYPE_COLOR ) {
+ if ( style->stroke.isColor() ) {
float rgb[3];
sp_color_get_rgb_floatv(&style->stroke.value.color, rgb);
cairo_set_source_rgba(cr, rgb[0], rgb[1], rgb[2], alpha);
- } else if ( style->stroke.type == SP_PAINT_TYPE_PAINTSERVER
+ } else if ( style->stroke.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_STROKE_SERVER(style)) ) {
cairo_pattern_t *pattern = create_pattern_for_paint(SP_STYLE_STROKE_SERVER(style), pbox, alpha);
@@ -664,16 +664,16 @@ PrintCairoPDF::stroke(Inkscape::Extension::Print *mod, NRBPath const *bpath, NRM
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
if (_bitmap) return 0;
- if ( style->stroke.type == SP_PAINT_TYPE_COLOR ||
- ( style->stroke.type == SP_PAINT_TYPE_PAINTSERVER
+ if ( style->stroke.isColor() ||
+ ( style->stroke.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_STROKE_SERVER(style)) ) ) {
- cairo_save(cr);
-
- print_stroke_style(cr, style, pbox);
+ cairo_save(cr);
+
+ print_stroke_style(cr, style, pbox);
print_bpath(cr, bpath->path);
cairo_stroke(cr);
-
+
cairo_restore(cr);
}
@@ -884,8 +884,8 @@ PrintCairoPDF::text(Inkscape::Extension::Print *mod, char const *text, NR::Point
cairo_set_font_matrix(cr, &matrix);
#endif
- if ( style->fill.type == SP_PAINT_TYPE_COLOR
- || ( style->fill.type == SP_PAINT_TYPE_PAINTSERVER
+ if ( style->fill.isColor()
+ || ( style->fill.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) ) )
{
// set fill style
@@ -904,8 +904,8 @@ PrintCairoPDF::text(Inkscape::Extension::Print *mod, char const *text, NR::Point
#endif
}
- if (style->stroke.type == SP_PAINT_TYPE_COLOR
- || ( style->stroke.type == SP_PAINT_TYPE_PAINTSERVER
+ if (style->stroke.isColor()
+ || ( style->stroke.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_STROKE_SERVER(style)) ) )
{
// set stroke style
index 7318fa78457873bbcaa21388f5cbeb33c333ab6d..c915de75bfb3dbf34dcb8c65acb24c0070238d03 100644 (file)
SPStyle *style = SP_OBJECT_STYLE(shape);
/* fixme: Handle other fill types, even if this means translating gradients to a single
flat colour. */
- if (style && (style->fill.type == SP_PAINT_TYPE_COLOR))
+ if (style && (style->fill.isColor()))
{
// see color.h for how to parse SPColor
float rgb[3];
index 8cf2845363923a99e273f13095d60ad0d6fc77a0..ac424e85eb62a7ccc5e4900bd58e4ef0b8cd8094 100644 (file)
void
PrintPS::print_fill_style(SVGOStringStream &os, SPStyle const *const style, NRRect const *pbox)
{
- g_return_if_fail( style->fill.type == SP_PAINT_TYPE_COLOR
- || ( style->fill.type == SP_PAINT_TYPE_PAINTSERVER
+ g_return_if_fail( style->fill.isColor()
+ || ( style->fill.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) ) );
- if (style->fill.type == SP_PAINT_TYPE_COLOR) {
+ if (style->fill.isColor()) {
float rgb[3];
sp_color_get_rgb_floatv(&style->fill.value.color, rgb);
os << rgb[0] << " " << rgb[1] << " " << rgb[2] << " setrgbcolor\n";
} else {
- g_assert( style->fill.type == SP_PAINT_TYPE_PAINTSERVER
+ g_assert( style->fill.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) );
if (SP_IS_LINEARGRADIENT(SP_STYLE_FILL_SERVER(style))) {
@@ -799,8 +799,8 @@ PrintPS::fill(Inkscape::Extension::Print *mod, NRBPath const *bpath, NRMatrix co
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
if (_bitmap) return 0;
- if ( style->fill.type == SP_PAINT_TYPE_COLOR
- || ( style->fill.type == SP_PAINT_TYPE_PAINTSERVER
+ if ( style->fill.isColor()
+ || ( style->fill.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) ) )
{
Inkscape::SVGOStringStream os;
@@ -812,10 +812,10 @@ PrintPS::fill(Inkscape::Extension::Print *mod, NRBPath const *bpath, NRMatrix co
print_bpath(os, bpath->path);
if (style->fill_rule.value == SP_WIND_RULE_EVENODD) {
- if (style->fill.type == SP_PAINT_TYPE_COLOR) {
+ if (style->fill.isColor()) {
os << "eofill\n";
} else {
- g_assert( style->fill.type == SP_PAINT_TYPE_PAINTSERVER
+ g_assert( style->fill.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) );
SPGradient const *g = SP_GRADIENT(SP_STYLE_FILL_SERVER(style));
os << "eoclip\n";
@@ -830,10 +830,10 @@ PrintPS::fill(Inkscape::Extension::Print *mod, NRBPath const *bpath, NRMatrix co
}
}
} else {
- if (style->fill.type == SP_PAINT_TYPE_COLOR) {
+ if (style->fill.isColor()) {
os << "fill\n";
} else {
- g_assert( style->fill.type == SP_PAINT_TYPE_PAINTSERVER
+ g_assert( style->fill.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) );
SPGradient const *g = SP_GRADIENT(SP_STYLE_FILL_SERVER(style));
os << "clip\n";
if (!_stream) return 0; // XXX: fixme, returning -1 as unsigned.
if (_bitmap) return 0;
- if (style->stroke.type == SP_PAINT_TYPE_COLOR) {
+ if (style->stroke.isColor()) {
Inkscape::SVGOStringStream os;
print_stroke_style(os, style);
//The commented line beneath causes Inkscape to crash under Linux but not under Windows
//g_free((void*) fn);
- if ( style->fill.type == SP_PAINT_TYPE_COLOR
- || ( style->fill.type == SP_PAINT_TYPE_PAINTSERVER
+ if ( style->fill.isColor()
+ || ( style->fill.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style)) ) )
{
// set fill style
os << ") show\n";
}
- if (style->stroke.type == SP_PAINT_TYPE_COLOR) {
+ if (style->stroke.isColor()) {
// set stroke style
print_stroke_style(os, style);
index fce26435c6b75a6037147b3dda2d888c35e98f8c..0690ef140c480efe083600cad8c5f71b2cbc8b76 100644 (file)
SPStyle *style = SP_OBJECT_STYLE(o);
if (style
- && style->fill.type == SP_PAINT_TYPE_PAINTSERVER
+ && style->fill.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_FILL_SERVER(style))
&& SP_GRADIENT(SP_STYLE_FILL_SERVER(style)) == gr)
{
i ++;
}
if (style
- && style->stroke.type == SP_PAINT_TYPE_PAINTSERVER
+ && style->stroke.isPaintserver()
&& SP_IS_GRADIENT(SP_STYLE_STROKE_SERVER(style))
&& SP_GRADIENT(SP_STYLE_STROKE_SERVER(style)) == gr)
{
SPGradient *gradient = NULL;
if (fill_or_stroke) {
- if (style && (style->fill.type == SP_PAINT_TYPE_PAINTSERVER)) {
+ if (style && (style->fill.isPaintserver())) {
SPObject *server = SP_OBJECT_STYLE_FILL_SERVER(item);
if (SP_IS_GRADIENT (server)) {
gradient = SP_GRADIENT (server);
}
}
} else {
- if (style && (style->stroke.type == SP_PAINT_TYPE_PAINTSERVER)) {
+ if (style && (style->stroke.isPaintserver())) {
SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER(item);
if (SP_IS_GRADIENT (server)) {
gradient = SP_GRADIENT (server);
@@ -1067,9 +1067,8 @@ sp_item_set_gradient(SPItem *item, SPGradient *gr, SPGradientType type, bool is_
SPStyle *style = SP_OBJECT_STYLE(item);
g_assert(style != NULL);
- guint style_type = is_fill? style->fill.type : style->stroke.type;
SPPaintServer *ps = NULL;
- if (style_type == SP_PAINT_TYPE_PAINTSERVER)
+ if (is_fill? style->fill.isPaintserver() : style->stroke.isPaintserver())
ps = is_fill? SP_STYLE_FILL_SERVER(style) : SP_STYLE_STROKE_SERVER(style);
if (ps
@@ -1223,15 +1222,15 @@ sp_gradient_vector_for_object(SPDocument *const doc, SPDesktop *const desktop,
SPIPaint const &paint = ( is_fill
? style.fill
: style.stroke );
- if (paint.type == SP_PAINT_TYPE_COLOR) {
- rgba = sp_color_get_rgba32_ualpha(&paint.value.color, 0xff);
- } else if (paint.type == SP_PAINT_TYPE_PAINTSERVER) {
+ if (paint.isPaintserver()) {
SPObject *server = is_fill? SP_OBJECT_STYLE_FILL_SERVER(o) : SP_OBJECT_STYLE_STROKE_SERVER(o);
if (SP_IS_GRADIENT (server)) {
return sp_gradient_get_vector(SP_GRADIENT (server), TRUE);
} else {
rgba = sp_desktop_get_color(desktop, is_fill);
}
+ } else if (paint.isColor()) {
+ rgba = sp_color_get_rgba32_ualpha(&paint.value.color, 0xff);
} else {
// if o doesn't use flat color, then take current color of the desktop.
rgba = sp_desktop_get_color(desktop, is_fill);
diff --git a/src/gradient-drag.cpp b/src/gradient-drag.cpp
index 171881a780208f62c7bda1375af0fcc3783f3303..59081475ee22a0f6550b243f844e1889f71445a9 100644 (file)
--- a/src/gradient-drag.cpp
+++ b/src/gradient-drag.cpp
cf[3] /= count;
// set both fill and stroke with our stop-color and stop-opacity
- sp_color_set_rgb_float((SPColor *) &style->fill.value.color, cf[0], cf[1], cf[2]);
+ style->fill.clear();
+ style->fill.setColor( cf[0], cf[1], cf[2] );
style->fill.set = TRUE;
- style->fill.type = SP_PAINT_TYPE_COLOR;
- sp_color_set_rgb_float((SPColor *) &style->stroke.value.color, cf[0], cf[1], cf[2]);
+ style->stroke.clear();
+ style->stroke.setColor( cf[0], cf[1], cf[2] );
style->stroke.set = TRUE;
- style->stroke.type = SP_PAINT_TYPE_COLOR;
style->fill_opacity.value = SP_SCALE24_FROM_FLOAT (1.0);
style->fill_opacity.set = TRUE;
SPItem *item = SP_ITEM(i->data);
SPStyle *style = SP_OBJECT_STYLE (item);
- if (style && (style->fill.type == SP_PAINT_TYPE_PAINTSERVER)) {
+ if (style && (style->fill.isPaintserver())) {
SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (item);
if (SP_IS_LINEARGRADIENT (server)) {
addDraggersLinear (SP_LINEARGRADIENT (server), item, true);
}
}
- if (style && (style->stroke.type == SP_PAINT_TYPE_PAINTSERVER)) {
+ if (style && (style->stroke.isPaintserver())) {
SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (item);
if (SP_IS_LINEARGRADIENT (server)) {
addDraggersLinear (SP_LINEARGRADIENT (server), item, false);
SPStyle *style = SP_OBJECT_STYLE (item);
- if (style && (style->fill.type == SP_PAINT_TYPE_PAINTSERVER)) {
+ if (style && (style->fill.isPaintserver())) {
SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (item);
if (SP_IS_LINEARGRADIENT (server)) {
this->addLine (sp_item_gradient_get_coords (item, POINT_LG_BEGIN, 0, true), sp_item_gradient_get_coords (item, POINT_LG_END, 0, true), GR_LINE_COLOR_FILL);
}
}
- if (style && (style->stroke.type == SP_PAINT_TYPE_PAINTSERVER)) {
+ if (style && (style->stroke.isPaintserver())) {
SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (item);
if (SP_IS_LINEARGRADIENT (server)) {
this->addLine (sp_item_gradient_get_coords (item, POINT_LG_BEGIN, 0, false), sp_item_gradient_get_coords (item, POINT_LG_END, 0, false), GR_LINE_COLOR_STROKE);
index 68d7752c30af2c516fb178d5f342761ce5e92d96..21d8c8e4883d8e7183acbbac066302a1e3a6ee64 100755 (executable)
NRBPath abp;
_getGlyphTransformMatrix(glyph_index, &glyph_matrix);
abp.path = nr_artpath_affine(bpath.path, glyph_matrix);
- if (text_source->style->fill.type != SP_PAINT_TYPE_NONE)
+ if (!text_source->style->fill.isNone())
sp_print_fill(ctx, &abp, &ctm, text_source->style, pbox, dbox, bbox);
- if (text_source->style->stroke.type != SP_PAINT_TYPE_NONE)
+ if (!text_source->style->stroke.isNone())
sp_print_stroke(ctx, &abp, &ctm, text_source->style, pbox, dbox, bbox);
g_free(abp.path);
}
diff --git a/src/object-edit.cpp b/src/object-edit.cpp
index fa0090c7f4de804242947053b5bb331c3c9c31ee..63ccf827e740cf4b55c1a632686031a9f104bdcc 100644 (file)
--- a/src/object-edit.cpp
+++ b/src/object-edit.cpp
static SPKnotHolder *
sp_misc_knot_holder(SPItem *item, SPDesktop *desktop) // FIXME: eliminate, instead make a pattern-drag similar to gradient-drag
{
- if ((SP_OBJECT(item)->style->fill.type == SP_PAINT_TYPE_PAINTSERVER)
+ if ((SP_OBJECT(item)->style->fill.isPaintserver())
&& SP_IS_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style)))
{
SPKnotHolder *knot_holder = sp_knot_holder_new(desktop, item, NULL);
@@ -1374,7 +1374,7 @@ sp_misc_knot_holder(SPItem *item, SPDesktop *desktop) // FIXME: eliminate, inste
static void
sp_pat_knot_holder(SPItem *item, SPKnotHolder *knot_holder)
{
- if ((SP_OBJECT(item)->style->fill.type == SP_PAINT_TYPE_PAINTSERVER)
+ if ((SP_OBJECT(item)->style->fill.isPaintserver())
&& SP_IS_PATTERN(SP_STYLE_FILL_SERVER(SP_OBJECT(item)->style)))
{
sp_knot_holder_add_full(knot_holder, sp_pattern_xy_set, sp_pattern_xy_get, NULL, SP_KNOT_SHAPE_CROSS, SP_KNOT_MODE_XOR,
index 99f66130f318fe90beda22f1377bffd39b53be9e..a8cb4d4fe193096cdf8eaffbd4ce5f9971a27667 100644 (file)
{
SPStyle *style = SP_OBJECT_STYLE (item);
- if (style && (style->fill.type == SP_PAINT_TYPE_PAINTSERVER)) {
+ if (style && (style->fill.isPaintserver())) {
SPObject *server = SP_OBJECT_STYLE_FILL_SERVER(item);
if (SP_IS_LINEARGRADIENT (server) || SP_IS_RADIALGRADIENT (server))
sp_copy_gradient (defs_clip, SP_GRADIENT(server), xml_doc);
sp_copy_pattern (defs_clip, SP_PATTERN(server), xml_doc);
}
- if (style && (style->stroke.type == SP_PAINT_TYPE_PAINTSERVER)) {
+ if (style && (style->stroke.isPaintserver())) {
SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER(item);
if (SP_IS_LINEARGRADIENT (server) || SP_IS_RADIALGRADIENT (server))
sp_copy_gradient (defs_clip, SP_GRADIENT(server), xml_doc);
SPStyle *style = SP_OBJECT_STYLE (item);
- if (!style || style->fill.type != SP_PAINT_TYPE_PAINTSERVER)
+ if (!style || !style->fill.isPaintserver())
continue;
SPObject *server = SP_OBJECT_STYLE_FILL_SERVER(item);
diff --git a/src/shape-editor.cpp b/src/shape-editor.cpp
index 72c5ef0585f257b57b7b0701558d2f9c8846428d..d9a500e3c463cb2dd03a70c56cd181077010fec8 100644 (file)
--- a/src/shape-editor.cpp
+++ b/src/shape-editor.cpp
delta = desktop->d2w(delta);
double stroke_tolerance =
- (SP_OBJECT_STYLE (item)->stroke.type != SP_PAINT_TYPE_NONE?
+ ( !SP_OBJECT_STYLE(item)->stroke.isNone() ?
desktop->current_zoom() *
SP_OBJECT_STYLE (item)->stroke_width.computed *
sp_item_i2d_affine (item).expansion() * 0.5
diff --git a/src/sp-flowtext.cpp b/src/sp-flowtext.cpp
index daa9f808a2db1c0046de3741ef94af7094330fe9..87e3246f97194fe9b92315e8e4e2da76642ae2f6 100644 (file)
--- a/src/sp-flowtext.cpp
+++ b/src/sp-flowtext.cpp
// Add stroke width
SPStyle* style=SP_OBJECT_STYLE (item);
- if (style->stroke.type != SP_PAINT_TYPE_NONE) {
+ if ( !style->stroke.isNone() ) {
double const scale = expansion(transform);
if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
double const width = MAX(0.125, style->stroke_width.computed * scale);
diff --git a/src/sp-item.cpp b/src/sp-item.cpp
index 338a70c4ed4b838866151848821a4ce8b81ced9e..4a5c0079b4fb6bd1499083cd63ad09d3f9eb5b92 100644 (file)
--- a/src/sp-item.cpp
+++ b/src/sp-item.cpp
{
SPStyle *style = SP_OBJECT_STYLE (item);
- if (style && (style->fill.type == SP_PAINT_TYPE_PAINTSERVER)) {
+ if (style && (style->fill.isPaintserver())) {
SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (item);
if (SP_IS_PATTERN (server)) {
SPPattern *pattern = sp_pattern_clone_if_necessary (item, SP_PATTERN (server), "fill");
}
}
- if (style && (style->stroke.type == SP_PAINT_TYPE_PAINTSERVER)) {
+ if (style && (style->stroke.isPaintserver())) {
SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (item);
if (SP_IS_PATTERN (server)) {
SPPattern *pattern = sp_pattern_clone_if_necessary (item, SP_PATTERN (server), "stroke");
{
SPStyle *style = SP_OBJECT_STYLE (item);
- if (style && (style->fill.type == SP_PAINT_TYPE_PAINTSERVER)) {
+ if (style && (style->fill.isPaintserver())) {
SPObject *server = SP_OBJECT_STYLE_FILL_SERVER(item);
if (SP_IS_GRADIENT (server)) {
}
}
- if (style && (style->stroke.type == SP_PAINT_TYPE_PAINTSERVER)) {
+ if (style && (style->stroke.isPaintserver())) {
SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER(item);
if (SP_IS_GRADIENT (server)) {
SPGradient *gradient = sp_gradient_convert_to_userspace (SP_GRADIENT (server), item, "stroke");
{
SPStyle *style = SP_OBJECT_STYLE (item);
- if (style && style->stroke.type != SP_PAINT_TYPE_NONE && !NR_DF_TEST_CLOSE (ex, 1.0, NR_EPSILON)) {
+ if (style && !style->stroke.isNone() && !NR_DF_TEST_CLOSE (ex, 1.0, NR_EPSILON)) {
style->stroke_width.computed *= ex;
style->stroke_width.set = TRUE;
diff --git a/src/sp-shape.cpp b/src/sp-shape.cpp
index 9a74b7217373452bdf9be1dbbd6f4d78c4c2be16..ff0ebf887f289846283e991ddd77b1dc49abadef 100644 (file)
--- a/src/sp-shape.cpp
+++ b/src/sp-shape.cpp
@@ -714,7 +714,7 @@ static void sp_shape_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr
if ((SPItem::BBoxType) flags != SPItem::GEOMETRIC_BBOX) {
SPStyle* style=SP_OBJECT_STYLE (item);
- if (style->stroke.type != SP_PAINT_TYPE_NONE) {
+ if (!style->stroke.isNone()) {
double const scale = expansion(transform);
if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
double const width = MAX(0.125, style->stroke_width.computed * scale);
SPStyle* style = SP_OBJECT_STYLE (item);
- if (style->fill.type != SP_PAINT_TYPE_NONE) {
+ if (!style->fill.isNone()) {
NRBPath bp;
bp.path = SP_CURVE_BPATH(shape->curve);
sp_print_fill (ctx, &bp, i2d, style, &pbox, &dbox, &bbox);
}
- if (style->stroke.type != SP_PAINT_TYPE_NONE) {
+ if (!style->stroke.isNone()) {
NRBPath bp;
bp.path = SP_CURVE_BPATH(shape->curve);
sp_print_stroke (ctx, &bp, i2d, style, &pbox, &dbox, &bbox);
diff --git a/src/sp-text.cpp b/src/sp-text.cpp
index cc575d99f7dc473e042a4364334066737590eb22..1c677edb2d7c014a0b689e557e7be8bf1ef38c5a 100644 (file)
--- a/src/sp-text.cpp
+++ b/src/sp-text.cpp
@@ -356,7 +356,7 @@ sp_text_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsi
// Add stroke width
SPStyle* style=SP_OBJECT_STYLE (item);
- if (style->stroke.type != SP_PAINT_TYPE_NONE) {
+ if (!style->stroke.isNone()) {
double const scale = expansion(transform);
if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
double const width = MAX(0.125, style->stroke_width.computed * scale);
diff --git a/src/sp-tref.cpp b/src/sp-tref.cpp
index 28db57990e25b32c7f43563c08e47395ba608765..16420436180a84f8c9d9713707265440628722b9 100644 (file)
--- a/src/sp-tref.cpp
+++ b/src/sp-tref.cpp
@@ -334,7 +334,7 @@ sp_tref_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &transform, unsi
// Add stroke width
SPStyle* style=SP_OBJECT_STYLE (item);
- if (style->stroke.type != SP_PAINT_TYPE_NONE) {
+ if (!style->stroke.isNone()) {
double const scale = expansion(transform);
if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
double const width = MAX(0.125, style->stroke_width.computed * scale);
diff --git a/src/sp-tspan.cpp b/src/sp-tspan.cpp
index face70aef55bfa1bceccbf35a6eeae71a548328d..a767ab1949e2d80aacecf526cfd39d132529592e 100644 (file)
--- a/src/sp-tspan.cpp
+++ b/src/sp-tspan.cpp
@@ -213,7 +213,7 @@ static void sp_tspan_bbox(SPItem const *item, NRRect *bbox, NR::Matrix const &tr
// Add stroke width
SPStyle* style=SP_OBJECT_STYLE (item);
- if (style->stroke.type != SP_PAINT_TYPE_NONE) {
+ if (!style->stroke.isNone()) {
double const scale = expansion(transform);
if ( fabs(style->stroke_width.computed * scale) > 0.01 ) { // sinon c'est 0=oon veut pas de bord
double const width = MAX(0.125, style->stroke_width.computed * scale);
diff --git a/src/style.cpp b/src/style.cpp
index 5817df3428e746eb08736edae748ff5ba45c599d..70e2948486385e328a464c2b680d0ee9a638167e 100644 (file)
--- a/src/style.cpp
+++ b/src/style.cpp
@@ -100,8 +100,6 @@ static gint sp_style_write_ilengthornormal(gchar *p, gint const len, gchar const
static gint sp_style_write_itextdecoration(gchar *p, gint const len, gchar const *const key, SPITextDecoration const *const val, SPITextDecoration const *const base, guint const flags);
static gint sp_style_write_ifilter(gchar *b, gint len, gchar const *key, SPIFilter const *filter, SPIFilter const *base, guint flags);
-static void sp_style_paint_clear(SPStyle *style, SPIPaint *paint);
-
static void sp_style_filter_clear(SPStyle *style);
#define SPS_READ_IENUM_IF_UNSET(v,s,d,i) if (!(v)->set) {sp_style_read_ienum((v), (s), (d), (i));}
static void
sp_style_object_release(SPObject *object, SPStyle *style)
{
+ (void)object; // TODO
style->object = NULL;
}
static void
sp_style_filter_ref_modified(SPObject *obj, guint flags, SPStyle *style)
{
+ (void)flags; // TODO
SPFilter *filter=static_cast<SPFilter *>(obj);
if (style->getFilter() == filter)
{
static void
sp_style_paint_server_ref_modified(SPObject *obj, guint flags, SPStyle *style)
{
+ (void)flags; // TODO
SPPaintServer *server = static_cast<SPPaintServer *>(obj);
- if ((style->fill.type == SP_PAINT_TYPE_PAINTSERVER)
+ if ((style->fill.isPaintserver())
&& style->getFillPaintServer() == server)
{
if (style->object) {
@@ -387,14 +388,14 @@ sp_style_paint_server_ref_modified(SPObject *obj, guint flags, SPStyle *style)
*/
style->object->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
}
- } else if ((style->stroke.type == SP_PAINT_TYPE_PAINTSERVER)
+ } else if ((style->stroke.isPaintserver())
&& style->getStrokePaintServer() == server)
{
if (style->object) {
/// \todo fixme:
style->object->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG);
}
- } else {
+ } else if (server) {
g_assert_not_reached();
}
}
style->fill_ps_modified_connection.~connection();
style->stroke_ps_modified_connection.~connection();
- sp_style_paint_clear(style, &style->fill);
- sp_style_paint_clear(style, &style->stroke);
+ style->fill.clear();
+ style->stroke.clear();
sp_style_filter_clear(style);
g_free(style->stroke_dash.dash);
static void
sp_style_merge_ipaint(SPStyle *style, SPIPaint *paint, SPIPaint const *parent)
{
- sp_style_paint_clear(style, paint);
-
if ((paint->set && paint->currentcolor) || parent->currentcolor) {
+ paint->clear();
paint->currentcolor = TRUE;
- paint->type = SP_PAINT_TYPE_COLOR;
- sp_color_copy(&paint->value.color, &style->color.value.color);
+ paint->setColor(style->color.value.color);
return;
}
- paint->type = parent->type;
- switch (paint->type) {
- case SP_PAINT_TYPE_COLOR:
- sp_color_copy(&paint->value.color, &parent->value.color);
- break;
- case SP_PAINT_TYPE_PAINTSERVER:
- if (parent->value.href) {
- sp_style_set_ipaint_to_uri(style, paint, parent->value.href->getURI(), parent->value.href->getOwnerDocument());
- }
- break;
- case SP_PAINT_TYPE_NONE:
- break;
- default:
- g_assert_not_reached();
- break;
+ paint->clear();
+ if ( parent->isPaintserver() ) {
+ if (parent->value.href) {
+ sp_style_set_ipaint_to_uri(style, paint, parent->value.href->getURI(), parent->value.href->getOwnerDocument());
+ } else {
+ g_warning("Expected paint server not found.");
+ }
+ } else if ( parent->isColor() ) {
+ paint->setColor( parent->value.color );
+ } else if ( parent->isNone() ) {
+ //
+ } else {
+ g_assert_not_reached();
}
}
{
g_return_if_fail(style != NULL);
- sp_style_paint_clear(style, &style->fill);
- sp_style_paint_clear(style, &style->stroke);
+ style->fill.clear();
+ style->stroke.clear();
sp_style_filter_clear(style);
- if (style->fill.value.href)
+ if (style->fill.value.href)
delete style->fill.value.href;
if (style->stroke.value.href)
delete style->stroke.value.href;
style->overflow.set = FALSE;
style->overflow.value = style->overflow.computed = SP_CSS_OVERFLOW_VISIBLE;
- style->color.type = SP_PAINT_TYPE_COLOR;
- sp_color_set_rgb_float(&style->color.value.color, 0.0, 0.0, 0.0);
+ style->color.clear();
+ style->color.setColor(0.0, 0.0, 0.0);
- style->fill.type = SP_PAINT_TYPE_COLOR;
- sp_color_set_rgb_float(&style->fill.value.color, 0.0, 0.0, 0.0);
+ style->fill.clear();
+ style->fill.setColor(0.0, 0.0, 0.0);
style->fill_opacity.value = SP_SCALE24_MAX;
style->fill_rule.value = style->fill_rule.computed = SP_WIND_RULE_NONZERO;
- style->stroke.type = SP_PAINT_TYPE_NONE;
- style->stroke.set = FALSE;
- sp_color_set_rgb_float(&style->stroke.value.color, 0.0, 0.0, 0.0);
+ style->stroke.clear();
style->stroke_opacity.value = SP_SCALE24_MAX;
style->stroke_width.set = FALSE;
static void
sp_style_read_icolor(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocument *document)
{
+ (void)style; // TODO
+ (void)document; // TODO
paint->currentcolor = FALSE; /* currentColor not a valid <color>. */
if (!strcmp(str, "inherit")) {
paint->set = TRUE;
@@ -2965,9 +2962,7 @@ sp_style_read_icolor(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocume
} else {
guint32 const rgb0 = sp_svg_read_color(str, 0xff);
if (rgb0 != 0xff) {
- paint->type = SP_PAINT_TYPE_COLOR;
- sp_color_set_rgb_rgba32(&paint->value.color, rgb0);
- paint->set = TRUE;
+ paint->setColor(rgb0);
paint->inherit = FALSE;
}
}
@@ -2986,19 +2981,12 @@ sp_style_read_ipaint(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocume
++str;
}
- if (paint->value.href && paint->value.href->getObject()) {
- paint->value.href->detach();
- }
- paint->colorSet = FALSE;
- paint->currentcolor = FALSE;
- paint->noneSet = FALSE;
+ paint->clear();
if (streq(str, "inherit")) {
paint->set = TRUE;
paint->inherit = TRUE;
} else {
- paint->type = SP_PAINT_TYPE_NONE;
- paint->inherit = FALSE;
if ( strneq(str, "url", 3) ) {
gchar *uri = extract_uri( str, &str );
while ( g_ascii_isspace(*str) ) {
@@ -3006,7 +2994,6 @@ sp_style_read_ipaint(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocume
}
// TODO check on and comment the comparrison "paint != &style->color".
if ( uri && *uri && (paint != &style->color) ) {
- paint->type = SP_PAINT_TYPE_PAINTSERVER;
paint->set = TRUE;
// it may be that this style's SPIPaint has not yet created its URIReference;
@@ -3031,12 +3018,8 @@ sp_style_read_ipaint(SPIPaint *paint, gchar const *str, SPStyle *style, SPDocume
} else {
guint32 const rgb0 = sp_svg_read_color(str, &str, 0xff);
if (rgb0 != 0xff) {
- if ( paint->type != SP_PAINT_TYPE_PAINTSERVER ) {
- paint->type = SP_PAINT_TYPE_COLOR;
- }
- sp_color_set_rgb_rgba32(&paint->value.color, rgb0);
+ paint->setColor( rgb0 );
paint->set = TRUE;
- paint->colorSet = true;
while (g_ascii_isspace(*str)) {
++str;
@@ -3523,9 +3506,21 @@ sp_style_write_itextdecoration(gchar *p, gint const len, gchar const *const key,
static bool
sp_paint_differ(SPIPaint const *const a, SPIPaint const *const b)
{
- if (a->type != b->type)
+ if ( (a->isColor() != b->isColor())
+ || (a->isPaintserver() != b->isPaintserver())
+ || (a->set != b->set)
+ || (a->currentcolor != b->currentcolor)
+ || (a->inherit!= b->inherit) ) {
return true;
- if (a->type == SP_PAINT_TYPE_COLOR)
+ }
+
+ // TODO refactor to allow for mixed paints (rgb() *and* url(), etc)
+
+ if ( a->isPaintserver() ) {
+ return (a->value.href == NULL || b->value.href == NULL || a->value.href->getObject() != b->value.href->getObject());
+ }
+
+ if ( a->isColor() ) {
return !(sp_color_is_equal(&a->value.color, &b->value.color)
&& ((a->value.iccColor == b->value.iccColor)
|| (a->value.iccColor && b->value.iccColor
&& (a->value.iccColor->colors == b->value.iccColor->colors))));
/* todo: Allow for epsilon differences in iccColor->colors, e.g. changes small enough not to show up
* in the string representation. */
- if (a->type == SP_PAINT_TYPE_PAINTSERVER)
- return (a->value.href == NULL || b->value.href == NULL || a->value.href->getObject() != b->value.href->getObject());
+ }
+
return false;
}
SPIFilter const *const val, SPIFilter const *const base,
guint const flags)
{
+ (void)base; // TODO
if ((flags & SP_STYLE_FLAG_ALWAYS)
|| ((flags & SP_STYLE_FLAG_IFSET) && val->set)
|| ((flags & SP_STYLE_FLAG_IFDIFF) && val->set))
}
-/**
- * Clear paint object, and disconnect style from paintserver (if present).
- */
-static void
-sp_style_paint_clear(SPStyle *style, SPIPaint *paint)
+void SPIPaint::clear()
{
- if (paint->value.href && paint->value.href->getObject())
- paint->value.href->detach();
+ set = false;
+ inherit = false;
+ currentcolor = false;
+ colorSet = false;
+ noneSet = false;
+ sp_color_set_rgb_rgba32( &value.color, 0 );
+ if ( value.href && value.href->getObject() )
+ {
+ value.href->detach();
+ }
- paint->type = SP_PAINT_TYPE_NONE;
- delete paint->value.iccColor;
- paint->value.iccColor = NULL;
+ delete value.iccColor;
+ value.iccColor = 0;
}
sp_style_filter_clear(SPStyle *style)
{
if (style->filter.href && style->filter.href->getObject())
- style->filter.href->detach();
+ style->filter.href->detach();
}
diff --git a/src/style.h b/src/style.h
index 3a547bfb90b2e6431782690a8b86a1dd5feab940..623291941e614a590bfcb393a78e16747365ea2f 100644 (file)
--- a/src/style.h
+++ b/src/style.h
#define SP_OBJECT_STYLE_FILL_SERVER(o) (SP_OBJECT (o)->style->getFillPaintServer())
#define SP_OBJECT_STYLE_STROKE_SERVER(o) (SP_OBJECT (o)->style->getStrokePaintServer())
-enum {
- SP_PAINT_TYPE_NONE,
- SP_PAINT_TYPE_COLOR,
- SP_PAINT_TYPE_PAINTSERVER,
- SP_PAINT_TYPE_IMPOSSIBLE
-};
-
class SVGICCColor;
/// Paint type internal to SPStyle.
unsigned set : 1;
unsigned inherit : 1;
unsigned currentcolor : 1;
- unsigned type : 2;
unsigned int colorSet : 1;
unsigned int noneSet : 1;
struct {
- SPPaintServerReference *href;
- SPColor color;
- SVGICCColor *iccColor;
+ SPPaintServerReference *href;
+ SPColor color;
+ SVGICCColor *iccColor;
} value;
+
+
+ bool isSet() const { return true; /* set || colorSet*/}
+ bool isSameType( SPIPaint const & other ) const {return (isPaintserver() == other.isPaintserver()) && (colorSet == other.colorSet) && (currentcolor == other.currentcolor);}
+
+ bool isNoneSet() const {return noneSet;}
+
+ bool isNone() const {return !currentcolor && !colorSet && !isPaintserver();} // TODO refine
+ bool isColor() const {return colorSet && !isPaintserver();}
+ bool isPaintserver() const {return value.href && value.href->getObject();}
+
+ void clear();
+
+ void setColor( float r, float g, float b ) {sp_color_set_rgb_float(&value.color, r, g, b); colorSet = true;}
+ void setColor( guint32 val ) {sp_color_set_rgb_rgba32(&value.color, val); colorSet = true;}
+ void setColor( SPColor const& color ) {value.color = color; colorSet = true;}
};
/// Filter type internal to SPStyle
diff --git a/src/tweak-context.cpp b/src/tweak-context.cpp
index 1e7379dea2e68097d5c35345c8e5adc3ad78eb13..49b39a5e6d86dfdfbb768f1d1081dbeb8b28b746 100644 (file)
--- a/src/tweak-context.cpp
+++ b/src/tweak-context.cpp
} else {
this_force = force * tweak_profile (NR::L2 (p - center), radius);
}
-
+
if (this_force > 0.002) {
if (do_fill) {
- if (style->fill.type == SP_PAINT_TYPE_COLOR) {
+ if (style->fill.isPaintserver()) {
+ tweak_colors_in_gradient (item, true, fill_goal, p, radius, this_force, mode, do_h, do_s, do_l, do_o);
+ did = true;
+ } else if (style->fill.isColor()) {
tweak_color (mode, style->fill.value.color.v.c, fill_goal, this_force, do_h, do_s, do_l);
item->updateRepr();
did = true;
- } else if (style->fill.type == SP_PAINT_TYPE_PAINTSERVER) {
- tweak_colors_in_gradient (item, true, fill_goal, p, radius, this_force, mode, do_h, do_s, do_l, do_o);
- did = true;
}
}
if (do_stroke) {
- if (style->stroke.type == SP_PAINT_TYPE_COLOR) {
+ if (style->stroke.isPaintserver()) {
+ tweak_colors_in_gradient (item, false, stroke_goal, p, radius, this_force, mode, do_h, do_s, do_l, do_o);
+ did = true;
+ } else if (style->stroke.isColor()) {
tweak_color (mode, style->stroke.value.color.v.c, stroke_goal, this_force, do_h, do_s, do_l);
item->updateRepr();
did = true;
- } else if (style->stroke.type == SP_PAINT_TYPE_PAINTSERVER) {
- tweak_colors_in_gradient (item, false, stroke_goal, p, radius, this_force, mode, do_h, do_s, do_l, do_o);
- did = true;
}
}
if (do_opacity && do_o) {
index e2ac69b4c44ded970fb243d4deb3336e517ed929..763913b2783ef8e759beb638079ea00e639b1b54 100644 (file)
} else {
paint = &(query->stroke);
}
- if (paint->set && paint->type == SP_PAINT_TYPE_COLOR) {
- guint32 color = sp_color_get_rgba32_falpha (&(paint->value.color),
- SP_SCALE24_TO_FLOAT ((i == SS_FILL)? query->fill_opacity.value : query->stroke_opacity.value));
- _lastselected[i] = _thisselected[i];
- _thisselected[i] = color | 0xff; // only color, opacity === 1
- ((Inkscape::UI::Widget::ColorPreview*)_color_preview[i])->setRgba32 (color);
- _color_preview[i]->show_all();
- place->add(*_color_preview[i]);
- gchar c_string[64];
- g_snprintf (c_string, 64, "%06x/%.3g", color >> 8, SP_RGBA32_A_F(color));
- _tooltips.set_tip(*place, __color[i] + ": " + c_string);
- _mode[i] = SS_COLOR;
- _popup_copy[i].set_sensitive(true);
-
- } else if (paint->set && paint->type == SP_PAINT_TYPE_PAINTSERVER) {
+ if (paint->set && paint->isPaintserver()) {
SPPaintServer *server = (i == SS_FILL)? SP_STYLE_FILL_SERVER (query) : SP_STYLE_STROKE_SERVER (query);
if ( server ) {
Inkscape::XML::Node *srepr = SP_OBJECT_REPR(server);
} else {
g_warning ("file %s: line %d: Unknown paint server", __FILE__, __LINE__);
}
+ } else if (paint->set && paint->isColor()) {
+ guint32 color = sp_color_get_rgba32_falpha (&(paint->value.color),
+ SP_SCALE24_TO_FLOAT ((i == SS_FILL)? query->fill_opacity.value : query->stroke_opacity.value));
+ _lastselected[i] = _thisselected[i];
+ _thisselected[i] = color | 0xff; // only color, opacity === 1
+ ((Inkscape::UI::Widget::ColorPreview*)_color_preview[i])->setRgba32 (color);
+ _color_preview[i]->show_all();
+ place->add(*_color_preview[i]);
+ gchar c_string[64];
+ g_snprintf (c_string, 64, "%06x/%.3g", color >> 8, SP_RGBA32_A_F(color));
+ _tooltips.set_tip(*place, __color[i] + ": " + c_string);
+ _mode[i] = SS_COLOR;
+ _popup_copy[i].set_sensitive(true);
- } else if (paint->set && paint->type == SP_PAINT_TYPE_NONE) {
+ } else if (paint->set && paint->isNone()) {
place->add(_none[i]);
_tooltips.set_tip(*place, __none[i]);
_mode[i] = SS_NONE;
index cad07fbd6ed3435cb6b87e2e31baf3a50152357c..4d5a7fc12c1315ae2001ca3b18fce25ffbded40f 100644 (file)
paint = &(query->stroke);
}
- if (paint->set && paint->type == SP_PAINT_TYPE_COLOR) {
- guint32 color = sp_color_get_rgba32_falpha (&(paint->value.color),
- SP_SCALE24_TO_FLOAT ((i == SS_FILL)? query->fill_opacity.value : query->stroke_opacity.value));
- ((Inkscape::UI::Widget::ColorPreview*)_color_preview[i])->setRgba32 (color);
- _color_preview[i]->show_all();
- place->add(*_color_preview[i]);
- gchar *tip;
- if (i == SS_FILL) {
- tip = g_strdup_printf (_("Fill: %06x/%.3g"), color >> 8, SP_RGBA32_A_F(color));
- } else {
- tip = g_strdup_printf (_("Stroke: %06x/%.3g"), color >> 8, SP_RGBA32_A_F(color));
- }
- _tooltips.set_tip(*place, tip);
- g_free (tip);
- } else if (paint->set && paint->type == SP_PAINT_TYPE_PAINTSERVER) {
+ if (paint->set && paint->isPaintserver()) {
SPPaintServer *server = (i == SS_FILL)? SP_STYLE_FILL_SERVER (query) : SP_STYLE_STROKE_SERVER (query);
if (SP_IS_LINEARGRADIENT (server)) {
_tooltips.set_tip(*place, (i == SS_FILL)? (_("Pattern fill")) : (_("Pattern stroke")));
}
- } else if (paint->set && paint->type == SP_PAINT_TYPE_NONE) {
+ } else if (paint->set && paint->isColor()) {
+ guint32 color = sp_color_get_rgba32_falpha (&(paint->value.color),
+ SP_SCALE24_TO_FLOAT ((i == SS_FILL)? query->fill_opacity.value : query->stroke_opacity.value));
+ ((Inkscape::UI::Widget::ColorPreview*)_color_preview[i])->setRgba32 (color);
+ _color_preview[i]->show_all();
+ place->add(*_color_preview[i]);
+ gchar *tip;
+ if (i == SS_FILL) {
+ tip = g_strdup_printf (_("Fill: %06x/%.3g"), color >> 8, SP_RGBA32_A_F(color));
+ } else {
+ tip = g_strdup_printf (_("Stroke: %06x/%.3g"), color >> 8, SP_RGBA32_A_F(color));
+ }
+ _tooltips.set_tip(*place, tip);
+ g_free (tip);
+ } else if (paint->set && paint->isNone()) {
_value[i].set_markup(_("<i>None</i>"));
place->add(_value[i]);
_tooltips.set_tip(*place, (i == SS_FILL)? (_("No fill")) : (_("No stroke")));
index 49e72bc2182f80b041ed8baf85a4145019ffcb4a..f6441b208448de2ee9a7794051f8448a38f16156 100644 (file)
SPStyle *style = SP_OBJECT_STYLE (item);
if (do_fill) {
- if (style && (style->fill.type == SP_PAINT_TYPE_PAINTSERVER) &&
+ if (style && (style->fill.isPaintserver()) &&
SP_IS_GRADIENT (SP_OBJECT_STYLE_FILL_SERVER (item))) {
SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (item);
if (SP_IS_LINEARGRADIENT (server)) {
}
if (do_stroke) {
- if (style && (style->stroke.type == SP_PAINT_TYPE_PAINTSERVER) &&
+ if (style && (style->stroke.isPaintserver()) &&
SP_IS_GRADIENT (SP_OBJECT_STYLE_STROKE_SERVER (item))) {
SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (item);
if (SP_IS_LINEARGRADIENT (server)) {
@@ -298,7 +298,7 @@ gr_read_selection (Inkscape::Selection *selection, GrDrag *drag, SPGradient **gr
SPItem *item = SP_ITEM(i->data);
SPStyle *style = SP_OBJECT_STYLE (item);
- if (style && (style->fill.type == SP_PAINT_TYPE_PAINTSERVER)) {
+ if (style && (style->fill.isPaintserver())) {
SPObject *server = SP_OBJECT_STYLE_FILL_SERVER (item);
if (SP_IS_GRADIENT (server)) {
SPGradient *gradient = sp_gradient_get_vector (SP_GRADIENT (server), false);
@@ -319,7 +319,7 @@ gr_read_selection (Inkscape::Selection *selection, GrDrag *drag, SPGradient **gr
}
}
}
- if (style && (style->stroke.type == SP_PAINT_TYPE_PAINTSERVER)) {
+ if (style && (style->stroke.isPaintserver())) {
SPObject *server = SP_OBJECT_STYLE_STROKE_SERVER (item);
if (SP_IS_GRADIENT (server)) {
SPGradient *gradient = sp_gradient_get_vector (SP_GRADIENT (server), false);
index c9f29f3c55ae5487a2d171ee3fd106d18758d1e0..b16a621686a8568c5cb49b72ef186cd5e76cde88 100644 (file)
@@ -920,47 +920,34 @@ sp_paint_selector_set_flat_color(SPPaintSelector *psel, SPDesktop *desktop, gcha
SPPaintSelectorMode
sp_style_determine_paint_selector_mode(SPStyle *style, bool isfill)
{
- unsigned set = isfill? style->fill.set : style->stroke.set;
- if (!set)
- return SP_PAINT_SELECTOR_MODE_UNSET;
-
- unsigned type = isfill? style->fill.type : style->stroke.type;
- switch (type) {
-
- case SP_PAINT_TYPE_NONE:
- {
- return SP_PAINT_SELECTOR_MODE_NONE;
- }
-
- case SP_PAINT_TYPE_COLOR:
- {
- return SP_PAINT_SELECTOR_MODE_COLOR_RGB; // so far only rgb can be read from svg
- }
-
- case SP_PAINT_TYPE_PAINTSERVER:
- {
- SPPaintServer *server = isfill? SP_STYLE_FILL_SERVER(style) : SP_STYLE_STROKE_SERVER(style);
-
- if (SP_IS_LINEARGRADIENT(server)) {
- return SP_PAINT_SELECTOR_MODE_GRADIENT_LINEAR;
- } else if (SP_IS_RADIALGRADIENT(server)) {
- return SP_PAINT_SELECTOR_MODE_GRADIENT_RADIAL;
- } else if (SP_IS_PATTERN(server)) {
- return SP_PAINT_SELECTOR_MODE_PATTERN;
- }
-
- g_warning( "file %s: line %d: Unknown paintserver",
- __FILE__, __LINE__ );
- return SP_PAINT_SELECTOR_MODE_NONE;
+ SPPaintSelectorMode mode = SP_PAINT_SELECTOR_MODE_UNSET;
+ SPIPaint& target = isfill ? style->fill : style->stroke;
+
+ if ( !target.set ) {
+ SPPaintSelectorMode mode = SP_PAINT_SELECTOR_MODE_UNSET;
+ } else if ( target.isPaintserver() ) {
+ SPPaintServer *server = isfill? SP_STYLE_FILL_SERVER(style) : SP_STYLE_STROKE_SERVER(style);
+
+ if (SP_IS_LINEARGRADIENT(server)) {
+ mode = SP_PAINT_SELECTOR_MODE_GRADIENT_LINEAR;
+ } else if (SP_IS_RADIALGRADIENT(server)) {
+ mode = SP_PAINT_SELECTOR_MODE_GRADIENT_RADIAL;
+ } else if (SP_IS_PATTERN(server)) {
+ mode = SP_PAINT_SELECTOR_MODE_PATTERN;
+ } else {
+ g_warning( "file %s: line %d: Unknown paintserver", __FILE__, __LINE__ );
+ mode = SP_PAINT_SELECTOR_MODE_NONE;
}
-
- default:
- g_warning( "file %s: line %d: Unknown paint type %d",
- __FILE__, __LINE__, type );
- break;
+ } else if ( target.isColor() ) {
+ mode = SP_PAINT_SELECTOR_MODE_COLOR_RGB; // so far only rgb can be read from svg
+ } else if ( target.isNone() ) {
+ mode = SP_PAINT_SELECTOR_MODE_NONE;
+ } else {
+ g_warning( "file %s: line %d: Unknown paint type", __FILE__, __LINE__ );
+ mode = SP_PAINT_SELECTOR_MODE_NONE;
}
- return SP_PAINT_SELECTOR_MODE_NONE;
+ return mode;
}
/*