Merge branch 'wip/static-colors'

* wip/static-colors:
  Move tests to static colors where possible
  color: Add named, global colors
This commit is contained in:
Emmanuele Bassi 2010-11-11 17:53:42 +00:00
commit dfdd591414
18 changed files with 320 additions and 84 deletions

View File

@ -86,6 +86,7 @@ source_h = \
$(srcdir)/clutter-child-meta.h \
$(srcdir)/clutter-click-action.h \
$(srcdir)/clutter-clone.h \
$(srcdir)/clutter-color-static.h \
$(srcdir)/clutter-color.h \
$(srcdir)/clutter-colorize-effect.h \
$(srcdir)/clutter-constraint.h \

View File

@ -0,0 +1,77 @@
/*
* Clutter.
*
* An OpenGL based 'interactive canvas' library.
*
* Copyright (C) 2010 Intel Corporation.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see <http://www.gnu.org/licenses/>.
*/
#if !defined(__CLUTTER_H_INSIDE__) && !defined(CLUTTER_COMPILATION)
#error "Only <clutter/clutter.h> can be included directly."
#endif
#ifndef __CLUTTER_COLOR_STATIC_H__
#define __CLUTTER_COLOR_STATIC_H__
#define CLUTTER_COLOR_White (clutter_color_get_static (CLUTTER_COLOR_WHITE))
#define CLUTTER_COLOR_Black (clutter_color_get_static (CLUTTER_COLOR_BLACK))
#define CLUTTER_COLOR_Red (clutter_color_get_static (CLUTTER_COLOR_RED))
#define CLUTTER_COLOR_DarkRed (clutter_color_get_static (CLUTTER_COLOR_DARK_RED))
#define CLUTTER_COLOR_Green (clutter_color_get_static (CLUTTER_COLOR_GREEN))
#define CLUTTER_COLOR_DarkGreen (clutter_color_get_static (CLUTTER_COLOR_DARK_GREEN))
#define CLUTTER_COLOR_Blue (clutter_color_get_static (CLUTTER_COLOR_BLUE))
#define CLUTTER_COLOR_DarkBlue (clutter_color_get_static (CLUTTER_COLOR_DARK_BLUE))
#define CLUTTER_COLOR_Cyan (clutter_color_get_static (CLUTTER_COLOR_CYAN))
#define CLUTTER_COLOR_DarkCyan (clutter_color_get_static (CLUTTER_COLOR_DARK_CYAN))
#define CLUTTER_COLOR_Magenta (clutter_color_get_static (CLUTTER_COLOR_MAGENTA))
#define CLUTTER_COLOR_DarkMagenta (clutter_color_get_static (CLUTTER_COLOR_DARK_MAGENTA))
#define CLUTTER_COLOR_Yellow (clutter_color_get_static (CLUTTER_COLOR_YELLOW))
#define CLUTTER_COLOR_DarkYellow (clutter_color_get_static (CLUTTER_COLOR_DARK_YELLOW))
#define CLUTTER_COLOR_Gray (clutter_color_get_static (CLUTTER_COLOR_GRAY))
#define CLUTTER_COLOR_DarkGray (clutter_color_get_static (CLUTTER_COLOR_DARK_GRAY))
#define CLUTTER_COLOR_LightGray (clutter_color_get_static (CLUTTER_COLOR_LIGHT_GRAY))
#define CLUTTER_COLOR_Butter (clutter_color_get_static (CLUTTER_COLOR_BUTTER))
#define CLUTTER_COLOR_LightButter (clutter_color_get_static (CLUTTER_COLOR_BUTTER_LIGHT))
#define CLUTTER_COLOR_DarkButter (clutter_color_get_static (CLUTTER_COLOR_BUTTER_DARK))
#define CLUTTER_COLOR_Orange (clutter_color_get_static (CLUTTER_COLOR_ORANGE))
#define CLUTTER_COLOR_LightOrange (clutter_color_get_static (CLUTTER_COLOR_ORANGE_LIGHT))
#define CLUTTER_COLOR_DarkOrange (clutter_color_get_static (CLUTTER_COLOR_ORANGE_DARK))
#define CLUTTER_COLOR_Chocolate (clutter_color_get_static (CLUTTER_COLOR_CHOCOLATE))
#define CLUTTER_COLOR_LightChocolate (clutter_color_get_static (CLUTTER_COLOR_CHOCOLATE_LIGHT))
#define CLUTTER_COLOR_DarkChocolate (clutter_color_get_static (CLUTTER_COLOR_CHOCOLATE_DARK))
#define CLUTTER_COLOR_Chameleon (clutter_color_get_static (CLUTTER_COLOR_CHAMELEON))
#define CLUTTER_COLOR_LightChameleon (clutter_color_get_static (CLUTTER_COLOR_CHAMELEON_LIGHT))
#define CLUTTER_COLOR_DarkChameleon (clutter_color_get_static (CLUTTER_COLOR_CHAMELEON_DARK))
#define CLUTTER_COLOR_SkyBlue (clutter_color_get_static (CLUTTER_COLOR_SKY_BLUE))
#define CLUTTER_COLOR_LightSkyBlue (clutter_color_get_static (CLUTTER_COLOR_SKY_BLUE_LIGHT))
#define CLUTTER_COLOR_DarkSkyBlue (clutter_color_get_static (CLUTTER_COLOR_SKY_BLUE_DARK))
#define CLUTTER_COLOR_Plum (clutter_color_get_static (CLUTTER_COLOR_PLUM))
#define CLUTTER_COLOR_LightPlum (clutter_color_get_static (CLUTTER_COLOR_PLUM_LIGHT))
#define CLUTTER_COLOR_DarkPlum (clutter_color_get_static (CLUTTER_COLOR_PLUM_DARK))
#define CLUTTER_COLOR_ScarletRed (clutter_color_get_static (CLUTTER_COLOR_SCARLET_RED))
#define CLUTTER_COLOR_LightScarletRed (clutter_color_get_static (CLUTTER_COLOR_SCARLET_RED_LIGHT))
#define CLUTTER_COLOR_DarkScarletRed (clutter_color_get_static (CLUTTER_COLOR_SCARLET_RED_DARK))
#define CLUTTER_COLOR_Aluminium1 (clutter_color_get_static (CLUTTER_COLOR_ALUMINIUM_1))
#define CLUTTER_COLOR_Aluminium2 (clutter_color_get_static (CLUTTER_COLOR_ALUMINIUM_2))
#define CLUTTER_COLOR_Aluminium3 (clutter_color_get_static (CLUTTER_COLOR_ALUMINIUM_3))
#define CLUTTER_COLOR_Aluminium4 (clutter_color_get_static (CLUTTER_COLOR_ALUMINIUM_4))
#define CLUTTER_COLOR_Aluminium5 (clutter_color_get_static (CLUTTER_COLOR_ALUMINIUM_5))
#define CLUTTER_COLOR_Aluminium6 (clutter_color_get_static (CLUTTER_COLOR_ALUMINIUM_6))
#define CLUTTER_COLOR_Transparent (clutter_color_get_static (CLUTTER_COLOR_TRANSPARENT))
#endif /* __CLUTTER_COLOR_STATIC_H__ */

