From: joncruz Date: Sat, 15 Sep 2007 16:37:27 +0000 (+0000) Subject: Refactoring SPColor to C++ and removing legacy CMYK implementation X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=569ef8f6dbacc8a8b0b933d02a806c2e091ce02b;p=inkscape.git Refactoring SPColor to C++ and removing legacy CMYK implementation --- diff --git a/src/color.cpp b/src/color.cpp index 2a6da863c..8dc4c8657 100644 --- a/src/color.cpp +++ b/src/color.cpp @@ -1,11 +1,12 @@ #define __SP_COLOR_C__ /** \file - * Colors and colorspaces. + * Colors. * * Author: * Lauris Kaplinski * bulia byak + * Jon A. Cruz * * Copyright (C) 2001-2002 Lauris Kaplinski * Copyright (C) 2001 Ximian, Inc. @@ -15,103 +16,115 @@ #include #include "color.h" +#include "svg/svg-icc-color.h" -/// A color space is just a name. -struct SPColorSpace { - gchar const *name; -}; +static bool profileMatches( SVGICCColor const* first, SVGICCColor const* second ); -static SPColorSpace const RGB = {"RGB"}; -static SPColorSpace const CMYK = {"CMYK"}; +#define PROFILE_EPSILON 0.00000001 -/** - * Returns one of three values depending on if color is valid and if it - * has a valid color space. Likely redundant as soon as this is C++. - */ -SPColorSpaceClass -sp_color_get_colorspace_class(SPColor const *color) +SPColor::SPColor() : + icc(0) { - g_return_val_if_fail (color != NULL, SP_COLORSPACE_CLASS_INVALID); - - if (color->colorspace == &RGB) return SP_COLORSPACE_CLASS_PROCESS; - if (color->colorspace == &CMYK) return SP_COLORSPACE_CLASS_PROCESS; + v.c[0] = 0; + v.c[1] = 0; + v.c[2] = 0; +} - return SP_COLORSPACE_CLASS_UNKNOWN; +SPColor::SPColor( SPColor const& other ) : + icc(0) +{ + *this = other; } -/** - * Returns the SPColorSpaceType corresponding to color's color space. - * \todo color->colorspace should simply be a named enum. - */ -SPColorSpaceType -sp_color_get_colorspace_type(SPColor const *color) +SPColor::SPColor( float r, float g, float b ) : + icc(0) { - g_return_val_if_fail (color != NULL, SP_COLORSPACE_TYPE_INVALID); + set( r, g, b ); +} - if (color->colorspace == &RGB) return SP_COLORSPACE_TYPE_RGB; - if (color->colorspace == &CMYK) return SP_COLORSPACE_TYPE_CMYK; +SPColor::SPColor( guint32 value ) : + icc(0) +{ + set( value ); +} - return SP_COLORSPACE_TYPE_UNKNOWN; +SPColor::~SPColor() +{ + delete icc; + icc = 0; } -/** - * Shallow copy of color struct with NULL check. - */ -void -sp_color_copy(SPColor *dst, SPColor const *src) + +SPColor& SPColor::operator= (SPColor const& other) { - g_return_if_fail (dst != NULL); - g_return_if_fail (src != NULL); + SVGICCColor* tmp = other.icc ? new SVGICCColor(*other.icc) : 0; + v.c[0] = other.v.c[0]; + v.c[1] = other.v.c[1]; + v.c[2] = other.v.c[2]; + if ( icc ) { + delete icc; + } + icc = tmp; - *dst = *src; + return *this; } + /** - * Returns TRUE if c0 or c1 is NULL, or if colors/opacities differ. + * Returns true if colors match. */ -gboolean -sp_color_is_equal (SPColor const *c0, SPColor const *c1) +bool SPColor::operator == (SPColor const& other) const { - g_return_val_if_fail (c0 != NULL, TRUE); - g_return_val_if_fail (c1 != NULL, TRUE); + bool match = (v.c[0] != other.v.c[0]) + && (v.c[1] != other.v.c[1]) + && (v.c[2] != other.v.c[2]); - if (c0->colorspace != c1->colorspace) return FALSE; - if (c0->v.c[0] != c1->v.c[0]) return FALSE; - if (c0->v.c[1] != c1->v.c[1]) return FALSE; - if (c0->v.c[2] != c1->v.c[2]) return FALSE; - if ((c0->colorspace == &CMYK) && (c0->v.c[3] != c1->v.c[3])) return FALSE; + match &= profileMatches( icc, other.icc ); - return TRUE; + return match; } /** - * Returns TRUE if no RGB value differs epsilon or more in both colors, - * with CMYK aditionally comparing opacity, or if c0 or c1 is NULL. - * \note Do we want the latter? + * Returns true if no RGB value differs epsilon or more in both colors, + * false otherwise. */ -gboolean -sp_color_is_close (SPColor const *c0, SPColor const *c1, float epsilon) +bool SPColor::isClose( SPColor const& other, float epsilon ) const { - g_return_val_if_fail (c0 != NULL, TRUE); - g_return_val_if_fail (c1 != NULL, TRUE); + bool match = false; + + match = (fabs((v.c[0]) - (other.v.c[0])) < epsilon) + && (fabs((v.c[1]) - (other.v.c[1])) < epsilon) + && (fabs((v.c[2]) - (other.v.c[2])) < epsilon); - if (c0->colorspace != c1->colorspace) return FALSE; - if (fabs ((c0->v.c[0]) - (c1->v.c[0])) >= epsilon) return FALSE; - if (fabs ((c0->v.c[1]) - (c1->v.c[1])) >= epsilon) return FALSE; - if (fabs ((c0->v.c[2]) - (c1->v.c[2])) >= epsilon) return FALSE; - if ((c0->colorspace == &CMYK) && (fabs ((c0->v.c[3]) - (c1->v.c[3])) >= epsilon)) return FALSE; + // TODO uncomment once we start using that profile. Will be RSN + //match &= profileMatches( icc, other.icc ); - return TRUE; + return match; +} + +static bool profileMatches( SVGICCColor const* first, SVGICCColor const* second ) { + bool match = false; + if ( !first && !second ) { + match = true; + } else { + match = first && second + && (first->colorProfile == second->colorProfile) + && (first->colors.size() == second->colors.size()); + if ( match ) { + for ( guint i = 0; i < first->colors.size(); i++ ) { + match &= (fabs(first->colors[i] - second->colors[i]) < PROFILE_EPSILON); + } + } + } + return match; } /** * Sets RGB values and colorspace in color. - * \pre color != NULL && 0 <={r,g,b}<=1 + * \pre 0 <={r,g,b}<=1 */ -void -sp_color_set_rgb_float(SPColor *color, float r, float g, float b) +void SPColor::set( float r, float g, float b ) { - g_return_if_fail(color != NULL); g_return_if_fail(r >= 0.0); g_return_if_fail(r <= 1.0); g_return_if_fail(g >= 0.0); @@ -119,80 +132,35 @@ sp_color_set_rgb_float(SPColor *color, float r, float g, float b) g_return_if_fail(b >= 0.0); g_return_if_fail(b <= 1.0); - color->colorspace = &RGB; - color->v.c[0] = r; - color->v.c[1] = g; - color->v.c[2] = b; - color->v.c[3] = 0; + // TODO clear icc if set? + v.c[0] = r; + v.c[1] = g; + v.c[2] = b; } /** * Converts 32bit value to RGB floats and sets color. - * \pre color != NULL */ -void -sp_color_set_rgb_rgba32(SPColor *color, guint32 value) +void SPColor::set( guint32 value ) { - g_return_if_fail (color != NULL); - - color->colorspace = &RGB; - color->v.c[0] = (value >> 24) / 255.0F; - color->v.c[1] = ((value >> 16) & 0xff) / 255.0F; - color->v.c[2] = ((value >> 8) & 0xff) / 255.0F; - color->v.c[3] = 0; -} - -/** - * Sets CMYK values and colorspace in color. - * \pre color != NULL && 0 <={c,m,y,k}<=1 - */ -void -sp_color_set_cmyk_float(SPColor *color, float c, float m, float y, float k) -{ - g_return_if_fail(color != NULL); - g_return_if_fail(c >= 0.0); - g_return_if_fail(c <= 1.0); - g_return_if_fail(m >= 0.0); - g_return_if_fail(m <= 1.0); - g_return_if_fail(y >= 0.0); - g_return_if_fail(y <= 1.0); - g_return_if_fail(k >= 0.0); - g_return_if_fail(k <= 1.0); - - color->colorspace = &CMYK; - color->v.c[0] = c; - color->v.c[1] = m; - color->v.c[2] = y; - color->v.c[3] = k; + // TODO clear icc if set? + v.c[0] = (value >> 24) / 255.0F; + v.c[1] = ((value >> 16) & 0xff) / 255.0F; + v.c[2] = ((value >> 8) & 0xff) / 255.0F; } /** * Convert SPColor with integer alpha value to 32bit RGBA value. - * \pre color != NULL && alpha < 256 + * \pre alpha < 256 */ -guint32 -sp_color_get_rgba32_ualpha(SPColor const *color, guint32 alpha) +guint32 SPColor::toRGBA32( gint alpha ) const { - guint32 rgba; - - g_return_val_if_fail (color != NULL, 0x0); g_return_val_if_fail (alpha <= 0xff, 0x0); - if (color->colorspace == &RGB) { - rgba = SP_RGBA32_U_COMPOSE(SP_COLOR_F_TO_U(color->v.c[0]), - SP_COLOR_F_TO_U(color->v.c[1]), - SP_COLOR_F_TO_U(color->v.c[2]), - alpha); - } else { - float rgb[3]; - rgb[0] = rgb[1] = rgb[2] = 0.0; - sp_color_get_rgb_floatv (color, rgb); - rgba = SP_RGBA32_U_COMPOSE(SP_COLOR_F_TO_U(rgb[0]), - SP_COLOR_F_TO_U(rgb[1]), - SP_COLOR_F_TO_U(rgb[2]), - alpha); - } - + guint32 rgba = SP_RGBA32_U_COMPOSE( SP_COLOR_F_TO_U(v.c[0]), + SP_COLOR_F_TO_U(v.c[1]), + SP_COLOR_F_TO_U(v.c[2]), + alpha ); return rgba; } @@ -200,14 +168,12 @@ sp_color_get_rgba32_ualpha(SPColor const *color, guint32 alpha) * Convert SPColor with float alpha value to 32bit RGBA value. * \pre color != NULL && 0 <= alpha <= 1 */ -guint32 -sp_color_get_rgba32_falpha(SPColor const *color, float alpha) +guint32 SPColor::toRGBA32( gdouble alpha ) const { - g_return_val_if_fail(color != NULL, 0x0); g_return_val_if_fail(alpha >= 0.0, 0x0); g_return_val_if_fail(alpha <= 1.0, 0x0); - return sp_color_get_rgba32_ualpha(color, SP_COLOR_F_TO_U(alpha)); + return toRGBA32( static_cast(SP_COLOR_F_TO_U(alpha)) ); } /** @@ -220,17 +186,9 @@ sp_color_get_rgb_floatv(SPColor const *color, float *rgb) g_return_if_fail (color != NULL); g_return_if_fail (rgb != NULL); - if (color->colorspace == &RGB) { - rgb[0] = color->v.c[0]; - rgb[1] = color->v.c[1]; - rgb[2] = color->v.c[2]; - } else if (color->colorspace == &CMYK) { - sp_color_cmyk_to_rgb_floatv(rgb, - color->v.c[0], - color->v.c[1], - color->v.c[2], - color->v.c[3]); - } + rgb[0] = color->v.c[0]; + rgb[1] = color->v.c[1]; + rgb[2] = color->v.c[2]; } /** @@ -243,17 +201,10 @@ sp_color_get_cmyk_floatv(SPColor const *color, float *cmyk) g_return_if_fail (color != NULL); g_return_if_fail (cmyk != NULL); - if (color->colorspace == &CMYK) { - cmyk[0] = color->v.c[0]; - cmyk[1] = color->v.c[1]; - cmyk[2] = color->v.c[2]; - cmyk[3] = color->v.c[3]; - } else if (color->colorspace == &RGB) { - sp_color_rgb_to_cmyk_floatv(cmyk, - color->v.c[0], - color->v.c[1], - color->v.c[2]); - } + sp_color_rgb_to_cmyk_floatv( cmyk, + color->v.c[0], + color->v.c[1], + color->v.c[2] ); } /* Plain mode helpers */ @@ -291,7 +242,7 @@ sp_color_rgb_to_hsv_floatv (float *hsv, float r, float g, float b) if (hsv[0] < 0) hsv[0] += 1.0; } - else + else hsv[0] = 0.0; } diff --git a/src/color.h b/src/color.h index 2c3f91fe7..e93943609 100644 --- a/src/color.h +++ b/src/color.h @@ -2,11 +2,12 @@ #define __SP_COLOR_H__ /** \file - * Colors and colorspaces + * Colors. * * Author: * Lauris Kaplinski * bulia byak + * Jon A. Cruz * * Copyright (C) 2001-2002 Lauris Kaplinski * Copyright (C) 2001 Ximian, Inc. @@ -16,8 +17,6 @@ #include -struct SPColorSpace; - /* Useful composition macros */ #define SP_RGBA32_R_U(v) (((v) >> 24) & 0xff) @@ -33,44 +32,34 @@ struct SPColorSpace; #define SP_RGBA32_U_COMPOSE(r,g,b,a) ((((r) & 0xff) << 24) | (((g) & 0xff) << 16) | (((b) & 0xff) << 8) | ((a) & 0xff)) #define SP_RGBA32_F_COMPOSE(r,g,b,a) SP_RGBA32_U_COMPOSE (SP_COLOR_F_TO_U (r), SP_COLOR_F_TO_U (g), SP_COLOR_F_TO_U (b), SP_COLOR_F_TO_U (a)) -typedef enum { - SP_COLORSPACE_CLASS_INVALID, - SP_COLORSPACE_CLASS_NONE, - SP_COLORSPACE_CLASS_UNKNOWN, - SP_COLORSPACE_CLASS_PROCESS, - SP_COLORSPACE_CLASS_SPOT -} SPColorSpaceClass; - -typedef enum { - SP_COLORSPACE_TYPE_INVALID, - SP_COLORSPACE_TYPE_NONE, - SP_COLORSPACE_TYPE_UNKNOWN, - SP_COLORSPACE_TYPE_RGB, - SP_COLORSPACE_TYPE_CMYK -} SPColorSpaceType; +struct SVGICCColor; /** - * An RGBA color in an SPColorSpace + * An RGB color with optional icc-color part */ struct SPColor { - const SPColorSpace *colorspace; - union { - float c[4]; - } v; -}; + SPColor(); + SPColor( SPColor const& other ); + SPColor( float r, float g, float b ); + SPColor( guint32 value ); + ~SPColor(); -SPColorSpaceClass sp_color_get_colorspace_class (const SPColor *color); -SPColorSpaceType sp_color_get_colorspace_type (const SPColor *color); + SPColor& operator= (SPColor const& other); -void sp_color_copy (SPColor *dst, const SPColor *src); + bool operator == ( SPColor const& other ) const; + bool isClose( SPColor const& other, float epsilon ) const; -gboolean sp_color_is_equal (const SPColor *c0, const SPColor *c1); -gboolean sp_color_is_close (const SPColor *c0, const SPColor *c1, float epsilon); + void set( float r, float g, float b ); + void set( guint32 value ); -void sp_color_set_rgb_float (SPColor *color, float r, float g, float b); -void sp_color_set_rgb_rgba32 (SPColor *color, guint32 value); + guint32 toRGBA32( gint alpha ) const; + guint32 toRGBA32( gdouble alpha ) const; -void sp_color_set_cmyk_float (SPColor *color, float c, float m, float y, float k); + SVGICCColor* icc; + union { + float c[3]; + } v; +}; guint32 sp_color_get_rgba32_ualpha (const SPColor *color, guint32 alpha); guint32 sp_color_get_rgba32_falpha (const SPColor *color, float alpha); @@ -90,6 +79,5 @@ void sp_color_rgb_to_cmyk_floatv (float *cmyk, float r, float g, float b); void sp_color_cmyk_to_rgb_floatv (float *rgb, float c, float m, float y, float k); - #endif diff --git a/src/dialogs/fill-style.cpp b/src/dialogs/fill-style.cpp index 3d830027c..1dfaea546 100644 --- a/src/dialogs/fill-style.cpp +++ b/src/dialogs/fill-style.cpp @@ -123,15 +123,14 @@ sp_fill_style_widget_new (void) static void sp_fill_style_widget_construct ( SPWidget *spw, SPPaintSelector *psel ) { + (void)psel; #ifdef SP_FS_VERBOSE g_print ( "Fill style widget constructed: inkscape %p repr %p\n", spw->inkscape, spw->repr ); #endif if (spw->inkscape) { - sp_fill_style_widget_update (spw); - } } // end of sp_fill_style_widget_construct() @@ -142,6 +141,8 @@ sp_fill_style_widget_modify_selection ( SPWidget *spw, guint flags, SPPaintSelector *psel ) { + (void)selection; + (void)psel; if (flags & ( SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_PARENT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG) ) @@ -155,6 +156,7 @@ sp_fill_style_widget_change_subselection ( Inkscape::Application *inkscape, SPDesktop *desktop, SPWidget *spw ) { + (void)inkscape; sp_fill_style_widget_update (spw); } @@ -163,6 +165,7 @@ sp_fill_style_widget_change_selection ( SPWidget *spw, Inkscape::Selection *selection, SPPaintSelector *psel ) { + (void)selection; sp_fill_style_widget_update (spw); } @@ -210,8 +213,7 @@ sp_fill_style_widget_update (SPWidget *spw) 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]); + SPColor 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.isPaintserver()) { @@ -261,6 +263,7 @@ sp_fill_style_widget_paint_mode_changed ( SPPaintSelector *psel, SPPaintSelectorMode mode, SPWidget *spw ) { + (void)mode; if (g_object_get_data (G_OBJECT (spw), "update")) return; @@ -275,6 +278,7 @@ sp_fill_style_widget_fillrule_changed ( SPPaintSelector *psel, SPPaintSelectorFillRule mode, SPWidget *spw ) { + (void)psel; if (g_object_get_data (G_OBJECT (spw), "update")) return; @@ -431,13 +435,13 @@ sp_fill_style_widget_paint_changed ( SPPaintSelector *psel, /* No vector in paint selector should mean that we just changed mode */ SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); - int result = objects_query_fillstroke ((GSList *) items, query, true); + int result = objects_query_fillstroke ((GSList *) items, query, true); guint32 common_rgb = 0; if (result == QUERY_STYLE_MULTIPLE_SAME) { 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); + common_rgb = query->fill.value.color.toRGBA32( 0xff ); } vector = sp_document_default_gradient_vector(document, common_rgb); } @@ -448,7 +452,7 @@ sp_fill_style_widget_paint_changed ( SPPaintSelector *psel, sp_repr_css_change_recursive(SP_OBJECT_REPR(i->data), css, "style"); if (!vector) { - sp_item_set_gradient(SP_ITEM(i->data), + sp_item_set_gradient(SP_ITEM(i->data), sp_gradient_vector_for_object(document, desktop, SP_OBJECT(i->data), true), gradient_type, true); } else { diff --git a/src/dialogs/stroke-style.cpp b/src/dialogs/stroke-style.cpp index de367b66f..9dc7131fc 100644 --- a/src/dialogs/stroke-style.cpp +++ b/src/dialogs/stroke-style.cpp @@ -73,7 +73,7 @@ static void sp_stroke_style_paint_dragged(SPPaintSelector *psel, SPWidget *spw); static void sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw); static void sp_stroke_style_widget_change_subselection ( Inkscape::Application *inkscape, SPDesktop *desktop, SPWidget *spw ); -static void sp_stroke_style_widget_transientize_callback(Inkscape::Application *inkscape, +static void sp_stroke_style_widget_transientize_callback(Inkscape::Application *inkscape, SPDesktop *desktop, SPWidget *spw ); @@ -136,13 +136,14 @@ sp_stroke_style_paint_widget_new(void) static void sp_stroke_style_paint_construct(SPWidget *spw, SPPaintSelector *psel) { + (void)psel; #ifdef SP_SS_VERBOSE g_print( "Stroke style widget constructed: inkscape %p repr %p\n", spw->inkscape, spw->repr ); #endif if (spw->inkscape) { sp_stroke_style_paint_update (spw); - } + } } /** @@ -154,6 +155,7 @@ sp_stroke_style_paint_selection_modified ( SPWidget *spw, guint flags, SPPaintSelector *psel) { + (void)selection; if (flags & ( SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_PARENT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG) ) { sp_stroke_style_paint_update(spw); @@ -169,6 +171,7 @@ sp_stroke_style_paint_selection_changed ( SPWidget *spw, Inkscape::Selection *selection, SPPaintSelector *psel ) { + (void)selection; sp_stroke_style_paint_update (spw); } @@ -177,10 +180,11 @@ sp_stroke_style_paint_selection_changed ( SPWidget *spw, * On signal change subselection, invoke an update of the stroke style widget. */ static void -sp_stroke_style_widget_change_subselection ( Inkscape::Application *inkscape, +sp_stroke_style_widget_change_subselection ( Inkscape::Application *inkscape, SPDesktop *desktop, SPWidget *spw ) { + (void)inkscape; sp_stroke_style_paint_update (spw); } @@ -202,7 +206,7 @@ sp_stroke_style_paint_update (SPWidget *spw) // create temporary style SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); // query into it - int result = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKE); + int result = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKE); switch (result) { case QUERY_STYLE_NOTHING: @@ -246,8 +250,7 @@ sp_stroke_style_paint_update (SPWidget *spw) } 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]); + SPColor color( d[0], d[1], d[2] ); sp_paint_selector_set_color_alpha (psel, &color, SP_SCALE24_TO_FLOAT (query->stroke_opacity.value)); } @@ -274,6 +277,7 @@ sp_stroke_style_paint_mode_changed( SPPaintSelector *psel, SPPaintSelectorMode mode, SPWidget *spw ) { + (void)mode; if (gtk_object_get_data(GTK_OBJECT(spw), "update")) { return; } @@ -290,7 +294,7 @@ static gchar *undo_label_2 = "stroke:flatcolor:2"; static gchar *undo_label = undo_label_1; /** - * When a drag callback occurs on a paint selector object, if it is a RGB or CMYK + * When a drag callback occurs on a paint selector object, if it is a RGB or CMYK * color mode, then set the stroke opacity to psel's flat color. */ static void @@ -305,7 +309,7 @@ sp_stroke_style_paint_dragged(SPPaintSelector *psel, SPWidget *spw) case SP_PAINT_SELECTOR_MODE_COLOR_CMYK: { sp_paint_selector_set_flat_color (psel, SP_ACTIVE_DESKTOP, "stroke", "stroke-opacity"); - sp_document_maybe_done (sp_desktop_document(SP_ACTIVE_DESKTOP), undo_label, SP_VERB_DIALOG_FILL_STROKE, + sp_document_maybe_done (sp_desktop_document(SP_ACTIVE_DESKTOP), undo_label, SP_VERB_DIALOG_FILL_STROKE, _("Set stroke color")); break; } @@ -355,7 +359,7 @@ sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw) sp_repr_css_attr_unref(css); - sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, + sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, _("Remove stroke")); break; } @@ -364,13 +368,13 @@ sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw) case SP_PAINT_SELECTOR_MODE_COLOR_CMYK: { sp_paint_selector_set_flat_color (psel, desktop, "stroke", "stroke-opacity"); - sp_document_maybe_done (sp_desktop_document(desktop), undo_label, SP_VERB_DIALOG_FILL_STROKE, + sp_document_maybe_done (sp_desktop_document(desktop), undo_label, SP_VERB_DIALOG_FILL_STROKE, _("Set stroke color")); // on release, toggle undo_label so that the next drag will not be lumped with this one if (undo_label == undo_label_1) undo_label = undo_label_2; - else + else undo_label = undo_label_1; break; @@ -387,13 +391,13 @@ sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw) /* No vector in paint selector should mean that we just changed mode */ SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); - int result = objects_query_fillstroke ((GSList *) items, query, false); + int result = objects_query_fillstroke ((GSList *) items, query, false); guint32 common_rgb = 0; if (result == QUERY_STYLE_MULTIPLE_SAME) { 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); + common_rgb = query->stroke.value.color.toRGBA32( 0xff ); } vector = sp_document_default_gradient_vector(document, common_rgb); } @@ -401,7 +405,7 @@ sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw) for (GSList const *i = items; i != NULL; i = i->next) { if (!vector) { - sp_item_set_gradient(SP_ITEM(i->data), + sp_item_set_gradient(SP_ITEM(i->data), sp_gradient_vector_for_object(document, desktop, SP_OBJECT(i->data), false), gradient_type, false); } else { @@ -416,7 +420,7 @@ sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw) } } - sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, + sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, _("Set gradient on stroke")); } break; @@ -460,7 +464,7 @@ sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw) } // end if - sp_document_done (document, SP_VERB_DIALOG_FILL_STROKE, + sp_document_done (document, SP_VERB_DIALOG_FILL_STROKE, _("Set pattern on stroke")); } // end if @@ -481,7 +485,7 @@ sp_stroke_style_paint_changed(SPPaintSelector *psel, SPWidget *spw) sp_desktop_set_style (desktop, css); sp_repr_css_attr_unref (css); - sp_document_done (document, SP_VERB_DIALOG_FILL_STROKE, + sp_document_done (document, SP_VERB_DIALOG_FILL_STROKE, _("Unset stroke")); } break; @@ -567,10 +571,13 @@ sp_stroke_radio_button(GtkWidget *tb, char const *icon, } static void -sp_stroke_style_widget_transientize_callback(Inkscape::Application *inkscape, +sp_stroke_style_widget_transientize_callback(Inkscape::Application *inkscape, SPDesktop *desktop, SPWidget *spw ) { + (void)inkscape; + (void)desktop; + (void)spw; // TODO: Either of these will cause crashes sometimes // sp_stroke_style_line_update( SP_WIDGET(spw), desktop ? sp_desktop_selection(desktop) : NULL); // ink_markers_menu_update(spw); @@ -586,6 +593,8 @@ sp_marker_prev_new(unsigned psize, gchar const *mname, SPDocument *source, SPDocument *sandbox, gchar *menu_id, NRArena const *arena, unsigned visionkey, NRArenaItem *root) { + (void)arena; + (void)visionkey; // Retrieve the marker named 'mname' from the source SVG document SPObject const *marker = source->getObjectById(mname); if (marker == NULL) @@ -726,6 +735,8 @@ sp_marker_menu_build (GtkWidget *m, GSList *marker_list, SPDocument *source, SPD static void sp_marker_list_from_doc (GtkWidget *m, SPDocument *current_doc, SPDocument *source, SPDocument *markers_doc, SPDocument *sandbox, gchar *menu_id) { + (void)current_doc; + (void)markers_doc; GSList *ml = ink_marker_list_get(source); GSList *clean_ml = NULL; @@ -813,7 +824,7 @@ ink_marker_menu_create_menu(GtkWidget *m, gchar *menu_id, SPDocument *doc, SPDoc // suck in from current doc sp_marker_list_from_doc ( m, NULL, doc, markers_doc, sandbox, menu_id ); - + // add separator { GtkWidget *i = gtk_separator_menu_item_new(); @@ -836,6 +847,7 @@ ink_marker_menu_create_menu(GtkWidget *m, gchar *menu_id, SPDocument *doc, SPDoc static GtkWidget * ink_marker_menu( GtkWidget *tbl, gchar *menu_id, SPDocument *sandbox) { + (void)tbl; SPDesktop *desktop = inkscape_active_desktop(); SPDocument *doc = sp_desktop_document(desktop); GtkWidget *mnu = gtk_option_menu_new(); @@ -935,14 +947,14 @@ sp_marker_select(GtkOptionMenu *mnu, GtkWidget *spw) sp_repr_css_attr_unref(css); - sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, + sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, _("Set markers")); }; static int ink_marker_menu_get_pos(GtkMenu* mnu, gchar* markname) { - + if (markname == NULL) markname = (gchar *) g_object_get_data(G_OBJECT(gtk_menu_get_active(mnu)), "marker"); @@ -1292,7 +1304,7 @@ sp_stroke_style_line_widget_new(void) static void sp_stroke_style_line_construct(SPWidget *spw, gpointer data) { - + (void)data; #ifdef SP_SS_VERBOSE g_print( "Stroke style widget constructed: inkscape %p repr %p\n", spw->inkscape, spw->repr ); @@ -1302,11 +1314,11 @@ sp_stroke_style_line_construct(SPWidget *spw, gpointer data) ( SP_ACTIVE_DESKTOP ? sp_desktop_selection(SP_ACTIVE_DESKTOP) : NULL )); - } + } } /** - * Callback for when stroke style widget is modified. + * Callback for when stroke style widget is modified. * Triggers update action. */ static void @@ -1315,6 +1327,7 @@ sp_stroke_style_line_selection_modified ( SPWidget *spw, guint flags, gpointer data ) { + (void)data; if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_PARENT_MODIFIED_FLAG)) { sp_stroke_style_line_update (spw, selection); } @@ -1330,6 +1343,7 @@ sp_stroke_style_line_selection_changed ( SPWidget *spw, Inkscape::Selection *selection, gpointer data ) { + (void)data; sp_stroke_style_line_update (spw, selection); } @@ -1426,10 +1440,10 @@ sp_stroke_style_line_update(SPWidget *spw, Inkscape::Selection *sel) // create temporary style SPStyle *query = sp_style_new (SP_ACTIVE_DOCUMENT); // query into it - int result_sw = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKEWIDTH); - int result_ml = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKEMITERLIMIT); - int result_cap = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKECAP); - int result_join = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKEJOIN); + int result_sw = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKEWIDTH); + int result_ml = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKEMITERLIMIT); + int result_cap = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKECAP); + int result_join = sp_desktop_query_style (SP_ACTIVE_DESKTOP, query, QUERY_STYLE_PROPERTY_STROKEJOIN); if (result_sw == QUERY_STYLE_NOTHING) { /* No objects stroked, set insensitive */ @@ -1604,7 +1618,7 @@ sp_stroke_style_scale_line(SPWidget *spw) sp_repr_css_attr_unref(css); - sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, + sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE, _("Set stroke style")); gtk_object_set_data(GTK_OBJECT(spw), "update", GINT_TO_POINTER(FALSE)); @@ -1612,12 +1626,13 @@ sp_stroke_style_scale_line(SPWidget *spw) /** - * Callback for when the stroke style's width changes. + * Callback for when the stroke style's width changes. * Causes all line styles to be applied to all selected items. */ static void sp_stroke_style_width_changed(GtkAdjustment *adj, SPWidget *spw) { + (void)adj; if (gtk_object_get_data(GTK_OBJECT(spw), "update")) { return; } @@ -1626,12 +1641,13 @@ sp_stroke_style_width_changed(GtkAdjustment *adj, SPWidget *spw) } /** - * Callback for when the stroke style's miterlimit changes. + * Callback for when the stroke style's miterlimit changes. * Causes all line styles to be applied to all selected items. */ static void sp_stroke_style_miterlimit_changed(GtkAdjustment *adj, SPWidget *spw) { + (void)adj; if (gtk_object_get_data(GTK_OBJECT(spw), "update")) { return; } @@ -1640,12 +1656,13 @@ sp_stroke_style_miterlimit_changed(GtkAdjustment *adj, SPWidget *spw) } /** - * Callback for when the stroke style's dash changes. + * Callback for when the stroke style's dash changes. * Causes all line styles to be applied to all selected items. */ static void sp_stroke_style_line_dash_changed(SPDashSelector *dsel, SPWidget *spw) { + (void)dsel; if (gtk_object_get_data(GTK_OBJECT(spw), "update")) { return; } @@ -1784,7 +1801,7 @@ ink_marker_menu_set_current(SPObject *marker, GtkOptionMenu *mnu) } /** - * Updates the marker menus to highlight the appropriate marker and scroll to + * Updates the marker menus to highlight the appropriate marker and scroll to * that marker. */ static void diff --git a/src/dialogs/swatches.cpp b/src/dialogs/swatches.cpp index 0a04d0d47..3a41c1ec4 100644 --- a/src/dialogs/swatches.cpp +++ b/src/dialogs/swatches.cpp @@ -113,6 +113,9 @@ void ColorItem::_dragGetColorData( GtkWidget *widget, guint time, gpointer user_data) { + (void)widget; + (void)drag_context; + (void)time; static GdkAtom typeXColor = gdk_atom_intern("application/x-color", FALSE); static GdkAtom typeText = gdk_atom_intern("text/plain", FALSE); @@ -188,6 +191,7 @@ void ColorItem::_dragGetColorData( GtkWidget *widget, static void dragBegin( GtkWidget *widget, GdkDragContext* dc, gpointer data ) { + (void)widget; ColorItem* item = reinterpret_cast(data); if ( item ) { @@ -216,6 +220,7 @@ static void dragBegin( GtkWidget *widget, GdkDragContext* dc, gpointer data ) static gboolean onButtonPressed (GtkWidget *widget, GdkEventButton *event, gpointer userdata) { + (void)widget; /* single click with the right mouse button? */ if(event->type == GDK_BUTTON_RELEASE) { @@ -263,6 +268,11 @@ void ColorItem::_dropDataIn( GtkWidget *widget, guint event_time, gpointer user_data) { + (void)widget; + (void)drag_context; + (void)x; + (void)y; + (void)event_time; // g_message(" droppy droppy %d", info); switch (info) { case APP_X_INKY_COLOR: diff --git a/src/display/nr-arena-glyphs.cpp b/src/display/nr-arena-glyphs.cpp index 3933625c3..243cf6618 100644 --- a/src/display/nr-arena-glyphs.cpp +++ b/src/display/nr-arena-glyphs.cpp @@ -503,11 +503,10 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi // In outline mode, render fill only, using outlinecolor rgba = item->arena->outlinecolor; } else if ( item->render_opacity ) { - rgba = sp_color_get_rgba32_falpha(&style->fill.value.color, - SP_SCALE24_TO_FLOAT(style->fill_opacity.value) * - SP_SCALE24_TO_FLOAT(style->opacity.value)); + rgba = style->fill.value.color.toRGBA32( SP_SCALE24_TO_FLOAT(style->fill_opacity.value) * + SP_SCALE24_TO_FLOAT(style->opacity.value) ); } else { - rgba = sp_color_get_rgba32_falpha(&style->fill.value.color, SP_SCALE24_TO_FLOAT(style->fill_opacity.value)); + rgba = style->fill.value.color.toRGBA32( SP_SCALE24_TO_FLOAT(style->fill_opacity.value) ); } nr_blit_pixblock_mask_rgba32(pb, &m, rgba); pb->empty = FALSE; @@ -528,7 +527,7 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi return (item->state); } - m.visible_area = pb->visible_area; + m.visible_area = pb->visible_area; /* Render children stroke mask */ for (child = group->children; child != NULL; child = child->next) { ret = nr_arena_glyphs_stroke_mask(NR_ARENA_GLYPHS(child), area, &m); @@ -544,12 +543,10 @@ nr_arena_glyphs_group_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPi } } 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)); + rgba = style->stroke.value.color.toRGBA32( 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)); + rgba = style->stroke.value.color.toRGBA32( SP_SCALE24_TO_FLOAT(style->stroke_opacity.value) ); } nr_blit_pixblock_mask_rgba32(pb, &m, rgba); pb->empty = FALSE; diff --git a/src/display/nr-arena-shape.cpp b/src/display/nr-arena-shape.cpp index d245e3928..9150b419f 100644 --- a/src/display/nr-arena-shape.cpp +++ b/src/display/nr-arena-shape.cpp @@ -770,17 +770,15 @@ cairo_arena_shape_render_stroke(NRArenaItem *item, NRRectL *area, NRPixBlock *pb cairo_t *ct = nr_create_cairo_context (area, pb); - if (!ct) + if (!ct) return; guint32 rgba; if ( item->render_opacity ) { - rgba = sp_color_get_rgba32_falpha(&shape->_stroke.paint.color(), - shape->_stroke.opacity * - SP_SCALE24_TO_FLOAT(style->opacity.value)); + rgba = shape->_stroke.paint.color().toRGBA32( shape->_stroke.opacity * + SP_SCALE24_TO_FLOAT(style->opacity.value) ); } else { - rgba = sp_color_get_rgba32_falpha(&shape->_stroke.paint.color(), - shape->_stroke.opacity); + rgba = shape->_stroke.paint.color().toRGBA32( shape->_stroke.opacity ); } // FIXME: we use RGBA buffers but cairo writes BGRA (on i386), so we must cheat @@ -897,7 +895,7 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock return (item->state); } - m.visible_area = pb->visible_area; + m.visible_area = pb->visible_area; nr_pixblock_render_shape_mask_or(m,shape->fill_shp); m.empty = FALSE; @@ -905,12 +903,10 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock // do not render fill in any way } else if (shape->_fill.paint.type() == NRArenaShape::Paint::COLOR) { if ( item->render_opacity ) { - rgba = sp_color_get_rgba32_falpha(&shape->_fill.paint.color(), - shape->_fill.opacity * - SP_SCALE24_TO_FLOAT(style->opacity.value)); + rgba = shape->_fill.paint.color().toRGBA32( shape->_fill.opacity * + SP_SCALE24_TO_FLOAT(style->opacity.value) ); } else { - rgba = sp_color_get_rgba32_falpha(&shape->_fill.paint.color(), - shape->_fill.opacity); + rgba = shape->_fill.paint.color().toRGBA32( shape->_fill.opacity ); } nr_blit_pixblock_mask_rgba32(pb, &m, rgba); pb->empty = FALSE; @@ -938,17 +934,15 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock return (item->state); } - m.visible_area = pb->visible_area; + m.visible_area = pb->visible_area; nr_pixblock_render_shape_mask_or(m, shape->stroke_shp); m.empty = FALSE; if ( item->render_opacity ) { - rgba = sp_color_get_rgba32_falpha(&shape->_stroke.paint.color(), - shape->_stroke.opacity * - SP_SCALE24_TO_FLOAT(style->opacity.value)); + rgba = shape->_stroke.paint.color().toRGBA32( shape->_stroke.opacity * + SP_SCALE24_TO_FLOAT(style->opacity.value) ); } else { - rgba = sp_color_get_rgba32_falpha(&shape->_stroke.paint.color(), - shape->_stroke.opacity); + rgba = shape->_stroke.paint.color().toRGBA32( shape->_stroke.opacity ); } nr_blit_pixblock_mask_rgba32(pb, &m, rgba); pb->empty = FALSE; @@ -992,6 +986,8 @@ nr_arena_shape_render(cairo_t *ct, NRArenaItem *item, NRRectL *area, NRPixBlock // cairo clipping: this basically works except for the stride-must-be-divisible-by-4 cairo bug; // reenable this when the bug is fixed and remove the rest of this function +// TODO +#if defined(DEADCODE) && !defined(DEADCODE) static guint cairo_arena_shape_clip(NRArenaItem *item, NRRectL *area, NRPixBlock *pb) { @@ -1000,7 +996,7 @@ cairo_arena_shape_clip(NRArenaItem *item, NRRectL *area, NRPixBlock *pb) cairo_t *ct = nr_create_cairo_context (area, pb); - if (!ct) + if (!ct) return item->state; cairo_set_source_rgba(ct, 0, 0, 0, 1); @@ -1020,6 +1016,7 @@ cairo_arena_shape_clip(NRArenaItem *item, NRRectL *area, NRPixBlock *pb) return item->state; } +#endif //defined(DEADCODE) && !defined(DEADCODE) static guint diff --git a/src/display/nr-arena-shape.h b/src/display/nr-arena-shape.h index e6484de9f..9b4c846fe 100644 --- a/src/display/nr-arena-shape.h +++ b/src/display/nr-arena-shape.h @@ -38,9 +38,7 @@ struct NRArenaShape : public NRArenaItem { SERVER }; - Paint() : _type(NONE), _server(NULL) { - sp_color_set_rgb_rgba32(&_color, 0); - } + Paint() : _type(NONE), _color(0), _server(NULL) {} Paint(Paint const &p) { _assign(p); } ~Paint() { clear(); } @@ -60,7 +58,7 @@ struct NRArenaShape : public NRArenaItem { void set(SPColor const &color) { clear(); _type = COLOR; - sp_color_copy(&_color, &color); + _color = color; } void set(SPPaintServer *server) { clear(); @@ -86,7 +84,7 @@ struct NRArenaShape : public NRArenaItem { void _assign(Paint const &p) { _type = p._type; _server = p._server; - sp_color_copy(&_color, &p._color); + _color = p._color; if (_server) { sp_object_ref(_server, NULL); } diff --git a/src/display/nr-filter-specularlighting.cpp b/src/display/nr-filter-specularlighting.cpp index 565fa5e05..90d243a6b 100644 --- a/src/display/nr-filter-specularlighting.cpp +++ b/src/display/nr-filter-specularlighting.cpp @@ -47,7 +47,7 @@ FilterSpecularLighting::~FilterSpecularLighting() //Investigating Phong Lighting model we should not take N.H but //R.E which equals to 2*N.H^2 - 1 //replace the second line by -//gdouble scal = scalar_product((N), (H)); scal = 2 * scal * scal - 1;\ +//gdouble scal = scalar_product((N), (H)); scal = 2 * scal * scal - 1; //to get the expected formula #define COMPUTE_INTER(inter, H, N, ks, speculaExponent) \ do {\ diff --git a/src/dom/dom.h b/src/dom/dom.h index 138e735e3..8a11ea0b0 100644 --- a/src/dom/dom.h +++ b/src/dom/dom.h @@ -1846,7 +1846,7 @@ public: virtual bool isDerivedFrom(const DOMString &typeNamespaceArg, const DOMString &typeNameArg, DerivationMethod derivationMethod) - { return false; } + { (void)typeNamespaceArg; (void)typeNameArg; (void)derivationMethod; return false; } //################## //# Non-API methods diff --git a/src/extension/internal/emf-win32-inout.cpp b/src/extension/internal/emf-win32-inout.cpp index 59f538ab9..ecc12b23a 100644 --- a/src/extension/internal/emf-win32-inout.cpp +++ b/src/extension/internal/emf-win32-inout.cpp @@ -332,7 +332,7 @@ select_pen(PEMF_CALLBACK_DATA d, int index) r = SP_COLOR_U_TO_F( GetRValue(pEmr->lopn.lopnColor) ); g = SP_COLOR_U_TO_F( GetGValue(pEmr->lopn.lopnColor) ); b = SP_COLOR_U_TO_F( GetBValue(pEmr->lopn.lopnColor) ); - sp_color_set_rgb_float( &(d->style.stroke.value.color), r,g,b ); + d->style.stroke.value.color.set( r, g, b ); d->style.stroke_linejoin.computed = 1; @@ -420,7 +420,7 @@ select_extpen(PEMF_CALLBACK_DATA d, int index) g = SP_COLOR_U_TO_F( GetGValue(pEmr->elp.elpColor) ); b = SP_COLOR_U_TO_F( GetBValue(pEmr->elp.elpColor) ); - sp_color_set_rgb_float( &(d->style.stroke.value.color), r,g,b ); + d->style.stroke.value.color.( r, g, b ); d->stroke_set = true; } @@ -442,7 +442,7 @@ select_brush(PEMF_CALLBACK_DATA d, int index) r = SP_COLOR_U_TO_F( GetRValue(pEmr->lb.lbColor) ); g = SP_COLOR_U_TO_F( GetGValue(pEmr->lb.lbColor) ); b = SP_COLOR_U_TO_F( GetBValue(pEmr->lb.lbColor) ); - sp_color_set_rgb_float( &(d->style.fill.value.color), r,g,b ); + d->style.fill.value.color.( r, g, b ); } d->fill_set = true; @@ -803,7 +803,7 @@ myEnhMetaFileProc(HDC hDC, HANDLETABLE *lpHTable, ENHMETARECORD *lpEMFR, int nOb val = 255.0 / 255.0; break; } - sp_color_set_rgb_float( &(d->style.fill.value.color), val,val,val ); + d->style.fill.value.color.set( val, val, val ); d->fill_set = true; break; @@ -817,7 +817,7 @@ myEnhMetaFileProc(HDC hDC, HANDLETABLE *lpHTable, ENHMETARECORD *lpEMFR, int nOb float val = index == BLACK_PEN ? 0 : 1; d->style.stroke_dasharray_set = 0; d->style.stroke_width.value = 1.0; - sp_color_set_rgb_float( &(d->style.stroke.value.color), val,val,val ); + d->style.stroke.value.color.set( val, val, val ); d->stroke_set = true; diff --git a/src/extension/internal/odf.cpp b/src/extension/internal/odf.cpp index 61e3e593e..e233515c9 100644 --- a/src/extension/internal/odf.cpp +++ b/src/extension/internal/odf.cpp @@ -1559,8 +1559,7 @@ bool OdfOutput::processStyle(Writer &outs, SPItem *item, //## FILL if (style->fill.isColor()) { - guint32 fillCol = - sp_color_get_rgba32_ualpha(&style->fill.value.color, 0); + guint32 fillCol = style->fill.value.color.toRGBA32( 0 ); char buf[16]; int r = (fillCol >> 24) & 0xff; int g = (fillCol >> 16) & 0xff; @@ -1578,8 +1577,7 @@ bool OdfOutput::processStyle(Writer &outs, SPItem *item, //## STROKE if (style->stroke.isColor()) { - guint32 strokeCol = - sp_color_get_rgba32_ualpha(&style->stroke.value.color, 0); + guint32 strokeCol = style->stroke.value.color.toRGBA32( 0 ); char buf[16]; int r = (strokeCol >> 24) & 0xff; int g = (strokeCol >> 16) & 0xff; diff --git a/src/extension/paramcolor.cpp b/src/extension/paramcolor.cpp index e051fc8dc..d31dc907c 100644 --- a/src/extension/paramcolor.cpp +++ b/src/extension/paramcolor.cpp @@ -86,14 +86,13 @@ ParamColor::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::sign { _changeSignal = new sigc::signal(*changeSignal); Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox(false, 4)); - SPColorSelector* spColorSelector = (SPColorSelector*)sp_color_selector_new(SP_TYPE_COLOR_NOTEBOOK, SP_COLORSPACE_TYPE_RGB); + SPColorSelector* spColorSelector = (SPColorSelector*)sp_color_selector_new(SP_TYPE_COLOR_NOTEBOOK); ColorSelector* colorSelector = spColorSelector->base; if (_value < 1) { _value = 0xFF000000; } - SPColor *color = new SPColor(); - sp_color_set_rgb_rgba32(color, _value); + SPColor *color = new SPColor( _value ); float alpha = (_value & 0xff) / 255.0F; colorSelector->setColorAlpha(*color, alpha); @@ -113,7 +112,7 @@ sp_color_param_changed(SPColorSelector *csel, GObject *obj) float alpha = csel->base->getAlpha(); ParamColor* ptr = (ParamColor*)obj; - ptr->set(sp_color_get_rgba32_falpha(&color, alpha), NULL, NULL); + ptr->set(color.toRGBA32( alpha ), NULL, NULL); ptr->_changeSignal->emit(); } diff --git a/src/extension/prefdialog.cpp b/src/extension/prefdialog.cpp index 3247224eb..9ee9b08cd 100644 --- a/src/extension/prefdialog.cpp +++ b/src/extension/prefdialog.cpp @@ -50,8 +50,8 @@ PrefDialog::PrefDialog (Glib::ustring name, gchar const * help, Gtk::Widget * co _button_pinned(NULL), _param_preview(NULL), _param_pinned(NULL), - _effect(effect), - _signal_param_change(changeSignal) + _signal_param_change(changeSignal), + _effect(effect) { Gtk::HBox * hbox = Gtk::manage(new Gtk::HBox()); hbox->pack_start(*controls, true, true, 6); @@ -156,7 +156,7 @@ PrefDialog::run (void) { void PrefDialog::setPreviewState (Glib::ustring state) { - + (void)state; } void diff --git a/src/forward.h b/src/forward.h index ef05ea026..0cab048e0 100644 --- a/src/forward.h +++ b/src/forward.h @@ -157,7 +157,6 @@ class SPAnchorClass; class ColorRGBA; -class SPColorSpace; class SPColor; class SPStyle; diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index 0690ef140..d3b8f7911 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -1230,7 +1230,7 @@ sp_gradient_vector_for_object(SPDocument *const doc, SPDesktop *const desktop, rgba = sp_desktop_get_color(desktop, is_fill); } } else if (paint.isColor()) { - rgba = sp_color_get_rgba32_ualpha(&paint.value.color, 0xff); + rgba = paint.value.color.toRGBA32( 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/helper-fns.h b/src/helper-fns.h index 4e51c9a16..b4976bad4 100644 --- a/src/helper-fns.h +++ b/src/helper-fns.h @@ -15,8 +15,7 @@ #include -static double -helperfns_read_number(gchar const *value) { +inline double helperfns_read_number(gchar const *value) { if (!value) return 0; char *end; double ret = g_ascii_strtod(value, &end); @@ -29,7 +28,7 @@ helperfns_read_number(gchar const *value) { return ret; } -static bool helperfns_read_bool(gchar const *value, bool default_value){ +inline bool helperfns_read_bool(gchar const *value, bool default_value){ if (!value) return default_value; switch(value[0]){ case 't': @@ -42,7 +41,7 @@ static bool helperfns_read_bool(gchar const *value, bool default_value){ return default_value; } -static std::vector helperfns_read_vector(const gchar* value, int size){ +inline std::vector helperfns_read_vector(const gchar* value, int size){ std::vector v(size, (gdouble) 0); std::istringstream is(value); for(int i = 0; i < size && (is >> v[i]); i++); diff --git a/src/live_effects/parameter/bool.cpp b/src/live_effects/parameter/bool.cpp index f0d409955..36806242f 100644 --- a/src/live_effects/parameter/bool.cpp +++ b/src/live_effects/parameter/bool.cpp @@ -26,7 +26,7 @@ namespace LivePathEffect { BoolParam::BoolParam( const Glib::ustring& label, const Glib::ustring& tip, const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr, Effect* effect, bool default_value ) - : Parameter(label, tip, key, wr, effect), defvalue(default_value), value(default_value) + : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value) { checkwdg = NULL; } diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 8a3eded40..d86e3b0e3 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -104,7 +104,7 @@ sp_stop_init(SPStop *stop) { stop->offset = 0.0; stop->currentColor = false; - sp_color_set_rgb_rgba32(&stop->specified_color, 0x000000ff); + stop->specified_color.set( 0x000000ff ); stop->opacity = 1.0; } @@ -148,7 +148,7 @@ sp_stop_set(SPObject *object, unsigned key, gchar const *value) stop->currentColor = true; } else { guint32 const color = sp_svg_read_color(p, 0); - sp_color_set_rgb_rgba32(&stop->specified_color, color); + stop->specified_color.set( color ); } } { @@ -167,7 +167,7 @@ sp_stop_set(SPObject *object, unsigned key, gchar const *value) } else { stop->currentColor = false; guint32 const color = sp_svg_read_color(p, 0); - sp_color_set_rgb_rgba32(&stop->specified_color, color); + stop->specified_color.set( color ); } } object->requestModified(SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_STYLE_MODIFIED_FLAG); @@ -208,7 +208,7 @@ sp_stop_write(SPObject *object, Inkscape::XML::Node *repr, guint flags) repr = xml_doc->createElement("svg:stop"); } - guint32 specifiedcolor = sp_color_get_rgba32_ualpha(&stop->specified_color, 255); + guint32 specifiedcolor = stop->specified_color.toRGBA32( 255 ); gfloat opacity = stop->opacity; if (((SPObjectClass *) stop_parent_class)->write) @@ -258,7 +258,7 @@ sp_stop_get_rgba32(SPStop const *const stop) rgb0 | 0xff); return rgb0 | alpha; } else { - return sp_color_get_rgba32_falpha(&stop->specified_color, stop->opacity); + return stop->specified_color.toRGBA32( stop->opacity ); } } @@ -278,8 +278,7 @@ sp_stop_get_color(SPStop const *const stop) if (str) { color = sp_svg_read_color(str, dfl); } - SPColor ret; - sp_color_set_rgb_rgba32(&ret, color); + SPColor ret( color ); return ret; } else { return stop->specified_color; @@ -918,7 +917,7 @@ sp_gradient_repr_write_vector(SPGradient *gr) /* strictly speaking, offset an SVG rather than a CSS one, but exponents make no * sense for offset proportions. */ gchar c[64]; - sp_svg_write_color(c, 64, sp_color_get_rgba32_ualpha(&gr->vector.stops[i].color, 0x00)); + sp_svg_write_color(c, 64, gr->vector.stops[i].color.toRGBA32( 0x00 )); os << "stop-color:" << c << ";stop-opacity:" << gr->vector.stops[i].opacity; child->setAttribute("style", os.str().c_str()); /* Order will be reversed here */ @@ -1034,14 +1033,14 @@ sp_gradient_rebuild_vector(SPGradient *gr) { SPGradientStop gstop; gstop.offset = 0.0; - sp_color_set_rgb_rgba32(&gstop.color, 0x00000000); + gstop.color.set( 0x00000000 ); gstop.opacity = 0.0; gr->vector.stops.push_back(gstop); } { SPGradientStop gstop; gstop.offset = 1.0; - sp_color_set_rgb_rgba32(&gstop.color, 0x00000000); + gstop.color.set( 0x00000000 ); gstop.opacity = 0.0; gr->vector.stops.push_back(gstop); } @@ -1053,7 +1052,7 @@ sp_gradient_rebuild_vector(SPGradient *gr) // If the first one is not at 0, then insert a copy of the first at 0. SPGradientStop gstop; gstop.offset = 0.0; - sp_color_copy(&gstop.color, &gr->vector.stops.front().color); + gstop.color = gr->vector.stops.front().color; gstop.opacity = gr->vector.stops.front().opacity; gr->vector.stops.insert(gr->vector.stops.begin(), gstop); } @@ -1061,7 +1060,7 @@ sp_gradient_rebuild_vector(SPGradient *gr) // If the last one is not at 1, then insert a copy of the last at 1. SPGradientStop gstop; gstop.offset = 1.0; - sp_color_copy(&gstop.color, &gr->vector.stops.back().color); + gstop.color = gr->vector.stops.back().color; gstop.opacity = gr->vector.stops.back().opacity; gr->vector.stops.push_back(gstop); } @@ -1087,14 +1086,12 @@ sp_gradient_ensure_colors(SPGradient *gr) } for (guint i = 0; i < gr->vector.stops.size() - 1; i++) { - guint32 color = sp_color_get_rgba32_falpha(&gr->vector.stops[i].color, - gr->vector.stops[i].opacity); + guint32 color = gr->vector.stops[i].color.toRGBA32( gr->vector.stops[i].opacity ); gint r0 = (color >> 24) & 0xff; gint g0 = (color >> 16) & 0xff; gint b0 = (color >> 8) & 0xff; gint a0 = color & 0xff; - color = sp_color_get_rgba32_falpha(&gr->vector.stops[i + 1].color, - gr->vector.stops[i + 1].opacity); + color = gr->vector.stops[i + 1].color.toRGBA32( gr->vector.stops[i + 1].opacity ); gint r1 = (color >> 24) & 0xff; gint g1 = (color >> 16) & 0xff; gint b1 = (color >> 8) & 0xff; diff --git a/src/sp-object.h b/src/sp-object.h index b563d8d3b..3c938e8a1 100644 --- a/src/sp-object.h +++ b/src/sp-object.h @@ -242,12 +242,12 @@ struct SPObject : public GObject { /** Retrieves the title of this object */ gchar const *title() const { return NULL; /* TODO */ } /** Sets the title of this object */ - void setTitle(gchar const *title) { /* TODO */ } + void setTitle(gchar const *title) { (void)title; /* TODO */ } /** Retrieves the description of this object */ gchar const *desc() const { return NULL; /* TODO */ } /** Sets the description of this object */ - void setDesc(gchar const *desc) { /* TODO */ } + void setDesc(gchar const *desc) { (void)desc; /* TODO */ } /** @brief Set the policy under which this object will be * orphan-collected. diff --git a/src/style.cpp b/src/style.cpp index 70e294848..b817ce083 100644 --- a/src/style.cpp +++ b/src/style.cpp @@ -3521,7 +3521,7 @@ sp_paint_differ(SPIPaint const *const a, SPIPaint const *const b) } if ( a->isColor() ) { - return !(sp_color_is_equal(&a->value.color, &b->value.color) + return !( (a->value.color == b->value.color) && ((a->value.iccColor == b->value.iccColor) || (a->value.iccColor && b->value.iccColor && (a->value.iccColor->colorProfile == b->value.iccColor->colorProfile) @@ -3578,7 +3578,7 @@ sp_style_write_ipaint(gchar *b, gint const len, gchar const *const key, css << " "; } char color_buf[8]; - sp_svg_write_color(color_buf, sizeof(color_buf), sp_color_get_rgba32_ualpha(&paint->value.color, 0)); + sp_svg_write_color(color_buf, sizeof(color_buf), paint->value.color.toRGBA32( 0 )); css << color_buf; } @@ -3691,7 +3691,7 @@ void SPIPaint::clear() currentcolor = false; colorSet = false; noneSet = false; - sp_color_set_rgb_rgba32( &value.color, 0 ); + value.color.set( 0 ); if ( value.href && value.href->getObject() ) { value.href->detach(); diff --git a/src/style.h b/src/style.h index 623291941..9b2d2878a 100644 --- a/src/style.h +++ b/src/style.h @@ -171,8 +171,8 @@ struct SPIPaint { 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( float r, float g, float b ) {value.color.set( r, g, b ); colorSet = true;} + void setColor( guint32 val ) {value.color.set( val ); colorSet = true;} void setColor( SPColor const& color ) {value.color = color; colorSet = true;} }; diff --git a/src/ui/widget/color-picker.cpp b/src/ui/widget/color-picker.cpp index 7d7dc9117..d6ae50ae3 100644 --- a/src/ui/widget/color-picker.cpp +++ b/src/ui/widget/color-picker.cpp @@ -57,8 +57,7 @@ ColorPicker::setupDialog(const Glib::ustring &title) _colorSelectorDialog.hide(); _colorSelectorDialog.set_title (title); _colorSelectorDialog.set_border_width (4); - _colorSelector = (SPColorSelector*)sp_color_selector_new(SP_TYPE_COLOR_NOTEBOOK, - SP_COLORSPACE_TYPE_UNKNOWN); + _colorSelector = (SPColorSelector*)sp_color_selector_new(SP_TYPE_COLOR_NOTEBOOK); _colorSelectorDialog.get_vbox()->pack_start ( *Glib::wrap(&_colorSelector->vbox), true, true, 0); @@ -86,7 +85,7 @@ ColorPicker::setRgba32 (guint32 rgba) if (_colorSelector) { SPColor color; - sp_color_set_rgb_rgba32(&color, rgba); + color.set( rgba ); _colorSelector->base->setColorAlpha(color, SP_RGBA32_A_F(rgba)); } } @@ -103,7 +102,7 @@ ColorPicker::on_clicked() if (_colorSelector) { SPColor color; - sp_color_set_rgb_rgba32(&color, _rgba); + color.set( _rgba ); _colorSelector->base->setColorAlpha(color, SP_RGBA32_A_F(_rgba)); } _colorSelectorDialog.show(); @@ -119,18 +118,18 @@ sp_color_picker_color_mod(SPColorSelector *csel, GObject *cp) { if (_in_use) return; else _in_use = true; - + SPColor color; float alpha; csel->base->getColorAlpha(color, &alpha); - guint32 rgba = sp_color_get_rgba32_falpha(&color, alpha); + guint32 rgba = color.toRGBA32( alpha ); ColorPicker *ptr = (ColorPicker *)(cp); (ptr->_preview).setRgba32 (rgba); if (ptr->_undo && SP_ACTIVE_DESKTOP) - sp_document_done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_NONE, + sp_document_done(sp_desktop_document(SP_ACTIVE_DESKTOP), SP_VERB_NONE, /* TODO: annotate */ "color-picker.cpp:130"); ptr->on_changed (rgba); diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 763913b27..aaf5fc35c 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -946,7 +946,7 @@ SelectedStyle::update() 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), + guint32 color = paint->value.color.toRGBA32( 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 diff --git a/src/ui/widget/style-swatch.cpp b/src/ui/widget/style-swatch.cpp index 4d5a7fc12..df543c8d3 100644 --- a/src/ui/widget/style-swatch.cpp +++ b/src/ui/widget/style-swatch.cpp @@ -307,8 +307,7 @@ StyleSwatch::setStyle(SPStyle *query) } } 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)); + guint32 color = paint->value.color.toRGBA32( 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]); diff --git a/src/uri-references.h b/src/uri-references.h index 3955d5f00..1d2a3310f 100644 --- a/src/uri-references.h +++ b/src/uri-references.h @@ -118,7 +118,7 @@ public: SPObject *getOwnerObject() {return _owner;} protected: - virtual bool _acceptObject(SPObject *obj) const { return true; } + virtual bool _acceptObject(SPObject *obj) const { (void)obj; return true; } private: SPObject *_owner; diff --git a/src/widgets/gradient-vector.cpp b/src/widgets/gradient-vector.cpp index f1c4e3500..f7a22cc43 100644 --- a/src/widgets/gradient-vector.cpp +++ b/src/widgets/gradient-vector.cpp @@ -595,8 +595,7 @@ sp_grad_edit_select (GtkOptionMenu *mnu, GtkWidget *tbl) SPColorSelector *csel = (SPColorSelector*)g_object_get_data (G_OBJECT (tbl), "cselector"); guint32 const c = sp_stop_get_rgba32(stop); csel->base->setAlpha(SP_RGBA32_A_F (c)); - SPColor color; - sp_color_set_rgb_float (&color, SP_RGBA32_R_F (c), SP_RGBA32_G_F (c), SP_RGBA32_B_F (c)); + SPColor color( SP_RGBA32_R_F (c), SP_RGBA32_G_F (c), SP_RGBA32_B_F (c) ); // set its color, from the stored array csel->base->setColor( color ); GtkWidget *offspin = GTK_WIDGET (g_object_get_data (G_OBJECT (tbl), "offspn")); @@ -868,7 +867,7 @@ sp_gradient_vector_widget_new (SPGradient *gradient, SPStop *select_stop) f = gtk_frame_new (_("Stop Color")); gtk_widget_show (f); gtk_box_pack_start (GTK_BOX (vb), f, TRUE, TRUE, PAD); - csel = (GtkWidget*)sp_color_selector_new (SP_TYPE_COLOR_NOTEBOOK, SP_COLORSPACE_TYPE_NONE); + csel = (GtkWidget*)sp_color_selector_new (SP_TYPE_COLOR_NOTEBOOK); g_object_set_data (G_OBJECT (vb), "cselector", csel); gtk_widget_show (csel); gtk_container_add (GTK_CONTAINER (f), csel); @@ -1014,8 +1013,7 @@ sp_gradient_vector_widget_load_gradient (GtkWidget *widget, SPGradient *gradient SPColorSelector *csel = SP_COLOR_SELECTOR(g_object_get_data (G_OBJECT (widget), "cselector")); // set alpha csel->base->setAlpha(SP_RGBA32_A_F (c)); - SPColor color; - sp_color_set_rgb_float (&color, SP_RGBA32_R_F (c), SP_RGBA32_G_F (c), SP_RGBA32_B_F (c)); + SPColor color( SP_RGBA32_R_F (c), SP_RGBA32_G_F (c), SP_RGBA32_B_F (c) ); // set color csel->base->setColor( color ); } @@ -1158,7 +1156,7 @@ sp_gradient_vector_color_changed (SPColorSelector *csel, GtkObject *object) csel = (SPColorSelector*)g_object_get_data (G_OBJECT (object), "cselector"); csel->base->getColorAlpha( color, &alpha ); - rgb = sp_color_get_rgba32_ualpha (&color, 0x00); + rgb = color.toRGBA32( 0x00 ); sp_repr_set_css_double (SP_OBJECT_REPR (stop), "offset", stop->offset); Inkscape::CSSOStringStream os; diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index b16a62168..3c103afb0 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -213,7 +213,7 @@ sp_paint_selector_init(SPPaintSelector *psel) gtk_box_pack_start(GTK_BOX(psel), psel->frame, TRUE, TRUE, 0); /* Last used color */ - sp_color_set_rgb_float(&psel->color, 0.0, 0.0, 0.0); + psel->color.set( 0.0, 0.0, 0.0 ); psel->alpha = 1.0; } @@ -363,6 +363,7 @@ sp_paint_selector_set_color_alpha(SPPaintSelector *psel, SPColor const *color, f SPColorSelector *csel; guint32 rgba; +/* if ( sp_color_get_colorspace_type(color) == SP_COLORSPACE_TYPE_CMYK ) { #ifdef SP_PS_VERBOSE @@ -371,6 +372,7 @@ sp_paint_selector_set_color_alpha(SPPaintSelector *psel, SPColor const *color, f sp_paint_selector_set_mode(psel, SP_PAINT_SELECTOR_MODE_COLOR_CMYK); } else +*/ { #ifdef SP_PS_VERBOSE g_print("PaintSelector set RGBA\n"); @@ -379,7 +381,7 @@ sp_paint_selector_set_color_alpha(SPPaintSelector *psel, SPColor const *color, f } csel = (SPColorSelector*)gtk_object_get_data(GTK_OBJECT(psel->selector), "color-selector"); - rgba = sp_color_get_rgba32_falpha( &*color, alpha ); + rgba = color->toRGBA32( alpha ); csel->base->setColorAlpha( *color, alpha ); } @@ -597,7 +599,7 @@ sp_paint_selector_set_mode_color(SPPaintSelector *psel, SPPaintSelectorMode mode gtk_widget_show(vb); /* Color selector */ - csel = sp_color_selector_new(SP_TYPE_COLOR_NOTEBOOK, SP_COLORSPACE_TYPE_NONE); + csel = sp_color_selector_new( SP_TYPE_COLOR_NOTEBOOK ); gtk_widget_show(csel); gtk_object_set_data(GTK_OBJECT(vb), "color-selector", csel); gtk_box_pack_start(GTK_BOX(vb), csel, TRUE, TRUE, 0); @@ -902,7 +904,7 @@ sp_paint_selector_set_flat_color(SPPaintSelector *psel, SPDesktop *desktop, gcha SPColor color; gfloat alpha; sp_paint_selector_get_color_alpha(psel, &color, &alpha); - guint32 rgba = sp_color_get_rgba32_falpha(&color, alpha); + guint32 rgba = color.toRGBA32( alpha ); gchar b[64]; sp_svg_write_color(b, 64, rgba); diff --git a/src/widgets/sp-color-gtkselector.cpp b/src/widgets/sp-color-gtkselector.cpp index 3c0ec17c6..b583903e3 100644 --- a/src/widgets/sp-color-gtkselector.cpp +++ b/src/widgets/sp-color-gtkselector.cpp @@ -109,7 +109,7 @@ sp_color_gtkselector_hide_all (GtkWidget *widget) } GtkWidget * -sp_color_gtkselector_new (GType, SPColorSpaceType colorspace) +sp_color_gtkselector_new( GType ) { SPColorGtkselector *csel; @@ -136,7 +136,7 @@ void ColorGtkselector::_colorChanged( const SPColor& color, gfloat alpha ) g_return_if_fail (SP_IS_COLOR_GTKSELECTOR (_csel)); g_return_if_fail( ( 0.0 <= alpha ) && ( alpha <= 1.0 ) ); - sp_color_copy (&_color, &color); + _color = color; _alpha = alpha; sp_color_get_rgb_floatv( &color, rgb ); @@ -154,17 +154,15 @@ void ColorGtkselector::_colorChanged( const SPColor& color, gfloat alpha ) void ColorGtkselector::_gtkChanged( GtkColorSelection *colorselection, SPColorGtkselector *gtksel ) { - ColorGtkselector* gtkInst = (ColorGtkselector*)(SP_COLOR_SELECTOR(gtksel)->base); - SPColor ourColor; GdkColor color; - guint16 alpha; - gtk_color_selection_get_current_color (colorselection, &color); - alpha = gtk_color_selection_get_current_alpha (colorselection); - sp_color_set_rgb_float (&ourColor, (color.red / 65535.0), (color.green / 65535.0), (color.blue / 65535.0)); + guint16 alpha = gtk_color_selection_get_current_alpha (colorselection); + + SPColor ourColor( (color.red / 65535.0), (color.green / 65535.0), (color.blue / 65535.0) ); // g_message( "***** _gtkChanged %04x %04x %04x", color.red, color.green, color.blue ); + ColorGtkselector* gtkInst = (ColorGtkselector*)(SP_COLOR_SELECTOR(gtksel)->base); gtkInst->_updateInternals( ourColor, static_cast< gfloat > (alpha) / 65535.0, gtk_color_selection_is_adjusting(colorselection) ); } diff --git a/src/widgets/sp-color-gtkselector.h b/src/widgets/sp-color-gtkselector.h index e3b780f25..75a28ee1a 100644 --- a/src/widgets/sp-color-gtkselector.h +++ b/src/widgets/sp-color-gtkselector.h @@ -48,7 +48,7 @@ struct SPColorGtkselectorClass { GType sp_color_gtkselector_get_type (void); -GtkWidget *sp_color_gtkselector_new (GType selector_type, SPColorSpaceType colorspace); +GtkWidget *sp_color_gtkselector_new( GType selector_type ); diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index c14d89f11..60617b849 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -437,29 +437,25 @@ void ColorNotebook::_rgbaEntryChangedHook(GtkEntry *entry, SPColorNotebook *colo void ColorNotebook::_rgbaEntryChanged(GtkEntry* entry) { - const gchar *t; - gchar *e; - SPColor color; - guint rgba; - - if (_updating) return; - if (_updatingrgba) return; - - t = gtk_entry_get_text (entry); - - if (t) { - rgba = strtoul (t, &e, 16); - if ( e != t ) { - ptrdiff_t len=e-t; - if ( len < 8 ) { - rgba = rgba << ( 4 * ( 8 - len ) ); - } - _updatingrgba = TRUE; - sp_color_set_rgb_rgba32 (&color, rgba); - setColorAlpha( color, SP_RGBA32_A_F(rgba), true); - _updatingrgba = FALSE; - } - } + if (_updating) return; + if (_updatingrgba) return; + + const gchar *t = gtk_entry_get_text( entry ); + + if (t) { + gchar *e = 0; + guint rgba = strtoul (t, &e, 16); + if ( e != t ) { + ptrdiff_t len=e-t; + if ( len < 8 ) { + rgba = rgba << ( 4 * ( 8 - len ) ); + } + _updatingrgba = TRUE; + SPColor color( rgba ); + setColorAlpha( color, SP_RGBA32_A_F(rgba), true ); + _updatingrgba = FALSE; + } + } } void ColorNotebook::_updateRgbaEntry( const SPColor& color, gfloat alpha ) @@ -472,7 +468,7 @@ void ColorNotebook::_updateRgbaEntry( const SPColor& color, gfloat alpha ) guint32 rgba; /* Update RGBA entry */ - rgba = sp_color_get_rgba32_falpha (&color, alpha); + rgba = color.toRGBA32( alpha ); g_snprintf (s, 32, "%08x", rgba); const gchar* oldText = gtk_entry_get_text( GTK_ENTRY( _rgbae ) ); @@ -543,7 +539,7 @@ GtkWidget* ColorNotebook::addPage(GType page_type, guint submode) { GtkWidget *page; - page = sp_color_selector_new ( page_type, SP_COLORSPACE_TYPE_NONE); + page = sp_color_selector_new( page_type ); if ( page ) { GtkWidget* tab_label = 0; diff --git a/src/widgets/sp-color-scales.cpp b/src/widgets/sp-color-scales.cpp index 8acd96bbb..4a232c82c 100644 --- a/src/widgets/sp-color-scales.cpp +++ b/src/widgets/sp-color-scales.cpp @@ -101,9 +101,7 @@ ColorScales::ColorScales( SPColorSelector* csel ) _updating( FALSE ), _dragging( FALSE ) { - gint i = 0; - - for (i = 0; i < 5; i++) { + for (gint i = 0; i < 5; i++) { _l[i] = 0; _a[i] = 0; _s[i] = 0; @@ -113,9 +111,7 @@ ColorScales::ColorScales( SPColorSelector* csel ) ColorScales::~ColorScales() { - gint i = 0; - - for (i = 0; i < 5; i++) { + for (gint i = 0; i < 5; i++) { _l[i] = 0; _a[i] = 0; _s[i] = 0; @@ -226,14 +222,19 @@ void ColorScales::_recalcColor( gboolean changing ) case SP_COLOR_SCALES_MODE_RGB: case SP_COLOR_SCALES_MODE_HSV: _getRgbaFloatv(c); - sp_color_set_rgb_float (&color, c[0], c[1], c[2]); + color.set( c[0], c[1], c[2] ); alpha = c[3]; break; case SP_COLOR_SCALES_MODE_CMYK: + { _getCmykaFloatv( c ); - sp_color_set_cmyk_float (&color, c[0], c[1], c[2], c[3]); + + float rgb[3]; + sp_color_cmyk_to_rgb_floatv( rgb, c[0], c[1], c[2], c[3] ); + color.set( rgb[0], rgb[1], rgb[2] ); alpha = c[4]; break; + } default: g_warning ("file %s: line %d: Illegal color selector mode %d", __FILE__, __LINE__, _mode); break; @@ -270,6 +271,9 @@ void ColorScales::_setRangeLimit( gdouble upper ) void ColorScales::_colorChanged( const SPColor& color, gfloat alpha ) { +#ifdef DUMP_CHANGE_INFO + g_message("ColorScales::_colorChanged( this=%p, %f, %f, %f, %f)", this, color.v.c[0], color.v.c[1], color.v.c[2], alpha ); +#endif gfloat tmp[3]; gfloat c[5] = {0.0, 0.0, 0.0, 0.0}; @@ -541,6 +545,7 @@ void ColorScales::_adjustmentAnyChanged( GtkAdjustment *adjustment, SPColorScale void ColorScales::_sliderAnyGrabbed( SPColorSlider *slider, SPColorScales *cs ) { + (void)slider; ColorScales* scales = (ColorScales*)(SP_COLOR_SELECTOR(cs)->base); if (!scales->_dragging) { scales->_dragging = TRUE; @@ -551,6 +556,7 @@ void ColorScales::_sliderAnyGrabbed( SPColorSlider *slider, SPColorScales *cs ) void ColorScales::_sliderAnyReleased( SPColorSlider *slider, SPColorScales *cs ) { + (void)slider; ColorScales* scales = (ColorScales*)(SP_COLOR_SELECTOR(cs)->base); if (scales->_dragging) { scales->_dragging = FALSE; @@ -561,6 +567,7 @@ void ColorScales::_sliderAnyReleased( SPColorSlider *slider, SPColorScales *cs ) void ColorScales::_sliderAnyChanged( SPColorSlider *slider, SPColorScales *cs ) { + (void)slider; ColorScales* scales = (ColorScales*)(SP_COLOR_SELECTOR(cs)->base); scales->_recalcColor( TRUE ); diff --git a/src/widgets/sp-color-selector.cpp b/src/widgets/sp-color-selector.cpp index 1532eddd7..ec80eff3e 100644 --- a/src/widgets/sp-color-selector.cpp +++ b/src/widgets/sp-color-selector.cpp @@ -142,7 +142,7 @@ sp_color_selector_hide_all (GtkWidget *widget) } GtkWidget * -sp_color_selector_new (GType selector_type, SPColorSpaceType colorspace) +sp_color_selector_new( GType selector_type ) { SPColorSelector *csel; g_return_val_if_fail (g_type_is_a (selector_type, SP_TYPE_COLOR_SELECTOR), NULL); @@ -156,6 +156,7 @@ double ColorSelector::_epsilon = 1e-4; void ColorSelector::setSubmode( guint submode ) { + (void)submode; } guint ColorSelector::getSubmode() const @@ -164,26 +165,13 @@ guint ColorSelector::getSubmode() const return mode; } -SPColorSpaceType ColorSelector::getColorspace() const -{ - SPColorSpaceType type = SP_COLORSPACE_TYPE_UNKNOWN; - - return type; -} - -gboolean ColorSelector::setColorspace( SPColorSpaceType colorspace ) -{ - return false; -} - ColorSelector::ColorSelector( SPColorSelector* csel ) : _csel(csel), + _color( 0 ), _alpha(1.0), - _held(FALSE) + _held(FALSE), + virgin(true) { - sp_color_set_rgb_rgba32( &_color, 0 ); - - virgin = true; } ColorSelector::~ColorSelector() @@ -222,19 +210,35 @@ downstream, e.g. the RGBA value field, but not from the rest of the program) */ void ColorSelector::setColorAlpha( const SPColor& color, gfloat alpha, bool emit ) { +#ifdef DUMP_CHANGE_INFO + g_message("ColorSelector::setColorAlpha( this=%p, %f, %f, %f, %f, %s)", this, color.v.c[0], color.v.c[1], color.v.c[2], alpha, (emit?"YES":"no")); +#endif g_return_if_fail( ( 0.0 <= alpha ) && ( alpha <= 1.0 ) ); - if ( virgin || !sp_color_is_close( &color, &_color, _epsilon ) || +#ifdef DUMP_CHANGE_INFO + g_message("---- ColorSelector::setColorAlpha virgin:%s !close:%s alpha is:%s", + (virgin?"YES":"no"), + (!color.isClose( _color, _epsilon )?"YES":"no"), + ((fabs ((_alpha) - (alpha)) >= _epsilon )?"YES":"no") + ); +#endif + + if ( virgin || !color.isClose( _color, _epsilon ) || (fabs ((_alpha) - (alpha)) >= _epsilon )) { virgin = false; - sp_color_copy (&_color, &color); + _color = color; _alpha = alpha; _colorChanged( color, alpha ); if (emit) gtk_signal_emit (GTK_OBJECT (_csel), csel_signals[CHANGED]); +#ifdef DUMP_CHANGE_INFO + } else { + g_message("++++ ColorSelector::setColorAlpha color:%08x ==> _color:%08X isClose", color.toRGBA32(alpha), _color.toRGBA32(_alpha), + (color.isClose( _color, _epsilon )?"YES":"no")); +#endif } } @@ -265,7 +269,7 @@ void ColorSelector::_released() void ColorSelector::_updateInternals( const SPColor& color, gfloat alpha, gboolean held ) { g_return_if_fail( ( 0.0 <= alpha ) && ( alpha <= 1.0 ) ); - gboolean colorDifferent = ( !sp_color_is_close( &color, &_color, _epsilon ) + gboolean colorDifferent = ( !color.isClose( _color, _epsilon ) || ( fabs((_alpha) - (alpha)) >= _epsilon ) ); gboolean grabbed = held && !_held; @@ -275,7 +279,7 @@ void ColorSelector::_updateInternals( const SPColor& color, gfloat alpha, gboole _held = held; if ( colorDifferent ) { - sp_color_copy (&_color, &color); + _color = color; _alpha = alpha; } @@ -284,7 +288,7 @@ void ColorSelector::_updateInternals( const SPColor& color, gfloat alpha, gboole #ifdef DUMP_CHANGE_INFO g_message ("%s:%d: About to signal %s to color %08x in %s", __FILE__, __LINE__, "GRABBED", - sp_color_get_rgba32_falpha(&color,alpha), FOO_NAME(_csel)); + color.toRGBA32( alpha ), FOO_NAME(_csel)); #endif gtk_signal_emit (GTK_OBJECT (_csel), csel_signals[GRABBED]); } @@ -293,7 +297,7 @@ void ColorSelector::_updateInternals( const SPColor& color, gfloat alpha, gboole #ifdef DUMP_CHANGE_INFO g_message ("%s:%d: About to signal %s to color %08x in %s", __FILE__, __LINE__, "RELEASED", - sp_color_get_rgba32_falpha(&color,alpha), FOO_NAME(_csel)); + color.toRGBA32( alpha ), FOO_NAME(_csel)); #endif gtk_signal_emit (GTK_OBJECT (_csel), csel_signals[RELEASED]); } @@ -303,7 +307,7 @@ void ColorSelector::_updateInternals( const SPColor& color, gfloat alpha, gboole #ifdef DUMP_CHANGE_INFO g_message ("%s:%d: About to signal %s to color %08x in %s", __FILE__, __LINE__, (_held ? "CHANGED" : "DRAGGED" ), - sp_color_get_rgba32_falpha(&color,alpha), FOO_NAME(_csel)); + color.toRGBA32( alpha ), FOO_NAME(_csel)); #endif gtk_signal_emit (GTK_OBJECT (_csel), csel_signals[_held ? CHANGED : DRAGGED]); } @@ -311,23 +315,21 @@ void ColorSelector::_updateInternals( const SPColor& color, gfloat alpha, gboole void ColorSelector::_colorChanged( const SPColor& color, gfloat alpha ) { + (void)color; + (void)alpha; } void ColorSelector::getColorAlpha( SPColor& color, gfloat* alpha ) const { gint i = 0; - sp_color_copy (&color, &_color); + color = _color; if ( alpha ) { *alpha = _alpha; } // Try to catch uninitialized value usage - if ( color.colorspace ) - { - i++; - } if ( color.v.c[0] ) { i++; diff --git a/src/widgets/sp-color-selector.h b/src/widgets/sp-color-selector.h index b2fd62b1e..43090b158 100644 --- a/src/widgets/sp-color-selector.h +++ b/src/widgets/sp-color-selector.h @@ -31,9 +31,6 @@ public: virtual void setSubmode( guint submode ); virtual guint getSubmode() const; - virtual SPColorSpaceType getColorspace() const; - virtual gboolean setColorspace( SPColorSpaceType colorspace ); - protected: void _grabbed(); void _released(); @@ -88,7 +85,7 @@ struct SPColorSelectorClass { GType sp_color_selector_get_type (void); -GtkWidget *sp_color_selector_new (GType selector_type, SPColorSpaceType colorspace); +GtkWidget *sp_color_selector_new( GType selector_type ); diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index 584a75dd0..854f6303d 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -207,12 +207,15 @@ sp_color_wheel_selector_new (void) void ColorWheelSelector::_colorChanged( const SPColor& color, gfloat alpha ) { +#ifdef DUMP_CHANGE_INFO + g_message("ColorWheelSelector::_colorChanged( this=%p, %f, %f, %f, %f)", this, color.v.c[0], color.v.c[1], color.v.c[2], alpha ); +#endif _updating = TRUE; sp_color_wheel_set_color( SP_COLOR_WHEEL( _wheel ), &color ); - guint32 start = sp_color_get_rgba32_ualpha( &color, 0x00 ); - guint32 mid = sp_color_get_rgba32_ualpha( &color, 0x7f ); - guint32 end = sp_color_get_rgba32_ualpha( &color, 0xff ); + guint32 start = color.toRGBA32( 0x00 ); + guint32 mid = color.toRGBA32( 0x7f ); + guint32 end = color.toRGBA32( 0xff ); sp_color_slider_set_colors (SP_COLOR_SLIDER(_slider), start, mid, end); @@ -241,6 +244,7 @@ void ColorWheelSelector::_adjustmentChanged( GtkAdjustment *adjustment, SPColorW void ColorWheelSelector::_sliderGrabbed( SPColorSlider *slider, SPColorWheelSelector *cs ) { + (void)slider; ColorWheelSelector* wheelSelector = (ColorWheelSelector*)(SP_COLOR_SELECTOR(cs)->base); if (!wheelSelector->_dragging) { wheelSelector->_dragging = TRUE; @@ -251,6 +255,7 @@ void ColorWheelSelector::_sliderGrabbed( SPColorSlider *slider, SPColorWheelSele void ColorWheelSelector::_sliderReleased( SPColorSlider *slider, SPColorWheelSelector *cs ) { + (void)slider; ColorWheelSelector* wheelSelector = (ColorWheelSelector*)(SP_COLOR_SELECTOR(cs)->base); if (wheelSelector->_dragging) { wheelSelector->_dragging = FALSE; @@ -261,6 +266,7 @@ void ColorWheelSelector::_sliderReleased( SPColorSlider *slider, SPColorWheelSel void ColorWheelSelector::_sliderChanged( SPColorSlider *slider, SPColorWheelSelector *cs ) { + (void)slider; ColorWheelSelector* wheelSelector = (ColorWheelSelector*)(SP_COLOR_SELECTOR(cs)->base); wheelSelector->_updateInternals( wheelSelector->_color, ColorScales::getScaled( wheelSelector->_adj ), wheelSelector->_dragging ); @@ -273,9 +279,9 @@ void ColorWheelSelector::_wheelChanged( SPColorWheel *wheel, SPColorWheelSelecto sp_color_wheel_get_color( wheel, &color ); - guint32 start = sp_color_get_rgba32_ualpha( &color, 0x00 ); - guint32 mid = sp_color_get_rgba32_ualpha( &color, 0x7f ); - guint32 end = sp_color_get_rgba32_ualpha( &color, 0xff ); + guint32 start = color.toRGBA32( 0x00 ); + guint32 mid = color.toRGBA32( 0x7f ); + guint32 end = color.toRGBA32( 0xff ); sp_color_slider_set_colors (SP_COLOR_SLIDER(wheelSelector->_slider), start, mid, end); diff --git a/src/widgets/sp-color-wheel.cpp b/src/widgets/sp-color-wheel.cpp index 9038b6d38..e59cce4d3 100644 --- a/src/widgets/sp-color-wheel.cpp +++ b/src/widgets/sp-color-wheel.cpp @@ -25,6 +25,9 @@ enum { LAST_SIGNAL }; +#define noDUMP_CHANGE_INFO +#define FOO_NAME(x) g_type_name( G_TYPE_FROM_INSTANCE(x) ) + static void sp_color_wheel_class_init (SPColorWheelClass *klass); static void sp_color_wheel_init (SPColorWheel *wheel); static void sp_color_wheel_destroy (GtkObject *object); @@ -185,11 +188,14 @@ void sp_color_wheel_get_color( SPColorWheel *wheel, SPColor* color ) rgb[i] = (rgb[i] * wheel->_sat) + (wheel->_value * (1.0 - wheel->_sat)); } - sp_color_set_rgb_float (color, rgb[0], rgb[1], rgb[2]); + color->set( rgb[0], rgb[1], rgb[2] ); } void sp_color_wheel_set_color( SPColorWheel *wheel, const SPColor* color ) { +#ifdef DUMP_CHANGE_INFO + g_message("sp_color_wheel_set_color( wheel=%p, %f, %f, %f)", wheel, color->v.c[0], color->v.c[1], color->v.c[2] ); +#endif g_return_if_fail (SP_IS_COLOR_WHEEL (wheel)); g_return_if_fail (wheel != NULL); g_return_if_fail (color != NULL); @@ -366,6 +372,15 @@ sp_color_wheel_button_press (GtkWidget *widget, GdkEventButton *event) gtk_widget_grab_focus( widget ); wheel->dragging = TRUE; +#ifdef DUMP_CHANGE_INFO + { + SPColor color; + sp_color_wheel_get_color( wheel, &color ); + g_message( "%s:%d: About to signal %s to color %08x in %s", __FILE__, __LINE__, + "CHANGED", + color.toRGBA32( 0 ), FOO_NAME(wheel)); + } +#endif gtk_signal_emit (GTK_OBJECT (wheel), wheel_signals[CHANGED]); gdk_pointer_grab (widget->window, FALSE, (GdkEventMask)(GDK_POINTER_MOTION_MASK | GDK_BUTTON_RELEASE_MASK), @@ -387,6 +402,15 @@ sp_color_wheel_button_release (GtkWidget *widget, GdkEventButton *event) gdk_pointer_ungrab (event->time); wheel->dragging = FALSE; +#ifdef DUMP_CHANGE_INFO + { + SPColor color; + sp_color_wheel_get_color( wheel, &color ); + g_message( "%s:%d: About to signal %s to color %08x in %s", __FILE__, __LINE__, + "CHANGED", + color.toRGBA32( 0 ), FOO_NAME(wheel)); + } +#endif gtk_signal_emit (GTK_OBJECT (wheel), wheel_signals[CHANGED]); } @@ -413,6 +437,15 @@ sp_color_wheel_motion_notify (GtkWidget *widget, GdkEventMotion *event) sp_color_wheel_process_in_triangle( wheel, event->x, event->y ); } +#ifdef DUMP_CHANGE_INFO + { + SPColor color; + sp_color_wheel_get_color( wheel, &color ); + g_message( "%s:%d: About to signal %s to color %08x in %s", __FILE__, __LINE__, + "CHANGED", + color.toRGBA32( 0 ), FOO_NAME(wheel)); + } +#endif gtk_signal_emit (GTK_OBJECT (wheel), wheel_signals[CHANGED]); } @@ -476,6 +509,15 @@ static void sp_color_wheel_set_sv( SPColorWheel *wheel, gdouble sat, gdouble val wheel->_spotValue = ( (0.299 * rgb[0]) + (0.587 * rgb[1]) + (0.114 * rgb[2]) ); +#ifdef DUMP_CHANGE_INFO + { + SPColor color; + sp_color_wheel_get_color( wheel, &color ); + g_message( "%s:%d: About to signal %s to color %08x in %s", __FILE__, __LINE__, + "CHANGED", + color.toRGBA32( 0 ), FOO_NAME(wheel)); + } +#endif gtk_signal_emit (GTK_OBJECT (wheel), wheel_signals[CHANGED]); } gtk_widget_queue_draw (GTK_WIDGET (wheel));