Code

Cleanup on color changers
authorjoncruz <joncruz@users.sourceforge.net>
Tue, 30 Oct 2007 06:16:09 +0000 (06:16 +0000)
committerjoncruz <joncruz@users.sourceforge.net>
Tue, 30 Oct 2007 06:16:09 +0000 (06:16 +0000)
14 files changed:
src/widgets/paint-selector.cpp
src/widgets/sp-color-gtkselector.cpp
src/widgets/sp-color-gtkselector.h
src/widgets/sp-color-icc-selector.cpp
src/widgets/sp-color-icc-selector.h
src/widgets/sp-color-notebook.cpp
src/widgets/sp-color-notebook.h
src/widgets/sp-color-scales.cpp
src/widgets/sp-color-scales.h
src/widgets/sp-color-selector.cpp
src/widgets/sp-color-selector.h
src/widgets/sp-color-slider.cpp
src/widgets/sp-color-wheel-selector.cpp
src/widgets/sp-color-wheel-selector.h

index c6273fcc2c52e8fb7ef246e078650e4f37492221..de9dd367c81007461cf72def672306d54f55cbea 100644 (file)
@@ -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)),
index 9a16ab05962cf4e01d8b518267bee0a6d3f6b934..10254321a54c8ba1a14f5b1d4b29ee8515fabcae 100644 (file)
@@ -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<guint16>(65535 * _alpha) );
+    gtk_color_selection_set_current_color( _gtkThing, &gcolor );
     g_signal_handler_unblock(_gtkThing, _sigId );
 }
 
index 75a28ee1af1c556a1cd16cede265281151f5270e..b9b2b086252ee49fa0c2a3f8a23a3aa3697dd5e1 100644 (file)
@@ -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 <gtk/gtkcolorsel.h>
 #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
index fc4e4bbdc932e73440c450cc86a45f08fcff8673..60b55bbe909022d7205d37a264c0a3919645e624 100644 (file)
@@ -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():"<null>"));
 #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 );
index b5e23c62cae2fb0b89b0ecfb4d7b32132c13c5ee..dfba71a0919f3623419643e0cf81b387fccdab47 100644 (file)
@@ -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 <glib/gtypes.h>
 #include <gtk/gtktooltips.h>
@@ -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:
index 44d6b3799e6aafc184d6d3ef589aa3c2c4914c81..b7ec3eb2c5d2c3984eb6c9b2469439cfa98d2213 100644 (file)
@@ -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 :
index ad79437da68b4e8584e7ae9187bd737a09163bcd..5def16289edc7c5bd16ca1d5f797edd437318691 100644 (file)
@@ -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 :
+
index 4a232c82cb5d65da302ab5d2f540316c76bda930..d5ff8609cb5b414d6d50d165c355a4519131d619 100644 (file)
@@ -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 )
index efb557f9bc91da090b4288a6eed0bff2345f0040..21a85a08e1708254cead47f6d3facc5cb59e04ce 100644 (file)
@@ -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);
index 05299624791ebedbe29bab9618217b0455e1d685..312128781765b18059cb21fa52ea51b2dbd7d0db 100644 (file)
@@ -1,6 +1,7 @@
 /*
  *   bulia byak <buliabyak@users.sf.net>
-*/ 
+ *   Jon A. Cruz <jon@joncruz.org>
+ */
 
 #ifdef HAVE_CONFIG_H
 # include "config.h"
 #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<GTypeFlags>(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():"<null>"), 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():"<null>"), 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():"<null>"), 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():"<null>"), 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 :
index 43090b158a82d591d848e34db2ac386420151295..40446fe0ad9b4998c69ce4b63c3281bf7804fe5e 100644 (file)
@@ -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 <gtk/gtkvbox.h>
 #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 :
index b3c775c372c96fe53019ae2150b6cf72483d02d7..4b7771e630b4c2397dfcc8315810828fb00f7bcd 100644 (file)
@@ -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));
 }
index 854f6303de0fc9a7211b04aaee1e5b6489c6f2c0..174b071f972680d3a55be23dacd430500e3b1ecf 100644 (file)
@@ -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;
 }
index de358d5aca38dd6fee1e7accb4882e01e921771b..df8819bc961e13e1ecb5dcdb817fee4b30e2c71f 100644 (file)
@@ -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 <glib/gtypes.h>
 #include <gtk/gtktooltips.h>
@@ -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: