mirror of
https://github.com/brl/mutter.git
synced 2024-11-30 03:50:47 -05:00
[tests] Check em to unit conversion
We should be able to position elements of the stage using em as a unit, and converting values into pixels.
This commit is contained in:
parent
33ef1675f5
commit
e41452fc0c
@ -91,13 +91,19 @@ test_text_field_main (gint argc,
|
|||||||
ClutterColor entry_color = {0x33, 0xff, 0x33, 0xff};
|
ClutterColor entry_color = {0x33, 0xff, 0x33, 0xff};
|
||||||
ClutterColor label_color = {0xff, 0xff, 0xff, 0xff};
|
ClutterColor label_color = {0xff, 0xff, 0xff, 0xff};
|
||||||
ClutterColor background_color = {0x00, 0x00, 0x00, 0xff};
|
ClutterColor background_color = {0x00, 0x00, 0x00, 0xff};
|
||||||
guint width, height;
|
gfloat width, height;
|
||||||
|
gfloat h_padding, v_padding;
|
||||||
|
|
||||||
clutter_init (&argc, &argv);
|
clutter_init (&argc, &argv);
|
||||||
|
|
||||||
stage = clutter_stage_get_default ();
|
stage = clutter_stage_get_default ();
|
||||||
clutter_stage_set_color (CLUTTER_STAGE (stage), &background_color);
|
clutter_stage_set_color (CLUTTER_STAGE (stage), &background_color);
|
||||||
|
|
||||||
|
h_padding = clutter_units_em_for_font (FONT, 2.0); /* 2em */
|
||||||
|
v_padding = clutter_units_em_for_font (FONT, 3.0); /* 3em */
|
||||||
|
|
||||||
|
g_print ("padding: h:%.2f px, v:%.2f px\n", h_padding, v_padding);
|
||||||
|
|
||||||
text = create_label (&label_color, "<b>Input field:</b> ");
|
text = create_label (&label_color, "<b>Input field:</b> ");
|
||||||
clutter_actor_set_position (text, 10, 10);
|
clutter_actor_set_position (text, 10, 10);
|
||||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), text);
|
clutter_container_add_actor (CLUTTER_CONTAINER (stage), text);
|
||||||
@ -106,15 +112,17 @@ test_text_field_main (gint argc,
|
|||||||
height = clutter_actor_get_height (text);
|
height = clutter_actor_get_height (text);
|
||||||
|
|
||||||
text = create_entry (&entry_color, "<i>some</i> text", 0, 0);
|
text = create_entry (&entry_color, "<i>some</i> text", 0, 0);
|
||||||
clutter_actor_set_position (text, width + 10 + 12, 10);
|
clutter_actor_set_position (text, 10 + width + h_padding, 10);
|
||||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), text);
|
clutter_container_add_actor (CLUTTER_CONTAINER (stage), text);
|
||||||
|
|
||||||
text = create_label (&label_color, "<i>A very long password field</i>: ");
|
text = create_label (&label_color, "<i>A very long password field</i>: ");
|
||||||
clutter_actor_set_position (text, 10, height + 12);
|
clutter_actor_set_position (text, 10, height + v_padding);
|
||||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), text);
|
clutter_container_add_actor (CLUTTER_CONTAINER (stage), text);
|
||||||
|
|
||||||
text = create_entry (&entry_color, "password", '*', 8);
|
text = create_entry (&entry_color, "password", '*', 8);
|
||||||
clutter_actor_set_position (text, width + 10 + 12, height + 12);
|
clutter_actor_set_position (text,
|
||||||
|
width + 10 + h_padding,
|
||||||
|
height + 10 + v_padding);
|
||||||
clutter_container_add_actor (CLUTTER_CONTAINER (stage), text);
|
clutter_container_add_actor (CLUTTER_CONTAINER (stage), text);
|
||||||
|
|
||||||
clutter_actor_show (stage);
|
clutter_actor_show (stage);
|
||||||
|
Loading…
Reference in New Issue
Block a user