diff --git a/ChangeLog b/ChangeLog index 5492872e9..f0ed4dcdb 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,23 @@ +2006-12-14 Emmanuele Bassi + + * clutter/clutter-color.h: + * clutter/clutter-color.c: Expose clutter_color_copy() + and clutter_color_free() for the python bindings, so that + they can manager the conversion automatically; use the + slice allocator when copying/freeing a ClutterColor. + +2006-12-13 Emmanuele Bassi + + * clutter/clutter-color.h: + * clutter/clutter-color.c: Add clutter_color_equal(), + a function for comparing two colors. + + * clutter/clutter-rectangle.c: + (clutter_rectangle_set_color), + (clutter_rectangle_set_border_color): Unset the border if + the color of the rectangle and the color of the border are + the same. + 2006-12-13 Emmanuele Bassi * clutter/clutter-actor.c: diff --git a/clutter/clutter-color.c b/clutter/clutter-color.c index afac4eb78..2f600ea01 100644 --- a/clutter/clutter-color.c +++ b/clutter/clutter-color.c @@ -416,16 +416,73 @@ clutter_color_parse (const gchar *color, return FALSE; } -static ClutterColor * -clutter_color_copy (ClutterColor *color) +/** + * clutter_color_equal: + * @a: a #ClutterColor + * @b: a #ClutterColor + * + * Compares two #ClutterColors and checks if they are the same. + * + * Return: %TRUE if the two colors are the same. + * + * Since: 0.2 + */ +gboolean +clutter_color_equal (const ClutterColor *a, + const ClutterColor *b) { - ClutterColor *result = g_new0 (ClutterColor, 1); + g_return_val_if_fail (a != NULL, FALSE); + g_return_val_if_fail (b != NULL, FALSE); + if (a == b) + return TRUE; + + return (a->red == b->red && + a->green == b->green && + a->blue == b->blue && + a->alpha == b->alpha); +} + +/** + * clutter_color_copy: + * @color: a #ClutterColor + * + * Makes a copy of the color structure. The result must be + * freed using clutter_color_free(). + * + * Return value: an allocated copy of @color. + * + * Since: 0.2 + */ +ClutterColor * +clutter_color_copy (const ClutterColor *color) +{ + ClutterColor *result; + + g_return_val_if_fail (color != NULL, NULL); + + result = g_slice_new (ClutterColor); *result = *color; return result; } +/** + * clutter_color_free: + * @color: a #ClutterColor + * + * Frees a color structure created with clutter_color_copy(). + * + * Since: 0.2 + */ +void +clutter_color_free (ClutterColor *color) +{ + g_return_if_fail (color != NULL); + + g_slice_free (ClutterColor, color); +} + GType clutter_color_get_type (void) { @@ -434,6 +491,6 @@ clutter_color_get_type (void) if (!our_type) our_type = g_boxed_type_register_static ("ClutterColor", (GBoxedCopyFunc) clutter_color_copy, - (GBoxedFreeFunc) g_free); + (GBoxedFreeFunc) clutter_color_free); return our_type; } diff --git a/clutter/clutter-color.h b/clutter/clutter-color.h index c927a2b3f..2a128edb4 100644 --- a/clutter/clutter-color.h +++ b/clutter/clutter-color.h @@ -43,37 +43,42 @@ struct _ClutterColor guint8 alpha; }; -GType clutter_color_get_type (void) G_GNUC_CONST; +ClutterColor *clutter_color_copy (const ClutterColor *color); +void clutter_color_free (ClutterColor *color); +gboolean clutter_color_parse (const gchar *color, + ClutterColor *dest); +gboolean clutter_color_equal (const ClutterColor *a, + const ClutterColor *b); -gboolean clutter_color_parse (const gchar *color, - ClutterColor *dest); -void clutter_color_add (const ClutterColor *src1, - const ClutterColor *src2, - ClutterColor *dest); -void clutter_color_subtract (const ClutterColor *src1, - const ClutterColor *src2, - ClutterColor *dest); +GType clutter_color_get_type (void) G_GNUC_CONST; -void clutter_color_lighten (const ClutterColor *src, - ClutterColor *dest); -void clutter_color_darken (const ClutterColor *src, - ClutterColor *dest); -void clutter_color_shade (const ClutterColor *src, - ClutterColor *dest, - gdouble shade); -void clutter_color_to_hls (const ClutterColor *src, - guint8 *hue, - guint8 *luminance, - guint8 *saturation); -void clutter_color_from_hls (ClutterColor *dest, - guint8 hue, - guint8 luminance, - guint8 saturation); +void clutter_color_add (const ClutterColor *src1, + const ClutterColor *src2, + ClutterColor *dest); +void clutter_color_subtract (const ClutterColor *src1, + const ClutterColor *src2, + ClutterColor *dest); +void clutter_color_lighten (const ClutterColor *src, + ClutterColor *dest); +void clutter_color_darken (const ClutterColor *src, + ClutterColor *dest); +void clutter_color_shade (const ClutterColor *src, + ClutterColor *dest, + gdouble shade); -guint32 clutter_color_to_pixel (const ClutterColor *src); -void clutter_color_from_pixel (ClutterColor *dest, - guint32 pixel); +void clutter_color_to_hls (const ClutterColor *src, + guint8 *hue, + guint8 *luminance, + guint8 *saturation); +void clutter_color_from_hls (ClutterColor *dest, + guint8 hue, + guint8 luminance, + guint8 saturation); + +guint32 clutter_color_to_pixel (const ClutterColor *src); +void clutter_color_from_pixel (ClutterColor *dest, + guint32 pixel); G_END_DECLS diff --git a/clutter/clutter-rectangle.c b/clutter/clutter-rectangle.c index 580b1603d..fac98dbef 100644 --- a/clutter/clutter-rectangle.c +++ b/clutter/clutter-rectangle.c @@ -377,10 +377,16 @@ clutter_rectangle_set_color (ClutterRectangle *rectangle, clutter_actor_set_opacity (CLUTTER_ACTOR (rectangle), priv->color.alpha); + if (clutter_color_equal (&priv->color, &priv->border_color)) + priv->has_border = FALSE; + else + priv->has_border = TRUE; + if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR (rectangle))) clutter_actor_queue_redraw (CLUTTER_ACTOR (rectangle)); g_object_notify (G_OBJECT (rectangle), "color"); + g_object_notify (G_OBJECT (rectangle), "has-border"); g_object_unref (rectangle); } @@ -498,10 +504,16 @@ clutter_rectangle_set_border_color (ClutterRectangle *rectangle, priv->border_color.blue = color->blue; priv->border_color.alpha = color->alpha; + if (clutter_color_equal (&priv->color, &priv->border_color)) + priv->has_border = FALSE; + else + priv->has_border = TRUE; + if (CLUTTER_ACTOR_IS_VISIBLE (CLUTTER_ACTOR (rectangle))) clutter_actor_queue_redraw (CLUTTER_ACTOR (rectangle)); g_object_notify (G_OBJECT (rectangle), "border-color"); + g_object_notify (G_OBJECT (rectangle), "has-border"); g_object_unref (rectangle); } } diff --git a/doc/reference/ChangeLog b/doc/reference/ChangeLog index 8e9e6d30f..cb988583f 100644 --- a/doc/reference/ChangeLog +++ b/doc/reference/ChangeLog @@ -1,3 +1,9 @@ +2006-12-13 Emmanuele Bassi + + * clutter-sections.txt: Update; add clutter_color_equal(). + + * tmpl/clutter-color.sgml: Update template. + 2006-12-13 Emmanuele Bassi * clutter-sections.txt: Update. diff --git a/doc/reference/clutter-sections.txt b/doc/reference/clutter-sections.txt index 5a9388939..ef473b584 100644 --- a/doc/reference/clutter-sections.txt +++ b/doc/reference/clutter-sections.txt @@ -466,9 +466,12 @@ CLUTTER_FIXED_DIV
clutter-color ClutterColor +clutter_color_copy +clutter_color_free clutter_color_parse clutter_color_add clutter_color_subtract +clutter_color_equal clutter_color_lighten clutter_color_darken clutter_color_shade @@ -495,12 +498,11 @@ clutter_event_new clutter_event_copy clutter_event_free clutter_event_type -clutter_key_event_type -clutter_key_event_time -clutter_key_event_state clutter_button_event_time clutter_button_event_x clutter_button_event_y +clutter_key_event_time +clutter_key_event_state clutter_key_event_symbol clutter_key_event_code clutter_key_event_unicode diff --git a/doc/reference/tmpl/clutter-actor.sgml b/doc/reference/tmpl/clutter-actor.sgml index 7e057e9a0..481873b2d 100644 --- a/doc/reference/tmpl/clutter-actor.sgml +++ b/doc/reference/tmpl/clutter-actor.sgml @@ -22,7 +22,7 @@ ClutterActor Sets a flag from #ClutterActorFlags to an actor -@e: a #ClutterActor +@e: a #ClutterActor @f: the flag to set diff --git a/doc/reference/tmpl/clutter-color.sgml b/doc/reference/tmpl/clutter-color.sgml index 16e48f8d5..538c2dbdd 100644 --- a/doc/reference/tmpl/clutter-color.sgml +++ b/doc/reference/tmpl/clutter-color.sgml @@ -27,6 +27,23 @@ clutter-color @blue: @alpha: + + + + + +@color: +@Returns: + + + + + + + +@color: + + @@ -57,6 +74,16 @@ clutter-color @dest: + + + + + +@a: +@b: +@Returns: + + diff --git a/doc/reference/tmpl/clutter-event.sgml b/doc/reference/tmpl/clutter-event.sgml index 8892c104e..0447456af 100644 --- a/doc/reference/tmpl/clutter-event.sgml +++ b/doc/reference/tmpl/clutter-event.sgml @@ -122,24 +122,6 @@ Windowing events handled by Clutter. @Returns: - - - - - -@keyev: -@Returns: - - - - - - - -@keyev: -@Returns: - - @@ -167,6 +149,24 @@ Windowing events handled by Clutter. @Returns: + + + + + +@keyev: +@Returns: + + + + + + + +@keyev: +@Returns: + +