summaryrefslogtreecommitdiff
path: root/src/bin/elementary/test_win_inline.c
diff options
context:
space:
mode:
authorCedric BAIL <cedric@osg.samsung.com>2016-03-23 12:56:14 -0700
committerCedric BAIL <cedric@osg.samsung.com>2016-03-23 13:24:41 -0700
commitc2a1c49ab2042f559b28e840e54feb8494888e0e (patch)
treec6eb110b7c479499854eede9d0c3ab0a80c9a11a /src/bin/elementary/test_win_inline.c
parent9340855597e7e465435c69b6278650346688da14 (diff)
elementary: move all legacy files to their expected new location.
Diffstat (limited to 'src/bin/elementary/test_win_inline.c')
-rw-r--r--src/bin/elementary/test_win_inline.c254
1 files changed, 254 insertions, 0 deletions
diff --git a/src/bin/elementary/test_win_inline.c b/src/bin/elementary/test_win_inline.c
new file mode 100644
index 0000000..b9e08ef
--- /dev/null
+++ b/src/bin/elementary/test_win_inline.c
@@ -0,0 +1,254 @@
1#ifdef HAVE_CONFIG_H
2# include "elementary_config.h"
3#endif
4#include <Elementary.h>
5
6static void
7fill(Evas_Object *win, Eina_Bool do_bg)
8{
9 Evas_Object *bg, *sc, *bx, *ic, *bb, *av, *en;
10 char buf[PATH_MAX];
11
12 if (do_bg)
13 {
14 bg = elm_bg_add(win);
15 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
16 elm_win_resize_object_add(win, bg);
17 evas_object_show(bg);
18 }
19
20 sc = elm_scroller_add(win);
21 evas_object_size_hint_weight_set(sc, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
22 elm_win_resize_object_add(win, sc);
23
24 bx = elm_box_add(win);
25 evas_object_size_hint_weight_set(bx, EVAS_HINT_EXPAND, 0.0);
26 evas_object_size_hint_align_set(bx, EVAS_HINT_FILL, EVAS_HINT_FILL);
27
28 en = elm_entry_add(win);
29 elm_entry_scrollable_set(en, EINA_TRUE);
30 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
31 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
32 elm_object_text_set(en, "This is a single line");
33 elm_scroller_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
34 elm_entry_single_line_set(en, EINA_TRUE);
35 evas_object_show(en);
36 elm_box_pack_end(bx, en);
37
38 en = elm_entry_add(win);
39 elm_entry_scrollable_set(en, EINA_TRUE);
40 evas_object_size_hint_weight_set(en, EVAS_HINT_EXPAND, 0.0);
41 evas_object_size_hint_align_set(en, EVAS_HINT_FILL, 0.5);
42 elm_object_text_set(en, "Entry 2");
43 elm_scroller_policy_set(en, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
44 elm_entry_single_line_set(en, EINA_TRUE);
45 evas_object_show(en);
46 elm_box_pack_end(bx, en);
47
48 ic = elm_icon_add(win);
49 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
50 elm_image_file_set(ic, buf, NULL);
51 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
52 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1);
53
54 bb = elm_bubble_add(win);
55 elm_object_text_set(bb, "Message 3");
56 elm_object_part_text_set(bb, "info", "10:32 4/11/2008");
57 elm_object_part_content_set(bb, "icon", ic);
58 evas_object_show(ic);
59 evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0);
60 evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL);
61 av = elm_entry_add(win);
62 elm_entry_anchor_hover_style_set(av, "popout");
63 elm_entry_anchor_hover_parent_set(av, win);
64 elm_object_text_set(av,
65 "Hi there. This is the most recent message in the "
66 "list of messages. It has one <a href=tel:+614321234>+61 432 1234</a> "
67 "(phone number) to click on.");
68 elm_object_content_set(bb, av);
69 evas_object_show(av);
70 elm_box_pack_end(bx, bb);
71 evas_object_show(bb);
72
73 ic = elm_icon_add(win);
74 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
75 elm_image_file_set(ic, buf, NULL);
76 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
77
78 bb = elm_bubble_add(win);
79 elm_object_text_set(bb, "Message 2");
80 elm_object_part_text_set(bb, "info", "7:16 27/10/2008");
81 elm_object_part_content_set(bb, "icon", ic);
82 evas_object_show(ic);
83 evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0);
84 evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL);
85 av = elm_entry_add(win);
86 elm_entry_anchor_hover_style_set(av, "popout");
87 elm_entry_anchor_hover_parent_set(av, win);
88 elm_object_text_set(av,
89 "Hey what are you doing? This is the second last message "
90 "Hi there. This is the most recent message in the "
91 "list. It's a longer one so it can wrap more and "
92 "contains a <a href=contact:john>John</a> contact "
93 "link in it to test popups on links. The idea is that "
94 "all SMS's are scanned for things that look like phone "
95 "numbers or names that are in your contacts list, and "
96 "if they are, they become clickable links that pop up "
97 "a menus of obvious actions to perform on this piece "
98 "of information. This of course can be later explicitly "
99 "done by links maybe running local apps or even being "
100 "web URL's too that launch the web browser and point it "
101 "to that URL. <item relsize=16x16 vsize=full href=emoticon/omg></item>");
102 elm_object_content_set(bb, av);
103 evas_object_show(av);
104 elm_box_pack_end(bx, bb);
105 evas_object_show(bb);
106
107 ic = elm_icon_add(win);
108 snprintf(buf, sizeof(buf), "%s/images/logo_small.png", elm_app_data_dir_get());
109 elm_image_file_set(ic, buf, NULL);
110 elm_image_resizable_set(ic, EINA_FALSE, EINA_FALSE);
111 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_HORIZONTAL, 1, 1);
112
113 bb = elm_bubble_add(win);
114 elm_object_text_set(bb, "Message 1");
115 elm_object_part_text_set(bb, "info", "20:47 18/6/2008");
116 elm_object_part_content_set(bb, "icon", ic);
117 evas_object_show(ic);
118 evas_object_size_hint_weight_set(bb, EVAS_HINT_EXPAND, 0.0);
119 evas_object_size_hint_align_set(bb, EVAS_HINT_FILL, EVAS_HINT_FILL);
120
121 av = elm_entry_add(win);
122 elm_entry_anchor_hover_style_set(av, "popout");
123 elm_entry_anchor_hover_parent_set(av, win);
124 elm_object_text_set(av, "This is a short message. <item relsize=16x16 vsize=full href=emoticon/haha></item>");
125 elm_object_content_set(bb, av);
126 evas_object_show(av);
127 elm_box_pack_end(bx, bb);
128 evas_object_show(bb);
129
130 elm_object_content_set(sc, bx);
131 evas_object_show(bx);
132
133 evas_object_show(sc);
134}
135
136static void
137cb_mouse_down(void *data EINA_UNUSED, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event_info)
138{
139 Evas_Event_Mouse_Down *ev = event_info;
140
141 if (ev->button == 1) elm_object_focus_set(obj, EINA_TRUE);
142}
143
144static void
145cb_mouse_move(void *data, Evas *evas EINA_UNUSED, Evas_Object *obj, void *event_info)
146{
147 Evas_Event_Mouse_Move *ev = event_info;
148 Evas_Object *orig = data;
149 Evas_Coord x, y;
150 Evas_Map *p;
151 int i, w, h;
152
153 if (!ev->buttons) return;
154 evas_object_geometry_get(obj, &x, &y, NULL, NULL);
155 evas_object_move(obj,
156 x + (ev->cur.canvas.x - ev->prev.output.x),
157 y + (ev->cur.canvas.y - ev->prev.output.y));
158 evas_object_image_size_get(orig, &w, &h);
159 p = evas_map_new(4);
160 evas_object_map_enable_set(orig, EINA_TRUE);
161 evas_object_raise(orig);
162 for (i = 0; i < 4; i++)
163 {
164 Evas_Object *hand;
165 char key[32];
166
167 snprintf(key, sizeof(key), "h-%i\n", i);
168 hand = evas_object_data_get(orig, key);
169 evas_object_raise(hand);
170 evas_object_geometry_get(hand, &x, &y, NULL, NULL);
171 x += 15;
172 y += 15;
173 evas_map_point_coord_set(p, i, x, y, 0);
174 if (i == 0) evas_map_point_image_uv_set(p, i, 0, 0);
175 else if (i == 1) evas_map_point_image_uv_set(p, i, w, 0);
176 else if (i == 2) evas_map_point_image_uv_set(p, i, w, h);
177 else if (i == 3) evas_map_point_image_uv_set(p, i, 0, h);
178 }
179 evas_object_map_set(orig, p);
180 evas_map_free(p);
181}
182
183static void
184create_handles(Evas_Object *obj)
185{
186 int i;
187 Evas_Coord x, y, w, h;
188
189 evas_object_geometry_get(obj, &x, &y, &w, &h);
190 for (i = 0; i < 4; i++)
191 {
192 Evas_Object *hand;
193 char buf[PATH_MAX];
194 char key[32];
195
196 hand = evas_object_image_filled_add(evas_object_evas_get(obj));
197 evas_object_resize(hand, 31, 31);
198 snprintf(buf, sizeof(buf), "%s/images/pt.png", elm_app_data_dir_get());
199 evas_object_image_file_set(hand, buf, NULL);
200 if (i == 0) evas_object_move(hand, x - 15, y - 15);
201 else if (i == 1) evas_object_move(hand, x + w - 15, y - 15);
202 else if (i == 2) evas_object_move(hand, x + w - 15, y + h - 15);
203 else if (i == 3) evas_object_move(hand, x - 15, y + h - 15);
204 evas_object_event_callback_add(hand, EVAS_CALLBACK_MOUSE_MOVE, cb_mouse_move, obj);
205 evas_object_show(hand);
206 snprintf(key, sizeof(key), "h-%i\n", i);
207 evas_object_data_set(obj, key, hand);
208 }
209}
210
211void
212test_win_inline(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
213{
214 Evas_Object *win, *bg, *win2, *win3;
215 char buf[PATH_MAX];
216
217 win = elm_win_add(NULL, "window-inline", ELM_WIN_BASIC);
218 elm_win_title_set(win, "Window Inline");
219 elm_win_autodel_set(win, EINA_TRUE);
220
221 bg = elm_bg_add(win);
222 snprintf(buf, sizeof(buf), "%s/images/plant_01.jpg", elm_app_data_dir_get());
223 elm_bg_file_set(bg, buf, NULL);
224 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
225 elm_win_resize_object_add(win, bg);
226 evas_object_show(bg);
227
228 win2 = elm_win_add(win, "inlined", ELM_WIN_INLINED_IMAGE);
229 evas_object_event_callback_add(elm_win_inlined_image_object_get(win2), EVAS_CALLBACK_MOUSE_DOWN, cb_mouse_down, NULL);
230 fill(win2, EINA_TRUE);
231
232 evas_object_move(win2, 20, 60);
233 evas_object_resize(win2, 300, 200);
234 // image object for win2 is unlinked to its pos/size - so manual control
235 // this allows also for using map and other things with it.
236 evas_object_move(elm_win_inlined_image_object_get(win2), 20, 40);
237 evas_object_resize(elm_win_inlined_image_object_get(win2), 200, 320);
238 evas_object_show(win2);
239
240 win3 = elm_win_add(win, "inlined", ELM_WIN_INLINED_IMAGE);
241 evas_object_event_callback_add(elm_win_inlined_image_object_get(win3), EVAS_CALLBACK_MOUSE_DOWN, cb_mouse_down, NULL);
242 elm_win_alpha_set(win3, EINA_TRUE);
243 fill(win3, EINA_FALSE);
244
245 evas_object_resize(win3, 300, 200);
246 evas_object_move(elm_win_inlined_image_object_get(win3), 80, 180);
247 evas_object_resize(elm_win_inlined_image_object_get(win3), 300, 200);
248 evas_object_show(win3);
249
250 create_handles(elm_win_inlined_image_object_get(win3));
251
252 evas_object_resize(win, 400, 400);
253 evas_object_show(win);
254}