View File

@ -47,6 +47,83 @@
#include "clutter-private.h"
#include "clutter-debug.h"
/* XXX - keep in sync with the ClutterStaticColor enumeration order */
static const ClutterColor const static_colors[] = {
/* CGA/EGA color palette */
{ 0xff, 0xff, 0xff, 0xff }, /* white */
{ 0x00, 0x00, 0x00, 0xff }, /* black */
{ 0xff, 0x00, 0x00, 0xff }, /* red */
{ 0x80, 0x00, 0x00, 0xff }, /* dark red */
{ 0x00, 0xff, 0x00, 0xff }, /* green */
{ 0x00, 0x80, 0x00, 0xff }, /* dark green */
{ 0x00, 0x00, 0xff, 0xff }, /* blue */
{ 0x00, 0x00, 0x80, 0xff }, /* dark blue */
{ 0x00, 0xff, 0xff, 0xff }, /* cyan */
{ 0x00, 0x80, 0x80, 0xff }, /* dark cyan */
{ 0xff, 0x00, 0xff, 0xff }, /* magenta */
{ 0x80, 0x00, 0x80, 0xff }, /* dark magenta */
{ 0xff, 0xff, 0x00, 0xff }, /* yellow */
{ 0x80, 0x80, 0x00, 0xff }, /* dark yellow */
{ 0xa0, 0xa0, 0xa4, 0xff }, /* gray */
{ 0x80, 0x80, 0x80, 0xff }, /* dark gray */
{ 0xc0, 0xc0, 0xc0, 0xff }, /* light gray */
/* Tango Icon color palette */
{ 0xed, 0xd4, 0x00, 0xff }, /* butter */
{ 0xfc, 0xe9, 0x4f, 0xff }, /* butter light */
{ 0xc4, 0xa0, 0x00, 0xff }, /* butter dark */
{ 0xf5, 0x79, 0x00, 0xff }, /* orange */
{ 0xfc, 0xaf, 0x3e, 0xff }, /* orange light */
{ 0xce, 0x5c, 0x00, 0xff }, /* orange dark */
{ 0xc1, 0x7d, 0x11, 0xff }, /* chocolate */
{ 0xe9, 0xb9, 0x6e, 0xff }, /* chocolate light */
{ 0x8f, 0x59, 0x02, 0xff }, /* chocolate dark */
{ 0x73, 0xd2, 0x16, 0xff }, /* chameleon */
{ 0x8a, 0xe2, 0x34, 0xff }, /* chameleon light */
{ 0x4e, 0x9a, 0x06, 0xff }, /* chameleon dark */
{ 0x34, 0x65, 0xa4, 0xff }, /* sky blue */
{ 0x72, 0x9f, 0xcf, 0xff }, /* sky blue light */
{ 0x20, 0x4a, 0x87, 0xff }, /* sky blue dark */
{ 0x75, 0x50, 0x7b, 0xff }, /* plum */
{ 0xad, 0x7f, 0xa8, 0xff }, /* plum light */
{ 0x5c, 0x35, 0x66, 0xff }, /* plum dark */
{ 0xcc, 0x00, 0x00, 0xff }, /* scarlet red */
{ 0xef, 0x29, 0x29, 0xff }, /* scarlet red light */
{ 0xa4, 0x00, 0x00, 0xff }, /* scarlet red dark */
{ 0xee, 0xee, 0xec, 0xff }, /* aluminium 1 */
{ 0xd3, 0xd7, 0xcf, 0xff }, /* aluminium 2 */
{ 0xba, 0xbd, 0xb6, 0xff }, /* aluminium 3 */
{ 0x88, 0x8a, 0x85, 0xff }, /* aluminium 4 */
{ 0x55, 0x57, 0x53, 0xff }, /* aluminium 5 */
{ 0x2e, 0x34, 0x36, 0xff }, /* aluminium 6 */
/* last color */
{ 0x00, 0x00, 0x00, 0x00 } /* transparent */
};
/**
* clutter_color_get_static:
* @color: the named global color
*
* Retrieves a static color for the given @color name
*
* Static colors are created by Clutter and are guaranteed to always be
* available and valid
*
* Return value: a pointer to a static color; the returned pointer
* is owned by Clutter and it should never be modified or freed
*
* Since: 1.4
*/
G_CONST_RETURN ClutterColor *
clutter_color_get_static (ClutterStaticColor color)
{
g_return_val_if_fail (color >= CLUTTER_COLOR_WHITE &&
color <= CLUTTER_COLOR_TRANSPARENT, NULL);
return &static_colors[color];
}
/**
* clutter_color_add:
* @a: a #ClutterColor

View File

@ -152,6 +152,113 @@ GParamSpec *clutter_param_spec_color (const gchar *name,
const ClutterColor *default_value,
GParamFlags flags);
/**
* ClutterStaticColor:
* @CLUTTER_COLOR_WHITE: White color (#ffffffff)
* @CLUTTER_COLOR_BLACK: Black color (#000000ff)
* @CLUTTER_COLOR_RED: Red color (#ff0000ff)
* @CLUTTER_COLOR_DARK_RED: Dark red color (#800000ff)
* @CLUTTER_COLOR_GREEN: Green color (#00ff00ff)
* @CLUTTER_COLOR_DARK_GREEN: Dark green color (#008000ff)
* @CLUTTER_COLOR_BLUE: Blue color (#0000ffff)
* @CLUTTER_COLOR_DARK_BLUE: Dark blue color (#000080ff)
* @CLUTTER_COLOR_CYAN: Cyan color (#00ffffff)
* @CLUTTER_COLOR_DARK_CYAN: Dark cyan color (#008080ff)
* @CLUTTER_COLOR_MAGENTA: Magenta color (#ff00ffff)
* @CLUTTER_COLOR_DARK_MAGENTA: Dark magenta color (#800080ff)
* @CLUTTER_COLOR_YELLOW: Yellow color (#ffff00ff)
* @CLUTTER_COLOR_DARK_YELLOW: Dark yellow color (#808000ff)
* @CLUTTER_COLOR_GRAY: Gray color (#a0a0a4ff)
* @CLUTTER_COLOR_DARK_GRAY: Dark Gray color (#808080ff)
* @CLUTTER_COLOR_LIGHT_GRAY: Light gray color (#c0c0c0ff)
* @CLUTTER_COLOR_BUTTER: Butter color (#edd400)
* @CLUTTER_COLOR_BUTTER_LIGHT: Light butter color (#fce94f)
* @CLUTTER_COLOR_BUTTER_DARK: Dark butter color (#c4a000)
* @CLUTTER_COLOR_ORANGE: Orange color (#f57900)
* @CLUTTER_COLOR_ORANGE_LIGHT: Light orange color (#fcaf3f)
* @CLUTTER_COLOR_ORANGE_DARK: Dark orange color (#ce5c00)
* @CLUTTER_COLOR_CHOCOLATE: Chocolate color (#c17d11)
* @CLUTTER_COLOR_CHOCOLATE_LIGHT: Light chocolate color (#e9b96e)
* @CLUTTER_COLOR_CHOCOLATE_DARK: Dark chocolate color (#8f5902)
* @CLUTTER_COLOR_CHAMELEON: Chameleon color (#73d216)
* @CLUTTER_COLOR_CHAMELEON_LIGHT: Light chameleon color (#8ae234)
* @CLUTTER_COLOR_CHAMELEON_DARK: Dark chameleon color (#4e9a06)
* @CLUTTER_COLOR_SKY_BLUE: Sky color (#3465a4)
* @CLUTTER_COLOR_SKY_BLUE_LIGHT: Light sky color (#729fcf)
* @CLUTTER_COLOR_SKY_BLUE_DARK: Dark sky color (#204a87)
* @CLUTTER_COLOR_PLUM: Plum color (#75507b)
* @CLUTTER_COLOR_PLUM_LIGHT: Light plum color (#ad7fa8)
* @CLUTTER_COLOR_PLUM_DARK: Dark plum color (#5c3566)
* @CLUTTER_COLOR_SCARLET_RED: Scarlet red color (#cc0000)
* @CLUTTER_COLOR_SCARLET_RED_LIGHT: Light scarlet red color (#ef2929)
* @CLUTTER_COLOR_SCARLET_RED_DARK: Dark scarlet red color (#a40000)
* @CLUTTER_COLOR_ALUMINIUM_1: Aluminium, first variant (#eeeeec)
* @CLUTTER_COLOR_ALUMINIUM_2: Aluminium, second variant (#d3d7cf)
* @CLUTTER_COLOR_ALUMINIUM_3: Aluminium, third variant (#babdb6)
* @CLUTTER_COLOR_ALUMINIUM_4: Aluminium, fourth variant (#888a85)
* @CLUTTER_COLOR_ALUMINIUM_5: Aluminium, fifth variant (#555753)
* @CLUTTER_COLOR_ALUMINIUM_6: Aluminium, sixth variant (#2e3436)
* @CLUTTER_COLOR_TRANSPARENT: Transparent color (#00000000)
*
* Named colors, for accessing global colors defined by Clutter
*
* Since: 1.4
*/
typedef enum { /*< prefix=CLUTTER_COLOR >*/
/* CGA/EGA-like palette */
CLUTTER_COLOR_WHITE = 0,
CLUTTER_COLOR_BLACK,
CLUTTER_COLOR_RED,
CLUTTER_COLOR_DARK_RED,
CLUTTER_COLOR_GREEN,
CLUTTER_COLOR_DARK_GREEN,
CLUTTER_COLOR_BLUE,
CLUTTER_COLOR_DARK_BLUE,
CLUTTER_COLOR_CYAN,
CLUTTER_COLOR_DARK_CYAN,
CLUTTER_COLOR_MAGENTA,
CLUTTER_COLOR_DARK_MAGENTA,
CLUTTER_COLOR_YELLOW,
CLUTTER_COLOR_DARK_YELLOW,
CLUTTER_COLOR_GRAY,
CLUTTER_COLOR_DARK_GRAY,
CLUTTER_COLOR_LIGHT_GRAY,
/* Tango icon palette */
CLUTTER_COLOR_BUTTER,
CLUTTER_COLOR_BUTTER_LIGHT,
CLUTTER_COLOR_BUTTER_DARK,
CLUTTER_COLOR_ORANGE,
CLUTTER_COLOR_ORANGE_LIGHT,
CLUTTER_COLOR_ORANGE_DARK,
CLUTTER_COLOR_CHOCOLATE,
CLUTTER_COLOR_CHOCOLATE_LIGHT,
CLUTTER_COLOR_CHOCOLATE_DARK,
CLUTTER_COLOR_CHAMELEON,
CLUTTER_COLOR_CHAMELEON_LIGHT,
CLUTTER_COLOR_CHAMELEON_DARK,
CLUTTER_COLOR_SKY_BLUE,
CLUTTER_COLOR_SKY_BLUE_LIGHT,
CLUTTER_COLOR_SKY_BLUE_DARK,
CLUTTER_COLOR_PLUM,
CLUTTER_COLOR_PLUM_LIGHT,
CLUTTER_COLOR_PLUM_DARK,
CLUTTER_COLOR_SCARLET_RED,
CLUTTER_COLOR_SCARLET_RED_LIGHT,
CLUTTER_COLOR_SCARLET_RED_DARK,
CLUTTER_COLOR_ALUMINIUM_1,
CLUTTER_COLOR_ALUMINIUM_2,
CLUTTER_COLOR_ALUMINIUM_3,
CLUTTER_COLOR_ALUMINIUM_4,
CLUTTER_COLOR_ALUMINIUM_5,
CLUTTER_COLOR_ALUMINIUM_6,
/* Fully transparent black */
CLUTTER_COLOR_TRANSPARENT
} ClutterStaticColor;
G_CONST_RETURN ClutterColor *clutter_color_get_static (ClutterStaticColor color);
G_END_DECLS
#endif /* __CLUTTER_COLOR_H__ */

