summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: ea9f218)
raw | patch | inline | side by side (parent: ea9f218)
author | joncruz <joncruz@users.sourceforge.net> | |
Sat, 15 Sep 2007 16:37:27 +0000 (16:37 +0000) | ||
committer | joncruz <joncruz@users.sourceforge.net> | |
Sat, 15 Sep 2007 16:37:27 +0000 (16:37 +0000) |
36 files changed:
diff --git a/src/color.cpp b/src/color.cpp
index 2a6da863c4fd35bffbe2033dcc1389bfe72ca64c..8dc4c865762af724607a92ef5149ffabed55e004 100644 (file)
--- a/src/color.cpp
+++ b/src/color.cpp
#define __SP_COLOR_C__
/** \file
- * Colors and colorspaces.
+ * Colors.
*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2001-2002 Lauris Kaplinski
* Copyright (C) 2001 Ximian, Inc.
#include <math.h>
#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);
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;
}
* 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<gint>(SP_COLOR_F_TO_U(alpha)) );
}
/**
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];
}
/**
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 */
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 2c3f91fe78a39e68d2e6d2dff5314b04b04e1387..e9394360900841a8c4199c9d62679fcad763e381 100644 (file)
--- a/src/color.h
+++ b/src/color.h
#define __SP_COLOR_H__
/** \file
- * Colors and colorspaces
+ * Colors.
*
* Author:
* Lauris Kaplinski <lauris@kaplinski.com>
* bulia byak <buliabyak@users.sf.net>
+ * Jon A. Cruz <jon@joncruz.org>
*
* Copyright (C) 2001-2002 Lauris Kaplinski
* Copyright (C) 2001 Ximian, Inc.
#include <gdk/gdktypes.h>
-struct SPColorSpace;
-
/* Useful composition macros */
#define SP_RGBA32_R_U(v) (((v) >> 24) & 0xff)
#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);
void sp_color_cmyk_to_rgb_floatv (float *rgb, float c, float m, float y, float k);
-
#endif
index 3d830027c60fa5438e86103233c7c5fe63e98443..1dfaea5461b132052b085d0d9161babac0bba0d9 100644 (file)
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()
guint flags,
SPPaintSelector *psel )
{
+ (void)selection;
+ (void)psel;
if (flags & ( SP_OBJECT_MODIFIED_FLAG |
SP_OBJECT_PARENT_MODIFIED_FLAG |
SP_OBJECT_STYLE_MODIFIED_FLAG) )
SPDesktop *desktop,
SPWidget *spw )
{
+ (void)inkscape;
sp_fill_style_widget_update (spw);
}
Inkscape::Selection *selection,
SPPaintSelector *psel )
{
+ (void)selection;
sp_fill_style_widget_update (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()) {
SPPaintSelectorMode mode,
SPWidget *spw )
{
+ (void)mode;
if (g_object_get_data (G_OBJECT (spw), "update"))
return;
SPPaintSelectorFillRule mode,
SPWidget *spw )
{
+ (void)psel;
if (g_object_get_data (G_OBJECT (spw), "update"))
return;
/* 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);
}
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 {
index de367b66f929554ecdb678fe2c4b82e6e6a223ed..9dc7131fcb15843bc3d775fa28e57aaf9d1184d0 100644 (file)
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 );
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);
- }
+ }
}
/**
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);
Inkscape::Selection *selection,
SPPaintSelector *psel )
{
+ (void)selection;
sp_stroke_style_paint_update (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);
}
// 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:
} 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));
}
SPPaintSelectorMode mode,
SPWidget *spw )
{
+ (void)mode;
if (gtk_object_get_data(GTK_OBJECT(spw), "update")) {
return;
}
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
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;
}
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;
}
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;
/* 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);
}
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 {
}
}
- sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
+ sp_document_done(document, SP_VERB_DIALOG_FILL_STROKE,
_("Set gradient on stroke"));
}
break;
} // 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
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;
}
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);
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();
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");
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 );
( 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
guint flags,
gpointer data )
{
+ (void)data;
if (flags & (SP_OBJECT_MODIFIED_FLAG | SP_OBJECT_PARENT_MODIFIED_FLAG)) {
sp_stroke_style_line_update (spw, selection);
}
Inkscape::Selection *selection,
gpointer data )
{
+ (void)data;
sp_stroke_style_line_update (spw, selection);
}
// 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 */
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));
/**
- * 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;
}
}
/**
- * 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;
}
}
/**
- * 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;
}
}
/**
- * 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
index 0a04d0d475c8eda8945b0d90f6e6d6c4d42656fa..3a41c1ec4a4629b096f828952bd921657a997711 100644 (file)
--- a/src/dialogs/swatches.cpp
+++ b/src/dialogs/swatches.cpp
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);
static void dragBegin( GtkWidget *widget, GdkDragContext* dc, gpointer data )
{
+ (void)widget;
ColorItem* item = reinterpret_cast<ColorItem*>(data);
if ( item )
{
static gboolean onButtonPressed (GtkWidget *widget, GdkEventButton *event, gpointer userdata)
{
+ (void)widget;
/* single click with the right mouse button? */
if(event->type == GDK_BUTTON_RELEASE)
{
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:
index 3933625c39ed6702c4f303defcfb52a90eb30665..243cf66187cf9deee5a2e582eb35d39e596a57c4 100644 (file)
@@ -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;
index d245e39283ed32f584e14716ae9b96d0b74f885e..9150b419f73b1f6e2d820657437c92c83a8a8bc7 100644 (file)
@@ -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
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;
// 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)
{
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);
return item->state;
}
+#endif //defined(DEADCODE) && !defined(DEADCODE)
static guint
index e6484de9f1d7748278a373f30ac7a671a317961f..9b4c846fe1d68c91edffe6c790b164336d054dae 100644 (file)
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(); }
void set(SPColor const &color) {
clear();
_type = COLOR;
- sp_color_copy(&_color, &color);
+ _color = color;
}
void set(SPPaintServer *server) {
clear();
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 565fa5e057b5101ef8c70672d141765d321963ef..90d243a6b00e320f141abe13ea79f4b66f7abf77 100644 (file)
//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 138e735e36d5886c47b03891931e6cc195a7b7fe..8a11ea0b00738a287e4675d5d68f6c2100853af1 100644 (file)
--- a/src/dom/dom.h
+++ b/src/dom/dom.h
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 59f538ab919a5cd109072d5e0443bba83b34ea35..ecc12b23a70ebd9e8163ce5677f5dca08f2a345a 100644 (file)
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;
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;
}
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;
index 61e3e593e2fb5968aaedcb08fd51ce9ed10f3087..e233515c96243c62b3741ce89f478011756e253f 100644 (file)
//## 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;
//## 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;
index e051fc8dc6b48c24216310f372ee955bfaf8e345..d31dc907ce886d901af85e68a636c9bb0ae6606d 100644 (file)
@@ -86,14 +86,13 @@ ParamColor::get_widget (SPDocument * doc, Inkscape::XML::Node * node, sigc::sign
{
_changeSignal = new sigc::signal<void>(*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);
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();
}
index 3247224eb622396e2fb0f10cb028c4a0a43689bb..9ee9b08cd99a5d7c9036271b4847d6b8fec6555e 100644 (file)
_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);
void
PrefDialog::setPreviewState (Glib::ustring state) {
-
+ (void)state;
}
void
diff --git a/src/forward.h b/src/forward.h
index ef05ea026007234471d6a100aa76ceb198e92bab..0cab048e0e756ff81464cd6920c2cb247989d7c0 100644 (file)
--- a/src/forward.h
+++ b/src/forward.h
class ColorRGBA;
-class SPColorSpace;
class SPColor;
class SPStyle;
index 0690ef140c480efe083600cad8c5f71b2cbc8b76..d3b8f79114cd44ba3ddc9c3def17b4a8a6dda6d0 100644 (file)
@@ -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 4e51c9a161b2d07c2ec1177cbaee7680bb34c6c6..b4976bad44f044cca86ab35561f5a95f43e3ff80 100644 (file)
--- a/src/helper-fns.h
+++ b/src/helper-fns.h
#include <sstream>
-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);
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':
return default_value;
}
-static std::vector<gdouble> helperfns_read_vector(const gchar* value, int size){
+inline std::vector<gdouble> helperfns_read_vector(const gchar* value, int size){
std::vector<gdouble> v(size, (gdouble) 0);
std::istringstream is(value);
for(int i = 0; i < size && (is >> v[i]); i++);
index f0d4099555bf312933aa2a437bedc21ecbf4c327..36806242f85f9ada9b5c1f628cec11e561483ee2 100644 (file)
BoolParam::BoolParam( const Glib::ustring& label, const Glib::ustring& tip,\r
const Glib::ustring& key, Inkscape::UI::Widget::Registry* wr,\r
Effect* effect, bool default_value )\r
- : Parameter(label, tip, key, wr, effect), defvalue(default_value), value(default_value)\r
+ : Parameter(label, tip, key, wr, effect), value(default_value), defvalue(default_value)\r
{\r
checkwdg = NULL;\r
}\r
diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp
index 8a3eded40e50085d05c54204d3fe5042e23bb2e2..d86e3b0e3cd8c73c01e492b9ff2c055bc04476b7 100644 (file)
--- a/src/sp-gradient.cpp
+++ b/src/sp-gradient.cpp
{
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;
}
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 );
}
}
{
} 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);
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)
rgb0 | 0xff);
return rgb0 | alpha;
} else {
- return sp_color_get_rgba32_falpha(&stop->specified_color, stop->opacity);
+ return stop->specified_color.toRGBA32( stop->opacity );
}
}
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;
/* strictly speaking, offset an SVG <number> 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 */
{
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);
}
// 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);
}
// 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);
}
}
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 b563d8d3b8abd708a263cde9f92fae961533e9b9..3c938e8a1554ae6ea1ec553a7649fba952c8ea05 100644 (file)
--- a/src/sp-object.h
+++ b/src/sp-object.h
/** 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 70e2948486385e328a464c2b680d0ee9a638167e..b817ce083b72bb0f32f0dece1530d12cf65d78ce 100644 (file)
--- a/src/style.cpp
+++ b/src/style.cpp
}
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)
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;
}
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 623291941e614a590bfcb393a78e16747365ea2f..9b2d2878ae631456600b5baa1e263289906517fa 100644 (file)
--- a/src/style.h
+++ b/src/style.h
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;}
};
index 7d7dc9117c32092e1bdbb3c5e20c51b981ac2ee5..d6ae50ae36998f8198720bcc1f5250f044c6b9cf 100644 (file)
_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);
if (_colorSelector)
{
SPColor color;
- sp_color_set_rgb_rgba32(&color, rgba);
+ color.set( rgba );
_colorSelector->base->setColorAlpha(color, SP_RGBA32_A_F(rgba));
}
}
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();
{
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);
index 763913b2783ef8e759beb638079ea00e639b1b54..aaf5fc35c46b7c253758f8dfb5db93980a69bfce 100644 (file)
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
index 4d5a7fc12c1315ae2001ca3b18fce25ffbded40f..df543c8d399c731134d2bc2143a363605f3d872f 100644 (file)
}
} 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 3955d5f009bd40739479b6b0aed6b089c49dfa4d..1d2a3310ffe4de5be545091908aa2c1e6fecb783 100644 (file)
--- a/src/uri-references.h
+++ b/src/uri-references.h
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;
index f1c4e3500437665d8ccc1013367ee5997119fe61..f7a22cc43338ca8a8196495c4f87284bd6c4c0ae 100644 (file)
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"));
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 );
}
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;
index b16a621686a8568c5cb49b72ef186cd5e76cde88..3c103afb00c7280d735d019e6e6dfbf2b10fb947 100644 (file)
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);
index 3c0ec17c646869ec7f587285459a982e34eedd2e..b583903e3e4757f9c627f6f1d5bf052bef35fe9f 100644 (file)
}
GtkWidget *
-sp_color_gtkselector_new (GType, SPColorSpaceType colorspace)
+sp_color_gtkselector_new( GType )
{
SPColorGtkselector *csel;
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 );
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) );
}
index e3b780f2544d39162ccb9c3bc7e11506a089dd77..75a28ee1af1c556a1cd16cede265281151f5270e 100644 (file)
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 );
index c14d89f1142e8dc9696a948190857b4611afe187..60617b849f7560eb720b8426a7bce0c9980338be 100644 (file)
@@ -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 )
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 ) );
{
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;
index 8acd96bbb3af014639ea328196a4bf2b0f1c388f..4a232c82cb5d65da302ab5d2f540316c76bda930 100644 (file)
_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;
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;
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;
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;
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 );
index 1532eddd74bc6516840136c358676a7d32af07ed..ec80eff3e099087e751e88fca3145c1735b85284 100644 (file)
}
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);
void ColorSelector::setSubmode( guint submode )
{
+ (void)submode;
}
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()
*/
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
}
}
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++;
index b2fd62b1e336bf02c544285e7dd953599a8e17ca..43090b158a82d591d848e34db2ac386420151295 100644 (file)
virtual void setSubmode( guint submode );
virtual guint getSubmode() const;
- virtual SPColorSpaceType getColorspace() const;
- virtual gboolean setColorspace( SPColorSpaceType colorspace );
-
protected:
void _grabbed();
void _released();
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 );
index 584a75dd00b335a3ccf4365f48c6a9a04d38b338..854f6303de0fc9a7211b04aaee1e5b6489c6f2c0 100644 (file)
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);
index 9038b6d38013d4fe2880b196411b3ebaf916557f..e59cce4d38e9da2634d4047b3f15facaf828ac8a 100644 (file)
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);
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);
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),
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]);
}
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));