fixed plugin image size problem
[framework/uifw/elementary.git] / src / bin / test_hover.c
1 #include "elementary_config.h"
2 #include <Elementary.h>
3 #ifndef ELM_LIB_QUICKLAUNCH
4 static void
5 my_hover_bt(void *data, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
6 {
7    Evas_Object *hv = data;
8
9    evas_object_show(hv);
10 }
11
12 static void
13 _top_bt_clicked(void *data, Evas_Object *obj __UNUSED__,
14                 void *event_info __UNUSED__)
15 {
16    Evas_Object *hv = (Evas_Object *)data;
17    elm_hover_dismiss(hv);
18 }
19
20 void
21 test_hover(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
22 {
23    Evas_Object *win, *bg, *bx, *bt, *hv, *ic;
24    char buf[PATH_MAX];
25
26    win = elm_win_add(NULL, "hover", ELM_WIN_BASIC);
27    elm_win_title_set(win, "Hover");
28    elm_win_autodel_set(win, EINA_TRUE);
29
30    bg = elm_bg_add(win);
31    elm_win_resize_object_add(win, bg);
32    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
33    evas_object_show(bg);
34
35    bx = elm_box_add(win);
36    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
37    elm_win_resize_object_add(win, bx);
38    evas_object_show(bx);
39
40    hv = elm_hover_add(win);
41
42    bt = elm_button_add(win);
43    elm_object_text_set(bt, "Button");
44    evas_object_smart_callback_add(bt, "clicked", my_hover_bt, hv);
45    elm_box_pack_end(bx, bt);
46    evas_object_show(bt);
47    elm_hover_parent_set(hv, win);
48    elm_hover_target_set(hv, bt);
49
50    bt = elm_button_add(win);
51    elm_object_text_set(bt, "Popup");
52    elm_object_part_content_set(hv, "middle", bt);
53    evas_object_show(bt);
54
55    bx = elm_box_add(win);
56
57    ic = elm_icon_add(win);
58    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
59    elm_icon_file_set(ic, buf, NULL);
60    elm_icon_resizable_set(ic, 0, 0);
61    elm_box_pack_end(bx, ic);
62    evas_object_show(ic);
63
64    bt = elm_button_add(win);
65    elm_object_text_set(bt, "Top 1");
66    evas_object_smart_callback_add(bt, "clicked", _top_bt_clicked, hv);
67    elm_box_pack_end(bx, bt);
68    evas_object_show(bt);
69    bt = elm_button_add(win);
70    elm_object_text_set(bt, "Top 2");
71    elm_box_pack_end(bx, bt);
72    evas_object_show(bt);
73    bt = elm_button_add(win);
74    elm_object_text_set(bt, "Top 3");
75    elm_box_pack_end(bx, bt);
76    evas_object_show(bt);
77
78    evas_object_show(bx);
79    elm_object_part_content_set(hv, "top", bx);
80
81    bt = elm_button_add(win);
82    elm_object_text_set(bt, "Bottom");
83    elm_object_part_content_set(hv, "bottom", bt);
84    evas_object_show(bt);
85
86    bt = elm_button_add(win);
87    elm_object_text_set(bt, "Left");
88    elm_object_part_content_set(hv, "left", bt);
89    evas_object_show(bt);
90
91    bt = elm_button_add(win);
92    elm_object_text_set(bt, "Right");
93    elm_object_part_content_set(hv, "right", bt);
94    evas_object_show(bt);
95
96    evas_object_size_hint_min_set(bg, 160, 160);
97    evas_object_size_hint_max_set(bg, 640, 640);
98    evas_object_resize(win, 440, 440);
99    evas_object_show(win);
100 }
101
102 void
103 test_hover2(void *data __UNUSED__, Evas_Object *obj __UNUSED__, void *event_info __UNUSED__)
104 {
105    Evas_Object *win, *bg, *bx, *bt, *hv, *ic;
106    char buf[PATH_MAX];
107
108    win = elm_win_add(NULL, "hover2", ELM_WIN_BASIC);
109    elm_win_title_set(win, "Hover 2");
110    elm_win_autodel_set(win, EINA_TRUE);
111
112    bg = elm_bg_add(win);
113    elm_win_resize_object_add(win, bg);
114    evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
115    evas_object_show(bg);
116
117    bx = elm_box_add(win);
118    evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
119    elm_win_resize_object_add(win, bx);
120    evas_object_show(bx);
121
122    hv = elm_hover_add(win);
123    elm_object_style_set(hv, "popout");
124
125    bt = elm_button_add(win);
126    elm_object_text_set(bt, "Button");
127    evas_object_smart_callback_add(bt, "clicked", my_hover_bt, hv);
128    elm_box_pack_end(bx, bt);
129    evas_object_show(bt);
130    elm_hover_parent_set(hv, win);
131    elm_hover_target_set(hv, bt);
132
133    bt = elm_button_add(win);
134    elm_object_text_set(bt, "Popup");
135    elm_object_part_content_set(hv, "middle", bt);
136    evas_object_show(bt);
137
138    bx = elm_box_add(win);
139
140    ic = elm_icon_add(win);
141    snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
142    elm_icon_file_set(ic, buf, NULL);
143    elm_icon_resizable_set(ic, 0, 0);
144    elm_box_pack_end(bx, ic);
145    evas_object_show(ic);
146    bt = elm_button_add(win);
147    elm_object_text_set(bt, "Top 1");
148    elm_box_pack_end(bx, bt);
149    evas_object_show(bt);
150    bt = elm_button_add(win);
151    elm_object_text_set(bt, "Top 2");
152    elm_box_pack_end(bx, bt);
153    evas_object_show(bt);
154    bt = elm_button_add(win);
155    elm_object_text_set(bt, "Top 3");
156    elm_box_pack_end(bx, bt);
157    evas_object_show(bt);
158    evas_object_show(bx);
159    elm_object_part_content_set(hv, "top", bx);
160
161    bt = elm_button_add(win);
162    elm_object_text_set(bt, "Bot");
163    elm_object_part_content_set(hv, "bottom", bt);
164    evas_object_show(bt);
165
166    bt = elm_button_add(win);
167    elm_object_text_set(bt, "Left");
168    elm_object_part_content_set(hv, "left", bt);
169    evas_object_show(bt);
170
171    bt = elm_button_add(win);
172    elm_object_text_set(bt, "Right");
173    elm_object_part_content_set(hv, "right", bt);
174    evas_object_show(bt);
175
176    evas_object_size_hint_min_set(bg, 160, 160);
177    evas_object_size_hint_max_set(bg, 640, 640);
178    evas_object_resize(win, 440, 440);
179    evas_object_show(win);
180 }
181 #endif