View File

@ -57,6 +57,7 @@
#include "clutter-click-action.h"
#include "clutter-clone.h"
#include "clutter-color.h"
#include "clutter-color-static.h"
#include "clutter-colorize-effect.h"
#include "clutter-constraint.h"
#include "clutter-container.h"

View File

@ -69,6 +69,7 @@ IGNORE_HFILES=\
clutter-actor-private.h \
clutter-backend-private.h \
clutter-bezier.h \
clutter-color-static.h \
clutter-debug.h \
clutter-deprecated.h \
clutter-device-manager-private.h \

View File

@ -960,6 +960,8 @@ clutter_color_copy
clutter_color_free
clutter_color_equal
clutter_color_hash
ClutterStaticColor
clutter_color_get_static
<SUBSECTION>
clutter_color_from_string

View File

@ -10,7 +10,8 @@
typedef struct SuperOH
{
ClutterActor **hand, *bgtex;
ClutterActor **hand;
ClutterActor *bgtex;
ClutterActor *real_hand;
ClutterActor *group;
ClutterActor *stage;
@ -133,7 +134,6 @@ test_actors_main (int argc, char *argv[])
{
ClutterAlpha *alpha;
ClutterActor *stage;
ClutterColor stage_color = { 0x61, 0x64, 0x8c, 0xff };
SuperOH *oh;
gint i;
GError *error;
@ -156,12 +156,13 @@ test_actors_main (int argc, char *argv[])
return EXIT_FAILURE;
}
stage = clutter_stage_get_default ();
stage = clutter_stage_new ();
clutter_actor_set_size (stage, 800, 600);
clutter_actor_set_name (stage, "Default Stage");
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
clutter_stage_set_title (CLUTTER_STAGE (stage), "Clone Test");
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
clutter_stage_set_title (CLUTTER_STAGE (stage), "Actors");
clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_LightSkyBlue);
clutter_stage_set_user_resizable (CLUTTER_STAGE (stage), TRUE);
oh = g_new (SuperOH, 1);

