Replace usage of [sg]et_geometry()

The set_geometry() and get_geometry() methods are going to be
deprecated.
This commit is contained in:
Emmanuele Bassi 2011-11-08 14:46:16 +00:00
parent 4fe7a77302
commit 101f39ea92
6 changed files with 38 additions and 45 deletions

View File

@ -700,7 +700,7 @@ set_foreign_window_callback (ClutterActor *actor,
fwd->stage_win32->win_width = fwd->geom.width; fwd->stage_win32->win_width = fwd->geom.width;
fwd->stage_win32->win_height = fwd->geom.height; fwd->stage_win32->win_height = fwd->geom.height;
clutter_actor_set_geometry (actor, &fwd->geom); clutter_actor_set_size (actor, fwd->geom.width, fwd->geom.height);
/* calling this with the stage unrealized will unset the stage /* calling this with the stage unrealized will unset the stage
* from the GL context; once the stage is realized the GL context * from the GL context; once the stage is realized the GL context

View File

@ -1298,7 +1298,7 @@ set_foreign_window_callback (ClutterActor *actor,
fwd->stage_x11->xwin_width = fwd->geom.width; fwd->stage_x11->xwin_width = fwd->geom.width;
fwd->stage_x11->xwin_height = fwd->geom.height; fwd->stage_x11->xwin_height = fwd->geom.height;
clutter_actor_set_geometry (actor, &fwd->geom); clutter_actor_set_size (actor, fwd->geom.width, fwd->geom.height);
if (clutter_stages_by_xid == NULL) if (clutter_stages_by_xid == NULL)
clutter_stages_by_xid = g_hash_table_new (NULL, NULL); clutter_stages_by_xid = g_hash_table_new (NULL, NULL);

View File

@ -29,23 +29,16 @@
#define SIZE 50 #define SIZE 50
#define DEPTH -100 #define DEPTH -100
static const ClutterColor color1 = { 0xff, 0xff, 0x00, 0xff };
static const ClutterColor color2 = { 0x00, 0xff, 0x00, 0xff };
static const ClutterColor color3 = { 0x00, 0x00, 0xff, 0xff };
static const ClutterColor color4 = { 0xff, 0x00, 0xff, 0xff };
int int
main (int argc, char *argv[]) main (int argc, char *argv[])
{ {
ClutterActor *stage = NULL; ClutterActor *stage = NULL;
ClutterColor color = { 0x00, 0x00, 0x00, 0xff };
ClutterActor *button1 = NULL; ClutterActor *button1 = NULL;
ClutterActor *button2 = NULL; ClutterActor *button2 = NULL;
ClutterActor *button3 = NULL; ClutterActor *button3 = NULL;
ClutterActor *button4 = NULL; ClutterActor *button4 = NULL;
ClutterActor *group[4]; ClutterActor *group[4];
ClutterGeometry geom = {0, 0, SIZE, SIZE}; int i = 0;
gint i = 0;
if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS) if (clutter_init (&argc, &argv) != CLUTTER_INIT_SUCCESS)
return 1; return 1;
@ -54,39 +47,34 @@ main (int argc, char *argv[])
stage = clutter_stage_get_default (); stage = clutter_stage_get_default ();
clutter_stage_set_color (CLUTTER_STAGE (stage), &color); clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_White);
clutter_actor_set_size (stage, WIDTH, HEIGHT); clutter_actor_set_size (stage, WIDTH, HEIGHT);
button1 = clutter_rectangle_new_with_color (&color1); button1 = clutter_rectangle_new_with_color (CLUTTER_COLOR_Yellow);
clutter_actor_set_geometry (button1, &geom); clutter_actor_set_size (button1, SIZE, SIZE);
button2 = clutter_rectangle_new_with_color (&color2); button2 = clutter_rectangle_new_with_color (CLUTTER_COLOR_Green);
geom.x = 2*SIZE; clutter_actor_set_position (button2, 2 * SIZE, 0);
geom.y = 0; clutter_actor_set_size (button2, SIZE, SIZE);
clutter_actor_set_geometry (button2, &geom);
geom.x = 0; button3 = clutter_rectangle_new_with_color (CLUTTER_COLOR_Blue);
geom.y = 2*SIZE; clutter_actor_set_position (button3, 0, 2 * SIZE);
button3 = clutter_rectangle_new_with_color (&color3); clutter_actor_set_size (button3, SIZE, SIZE);
clutter_actor_set_geometry (button3, &geom);
clutter_actor_set_depth( button3, DEPTH); clutter_actor_set_depth( button3, DEPTH);
/* a nested hierarchy, to check that the relative positions are /* a nested hierarchy, to check that the relative positions are
computed properly */ computed properly */
geom.x = SIZE/2; button4 = clutter_rectangle_new_with_color (CLUTTER_COLOR_Magenta);
geom.y = SIZE/2; clutter_actor_set_position (button4, SIZE / 2, SIZE / 2);
button4 = clutter_rectangle_new_with_color (&color4); clutter_actor_set_size (button4, SIZE, SIZE);
clutter_actor_set_geometry (button4, &geom);
clutter_actor_show (button4);
for (i = 0; i < 4; i++) { for (i = 0; i < 4; i++) {
group[i] = clutter_group_new (); group[i] = clutter_group_new ();
clutter_actor_set_geometry (group[i], &geom); clutter_actor_set_position (group[i], SIZE / 2, SIZE / 2);
clutter_actor_set_size (group[i], SIZE, SIZE);
if (i > 0) if (i > 0)
clutter_container_add_actor (CLUTTER_CONTAINER (group[i]), group [i - 1]); clutter_container_add_actor (CLUTTER_CONTAINER (group[i]), group [i - 1]);
clutter_actor_show_all (group[i]);
} }
clutter_container_add_actor (CLUTTER_CONTAINER (stage), button1); clutter_container_add_actor (CLUTTER_CONTAINER (stage), button1);
@ -95,7 +83,7 @@ main (int argc, char *argv[])
clutter_container_add_actor (CLUTTER_CONTAINER (stage), group[3]); clutter_container_add_actor (CLUTTER_CONTAINER (stage), group[3]);
clutter_container_add_actor (CLUTTER_CONTAINER (group[0]), button4); clutter_container_add_actor (CLUTTER_CONTAINER (group[0]), button4);
clutter_actor_show_all (stage); clutter_actor_show (stage);
clutter_main (); clutter_main ();

View File

@ -88,31 +88,32 @@ make_ui (ClutterActor *stage)
ClutterActor *editable = NULL; ClutterActor *editable = NULL;
ClutterActor *rectangle = NULL; ClutterActor *rectangle = NULL;
ClutterActor *label = NULL; ClutterActor *label = NULL;
ClutterColor color_stage = { 0x00, 0x00, 0x00, 0xff };
ClutterColor color_text = { 0xff, 0x00, 0x00, 0xff }; ClutterColor color_text = { 0xff, 0x00, 0x00, 0xff };
ClutterColor color_sel = { 0x00, 0xff, 0x00, 0x55 }; ClutterColor color_sel = { 0x00, 0xff, 0x00, 0x55 };
ClutterColor color_label = { 0x00, 0xff, 0x55, 0xff }; ClutterColor color_label = { 0x00, 0xff, 0x55, 0xff };
ClutterColor color_rect = { 0x00, 0xff, 0xff, 0x55 }; ClutterColor color_rect = { 0x00, 0xff, 0xff, 0x55 };
ClutterGeometry label_geom = {0, 50, -1, -1}; float label_geom_y, editable_geom_y;
ClutterGeometry editable_geom = {150, 50, 500, 75};
clutter_stage_set_color (CLUTTER_STAGE (stage), CLUTTER_COLOR_White);
clutter_stage_set_color (CLUTTER_STAGE (stage), &color_stage);
clutter_actor_set_size (stage, WIDTH, HEIGHT); clutter_actor_set_size (stage, WIDTH, HEIGHT);
label_geom_y = 50;
editable_geom_y = 50;
for (i = 0; i < NUM_ENTRIES; i++) for (i = 0; i < NUM_ENTRIES; i++)
{ {
/* label */ /* label */
label = clutter_text_new_full ("Sans Bold 32px", label = clutter_text_new_full ("Sans Bold 32px",
"Entry", "Entry",
&color_label); &color_label);
clutter_actor_set_geometry (label, &label_geom); clutter_actor_set_position (label, 0, label_geom_y);
/* editable */ /* editable */
editable = clutter_text_new_full ("Sans Bold 32px", editable = clutter_text_new_full ("Sans Bold 32px",
"ddd", "ddd",
&color_text); &color_text);
clutter_actor_set_geometry (editable, &editable_geom); clutter_actor_set_position (editable, 150, editable_geom_y);
clutter_actor_set_size (editable, 500, 75);
clutter_text_set_editable (CLUTTER_TEXT (editable), TRUE); clutter_text_set_editable (CLUTTER_TEXT (editable), TRUE);
clutter_text_set_selectable (CLUTTER_TEXT (editable), TRUE); clutter_text_set_selectable (CLUTTER_TEXT (editable), TRUE);
clutter_text_set_selection_color (CLUTTER_TEXT (editable), clutter_text_set_selection_color (CLUTTER_TEXT (editable),
@ -122,14 +123,15 @@ make_ui (ClutterActor *stage)
/* rectangle: to create a entry "feeling" */ /* rectangle: to create a entry "feeling" */
rectangle = clutter_rectangle_new_with_color (&color_rect); rectangle = clutter_rectangle_new_with_color (&color_rect);
clutter_actor_set_geometry (rectangle, &editable_geom); clutter_actor_set_position (rectangle, 150, editable_geom_y);
clutter_actor_set_size (rectangle, 500, 75);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), label); clutter_container_add_actor (CLUTTER_CONTAINER (stage), label);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), editable); clutter_container_add_actor (CLUTTER_CONTAINER (stage), editable);
clutter_container_add_actor (CLUTTER_CONTAINER (stage), rectangle); clutter_container_add_actor (CLUTTER_CONTAINER (stage), rectangle);
label_geom.y += HEIGHT_STEP; label_geom_y += HEIGHT_STEP;
editable_geom.y += HEIGHT_STEP; editable_geom_y += HEIGHT_STEP;
} }
} }

