summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordiscomfitor <michael.blumenkrantz@gmail.com>2013-08-26 20:01:43 +0100
committerdiscomfitor <michael.blumenkrantz@gmail.com>2013-08-26 20:02:45 +0100
commitec250b84878179a0bf6970cd4e5a805b77bd4d63 (patch)
tree4e05bf53b0345261914c942533d62a7af35098f0
parentb812d4d08bab150eea8156f17b1b990f8a8d6e56 (diff)
add list overlay for info
-rw-r--r--data/themes/list_basic.edc53
-rw-r--r--src/bin/main.c14
-rw-r--r--src/modules/list_basic.c274
3 files changed, 308 insertions, 33 deletions
diff --git a/data/themes/list_basic.edc b/data/themes/list_basic.edc
index a4ed924..b65f384 100644
--- a/data/themes/list_basic.edc
+++ b/data/themes/list_basic.edc
@@ -40,11 +40,6 @@ collections {
40 } 40 }
41 } 41 }
42 parts { 42 parts {
43 part { name: "base"; type: RECT;
44 description { state: "default";
45 color: 0 0 0 255;
46 }
47 }
48 part { name: "color_clip"; type: RECT; 43 part { name: "color_clip"; type: RECT;
49 description { state: "default"; 44 description { state: "default";
50 color: 255 255 255 255; 45 color: 255 255 255 255;
@@ -71,8 +66,8 @@ collections {
71 } 66 }
72 } 67 }
73 part { name: "img"; clip_to: "clip"; 68 part { name: "img"; clip_to: "clip";
69 scale: 1;
74 description { state: "default"; 70 description { state: "default";
75 min: 16 16;
76 aspect: 1.0 1.0; 71 aspect: 1.0 1.0;
77 aspect_preference: BOTH; 72 aspect_preference: BOTH;
78 image.normal: "arrows_both.png"; 73 image.normal: "arrows_both.png";
@@ -154,4 +149,50 @@ collections {
154#endif 149#endif
155 ICON("userunknown", 16, 0, 5, -6); 150 ICON("userunknown", 16, 0, 5, -6);
156 151
152 group { name: "info_mover";
153 parts {
154 part { name: "swallow.mover"; type: SWALLOW;
155 scale: 1;
156 description { state: "default" 0.0;
157 fixed: 1 1;
158 visible: 0;
159 rel1 {
160 relative: 1.0 0.0;
161 offset: 888 8;
162 }
163 rel2 {
164 relative: 1.0 1.0;
165 offset: 8 -9;
166 }
167 }
168 description { state: "visible" 0.0;
169 inherit: "default" 0.0;
170 visible: 1;
171 rel1 {
172 relative: 0 0;
173 offset: 8 8;
174 }
175 rel2 {
176 offset: -9 -9;
177 }
178 }
179 }
180 }
181 program { name: "show";
182 signal: "s2.show"; source: "s2";
183 action: STATE_SET "visible" 0.0;
184 transition: LINEAR 0.3;
185 target: "swallow.mover";
186 }
187 program {
188 signal: "s2.hide"; source: "s2";
189 action: STATE_SET "default" 0.0;
190 transition: LINEAR 0.3 CURRENT;
191 target: "swallow.mover";
192 after: "hide_after";
193 }
194 program { name: "hide_after";
195 action: SIGNAL_EMIT "s2.hide.done" "";
196 }
197 }
157} 198}
diff --git a/src/bin/main.c b/src/bin/main.c
index 634e94b..7795dfb 100644
--- a/src/bin/main.c
+++ b/src/bin/main.c
@@ -14,7 +14,6 @@
14#define CRI(...) EINA_LOG_DOM_CRIT(ui_log_dom, __VA_ARGS__) 14#define CRI(...) EINA_LOG_DOM_CRIT(ui_log_dom, __VA_ARGS__)
15 15
16typedef struct _S2_Module S2_Module; 16typedef struct _S2_Module S2_Module;
17typedef struct _S2_List_Module S2_List_Module;
18 17
19typedef S2_Module_Type (*S2_Module_Type_Cb)(void); 18typedef S2_Module_Type (*S2_Module_Type_Cb)(void);
20typedef Eina_Bool (*S2_Module_Init_Cb)(void); 19typedef Eina_Bool (*S2_Module_Init_Cb)(void);
@@ -33,12 +32,6 @@ struct _S2_Module
33 Eina_Module *module; 32 Eina_Module *module;
34}; 33};
35 34
36struct _S2_List_Module
37{
38 S2_Module module;
39
40};
41
42int ui_log_dom = -1; 35int ui_log_dom = -1;
43EAPI int S2_EVENT_CONTACT_ADD = -1; 36EAPI int S2_EVENT_CONTACT_ADD = -1;
44EAPI int S2_EVENT_CONTACT_UPDATE = -1; 37EAPI int S2_EVENT_CONTACT_UPDATE = -1;
@@ -229,6 +222,7 @@ sc_presence_add(S2_Contact *sc, Shotgun_Event_Presence *ev)
229 else 222 else
230 { 223 {
231 p = calloc(1, sizeof(Shotgun_Event_Presence)); 224 p = calloc(1, sizeof(Shotgun_Event_Presence));
225 p->account = sc->auth->auth;
232 p->priority = ev->priority; 226 p->priority = ev->priority;
233 p->jid = eina_stringshare_ref(ev->jid); 227 p->jid = eina_stringshare_ref(ev->jid);
234 sc->presences = eina_list_sorted_insert(sc->presences, (Eina_Compare_Cb)sc_presence_compare_cb, p); 228 sc->presences = eina_list_sorted_insert(sc->presences, (Eina_Compare_Cb)sc_presence_compare_cb, p);
@@ -434,6 +428,12 @@ ui_contact_find(S2_Auth *sa, const char *jid)
434 return eina_hash_find(sa->contacts, jid); 428 return eina_hash_find(sa->contacts, jid);
435} 429}
436 430
431EAPI void
432ui_contact_chat_open(S2_Contact *sc)
433{
434
435}
436
437EAPI S2_Auth * 437EAPI S2_Auth *
438ui_shotgun_find(const char *jid) 438ui_shotgun_find(const char *jid)
439{ 439{
diff --git a/src/modules/list_basic.c b/src/modules/list_basic.c
index e53b1b1..8489947 100644
--- a/src/modules/list_basic.c
+++ b/src/modules/list_basic.c
@@ -63,10 +63,10 @@ list_item_text_get(S2_Contact *sc, Evas_Object *obj EINA_UNUSED, const char *par
63} 63}
64 64
65static Evas_Object * 65static Evas_Object *
66list_item_content_get(S2_Contact *sc, Evas_Object *obj, const char *part) 66list_item_status_icon_new(S2_Contact *sc, Shotgun_Event_Presence *p, Eina_Stringshare *file, Evas *e)
67{ 67{
68 Evas_Object *ic; 68 Evas_Object *ic;
69 const char *sig = NULL, *file; 69 const char *sig;
70 static const char *st[] = 70 static const char *st[] =
71 { 71 {
72 [SHOTGUN_USER_STATUS_NONE] = "s2.none", 72 [SHOTGUN_USER_STATUS_NONE] = "s2.none",
@@ -76,19 +76,8 @@ list_item_content_get(S2_Contact *sc, Evas_Object *obj, const char *part)
76 [SHOTGUN_USER_STATUS_DND] = "s2.dnd", 76 [SHOTGUN_USER_STATUS_DND] = "s2.dnd",
77 [SHOTGUN_USER_STATUS_XA] = "s2.xa" 77 [SHOTGUN_USER_STATUS_XA] = "s2.xa"
78 }; 78 };
79 file = evas_object_data_get(elm_object_top_widget_get(obj), "file"); 79
80 if (!strcmp(part, "elm.swallow.end")) 80 ic = edje_object_add(e);
81 {
82 ic = elm_icon_add(obj);
83 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
84 if (sc->info.photo.data && sc->info.photo.size)
85 elm_image_memfile_set(ic, sc->info.photo.data, sc->info.photo.size, NULL, NULL);
86 else
87 elm_image_file_set(ic, file, "list_basic/userunknown");
88 evas_object_show(ic);
89 return ic;
90 }
91 ic = edje_object_add(evas_object_evas_get(obj));
92 edje_object_file_set(ic, file, "status_icon"); 81 edje_object_file_set(ic, file, "status_icon");
93 switch (sc->ptype) 82 switch (sc->ptype)
94 { 83 {
@@ -101,9 +90,8 @@ list_item_content_get(S2_Contact *sc, Evas_Object *obj, const char *part)
101 break; 90 break;
102 } 91 }
103 92
104 if (sc->presences) 93 if (p)
105 { 94 {
106 Shotgun_Event_Presence *p = eina_list_data_get(sc->presences);
107 Edje_Message_Int_Set msg; 95 Edje_Message_Int_Set msg;
108 96
109 msg.count = 1; 97 msg.count = 1;
@@ -144,10 +132,31 @@ list_item_content_get(S2_Contact *sc, Evas_Object *obj, const char *part)
144 //FILL(ic); 132 //FILL(ic);
145 evas_object_size_hint_min_set(ic, 40, 40); 133 evas_object_size_hint_min_set(ic, 40, 40);
146 evas_object_show(ic); 134 evas_object_show(ic);
147
148 return ic; 135 return ic;
149} 136}
150 137
138static Evas_Object *
139list_item_content_get(S2_Contact *sc, Evas_Object *obj, const char *part)
140{
141 Evas_Object *ic;
142 const char *file;
143
144 file = evas_object_data_get(elm_object_top_widget_get(obj), "file");
145 if (!strcmp(part, "elm.swallow.end"))
146 {
147 ic = elm_icon_add(obj);
148 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
149 if (sc->info.photo.data && sc->info.photo.size)
150 elm_image_memfile_set(ic, sc->info.photo.data, sc->info.photo.size, NULL, NULL);
151 else
152 elm_image_file_set(ic, file, "list_basic/userunknown");
153 evas_object_show(ic);
154 return ic;
155 }
156
157 return list_item_status_icon_new(sc, eina_list_data_get(sc->presences), file, evas_object_evas_get(obj));
158}
159
151static void 160static void
152list_item_add(S2_Contact *sc, Evas_Object *win) 161list_item_add(S2_Contact *sc, Evas_Object *win)
153{ 162{
@@ -172,6 +181,232 @@ list_del(void *data EINA_UNUSED, Evas *e EINA_UNUSED, Evas_Object *obj, void *ev
172 ecore_main_loop_quit(); 181 ecore_main_loop_quit();
173} 182}
174 183
184static void
185overlay_delete(void *data, Evas_Object *obj, const char *sig EINA_UNUSED, const char *src EINA_UNUSED)
186{
187 Eina_List *l;
188 Evas_Object *o;
189
190 evas_object_data_del(data, "overlay");
191 l = evas_object_data_del(data, "overlay_objs");
192 EINA_LIST_FREE(l, o)
193 evas_object_del(o);
194 evas_object_del(obj);
195}
196
197static char *
198overlay_item_text_get(Shotgun_Event_Presence *p, Evas_Object *obj EINA_UNUSED, const char *part)
199{
200 if (!strcmp(part, "elm.text"))
201 {
202 const char *jid;
203
204 jid = strchr(p->jid, '/');
205 return strdup(jid + 1);
206 }
207 if (!strcmp(part, "elm.text.sub"))
208 {
209 if (p->description)
210 return strdup(p->description);
211 }
212 return NULL;
213}
214
215static Evas_Object *
216overlay_item_content_get(Shotgun_Event_Presence *p, Evas_Object *obj, const char *part)
217{
218 Evas_Object *ic;
219 const char *file;
220 char *jid, *s;
221
222 file = evas_object_data_get(elm_object_top_widget_get(obj), "file");
223 if (!strcmp(part, "elm.swallow.end"))
224 {
225 return NULL;
226 }
227
228 s = strchr(p->jid, '/');
229 jid = strndupa(p->jid, s - p->jid);
230 return list_item_status_icon_new(ui_contact_find(shotgun_data_get(p->account), jid), p, file, evas_object_evas_get(obj));
231}
232
233static void
234overlay_selected(void *data, Evas_Object *obj, void *event_info)
235{
236 Elm_Object_Item *it = event_info;
237 S2_Contact *sc = data;
238
239
240}
241
242static Evas_Object *
243overlay_create(Elm_Object_Item *it, Evas *e)
244{
245 Evas_Object *ic, *box, *win, *o, *ii, *mover;
246 int y, w, h, oy, oh, above, below, mw, mh;
247 Eina_Stringshare *file;
248 Eina_List *objs = NULL;
249 S2_Contact *sc;
250 Eina_List *l;
251 Shotgun_Event_Presence *p;
252 static Elm_Genlist_Item_Class glit = {
253 .item_style = "double_label",
254 .func = {
255 .text_get = (Elm_Genlist_Item_Text_Get_Cb)overlay_item_text_get,
256 .content_get = (Elm_Genlist_Item_Content_Get_Cb)overlay_item_content_get,
257 },
258 .version = ELM_GENLIST_ITEM_CLASS_VERSION
259 };
260
261 sc = elm_object_item_data_get(it);
262 ic = elm_object_item_part_content_get(it, "elm.swallow.end");
263 /* get box object for icon so we can find position */
264 box = evas_object_smart_parent_get(ic);
265 evas_object_geometry_get(box, NULL, &oy, NULL, &oh);
266 win = elm_object_top_widget_get(elm_object_item_widget_get(it));
267 evas_object_geometry_get(win, NULL, NULL, &w, &h);
268
269 /* commence most complicated placement calculations of all time */
270 above = oy - 10;
271 if (above < 3 * oh + 20) above = 0;
272 below = h - (oy + oh + 10);
273 if (below < oh) below = 0;
274 /* require at least list-item-height to put things above/below item;
275 * abort if we don't have this much
276 */
277 if ((!above) && (!below)) return NULL;
278 file = evas_object_data_get(win, "file");
279 mover = edje_object_add(e);
280 edje_object_file_set(mover, file, "info_mover");
281 box = elm_box_add(win);
282 evas_object_show(box);
283 objs = eina_list_append(objs, box);
284 o = elm_icon_add(win);
285 EXPAND(o);
286 FILL(o);
287 objs = eina_list_append(objs, o);
288 evas_object_size_hint_aspect_set(o, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
289 if (sc->info.photo.data && sc->info.photo.size)
290 elm_image_memfile_set(o, sc->info.photo.data, sc->info.photo.size, NULL, NULL);
291 else
292 elm_image_file_set(o, file, "list_basic/userunknown");
293 evas_object_show(o);
294 elm_box_pack_end(box, o);
295 o = elm_label_add(win);
296 WEIGHT(o, EVAS_HINT_EXPAND, 0);
297 objs = eina_list_append(objs, o);
298 elm_object_text_set(o, sc->jid);
299 evas_object_show(o);
300 elm_box_pack_end(box, o);
301
302 ii = elm_genlist_add(win);
303 EXPAND(ii);
304 FILL(ii);
305 elm_scroller_bounce_set(ii, EINA_FALSE, EINA_FALSE);
306 elm_scroller_policy_set(ii, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
307 elm_genlist_homogeneous_set(ii, EINA_TRUE);
308 elm_genlist_mode_set(ii, ELM_LIST_COMPRESS);
309 EINA_LIST_FOREACH(sc->presences, l, p)
310 elm_genlist_item_append(ii, &glit, p, NULL, 0, overlay_selected, sc);
311
312 evas_object_show(ii);
313 elm_box_pack_end(box, ii);
314 /* FIXME: size/scroller/something? */
315
316 //edje_extern_object_min_size_set(box, mw, mh);
317
318 if (above < 2 * oh + 20)
319 /* not gonna be able to fit image... */
320 above = 0;
321 if (below < oh)
322 below = 0;
323
324 if (above)
325 {
326 Evas_Object *ob;
327 int remain = above - (2 * oh) - 20;
328 /* figure out where our item is in the box */
329 EINA_LIST_FOREACH(elm_box_children_get(box), l, ob)
330 {
331 if (remain < oh) break;
332 remain -= oh;
333 }
334 if (remain >= oh)
335 {
336 /* easymode */
337 y = 10 + remain;
338 }
339 else
340 {
341 /* ffffffffffuuuuuuuuuuuuuuuuu */
342 o = evas_object_rectangle_add(e);
343 evas_object_color_set(o, 0, 0, 0, 0);
344 evas_object_pass_events_set(o, 1);
345 edje_extern_object_min_size_set(o, oh, remain);
346 elm_box_pack_after(box, o, ob);
347 o = evas_object_rectangle_add(e);
348 evas_object_color_set(o, 0, 0, 0, 0);
349 evas_object_pass_events_set(o, 1);
350 edje_extern_object_min_size_set(o, oh, oh + 10);
351 elm_box_pack_after(box, o, ob);
352 y = 10;
353 }
354 }
355 else
356 y = oy + oh + 2;
357 edje_object_part_swallow(mover, "swallow.mover", box);
358 //if ((!mw) && (!mh))
359 {
360 fprintf(stderr, EINA_COLOR_YELLOW "min size calc failed for overlay!\n" EINA_COLOR_RESET);
361 mw = MIN(3 * oh, w);
362 mh = (4 + eina_list_count(sc->presences)) * oh;
363 }
364 fprintf(stderr, "OVERLAY: 10,%d %dx%d\n", y, mw, mh);
365 evas_object_move(mover, 0, y);
366 evas_object_resize(mover, w, MIN(h - 10, mh));
367 evas_object_show(mover);
368 edje_object_signal_emit(mover, "s2.show", "s2");
369 edje_object_signal_callback_add(mover, "s2.hide.done", "", overlay_delete, win);
370 evas_object_data_set(win, "overlay", mover);
371 evas_object_data_set(win, "overlay_objs", objs);
372 evas_object_layer_set(mover, 10);
373 return mover;
374}
375
376static void
377overlay_dismiss(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
378{
379 edje_object_signal_emit(data, "s2.hide", "s2");
380}
381
382static void
383list_mouse_down_cb(void *data, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Down *ev)
384{
385 Elm_Object_Item *it;
386 Evas_Object *overlay, *rect, *win;
387 int w, h;
388
389 win = elm_object_top_widget_get(obj);
390 overlay = evas_object_data_get(win, "overlay");
391 if (overlay)
392 {
393 edje_object_signal_emit(overlay, "s2.hide", "s2");
394 return;
395 }
396 if (ev->button != 3) return;
397 it = elm_genlist_at_xy_item_get(data, ev->output.x, ev->output.y, NULL);
398 if (!it) return;
399 overlay = overlay_create(it, e);
400 if (!overlay) return;
401 evas_object_geometry_get(win, NULL, NULL, &w, &h);
402
403 rect = evas_object_rectangle_add(e);
404 evas_object_resize(rect, w, h);
405 evas_object_color_set(rect, 0, 0, 0, 0);
406 evas_object_layer_set(rect, 9);
407 evas_object_event_callback_add(rect, EVAS_CALLBACK_MOUSE_DOWN, overlay_dismiss, overlay);
408}
409
175static Evas_Object * 410static Evas_Object *
176list_create(S2_Auth *sa) 411list_create(S2_Auth *sa)
177{ 412{
@@ -208,12 +443,11 @@ list_create(S2_Auth *sa)
208 elm_genlist_homogeneous_set(o, EINA_TRUE); 443 elm_genlist_homogeneous_set(o, EINA_TRUE);
209 elm_genlist_mode_set(o, ELM_LIST_COMPRESS); 444 elm_genlist_mode_set(o, ELM_LIST_COMPRESS);
210 elm_layout_content_set(ly, "swallow.list", o); 445 elm_layout_content_set(ly, "swallow.list", o);
446 evas_object_event_callback_add(ly, EVAS_CALLBACK_MOUSE_DOWN, (Evas_Object_Event_Cb)list_mouse_down_cb, o);
211 //evas_object_smart_callback_add(o, "activated", 447 //evas_object_smart_callback_add(o, "activated",
212 //(Evas_Smart_Cb)list_click_cb, NULL); 448 //(Evas_Smart_Cb)list_click_cb, NULL);
213 //evas_object_smart_callback_add(o, "moved", 449 //evas_object_smart_callback_add(o, "moved",
214 //(Evas_Smart_Cb)list_reorder_cb, NULL); 450 //(Evas_Smart_Cb)list_reorder_cb, NULL);
215 //evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_DOWN,
216 //(Evas_Object_Event_Cb)list_rightclick_cb, NULL);
217 451
218 evas_object_show(win); 452 evas_object_show(win);
219 return win; 453 return win;