View File

@ -73,9 +73,6 @@ test_behave_main (int argc, char *argv[])
ClutterBehaviour *o_behave, *p_behave;
ClutterActor *stage;
ClutterActor *group, *rect, *hand;
ClutterColor stage_color = { 0xcc, 0xcc, 0xcc, 0xff };
ClutterColor rect_bg_color = { 0x33, 0x22, 0x22, 0xff };
ClutterColor rect_border_color = { 0, 0, 0, 0 };
gchar *file;
int i;
path_t path_type = PATH_POLY;
@ -119,9 +116,11 @@ test_behave_main (int argc, char *argv[])
clutter_init (&argc, &argv);
stage = clutter_stage_get_default ();
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Behaviours");
clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Aluminium2);
clutter_stage_hide_cursor (CLUTTER_STAGE (stage));
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
g_signal_connect (stage, "button-press-event",
G_CALLBACK (button_press_cb),
NULL);
@ -132,9 +131,6 @@ test_behave_main (int argc, char *argv[])
G_CALLBACK (clutter_main_quit),
NULL);
clutter_stage_set_color (CLUTTER_STAGE (stage),
&stage_color);
/* Make a hand */
group = clutter_group_new ();
clutter_container_add_actor (CLUTTER_CONTAINER (stage), group);
@ -155,12 +151,10 @@ test_behave_main (int argc, char *argv[])
clutter_actor_set_size (rect,
clutter_actor_get_width (hand),
clutter_actor_get_height (hand));
clutter_rectangle_set_color (CLUTTER_RECTANGLE (rect),
&rect_bg_color);
clutter_rectangle_set_color (CLUTTER_RECTANGLE (rect), CLUTTER_COLOR_Transparent);
clutter_rectangle_set_border_width (CLUTTER_RECTANGLE (rect), 10);
clutter_color_from_string (&rect_border_color, "DarkSlateGray");
clutter_rectangle_set_border_color (CLUTTER_RECTANGLE (rect),
&rect_border_color);
CLUTTER_COLOR_Chameleon);
clutter_actor_show (rect);
clutter_container_add (CLUTTER_CONTAINER (group), rect, hand, NULL);

