When the separators exist in toolbar and the toolbar shrinks by resizing window,
[framework/uifw/elementary.git] / src / examples / layout_example_02.c
1 //Compile with:
2 //gcc -g layout_example_02.c -o layout_example_02 `pkg-config --cflags --libs elementary`
3
4 #include <Elementary.h>
5
6 #define TABLE "example/table"
7 #define BOX "example/box"
8 #define TITLE "example/title"
9 #define SWALLOW "example/custom"
10
11 static const char *images[] = { "home", "close", "arrow_up", "arrow_down", NULL };
12
13 struct _App {
14      int current;
15 };
16
17 static void
18 _signal_cb(void *data, Evas_Object *o, const char *emission, const char *source)
19 {
20    struct _App *app = data;
21    Evas_Object *icon = elm_object_part_content_get(o, "elm.swallow.content");
22
23    printf("signal received\n");
24
25    if (!strcmp("elm,action,back", emission))
26      app->current--;
27    else if (!strcmp("elm,action,next", emission))
28      app->current++;
29
30    if (app->current < 0)
31      app->current = sizeof(images) - 1;
32    else if (images[app->current] == NULL)
33      app->current = 0;
34
35    elm_icon_standard_set(icon, images[app->current]);
36 }
37
38 EAPI_MAIN int
39 elm_main(int argc, char **argv)
40 {
41    Evas_Object *win, *bg, *layout, *icon;
42    struct _App app;
43
44    app.current = 0;
45
46    win = elm_win_add(NULL, "layout", ELM_WIN_BASIC);
47    elm_win_title_set(win, "Layout");
48    elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
49    elm_win_autodel_set(win, EINA_TRUE);
50
51    bg = elm_bg_add(win);
52    elm_bg_color_set(bg, 255, 255, 255);
53    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
54    elm_win_resize_object_add(win, bg);
55    evas_object_show(bg);
56
57    // Adding layout and filling it with widgets
58    layout = elm_layout_add(win);
59    evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
60    elm_win_resize_object_add(win, layout);
61    elm_layout_theme_set(
62        layout, "layout", "application", "content-back-next");
63    evas_object_show(layout);
64
65    icon = elm_icon_add(win);
66    elm_icon_standard_set(icon, images[app.current]);
67    evas_object_size_hint_weight_set(layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
68    elm_object_part_content_set(layout, "elm.swallow.content", icon);
69
70    elm_object_signal_callback_add(layout, "elm,action,back", "", _signal_cb, &app);
71    elm_object_signal_callback_add(layout, "elm,action,next", "", _signal_cb, &app);
72
73    evas_object_size_hint_min_set(bg, 160, 160);
74    evas_object_size_hint_max_set(bg, 640, 640);
75    evas_object_resize(win, 320, 320);
76    evas_object_show(win);
77
78    elm_run();
79    elm_shutdown();
80
81    return 0;
82 }
83 ELM_MAIN()