mirror of
https://github.com/brl/mutter.git
synced 2024-11-09 23:46:33 -05:00
Update the interactive tests to ClutterText
Instead of using ClutterLabel, use ClutterText to display some text where needed.
This commit is contained in:
parent
24a6163688
commit
5c14044e52
@ -305,8 +305,8 @@ test_clip_main (int argc, char **argv)
|
||||
data.hand = cogl_texture_new_from_file ("redhand.png", 64, FALSE,
|
||||
COGL_PIXEL_FORMAT_ANY, NULL);
|
||||
|
||||
label = clutter_label_new_with_text ("Sans 12px", instructions);
|
||||
clutter_label_set_line_wrap (CLUTTER_LABEL (label), TRUE);
|
||||
label = clutter_text_new_with_text ("Sans 12px", instructions);
|
||||
clutter_text_set_line_wrap (CLUTTER_TEXT (label), TRUE);
|
||||
clutter_actor_set_width (label, clutter_actor_get_width (data.stage) - 310);
|
||||
clutter_actor_set_y (label,
|
||||
clutter_actor_get_height (data.stage)
|
||||
|
@ -297,16 +297,16 @@ frame_cb (ClutterTimeline *timeline,
|
||||
}
|
||||
|
||||
static void
|
||||
update_toggle_text (ClutterLabel *button, gboolean val)
|
||||
update_toggle_text (ClutterText *button, gboolean val)
|
||||
{
|
||||
clutter_label_set_text (button, val ? "Enabled" : "Disabled");
|
||||
clutter_text_set_text (button, val ? "Enabled" : "Disabled");
|
||||
}
|
||||
|
||||
static gboolean
|
||||
on_toggle_click (ClutterActor *button, ClutterEvent *event,
|
||||
gboolean *toggle_val)
|
||||
{
|
||||
update_toggle_text (CLUTTER_LABEL (button), *toggle_val = !*toggle_val);
|
||||
update_toggle_text (CLUTTER_TEXT (button), *toggle_val = !*toggle_val);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@ -315,12 +315,12 @@ static ClutterActor *
|
||||
make_toggle (const char *label_text, gboolean *toggle_val)
|
||||
{
|
||||
ClutterActor *group = clutter_group_new ();
|
||||
ClutterActor *label = clutter_label_new_with_text ("Sans 14", label_text);
|
||||
ClutterActor *button = clutter_label_new_with_text ("Sans 14", "");
|
||||
ClutterActor *label = clutter_text_new_with_text ("Sans 14", label_text);
|
||||
ClutterActor *button = clutter_text_new_with_text ("Sans 14", "");
|
||||
|
||||
clutter_actor_set_reactive (button, TRUE);
|
||||
|
||||
update_toggle_text (CLUTTER_LABEL (button), *toggle_val);
|
||||
update_toggle_text (CLUTTER_TEXT (button), *toggle_val);
|
||||
|
||||
clutter_actor_set_position (button, clutter_actor_get_width (label) + 10, 0);
|
||||
clutter_container_add (CLUTTER_CONTAINER (group), label, button, NULL);
|
||||
@ -373,7 +373,7 @@ test_cogl_tex_polygon_main (int argc, char *argv[])
|
||||
clutter_actor_set_position (filtering_toggle, 0,
|
||||
clutter_actor_get_y (slicing_toggle)
|
||||
- clutter_actor_get_height (filtering_toggle));
|
||||
note = clutter_label_new_with_text ("Sans 10", "<- Click to change");
|
||||
note = clutter_text_new_with_text ("Sans 10", "<- Click to change");
|
||||
clutter_actor_set_position (note,
|
||||
clutter_actor_get_width (filtering_toggle) + 10,
|
||||
(clutter_actor_get_height (stage)
|
||||
|
@ -83,10 +83,10 @@ janus_group (const gchar *front_text,
|
||||
|
||||
group = clutter_group_new ();
|
||||
rectangle = clutter_rectangle_new_with_color (&slide_color);
|
||||
front = clutter_label_new_with_text ("Sans 50px", front_text);
|
||||
back = clutter_label_new_with_text ("Sans 50px", back_text);
|
||||
clutter_label_set_color (CLUTTER_LABEL (front), &red);
|
||||
clutter_label_set_color (CLUTTER_LABEL (back), &green);
|
||||
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_actor_get_size (front, &width, &height);
|
||||
clutter_actor_get_size (back, &width2, &height2);
|
||||
@ -134,7 +134,7 @@ test_depth_main (int argc, char *argv[])
|
||||
clutter_stage_add (stage, group);
|
||||
clutter_actor_show (group);
|
||||
|
||||
label = clutter_label_new_with_text ("Mono 26", "Clutter");
|
||||
label = clutter_text_new_with_text ("Mono 26", "Clutter");
|
||||
clutter_actor_set_position (label, 120, 200);
|
||||
clutter_actor_show (label);
|
||||
|
||||
|
@ -41,7 +41,7 @@ on_button_press (ClutterActor *actor,
|
||||
current_mode + 1,
|
||||
n_easing_modes);
|
||||
|
||||
clutter_label_set_text (CLUTTER_LABEL (easing_mode_label), text);
|
||||
clutter_text_set_text (CLUTTER_TEXT (easing_mode_label), text);
|
||||
g_free (text);
|
||||
|
||||
clutter_actor_get_size (main_stage, &stage_width, &stage_height);
|
||||
@ -97,10 +97,10 @@ test_easing_main (int argc, char *argv[])
|
||||
current_mode + 1,
|
||||
n_easing_modes);
|
||||
|
||||
label = clutter_label_new ();
|
||||
label = clutter_text_new ();
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), label);
|
||||
clutter_label_set_font_name (CLUTTER_LABEL (label), "Sans 18px");
|
||||
clutter_label_set_text (CLUTTER_LABEL (label), text);
|
||||
clutter_text_set_font_name (CLUTTER_TEXT (label), "Sans 18px");
|
||||
clutter_text_set_text (CLUTTER_TEXT (label), text);
|
||||
clutter_actor_get_size (label, &label_width, &label_height);
|
||||
clutter_actor_set_position (label,
|
||||
stage_width - label_width - 10,
|
||||
|
@ -43,9 +43,9 @@ make_source(void)
|
||||
|
||||
clutter_group_add (source, actor);
|
||||
|
||||
actor = clutter_label_new_with_text ("Sans Bold 50px", "Clutter");
|
||||
actor = clutter_text_new_with_text ("Sans Bold 50px", "Clutter");
|
||||
|
||||
clutter_label_set_color (CLUTTER_LABEL (actor), &yellow);
|
||||
clutter_text_set_color (CLUTTER_TEXT (actor), &yellow);
|
||||
clutter_actor_set_y (actor, clutter_actor_get_height(source) + 5);
|
||||
clutter_group_add (source, actor);
|
||||
|
||||
|
@ -787,7 +787,7 @@ test_layout_main (int argc, char *argv[])
|
||||
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), box);
|
||||
|
||||
instructions = clutter_label_new_with_text ("Sans 14",
|
||||
instructions = clutter_text_new_with_text ("Sans 14",
|
||||
"<b>Instructions:</b>\n"
|
||||
"a - add a new item\n"
|
||||
"d - remove last item\n"
|
||||
@ -799,7 +799,7 @@ test_layout_main (int argc, char *argv[])
|
||||
"s - use transformed box\n"
|
||||
"q - quit");
|
||||
|
||||
clutter_label_set_use_markup (CLUTTER_LABEL (instructions), TRUE);
|
||||
clutter_text_set_use_markup (CLUTTER_TEXT (instructions), TRUE);
|
||||
clutter_actor_set_position (instructions, 450, 10);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), instructions);
|
||||
|
||||
|
@ -50,10 +50,10 @@ on_button_press (ClutterActor *actor,
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (new_stage), tex);
|
||||
|
||||
stage_label = g_strdup_printf ("<b>Stage: %d</b>", ++n_stages);
|
||||
label = clutter_label_new_with_text ("Mono 12", stage_label);
|
||||
label = clutter_text_new_with_text ("Mono 12", stage_label);
|
||||
|
||||
clutter_label_set_color (CLUTTER_LABEL (label), &white);
|
||||
clutter_label_set_use_markup (CLUTTER_LABEL (label), TRUE);
|
||||
clutter_text_set_color (CLUTTER_TEXT (label), &white);
|
||||
clutter_text_set_use_markup (CLUTTER_TEXT (label), TRUE);
|
||||
width = (clutter_actor_get_width (new_stage)
|
||||
- clutter_actor_get_width (label)) / 2;
|
||||
height = (clutter_actor_get_height (new_stage)
|
||||
@ -110,7 +110,7 @@ test_multistage_main (int argc, char *argv[])
|
||||
G_CALLBACK (on_button_press),
|
||||
NULL);
|
||||
|
||||
label = clutter_label_new_with_text ("Mono 16", "Default stage");
|
||||
label = clutter_text_new_with_text ("Mono 16", "Default stage");
|
||||
width = (clutter_actor_get_width (stage_default)
|
||||
- clutter_actor_get_width (label))
|
||||
/ 2;
|
||||
|
@ -224,8 +224,8 @@ test_project_main (int argc, char *argv[])
|
||||
clutter_actor_set_rotation (rect, CLUTTER_Y_AXIS, 60, 0, 0, 0);
|
||||
clutter_group_add (CLUTTER_GROUP (main_stage), rect);
|
||||
|
||||
label = clutter_label_new_with_text ("Mono 8pt", "Drag the blue rectangles");
|
||||
clutter_label_set_color (CLUTTER_LABEL (label), &white);
|
||||
label = clutter_text_new_with_text ("Mono 8pt", "Drag the blue rectangles");
|
||||
clutter_text_set_color (CLUTTER_TEXT (label), &white);
|
||||
|
||||
clutter_actor_set_position (label, 10, 10);
|
||||
clutter_group_add (CLUTTER_GROUP (main_stage), label);
|
||||
|
@ -45,7 +45,7 @@ on_idle (gpointer data)
|
||||
font_names[rand () % FONT_NAME_COUNT],
|
||||
rand () % (MAX_FONT_SIZE - MIN_FONT_SIZE) + MIN_FONT_SIZE);
|
||||
|
||||
label = clutter_label_new_with_text (font_name, text);
|
||||
label = clutter_text_new_with_text (font_name, text);
|
||||
|
||||
if (clutter_actor_get_height (label) > line_height)
|
||||
line_height = clutter_actor_get_height (label);
|
||||
|
@ -33,8 +33,8 @@ test_rotate_main (int argc, char *argv[])
|
||||
clutter_actor_show (hand);
|
||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), hand);
|
||||
|
||||
label = clutter_label_new_with_text ("Mono 16", "The Wonder of the Spinning Hand");
|
||||
clutter_label_set_alignment (CLUTTER_LABEL (label), PANGO_ALIGN_CENTER);
|
||||
label = clutter_text_new_with_text ("Mono 16", "The Wonder of the Spinning Hand");
|
||||
clutter_text_set_alignment (CLUTTER_TEXT (label), PANGO_ALIGN_CENTER);
|
||||
clutter_actor_set_position (label, 150, 150);
|
||||
clutter_actor_set_size (label, 500, 100);
|
||||
clutter_actor_show (label);
|
||||
|
@ -354,7 +354,7 @@ test_shader_main (gint argc, gchar *argv[])
|
||||
if (!child2)
|
||||
g_error("pixbuf load failed: %s", error ? error->message : "Unknown");
|
||||
child3 = clutter_rectangle_new ();
|
||||
child4 = clutter_label_new_with_text ("Sans 20px", "Shady stuff");
|
||||
child4 = clutter_text_new_with_text ("Sans 20px", "Shady stuff");
|
||||
|
||||
clutter_rectangle_set_color (child3, &color);
|
||||
clutter_actor_set_size (child3, 50, 50);
|
||||
|
@ -23,14 +23,14 @@ make_label (void)
|
||||
gchar *text;
|
||||
gchar *argv[] = { "ls", "--help", NULL };
|
||||
|
||||
label = clutter_label_new ();
|
||||
clutter_label_set_font_name (CLUTTER_LABEL (label), "Sans 10");
|
||||
label = clutter_text_new ();
|
||||
clutter_text_set_font_name (CLUTTER_TEXT (label), "Sans 10");
|
||||
|
||||
if (g_spawn_sync (NULL, argv, NULL,
|
||||
G_SPAWN_STDERR_TO_DEV_NULL | G_SPAWN_SEARCH_PATH,
|
||||
NULL, NULL, &text, NULL, NULL, NULL))
|
||||
{
|
||||
clutter_label_set_text (CLUTTER_LABEL (label), text);
|
||||
clutter_text_set_text (CLUTTER_TEXT (label), text);
|
||||
g_free (text);
|
||||
}
|
||||
|
||||
|
@ -29,11 +29,10 @@ on_event (ClutterStage *stage,
|
||||
|
||||
actor = clutter_stage_get_actor_at_pos (stage, x, y);
|
||||
|
||||
|
||||
if (clutter_actor_transform_stage_point (actor,
|
||||
CLUTTER_UNITS_FROM_DEVICE (x),
|
||||
CLUTTER_UNITS_FROM_DEVICE (y),
|
||||
&xu2, &yu2))
|
||||
CLUTTER_UNITS_FROM_DEVICE (x),
|
||||
CLUTTER_UNITS_FROM_DEVICE (y),
|
||||
&xu2, &yu2))
|
||||
{
|
||||
gchar *txt;
|
||||
|
||||
@ -52,12 +51,11 @@ on_event (ClutterStage *stage,
|
||||
CLUTTER_UNITS_TO_DEVICE (xu2),
|
||||
CLUTTER_UNITS_TO_DEVICE (yu2));
|
||||
|
||||
clutter_label_set_text (CLUTTER_LABEL (label), txt);
|
||||
clutter_text_set_text (CLUTTER_TEXT (label), txt);
|
||||
g_free (txt);
|
||||
}
|
||||
else
|
||||
clutter_label_set_text (CLUTTER_LABEL (label),
|
||||
"Unprojection failed.");
|
||||
clutter_text_set_text (CLUTTER_TEXT (label), "Unprojection failed.");
|
||||
}
|
||||
break;
|
||||
|
||||
@ -75,9 +73,9 @@ test_unproject_main (int argc, char *argv[])
|
||||
gchar *txt;
|
||||
ClutterActor *rect, *stage, *label0;
|
||||
int i, rotate_x = 0, rotate_y = 60, rotate_z = 0;
|
||||
ClutterColor stage_clr = { 0x0, 0x0, 0x0, 0xff },
|
||||
ClutterColor stage_clr = { 0x0, 0x0, 0x0, 0xff },
|
||||
white = { 0xff, 0xff, 0xff, 0xff },
|
||||
blue = { 0, 0xff, 0xff, 0xff };
|
||||
blue = { 0x0, 0xff, 0xff, 0xff };
|
||||
|
||||
for (i = 0; i < argc; ++i)
|
||||
{
|
||||
@ -95,11 +93,12 @@ test_unproject_main (int argc, char *argv[])
|
||||
}
|
||||
else if (!strncmp (argv[i], "--help", 6))
|
||||
{
|
||||
printf ("%s [--rotage-x=degrees] [--rotage-y=degrees] "
|
||||
"[--rotage-z=degrees]\n",
|
||||
argv[0]);
|
||||
g_print ("%s [--rotage-x=degrees] "
|
||||
"[--rotage-y=degrees] "
|
||||
"[--rotage-z=degrees]\n",
|
||||
argv[0]);
|
||||
|
||||
exit (0);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
@ -124,8 +123,8 @@ test_unproject_main (int argc, char *argv[])
|
||||
RECT_T, RECT_T + RECT_H,
|
||||
rotate_x, rotate_y, rotate_z);
|
||||
|
||||
label0 = clutter_label_new_with_text ("Mono 8pt", txt);
|
||||
clutter_label_set_color (CLUTTER_LABEL (label0), &white);
|
||||
label0 = clutter_text_new_with_text ("Mono 8pt", txt);
|
||||
clutter_text_set_color (CLUTTER_TEXT (label0), &white);
|
||||
|
||||
clutter_actor_set_position (label0, 10, 10);
|
||||
clutter_group_add (CLUTTER_GROUP (stage), label0);
|
||||
@ -133,9 +132,9 @@ test_unproject_main (int argc, char *argv[])
|
||||
g_free (txt);
|
||||
|
||||
label =
|
||||
clutter_label_new_with_text ("Mono 8pt", "Click around!");
|
||||
clutter_text_new_with_text ("Mono 8pt", "Click around!");
|
||||
|
||||
clutter_label_set_color (CLUTTER_LABEL (label), &blue);
|
||||
clutter_text_set_color (CLUTTER_TEXT (label), &blue);
|
||||
|
||||
clutter_actor_set_position (label, 10, 50);
|
||||
clutter_group_add (CLUTTER_GROUP (stage), label);
|
||||
|
Loading…
Reference in New Issue
Block a user