View File

@ -245,9 +245,6 @@ G_MODULE_EXPORT int
test_binding_pool_main (int argc, char *argv[])
{
ClutterActor *stage, *key_group;
ClutterColor red_color = { 255, 0, 0, 255 };
ClutterColor green_color = { 0, 255, 0, 255 };
ClutterColor blue_color = { 0, 0, 255, 255 };
gint group_x, group_y;
clutter_init (&argc, &argv);
@ -263,21 +260,21 @@ test_binding_pool_main (int argc, char *argv[])
/* add three rectangles to the key group */
clutter_container_add (CLUTTER_CONTAINER (key_group),
g_object_new (CLUTTER_TYPE_RECTANGLE,
"color", &red_color,
"color", CLUTTER_COLOR_Red,
"width", 50.0,
"height", 50.0,
"x", 0.0,
"y", 0.0,
NULL),
g_object_new (CLUTTER_TYPE_RECTANGLE,
"color", &green_color,
"color", CLUTTER_COLOR_Green,
"width", 50.0,
"height", 50.0,
"x", 75.0,
"y", 0.0,
NULL),
g_object_new (CLUTTER_TYPE_RECTANGLE,
"color", &blue_color,
"color", CLUTTER_COLOR_Blue,
"width", 50.0,
"height", 50.0,
"x", 150.0,

View File

@ -71,10 +71,9 @@ enter_event (ClutterActor *actor,
ClutterEvent *event,
gpointer data)
{
ClutterColor color = { 0x00, 0x00, 0x00, 0xff };
clutter_rectangle_set_border_width (CLUTTER_RECTANGLE (actor), 2);
clutter_rectangle_set_border_color (CLUTTER_RECTANGLE (actor), &color);
clutter_rectangle_set_border_color (CLUTTER_RECTANGLE (actor),
CLUTTER_COLOR_Black);
hover_actor = actor;
}
@ -132,13 +131,14 @@ add_actor (ClutterBoxLayout *layout,
guint index_)
{
ClutterActor *rect;
ClutterColor color = { 0xff, 0xff, 0xff, 255 };
static gboolean expand = TRUE;
ClutterColor color;
clutter_color_from_hls (&color,
g_random_double_range (0.0, 360.0),
0.5,
0.5);
color.alpha = 255;
rect = clutter_rectangle_new_with_color (&color);
clutter_actor_set_size (rect, 32, 64);

View File

@ -75,19 +75,16 @@ static ClutterActor *
janus_group (const gchar *front_text,
const gchar *back_text)
{
ClutterColor slide_color = {0x00, 0x00, 0x00, 0xff};
ClutterColor red = {0xff, 0x00, 0x00, 0xff};
ClutterColor green = {0x00, 0xff, 0x00, 0xff};
ClutterActor *group, *rectangle, *front, *back;
gfloat width, height;
gfloat width2, height2;
group = clutter_group_new ();
rectangle = clutter_rectangle_new_with_color (&slide_color);
rectangle = clutter_rectangle_new_with_color (CLUTTER_COLOR_White);
front = clutter_text_new_with_text ("Sans 50px", front_text);
back = clutter_text_new_with_text ("Sans 50px", back_text);
clutter_text_set_color (CLUTTER_TEXT (front), &red);
clutter_text_set_color (CLUTTER_TEXT (back), &green);
clutter_text_set_color (CLUTTER_TEXT (front), CLUTTER_COLOR_Red);
clutter_text_set_color (CLUTTER_TEXT (back), CLUTTER_COLOR_Green);
clutter_actor_get_size (front, &width, &height);
clutter_actor_get_size (back, &width2, &height2);
@ -117,22 +114,22 @@ test_depth_main (int argc, char *argv[])
ClutterBehaviour *r_behave;
ClutterActor *stage;
ClutterActor *group, *hand, *label, *rect, *janus, *box;
ClutterColor stage_color = { 0xcc, 0xcc, 0xcc, 0xff };
ClutterColor rect_color = { 0, 0, 0, 0x88 };
GError *error;
clutter_init (&argc, &argv);
stage = clutter_stage_get_default ();
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Depth Test");
clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Aluminium2);
g_signal_connect (stage,
"destroy", G_CALLBACK (clutter_main_quit),
NULL);
g_signal_connect (stage,
"button-press-event", G_CALLBACK (clutter_main_quit),
NULL);
group = clutter_group_new ();
clutter_stage_add (stage, group);
clutter_actor_show (group);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), group);
label = clutter_text_new_with_text ("Mono 26", "Clutter");
clutter_actor_set_position (label, 120, 200);
@ -148,9 +145,10 @@ test_depth_main (int argc, char *argv[])
clutter_actor_set_position (hand, 240, 100);
clutter_actor_show (hand);
rect = clutter_rectangle_new_with_color (&rect_color);
rect = clutter_rectangle_new_with_color (CLUTTER_COLOR_Black);
clutter_actor_set_position (rect, 340, 100);
clutter_actor_set_size (rect, 200, 200);
clutter_actor_set_opacity (rect, 128);
clutter_actor_show (rect);
clutter_container_add (CLUTTER_CONTAINER (group), hand, rect, NULL);

View File

@ -37,13 +37,12 @@ on_drag_begin (ClutterDragAction *action,
if (is_copy)
{
ClutterActor *stage = clutter_actor_get_stage (actor);
ClutterColor handle_color;
drag_handle = clutter_rectangle_new ();
clutter_actor_set_size (drag_handle, 48, 48);
clutter_color_from_string (&handle_color, "#204a87aa");
clutter_rectangle_set_color (CLUTTER_RECTANGLE (drag_handle), &handle_color);
clutter_rectangle_set_color (CLUTTER_RECTANGLE (drag_handle),
CLUTTER_COLOR_DarkSkyBlue);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), drag_handle);
clutter_actor_set_position (drag_handle, event_x, event_y);
@ -154,7 +153,6 @@ test_drag_main (int argc, char *argv[])
{
ClutterActor *stage, *handle;
ClutterAction *action;
ClutterColor handle_color;
GError *error;
error = NULL;
@ -176,10 +174,9 @@ test_drag_main (int argc, char *argv[])
clutter_actor_set_size (stage, 800, 600);
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
clutter_color_from_string (&handle_color, "#729fcfff");
handle = clutter_rectangle_new ();
clutter_rectangle_set_color (CLUTTER_RECTANGLE (handle), &handle_color);
clutter_rectangle_set_color (CLUTTER_RECTANGLE (handle),
CLUTTER_COLOR_SkyBlue);
clutter_actor_set_size (handle, 128, 128);
clutter_actor_set_position (handle, (800 - 128) / 2, (600 - 128) / 2);
clutter_actor_set_reactive (handle, TRUE);

View File

@ -566,8 +566,6 @@ static ClutterActor *icon = NULL;
static ClutterTimeline *main_timeline = NULL;
static ClutterBehaviour *behaviour = NULL;
static ClutterColor bg_color;
static void
toggle_property_value (ClutterActor *actor,
const gchar *property_name)
@ -752,8 +750,6 @@ test_layout_main (int argc, char *argv[])
stage = clutter_stage_get_default ();
clutter_actor_set_size (stage, 800, 600);
clutter_color_from_string (&bg_color, "Red");
main_timeline = clutter_timeline_new (2000);
clutter_timeline_set_loop (main_timeline, TRUE);
g_signal_connect (main_timeline, "new-frame",

View File

@ -22,20 +22,15 @@ on_button_press (ClutterActor *actor,
ClutterActor *label, *tex;
gint width, height;
gchar *stage_label, *win_title;
ClutterColor color = { 0xdd, 0x33, 0xdd, 0xff };
ClutterColor white = { 0x99, 0x99, 0x99, 0xff };
ClutterTimeline *timeline;
ClutterAlpha *alpha;
ClutterBehaviour *r_behave;
new_stage = clutter_stage_new ();
if (!new_stage)
if (new_stage == NULL)
return FALSE;
/* FIXME: below should really be automatic */
/* clutter_stage_ensure_cogl_context (CLUTTER_STAGE(new_stage)); */
clutter_stage_set_color (CLUTTER_STAGE (new_stage), &color);
clutter_stage_set_color (CLUTTER_STAGE (new_stage), CLUTTER_COLOR_DarkScarletRed);
clutter_actor_set_size (new_stage, 320, 240);
tex = clutter_texture_new_from_file (TESTS_DATADIR
@ -55,7 +50,7 @@ on_button_press (ClutterActor *actor,
stage_label = g_strdup_printf ("<b>Stage: %d</b>", ++n_stages);
label = clutter_text_new_with_text ("Mono 12", stage_label);
clutter_text_set_color (CLUTTER_TEXT (label), &white);
clutter_text_set_color (CLUTTER_TEXT (label), CLUTTER_COLOR_White);
clutter_text_set_use_markup (CLUTTER_TEXT (label), TRUE);
width = (clutter_actor_get_width (new_stage)
- clutter_actor_get_width (label)) / 2;

View File

@ -15,8 +15,6 @@ test_rotate_main (int argc, char *argv[])
ClutterBehaviour *r_behave;
ClutterActor *stage;
ClutterActor *hand, *label, *rect;
ClutterColor stage_color = { 0xcc, 0xcc, 0xcc, 0xff };
ClutterColor rect_color;
gchar *file;
clutter_init (&argc, &argv);
@ -25,10 +23,10 @@ test_rotate_main (int argc, char *argv[])
timeline = clutter_timeline_new (7692);
clutter_timeline_set_loop (timeline, TRUE);
stage = clutter_stage_get_default ();
clutter_stage_set_color (CLUTTER_STAGE (stage),
&stage_color);
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Rotations");
clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Aluminium3);
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
/* Make a hand */
file = g_build_filename (TESTS_DATADIR, "redhand.png", NULL);
@ -38,8 +36,7 @@ test_rotate_main (int argc, char *argv[])
g_free (file);
clutter_color_from_string (&rect_color, "#ce5c00ff");
rect = clutter_rectangle_new_with_color (&rect_color);
rect = clutter_rectangle_new_with_color (CLUTTER_COLOR_DarkOrange);
clutter_actor_add_effect_with_name (rect, "blur", clutter_blur_effect_new ());
clutter_actor_set_position (rect, 340, 140);
clutter_actor_set_size (rect, 150, 150);

View File

@ -39,7 +39,6 @@ G_MODULE_EXPORT int
test_stage_sizing_main (int argc, char *argv[])
{
gfloat width;
ClutterColor color;
ClutterActor *stage, *rect, *label;
clutter_init (&argc, &argv);
@ -47,8 +46,7 @@ test_stage_sizing_main (int argc, char *argv[])
stage = clutter_stage_get_default ();
label = clutter_text_new_with_text ("Sans 16", "Toggle fullscreen");
clutter_color_from_string (&color, "light red");
rect = clutter_rectangle_new_with_color (&color);
rect = clutter_rectangle_new_with_color (CLUTTER_COLOR_LightScarletRed);
clutter_actor_set_size (rect,
clutter_actor_get_width (label) + 20,
clutter_actor_get_height (label) + 20);
@ -60,8 +58,7 @@ test_stage_sizing_main (int argc, char *argv[])
width = clutter_actor_get_width (rect);
label = clutter_text_new_with_text ("Sans 16", "Toggle resizable");
clutter_color_from_string (&color, "light green");
rect = clutter_rectangle_new_with_color (&color);
rect = clutter_rectangle_new_with_color (CLUTTER_COLOR_Chameleon);
clutter_actor_set_size (rect,
clutter_actor_get_width (label) + 20,
clutter_actor_get_height (label) + 20);
@ -74,8 +71,7 @@ test_stage_sizing_main (int argc, char *argv[])
width += clutter_actor_get_width (rect);
label = clutter_text_new_with_text ("Sans 16", "Shrink");
clutter_color_from_string (&color, "light blue");
rect = clutter_rectangle_new_with_color (&color);
rect = clutter_rectangle_new_with_color (CLUTTER_COLOR_SkyBlue);
clutter_actor_set_size (rect,
clutter_actor_get_width (label) + 20,
clutter_actor_get_height (label) + 20);
@ -88,8 +84,7 @@ test_stage_sizing_main (int argc, char *argv[])
width += clutter_actor_get_width (rect);
label = clutter_text_new_with_text ("Sans 16", "Expand");
clutter_color_from_string (&color, "light yellow");
rect = clutter_rectangle_new_with_color (&color);
rect = clutter_rectangle_new_with_color (CLUTTER_COLOR_Butter);
clutter_actor_set_size (rect,
clutter_actor_get_width (label) + 20,
clutter_actor_get_height (label) + 20);

View File

@ -179,9 +179,6 @@ test_threads_main (int argc, char *argv[])
{
ClutterActor *stage;
ClutterActor *rect;
ClutterColor stage_color = { 0xcc, 0xcc, 0xcc, 0xff };
ClutterColor rect_color = { 0xee, 0x55, 0x55, 0x99 };
ClutterColor progress_color = { 0x55, 0xee, 0x55, 0xbb };
ClutterBehaviour *r_behaviour, *p_behaviour;
ClutterAlpha *alpha;
const ClutterKnot knots[] = {
@ -193,9 +190,11 @@ test_threads_main (int argc, char *argv[])
clutter_threads_init ();
clutter_init (&argc, &argv);
stage = clutter_stage_get_default ();
clutter_stage_set_color (CLUTTER_STAGE (stage), &stage_color);
stage = clutter_stage_new ();
clutter_stage_set_title (CLUTTER_STAGE (stage), "Threading");
clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_Aluminium3);
clutter_actor_set_size (stage, 600, 300);
g_signal_connect (stage, "destroy", G_CALLBACK (clutter_main_quit), NULL);
count_label = clutter_text_new_with_text ("Mono 12", "Counter");
clutter_actor_set_position (count_label, 350, 50);
@ -203,12 +202,13 @@ test_threads_main (int argc, char *argv[])
help_label = clutter_text_new_with_text ("Mono 12", "Press 's' to start");
clutter_actor_set_position (help_label, 50, 50);
rect = clutter_rectangle_new_with_color (&rect_color);
rect = clutter_rectangle_new_with_color (CLUTTER_COLOR_LightScarletRed);
clutter_actor_set_position (rect, 75, 150);
clutter_actor_set_size (rect, 50, 50);
clutter_actor_set_anchor_point (rect, 25, 25);
clutter_actor_set_opacity (rect, 224);
progress_rect = clutter_rectangle_new_with_color (&progress_color);
progress_rect = clutter_rectangle_new_with_color (CLUTTER_COLOR_DarkChameleon);
clutter_actor_set_position (progress_rect, 50, 225);
clutter_actor_set_size (progress_rect, 350, 50);