summaryrefslogtreecommitdiff
path: root/src/bin/elementary/test_ui_items.c
blob: 36c5f9719fd3466507f52ba1004bd6cf54d55bcc (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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#ifdef HAVE_CONFIG_H
# include "elementary_config.h"
#endif

#include <Efl_Ui.h>

static Efl_Ui_Widget*
_item_add(Eo *box, const Efl_Class *c, int i)
{
   Eo *check, *rect, *il = efl_add(c, box);
   int r = 0, g = 0, b = 0;
   char buf[PATH_MAX];

   snprintf(buf, sizeof(buf), "%d - Test %d", i, i%13);
   efl_text_set(il, buf);

   rect = efl_add(EFL_CANVAS_RECTANGLE_CLASS, il);
   switch (i % 5)
     {
      case 0:
         r = 255;
         break;
      case 1:
         g = 255;
         break;
      case 2:
         b = 255;
         break;
      case 3:
         r = g = b = 255;
         break;
      case 4:
         r = g = b = 0;
         break;
   }
   efl_gfx_color_set(rect, r, g, b, 255);
   efl_content_set(il, rect);

   check = efl_add(EFL_UI_CHECK_CLASS, il);
   efl_content_set(efl_part(il, "extra"), check);

   if (c == EFL_UI_GRID_DEFAULT_ITEM_CLASS)
     efl_gfx_hint_size_min_set(il, EINA_SIZE2D(100, 180));
   else
     efl_gfx_hint_size_min_set(il, EINA_SIZE2D(40, 40+(i%2)*40));

   return il;
}

void test_efl_ui_item(void *data EINA_UNUSED,
                      Efl_Object *obj EINA_UNUSED,
                      void *event_info EINA_UNUSED)
{
   Eo *win, *box, *o;

   win = efl_add(EFL_UI_WIN_CLASS, efl_main_loop_get(),
                                  efl_text_set(efl_added, "Item examples"),
                 efl_ui_win_autodel_set(efl_added, EINA_TRUE)
                );

   box = efl_add(EFL_UI_BOX_CLASS, win,
                 efl_content_set(win, efl_added));

   o = _item_add(box, EFL_UI_GRID_DEFAULT_ITEM_CLASS, 1);
   efl_pack_end(box, o);

   o = _item_add(box, EFL_UI_GRID_DEFAULT_ITEM_CLASS, 2);
   efl_ui_widget_disabled_set(o, EINA_TRUE);
   efl_pack_end(box, o);

   o = _item_add(box, EFL_UI_LIST_DEFAULT_ITEM_CLASS, 3);
   efl_pack_end(box, o);

   o = _item_add(box, EFL_UI_LIST_DEFAULT_ITEM_CLASS, 4);
   efl_ui_widget_disabled_set(o, EINA_TRUE);
   efl_pack_end(box, o);

   o = efl_add(EFL_UI_LIST_PLACEHOLDER_ITEM_CLASS, box);
   efl_gfx_hint_size_min_set(o, EINA_SIZE2D(40, 40+40));
   efl_pack_end(box, o);

   o = efl_add(EFL_UI_LIST_PLACEHOLDER_ITEM_CLASS, box);
   efl_gfx_hint_size_min_set(o, EINA_SIZE2D(40, 40));
   efl_ui_widget_disabled_set(o, EINA_TRUE);
   efl_pack_end(box, o);

   o = _item_add(box, EFL_UI_GROUP_ITEM_CLASS, 5);
   efl_gfx_hint_size_min_set(o, EINA_SIZE2D(40, 40+40));
   efl_pack_end(box, o);

   o = _item_add(box, EFL_UI_GROUP_ITEM_CLASS, 6);
   efl_gfx_hint_size_min_set(o, EINA_SIZE2D(40, 40));
   efl_ui_widget_disabled_set(o, EINA_TRUE);

   o = _item_add(box, EFL_UI_TAB_BAR_DEFAULT_ITEM_CLASS, 5);
   efl_gfx_hint_size_min_set(o, EINA_SIZE2D(40, 40+40));
   efl_pack_end(box, o);

   o = _item_add(box, EFL_UI_TAB_BAR_DEFAULT_ITEM_CLASS, 6);
   efl_gfx_hint_size_min_set(o, EINA_SIZE2D(40, 40));
   efl_ui_widget_disabled_set(o, EINA_TRUE);
   efl_pack_end(box, o);
   o = _item_add(box, EFL_UI_TAB_BAR_DEFAULT_ITEM_CLASS, 5);
   efl_ui_tab_bar_default_item_icon_set(o, "folder");
   efl_gfx_hint_size_min_set(o, EINA_SIZE2D(40, 40+40));
   efl_pack_end(box, o);
}