summaryrefslogtreecommitdiff
path: root/edje/part_swallow_geometry.c
blob: 4d726e93beaec3a85af908df48be7860a6e88df3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
 * gcc part_swallow_geometry.c -o part_swallow_geometry `pkg-config --cflags --libs elementary` -g
 */
#include <Elementary.h>

static void
_bg_resize_cb(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
   Evas_Coord x = 0,  y = 0, w = 0, h = 0;
   evas_object_geometry_get(obj, &x, &y, &w, &h);
   printf("[%f] resize: %d,%d %dx%d\n", ecore_loop_time_get(), x, y, w, h);
}

EAPI_MAIN int
elm_main(int argc, char **argv)
{
   Evas_Object *win = NULL, *edje = NULL, *bg = NULL;
   Evas_Coord x = 0,  y = 0, w = 0, h = 0;

   elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);

   win = elm_win_util_standard_add("main", "Main");
   elm_win_autodel_set(win, EINA_TRUE);
   evas_object_resize(win, 300, 400);
   evas_object_show(win);

   edje = edje_object_add(evas_object_evas_get(win));
   edje_object_file_set(edje, "part_swallow_geometry.edj", "main");
   evas_object_size_hint_weight_set(edje, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
   elm_win_resize_object_add(win, edje);
   evas_object_show(edje);

   bg = elm_bg_add(win);
   elm_bg_color_set(bg, 255, 0, 0);
   evas_object_event_callback_add(bg, EVAS_CALLBACK_RESIZE, _bg_resize_cb, NULL);

   //before swallow
   evas_object_geometry_get(bg, &x, &y, &w, &h);
   printf("[%f] before swallow: %d,%d %dx%d\n", ecore_loop_time_get(), x, y, w, h);

   //swallow
   edje_object_part_swallow(edje, "content", bg);

   //after swallow
   evas_object_geometry_get(bg, &x, &y, &w, &h);
   printf("[%f] before swallow: %d,%d %dx%d\n", ecore_loop_time_get(), x, y, w, h);

   edje_object_part_geometry_get(edje, "content", &x, &y, &w, &h);
   printf("[%f] edje part geometry: %d,%d %dx%d\n", ecore_loop_time_get(), x, y, w, h);

   //text set
   edje_object_part_text_set(edje, "text", "Size Test");
   evas_object_geometry_get(bg, &x, &y, &w, &h);
   printf("[%f] after text set: %d,%d %dx%d\n", ecore_loop_time_get(), x, y, w, h);

   //text get
   edje_object_part_text_get(edje, "text");
   evas_object_geometry_get(bg, &x, &y, &w, &h);
   printf("[%f] after text get: %d,%d %dx%d\n", ecore_loop_time_get(), x, y, w, h);

   edje_object_part_geometry_get(edje, "text", &x, &y, &w, &h);
   printf("[%f] edje text part geometry: %d,%d %dx%d\n", ecore_loop_time_get(), x, y, w, h);

   elm_run();

   return 0;
}
ELM_MAIN()