View File

@ -41,7 +41,6 @@ make_ui (ClutterActor *stage)
ClutterColor color_sel = { 0x00, 0xff, 0x00, 0x55 }; ClutterColor color_sel = { 0x00, 0xff, 0x00, 0x55 };
ClutterColor color_label = { 0x00, 0xff, 0x55, 0xff }; ClutterColor color_label = { 0x00, 0xff, 0x55, 0xff };
ClutterColor color_rect = { 0x00, 0xff, 0xff, 0x55 }; ClutterColor color_rect = { 0x00, 0xff, 0xff, 0x55 };
ClutterGeometry editable_geom = {150, 50, 100, 75};
ClutterActor *full_entry = NULL; ClutterActor *full_entry = NULL;
ClutterActor *cloned_entry = NULL; ClutterActor *cloned_entry = NULL;
@ -68,7 +67,8 @@ make_ui (ClutterActor *stage)
/* rectangle: to create a entry "feeling" */ /* rectangle: to create a entry "feeling" */
rectangle = clutter_rectangle_new_with_color (&color_rect); rectangle = clutter_rectangle_new_with_color (&color_rect);
clutter_actor_set_geometry (rectangle, &editable_geom); clutter_actor_set_position (rectangle, 150, 50);
clutter_actor_add_constraint (rectangle, clutter_bind_constraint_new (editable, CLUTTER_BIND_SIZE, 0));
full_entry = clutter_group_new (); full_entry = clutter_group_new ();
clutter_actor_set_position (full_entry, 0, 50); clutter_actor_set_position (full_entry, 0, 50);

View File

@ -251,11 +251,14 @@ actor_picking (void)
ClutterColor color = { x * 255 / (ACTORS_X - 1), ClutterColor color = { x * 255 / (ACTORS_X - 1),
y * 255 / (ACTORS_Y - 1), y * 255 / (ACTORS_Y - 1),
128, 255 }; 128, 255 };
ClutterGeometry geom = { x * state.actor_width, y * state.actor_height,
state.actor_width, state.actor_height };
ClutterActor *rect = clutter_rectangle_new_with_color (&color); ClutterActor *rect = clutter_rectangle_new_with_color (&color);
clutter_actor_set_geometry (rect, &geom); clutter_actor_set_position (rect,
x * state.actor_width,
y * state.actor_height);
clutter_actor_set_size (rect,
state.actor_width,
state.actor_height);
clutter_container_add (CLUTTER_CONTAINER (state.stage), rect, NULL); clutter_container_add (CLUTTER_CONTAINER (state.stage), rect, NULL);