2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <Elementary.h>
28 #define STYLE_TITLE "title"
29 #define STYLE_VIDEO "video"
30 #define STYLE_AUDIO "audio"
31 #define STYLE_ALBUM "album"
32 #define STYLE_COMMON "common"
34 #define DEFAULT_TITLE "No Information"
35 #define UNKNOWN_DEVICE "Unknown device"
36 #define MESSAGE_DELETE "Are you sure you want to delete the"
37 #define MESSAGE_HISTORY_BANNER "Your history has been cleared"
38 #define KEY_DBAR_ITEM "dbar.item"
39 #define ICON_PIN "pin"
40 #define ICON_LOCK "lock"
42 #define ASPECT_RATIO ((double)198 / (double)(166))
43 #define LABEL_BUFMAX 512
44 #define DBAR_PADDING 10
45 #define FUNCS_PADDING 3
46 #define BUF_DELIMITER 2
47 #define BUF_STRING 128
49 #define IMG_FUNCS_FAVORITE IMAGEDIR"/ico_favorite_channel_nor.png"
50 #define IMG_FUNCS_PIN IMAGEDIR"/ico_pin_channel_nor.png"
51 #define IMG_FUNCS_LOCK IMAGEDIR"/ico_locked_channel_nor.png"
67 struct _dbar_item *cur;
68 struct bar_cb focus_cb;
72 enum _dbar_state state;
77 struct engine_dbar_item *it;
78 struct _dbar_data *bar;
79 struct bar_info *xbar;
83 struct _dbar_item_loader {
84 enum engine_dbar_item_style style;
85 Evas_Object *(*loader)(Evas_Object *p, struct engine_dbar_item *it,
89 static void _bring_in_middle(Evas_Object *scr, Evas_Object *obj)
91 Evas_Coord y, h, sy, sh, rx, ry, rw, rh, my, smy, ch;
96 evas_object_geometry_get(obj, NULL, &y, NULL, &h);
97 evas_object_geometry_get(scr, NULL, &sy, NULL, &sh);
98 elm_scroller_region_get(scr, &rx, &ry, &rw, &rh);
99 elm_scroller_child_size_get(scr, NULL, &ch);
102 smy = sy + (sh >> 1);
108 else if (ry + rh > ch)
111 elm_scroller_region_bring_in(scr, rx, ry, rw, rh);
114 static void _focused(void *data, Evas_Object *obj, void *ei)
116 struct _dbar_item *foc;
117 struct _dbar_data *bar;
128 r = bar->focus_cb.func(bar->focus_cb.data, foc->eo);
130 _bring_in_middle(bar->scr, foc->eo);
133 bar->state = DBAR_STATE_DBAR;
138 switch (bar->state) {
139 case DBAR_STATE_XBAR:
140 eo = bar->cur->xbar->ops->get_object(bar->cur->xbar);
142 elm_object_signal_emit(eo, SIG_UNFOCUS_TO_DBAR,
144 elm_object_signal_emit(foc->eo, SIG_UNFOCUS_FROM_XBAR,
147 if (foc != bar->cur) {
148 elm_object_signal_emit(bar->cur->eo, SIG_HIDE,
150 bar->cur->xbar->ops->hide(bar->cur->xbar);
151 foc->xbar->ops->update(foc->xbar, foc->it, foc->eo);
152 foc->xbar->ops->show(foc->xbar);
155 case DBAR_STATE_HIDE:
156 eo = foc->xbar->ops->get_object(foc->xbar);
158 elm_object_signal_emit(eo, SIG_SHOW, SRC_PROG);
159 r = bar->focus_cb.func(bar->focus_cb.data, foc->eo);
161 _bring_in_middle(bar->scr, foc->eo);
163 foc->xbar->ops->update(foc->xbar, foc->it, foc->eo);
165 case DBAR_STATE_DBAR:
166 eo = foc->xbar->ops->get_object(foc->xbar);
168 elm_object_signal_emit(eo, SIG_SHOW, SRC_PROG);
170 r = bar->focus_cb.func(bar->focus_cb.data, foc->eo);
172 _bring_in_middle(bar->scr, foc->eo);
174 if (foc != bar->cur && bar->cur->xbar)
175 bar->cur->xbar->ops->hide(bar->cur->xbar);
177 foc->xbar->ops->update(foc->xbar, foc->it, foc->eo);
185 bar->state = DBAR_STATE_DBAR;
188 static void _mouse_over(void *data, Evas *e, Evas_Object *obj, void *ei)
190 struct _dbar_item *item;
193 _ERR("Invalide argument");
199 if (elm_object_focus_get(item->eo))
202 elm_object_focus_set(item->eo, EINA_TRUE);
205 static void _clicked(void *data, Evas *e, Evas_Object *obj, void *ei)
207 struct _dbar_item *item;
208 Evas_Event_Mouse_Up *ev;
209 Evas_Coord x, y, w, h;
216 evas_object_geometry_get(obj, &x, &y, &w, &h);
217 if (ev->canvas.x < x || ev->canvas.x > x + w ||
218 ev->canvas.y < y || ev->canvas.y > y + h)
222 engine_dbar_item_launch(item->it);
225 static int _launch_app(struct bar_info *info)
227 struct _dbar_data *bar;
228 struct _dbar_item *item;
237 _ERR("Invalid argument");
241 return engine_dbar_item_launch(item->it);
244 static inline Evas_Object *_load_bg(Evas_Object *base,
245 struct engine_dbar_item *it)
253 bg = evas_object_rectangle_add(evas_object_evas_get(base));
255 _ERR("bg add failed");
262 engine_dbar_item_get_color(it, &r, &g, &b);
263 evas_object_color_set(bg, r, g, b, 255);
268 static Evas_Object *_load_title(Evas_Object *p, struct engine_dbar_item *it,
277 name = engine_dbar_item_get_name(it);
281 ly = elm_layout_add(p);
283 _ERR("layout add failed");
287 elm_layout_file_set(ly, EDJEFILE, GRP_DBAR_LABEL);
288 elm_object_part_text_set(ly, PART_TITLE,
289 engine_dbar_item_get_name(it));
296 static Evas_Object *_load_ly(Evas_Object *p,
297 struct engine_dbar_item *it,
303 if (!p || !it || !group)
306 ly = elm_layout_add(p);
308 _ERR("layout add failed");
311 elm_layout_file_set(ly, EDJEFILE, group);
313 bg = _load_bg(ly, it);
318 elm_object_part_content_set(ly, PART_BG, bg);
323 static const char *_trim(char *str)
344 static void _put_icon(Evas_Object *ly, const char *file, const char *part,
345 const char *def_sig, const char *def_src,
346 Eina_Bool make_thumbnail)
350 if (file && strlen(file) > 0) {
351 ic = elm_icon_add(ly);
353 if (make_thumbnail) {
355 elm_icon_thumb_set(ic, file, NULL);
357 elm_image_file_set(ic, file, NULL);
359 elm_image_fill_outside_set(ic, EINA_TRUE);
360 elm_object_part_content_set(ly, part, ic);
363 _ERR("icon add failed");
366 elm_object_signal_emit(ly, def_sig, def_src);
369 static void _lbl_start_slide(void *data, Evas_Object *obj, void *ei)
371 elm_label_ellipsis_set(data, EINA_FALSE);
372 elm_label_slide_mode_set(data, ELM_LABEL_SLIDE_MODE_AUTO);
373 elm_label_slide_go(data);
376 static void _lbl_stop_slide(void *data, Evas_Object *obj, void *ei)
378 elm_label_ellipsis_set(data, EINA_TRUE);
379 elm_label_slide_mode_set(data, ELM_LABEL_SLIDE_MODE_NONE);
380 elm_label_slide_go(data);
383 static Evas_Object *_add_icon(Evas_Object *box, const char *file)
388 _ERR("Invalid argument");
392 ic = elm_icon_add(box);
394 _ERR("icon add failed");
398 elm_image_file_set(ic, file, NULL);
399 elm_image_no_scale_set(ic, EINA_TRUE);
400 evas_object_show(ic);
402 elm_box_pack_end(box, ic);
407 static void _load_funcs(const char *icon, Evas_Object *p)
409 Evas_Object *box, *ic;
411 char delimiter[BUF_DELIMITER] = ",";
413 char str[BUF_STRING];
417 _ERR("Invalid argument");
421 padding = elm_config_scale_get() * FUNCS_PADDING;
422 box = elm_box_add(p);
424 _ERR("box add failed");
427 elm_object_part_content_set(p, PART_FUNCS, box);
428 elm_box_padding_set(box, padding, padding);
429 elm_box_horizontal_set(box, EINA_TRUE);
437 iter = strtok(str, delimiter);
439 if (!strcmp(iter, ICON_PIN))
441 else if (!strcmp(iter, ICON_LOCK))
444 iter = strtok(NULL, delimiter);
448 ic = _add_icon(box, IMG_FUNCS_PIN);
450 _ERR("icon add failed");
451 evas_object_del(box);
457 ic = _add_icon(box, IMG_FUNCS_LOCK);
459 _ERR("icon add failed");
460 evas_object_del(box);
466 static Evas_Object *_add_label(Evas_Object *ly,
467 const char *style, const char *name)
471 if (!ly || !style || !name) {
472 _ERR("Invalid argument");
476 lbl = elm_label_add(ly);
478 _ERR("failed to create label");
481 elm_object_style_set(lbl, style);
482 elm_object_text_set(lbl, name);
483 evas_object_show(lbl);
488 static Evas_Object *_add_slide_label(Evas_Object *ly,
489 const char *name, const char *style)
494 if (!ly || !name || !style) {
495 _ERR("Invalid argument");
499 lbl = _add_label(ly, style, name);
504 elm_label_ellipsis_set(lbl, EINA_TRUE);
505 s = edje_object_data_get(elm_layout_edje_get(ly),
508 elm_label_wrap_width_set(lbl, atoi(s));
510 _ERR("No title width exist");
512 elm_label_slide_speed_set(lbl, LABEL_SLIDE_SPEED);
513 evas_object_smart_callback_add(ly, "focused", _lbl_start_slide, lbl);
514 evas_object_smart_callback_add(ly, "unfocused", _lbl_stop_slide, lbl);
519 static Evas_Object *_load_content_broadcast(Evas_Object *p,
520 const char *style, struct engine_dbar_item_content *ctnt,
521 struct engine_dbar_item *it)
523 Evas_Object *ly, *lbl;
524 const char *channel, *progname, *progtime, *icon;
526 if (!p || !style || !ctnt || !it) {
527 _ERR("Invalid argument");
531 ly = _load_ly(p, it, style);
535 channel = engine_dbar_item_get_content_subtitle(ctnt);
536 _trim((char *)channel);
538 progname = engine_dbar_item_get_content_description(ctnt);
539 _trim((char *)progname);
541 progtime = engine_dbar_item_get_content_detail(ctnt);
542 _trim((char *)progtime);
544 icon = engine_dbar_item_get_content_icon(ctnt);
545 if (icon && strlen(icon) != 0)
546 _load_funcs(_trim((char *)icon), ly);
548 lbl = _add_label(ly, STYLE_LABEL_SLIDE_CENTER_40,
549 _trim((char *)engine_dbar_item_get_name(it)));
552 elm_object_part_content_set(ly, PART_NUMBER, lbl);
554 if (!progname || strlen(progname) <= 0) {
555 if (!channel || strlen(channel) <= 0)
556 channel = _(DEFAULT_TITLE);
558 lbl = _add_slide_label(ly, channel, STYLE_LABEL_SLIDE_LEFT_32);
561 elm_object_part_content_set(ly, PART_PROGRAM, lbl);
566 lbl = _add_slide_label(ly, progname, STYLE_LABEL_SLIDE_LEFT_32);
569 elm_object_part_content_set(ly, PART_PROGRAM, lbl);
571 lbl = _add_label(ly, STYLE_LABEL_SLIDE_LEFT_20, channel);
574 elm_object_part_content_set(ly, PART_CHANNEL, lbl);
576 lbl = _add_label(ly, STYLE_LABEL_SLIDE_LEFT_20, progtime);
579 elm_object_part_content_set(ly, PART_DURATION, lbl);
583 _ERR("failed to create label");
588 static Evas_Object *_load_content_history(Evas_Object *p,
589 const char *style, struct engine_dbar_item_content *ctnt,
590 struct engine_dbar_item *it)
596 ly = _load_ly(p, it, style);
600 bg = _load_bg(ly, it);
605 elm_object_part_content_set(ly, PART_BG2, bg);
607 name = engine_dbar_item_get_name(it);
609 if (!name || strlen(name) <= 0)
610 name = _(DEFAULT_TITLE);
612 _put_icon(ly, engine_dbar_item_get_content_icon(ctnt),
613 PART_ICON, SIG_SHOW_DEFAULT_ICON, SRC_PROG,
616 elm_object_part_text_set(ly, PART_TITLE, name);
621 static Evas_Object *_load_content_common(Evas_Object *p,
622 const char *style, struct engine_dbar_item_content *ctnt,
623 struct engine_dbar_item *it)
628 ly = _load_ly(p, it, style);
632 name = engine_dbar_item_get_name(it);
634 if (!name || strlen(name) <= 0)
635 name = _(DEFAULT_TITLE);
637 _put_icon(ly, engine_dbar_item_get_content_thumbnail(ctnt),
638 PART_THUMB, SIG_SHOW_DEFAULT_THUMB, SRC_PROG,
640 _put_icon(ly, engine_dbar_item_get_content_icon(ctnt),
641 PART_ICON, SIG_SHOW_DEFAULT_ICON, SRC_PROG,
644 elm_object_part_text_set(ly, PART_TITLE, name);
645 elm_object_part_text_set(ly, PART_SUBTITLE, _trim((char *)
646 engine_dbar_item_get_content_subtitle(ctnt)));
651 static Evas_Object *_load_content_music(Evas_Object *p,
652 const char *style, struct engine_dbar_item_content *ctnt,
653 struct engine_dbar_item *it)
659 ly = _load_ly(p, it, style);
663 name = engine_dbar_item_get_name(it);
665 if (!name || strlen(name) <= 0)
666 name = _(DEFAULT_TITLE);
668 _put_icon(ly, engine_dbar_item_get_content_thumbnail(ctnt),
669 PART_THUMB, SIG_SHOW_DEFAULT_THUMB, SRC_PROG,
671 _put_icon(ly, engine_dbar_item_get_content_icon(ctnt),
672 PART_ICON, SIG_SHOW_DEFAULT_ICON, SRC_PROG,
675 lbl = _add_slide_label(ly, name, STYLE_LABEL_SLIDE_LEFT);
680 elm_object_part_content_set(ly, PART_TITLE, lbl);
682 elm_object_part_text_set(ly, PART_SUBTITLE, _trim((char *)
683 engine_dbar_item_get_content_subtitle(ctnt)));
688 static Evas_Object *_load_content_source(Evas_Object *p,
689 const char *style, struct engine_dbar_item_content *ctnt,
690 struct engine_dbar_item *it)
695 ly = _load_ly(p, it, style);
699 _put_icon(ly, engine_dbar_item_get_content_thumbnail(ctnt),
700 PART_THUMB, SIG_SHOW_DEFAULT_THUMB, SRC_PROG,
703 name = engine_dbar_item_get_name(it);
705 if (!name || strlen(name) <= 0)
706 name = _(UNKNOWN_DEVICE);
707 elm_object_part_text_set(ly, PART_TITLE, name);
708 elm_object_part_text_set(ly, PART_SUBTITLE, _trim((char *)
709 engine_dbar_item_get_content_subtitle(ctnt)));
714 static Evas_Object *_load_content_notification(Evas_Object *p,
715 const char *style, struct engine_dbar_item_content *ctnt,
716 struct engine_dbar_item *it)
719 const char *title, *subtitle, *icon, *description;
722 icon = engine_dbar_item_get_content_icon(ctnt);
723 title = engine_dbar_item_get_name(it);
724 subtitle = engine_dbar_item_get_content_subtitle(ctnt);
725 description = engine_dbar_item_get_content_description(ctnt);
727 ly = _load_ly(p, it, GRP_DBAR_NOTIFICATION);
731 bg = _load_bg(ly, it);
736 elm_object_part_content_set(ly, PART_BG2, bg);
739 elm_object_part_text_set(ly, PART_TITLE, title);
742 elm_object_part_text_set(ly, PART_SUBTITLE, subtitle);
745 elm_object_part_text_set(ly, PART_DESCRIPTION, description);
748 _put_icon(ly, icon, PART_THUMB,
749 SIG_SHOW_DEFAULT_THUMB, SRC_PROG,
752 elm_object_focus_allow_set(ly, EINA_TRUE);
757 static Evas_Object *_load_content(Evas_Object *p, struct engine_dbar_item *it,
760 struct engine_dbar_item_content *ctnt;
761 const Eina_List *ctnts;
764 ctnts = engine_dbar_item_get_contents(it);
768 ctnt = eina_list_data_get(ctnts);
773 switch (engine_dbar_item_get_content_type(ctnt)) {
774 case ENGINE_DBAR_CONTENT_TYPE_IMAGE:
775 case ENGINE_DBAR_CONTENT_TYPE_VIDEO:
776 eo = _load_content_common(p, GRP_DBAR_COMMON, ctnt, it);
780 case ENGINE_DBAR_CONTENT_TYPE_BROADCAST:
781 eo = _load_content_broadcast(p, GRP_DBAR_BROADCAST, ctnt, it);
785 case ENGINE_DBAR_CONTENT_TYPE_APP:
786 eo = _load_content_common(p, GRP_DBAR_APP, ctnt, it);
790 case ENGINE_DBAR_CONTENT_TYPE_MUSIC:
791 eo = _load_content_music(p, GRP_DBAR_MUSIC, ctnt, it);
795 case ENGINE_DBAR_CONTENT_TYPE_SOURCE:
796 eo = _load_content_source(p, GRP_DBAR_SOURCE, ctnt, it);
800 case ENGINE_DBAR_CONTENT_TYPE_NOTIFICATION_ONGOING:
801 case ENGINE_DBAR_CONTENT_TYPE_NOTIFICATION_NOTI:
802 eo = _load_content_notification(p, NULL, ctnt, it);
806 case ENGINE_DBAR_CONTENT_TYPE_HISTORY:
807 eo = _load_content_history(p, GRP_DBAR_HISTORY, ctnt, it);
812 eo = _load_content_common(p, GRP_DBAR_COMMON, ctnt, it);
821 static void _img_resized(void *data, Evas *e, Evas_Object *obj, void *ei)
825 evas_object_geometry_get(obj, NULL, NULL, &w, &h);
826 evas_object_image_fill_set(obj, 0, 0, w, h);
829 static Evas_Object *_load_album_thumb(Evas_Object *p, const Eina_List *ctnts)
838 const char * const parts[] = {
846 const char * const sig_video[] = {
847 SIG_SHOW_THUMB1_VIDEO,
848 SIG_SHOW_THUMB2_VIDEO,
849 SIG_SHOW_THUMB3_VIDEO,
850 SIG_SHOW_THUMB4_VIDEO,
851 SIG_SHOW_THUMB5_VIDEO,
852 SIG_SHOW_THUMB6_VIDEO
854 struct engine_dbar_item_content *ctnt;
857 _ERR("Invalid argument");
861 ly = elm_layout_add(p);
863 _ERR("icon add failed");
866 elm_layout_file_set(ly, EDJEFILE, GRP_ALBUM_THUMB);
868 ctnt_cnt = eina_list_count(ctnts);
872 } else if (ctnt_cnt >= 3) {
880 l = (Eina_List *)ctnts;
882 /* TODO, show default photo/video icon */
883 for (i = 0; i < ctnt_cnt; i++) {
884 ctnt = eina_list_data_get(l);
885 thumb = engine_dbar_item_get_content_thumbnail(ctnt);
886 ic = evas_object_image_add(evas_object_evas_get(ly));
891 evas_object_image_preload(ic, EINA_TRUE);
892 evas_object_image_file_set(ic, thumb, NULL);
893 evas_object_event_callback_add(ic, EVAS_CALLBACK_RESIZE,
895 elm_object_part_content_set(ly, parts[i], ic);
897 if (engine_dbar_item_get_content_type(ctnt) ==
898 ENGINE_DBAR_CONTENT_TYPE_VIDEO)
899 elm_object_signal_emit(ly, sig_video[i], SRC_PROG);
901 l = eina_list_next(l);
907 elm_object_signal_emit(ly, sig, SRC_PROG);
912 static Evas_Object *_load_album(Evas_Object *p, struct engine_dbar_item *it,
919 ly = _load_ly(p, it, GRP_DBAR_ALBUM);
923 name = engine_dbar_item_get_name(it);
927 ly2 = _load_album_thumb(ly, engine_dbar_item_get_contents(it));
933 elm_object_part_content_set(ly, PART_THUMB, ly2);
934 elm_object_part_text_set(ly, PART_TITLE, name);
941 Evas_Object *_item_load(Evas_Object *p, struct engine_dbar_item *it,
942 Eina_Bool *fill, Eina_Bool *focus)
944 static struct _dbar_item_loader loaders[] = {
946 .style = ENGINE_DBAR_ITEM_STYLE_CONTENT,
947 .loader = _load_content
950 .style = ENGINE_DBAR_ITEM_STYLE_LABEL,
951 .loader = _load_title
954 .style = ENGINE_DBAR_ITEM_STYLE_ALBUM,
955 .loader = _load_album
959 enum engine_dbar_item_style style;
963 _ERR("Invalid argument");
967 style = engine_dbar_item_get_style(it);
968 if (style >= ENGINE_DBAR_ITEM_STYLE_MAX)
969 style = ENGINE_DBAR_ITEM_STYLE_CONTENT;
971 for (i = 0; i < sizeof(loaders) / sizeof(*loaders); i++) {
972 if (loaders[i].style == style) {
973 eo = loaders[i].loader(p, it, fill);
977 if (style == ENGINE_DBAR_ITEM_STYLE_LABEL)
986 _ERR("cannot find style: %d", style);
991 static int _add_bar(struct bar_info *info, Evas_Object *base)
993 Evas_Object *ly, *scr, *tbl, *bx;
994 struct _dbar_data *bar;
997 if (!base || !info || !info->data) {
998 _ERR("Invalid argument");
1003 padding = elm_config_scale_get() * DBAR_PADDING;
1005 ly = elm_layout_add(base);
1007 _ERR("layout add failed");
1010 elm_layout_file_set(ly, EDJEFILE, GRP_DBAR_ITEM);
1012 scr = elm_scroller_add(ly);
1014 _ERR("scroller add failed");
1015 evas_object_del(ly);
1018 elm_scroller_policy_set(scr, ELM_SCROLLER_POLICY_OFF,
1019 ELM_SCROLLER_POLICY_OFF);
1021 bx = elm_box_add(scr);
1023 _ERR("box add failed");
1024 evas_object_del(ly);
1028 tbl = elm_table_add(bx);
1030 _ERR("table add failed");
1031 evas_object_del(ly);
1035 evas_object_size_hint_align_set(tbl, 0.5, 0.0);
1036 evas_object_size_hint_weight_set(tbl, EVAS_HINT_EXPAND,
1038 elm_table_homogeneous_set(tbl, EINA_FALSE);
1039 elm_table_padding_set(tbl, padding, padding);
1041 evas_object_show(tbl);
1042 evas_object_show(bx);
1043 elm_box_pack_end(bx, tbl);
1044 elm_object_content_set(scr, bx);
1045 elm_object_part_content_set(ly, PART_CONTENT, scr);
1055 static inline int _get_dbar_row_col(struct _dbar_data *bar,
1056 Eina_Bool fill, int *row, int *col)
1060 if (!bar || !row || !col || bar->content_column <= 0)
1063 *row = bar->tbl_idx / bar->content_column;
1064 *col = bar->tbl_idx % bar->content_column;
1069 if (bar->content_column > 1 && *col > 0) {
1073 r = bar->content_column - *col;
1078 static Eina_Bool _xbar_focused(void *data, Evas_Object *foc)
1080 struct _dbar_data *bar;
1081 struct _dbar_item *cur;
1083 if (!data || !foc) {
1084 _ERR("Invalid argument");
1090 _ERR("There is no dbar item");
1095 switch (bar->state) {
1096 case DBAR_STATE_DBAR:
1097 elm_object_signal_emit(foc, SIG_INITIAL_FOCUS, SRC_PROG);
1098 elm_object_signal_emit(cur->eo, SIG_UNFOCUS_TO_XBAR,
1105 bar->state = DBAR_STATE_XBAR;
1110 static int _init_child_bars(struct _dbar_item *item)
1112 struct bar_info *xbar;
1116 _ERR("Invalid argument");
1120 xbar = calloc(1, sizeof(*xbar));
1122 _ERR("failed to calloc xbar");
1126 xbar->cb.func = _xbar_focused;
1127 xbar->cb.data = item->bar;
1129 r = init_delete_bar(xbar);
1140 static void _unfocused(void *data, Evas_Object *obj, const char *emission,
1143 struct _dbar_item *cur;
1144 struct _dbar_data *bar;
1147 _ERR("Invalid argument");
1154 bar->state = DBAR_STATE_HIDE;
1159 cur->xbar->ops->hide(cur->xbar);
1162 static void _cancel_delete_popup(void *data, Evas_Object *obj,
1163 const char *emission, const char *source)
1165 struct _dbar_item *cur;
1168 _ERR("Invalid argument");
1175 elm_object_focus_set(cur->eo, EINA_TRUE);
1178 static struct _dbar_item *_pack_item(struct _dbar_data *bar,
1179 struct engine_dbar_item *it)
1182 struct _dbar_item *item;
1188 enum engine_dbar_content_type type;
1189 struct engine_dbar_item_content *ctnt;
1194 item = calloc(1, sizeof(*item));
1196 _ERR("Calloc failed");
1203 eo = _item_load(bar->tbl, it, &fill, &focus);
1209 step = _get_dbar_row_col(bar, fill, &row, &col);
1211 evas_object_del(eo);
1216 evas_object_size_hint_align_set(eo, EVAS_HINT_FILL, 0.0);
1217 elm_table_pack(bar->tbl, eo, col, row,
1218 fill ? bar->content_column : 1, 1);
1219 evas_object_show(eo);
1221 bar->tbl_idx += step;
1222 bar->state = DBAR_STATE_HIDE;
1226 item->focus = focus;
1228 evas_object_event_callback_add(eo,
1229 EVAS_CALLBACK_MOUSE_MOVE, _mouse_over, item);
1230 evas_object_event_callback_add(eo,
1231 EVAS_CALLBACK_MOUSE_UP, _clicked, item);
1232 evas_object_smart_callback_add(eo, "focused", _focused, item);
1233 elm_object_signal_callback_add(eo, SIG_UNFOCUS_TO_HBAR, SRC_PROG,
1236 ctnt = eina_list_data_get(engine_dbar_item_get_contents(it));
1238 _ERR("failed to get ci");
1242 type = engine_dbar_item_get_content_type(ctnt);
1243 if ((type == ENGINE_DBAR_CONTENT_TYPE_NOTIFICATION_NOTI ||
1244 type == ENGINE_DBAR_CONTENT_TYPE_HISTORY) &&
1246 r = _init_child_bars(item);
1252 r = item->xbar->ops->add_bar(item->xbar, bar->base);
1254 item->xbar->ops->release(item->xbar);
1259 eo = item->xbar->ops->get_object(item->xbar);
1261 elm_object_signal_callback_add(eo,
1263 SRC_PROG, _cancel_delete_popup, item);
1269 static int _update(struct bar_info *info, void *eng, void *data)
1271 struct _dbar_data *bar;
1272 const Eina_List *list;
1274 struct engine_dbar_item *it;
1275 struct _dbar_item *item;
1276 const char *noctnt_title;
1277 const char *noctnt_desc;
1280 if (!info || !info->data) {
1281 _ERR("Invalid argument");
1287 elm_table_clear(bar->tbl, EINA_TRUE);
1290 EINA_LIST_FREE(bar->list, item) {
1292 item->xbar->ops->release(item->xbar);
1294 evas_object_del(item->eo);
1300 engine_bar_item_get_content_column(eng, &bar->content_column);
1303 list = engine_get_dbar_items(eng);
1305 noctnt_title = engine_bar_item_get_noctnt_title(eng);
1306 noctnt_desc = engine_bar_item_get_noctnt_desc(eng);
1307 elm_object_part_text_set(bar->ly,
1309 noctnt_title ? noctnt_title : "");
1310 elm_object_part_text_set(bar->ly,
1312 noctnt_desc ? noctnt_desc : "");
1315 elm_object_part_text_set(bar->ly, PART_DEFAULT_TITLE, "");
1316 elm_object_part_text_set(bar->ly, PART_DEFAULT_DESC, "");
1318 EINA_LIST_FOREACH((Eina_List *)list, l, it) {
1319 item = _pack_item(bar, it);
1323 bar->list = eina_list_append(bar->list, item);
1330 static Evas_Object *_get_object(struct bar_info *info)
1332 struct _dbar_data *bar;
1334 if (!info || !info->data) {
1335 _ERR("Invalid argument");
1344 static Evas_Object *_get_item(struct bar_info *info)
1346 struct _dbar_data *bar;
1347 struct _dbar_item *item;
1350 if (!info || !info->data) {
1351 _ERR("Invalid argument");
1357 return bar->cur->eo;
1359 EINA_LIST_FOREACH(bar->list, l, item) {
1360 if (elm_object_focus_allow_get(item->eo)) {
1362 return bar->cur->eo;
1369 static void _show(struct bar_info *info)
1371 struct _dbar_data *bar;
1372 struct _dbar_item *item;
1375 if (!info || !info->data) {
1376 _ERR("Invalid argument");
1382 EINA_LIST_FOREACH(bar->list, l, item) {
1384 elm_object_focus_allow_set(item->eo, EINA_TRUE);
1386 elm_object_signal_emit(bar->ly, SIG_SHOW, SRC_PROG);
1389 static void _hide(struct bar_info *info)
1391 struct _dbar_data *bar;
1392 struct _dbar_item *item;
1395 if (!info || !info->data) {
1396 _ERR("Invalid argument");
1402 EINA_LIST_FOREACH(bar->list, l, item) {
1403 elm_object_signal_emit(item->eo, SIG_HIDE, SRC_PROG);
1404 elm_object_focus_allow_set(item->eo, EINA_FALSE);
1407 item->xbar->ops->hide(item->xbar);
1409 elm_object_signal_emit(bar->ly, SIG_HIDE, SRC_PROG);
1412 static Eina_Bool _is_move(struct bar_info *info, int dir)
1414 struct _dbar_data *bar;
1415 struct _dbar_item *item;
1416 struct _dbar_item *_item;
1420 if (!info || !info->data) {
1421 _ERR("Invalid argument");
1431 if (bar->content_column == 1)
1434 elm_table_pack_get(item->eo, &x, NULL, NULL, NULL);
1445 l = eina_list_last(bar->list);
1446 _item = eina_list_data_get(l);
1447 if (item->eo != _item->eo)
1457 static Eina_Bool _move(struct bar_info *info)
1459 struct _dbar_data *bar;
1460 struct _dbar_item *item;
1463 if (!info || !info->data) {
1464 _ERR("Invalid argument");
1472 EINA_LIST_FOREACH(bar->list, l, item) {
1473 if (elm_object_focus_allow_get(item->eo))
1481 elm_object_focus_set(item->eo, EINA_TRUE);
1486 static enum bar_event _enter(struct bar_info *info)
1489 struct _dbar_data *bar;
1492 _ERR("Invalid argument");
1493 return BAR_EVENT_ERROR;
1499 switch (bar->state) {
1500 case DBAR_STATE_DBAR:
1501 r = _launch_app(info);
1504 return BAR_EVENT_DONE;
1507 return r ? BAR_EVENT_DONE : BAR_EVENT_PASS;
1510 static enum bar_event _move_right(struct bar_info *info)
1513 struct _dbar_data *bar;
1516 _ERR("Invalid argument");
1517 return BAR_EVENT_ERROR;
1523 switch (bar->state) {
1524 case DBAR_STATE_DBAR:
1525 if (_is_move(info, BAR_DIR_RIGHT)) {
1527 r = bar->cur->xbar->ops->move(bar->cur->xbar);
1531 return BAR_EVENT_ERROR;
1534 return r ? BAR_EVENT_DONE : BAR_EVENT_PASS;
1537 static enum bar_event _move_left(struct bar_info *info)
1539 struct _dbar_data *bar;
1542 _ERR("Invalid argument");
1543 return BAR_EVENT_ERROR;
1548 switch (bar->state) {
1549 case DBAR_STATE_XBAR:
1551 case DBAR_STATE_DBAR:
1552 if (_is_move(info, BAR_DIR_LEFT)) {
1553 if (bar->cur->xbar) {
1554 bar->cur->xbar->ops->hide(bar->cur->xbar);
1555 bar->state = DBAR_STATE_HIDE;
1557 return BAR_EVENT_MOVE;
1561 return BAR_EVENT_ERROR;
1564 return BAR_EVENT_PASS;
1567 static enum bar_event _key_event(struct bar_info *info, void *ei)
1569 Ecore_Event_Key *ev;
1573 return BAR_EVENT_ERROR;
1577 if (!strcmp(ev->keyname, KEY_ENTER))
1579 else if (!strcmp(ev->keyname, KEY_RIGHT))
1580 r = _move_right(info);
1581 else if (!strcmp(ev->keyname, KEY_LEFT) ||
1582 !strcmp(ev->keyname, KEY_BACK))
1583 r = _move_left(info);
1590 static enum bar_event _bar_event(struct bar_info *info, void *ei,
1593 struct _dbar_data *bar;
1597 return BAR_EVENT_ERROR;
1602 case BAR_EVENT_DONE:
1603 case BAR_EVENT_ERROR:
1605 case BAR_EVENT_PASS:
1606 r = _key_event(info, ei);
1608 case BAR_EVENT_MOVE:
1609 if (bar->state == DBAR_STATE_XBAR)
1621 static enum bar_event _key_down(struct bar_info *info, void *ei)
1623 struct _dbar_data *bar;
1624 struct _dbar_item *item;
1628 return BAR_EVENT_ERROR;
1634 return BAR_EVENT_ERROR;
1638 switch (bar->state) {
1639 case DBAR_STATE_HIDE:
1640 case DBAR_STATE_DBAR:
1643 case DBAR_STATE_XBAR:
1644 if (!bar->cur->xbar)
1647 r = bar->cur->xbar->ops->key_down(bar->cur->xbar, ei);
1650 return BAR_EVENT_ERROR;
1653 return _bar_event(info, ei, r);
1656 static void _release(struct bar_info *info)
1658 struct _dbar_data *bar;
1659 struct _dbar_item *item;
1662 _ERR("Invalid argument");
1671 EINA_LIST_FREE(bar->list, item) {
1673 item->xbar->ops->release(item->xbar);
1675 evas_object_del(item->eo);
1678 evas_object_del(bar->ly);
1687 static struct bar_ops dbar_ops = {
1688 .add_bar = _add_bar,
1690 .get_object = _get_object,
1691 .get_item = _get_item,
1692 .is_move = _is_move,
1696 .key_down = _key_down,
1697 .release = _release,
1700 int init_dynamic_bar(struct bar_info *info)
1702 struct _dbar_data *bar;
1707 bar = calloc(1, sizeof(*bar));
1709 _ERR("calloc failed");
1714 info->ops = &dbar_ops;
1716 if (!info->cb.func) {
1717 _ERR("invalid callback function");
1722 bar->focus_cb = info->cb;