From: joncruz Date: Tue, 30 Oct 2007 06:16:09 +0000 (+0000) Subject: Cleanup on color changers X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=9fb4864477462bc005fa792b095fd06549eca4ab;p=inkscape.git Cleanup on color changers --- diff --git a/src/widgets/paint-selector.cpp b/src/widgets/paint-selector.cpp index c6273fcc2..de9dd367c 100644 --- a/src/widgets/paint-selector.cpp +++ b/src/widgets/paint-selector.cpp @@ -764,7 +764,7 @@ ink_pattern_list_get (SPDocument *source) * Adds menu items for pattern list - derived from marker code, left hb etc in to make addition of previews easier at some point. */ static void -sp_pattern_menu_build (GtkWidget *m, GSList *pattern_list, SPDocument *source) +sp_pattern_menu_build (GtkWidget *m, GSList *pattern_list, SPDocument */*source*/) { for (; pattern_list != NULL; pattern_list = pattern_list->next) { @@ -1012,7 +1012,7 @@ sp_paint_selector_get_pattern(SPPaintSelector *psel) } gchar *patid = (gchar *) g_object_get_data(G_OBJECT(gtk_menu_get_active(m)), "pattern"); - gchar *pattern = ""; + //gchar *pattern = ""; if (strcmp(patid, "none")){ gchar *stockid = (gchar *) g_object_get_data(G_OBJECT(gtk_menu_get_active(m)), diff --git a/src/widgets/sp-color-gtkselector.cpp b/src/widgets/sp-color-gtkselector.cpp index 9a16ab059..10254321a 100644 --- a/src/widgets/sp-color-gtkselector.cpp +++ b/src/widgets/sp-color-gtkselector.cpp @@ -128,25 +128,19 @@ ColorGtkselector::~ColorGtkselector() { } -void ColorGtkselector::_colorChanged( const SPColor& color, gfloat alpha ) +void ColorGtkselector::_colorChanged() { GdkColor gcolor; - g_return_if_fail (_csel != NULL); - g_return_if_fail (SP_IS_COLOR_GTKSELECTOR (_csel)); - g_return_if_fail( ( 0.0 <= alpha ) && ( alpha <= 1.0 ) ); - - _color = color; - _alpha = alpha; gcolor.pixel = 0; - gcolor.red = static_cast< guint16 > (color.v.c[0] * 65535); - gcolor.green = static_cast< guint16 > (color.v.c[1] * 65535); - gcolor.blue = static_cast< guint16 > (color.v.c[2] * 65535); + gcolor.red = static_cast< guint16 >(_color.v.c[0] * 65535); + gcolor.green = static_cast< guint16 >(_color.v.c[1] * 65535); + gcolor.blue = static_cast< guint16 >(_color.v.c[2] * 65535); // g_message( "***** _colorChanged %04x %04x %04x", gcolor.red, gcolor.green, gcolor.blue ); g_signal_handler_block( _gtkThing, _sigId ); - gtk_color_selection_set_current_alpha (_gtkThing, (guint16)(65535 * alpha)); - gtk_color_selection_set_current_color (_gtkThing, &gcolor); + gtk_color_selection_set_current_alpha( _gtkThing, static_cast(65535 * _alpha) ); + gtk_color_selection_set_current_color( _gtkThing, &gcolor ); g_signal_handler_unblock(_gtkThing, _sigId ); } diff --git a/src/widgets/sp-color-gtkselector.h b/src/widgets/sp-color-gtkselector.h index 75a28ee1a..b9b2b0862 100644 --- a/src/widgets/sp-color-gtkselector.h +++ b/src/widgets/sp-color-gtkselector.h @@ -1,5 +1,5 @@ -#ifndef __SP_COLOR_GTKSELECTOR_H__ -#define __SP_COLOR_GTKSELECTOR_H__ +#ifndef SEEN_SP_COLOR_GTKSELECTOR_H +#define SEEN_SP_COLOR_GTKSELECTOR_H #include #include "../color.h" @@ -24,7 +24,7 @@ public: protected: static void _gtkChanged( GtkColorSelection *colorselection, SPColorGtkselector *gtksel ); - virtual void _colorChanged( const SPColor& color, gfloat alpha ); + virtual void _colorChanged(); GtkColorSelection* _gtkThing; gulong _sigId; @@ -39,11 +39,11 @@ protected: #define SP_IS_COLOR_GTKSELECTOR_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_GTKSELECTOR)) struct SPColorGtkselector { - SPColorSelector base; + SPColorSelector base; }; struct SPColorGtkselectorClass { - SPColorSelectorClass parent_class; + SPColorSelectorClass parent_class; }; GType sp_color_gtkselector_get_type (void); @@ -52,4 +52,4 @@ GtkWidget *sp_color_gtkselector_new( GType selector_type ); -#endif +#endif // SEEN_SP_COLOR_GTKSELECTOR_H diff --git a/src/widgets/sp-color-icc-selector.cpp b/src/widgets/sp-color-icc-selector.cpp index fc4e4bbdc..60b55bbe9 100644 --- a/src/widgets/sp-color-icc-selector.cpp +++ b/src/widgets/sp-color-icc-selector.cpp @@ -540,7 +540,7 @@ void ColorICCSelector::_profilesChanged( std::string const & name ) /* Helpers for setting color value */ -void ColorICCSelector::_colorChanged( const SPColor& color, gfloat alpha ) +void ColorICCSelector::_colorChanged() { _updating = TRUE; // sp_color_icc_set_color( SP_COLOR_ICC( _icc ), &color ); @@ -555,11 +555,11 @@ void ColorICCSelector::_colorChanged( const SPColor& color, gfloat alpha ) g_message("FLIPPIES!!!! %p '%s'", color.icc, (color.icc?color.icc->colorProfile.c_str():"")); #endif // DEBUG_LCMS - _profilesChanged( (color.icc) ? color.icc->colorProfile : std::string("") ); - ColorScales::setScaled( _adj, alpha ); + _profilesChanged( (_color.icc) ? _color.icc->colorProfile : std::string("") ); + ColorScales::setScaled( _adj, _alpha ); #if ENABLE_LCMS - _setProfile( color.icc ); + _setProfile( _color.icc ); _fixupNeeded = 0; gtk_widget_set_sensitive( _fixupBtn, FALSE ); @@ -579,7 +579,7 @@ void ColorICCSelector::_colorChanged( const SPColor& color, gfloat alpha ) guchar post[4] = {0,0,0,0}; cmsDoTransform( _prof->getTransfToSRGB8(), tmp, post, 1 ); guint32 other = SP_RGBA32_U_COMPOSE(post[0], post[1], post[2], 255 ); - if ( other != color.toRGBA32(255) ) { + if ( other != _color.toRGBA32(255) ) { _fixupNeeded = other; gtk_widget_set_sensitive( _fixupBtn, TRUE ); //g_message("Color needs to change 0x%06x to 0x%06x", color.toRGBA32(255) >> 8, other >> 8 ); diff --git a/src/widgets/sp-color-icc-selector.h b/src/widgets/sp-color-icc-selector.h index b5e23c62c..dfba71a09 100644 --- a/src/widgets/sp-color-icc-selector.h +++ b/src/widgets/sp-color-icc-selector.h @@ -1,5 +1,5 @@ -#ifndef __SP_COLOR_ICC_SELECTOR_H__ -#define __SP_COLOR_ICC_SELECTOR_H__ +#ifndef SEEN_SP_COLOR_ICC_SELECTOR_H +#define SEEN_SP_COLOR_ICC_SELECTOR_H #include #include @@ -28,7 +28,7 @@ public: virtual void init(); protected: - virtual void _colorChanged( const SPColor& color, gfloat alpha ); + virtual void _colorChanged(); static void _adjustmentChanged ( GtkAdjustment *adjustment, SPColorICCSelector *cs ); @@ -104,7 +104,7 @@ GtkWidget *sp_color_icc_selector_new (void); -#endif +#endif // SEEN_SP_COLOR_ICC_SELECTOR_H /* Local Variables: diff --git a/src/widgets/sp-color-notebook.cpp b/src/widgets/sp-color-notebook.cpp index 44d6b3799..b7ec3eb2c 100644 --- a/src/widgets/sp-color-notebook.cpp +++ b/src/widgets/sp-color-notebook.cpp @@ -418,21 +418,15 @@ SPColorSelector* ColorNotebook::getCurrentSelector() return csel; } -void ColorNotebook::_colorChanged(const SPColor& color, gfloat alpha) +void ColorNotebook::_colorChanged() { - SPColorSelector* cselPage = 0; - - g_return_if_fail (_csel != NULL); - g_return_if_fail (SP_IS_COLOR_NOTEBOOK (_csel)); - g_return_if_fail( ( 0.0 <= alpha ) && ( alpha <= 1.0 ) ); - - cselPage = getCurrentSelector(); - if ( cselPage ) - { - cselPage->base->setColorAlpha( color, alpha ); - } + SPColorSelector* cselPage = getCurrentSelector(); + if ( cselPage ) + { + cselPage->base->setColorAlpha( _color, _alpha ); + } - _updateRgbaEntry( color, alpha ); + _updateRgbaEntry( _color, _alpha ); } void ColorNotebook::_rgbaEntryChangedHook(GtkEntry *entry, SPColorNotebook *colorbook) @@ -624,3 +618,14 @@ void ColorNotebook::removePage( GType page_type, guint submode ) } } } + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/widgets/sp-color-notebook.h b/src/widgets/sp-color-notebook.h index ad79437da..5def16289 100644 --- a/src/widgets/sp-color-notebook.h +++ b/src/widgets/sp-color-notebook.h @@ -1,5 +1,5 @@ -#ifndef __SP_COLOR_NOTEBOOK_H__ -#define __SP_COLOR_NOTEBOOK_H__ +#ifndef SEEN_SP_COLOR_NOTEBOOK_H +#define SEEN_SP_COLOR_NOTEBOOK_H /* * A block of 3 color sliders plus spinbuttons @@ -49,7 +49,7 @@ protected: static void _entryChanged( SPColorSelector *csel, SPColorNotebook *colorbook ); static void _entryModified( SPColorSelector *csel, SPColorNotebook *colorbook ); - virtual void _colorChanged( const SPColor& color, gfloat alpha ); + virtual void _colorChanged(); void _rgbaEntryChanged( GtkEntry* entry ); void _updateRgbaEntry( const SPColor& color, gfloat alpha ); @@ -81,16 +81,16 @@ private: #define SP_IS_COLOR_NOTEBOOK_CLASS(k) (GTK_CHECK_CLASS_TYPE ((k), SP_TYPE_COLOR_NOTEBOOK)) struct SPColorNotebook { - SPColorSelector parent; /* Parent */ + SPColorSelector parent; /* Parent */ }; struct SPColorNotebookClass { - SPColorSelectorClass parent_class; + SPColorSelectorClass parent_class; - void (* grabbed) (SPColorNotebook *rgbsel); - void (* dragged) (SPColorNotebook *rgbsel); - void (* released) (SPColorNotebook *rgbsel); - void (* changed) (SPColorNotebook *rgbsel); + void (* grabbed) (SPColorNotebook *rgbsel); + void (* dragged) (SPColorNotebook *rgbsel); + void (* released) (SPColorNotebook *rgbsel); + void (* changed) (SPColorNotebook *rgbsel); }; GtkType sp_color_notebook_get_type (void); @@ -102,4 +102,16 @@ GtkWidget *sp_color_notebook_new (void); -#endif +#endif // SEEN_SP_COLOR_NOTEBOOK_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : + diff --git a/src/widgets/sp-color-scales.cpp b/src/widgets/sp-color-scales.cpp index 4a232c82c..d5ff8609c 100644 --- a/src/widgets/sp-color-scales.cpp +++ b/src/widgets/sp-color-scales.cpp @@ -269,44 +269,44 @@ void ColorScales::_setRangeLimit( gdouble upper ) } } -void ColorScales::_colorChanged( const SPColor& color, gfloat alpha ) +void ColorScales::_colorChanged() { #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}; - - switch (_mode) { - case SP_COLOR_SCALES_MODE_RGB: - sp_color_get_rgb_floatv (&color, c); - c[3] = alpha; - c[4] = 0.0; - break; - case SP_COLOR_SCALES_MODE_HSV: - sp_color_get_rgb_floatv (&color, tmp); - c[0] = getScaled( _a[0] ); - sp_color_rgb_to_hsl_floatv (c, tmp[0], tmp[1], tmp[2]); - c[3] = alpha; - c[4] = 0.0; - break; - case SP_COLOR_SCALES_MODE_CMYK: - sp_color_get_cmyk_floatv (&color, c); - c[4] = alpha; - break; - default: - g_warning ("file %s: line %d: Illegal color selector mode %d", __FILE__, __LINE__, _mode); - break; - } + gfloat tmp[3]; + gfloat c[5] = {0.0, 0.0, 0.0, 0.0}; + + switch (_mode) { + case SP_COLOR_SCALES_MODE_RGB: + sp_color_get_rgb_floatv( &_color, c ); + c[3] = _alpha; + c[4] = 0.0; + break; + case SP_COLOR_SCALES_MODE_HSV: + sp_color_get_rgb_floatv( &_color, tmp ); + c[0] = getScaled( _a[0] ); + sp_color_rgb_to_hsl_floatv (c, tmp[0], tmp[1], tmp[2]); + c[3] = _alpha; + c[4] = 0.0; + break; + case SP_COLOR_SCALES_MODE_CMYK: + sp_color_get_cmyk_floatv( &_color, c ); + c[4] = _alpha; + break; + default: + g_warning ("file %s: line %d: Illegal color selector mode %d", __FILE__, __LINE__, _mode); + break; + } - _updating = TRUE; - setScaled( _a[0], c[0] ); - setScaled( _a[1], c[1] ); - setScaled( _a[2], c[2] ); - setScaled( _a[3], c[3] ); - setScaled( _a[4], c[4] ); - _updateSliders( CSC_CHANNELS_ALL ); - _updating = FALSE; + _updating = TRUE; + setScaled( _a[0], c[0] ); + setScaled( _a[1], c[1] ); + setScaled( _a[2], c[2] ); + setScaled( _a[3], c[3] ); + setScaled( _a[4], c[4] ); + _updateSliders( CSC_CHANNELS_ALL ); + _updating = FALSE; } void ColorScales::_getRgbaFloatv( gfloat *rgba ) diff --git a/src/widgets/sp-color-scales.h b/src/widgets/sp-color-scales.h index efb557f9b..21a85a08e 100644 --- a/src/widgets/sp-color-scales.h +++ b/src/widgets/sp-color-scales.h @@ -41,7 +41,7 @@ public: protected: - virtual void _colorChanged(SPColor const &color, gfloat alpha); + virtual void _colorChanged(); static void _adjustmentAnyChanged(GtkAdjustment *adjustment, SPColorScales *cs); static void _sliderAnyGrabbed(SPColorSlider *slider, SPColorScales *cs); diff --git a/src/widgets/sp-color-selector.cpp b/src/widgets/sp-color-selector.cpp index 052996247..312128781 100644 --- a/src/widgets/sp-color-selector.cpp +++ b/src/widgets/sp-color-selector.cpp @@ -1,6 +1,7 @@ /* * bulia byak -*/ + * Jon A. Cruz + */ #ifdef HAVE_CONFIG_H # include "config.h" @@ -11,152 +12,143 @@ #include "sp-color-selector.h" enum { - GRABBED, - DRAGGED, - RELEASED, - CHANGED, - LAST_SIGNAL + GRABBED, + DRAGGED, + RELEASED, + CHANGED, + LAST_SIGNAL }; #define noDUMP_CHANGE_INFO #define FOO_NAME(x) g_type_name( G_TYPE_FROM_INSTANCE(x) ) -static void sp_color_selector_class_init (SPColorSelectorClass *klass); -static void sp_color_selector_init (SPColorSelector *csel); -static void sp_color_selector_destroy (GtkObject *object); +static void sp_color_selector_class_init( SPColorSelectorClass *klass ); +static void sp_color_selector_init( SPColorSelector *csel ); +static void sp_color_selector_destroy( GtkObject *object ); -static void sp_color_selector_show_all (GtkWidget *widget); -static void sp_color_selector_hide_all (GtkWidget *widget); +static void sp_color_selector_show_all( GtkWidget *widget ); +static void sp_color_selector_hide_all( GtkWidget *widget ); static GtkVBoxClass *parent_class; static guint csel_signals[LAST_SIGNAL] = {0}; -GType -sp_color_selector_get_type (void) +double ColorSelector::_epsilon = 1e-4; + +GType sp_color_selector_get_type( void ) { - static GType type = 0; - if (!type) { - static const GTypeInfo info = { - sizeof (SPColorSelectorClass), - NULL, /* base_init */ - NULL, /* base_finalize */ - (GClassInitFunc) sp_color_selector_class_init, - NULL, /* class_finalize */ - NULL, /* class_data */ - sizeof (SPColorSelector), - 0, /* n_preallocs */ - (GInstanceInitFunc) sp_color_selector_init, - NULL - }; - - type = g_type_register_static (GTK_TYPE_VBOX, - "SPColorSelector", - &info, - static_cast< GTypeFlags > (0) ); - } - return type; + static GType type = 0; + if (!type) { + static const GTypeInfo info = { + sizeof(SPColorSelectorClass), + NULL, /* base_init */ + NULL, /* base_finalize */ + (GClassInitFunc) sp_color_selector_class_init, + NULL, /* class_finalize */ + NULL, /* class_data */ + sizeof(SPColorSelector), + 0, /* n_preallocs */ + (GInstanceInitFunc) sp_color_selector_init, + NULL + }; + + type = g_type_register_static( GTK_TYPE_VBOX, + "SPColorSelector", + &info, + static_cast(0) ); + } + return type; } -static void -sp_color_selector_class_init (SPColorSelectorClass *klass) +void sp_color_selector_class_init( SPColorSelectorClass *klass ) { - static const gchar* nameset[] = {N_("Unnamed"), 0}; - GtkObjectClass *object_class; - GtkWidgetClass *widget_class; - - object_class = (GtkObjectClass *) klass; - widget_class = (GtkWidgetClass *) klass; - - parent_class = (GtkVBoxClass*)gtk_type_class (GTK_TYPE_VBOX); - - csel_signals[GRABBED] = gtk_signal_new ("grabbed", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET (SPColorSelectorClass, grabbed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - csel_signals[DRAGGED] = gtk_signal_new ("dragged", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET (SPColorSelectorClass, dragged), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - csel_signals[RELEASED] = gtk_signal_new ("released", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET (SPColorSelectorClass, released), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - csel_signals[CHANGED] = gtk_signal_new ("changed", - (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), - GTK_CLASS_TYPE(object_class), - GTK_SIGNAL_OFFSET (SPColorSelectorClass, changed), - gtk_marshal_NONE__NONE, - GTK_TYPE_NONE, 0); - - klass->name = nameset; - klass->submode_count = 1; - - object_class->destroy = sp_color_selector_destroy; - - widget_class->show_all = sp_color_selector_show_all; - widget_class->hide_all = sp_color_selector_hide_all; + static const gchar* nameset[] = {N_("Unnamed"), 0}; + GtkObjectClass *object_class; + GtkWidgetClass *widget_class; + + object_class = GTK_OBJECT_CLASS(klass); + widget_class = GTK_WIDGET_CLASS(klass); + + parent_class = GTK_VBOX_CLASS( gtk_type_class(GTK_TYPE_VBOX) ); + + csel_signals[GRABBED] = gtk_signal_new( "grabbed", + (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), + GTK_CLASS_TYPE(object_class), + GTK_SIGNAL_OFFSET(SPColorSelectorClass, grabbed), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0 ); + csel_signals[DRAGGED] = gtk_signal_new( "dragged", + (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), + GTK_CLASS_TYPE(object_class), + GTK_SIGNAL_OFFSET(SPColorSelectorClass, dragged), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0 ); + csel_signals[RELEASED] = gtk_signal_new( "released", + (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), + GTK_CLASS_TYPE(object_class), + GTK_SIGNAL_OFFSET(SPColorSelectorClass, released), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0 ); + csel_signals[CHANGED] = gtk_signal_new( "changed", + (GtkSignalRunType)(GTK_RUN_FIRST | GTK_RUN_NO_RECURSE), + GTK_CLASS_TYPE(object_class), + GTK_SIGNAL_OFFSET(SPColorSelectorClass, changed), + gtk_marshal_NONE__NONE, + GTK_TYPE_NONE, 0 ); + + klass->name = nameset; + klass->submode_count = 1; + + object_class->destroy = sp_color_selector_destroy; + + widget_class->show_all = sp_color_selector_show_all; + widget_class->hide_all = sp_color_selector_hide_all; } -void sp_color_selector_init (SPColorSelector *csel) +void sp_color_selector_init( SPColorSelector *csel ) { if ( csel->base ) { csel->base->init(); } -/* gtk_signal_connect (GTK_OBJECT (csel->rgbae), "changed", GTK_SIGNAL_FUNC (sp_color_selector_rgba_entry_changed), csel); */ +/* gtk_signal_connect(GTK_OBJECT(csel->rgbae), "changed", GTK_SIGNAL_FUNC(sp_color_selector_rgba_entry_changed), csel); */ } -static void -sp_color_selector_destroy (GtkObject *object) +void sp_color_selector_destroy( GtkObject *object ) { - SPColorSelector *csel; - - csel = SP_COLOR_SELECTOR (object); + SPColorSelector *csel = SP_COLOR_SELECTOR( object ); if ( csel->base ) - { - delete csel->base; - csel->base = 0; - } + { + delete csel->base; + csel->base = 0; + } - if (((GtkObjectClass *) (parent_class))->destroy) - (* ((GtkObjectClass *) (parent_class))->destroy) (object); + if ( (GTK_OBJECT_CLASS(parent_class))->destroy ) { + (* (GTK_OBJECT_CLASS(parent_class))->destroy)(object); + } } -static void -sp_color_selector_show_all (GtkWidget *widget) +void sp_color_selector_show_all( GtkWidget *widget ) { - gtk_widget_show (widget); + gtk_widget_show( widget ); } -static void -sp_color_selector_hide_all (GtkWidget *widget) +void sp_color_selector_hide_all( GtkWidget *widget ) { - gtk_widget_hide (widget); + gtk_widget_hide( widget ); } -GtkWidget * -sp_color_selector_new( GType selector_type ) +GtkWidget *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); + g_return_val_if_fail( g_type_is_a( selector_type, SP_TYPE_COLOR_SELECTOR ), NULL ); - csel = SP_COLOR_SELECTOR (g_object_new (selector_type, NULL)); + SPColorSelector *csel = SP_COLOR_SELECTOR( g_object_new( selector_type, NULL ) ); - return GTK_WIDGET (csel); + return GTK_WIDGET( csel ); } -double ColorSelector::_epsilon = 1e-4; - -void ColorSelector::setSubmode( guint submode ) +void ColorSelector::setSubmode( guint /*submode*/ ) { - (void)submode; } guint ColorSelector::getSubmode() const @@ -172,6 +164,7 @@ ColorSelector::ColorSelector( SPColorSelector* csel ) _held(FALSE), virgin(true) { + g_return_if_fail( SP_IS_COLOR_SELECTOR(_csel) ); } ColorSelector::~ColorSelector() @@ -215,28 +208,30 @@ void ColorSelector::setColorAlpha( const SPColor& color, gfloat alpha, bool emit #ifdef DUMP_CHANGE_INFO g_message("ColorSelector::setColorAlpha( this=%p, %f, %f, %f, %s, %f, %s) in %s", this, color.v.c[0], color.v.c[1], color.v.c[2], (color.icc?color.icc->colorProfile.c_str():""), alpha, (emit?"YES":"no"), FOO_NAME(_csel)); #endif + g_return_if_fail( _csel != NULL ); g_return_if_fail( ( 0.0 <= alpha ) && ( alpha <= 1.0 ) ); #ifdef DUMP_CHANGE_INFO g_message("---- ColorSelector::setColorAlpha virgin:%s !close:%s alpha is:%s in %s", (virgin?"YES":"no"), (!color.isClose( _color, _epsilon )?"YES":"no"), - ((fabs ((_alpha) - (alpha)) >= _epsilon )?"YES":"no"), + ((fabs((_alpha) - (alpha)) >= _epsilon )?"YES":"no"), FOO_NAME(_csel) ); #endif if ( virgin || !color.isClose( _color, _epsilon ) || - (fabs ((_alpha) - (alpha)) >= _epsilon )) { + (fabs((_alpha) - (alpha)) >= _epsilon )) { virgin = false; _color = color; _alpha = alpha; - _colorChanged( color, alpha ); + _colorChanged(); - if (emit) - gtk_signal_emit (GTK_OBJECT (_csel), csel_signals[CHANGED]); + 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:%s in %s", color.toRGBA32(alpha), _color.toRGBA32(_alpha), @@ -249,23 +244,23 @@ void ColorSelector::_grabbed() { _held = TRUE; #ifdef DUMP_CHANGE_INFO - g_message ("%s:%d: About to signal %s in %s", __FILE__, __LINE__, + g_message("%s:%d: About to signal %s in %s", __FILE__, __LINE__, "GRABBED", FOO_NAME(_csel)); #endif - gtk_signal_emit (GTK_OBJECT (_csel), csel_signals[GRABBED]); + gtk_signal_emit(GTK_OBJECT(_csel), csel_signals[GRABBED]); } void ColorSelector::_released() { _held = false; #ifdef DUMP_CHANGE_INFO - g_message ("%s:%d: About to signal %s in %s", __FILE__, __LINE__, + g_message("%s:%d: About to signal %s in %s", __FILE__, __LINE__, "RELEASED", FOO_NAME(_csel)); #endif - gtk_signal_emit (GTK_OBJECT (_csel), csel_signals[RELEASED]); - gtk_signal_emit (GTK_OBJECT (_csel), csel_signals[CHANGED]); + gtk_signal_emit(GTK_OBJECT(_csel), csel_signals[RELEASED]); + gtk_signal_emit(GTK_OBJECT(_csel), csel_signals[CHANGED]); } // Called from subclasses to update color and broadcast if needed @@ -289,37 +284,38 @@ void ColorSelector::_updateInternals( const SPColor& color, gfloat alpha, gboole if ( grabbed ) { #ifdef DUMP_CHANGE_INFO - g_message ("%s:%d: About to signal %s to color %08x::%s in %s", __FILE__, __LINE__, + g_message("%s:%d: About to signal %s to color %08x::%s in %s", __FILE__, __LINE__, "GRABBED", color.toRGBA32( alpha ), (color.icc?color.icc->colorProfile.c_str():""), FOO_NAME(_csel)); #endif - gtk_signal_emit (GTK_OBJECT (_csel), csel_signals[GRABBED]); + gtk_signal_emit(GTK_OBJECT(_csel), csel_signals[GRABBED]); } else if ( released ) { #ifdef DUMP_CHANGE_INFO - g_message ("%s:%d: About to signal %s to color %08x::%s in %s", __FILE__, __LINE__, + g_message("%s:%d: About to signal %s to color %08x::%s in %s", __FILE__, __LINE__, "RELEASED", color.toRGBA32( alpha ), (color.icc?color.icc->colorProfile.c_str():""), FOO_NAME(_csel)); #endif - gtk_signal_emit (GTK_OBJECT (_csel), csel_signals[RELEASED]); + gtk_signal_emit(GTK_OBJECT(_csel), csel_signals[RELEASED]); } if ( colorDifferent || released ) { #ifdef DUMP_CHANGE_INFO - g_message ("%s:%d: About to signal %s to color %08x::%s in %s", __FILE__, __LINE__, + g_message("%s:%d: About to signal %s to color %08x::%s in %s", __FILE__, __LINE__, (_held ? "CHANGED" : "DRAGGED" ), color.toRGBA32( alpha ), (color.icc?color.icc->colorProfile.c_str():""), FOO_NAME(_csel)); #endif - gtk_signal_emit (GTK_OBJECT (_csel), csel_signals[_held ? CHANGED : DRAGGED]); + gtk_signal_emit(GTK_OBJECT(_csel), csel_signals[_held ? CHANGED : DRAGGED]); } } -void ColorSelector::_colorChanged( const SPColor& color, gfloat alpha ) +/** + * Called once the color actually changes. Allows subclasses to react to changes. + */ +void ColorSelector::_colorChanged() { - (void)color; - (void)alpha; } void ColorSelector::getColorAlpha( SPColor& color, gfloat* alpha ) const @@ -354,3 +350,14 @@ void ColorSelector::getColorAlpha( SPColor& color, gfloat* alpha ) const i++; } } + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/widgets/sp-color-selector.h b/src/widgets/sp-color-selector.h index 43090b158..40446fe0a 100644 --- a/src/widgets/sp-color-selector.h +++ b/src/widgets/sp-color-selector.h @@ -1,5 +1,5 @@ -#ifndef __SP_COLOR_SELECTOR_H__ -#define __SP_COLOR_SELECTOR_H__ +#ifndef SEEN_SP_COLOR_SELECTOR_H +#define SEEN_SP_COLOR_SELECTOR_H #include #include "../color.h" @@ -37,13 +37,13 @@ protected: void _updateInternals( const SPColor& color, gfloat alpha, gboolean held ); gboolean _isHeld() const { return _held; } - virtual void _colorChanged( const SPColor& color, gfloat alpha ); + virtual void _colorChanged(); static double _epsilon; SPColorSelector* _csel; SPColor _color; - gfloat _alpha; /* guaranteed to be in [0, 1]. */ + gfloat _alpha; // guaranteed to be in [0, 1]. private: // By default, disallow copy constructor and assignment operator @@ -71,22 +71,32 @@ struct SPColorSelector { }; struct SPColorSelectorClass { - GtkVBoxClass parent_class; + GtkVBoxClass parent_class; - const gchar **name; - guint submode_count; - - void (* grabbed) (SPColorSelector *rgbsel); - void (* dragged) (SPColorSelector *rgbsel); - void (* released) (SPColorSelector *rgbsel); - void (* changed) (SPColorSelector *rgbsel); + const gchar **name; + guint submode_count; + void (* grabbed) (SPColorSelector *rgbsel); + void (* dragged) (SPColorSelector *rgbsel); + void (* released) (SPColorSelector *rgbsel); + void (* changed) (SPColorSelector *rgbsel); }; -GType sp_color_selector_get_type (void); +GType sp_color_selector_get_type(void); GtkWidget *sp_color_selector_new( GType selector_type ); -#endif +#endif // SEEN_SP_COLOR_SELECTOR_H + +/* + Local Variables: + mode:c++ + c-file-style:"stroustrup" + c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +)) + indent-tabs-mode:nil + fill-column:99 + End: +*/ +// vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 : diff --git a/src/widgets/sp-color-slider.cpp b/src/widgets/sp-color-slider.cpp index b3c775c37..4b7771e63 100644 --- a/src/widgets/sp-color-slider.cpp +++ b/src/widgets/sp-color-slider.cpp @@ -406,7 +406,7 @@ sp_color_slider_set_background (SPColorSlider *slider, guint dark, guint light, } static void -sp_color_slider_adjustment_changed (GtkAdjustment *adjustment, SPColorSlider *slider) +sp_color_slider_adjustment_changed (GtkAdjustment */*adjustment*/, SPColorSlider *slider) { gtk_widget_queue_draw (GTK_WIDGET (slider)); } diff --git a/src/widgets/sp-color-wheel-selector.cpp b/src/widgets/sp-color-wheel-selector.cpp index 854f6303d..174b071f9 100644 --- a/src/widgets/sp-color-wheel-selector.cpp +++ b/src/widgets/sp-color-wheel-selector.cpp @@ -205,21 +205,21 @@ sp_color_wheel_selector_new (void) /* Helpers for setting color value */ -void ColorWheelSelector::_colorChanged( const SPColor& color, gfloat alpha ) +void ColorWheelSelector::_colorChanged() { #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 ); + sp_color_wheel_set_color( SP_COLOR_WHEEL( _wheel ), &_color ); - guint32 start = color.toRGBA32( 0x00 ); - guint32 mid = color.toRGBA32( 0x7f ); - guint32 end = color.toRGBA32( 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); + sp_color_slider_set_colors(SP_COLOR_SLIDER(_slider), start, mid, end); - ColorScales::setScaled(_adj, alpha); + ColorScales::setScaled(_adj, _alpha); _updating = FALSE; } diff --git a/src/widgets/sp-color-wheel-selector.h b/src/widgets/sp-color-wheel-selector.h index de358d5ac..df8819bc9 100644 --- a/src/widgets/sp-color-wheel-selector.h +++ b/src/widgets/sp-color-wheel-selector.h @@ -1,5 +1,5 @@ -#ifndef __SP_COLOR_WHEEL_SELECTOR_H__ -#define __SP_COLOR_WHEEL_SELECTOR_H__ +#ifndef SEEN_SP_COLOR_WHEEL_SELECTOR_H +#define SEEN_SP_COLOR_WHEEL_SELECTOR_H #include #include @@ -25,7 +25,7 @@ public: virtual void init(); protected: - virtual void _colorChanged( const SPColor& color, gfloat alpha ); + virtual void _colorChanged(); static void _adjustmentChanged ( GtkAdjustment *adjustment, SPColorWheelSelector *cs ); @@ -76,7 +76,7 @@ GtkWidget *sp_color_wheel_selector_new (void); -#endif +#endif // SEEN_SP_COLOR_WHEEL_SELECTOR_H /* Local Variables: