From aaa9928f69335cd746c127e133d83e270b70d6d2 Mon Sep 17 00:00:00 2001 From: Jehun Lim Date: Tue, 30 Jun 2015 13:38:59 +0900 Subject: [PATCH 01/16] add button and gengrid edc : button for index in thumbnail area and gengrid for movie item Change-Id: Ic3a5c112a5d9e79ea33ae9c5e48d25e57ad62080 Signed-off-by: Jehun Lim --- include/define.h | 3 + include/view/base.h | 2 +- res/edc/mediahub-theme.edc | 1 + res/edc/widgets/button.edc | 51 +++++- res/edc/widgets/gengrid.edc | 392 ++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 447 insertions(+), 2 deletions(-) create mode 100644 res/edc/widgets/gengrid.edc diff --git a/include/define.h b/include/define.h index c0e2317..56003cb 100644 --- a/include/define.h +++ b/include/define.h @@ -42,5 +42,8 @@ #define COLOR_TEXT_DISABLED 87 87 87 128 #define COLOR_BTN_FOCUS 0 119 246 255 #define COLOR_BTN_SELECTED 64 136 211 255 +#define COLOR_ITEM_BG 56 55 59 255 +#define COLOR_ITEM_FOCUS 0 119 246 255 +#define COLOR_ITEM_FOCUS_0 0 119 246 0 #endif /* __AIR_MEDIAHUB_DEFINE_H__ */ diff --git a/include/view/base.h b/include/view/base.h index 965493c..470bc93 100644 --- a/include/view/base.h +++ b/include/view/base.h @@ -26,6 +26,6 @@ #define PART_THUMBNAIL_AREA "part.thumbnail_area" #define PART_BOTTOM_AREA "part.bottom_area" -#define STYLE_MENU_BTN "menu_btn" +#define STYLE_MENU_BTN "base_btn_menu" #endif /* __AIR_MEDIAHUB_VIEW_BASE_H__ */ diff --git a/res/edc/mediahub-theme.edc b/res/edc/mediahub-theme.edc index 8f01d57..4187a48 100644 --- a/res/edc/mediahub-theme.edc +++ b/res/edc/mediahub-theme.edc @@ -18,4 +18,5 @@ collections { #include "widgets/button.edc" + #include "widgets/gengrid.edc" } diff --git a/res/edc/widgets/button.edc b/res/edc/widgets/button.edc index b049524..2113a5b 100644 --- a/res/edc/widgets/button.edc +++ b/res/edc/widgets/button.edc @@ -19,7 +19,7 @@ #define TRANSITION_TIME 0.17 group { - name: "elm/button/base/menu_btn"; + name: "elm/button/base/base_btn_menu"; data.item: "focus_highlight" "on"; parts { part { @@ -126,6 +126,55 @@ group { } group { + name: "elm/button/base/base_btn_index"; + inherit: "elm/button/base/base_btn_menu"; + data.item: "focus_highlight" "on"; + parts { + part { + name: "bg"; + scale: 1; + description { + state: "default" 0.0; + min: 0 36; + color: 0 0 0 0; + fixed: 0 1; + } + description { + state: "focused" 0.0; + inherit: "default" 0.0; + color: COLOR_BTN_FOCUS; + } + } + part { + name: "elm.text"; + type: TEXT; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "bg"; + rel2.to: "bg"; + text { + font: FONT_LIGHT; + size: 36; + align: 0.0 0.5; + } + min: 82 0; + align: 0.0 0.5; + color: COLOR_TEXT_INDEX; + align: 0.0 0.0; + fixed: 1 1; + } + description { + state: "focused" 0.0; + inherit: "default" 0.0; + text.font: "TizenSans"; + color: COLOR_TEXT_FOCUS; + } + } + } +} + +group { name: "elm/button/base/viewer_btn_prev"; data.item, "focus_highlight" "on"; images { diff --git a/res/edc/widgets/gengrid.edc b/res/edc/widgets/gengrid.edc new file mode 100644 index 0000000..3e9a631 --- /dev/null +++ b/res/edc/widgets/gengrid.edc @@ -0,0 +1,392 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +group { + name: "elm/gengrid/item/movie_item/default"; + data.item: "selectraise" "on"; + data.item: "texts" "elm.text"; + data.item: "contents" "elm.swallow.icon"; + data.item: "focus_highlight" "on"; + parts { + part { + name: "elm.padding.bottom_right"; + type: SPACER; + scale: 1; + description { + state: "default" 0.0; + rel1.relative: 1.0 1.0; + min: 26 26; + align: 1.0 1.0; + fixed: 1 1; + } + } + part { + name: "map"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + perspective { + zplane: 0; + focal: 1000; + } + visible: 0; + } + description { + state: "clicked" 0.0; + inherit: "default" 0.0; + perspective.zplane: -100; + } + } + part { + name: "bg"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + rel2 { + to: "elm.padding.bottom_right"; + relative: 0.0 0.0; + } + fixed: 1 1; + visible: 0; + } + } + part { + name: "defaultbg"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "bg"; + rel2 { + to: "elm.bg.text"; + relative: 1.0 0.0; + } + color: 0 0 0 115; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + map.on: 1; + } + } + part { + name: "elm.swallow.icon"; + type: SWALLOW; + scale: 1; + mouse_events: 1; + description { + state : "default" 0.0; + rel1.to: "defaultbg"; + rel2.to: "defaultbg"; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + map.on: 1; + } + } + part { + name: "part_focus1"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "bg"; + rel2 { + to: "bg"; + relative: 1.0 0.0; + } + min: 0 3; + align: 0.5 0.0; + color: COLOR_ITEM_FOCUS; + fixed: 0 1; + visible: 0; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + map.on: 1; + visible: 1; + } + description { + state: "selected_0" 0.0; + inherit: "default" 0.0; + visible: 1; + color: COLOR_ITEM_FOCUS_0; + } + } + part { + name: "part_focus2"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: "part_focus1"; + relative: 0.0 1.0; + } + rel2 { + to: "elm.bg.text"; + relative: 0.0 0.0; + } + min: 3 0; + align: 0.0 0.5; + color: COLOR_ITEM_FOCUS; + fixed: 1 0; + visible: 0; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + map.on: 1; + visible: 1; + } + description { + state: "selected_0" 0.0; + inherit: "default" 0.0; + visible: 1; + color: COLOR_ITEM_FOCUS_0; + } + } + part { + name: "part_focus3"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: "part_focus1"; + relative: 1.0 1.0; + } + rel2 { + to: "elm.bg.text"; + relative: 1.0 0.0; + } + min: 3 0; + align: 1.0 0.5; + color: COLOR_ITEM_FOCUS; + fixed: 1 0; + visible: 0; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + map.on: 1; + visible: 1; + } + description { + state: "selected_0" 0.0; + inherit: "default" 0.0; + visible: 1; + color: COLOR_ITEM_FOCUS_0; + } + } + part { + name: "defaultbg_text"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: "bg"; + relative: 0.0 1.0; + } + rel2.to: "bg"; + min: 0 82; + align: 0.5 1.0; + color: COLOR_ITEM_BG; + fixed: 0 1; + } + } + part { + name: "elm.bg.text"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "defaultbg_text"; + rel2.to: "defaultbg_text"; + color: COLOR_ITEM_BG; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + color: COLOR_ITEM_FOCUS; + map.on: 1; + } + description { + state: "selected_0" 0.0; + inherit: "default" 0.0; + color: COLOR_ITEM_FOCUS_0; + } + } + part { + name: "elm.padding.text.left"; + type: SPACER; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "elm.bg.text"; + rel2 { + to: "elm.bg.text"; + relative: 0.0 0.0; + } + min: 18 82; + align: 0.0 0.0; + fixed: 1 1; + } + } + part { + name: "elm.padding.text.right"; + type: SPACER; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: "elm.bg.text"; + relative: 1.0 0.0; + } + rel2 { + to: "elm.bg.text"; + relative: 1.0 0.0; + } + min: 18 82; + align: 1.0 0.0; + fixed: 1 1; + } + } + part { + name: "elm.text"; + type: TEXT; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: "elm.padding.text.left"; + relative: 1.0 0.0; + } + rel2 { + to: "elm.padding.text.right"; + relative: 0.0 1.0; + } + text { + font: FONT_LIGHT; + size: 28; + align: 0.0 0.5; + } + color: COLOR_TEXT_FOCUS; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + color: COLOR_TEXT_FOCUS; + map.on: 1; + } + description { + state: "selected_0" 0.0; + inherit: "selected" 0.0; + } + } + } + programs { + program { + name: "go_active"; + signal: "elm,state,focused"; + source: "elm"; + action: STATE_SET "selected_0" 0.0; + target: "part_focus1"; + target: "part_focus2"; + target: "part_focus3"; + target: "elm.bg.text"; + target: "elm.text"; + after: "focus,in,anim"; + } + program { + name: "focus,in,anim"; + action: STATE_SET "selected" 0.0; + target: "defaultbg"; + target: "elm.swallow.icon"; + target: "part_focus1"; + target: "part_focus2"; + target: "part_focus3"; + target: "elm.bg.text"; + transition: LINEAR 0.17; + } + program { + name: "go_passive"; + signal: "elm,state,unfocused"; + source: "elm"; + action: STATE_SET "default" 0.0; + target: "elm.text"; + after: "focus,out,anim"; + } + program { + name: "focus,out,anim"; + action: STATE_SET "selected_0" 0.0; + target: "part_focus1"; + target: "part_focus2"; + target: "part_focus3"; + target: "elm.bg.text"; + transition: LINEAR 0.17; + after: "focus,out,anim,3"; + } + program { + name: "focus,out,anim,3"; + action: STATE_SET "default" 0.0; + target: "elm.swallow.icon"; + target: "defaultbg"; + target: "part_focus1"; + target: "part_focus2"; + target: "part_focus3"; + target: "elm.bg.text"; + } + } +} -- 2.7.4 From 7751cd59ff62f53dcd8d5f006db4f2f083f5fe75 Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Tue, 30 Jun 2015 16:23:37 +0900 Subject: [PATCH 02/16] fix rpmlint issue Change-Id: I3c207a4be5a51f3adf7c598ed0b5389ff36d0199 Signed-off-by: Minkyu Kang --- packaging/org.tizen.mediahub.spec | 1 + 1 file changed, 1 insertion(+) diff --git a/packaging/org.tizen.mediahub.spec b/packaging/org.tizen.mediahub.spec index d5a7724..2a6c12a 100644 --- a/packaging/org.tizen.mediahub.spec +++ b/packaging/org.tizen.mediahub.spec @@ -25,6 +25,7 @@ Media Hub Application %setup -q cp %{SOURCE1} . +%build cmake \ -DCMAKE_INSTALL_PREFIX=%{_appdir} \ -DPACKAGE_NAME=%{name} \ -- 2.7.4 From 241e5fc9ffb0689f3fded34c719a037e219b284f Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Tue, 30 Jun 2015 19:58:51 +0900 Subject: [PATCH 03/16] add timeout_handler for show/hide the bar Change-Id: If65892b0199abf91fec094727c8b08ea258040fa Signed-off-by: Minkyu Kang --- CMakeLists.txt | 1 + include/util/controller.h | 2 + include/util/timeout_handler.h | 32 +++++++++ include/view/viewer.h | 3 + res/edc/view/viewer.edc | 28 ++++++++ src/util/controller.c | 51 ++++++++++++++- src/util/timeout_handler.c | 144 +++++++++++++++++++++++++++++++++++++++++ src/view/viewer.c | 54 ++++++++++++++++ 8 files changed, 312 insertions(+), 3 deletions(-) create mode 100644 include/util/timeout_handler.h create mode 100644 src/util/timeout_handler.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 5f67dbe..848459a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,7 @@ src/layout/gallery.c src/layout/music.c src/util/gridmgr.c src/util/controller.c +src/util/timeout_handler.c src/data/mediadata.c ) diff --git a/include/util/controller.h b/include/util/controller.h index 8a6a4c3..6c3cead 100644 --- a/include/util/controller.h +++ b/include/util/controller.h @@ -19,6 +19,8 @@ struct controller; struct controller_ops { void (*show)(void *handle); void (*hide)(void *handle); + void (*enable)(void *handle); + void (*disable)(void *handle); bool (*add_control)(void *handle, const char *name, int loc, const char *style, const char *part); void (*add_callback)(void *handle, diff --git a/include/util/timeout_handler.h b/include/util/timeout_handler.h new file mode 100644 index 0000000..29dd6e1 --- /dev/null +++ b/include/util/timeout_handler.h @@ -0,0 +1,32 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#ifndef __AIR_MEDIAHUB_TIMEOUT_HANDLER_H__ +#define __AIR_MEDIAHUB_TIMEOUT_HANDLER_H__ + +struct timeout_handler; + +typedef void (*timeout_event_cb)(void *data, int type, void *ei); + +struct timeout_handler *timeout_handler_init(double timeout, + timeout_event_cb timeout_cb, void *timeout_data, + timeout_event_cb event_cb, void *event_data); + +void timeout_handler_fini(struct timeout_handler *handle); + +void timeout_handler_reset(struct timeout_handler *handle); + +#endif diff --git a/include/view/viewer.h b/include/view/viewer.h index 33cdc14..1babe1c 100644 --- a/include/view/viewer.h +++ b/include/view/viewer.h @@ -37,6 +37,9 @@ #define SIG_SET_PAUSE "set,pause,icon" #define SIG_BTN_CLICKED "btn,clicked" #define SIG_BTN_CALLBACK "btn,callback" +#define SIG_HIDE_BAR "hide,bar" +#define SIG_SHOW_BAR "show,bar" +#define SIG_SHOWED_BAR "showed,bar" /* source */ #define SRC_BTN_PREV "prev" diff --git a/res/edc/view/viewer.edc b/res/edc/view/viewer.edc index e3c6573..a8007a1 100644 --- a/res/edc/view/viewer.edc +++ b/res/edc/view/viewer.edc @@ -14,6 +14,8 @@ * limitations under the License. */ +#define TRANSITION_TIME 0.25 + group { name: GRP_VIEWER_VIEW; parts { @@ -426,4 +428,30 @@ group { } } } + + programs { + program { + name: SIG_HIDE_BAR; + signal: SIG_HIDE_BAR; + source: ""; + action: STATE_SET "hide" 0.0; + target: "toparea"; + target: "bottomarea"; + transition: LINEAR TRANSITION_TIME; + } + program { + name: SIG_SHOW_BAR; + signal: SIG_SHOW_BAR; + source: ""; + action: STATE_SET "default" 0.0; + target: "toparea"; + target: "bottomarea"; + transition: LINEAR TRANSITION_TIME; + after: SIG_SHOWED_BAR; + } + program { + name: SIG_SHOWED_BAR; + action: SIGNAL_EMIT SIG_SHOWED_BAR ""; + } + } } diff --git a/src/util/controller.c b/src/util/controller.c index 1be6e8c..b43c4f9 100644 --- a/src/util/controller.c +++ b/src/util/controller.c @@ -174,7 +174,7 @@ static void _signal(void *handle, int loc, const char *signal) elm_object_signal_emit(ctl->obj, signal, ""); } -static void _show(void *handle) +static void _enable(void *handle) { struct _priv *p; struct _control *ctl; @@ -193,10 +193,53 @@ static void _show(void *handle) evas_object_freeze_events_set(ctl->obj, EINA_FALSE); elm_object_focus_allow_set(ctl->obj, EINA_TRUE); + } +} + +static void _disable(void *handle) +{ + struct _priv *p; + struct _control *ctl; + Eina_List *l; + + if (!handle) { + _ERR("invalid parameter"); + return; + } + + p = handle; + + EINA_LIST_FOREACH(p->list, l, ctl) { + if (!ctl->obj) + continue; + + evas_object_freeze_events_set(ctl->obj, EINA_TRUE); + elm_object_focus_allow_set(ctl->obj, EINA_FALSE); + } +} + +static void _show(void *handle) +{ + struct _priv *p; + struct _control *ctl; + Eina_List *l; + + if (!handle) { + _ERR("invalid parameter"); + return; + } + + p = handle; + + EINA_LIST_FOREACH(p->list, l, ctl) { + if (!ctl->obj) + continue; evas_object_show(ctl->obj); elm_object_part_content_set(p->base, ctl->part, ctl->obj); } + + _enable(handle); } static void _hide(void *handle) @@ -216,13 +259,13 @@ static void _hide(void *handle) if (!ctl->obj) continue; - evas_object_freeze_events_set(ctl->obj, EINA_TRUE); elm_object_focus_set(ctl->obj, false); - elm_object_focus_allow_set(ctl->obj, EINA_FALSE); evas_object_hide(ctl->obj); elm_object_part_content_unset(p->base, ctl->part); } + + _disable(handle); } static struct controller_ops _operations = { @@ -230,6 +273,8 @@ static struct controller_ops _operations = { .add_callback = _add_callback, .focus = _focus, .signal = _signal, + .enable = _enable, + .disable = _disable, .show = _show, .hide = _hide, }; diff --git a/src/util/timeout_handler.c b/src/util/timeout_handler.c new file mode 100644 index 0000000..e35f571 --- /dev/null +++ b/src/util/timeout_handler.c @@ -0,0 +1,144 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ +#include +#include +#include + +#include "define.h" +#include "util/timeout_handler.h" + +struct timeout_handler { + Eina_List *list; + Ecore_Timer *timer; + + timeout_event_cb event_cb; + void *event_data; + + timeout_event_cb timeout_cb; + void *timeout_data; + + double timeout; +}; + +static Eina_Bool _timer_cb(void *data) +{ + struct timeout_handler *handle; + + if (!data) + return ECORE_CALLBACK_CANCEL; + + handle = data; + + handle->timeout_cb(handle->timeout_data, 0, NULL); + handle->timer = NULL; + + return ECORE_CALLBACK_CANCEL; +} + +static Eina_Bool _event_occured(void *data, int type, void *event) +{ + struct timeout_handler *handle; + + if (!data) + return ECORE_CALLBACK_PASS_ON; + + handle = data; + + handle->event_cb(handle->event_data, type, event); + + timeout_handler_reset(handle); + + return ECORE_CALLBACK_PASS_ON; +} + +void timeout_handler_reset(struct timeout_handler *handle) +{ + if (!handle) { + _ERR("invalid parameter"); + return; + } + + if (handle->timer) + ecore_timer_reset(handle->timer); + else + handle->timer = ecore_timer_add(handle->timeout, + _timer_cb, handle); +} + +struct timeout_handler *timeout_handler_init(double timeout, + timeout_event_cb timeout_cb, void *timeout_data, + timeout_event_cb event_cb, void *event_data) +{ + struct timeout_handler *handle; + Ecore_Event_Handler *ev; + int i; + int event_type[] = { + ECORE_EVENT_KEY_UP, + ECORE_EVENT_KEY_DOWN, + ECORE_EVENT_MOUSE_BUTTON_DOWN, + ECORE_EVENT_MOUSE_BUTTON_UP, + ECORE_EVENT_MOUSE_MOVE, + ECORE_EVENT_MOUSE_WHEEL + }; + + handle = calloc(1, sizeof(*handle)); + if (!handle) { + _ERR("failed to allocate"); + return NULL; + } + + for (i = 0; i < sizeof(event_type) / sizeof(*event_type); i++) { + ev = ecore_event_handler_add(event_type[i], + _event_occured, handle); + if (!ev) + goto error; + + handle->list = eina_list_append(handle->list, ev); + } + + handle->timer = ecore_timer_add(timeout, _timer_cb, handle); + if (!handle->timer) + goto error; + + handle->event_cb = event_cb; + handle->event_data = event_data; + handle->timeout_cb = timeout_cb; + handle->timeout_data = timeout_data; + handle->timeout = timeout; + + return handle; + +error: + timeout_handler_fini(handle); + + return NULL; +} + +void timeout_handler_fini(struct timeout_handler *handle) +{ + Ecore_Event_Handler *ev; + + if (!handle) + return; + + EINA_LIST_FREE(handle->list, ev) + ecore_event_handler_del(ev); + + ecore_timer_del(handle->timer); + handle->timer = NULL; + + free(handle); +} diff --git a/src/view/viewer.c b/src/view/viewer.c index 52c5bc7..f09ad46 100644 --- a/src/view/viewer.c +++ b/src/view/viewer.c @@ -24,10 +24,13 @@ #include "define.h" #include "util/controller.h" +#include "util/timeout_handler.h" #define STYLE_VIEWER_BTN "viewer_btn" #define PART_VIEWER_BTN "control_btn" +#define VIEWER_TIMEOUT 3.0 + #define VIDEO_COPYRIGHT "Unknown" enum { @@ -62,6 +65,9 @@ struct _priv { struct _viewer viewer; struct _playlist playlist; + struct timeout_handler *timeout; + + bool bar_show; }; struct _btn_info { @@ -554,6 +560,44 @@ static bool _viewer_next(struct _priv *priv) return r; } +static void _show_bar(struct _priv *priv) +{ + struct controller *ctl; + + if (priv->bar_show) + return; + + elm_object_signal_emit(priv->base, SIG_SHOW_BAR, ""); + priv->bar_show = true; + + ctl = priv->viewer.ctl[priv->viewer.cur]; + ctl->ops->enable(ctl->handle); +} + +static void _hide_bar(struct _priv *priv) +{ + struct controller *ctl; + + if (!priv->bar_show) + return; + + elm_object_signal_emit(priv->base, SIG_HIDE_BAR, ""); + priv->bar_show = false; + + ctl = priv->viewer.ctl[priv->viewer.cur]; + ctl->ops->disable(ctl->handle); +} + +static void _timeout_cb(void *data, int type, void *ei) +{ + _hide_bar(data); +} + +static void _event_cb(void *data, int type, void *ei) +{ + _show_bar(data); +} + static bool _ui_init(struct _priv *priv) { Evas_Object *obj; @@ -575,6 +619,12 @@ static bool _ui_init(struct _priv *priv) elm_image_file_set(obj, IMAGE_VIEWER_FAVORITE, NULL); priv->favorite = obj; + priv->timeout = timeout_handler_init(VIEWER_TIMEOUT, + _timeout_cb, priv, + _event_cb, priv); + + priv->bar_show = true; + return true; err: @@ -682,6 +732,8 @@ static void _show(void *view_data) /* FIXME: test code */ _viewer_show(priv, priv->playlist.cur, DIR_NONE); + timeout_handler_reset(priv->timeout); + evas_object_show(priv->base); } @@ -718,6 +770,8 @@ static void _destroy(void *view_data) EINA_LIST_FREE(priv->playlist.list, am) app_media_destroy(am); + timeout_handler_fini(priv->timeout); + evas_object_del(priv->base); free(priv); -- 2.7.4 From 68103740bf6f970b46006e9d0dac0d5317073f76 Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Tue, 30 Jun 2015 20:56:08 +0900 Subject: [PATCH 04/16] viewer: set zoom mode to auto fit Change-Id: I52ffc9c0705d6728854bdcc5223748d009f0a07a Signed-off-by: Minkyu Kang --- src/view/viewer.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/src/view/viewer.c b/src/view/viewer.c index f09ad46..91c09be 100644 --- a/src/view/viewer.c +++ b/src/view/viewer.c @@ -307,8 +307,6 @@ static void _image_loaded_detail(void *data, Evas_Object *obj, void *ev) static void _load_image_file(struct _priv *priv, int id, app_media_info *mi) { Evas_Object *obj; - int w, h; - int mode; if (id == VIEWER_MOVIE) { elm_object_part_content_unset(priv->base, PART_VIEWER_CONTENT); @@ -349,14 +347,7 @@ static void _load_image_file(struct _priv *priv, int id, app_media_info *mi) } elm_photocam_file_set(obj, mi->file_path); - - elm_photocam_image_size_get(obj, &w, &h); - if (h > w) - mode = ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT; - else - mode = ELM_PHOTOCAM_ZOOM_MODE_AUTO_FILL; - - elm_photocam_zoom_mode_set(obj, mode); + elm_photocam_zoom_mode_set(obj, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT); } static void _draw_title_bar(struct _priv *priv, int id, app_media_info *mi) -- 2.7.4 From 29f90918ae0a4634f5e28e09653fa416644a622a Mon Sep 17 00:00:00 2001 From: Jehun Lim Date: Tue, 30 Jun 2015 19:13:30 +0900 Subject: [PATCH 05/16] mediadata: add media_list in struct mediadata Change-Id: I68f640f2782fb64abdcb8d49e854acda316fcaee Signed-off-by: Jehun Lim --- include/data/mediadata.h | 11 +++- src/data/mediadata.c | 129 ++++++++++++++++++++++++++++++++++++++--------- 2 files changed, 114 insertions(+), 26 deletions(-) diff --git a/include/data/mediadata.h b/include/data/mediadata.h index 59431b4..0715cc8 100644 --- a/include/data/mediadata.h +++ b/include/data/mediadata.h @@ -28,13 +28,20 @@ enum source_type { E_SOURCE_MAX }; -struct folderdata { +enum sort_type { + E_SORT_DATE = 0, + E_SORT_NAME, + E_SORT_MAX +}; + +struct folder_info { char *name; time_t modified_time; Eina_List *list; }; -struct mediadata *mediadata_create(const char *media_type, int source_type); +struct mediadata *mediadata_create(const char *media_type, + int source_type, int sort_type); void mediadata_destroy(struct mediadata *md); #endif /* _AIR_MEDIAHUB_MEDIADATA_H__ */ diff --git a/src/data/mediadata.c b/src/data/mediadata.c index ce8858c..abef770 100644 --- a/src/data/mediadata.c +++ b/src/data/mediadata.c @@ -21,20 +21,45 @@ #include "data/mediadata.h" +static int _compare_cb_date(const void *, const void *); +static int _compare_cb_name(const void *, const void *); + enum _filter_type { E_FILTER_FOLDER = 0, E_FILTER_MEDIA }; struct mediadata { - Eina_List *list; + Eina_List *folder_list; + Eina_List *media_list; }; struct _data { const char *media_type; int source_type; + int sort_type; Eina_List *item_list; Eina_List *folder_list; + Eina_List *media_list; +}; + +struct _sort_info { + int order_type; + const char *order_keyword; + Eina_Compare_Cb func; +}; + +static struct _sort_info g_sort_info[E_SORT_MAX] = { + [E_SORT_DATE] = { + .order_type = MEDIA_CONTENT_ORDER_DESC, + .order_keyword = MEDIA_MODIFIED_TIME, + .func = _compare_cb_date, + }, + [E_SORT_NAME] = { + .order_type = MEDIA_CONTENT_ORDER_ASC, + .order_keyword = MEDIA_TITLE, + .func = _compare_cb_name + } }; static bool _create_filter(struct _data *data, filter_h *filter, int type) @@ -61,24 +86,73 @@ static bool _create_filter(struct _data *data, filter_h *filter, int type) media_filter_set_condition(tmp_filter, buf, MEDIA_CONTENT_COLLATE_DEFAULT); - media_filter_set_order(tmp_filter, MEDIA_CONTENT_ORDER_DESC, - MEDIA_MODIFIED_TIME, MEDIA_CONTENT_COLLATE_NOCASE); + + media_filter_set_order(tmp_filter, + g_sort_info[data->sort_type].order_type, + g_sort_info[data->sort_type].order_keyword, + MEDIA_CONTENT_COLLATE_NOCASE); *filter = tmp_filter; return true; } -static void _destroy_medialist(Eina_List *list) +static int _compare_cb_date(const void *data1, const void *data2) +{ + app_media *am1, *am2; + app_media_info *info1, *info2; + + am1 = (app_media *)data1; + am2 = (app_media *)data2; + + info1 = app_media_get_info(am1); + info2 = app_media_get_info(am2); + + if (!info1 || !info2) + return -1; + + if (info1->modified_time > info2->modified_time) + return 1; + + return -1; +} + +static int _compare_cb_name(const void *data1, const void *data2) +{ + app_media *am1, *am2; + app_media_info *info1, *info2; + + am1 = (app_media *)data1; + am2 = (app_media *)data2; + + info1 = app_media_get_info(am1); + info2 = app_media_get_info(am2); + + if (!info1 || !info2 || !info1->display_name || !info2->display_name) + return -1; + + return strcasecmp(info1->display_name, info2->display_name); +} + +static Eina_List *_sort_list(Eina_List *list, int sort) +{ + Eina_List *sorted_list; + + sorted_list = eina_list_sort(list, 0, g_sort_info[sort].func); + + return sorted_list; +} + +static void _destroy_folderlist(Eina_List *list) { - struct folderdata *fd; + struct folder_info *fi; app_media *am; - EINA_LIST_FREE(list, fd) { - free(fd->name); - EINA_LIST_FREE(fd->list, am) + EINA_LIST_FREE(list, fi) { + free(fi->name); + EINA_LIST_FREE(fi->list, am) app_media_destroy(am); - fd->list = NULL; + free(fi); } } @@ -107,7 +181,7 @@ static bool _get_each_folder_info(media_folder_h folder, void *dt) { filter_h filter; struct _data *data; - struct folderdata *fd; + struct folder_info *fi; int ret; char *uuid; @@ -116,19 +190,19 @@ static bool _get_each_folder_info(media_folder_h folder, void *dt) data = dt; - fd = calloc(1, sizeof(*fd)); - if (!fd) { + fi = calloc(1, sizeof(*fi)); + if (!fi) { _ERR("failed to create folderdata"); return false; } - if (media_folder_get_name(folder, &(fd->name)) + if (media_folder_get_name(folder, &(fi->name)) != MEDIA_CONTENT_ERROR_NONE) { _ERR("Media folder id Fetch error"); goto err; } - if (media_folder_get_modified_time(folder, &(fd->modified_time)) + if (media_folder_get_modified_time(folder, &(fi->modified_time)) != MEDIA_CONTENT_ERROR_NONE) { _ERR("Media folder modified time Fetch error"); goto err; @@ -152,10 +226,11 @@ static bool _get_each_folder_info(media_folder_h folder, void *dt) goto err; } - fd->list = data->item_list; + fi->list = eina_list_clone(data->item_list); + data->media_list = eina_list_merge(data->media_list, data->item_list); data->item_list = NULL; - data->folder_list = eina_list_append(data->folder_list, fd); + data->folder_list = eina_list_append(data->folder_list, fi); media_filter_destroy(filter); free(uuid); @@ -165,11 +240,11 @@ static bool _get_each_folder_info(media_folder_h folder, void *dt) err: media_filter_destroy(filter); free(uuid); - _destroy_medialist(data->folder_list); + _destroy_folderlist(data->folder_list); return false; } -static bool _get_medialist(struct _data *data) +static bool _get_folderlist(struct _data *data) { filter_h filter; int ret; @@ -192,13 +267,15 @@ static bool _get_medialist(struct _data *data) return true; } -struct mediadata *mediadata_create(const char *media_type, int source_type) +struct mediadata *mediadata_create(const char *media_type, + int source_type, int sort_type) { struct mediadata *md; struct _data data; int ret; - if (!media_type || source_type < 0 || source_type >= E_SOURCE_MAX) { + if (!media_type || source_type < 0 || source_type >= E_SOURCE_MAX + || sort_type < 0 || sort_type >= E_SORT_MAX) { _ERR("invalid argument"); return NULL; } @@ -218,11 +295,13 @@ struct mediadata *mediadata_create(const char *media_type, int source_type) data.media_type = media_type; data.source_type = source_type; + data.sort_type = sort_type; data.item_list = NULL; data.folder_list = NULL; + data.media_list = NULL; - if (!_get_medialist(&data)) { - _ERR("failed to get medialist"); + if (!_get_folderlist(&data)) { + _ERR("failed to get folderlist"); free(md); media_content_disconnect(); return NULL; @@ -230,7 +309,8 @@ struct mediadata *mediadata_create(const char *media_type, int source_type) media_content_disconnect(); - md->list = data.folder_list; + md->folder_list = data.folder_list; + md->media_list = _sort_list(data.media_list, data.sort_type); return md; } @@ -242,5 +322,6 @@ void mediadata_destroy(struct mediadata *md) return; } - _destroy_medialist(md->list); + _destroy_folderlist(md->folder_list); + eina_list_free(md->media_list); } -- 2.7.4 From b81aa668ac86b55ccfcc5ac6d67c5a1a20487b61 Mon Sep 17 00:00:00 2001 From: Jehun Lim Date: Wed, 1 Jul 2015 16:09:39 +0900 Subject: [PATCH 06/16] mediadata: add function to create list with media name Change-Id: Idbfeb52c19bd52deb461b2917e4ce546e664bf59 Signed-off-by: Jehun Lim --- include/data/mediadata.h | 11 ++++- src/data/mediadata.c | 123 ++++++++++++++++++++++++++++++++++++++++------- 2 files changed, 114 insertions(+), 20 deletions(-) diff --git a/include/data/mediadata.h b/include/data/mediadata.h index 0715cc8..006eaac 100644 --- a/include/data/mediadata.h +++ b/include/data/mediadata.h @@ -34,9 +34,13 @@ enum sort_type { E_SORT_MAX }; -struct folder_info { +enum list_type { + E_LIST_NAME = 0, + E_LIST_MAX +}; + +struct group_info { char *name; - time_t modified_time; Eina_List *list; }; @@ -44,4 +48,7 @@ struct mediadata *mediadata_create(const char *media_type, int source_type, int sort_type); void mediadata_destroy(struct mediadata *md); +Eina_List *mediadata_get_list(struct mediadata *md, int list_type); +void mediadata_free_list(Eina_List *list); + #endif /* _AIR_MEDIAHUB_MEDIADATA_H__ */ diff --git a/src/data/mediadata.c b/src/data/mediadata.c index abef770..04556b0 100644 --- a/src/data/mediadata.c +++ b/src/data/mediadata.c @@ -21,9 +21,15 @@ #include "data/mediadata.h" +typedef int (*media_compare)(struct group_info *gi, app_media_info *info); +typedef char *(*group_name_get)(app_media_info *info); + static int _compare_cb_date(const void *, const void *); static int _compare_cb_name(const void *, const void *); +static int _compare_title(struct group_info *, app_media_info *); +static char *_get_title(app_media_info *); + enum _filter_type { E_FILTER_FOLDER = 0, E_FILTER_MEDIA @@ -49,6 +55,11 @@ struct _sort_info { Eina_Compare_Cb func; }; +struct _list_info { + media_compare media_cmp; + group_name_get name_get; +}; + static struct _sort_info g_sort_info[E_SORT_MAX] = { [E_SORT_DATE] = { .order_type = MEDIA_CONTENT_ORDER_DESC, @@ -58,7 +69,14 @@ static struct _sort_info g_sort_info[E_SORT_MAX] = { [E_SORT_NAME] = { .order_type = MEDIA_CONTENT_ORDER_ASC, .order_keyword = MEDIA_TITLE, - .func = _compare_cb_name + .func = _compare_cb_name, + } +}; + +static struct _list_info g_list_info[E_LIST_MAX] = { + [E_LIST_NAME] = { + .media_cmp = _compare_title, + .name_get = _get_title, } }; @@ -97,6 +115,22 @@ static bool _create_filter(struct _data *data, filter_h *filter, int type) return true; } +static int _compare_title(struct group_info *gi, app_media_info *info) +{ + if (!gi || !gi->name || !info->title) + return -1; + + return strncasecmp(gi->name, info->title, 1); +} + +static char *_get_title(app_media_info *info) +{ + if (!info->title) + return NULL; + + return strndup(info->title, 1); +} + static int _compare_cb_date(const void *data1, const void *data2) { app_media *am1, *am2; @@ -145,14 +179,14 @@ static Eina_List *_sort_list(Eina_List *list, int sort) static void _destroy_folderlist(Eina_List *list) { - struct folder_info *fi; + struct group_info *gi; app_media *am; - EINA_LIST_FREE(list, fi) { - free(fi->name); - EINA_LIST_FREE(fi->list, am) + EINA_LIST_FREE(list, gi) { + free(gi->name); + EINA_LIST_FREE(gi->list, am) app_media_destroy(am); - free(fi); + free(gi); } } @@ -181,7 +215,7 @@ static bool _get_each_folder_info(media_folder_h folder, void *dt) { filter_h filter; struct _data *data; - struct folder_info *fi; + struct group_info *gi; int ret; char *uuid; @@ -190,24 +224,18 @@ static bool _get_each_folder_info(media_folder_h folder, void *dt) data = dt; - fi = calloc(1, sizeof(*fi)); - if (!fi) { + gi = calloc(1, sizeof(*gi)); + if (!gi) { _ERR("failed to create folderdata"); return false; } - if (media_folder_get_name(folder, &(fi->name)) + if (media_folder_get_name(folder, &(gi->name)) != MEDIA_CONTENT_ERROR_NONE) { _ERR("Media folder id Fetch error"); goto err; } - if (media_folder_get_modified_time(folder, &(fi->modified_time)) - != MEDIA_CONTENT_ERROR_NONE) { - _ERR("Media folder modified time Fetch error"); - goto err; - } - if (media_folder_get_folder_id(folder, &uuid) != MEDIA_CONTENT_ERROR_NONE) { _ERR("failed to fetch media folder id"); @@ -226,11 +254,11 @@ static bool _get_each_folder_info(media_folder_h folder, void *dt) goto err; } - fi->list = eina_list_clone(data->item_list); + gi->list = eina_list_clone(data->item_list); data->media_list = eina_list_merge(data->media_list, data->item_list); data->item_list = NULL; - data->folder_list = eina_list_append(data->folder_list, fi); + data->folder_list = eina_list_append(data->folder_list, gi); media_filter_destroy(filter); free(uuid); @@ -325,3 +353,62 @@ void mediadata_destroy(struct mediadata *md) _destroy_folderlist(md->folder_list); eina_list_free(md->media_list); } + +Eina_List *mediadata_get_list(struct mediadata *md, int list_type) +{ + Eina_List *list, *l; + struct group_info *gi; + app_media *am; + app_media_info *info; + + if (!md) { + _ERR("failed to get mediadata"); + return NULL; + } + + if (list_type < 0 || list_type >= E_LIST_MAX) { + _ERR("invalid argument"); + return NULL; + } + + gi = NULL; + list = NULL; + EINA_LIST_FOREACH(md->media_list, l, am) { + info = app_media_get_info(am); + if (!info) { + _ERR("failed to get media info"); + mediadata_free_list(list); + return NULL; + } + + if (g_list_info[list_type].media_cmp(gi, info)) { + gi = calloc(1, sizeof(*gi)); + if (!gi) { + _ERR("failed to create group info"); + mediadata_free_list(list); + return NULL; + } + + gi->name = g_list_info[list_type].name_get(info); + + list = eina_list_append(list, gi); + } + + gi->list = eina_list_append(gi->list, am); + } + + return list; +} + +void mediadata_free_list(Eina_List *list) +{ + Eina_List *l; + struct group_info *gi; + + EINA_LIST_FOREACH(list, l, gi) { + free(gi->name); + eina_list_free(gi->list); + + free(gi); + } +} -- 2.7.4 From cb05893c72d7bd17c8074a0f6a6d9aa6e84b2cac Mon Sep 17 00:00:00 2001 From: Jehun Lim Date: Wed, 1 Jul 2015 21:50:46 +0900 Subject: [PATCH 07/16] remove gridmgr Change-Id: I7514b7e397626238bee8a3f40203b44042ea691c Signed-off-by: Jehun Lim --- CMakeLists.txt | 1 - include/util/gridmgr.h | 39 ------------ src/util/gridmgr.c | 169 ------------------------------------------------- 3 files changed, 209 deletions(-) delete mode 100644 include/util/gridmgr.h delete mode 100644 src/util/gridmgr.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 848459a..747150e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -53,7 +53,6 @@ src/view/viewer.c src/layout/movie.c src/layout/gallery.c src/layout/music.c -src/util/gridmgr.c src/util/controller.c src/util/timeout_handler.c src/data/mediadata.c diff --git a/include/util/gridmgr.h b/include/util/gridmgr.h deleted file mode 100644 index 97ba910..0000000 --- a/include/util/gridmgr.h +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef _AIR_MEDIAHUB_GRIDMGR_H__ -#define _AIR_MEDIAHUB_GRIDMGR_H__ - -#include - -struct gridmgr; - -struct grid_class { - const char *grid_style; - - char *(*text_get)(void *data, Evas_Object *obj, const char *part); - Evas_Object *(*content_get)(void *data, Evas_Object *obj, - const char *part); - /* It will be added later */ -}; - -struct gridmgr *gridmgr_create(void); -bool gridmgr_destroy(struct gridmgr *gmgr); -bool gridmgr_add_grid(struct gridmgr *gmgr, const char *grid_id, - Evas_Object *grid, struct grid_class *gclass); -bool gridmgr_update_grid(struct gridmgr *gmgr, const char *grid_id, Eina_List *item_list); - -#endif /* _AIR_MEDIAHUB_GRIDMGR_H__ */ diff --git a/src/util/gridmgr.c b/src/util/gridmgr.c deleted file mode 100644 index 2a7cad9..0000000 --- a/src/util/gridmgr.c +++ /dev/null @@ -1,169 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include "define.h" -#include "util/gridmgr.h" - -struct gridmgr { - Eina_List *list; -}; - -struct grid_item { - const char *id; - Evas_Object *grid; - struct grid_class *gclass; -}; - -struct grid_item *_get_item_from_id(struct gridmgr *gmgr, const char *id) -{ - Eina_List *l; - struct grid_item *gitem; - - if (!gmgr || !id) - return NULL; - - gitem = NULL; - EINA_LIST_FOREACH(gmgr->list, l, gitem) { - if (!strcmp(gitem->id, id)) - break; - } - - return gitem; -} - -Elm_Gengrid_Item_Class *_get_item_class(struct grid_class *gclass) -{ - Elm_Gengrid_Item_Class *ic; - - if (!gclass) - return NULL; - - ic = elm_gengrid_item_class_new(); - if (!ic) { - _ERR("failed to create item class"); - return NULL; - } - - ic->func.text_get = gclass->text_get; - ic->func.content_get = gclass->content_get; - - ic->item_style = gclass->grid_style; - - return ic; -} - -struct gridmgr *gridmgr_create(void) -{ - struct gridmgr *gmgr; - - gmgr = calloc(1, sizeof(*gmgr)); - if (!gmgr) { - _ERR("failed to create gridmgr"); - return NULL; - } - - return gmgr; -} - -bool gridmgr_destroy(struct gridmgr *gmgr) -{ - struct grid_item *gitem; - - if (!gmgr) { - _ERR("failed to get gridmgr"); - return false; - } - - EINA_LIST_FREE(gmgr->list, gitem) - free(gitem); - - free(gmgr); - gmgr = NULL; - - return true; -} - -bool gridmgr_add_grid(struct gridmgr *gmgr, const char *grid_id, - Evas_Object *grid, struct grid_class *gclass) -{ - struct grid_item *gitem; - - if (!gmgr) { - _ERR("failed to get gridmgr"); - return false; - } - - if (!gclass || !gclass->text_get || !gclass->content_get) { - _ERR("failed to get grid class"); - return false; - } - - gitem = calloc(1, sizeof(*gitem)); - if (!gitem) { - _ERR("failed to create gengrid item"); - return false; - } - - gitem->id = grid_id; - gitem->grid = grid; - gitem->gclass = gclass; - - gmgr->list = eina_list_append(gmgr->list, gitem); - - return true; -} - -bool gridmgr_update_grid(struct gridmgr *gmgr, const char *grid_id, - Eina_List *item_list) -{ - Eina_List *l; - Elm_Object_Item *it; - Elm_Gengrid_Item_Class *ic; - struct grid_item *gitem; - void *data; - - if (!gmgr) { - _ERR("failed to get gridmgr"); - return false; - } - - gitem = _get_item_from_id(gmgr, grid_id); - if (!gitem) { - _ERR("%s doesn't exist", grid_id); - return false; - } - - elm_gengrid_clear(gitem->grid); - - ic = _get_item_class(gitem->gclass); - if (!ic) { - _ERR("failed to get item class"); - return false; - } - - EINA_LIST_FOREACH(item_list, l, data) { - it = elm_gengrid_item_append(gitem->grid, ic, data, NULL, NULL); - - elm_object_item_data_set(it, data); - } - - elm_gengrid_item_class_free(ic); - - return true; -} -- 2.7.4 From e59444149ed200dff36f4daaaa062fc926163df5 Mon Sep 17 00:00:00 2001 From: Jehun Lim Date: Wed, 1 Jul 2015 21:54:50 +0900 Subject: [PATCH 08/16] util: add function to create box, gengrid and scroller Change-Id: I6dbf248e75d305f951f4983848920baefb5fc7e4 Signed-off-by: Jehun Lim --- CMakeLists.txt | 1 + include/util/util.h | 25 +++++++++++++++ src/util/util.c | 89 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 115 insertions(+) create mode 100644 include/util/util.h create mode 100644 src/util/util.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 747150e..8077938 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,7 @@ src/layout/gallery.c src/layout/music.c src/util/controller.c src/util/timeout_handler.c +src/util/util.c src/data/mediadata.c ) diff --git a/include/util/util.h b/include/util/util.h new file mode 100644 index 0000000..59aefce --- /dev/null +++ b/include/util/util.h @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __AIR_MEDIAHUB_UTIL_H__ +#define __AIR_MEDIAHUB_UTIL_H__ + +Evas_Object *util_add_box(Evas_Object *base); +Evas_Object *util_add_gengrid(Evas_Object *base, + int item_size_x, int item_size_y); +Evas_Object *util_add_scroller(Evas_Object *base); + +#endif /* __AIR_MEDIAHUB_UTIL_H__ */ diff --git a/src/util/util.c b/src/util/util.c new file mode 100644 index 0000000..df8abad --- /dev/null +++ b/src/util/util.c @@ -0,0 +1,89 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include + +Evas_Object *util_add_box(Evas_Object *base) +{ + Evas_Object *box; + + if (!base) + return NULL; + + box = elm_box_add(base); + if (!box) { + _ERR("failed to create box object"); + return NULL; + } + + evas_object_size_hint_align_set(box, 0.0, EVAS_HINT_FILL); + evas_object_size_hint_weight_set(box, 0.0, EVAS_HINT_EXPAND); + elm_box_horizontal_set(box, EINA_TRUE); + + return box; +} + +Evas_Object *util_add_gengrid(Evas_Object *base, + int item_size_x, int item_size_y) +{ + Evas_Object *grid; + + if (!base) + return NULL; + + grid = elm_gengrid_add(base); + if (!grid) { + _ERR("failed to create gengrid object"); + return NULL; + } + + evas_object_size_hint_weight_set(grid, + EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL); + + elm_gengrid_select_mode_set(grid, ELM_OBJECT_SELECT_MODE_ALWAYS); + elm_gengrid_multi_select_set(grid, EINA_FALSE); + + elm_gengrid_horizontal_set(grid, EINA_TRUE); + + elm_gengrid_align_set(grid, 0.0, 0.0); + + elm_gengrid_item_size_set(grid, + elm_config_scale_get() * item_size_x, + elm_config_scale_get() * item_size_y); + + return grid; +} + +Evas_Object *util_add_scroller(Evas_Object *base) +{ + Evas_Object *scr; + + if (!base) + return NULL; + + scr = elm_scroller_add(base); + if (!scr) { + _ERR("failed to create scroller object"); + return NULL; + } + + elm_scroller_policy_set(scr, ELM_SCROLLER_POLICY_OFF, + ELM_SCROLLER_POLICY_OFF); + + return scr; +} -- 2.7.4 From b05c2da281d35b4c376fa713deb631391ae53861 Mon Sep 17 00:00:00 2001 From: Jehun Lim Date: Thu, 2 Jul 2015 13:39:16 +0900 Subject: [PATCH 09/16] movie: draw content list area Change-Id: I7d26432b189c8c5fd6e08b27727ecce02114b488 Signed-off-by: Jehun Lim --- include/define.h | 1 + include/layout/movie.h | 9 ++ res/edc/layout/movie.edc | 119 +++++++++++++++++++++ res/edc/view/base.edc | 27 +++-- src/layout/movie.c | 265 +++++++++++++++++++++++++++++++++++++++++++++-- src/view/base.c | 1 + 6 files changed, 409 insertions(+), 13 deletions(-) diff --git a/include/define.h b/include/define.h index 56003cb..20da0e8 100644 --- a/include/define.h +++ b/include/define.h @@ -33,6 +33,7 @@ #define FONT_LIGHT "TizenSans:style=Light" #define FONT_BOLD "TizenSans:style=Bold" +#define COLOR_BASE_BG 247 247 247 255 #define COLOR_TEXT_TITLE 51 51 51 255 #define COLOR_TEXT_MENU 104 104 104 255 #define COLOR_TEXT_INDEX 77 77 77 255 diff --git a/include/layout/movie.h b/include/layout/movie.h index a0aaa9f..4d83ecd 100644 --- a/include/layout/movie.h +++ b/include/layout/movie.h @@ -20,5 +20,14 @@ #define LAYOUT_MOVIE "LAYOUT_MOVIE" #define GRP_MOVIE_LAYOUT "group.movie_layout" +#define GRP_LIST_ITEM "group.list_item" + +#define PART_CONTENT "part.content" +#define PART_NOCONTENT "part.nocontent" +#define PART_ITEM_TITLE "part.item_title" +#define PART_ITEM_CONTENT "part.item_content" + +#define STYLE_BTN_INDEX "base_btn_index" +#define STYLE_GRID_MOVIE_ITEM "movie_item" #endif /* __AIR_MEDIAHUB_LAYOUT_MOVIE_H__ */ diff --git a/res/edc/layout/movie.edc b/res/edc/layout/movie.edc index 85385a5..fa64707 100644 --- a/res/edc/layout/movie.edc +++ b/res/edc/layout/movie.edc @@ -16,4 +16,123 @@ group { name: GRP_MOVIE_LAYOUT; + parts { + part { + name: "area"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + min: 1920 704; + visible: 0; + } + } + part { + name: "padding_thumbnail_area"; + type: SPACER; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "area"; + rel2 { + to: "area"; + relative: 0.0 0.0; + } + min: 62 0; + align: 0.0 0.0; + fixed: 1 1; + } + } + part { + name: PART_CONTENT; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: "padding_thumbnail_area"; + relative: 1.0 1.0; + } + rel2.to: "area"; + } + } + part { + name: PART_NOCONTENT; + type: TEXT; + scale: 1; + description { + state: "default" 0.0; + text { + font: FONT_REGULAR; + size: 36; + align: 0.5 0.5; + } + rel1.to: PART_CONTENT; + rel2.to: PART_CONTENT; + color: COLOR_TEXT_NORMAL; + } + } + } +} + +group { + name: GRP_LIST_ITEM; + parts { + part { + name: "area"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + min: 0 703; + fixed: 0 1; + visible: 0; + } + } + part { + name: PART_ITEM_TITLE; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "area"; + rel2 { + to: "area"; + relative: 1.0 0.0; + } + min: 0 36; + align: 0.5 0.0; + fixed: 0 1; + } + } + part { + name: "padding_content"; + type: SPACER; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: PART_ITEM_TITLE; + relative: 0.0 1.0; + } + rel2.to: PART_ITEM_TITLE; + min: 0 28; + align: 0.5 0.0; + fixed: 0 1; + } + } + part { + name: PART_ITEM_CONTENT; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: "padding_content"; + relative: 0.0 1.0; + } + rel2.to: "area"; + } + } + } } diff --git a/res/edc/view/base.edc b/res/edc/view/base.edc index 2d98689..4ad5a83 100644 --- a/res/edc/view/base.edc +++ b/res/edc/view/base.edc @@ -23,7 +23,20 @@ group { scale: 1; description { state: "default" 0.0; + color: COLOR_BASE_BG; + } + } + part { + name: "toparea_bg"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + rel2.relative: 1.0 0.0; + min: 0 184; + align: 0.5 0.0; color: 255 255 255 255; + fixed: 0 1; } } part { @@ -32,7 +45,10 @@ group { scale: 1; description { state: "default" 0.0; - rel2.relative: 1.0 0.0; + rel2 { + to: "toparea_bg"; + relative: 1.0 0.0; + } min: 0 44; align: 0.5 0.0; fixed: 0 1; @@ -86,10 +102,7 @@ group { to: "padding_menu_area"; relative: 0.0 1.0; } - rel2.to: "padding_menu_area"; - min: 0 82; - align: 0.5 0.0; - fixed: 0 1; + rel2.to: "toparea_bg"; } } part { @@ -105,7 +118,7 @@ group { rel2.to: PART_MENU_AREA; min: 0 70; align: 0.5 0.0; - color: 223 223 223 255; + color: COLOR_BASE_BG; fixed: 0 1; } } @@ -120,7 +133,7 @@ group { relative: 0.0 1.0; } rel2.to: "padding_thumbnail_area"; - min: 0 678; + min: 0 704; align: 0.5 0.0; fixed: 0 1; } diff --git a/src/layout/movie.c b/src/layout/movie.c index 14a8c16..4855617 100644 --- a/src/layout/movie.c +++ b/src/layout/movie.c @@ -15,20 +15,233 @@ */ #include +#include #include +#include #include +#include #include "define.h" +#include "data/mediadata.h" +#include "util/util.h" + +#define LIST_MEDIA_COND "media_type=1 AND copyright NOT LIKE \"Unknown\"" + +#define TEXT_NOCONTENT "No Movie Content" + +#define NUM_CONTENT 2 +#define SIZE_GRID_ITEM_X 404 +#define SIZE_GRID_ITEM_Y 320 + +#define PADDING_BOX_ITEM 62 struct _priv { Evas_Object *base; Evas_Object *layout; + Evas_Object *box; layoutmgr *lmgr; + + struct gridmgr *gmgr; + + struct mediadata *md; + + Eina_List *media_list; }; +static char *_grid_text_get(void *data, Evas_Object *obj, const char *part) +{ + app_media *am; + app_media_info *info; + + if (!data) + return NULL; + + am = data; + + if (!strcmp(part, "elm.text")) { + info = app_media_get_info(am); + if (!info) { + _ERR("failed to get media info"); + return NULL; + } + + return strdup(info->title); + } + + return NULL; +} + +static Evas_Object *_grid_content_get(void *data, + Evas_Object *obj, const char *part) +{ + Evas_Object *image; + app_media *am; + app_media_info *info; + + if (!data) + return NULL; + + am = data; + + if (!strcmp(part, "elm.swallow.icon")) { + image = elm_image_add(obj); + if (!image) { + _ERR("failed to create image object"); + return NULL; + } + + info = app_media_get_info(am); + if (!info) { + _ERR("failed to get media info"); + evas_object_del(image); + return NULL; + } + + elm_image_file_set(image, info->thumbnail_path, NULL); + elm_image_aspect_fixed_set(image, EINA_FALSE); + + evas_object_show(image); + + return image; + } + + return NULL; +} + +static struct grid_class gclass = { + .item_style = STYLE_GRID_MOVIE_ITEM, + .text_get = _grid_text_get, + .content_get = _grid_content_get +}; + +static int _get_grid_size(int count) +{ + int size; + + size = count / NUM_CONTENT; + if (count % NUM_CONTENT > 0) + size++; + + return size; +} + +static Evas_Object *_draw_list_item(struct _priv *priv, struct group_info *gi) +{ + Evas_Object *ly, *btn, *grid; + int size; + + ly = elm_layout_add(priv->box); + if (!ly) { + _ERR("failed to create layout object"); + return NULL; + } + + elm_layout_file_set(ly, EDJEFILE, GRP_LIST_ITEM); + + btn = elm_button_add(ly); + if (!btn) { + _ERR("failed to create button object"); + evas_object_del(ly); + return NULL; + } + + elm_object_style_set(btn, STYLE_BTN_INDEX); + elm_object_text_set(btn, gi->name); + + grid = util_add_gengrid(ly, SIZE_GRID_ITEM_X, SIZE_GRID_ITEM_Y); + if (!grid) { + _ERR("failed to create gengrid object"); + evas_object_del(ly); + return NULL; + } + + if (!gridmgr_add_grid(priv->gmgr, gi->name, grid, &gclass)) { + _ERR("failed to add grid"); + evas_object_del(ly); + return NULL; + } + + size = _get_grid_size(eina_list_count(gi->list)); + + evas_object_size_hint_min_set(grid, size * SIZE_GRID_ITEM_X, + NUM_CONTENT * SIZE_GRID_ITEM_Y); + + elm_object_part_content_set(ly, PART_ITEM_TITLE, btn); + elm_object_part_content_set(ly, PART_ITEM_CONTENT, grid); + + return ly; +} + +static void _update_list_area(struct _priv *priv) +{ + Eina_List *list, *l; + Evas_Object *ly; + struct group_info *gi; + + if (priv->media_list) + return; + + list = mediadata_get_list(priv->md, E_LIST_NAME); + if (!list) { + elm_object_part_text_set(priv->layout, + PART_NOCONTENT, TEXT_NOCONTENT); + return; + } + + EINA_LIST_FOREACH(list, l, gi) { + ly = _draw_list_item(priv, gi); + if (!ly) { + _ERR("failed to draw list item"); + return; + } + + if (!gridmgr_append_list(priv->gmgr, gi->name, gi->list)) { + _ERR("failed to append list in grid"); + return; + } + + evas_object_show(ly); + + elm_box_pack_end(priv->box, ly); + } + + priv->media_list = list; +} + +static bool _draw_list_area(struct _priv *priv) +{ + Evas_Object *scr, *box; + + scr = util_add_scroller(priv->layout); + if (!scr) { + _ERR("failed to create scroller object"); + return false; + } + + box = util_add_box(scr); + if (!box) { + _ERR("failed to create box object"); + evas_object_del(scr); + return false; + } + + elm_box_padding_set(box, PADDING_BOX_ITEM, 0); + + evas_object_show(box); + elm_object_content_set(scr, box); + + elm_object_part_content_set(priv->layout, PART_CONTENT, scr); + + priv->box = box; + + return true; +} + static bool _create(layoutmgr *lmgr, void *data) { + struct gridmgr *gmgr; + struct mediadata *md; struct _priv *priv; Evas_Object *base, *layout; @@ -46,30 +259,55 @@ static bool _create(layoutmgr *lmgr, void *data) base = layoutmgr_get_base(lmgr); if (!base) { _ERR("failed to get base object"); - free(priv); - return false; + goto err; } layout = elm_layout_add(base); if (!layout) { _ERR("failed to create layout"); - free(priv); - return false; + goto err; } if (!elm_layout_file_set(layout, EDJEFILE, GRP_MOVIE_LAYOUT)) { _ERR("failed to set layout file"); - evas_object_del(layout); - free(priv); + goto err2; + } + + gmgr = gridmgr_create(); + if (!gmgr) { + _ERR("failed to create gridmgr"); + goto err2; + } + + md = mediadata_create(LIST_MEDIA_COND, E_SOURCE_ALL, E_SORT_NAME); + if (!md) { + _ERR("failed to create mediadata"); + gridmgr_destroy(gmgr); + goto err2; } priv->base = base; priv->layout = layout; priv->lmgr = lmgr; + priv->gmgr = gmgr; + priv->md = md; layoutmgr_set_layout_data(lmgr, LAYOUT_MOVIE, priv); + if (!_draw_list_area(priv)) { + _ERR("failed to draw list area"); + mediadata_destroy(md); + gridmgr_destroy(gmgr); + goto err2; + } + return true; + +err2: + evas_object_del(layout); +err: + free(priv); + return false; } static void _destroy(void *layout_data) @@ -83,6 +321,11 @@ static void _destroy(void *layout_data) priv = layout_data; + gridmgr_destroy(priv->gmgr); + + mediadata_free_list(priv->media_list); + mediadata_destroy(priv->md); + evas_object_del(priv->layout); free(priv); } @@ -120,6 +363,16 @@ static void _hide(void *layout_data) static void _update(void *layout_data, int update_type, void *data) { + struct _priv *priv; + + if (!layout_data) { + _ERR("failed to get layout data"); + return; + } + + priv = layout_data; + + _update_list_area(priv); } static layout_class _lclass = { diff --git a/src/view/base.c b/src/view/base.c index fb118f0..b007ef7 100644 --- a/src/view/base.c +++ b/src/view/base.c @@ -88,6 +88,7 @@ static void _focused_cb(int id, void *data, Evas_Object *obj, layoutmgr_hide_layout(priv->lmgr, g_menu_item[priv->current_layout].layout_id); layoutmgr_show_layout(priv->lmgr, g_menu_item[i].layout_id); + layoutmgr_update_layout(priv->lmgr, g_menu_item[i].layout_id, 0, NULL); priv->current_layout = i; } -- 2.7.4 From 41b883b66905bde66e0178b5729bade9d4bc23c7 Mon Sep 17 00:00:00 2001 From: Jehun Lim Date: Thu, 2 Jul 2015 16:03:06 +0900 Subject: [PATCH 10/16] add gengrid item style for photo and video contents Change-Id: Ic8c66668c3fe4f972d83b9d0a37b2fa7fd2bbb68 Signed-off-by: Jehun Lim --- include/define.h | 6 + include/layout/gallery.h | 2 + res/edc/widgets/gengrid.edc | 352 +++++++++++++++++++++++++++++++++++++++++++- 3 files changed, 352 insertions(+), 8 deletions(-) diff --git a/include/define.h b/include/define.h index 20da0e8..6ecf61b 100644 --- a/include/define.h +++ b/include/define.h @@ -47,4 +47,10 @@ #define COLOR_ITEM_FOCUS 0 119 246 255 #define COLOR_ITEM_FOCUS_0 0 119 246 0 +/* part */ +#define PART_ELM_TEXT_TITLE "elm.text.title" +#define PART_ELM_TEXT_PLAYTIME "elm.text.playtime" +#define PART_ELM_SWALLOW_THUMBNAIL "elm.swallow.thumbnail" +#define PART_ELM_SWALLOW_VIDEO "elm.swallow.video" + #endif /* __AIR_MEDIAHUB_DEFINE_H__ */ diff --git a/include/layout/gallery.h b/include/layout/gallery.h index aa7e914..3ea6526 100644 --- a/include/layout/gallery.h +++ b/include/layout/gallery.h @@ -21,4 +21,6 @@ #define GRP_GALLERY_LAYOUT "group.gallery_layout" +#define STYLE_GRID_GALLERY_ITEM "gallery_item" + #endif /* __AIR_MEDIAHUB_LAYOUT_GALLERY_H__ */ diff --git a/res/edc/widgets/gengrid.edc b/res/edc/widgets/gengrid.edc index 3e9a631..789f9da 100644 --- a/res/edc/widgets/gengrid.edc +++ b/res/edc/widgets/gengrid.edc @@ -17,8 +17,8 @@ group { name: "elm/gengrid/item/movie_item/default"; data.item: "selectraise" "on"; - data.item: "texts" "elm.text"; - data.item: "contents" "elm.swallow.icon"; + data.item: "texts" "elm.text.title"; + data.item: "contents" "elm.swallow.thumbnail"; data.item: "focus_highlight" "on"; parts { part { @@ -89,7 +89,7 @@ group { } } part { - name: "elm.swallow.icon"; + name: PART_SWALLOW_THUMBNAIL; type: SWALLOW; scale: 1; mouse_events: 1; @@ -300,7 +300,7 @@ group { } } part { - name: "elm.text"; + name: PART_ELM_TEXT_TITLE; type: TEXT; scale: 1; description { @@ -346,14 +346,14 @@ group { target: "part_focus2"; target: "part_focus3"; target: "elm.bg.text"; - target: "elm.text"; + target: PART_ELM_TEXT_TITLE; after: "focus,in,anim"; } program { name: "focus,in,anim"; action: STATE_SET "selected" 0.0; target: "defaultbg"; - target: "elm.swallow.icon"; + target: PART_SWALLOW_THUMBNAIL; target: "part_focus1"; target: "part_focus2"; target: "part_focus3"; @@ -365,7 +365,7 @@ group { signal: "elm,state,unfocused"; source: "elm"; action: STATE_SET "default" 0.0; - target: "elm.text"; + target: PART_ELM_TEXT_TITLE; after: "focus,out,anim"; } program { @@ -381,7 +381,7 @@ group { program { name: "focus,out,anim,3"; action: STATE_SET "default" 0.0; - target: "elm.swallow.icon"; + target: PART_SWALLOW_THUMBNAIL; target: "defaultbg"; target: "part_focus1"; target: "part_focus2"; @@ -390,3 +390,339 @@ group { } } } + +group { + name: "elm/gengrid/item/gallery_item/default"; + data.item: "selectraise" "on"; + data.item: "texts" "elm.text.playtime"; + data.item: "contents" "elm.swallow.thumbnail elm.swallow.video"; + data.item: "focus_highlight" "on"; + parts { + part { + name: "elm.padding.bottom_right"; + type: SPACER; + scale: 1; + description { + state: "default" 0.0; + rel1.relative: 1.0 1.0; + min: 6 6; + align: 1.0 1.0; + fixed: 1 1; + } + } + part { + name: "map"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + perspective { + zplane: 0; + focal: 1000; + } + visible: 0; + } + description { + state: "clicked" 0.0; + inherit: "default" 0.0; + perspective.zplane: -100; + } + } + part { + name: "bg"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + rel2 { + to: "elm.padding.bottom_right"; + relative: 0.0 0.0; + } + fixed: 1 1; + visible: 0; + } + } + part { + name: "defaultbg"; + scale: 1; + type: RECT; + mouse_events: 1; + description { + state : "default" 0.0; + rel1.to: "bg"; + rel2.to: "bg"; + color: 0 0 0 115; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + map.on: 1; + } + } + part { + name: PART_ELM_SWALLOW_THUMBNAIL; + scale: 1; + type: SWALLOW; + mouse_events: 1; + description { + state : "default" 0.0; + rel1.to: "defaultbg"; + rel2.to: "defaultbg"; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + map.on: 1; + } + } + part { + name: PART_ELM_SWALLOW_VIDEO; + scale: 1; + type: SWALLOW; + description { + state: "default" 0.0; + rel1.to: "defaultbg"; + rel2.to: "defaultbg"; + } + } + part { + name: "part_focus1"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "bg"; + rel2 { + to: "bg"; + relative: 1.0 0.0; + } + min: 0 3; + align: 0.5 0.0; + color: COLOR_ITEM_FOCUS; + fixed: 0 1; + visible: 0; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + map.on: 1; + visible: 1; + } + description { + state: "selected_0" 0.0; + inherit: "default" 0.0; + visible: 1; + color: COLOR_ITEM_FOCUS_0; + } + } + part { + name: "part_focus2"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: "part_focus1"; + relative: 0.0 1.0; + } + rel2 { + to: "bg"; + relative: 0.0 1.0; + } + min: 3 0; + align: 0.0 0.5; + color: COLOR_ITEM_FOCUS; + fixed: 1 0; + visible: 0; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + map.on: 1; + visible: 1; + } + description { + state: "selected_0" 0.0; + inherit: "default" 0.0; + visible: 1; + color: COLOR_ITEM_FOCUS_0; + } + } + part { + name: "part_focus3"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: "part_focus1"; + relative: 1.0 1.0; + } + rel2.to: "bg"; + min: 3 0; + align: 1.0 0.5; + color: COLOR_ITEM_FOCUS; + fixed: 1 0; + visible: 0; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + map.on: 1; + visible: 1; + } + description { + state: "selected_0" 0.0; + inherit: "default" 0.0; + visible: 1; + color: COLOR_ITEM_FOCUS_0; + } + } + part { + name: "part_focus4"; + type: RECT; + mouse_events: 0; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: "part_focus2"; + relative: 1.0 1.0; + } + rel2 { + to: "part_focus3"; + relative: 0.0 1.0; + } + min: 0 3; + align: 0.5 1.0; + color: COLOR_ITEM_FOCUS; + fixed: 0 1; + visible: 0; + map { + perspective_on: 1; + perspective: "map"; + } + } + description { + state: "selected" 0.0; + inherit: "default" 0.0; + map.on: 1; + visible: 1; + } + description { + state: "selected_0" 0.0; + inherit: "default" 0.0; + visible: 1; + color: COLOR_ITEM_FOCUS_0; + } + } + part { + name: "padding_playtime"; + type: SPACER; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: "defaultbg"; + relative: 1.0 1.0; + } + rel2.to: "defaultbg"; + min: 12 12; + align: 1.0 1.0; + fixed: 1 1; + } + } + part { + name: PART_ELM_TEXT_PLAYTIME; + type: TEXT; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "padding_playtime"; + rel2 { + to: "padding_playtime"; + relative: 0.0 0.0; + } + text { + font: FONT_LIGHT; + size: 24; + min: 1 0; + align: 1.0 1.0; + } + min: 0 24; + align: 1.0 1.0; + color: COLOR_TEXT_FOCUS; + fixed: 0 1; + } + } + } + programs { + program { + name: "go_active"; + signal: "elm,state,focused"; + source: "elm"; + action: STATE_SET "selected_0" 0.0; + target: "part_focus1"; + target: "part_focus2"; + target: "part_focus3"; + target: "part_focus4"; + after: "focus,in,anim"; + } + program { + name: "focus,in,anim"; + action: STATE_SET "selected" 0.0; + target: "defaultbg"; + target: PART_ELM_SWALLOW_THUMBNAIL; + target: "part_focus1"; + target: "part_focus2"; + target: "part_focus3"; + target: "part_focus4"; + transition: LINEAR 0.17; + } + program { + name: "go_passive"; + signal: "elm,state,unfocused"; + source: "elm"; + action: STATE_SET "selected_0" 0.0; + target: "part_focus1"; + target: "part_focus2"; + target: "part_focus3"; + target: "part_focus4"; + transition: LINEAR 0.17; + after: "focus,out,anim"; + } + program { + name: "focus,out,anim"; + action: STATE_SET "default" 0.0; + target: PART_ELM_SWALLOW_THUMBNAIL; + target: "defaultbg"; + target: "part_focus1"; + target: "part_focus2"; + target: "part_focus3"; + target: "part_focus4"; + } + } +} -- 2.7.4 From acc85ce5a616958c20cdce707a9fec735a63a608 Mon Sep 17 00:00:00 2001 From: Jehun Lim Date: Fri, 3 Jul 2015 19:02:42 +0900 Subject: [PATCH 11/16] base: manage current focused menu button Change-Id: I9c671b2f25172788abaf3550afc7d459a7098cbf Signed-off-by: Jehun Lim --- src/view/base.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/view/base.c b/src/view/base.c index b007ef7..07247de 100644 --- a/src/view/base.c +++ b/src/view/base.c @@ -31,6 +31,7 @@ struct _priv { Evas_Object *win; Evas_Object *base; Evas_Object *btn[MENU_BTN_SIZE]; + Evas_Object *focused_btn; layoutmgr *lmgr; @@ -77,12 +78,15 @@ static void _focused_cb(int id, void *data, Evas_Object *obj, priv = data; + if (priv->focused_btn == obj) + return; + for (i = 0; i < MENU_BTN_SIZE; i++) { if (priv->btn[i] == obj) break; } - if (i == priv->current_layout || i == MENU_BTN_SIZE) + if (i == MENU_BTN_SIZE) return; layoutmgr_hide_layout(priv->lmgr, @@ -90,6 +94,7 @@ static void _focused_cb(int id, void *data, Evas_Object *obj, layoutmgr_show_layout(priv->lmgr, g_menu_item[i].layout_id); layoutmgr_update_layout(priv->lmgr, g_menu_item[i].layout_id, 0, NULL); + priv->focused_btn = obj; priv->current_layout = i; } -- 2.7.4 From 7216e7a98a386f0a07ea0b593144668b3f2ba35e Mon Sep 17 00:00:00 2001 From: Jehun Lim Date: Fri, 3 Jul 2015 19:21:25 +0900 Subject: [PATCH 12/16] fix wrong part name Change-Id: Ib7070ca23fe683282396e0972262f8f4c437449b Signed-off-by: Jehun Lim --- res/edc/widgets/gengrid.edc | 6 +++--- src/layout/movie.c | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/res/edc/widgets/gengrid.edc b/res/edc/widgets/gengrid.edc index 789f9da..67e69eb 100644 --- a/res/edc/widgets/gengrid.edc +++ b/res/edc/widgets/gengrid.edc @@ -89,7 +89,7 @@ group { } } part { - name: PART_SWALLOW_THUMBNAIL; + name: PART_ELM_SWALLOW_THUMBNAIL; type: SWALLOW; scale: 1; mouse_events: 1; @@ -353,7 +353,7 @@ group { name: "focus,in,anim"; action: STATE_SET "selected" 0.0; target: "defaultbg"; - target: PART_SWALLOW_THUMBNAIL; + target: PART_ELM_SWALLOW_THUMBNAIL; target: "part_focus1"; target: "part_focus2"; target: "part_focus3"; @@ -381,7 +381,7 @@ group { program { name: "focus,out,anim,3"; action: STATE_SET "default" 0.0; - target: PART_SWALLOW_THUMBNAIL; + target: PART_ELM_SWALLOW_THUMBNAIL; target: "defaultbg"; target: "part_focus1"; target: "part_focus2"; diff --git a/src/layout/movie.c b/src/layout/movie.c index 4855617..8d4f587 100644 --- a/src/layout/movie.c +++ b/src/layout/movie.c @@ -59,7 +59,7 @@ static char *_grid_text_get(void *data, Evas_Object *obj, const char *part) am = data; - if (!strcmp(part, "elm.text")) { + if (!strcmp(part, PART_ELM_TEXT_TITLE)) { info = app_media_get_info(am); if (!info) { _ERR("failed to get media info"); @@ -84,7 +84,7 @@ static Evas_Object *_grid_content_get(void *data, am = data; - if (!strcmp(part, "elm.swallow.icon")) { + if (!strcmp(part, PART_ELM_SWALLOW_THUMBNAIL)) { image = elm_image_add(obj); if (!image) { _ERR("failed to create image object"); -- 2.7.4 From a58229cc16cdb9b5e083fb8e6f1e6250859c6af0 Mon Sep 17 00:00:00 2001 From: Minkyu Kang Date: Fri, 3 Jul 2015 19:25:22 +0900 Subject: [PATCH 13/16] viewer: adds playermgr and support playing video Werror was disabled due to deprecated compiler warning from sound manager module Change-Id: Ia798d8b4a2900c8b8aa0c71efcf0641c2477b025 Signed-off-by: Minkyu Kang --- CMakeLists.txt | 4 +- include/util/playermgr.h | 38 ++++++ include/view/viewer.h | 1 + packaging/org.tizen.mediahub.spec | 1 + res/edc/view/viewer.edc | 17 ++- res/edc/widgets/button.edc | 2 +- src/main.c | 6 +- src/util/playermgr.c | 260 +++++++++++++++++++++++++++++++++++++ src/view/viewer.c | 264 +++++++++++++++++++++++++++++++++++--- 9 files changed, 569 insertions(+), 24 deletions(-) create mode 100644 include/util/playermgr.h create mode 100644 src/util/playermgr.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 8077938..45014bc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,6 +20,7 @@ INCLUDE(FindPkgConfig) pkg_check_modules(PKGS REQUIRED elementary capi-appfw-application + capi-media-player app-utils) IF(NOT DEFINED PACKAGE_NAME) @@ -56,6 +57,7 @@ src/layout/music.c src/util/controller.c src/util/timeout_handler.c src/util/util.c +src/util/playermgr.c src/data/mediadata.c ) @@ -77,7 +79,7 @@ ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) FOREACH(flag ${PKGS_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -Werror") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall") TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${PKGS_LDFLAGS}) CONFIGURE_FILE(${PACKAGE_NAME}.xml.in ${PACKAGE_NAME}.xml) diff --git a/include/util/playermgr.h b/include/util/playermgr.h new file mode 100644 index 0000000..7ba5831 --- /dev/null +++ b/include/util/playermgr.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. +*/ + +#ifndef __AIR_MEDIAHUB_PLAYERMGR_H__ +#define __AIR_MEDIAHUB_PLAYERMGR_H__ + +struct playermgr; + +struct playermgr *playermgr_create(Evas_Object *win); +void playermgr_destroy(struct playermgr *m); + +bool playermgr_play(struct playermgr *m, const char *path); +void playermgr_stop(struct playermgr *m); +bool playermgr_resume(struct playermgr *m); +bool playermgr_pause(struct playermgr *m); + +int playermgr_get_duration(struct playermgr *m); +int playermgr_get_position(struct playermgr *m); +bool playermgr_set_position(struct playermgr *m, int ms, + player_seek_completed_cb cb, void *data); +void playermgr_get_state(struct playermgr *m, player_state_e *state); +bool playermgr_set_completed_cb(struct playermgr *m, + player_completed_cb cb, void *data); + +#endif diff --git a/include/view/viewer.h b/include/view/viewer.h index 1babe1c..b7622f2 100644 --- a/include/view/viewer.h +++ b/include/view/viewer.h @@ -24,6 +24,7 @@ #define GRP_VIEWER_VIEW "group.viewer_view" /* part */ +#define PART_VIEWER_BG "part.viewer_bg" #define PART_VIEWER_CONTENT "part.viewer_content" #define PART_VIEWER_TITLE "part.viewer_title" #define PART_VIEWER_DATE "part.viewer_date" diff --git a/packaging/org.tizen.mediahub.spec b/packaging/org.tizen.mediahub.spec index 2a6c12a..969283d 100644 --- a/packaging/org.tizen.mediahub.spec +++ b/packaging/org.tizen.mediahub.spec @@ -10,6 +10,7 @@ Source1: %{name}.manifest BuildRequires: cmake BuildRequires: pkgconfig(elementary) BuildRequires: pkgconfig(capi-appfw-application) +BuildRequires: pkgconfig(capi-media-player) BuildRequires: pkgconfig(app-utils) %define _appdir /usr/apps/%{name} diff --git a/res/edc/view/viewer.edc b/res/edc/view/viewer.edc index a8007a1..e698125 100644 --- a/res/edc/view/viewer.edc +++ b/res/edc/view/viewer.edc @@ -25,7 +25,22 @@ group { scale: 1; description { state: "default" 0.0; - color: 0 0 0 255; + color: 0 0 0 0; + } + } + part { + name: PART_VIEWER_BG; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + rel2 { + relative: 0.0 0.0; + } + rel2 { + relative: 1.0 1.0; + } + align: 0.0 0.0; } } part { diff --git a/res/edc/widgets/button.edc b/res/edc/widgets/button.edc index 2113a5b..98bff76 100644 --- a/res/edc/widgets/button.edc +++ b/res/edc/widgets/button.edc @@ -502,7 +502,7 @@ group { script { set_int(cur_state, STATE_PAUSE); set_state(PART:"bg", "default_pause", 0.0); - set_state(PART:"color", "default", 0.0); + set_state(PART:"color", "default_pause", 0.0); } } program { diff --git a/src/main.c b/src/main.c index 3b01bb5..d68cc2a 100644 --- a/src/main.c +++ b/src/main.c @@ -34,12 +34,16 @@ struct _appdata { static Evas_Object *_add_win(const char *name) { Evas_Object *win; + int w, h; - win = elm_win_util_standard_add(NULL, name); + win = elm_win_add(NULL, name, ELM_WIN_BASIC); if (!win) return NULL; elm_win_title_set(win, MEDIAHUB_WIN_TITLE); + elm_win_alpha_set(win, EINA_TRUE); + elm_win_screen_size_get(win, NULL, NULL, &w, &h); + evas_object_resize(win, w, h); evas_object_show(win); diff --git a/src/util/playermgr.c b/src/util/playermgr.c new file mode 100644 index 0000000..07aa63c --- /dev/null +++ b/src/util/playermgr.c @@ -0,0 +1,260 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include +#include + +#include "define.h" + +struct playermgr { + Evas_Object *win; + player_h player; +}; + +int playermgr_get_duration(struct playermgr *m) +{ + int r; + int ms; + + if (!m) { + _ERR("invalid parameter"); + return 0; + } + + r = player_get_duration(m->player, &ms); + if (r != PLAYER_ERROR_NONE) { + _ERR("player: get_position error (%d)", r); + return 0; + } + + return ms; +} + +int playermgr_get_position(struct playermgr *m) +{ + int r; + int ms; + + if (!m) { + _ERR("invalid parameter"); + return 0; + } + + r = player_get_play_position(m->player, &ms); + if (r != PLAYER_ERROR_NONE) { + _ERR("player: get_position error (%d)", r); + return 0; + } + + return ms; +} + +bool playermgr_set_position(struct playermgr *m, int ms, + player_seek_completed_cb cb, void *data) +{ + int r; + + if (!m) { + _ERR("invalid parameter"); + return false; + } + + r = player_set_play_position(m->player, ms, false, cb, data); + if (r != PLAYER_ERROR_NONE) { + _ERR("player: set_position error (%d)", r); + return false; + } + + return true; +} + +void playermgr_get_state(struct playermgr *m, player_state_e *state) +{ + int r; + + if (!m) { + _ERR("invalid parameter"); + return; + } + + r = player_get_state(m->player, state); + if (r != PLAYER_ERROR_NONE) { + _ERR("player: get_state error (%d)", r); + *state = PLAYER_STATE_NONE; + } +} + +bool playermgr_pause(struct playermgr *m) +{ + player_state_e state; + int r; + + if (!m) { + _ERR("invalid parameter"); + return false; + } + + playermgr_get_state(m, &state); + if (state == PLAYER_STATE_PAUSED) + return true; + + r = player_pause(m->player); + if (r != PLAYER_ERROR_NONE) { + _ERR("player: pause error (%d)", r); + return false; + } + + return true; +} + +bool playermgr_resume(struct playermgr *m) +{ + player_state_e state; + int r; + + if (!m) { + _ERR("invalid parameter"); + return false; + } + + playermgr_get_state(m, &state); + if (state == PLAYER_STATE_PLAYING) + return true; + + r = player_start(m->player); + if (r != PLAYER_ERROR_NONE) { + _ERR("player: start error (%d)", r); + return false; + } + + return true; +} + +void playermgr_stop(struct playermgr *m) +{ + if (!m) { + _ERR("invalid parameter"); + return; + } + + player_pause(m->player); + player_stop(m->player); + player_unprepare(m->player); +} + +bool playermgr_play(struct playermgr *m, const char *path) +{ + int r; + + if (!m || !path) { + _ERR("invalid parameter"); + return false; + } + + playermgr_stop(m); + + r = player_set_uri(m->player, path); + if (r != PLAYER_ERROR_NONE) { + _ERR("player: set_uri error (%d)", r); + return false; + } + + r = player_set_display(m->player, PLAYER_DISPLAY_TYPE_OVERLAY, + GET_DISPLAY(m->win)); + if (r != PLAYER_ERROR_NONE) { + _ERR("player: set_display error (%d)", r); + return false; + } + + r = player_set_display_mode(m->player, PLAYER_DISPLAY_MODE_FULL_SCREEN); + if (r != PLAYER_ERROR_NONE) { + _ERR("player: set_display_mode error (%d)", r); + return false; + } + + r = player_prepare(m->player); + if (r != PLAYER_ERROR_NONE) { + _ERR("player: prepare error (%d)", r); + return false; + } + + r = player_start(m->player); + if (r != PLAYER_ERROR_NONE) { + _ERR("player: start error (%d)", r); + return false; + } + + return true; +} + +bool playermgr_set_completed_cb(struct playermgr *m, + player_completed_cb cb, void *data) +{ + int r; + + r = player_set_completed_cb(m->player, cb, data); + if (r != PLAYER_ERROR_NONE) { + _ERR("player: set callback error (%d)", r); + return false; + } + + return true; +} + +struct playermgr *playermgr_create(Evas_Object *win) +{ + struct playermgr *m; + int r; + + if (!win) { + _ERR("invalid parameter"); + return NULL; + } + + m = calloc(1, sizeof(*m)); + if (!m) { + _ERR("failed to allocate"); + return NULL; + } + + r = player_create(&m->player); + if (r != PLAYER_ERROR_NONE) { + _ERR("player: creation error (%d)", r); + free(m); + return NULL; + } + + m->win = win; + + return m; +} + +void playermgr_destroy(struct playermgr *m) +{ + if (!m) { + _ERR("invalid parameter"); + return; + } + + if (m->player) { + playermgr_stop(m); + player_destroy(m->player); + } + + free(m); +} diff --git a/src/view/viewer.c b/src/view/viewer.c index 91c09be..898aa07 100644 --- a/src/view/viewer.c +++ b/src/view/viewer.c @@ -20,16 +20,21 @@ #include #include #include +#include #include #include "define.h" #include "util/controller.h" #include "util/timeout_handler.h" +#include "util/playermgr.h" +#include "util/util.h" #define STYLE_VIEWER_BTN "viewer_btn" #define PART_VIEWER_BTN "control_btn" +#define PLAY_BTN_LOC 2 #define VIEWER_TIMEOUT 3.0 +#define VIEWER_INTERVAL 0.1 #define VIDEO_COPYRIGHT "Unknown" @@ -62,10 +67,12 @@ struct _priv { Evas_Object *photo; Evas_Object *photo_pre; Evas_Object *favorite; + Evas_Object *timer; struct _viewer viewer; struct _playlist playlist; struct timeout_handler *timeout; + struct playermgr *player; bool bar_show; }; @@ -139,6 +146,8 @@ struct _viewer_info { void (*callback)(void *, const char *); }; +static void _player_play(struct _priv *priv); + static void _callback_movie(void *data, const char *ev); static void _callback_photo(void *data, const char *ev); static void _callback_video(void *data, const char *ev); @@ -247,7 +256,22 @@ static void _up_string(char *str) } } -static void _draw_thumbnail(struct _priv *priv, int id, app_media_info *mi) +static void _set_bg_color(struct _priv *priv, int r, int g, int b, int a) +{ + Evas_Object *bg; + + bg = evas_object_rectangle_add(evas_object_evas_get(priv->base)); + if (!bg) { + _ERR("failed to add rect"); + return; + } + + evas_object_color_set(bg, r, g, b, a); + + elm_object_part_content_set(priv->base, PART_VIEWER_BG, bg); +} + +static void _draw_thumbnail(struct _priv *priv, app_media_info *mi) { Evas_Object *obj; @@ -273,6 +297,23 @@ static void _draw_thumbnail(struct _priv *priv, int id, app_media_info *mi) priv->photo = obj; } +static void _remove_thumbnail(struct _priv *priv) +{ + if (priv->photo_pre) { + evas_object_del(priv->photo_pre); + priv->photo_pre = NULL; + } + + if (priv->photo) { + evas_object_del(priv->photo); + priv->photo = NULL; + } + + _set_bg_color(priv, 0, 0, 0, 0); + + elm_object_part_content_unset(priv->base, PART_VIEWER_CONTENT); +} + static void _image_loaded(void *data, Evas_Object *obj, void *ev) { struct _priv *priv; @@ -304,15 +345,15 @@ static void _image_loaded_detail(void *data, Evas_Object *obj, void *ev) priv->photo_pre = NULL; } -static void _load_image_file(struct _priv *priv, int id, app_media_info *mi) +static void _draw_contents(struct _priv *priv, int id, app_media_info *mi) { Evas_Object *obj; if (id == VIEWER_MOVIE) { - elm_object_part_content_unset(priv->base, PART_VIEWER_CONTENT); + _player_play(priv); return; } else if (id == VIEWER_VIDEO) { - _draw_thumbnail(priv, id, mi); + _draw_thumbnail(priv, mi); return; } @@ -346,6 +387,8 @@ static void _load_image_file(struct _priv *priv, int id, app_media_info *mi) priv->photo_pre = obj; } + _set_bg_color(priv, 0, 0, 0, 255); + elm_photocam_file_set(obj, mi->file_path); elm_photocam_zoom_mode_set(obj, ELM_PHOTOCAM_ZOOM_MODE_AUTO_FIT); } @@ -393,6 +436,14 @@ static void _draw_time_info(struct _priv *priv, int id, app_media_info *mi) elm_object_part_text_set(priv->base, PART_VIEWER_TOTAL, total); } +static void _draw_progress_info(struct _priv *priv, int ms) +{ + char progress[32] = {0,}; + + _time_string(progress, sizeof(progress), ms); + elm_object_part_text_set(priv->base, PART_VIEWER_PROGRESS, progress); +} + static void _draw_favorite_icon(struct _priv *priv, int id, app_media_info *mi) { if (!mi->favorite) @@ -402,26 +453,37 @@ static void _draw_favorite_icon(struct _priv *priv, int id, app_media_info *mi) PART_VIEWER_FAVORITE, priv->favorite); } -static bool _viewer_show(struct _priv *priv, int cur, int foc) +static app_media_info *_get_current_media_info(struct _priv *priv) { - struct _viewer_info *info; - struct controller *ctl; - int id; - int loc; app_media *am; app_media_info *mi; - am = eina_list_nth(priv->playlist.list, cur); + am = eina_list_nth(priv->playlist.list, priv->playlist.cur); if (!am) { _ERR("failed to get app_media"); - return false; + return NULL; } - priv->playlist.cur = cur; - mi = app_media_get_info(am); if (!mi) { _ERR("failed to getting media info"); + return NULL; + } + + return mi; +} + +static bool _viewer_show(struct _priv *priv, int foc) +{ + struct _viewer_info *info; + struct controller *ctl; + int id; + int loc; + app_media_info *mi; + + mi = _get_current_media_info(priv); + if (!mi) { + _ERR("failed to getting media info"); return false; } @@ -455,11 +517,15 @@ static bool _viewer_show(struct _priv *priv, int cur, int foc) case DIR_NONE: default: loc = info->focus_loc; + if (id == VIEWER_MOVIE) { + ctl->ops->signal(ctl->handle, + PLAY_BTN_LOC, SIG_SET_PAUSE); + } break; } ctl->ops->focus(ctl->handle, loc, true); - _load_image_file(priv, id, mi); + _draw_contents(priv, id, mi); _draw_title_bar(priv, id, mi); _draw_time_info(priv, id, mi); @@ -527,7 +593,7 @@ static bool _viewer_prev(struct _priv *priv) else priv->playlist.cur--; - r = _viewer_show(priv, priv->playlist.cur, DIR_PREV); + r = _viewer_show(priv, DIR_PREV); return r; } @@ -546,7 +612,7 @@ static bool _viewer_next(struct _priv *priv) else priv->playlist.cur++; - r = _viewer_show(priv, priv->playlist.cur, DIR_NEXT); + r = _viewer_show(priv, DIR_NEXT); return r; } @@ -623,8 +689,141 @@ err: return false; } +static Eina_Bool _timer_cb(void *data) +{ + struct _priv *priv; + int ms; + + if (!data) + return ECORE_CALLBACK_CANCEL; + + priv = data; + + ms = playermgr_get_position(priv->player); + + _draw_progress_info(priv, ms); + + return ECORE_CALLBACK_RENEW; +} + +static void _timer_reset(struct _priv *priv) +{ + if (priv->timer) + ecore_timer_reset(priv->timer); + else + priv->timer = ecore_timer_add(VIEWER_INTERVAL, _timer_cb, priv); +} + +static void _player_play(struct _priv *priv) +{ + app_media_info *mi; + player_state_e state; + + playermgr_get_state(priv->player, &state); + + switch (state) { + case PLAYER_STATE_PAUSED: + if (priv->timer) + ecore_timer_thaw(priv->timer); + + playermgr_resume(priv->player); + break; + case PLAYER_STATE_PLAYING: + if (priv->timer) + ecore_timer_freeze(priv->timer); + + playermgr_pause(priv->player); + break; + case PLAYER_STATE_IDLE: + case PLAYER_STATE_READY: + mi = _get_current_media_info(priv); + if (!mi) { + _ERR("failed to getting media info"); + return; + } + + _remove_thumbnail(priv); + _timer_reset(priv); + + playermgr_play(priv->player, mi->file_path); + + break; + default: + _ERR("player was not created"); + break; + } +} + +static void _player_stop(struct _priv *priv) +{ + struct controller *ctl; + + ecore_timer_del(priv->timer); + priv->timer = NULL; + + playermgr_stop(priv->player); + + ctl = priv->viewer.ctl[priv->viewer.cur]; + ctl->ops->signal(ctl->handle, PLAY_BTN_LOC, SIG_SET_PLAY); +} + +static void _player_complete_cb(void *data) +{ + struct _priv *priv; + + if (!data) + return; + + priv = data; + + ecore_timer_del(priv->timer); + priv->timer = NULL; +} + +static void _player_set_position_cb(void *data) +{ + struct _priv *priv; + struct controller *ctl; + int ms; + + if (!data) + return; + + priv = data; + + ms = playermgr_get_position(priv->player); + _draw_progress_info(priv, ms); + + /* FIXME: what will you do here? */ + playermgr_pause(priv->player); + + if (priv->timer) + ecore_timer_freeze(priv->timer); + + ctl = priv->viewer.ctl[priv->viewer.cur]; + ctl->ops->signal(ctl->handle, PLAY_BTN_LOC, SIG_SET_PLAY); +} + static void _callback_movie(void *data, const char *ev) { + struct _priv *priv; + int ms; + + if (!data || !ev) + return; + + priv = data; + + if (!strcmp(ev, SRC_BTN_PREV)) { + playermgr_set_position(priv->player, 0, + _player_set_position_cb, priv); + } else if (!strcmp(ev, SRC_BTN_NEXT)) { + ms = playermgr_get_duration(priv->player); + playermgr_set_position(priv->player, ms - 1000, + _player_set_position_cb, priv); + } else if (!strcmp(ev, SRC_BTN_PLAY)) { + _player_play(priv); + } } static void _callback_photo(void *data, const char *ev) @@ -636,11 +835,10 @@ static void _callback_photo(void *data, const char *ev) priv = data; - if (!strcmp(ev, SRC_BTN_PHOTO_PREV)) { + if (!strcmp(ev, SRC_BTN_PHOTO_PREV)) _viewer_prev(priv); - } else if (!strcmp(ev, SRC_BTN_PHOTO_NEXT)) { + else if (!strcmp(ev, SRC_BTN_PHOTO_NEXT)) _viewer_next(priv); - } } static void _callback_video(void *data, const char *ev) @@ -653,9 +851,13 @@ static void _callback_video(void *data, const char *ev) priv = data; if (!strcmp(ev, SRC_BTN_PREV)) { + _player_stop(priv); _viewer_prev(priv); } else if (!strcmp(ev, SRC_BTN_NEXT)) { + _player_stop(priv); _viewer_next(priv); + } else if (!strcmp(ev, SRC_BTN_PLAY)) { + _player_play(priv); } } @@ -663,6 +865,7 @@ static Evas_Object *_create(Evas_Object *win, void *data) { struct _priv *priv; Evas_Object *base; + struct playermgr *player; bool r; if (!win) { @@ -695,9 +898,25 @@ static Evas_Object *_create(Evas_Object *win, void *data) priv->playlist.list = NULL; priv->playlist.cur = 0; + player = playermgr_create(win); + if (!player) { + _ERR("failed to create player"); + return NULL; + } + + r = playermgr_set_completed_cb(player, _player_complete_cb, priv); + if (!r) { + _ERR("failed to set callback"); + playermgr_destroy(player); + return NULL; + } + + priv->player = player; + r = _ui_init(priv); if (!r) { _ERR("failed to init UI"); + playermgr_destroy(player); return NULL; } @@ -721,7 +940,7 @@ static void _show(void *view_data) priv = view_data; /* FIXME: test code */ - _viewer_show(priv, priv->playlist.cur, DIR_NONE); + _viewer_show(priv, DIR_NONE); timeout_handler_reset(priv->timeout); @@ -763,6 +982,11 @@ static void _destroy(void *view_data) timeout_handler_fini(priv->timeout); + ecore_timer_del(priv->timer); + priv->timer = NULL; + + playermgr_destroy(priv->player); + evas_object_del(priv->base); free(priv); -- 2.7.4 From 2c25e27e9f1e934c3edc75faacdbad131df69bd0 Mon Sep 17 00:00:00 2001 From: Jehun Lim Date: Mon, 6 Jul 2015 17:32:45 +0900 Subject: [PATCH 14/16] add listmgr to draw and update the thumbnail area Change-Id: I0cb4a9aeaf3e8d771fa720661e4caa60e897ea00 Signed-off-by: Jehun Lim --- CMakeLists.txt | 1 + include/util/listmgr.h | 38 ++++++++++ src/layout/movie.c | 163 +++++++++++---------------------------- src/util/listmgr.c | 201 +++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 284 insertions(+), 119 deletions(-) create mode 100644 include/util/listmgr.h create mode 100644 src/util/listmgr.c diff --git a/CMakeLists.txt b/CMakeLists.txt index 45014bc..cba373b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -55,6 +55,7 @@ src/layout/movie.c src/layout/gallery.c src/layout/music.c src/util/controller.c +src/util/listmgr.c src/util/timeout_handler.c src/util/util.c src/util/playermgr.c diff --git a/include/util/listmgr.h b/include/util/listmgr.h new file mode 100644 index 0000000..4889e3d --- /dev/null +++ b/include/util/listmgr.h @@ -0,0 +1,38 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef __AIR_MEDIAHUB_LISTMGR_H__ +#define __AIR_MEDIAHUB_LISTMGR_H__ + +struct listmgr; + +struct listmgr_data { + int grid_item_x; + int grid_item_y; + int grid_num_item; + + int box_padding; + + struct grid_class *gclass; +}; + +struct listmgr *listmgr_create(Evas_Object *base, void *data); +void listmgr_destroy(struct listmgr *listmgr); + +bool listmgr_draw_list_area(struct listmgr *lmgr); +bool listmgr_update_list_area(struct listmgr *lmgr, Eina_List *list); + +#endif /* __AIR_MEDIAHUB_LISTMGR_H__ */ diff --git a/src/layout/movie.c b/src/layout/movie.c index 8d4f587..af6855a 100644 --- a/src/layout/movie.c +++ b/src/layout/movie.c @@ -18,22 +18,22 @@ #include #include #include -#include #include +#include #include "define.h" #include "data/mediadata.h" -#include "util/util.h" +#include "util/listmgr.h" #define LIST_MEDIA_COND "media_type=1 AND copyright NOT LIKE \"Unknown\"" -#define TEXT_NOCONTENT "No Movie Content" +#define TEXT_NOCONTENT "No Movies" -#define NUM_CONTENT 2 -#define SIZE_GRID_ITEM_X 404 -#define SIZE_GRID_ITEM_Y 320 +#define GRID_ITEM_X 404 +#define GRID_ITEM_Y 320 +#define GRID_NUM_ITEM 2 -#define PADDING_BOX_ITEM 62 +#define BOX_PADDING 62 struct _priv { Evas_Object *base; @@ -42,7 +42,7 @@ struct _priv { layoutmgr *lmgr; - struct gridmgr *gmgr; + struct listmgr *listmgr; struct mediadata *md; @@ -109,75 +109,34 @@ static Evas_Object *_grid_content_get(void *data, return NULL; } -static struct grid_class gclass = { +static struct grid_class _gclass = { .item_style = STYLE_GRID_MOVIE_ITEM, .text_get = _grid_text_get, .content_get = _grid_content_get }; -static int _get_grid_size(int count) -{ - int size; - - size = count / NUM_CONTENT; - if (count % NUM_CONTENT > 0) - size++; - - return size; -} - -static Evas_Object *_draw_list_item(struct _priv *priv, struct group_info *gi) +static struct listmgr_data *_create_listmgr_data(void) { - Evas_Object *ly, *btn, *grid; - int size; - - ly = elm_layout_add(priv->box); - if (!ly) { - _ERR("failed to create layout object"); - return NULL; - } - - elm_layout_file_set(ly, EDJEFILE, GRP_LIST_ITEM); - - btn = elm_button_add(ly); - if (!btn) { - _ERR("failed to create button object"); - evas_object_del(ly); - return NULL; - } - - elm_object_style_set(btn, STYLE_BTN_INDEX); - elm_object_text_set(btn, gi->name); - - grid = util_add_gengrid(ly, SIZE_GRID_ITEM_X, SIZE_GRID_ITEM_Y); - if (!grid) { - _ERR("failed to create gengrid object"); - evas_object_del(ly); - return NULL; - } + struct listmgr_data *data; - if (!gridmgr_add_grid(priv->gmgr, gi->name, grid, &gclass)) { - _ERR("failed to add grid"); - evas_object_del(ly); + data = calloc(1, sizeof(*data)); + if (!data) { + _ERR("failed to allocate listmgr data"); return NULL; } - size = _get_grid_size(eina_list_count(gi->list)); + data->grid_item_x = GRID_ITEM_X; + data->grid_item_y = GRID_ITEM_Y; + data->grid_num_item = GRID_NUM_ITEM; + data->box_padding = BOX_PADDING; + data->gclass = &_gclass; - evas_object_size_hint_min_set(grid, size * SIZE_GRID_ITEM_X, - NUM_CONTENT * SIZE_GRID_ITEM_Y); - - elm_object_part_content_set(ly, PART_ITEM_TITLE, btn); - elm_object_part_content_set(ly, PART_ITEM_CONTENT, grid); - - return ly; + return data; } static void _update_list_area(struct _priv *priv) { - Eina_List *list, *l; - Evas_Object *ly; - struct group_info *gi; + Eina_List *list; if (priv->media_list) return; @@ -189,58 +148,16 @@ static void _update_list_area(struct _priv *priv) return; } - EINA_LIST_FOREACH(list, l, gi) { - ly = _draw_list_item(priv, gi); - if (!ly) { - _ERR("failed to draw list item"); - return; - } - - if (!gridmgr_append_list(priv->gmgr, gi->name, gi->list)) { - _ERR("failed to append list in grid"); - return; - } - - evas_object_show(ly); - - elm_box_pack_end(priv->box, ly); - } + if (!listmgr_update_list_area(priv->listmgr, list)) + _ERR("failed to update list area"); priv->media_list = list; } -static bool _draw_list_area(struct _priv *priv) -{ - Evas_Object *scr, *box; - - scr = util_add_scroller(priv->layout); - if (!scr) { - _ERR("failed to create scroller object"); - return false; - } - - box = util_add_box(scr); - if (!box) { - _ERR("failed to create box object"); - evas_object_del(scr); - return false; - } - - elm_box_padding_set(box, PADDING_BOX_ITEM, 0); - - evas_object_show(box); - elm_object_content_set(scr, box); - - elm_object_part_content_set(priv->layout, PART_CONTENT, scr); - - priv->box = box; - - return true; -} - static bool _create(layoutmgr *lmgr, void *data) { - struct gridmgr *gmgr; + struct listmgr *listmgr; + struct listmgr_data *ldata; struct mediadata *md; struct _priv *priv; Evas_Object *base, *layout; @@ -273,36 +190,44 @@ static bool _create(layoutmgr *lmgr, void *data) goto err2; } - gmgr = gridmgr_create(); - if (!gmgr) { - _ERR("failed to create gridmgr"); + ldata = _create_listmgr_data(); + if (!ldata) { + _ERR("failed to create listmgr data"); goto err2; } + listmgr = listmgr_create(layout, (void *)ldata); + if (!listmgr) { + _ERR("failed to create listmgr"); + goto err3; + } + md = mediadata_create(LIST_MEDIA_COND, E_SOURCE_ALL, E_SORT_NAME); if (!md) { _ERR("failed to create mediadata"); - gridmgr_destroy(gmgr); - goto err2; + listmgr_destroy(listmgr); + goto err3; } priv->base = base; priv->layout = layout; priv->lmgr = lmgr; - priv->gmgr = gmgr; + priv->listmgr = listmgr; priv->md = md; layoutmgr_set_layout_data(lmgr, LAYOUT_MOVIE, priv); - if (!_draw_list_area(priv)) { + if (!listmgr_draw_list_area(priv->listmgr)) { _ERR("failed to draw list area"); mediadata_destroy(md); - gridmgr_destroy(gmgr); - goto err2; + listmgr_destroy(listmgr); + goto err3; } return true; +err3: + free(ldata); err2: evas_object_del(layout); err: @@ -321,11 +246,11 @@ static void _destroy(void *layout_data) priv = layout_data; - gridmgr_destroy(priv->gmgr); - mediadata_free_list(priv->media_list); mediadata_destroy(priv->md); + listmgr_destroy(priv->listmgr); + evas_object_del(priv->layout); free(priv); } diff --git a/src/util/listmgr.c b/src/util/listmgr.c new file mode 100644 index 0000000..b5ca603 --- /dev/null +++ b/src/util/listmgr.c @@ -0,0 +1,201 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include "define.h" +#include "data/mediadata.h" +#include "util/listmgr.h" +#include "util/util.h" + +struct listmgr { + Evas_Object *base; + Evas_Object *box; + + struct gridmgr *gmgr; + struct listmgr_data *data; +}; + +static int _get_grid_size(int count, int num_item) +{ + int size; + + size = count / num_item; + if (count % num_item > 0) + size++; + + return size; +} + +static Evas_Object *_draw_list_item(struct listmgr *lmgr, struct group_info *gi) +{ + Evas_Object *ly, *btn, *grid; + struct listmgr_data *data; + int size; + + data = lmgr->data; + + ly = elm_layout_add(lmgr->box); + if (!ly) { + _ERR("failed to create layout object"); + return NULL; + } + + elm_layout_file_set(ly, EDJEFILE, GRP_LIST_ITEM); + + btn = elm_button_add(ly); + if (!btn) { + _ERR("failed to create button object"); + evas_object_del(ly); + return NULL; + } + + elm_object_style_set(btn, STYLE_BTN_INDEX); + elm_object_text_set(btn, gi->name); + + grid = util_add_gengrid(ly, data->grid_item_x, data->grid_item_y); + if (!grid) { + _ERR("failed to create gengrid object"); + evas_object_del(ly); + return NULL; + } + + if (!gridmgr_add_grid(lmgr->gmgr, gi->name, grid, data->gclass)) { + _ERR("failed to add grid"); + evas_object_del(ly); + return NULL; + } + + size = _get_grid_size(eina_list_count(gi->list), data->grid_num_item); + + evas_object_size_hint_min_set(grid, size * data->grid_item_x, + data->grid_num_item * data->grid_item_y); + + elm_object_part_content_set(ly, PART_ITEM_TITLE, btn); + elm_object_part_content_set(ly, PART_ITEM_CONTENT, grid); + + return ly; +} + +bool listmgr_update_list_area(struct listmgr *lmgr, Eina_List *list) +{ + Evas_Object *ly; + Eina_List *l; + struct group_info *gi; + + if (!lmgr) { + _ERR("invalid argument"); + return false; + } + + EINA_LIST_FOREACH(list, l, gi) { + ly = _draw_list_item(lmgr, gi); + if (!ly) { + _ERR("failed to draw list item"); + return false; + } + + if (!gridmgr_append_list(lmgr->gmgr, gi->name, gi->list)) { + _ERR("failed to append list in grid"); + return false; + } + + evas_object_show(ly); + + elm_box_pack_end(lmgr->box, ly); + } + + return true; +} + +bool listmgr_draw_list_area(struct listmgr *lmgr) +{ + Evas_Object *scr, *box; + + if (!lmgr) { + _ERR("invalid argument"); + return false; + } + + scr = util_add_scroller(lmgr->base); + if (!scr) { + _ERR("failed to create scroller object"); + return false; + } + + box = util_add_box(scr); + if (!box) { + _ERR("failed to create box object"); + evas_object_del(scr); + return false; + } + + elm_box_padding_set(box, lmgr->data->box_padding, 0); + + evas_object_show(box); + elm_object_content_set(scr, box); + + elm_object_part_content_set(lmgr->base, PART_CONTENT, scr); + + lmgr->box = box; + + return true; +} + +struct listmgr *listmgr_create(Evas_Object *base, void *data) +{ + struct gridmgr *gmgr; + struct listmgr *lmgr; + + if (!base || !data) { + _ERR("invalid argument"); + return NULL; + } + + lmgr = calloc(1, sizeof(*lmgr)); + if (!lmgr) { + _ERR("failed to allocate listmgr"); + return NULL; + } + + gmgr = gridmgr_create(); + if (!gmgr) { + _ERR("failed to create gridmgr"); + free(lmgr); + return false; + } + + lmgr->base = base; + lmgr->gmgr = gmgr; + lmgr->data = (struct listmgr_data *)data; + + return lmgr; +} + +void listmgr_destroy(struct listmgr *lmgr) +{ + if (!lmgr) { + _ERR("invalid argument"); + return; + } + + gridmgr_destroy(lmgr->gmgr); + free(lmgr->data); + + free(lmgr); +} -- 2.7.4 From 387651053ee860f7827722a7ca7edec1b3b4546e Mon Sep 17 00:00:00 2001 From: Jehun Lim Date: Tue, 7 Jul 2015 10:46:29 +0900 Subject: [PATCH 15/16] mediadata: add function to create list with media modified time Change-Id: I3ef1500a380bccfb49f06f40dc57f073d9767031 Signed-off-by: Jehun Lim --- include/data/mediadata.h | 1 + src/data/mediadata.c | 41 ++++++++++++++++++++++++++++++++++++++++- 2 files changed, 41 insertions(+), 1 deletion(-) diff --git a/include/data/mediadata.h b/include/data/mediadata.h index 006eaac..557c85f 100644 --- a/include/data/mediadata.h +++ b/include/data/mediadata.h @@ -36,6 +36,7 @@ enum sort_type { enum list_type { E_LIST_NAME = 0, + E_LIST_DATE, E_LIST_MAX }; diff --git a/src/data/mediadata.c b/src/data/mediadata.c index 04556b0..16504bb 100644 --- a/src/data/mediadata.c +++ b/src/data/mediadata.c @@ -29,6 +29,8 @@ static int _compare_cb_name(const void *, const void *); static int _compare_title(struct group_info *, app_media_info *); static char *_get_title(app_media_info *); +static int _compare_modified_time(struct group_info *, app_media_info *); +static char *_get_modified_time(app_media_info *); enum _filter_type { E_FILTER_FOLDER = 0, @@ -77,6 +79,10 @@ static struct _list_info g_list_info[E_LIST_MAX] = { [E_LIST_NAME] = { .media_cmp = _compare_title, .name_get = _get_title, + }, + [E_LIST_DATE] = { + .media_cmp = _compare_modified_time, + .name_get = _get_modified_time, } }; @@ -115,6 +121,17 @@ static bool _create_filter(struct _data *data, filter_h *filter, int type) return true; } +static char *_get_date_string(time_t time) +{ + struct tm tm; + char buf[32]; + + localtime_r(&time, &tm); + strftime(buf, sizeof(buf), "%Y.%m.%d", &tm); + + return strdup(buf); +} + static int _compare_title(struct group_info *gi, app_media_info *info) { if (!gi || !gi->name || !info->title) @@ -131,6 +148,28 @@ static char *_get_title(app_media_info *info) return strndup(info->title, 1); } +static int _compare_modified_time(struct group_info *gi, app_media_info *info) +{ + char *date; + int r; + + if (!gi || !gi->name) + return -1; + + date = _get_date_string(info->modified_time); + + r = strcasecmp(gi->name, date); + + free(date); + + return r; +} + +static char *_get_modified_time(app_media_info *info) +{ + return _get_date_string(info->modified_time); +} + static int _compare_cb_date(const void *data1, const void *data2) { app_media *am1, *am2; @@ -145,7 +184,7 @@ static int _compare_cb_date(const void *data1, const void *data2) if (!info1 || !info2) return -1; - if (info1->modified_time > info2->modified_time) + if (info1->modified_time < info2->modified_time) return 1; return -1; -- 2.7.4 From 1d50394f81d736ba0076c9cb970e3c159bafc425 Mon Sep 17 00:00:00 2001 From: Jehun Lim Date: Mon, 6 Jul 2015 21:43:42 +0900 Subject: [PATCH 16/16] gallery: draw content list area Change-Id: I7c8b100d699b9c0e48337b0418a738b7fe0414fd Signed-off-by: Jehun Lim --- include/layout/movie.h | 4 -- include/util/util.h | 1 + include/view/base.h | 14 +++- res/edc/layout/gallery.edc | 1 + res/edc/layout/movie.edc | 62 ---------------- res/edc/view/base.edc | 62 ++++++++++++++++ res/edc/widgets/gengrid.edc | 26 ++++--- src/layout/gallery.c | 170 ++++++++++++++++++++++++++++++++++++++++++-- src/layout/movie.c | 19 +++-- src/util/util.c | 19 +++++ src/view/base.c | 2 +- 11 files changed, 286 insertions(+), 94 deletions(-) diff --git a/include/layout/movie.h b/include/layout/movie.h index 4d83ecd..5d10efc 100644 --- a/include/layout/movie.h +++ b/include/layout/movie.h @@ -20,14 +20,10 @@ #define LAYOUT_MOVIE "LAYOUT_MOVIE" #define GRP_MOVIE_LAYOUT "group.movie_layout" -#define GRP_LIST_ITEM "group.list_item" #define PART_CONTENT "part.content" #define PART_NOCONTENT "part.nocontent" -#define PART_ITEM_TITLE "part.item_title" -#define PART_ITEM_CONTENT "part.item_content" -#define STYLE_BTN_INDEX "base_btn_index" #define STYLE_GRID_MOVIE_ITEM "movie_item" #endif /* __AIR_MEDIAHUB_LAYOUT_MOVIE_H__ */ diff --git a/include/util/util.h b/include/util/util.h index 59aefce..9f17b5f 100644 --- a/include/util/util.h +++ b/include/util/util.h @@ -20,6 +20,7 @@ Evas_Object *util_add_box(Evas_Object *base); Evas_Object *util_add_gengrid(Evas_Object *base, int item_size_x, int item_size_y); +Evas_Object *util_add_image(Evas_Object *base, const char *file); Evas_Object *util_add_scroller(Evas_Object *base); #endif /* __AIR_MEDIAHUB_UTIL_H__ */ diff --git a/include/view/base.h b/include/view/base.h index 470bc93..a40dd4e 100644 --- a/include/view/base.h +++ b/include/view/base.h @@ -17,15 +17,27 @@ #ifndef __AIR_MEDIAHUB_VIEW_BASE_H__ #define __AIR_MEDIAHUB_VIEW_BASE_H__ +/* view */ #define VIEW_BASE "VIEW_BASE" +/* group */ #define GRP_BASE_VIEW "group.base_view" +#define GRP_LIST_ITEM "group.list_item" +/* part */ #define PART_TITLE "part.title" #define PART_MENU_AREA "part.menu_area" #define PART_THUMBNAIL_AREA "part.thumbnail_area" #define PART_BOTTOM_AREA "part.bottom_area" -#define STYLE_MENU_BTN "base_btn_menu" +#define PART_ITEM_TITLE "part.item_title" +#define PART_ITEM_CONTENT "part.item_content" + +/* images */ +#define IMAGE_THUMBNAIL_PLAY IMAGEDIR"/ic_thumbnail_play.png" + +/* style */ +#define STYLE_BTN_MENU "base_btn_menu" +#define STYLE_BTN_INDEX "base_btn_index" #endif /* __AIR_MEDIAHUB_VIEW_BASE_H__ */ diff --git a/res/edc/layout/gallery.edc b/res/edc/layout/gallery.edc index 520e09a..a773e3d 100644 --- a/res/edc/layout/gallery.edc +++ b/res/edc/layout/gallery.edc @@ -16,4 +16,5 @@ group { name: GRP_GALLERY_LAYOUT; + inherit: GRP_MOVIE_LAYOUT; } diff --git a/res/edc/layout/movie.edc b/res/edc/layout/movie.edc index fa64707..d029dd9 100644 --- a/res/edc/layout/movie.edc +++ b/res/edc/layout/movie.edc @@ -74,65 +74,3 @@ group { } } } - -group { - name: GRP_LIST_ITEM; - parts { - part { - name: "area"; - type: RECT; - scale: 1; - description { - state: "default" 0.0; - min: 0 703; - fixed: 0 1; - visible: 0; - } - } - part { - name: PART_ITEM_TITLE; - type: SWALLOW; - scale: 1; - description { - state: "default" 0.0; - rel1.to: "area"; - rel2 { - to: "area"; - relative: 1.0 0.0; - } - min: 0 36; - align: 0.5 0.0; - fixed: 0 1; - } - } - part { - name: "padding_content"; - type: SPACER; - scale: 1; - description { - state: "default" 0.0; - rel1 { - to: PART_ITEM_TITLE; - relative: 0.0 1.0; - } - rel2.to: PART_ITEM_TITLE; - min: 0 28; - align: 0.5 0.0; - fixed: 0 1; - } - } - part { - name: PART_ITEM_CONTENT; - type: SWALLOW; - scale: 1; - description { - state: "default" 0.0; - rel1 { - to: "padding_content"; - relative: 0.0 1.0; - } - rel2.to: "area"; - } - } - } -} diff --git a/res/edc/view/base.edc b/res/edc/view/base.edc index 4ad5a83..931ffda 100644 --- a/res/edc/view/base.edc +++ b/res/edc/view/base.edc @@ -154,3 +154,65 @@ group { } } } + +group { + name: GRP_LIST_ITEM; + parts { + part { + name: "area"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + min: 0 703; + fixed: 0 1; + visible: 0; + } + } + part { + name: PART_ITEM_TITLE; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "area"; + rel2 { + to: "area"; + relative: 1.0 0.0; + } + min: 0 36; + align: 0.5 0.0; + fixed: 0 1; + } + } + part { + name: "padding_content"; + type: SPACER; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: PART_ITEM_TITLE; + relative: 0.0 1.0; + } + rel2.to: PART_ITEM_TITLE; + min: 0 28; + align: 0.5 0.0; + fixed: 0 1; + } + } + part { + name: PART_ITEM_CONTENT; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + rel1 { + to: "padding_content"; + relative: 0.0 1.0; + } + rel2.to: "area"; + } + } + } +} diff --git a/res/edc/widgets/gengrid.edc b/res/edc/widgets/gengrid.edc index 67e69eb..624f553 100644 --- a/res/edc/widgets/gengrid.edc +++ b/res/edc/widgets/gengrid.edc @@ -120,7 +120,7 @@ group { to: "bg"; relative: 1.0 0.0; } - min: 0 3; + min: 0 6; align: 0.5 0.0; color: COLOR_ITEM_FOCUS; fixed: 0 1; @@ -158,7 +158,7 @@ group { to: "elm.bg.text"; relative: 0.0 0.0; } - min: 3 0; + min: 6 0; align: 0.0 0.5; color: COLOR_ITEM_FOCUS; fixed: 1 0; @@ -196,7 +196,7 @@ group { to: "elm.bg.text"; relative: 1.0 0.0; } - min: 3 0; + min: 6 0; align: 1.0 0.5; color: COLOR_ITEM_FOCUS; fixed: 1 0; @@ -489,8 +489,16 @@ group { type: SWALLOW; description { state: "default" 0.0; - rel1.to: "defaultbg"; - rel2.to: "defaultbg"; + rel1 { + to: "defaultbg"; + relative: 0.5 0.5; + } + rel2 { + to: "defaultbg"; + relative: 0.5 0.5; + } + min: 80 80; + fixed: 1 1; } } part { @@ -505,7 +513,7 @@ group { to: "bg"; relative: 1.0 0.0; } - min: 0 3; + min: 0 6; align: 0.5 0.0; color: COLOR_ITEM_FOCUS; fixed: 0 1; @@ -543,7 +551,7 @@ group { to: "bg"; relative: 0.0 1.0; } - min: 3 0; + min: 6 0; align: 0.0 0.5; color: COLOR_ITEM_FOCUS; fixed: 1 0; @@ -578,7 +586,7 @@ group { relative: 1.0 1.0; } rel2.to: "bg"; - min: 3 0; + min: 6 0; align: 1.0 0.5; color: COLOR_ITEM_FOCUS; fixed: 1 0; @@ -616,7 +624,7 @@ group { to: "part_focus3"; relative: 0.0 1.0; } - min: 0 3; + min: 0 6; align: 0.5 1.0; color: COLOR_ITEM_FOCUS; fixed: 0 1; diff --git a/src/layout/gallery.c b/src/layout/gallery.c index 85df1b1..9dd4c73 100644 --- a/src/layout/gallery.c +++ b/src/layout/gallery.c @@ -15,20 +15,130 @@ */ #include +#include #include +#include +#include #include #include "define.h" +#include "data/mediadata.h" +#include "util/listmgr.h" +#include "util/util.h" + +#define LIST_MEDIA_COND "media_type=0 OR media_type=1" + +#define TEXT_NOCONTENT "No Photo & Video" + +#define GRID_ITEM_X 206 +#define GRID_ITEM_Y 206 +#define GRID_NUM_ITEM 3 + +#define BOX_PADDING 62 struct _priv { Evas_Object *base; Evas_Object *layout; layoutmgr *lmgr; + + struct listmgr *listmgr; + + struct mediadata *md; + + Eina_List *media_list; +}; + +static Evas_Object *_grid_content_get(void *data, + Evas_Object *obj, const char *part) +{ + Evas_Object *image; + app_media *am; + app_media_info *info; + + if (!data) + return NULL; + + am = data; + info = app_media_get_info(am); + if (!info) { + _ERR("failed to get media info"); + return NULL; + } + + image = NULL; + if (!strcmp(part, PART_ELM_SWALLOW_THUMBNAIL)) { + image = util_add_image(obj, info->thumbnail_path); + if (!image) { + _ERR("failed to create image object"); + return NULL; + } + + evas_object_show(image); + } else if (!strcmp(part, PART_ELM_SWALLOW_VIDEO)) { + if (info->media_type == MEDIA_CONTENT_TYPE_VIDEO) { + image = util_add_image(obj, IMAGE_THUMBNAIL_PLAY); + if (!image) { + _ERR("failed to create image object"); + return NULL; + } + + evas_object_show(image); + } + } + + return image; +} + +static struct grid_class _gclass = { + .item_style = STYLE_GRID_GALLERY_ITEM, + .content_get = _grid_content_get }; +static struct listmgr_data *_create_listmgr_data(void) +{ + struct listmgr_data *data; + + data = calloc(1, sizeof(*data)); + if (!data) { + _ERR("failed to allocate listmgr data"); + return NULL; + } + + data->grid_item_x = GRID_ITEM_X; + data->grid_item_y = GRID_ITEM_Y; + data->grid_num_item = GRID_NUM_ITEM; + data->box_padding = BOX_PADDING; + data->gclass = &_gclass; + + return data; +} + +static void _update_list_area(struct _priv *priv) +{ + Eina_List *list; + + if (priv->media_list) + return; + + list = mediadata_get_list(priv->md, E_LIST_DATE); + if (!list) { + elm_object_part_text_set(priv->layout, + PART_NOCONTENT, TEXT_NOCONTENT); + return; + } + + if (!listmgr_update_list_area(priv->listmgr, list)) + _ERR("failed to update list area"); + + priv->media_list = list; +} + static bool _create(layoutmgr *lmgr, void *data) { + struct listmgr *listmgr; + struct listmgr_data *ldata; + struct mediadata *md; struct _priv *priv; Evas_Object *base, *layout; @@ -46,30 +156,63 @@ static bool _create(layoutmgr *lmgr, void *data) base = layoutmgr_get_base(lmgr); if (!base) { _ERR("failed to get base object"); - free(priv); - return false; + goto err; } layout = elm_layout_add(base); if (!layout) { _ERR("failed to create layout"); - free(priv); - return false; + goto err; } if (!elm_layout_file_set(layout, EDJEFILE, GRP_GALLERY_LAYOUT)) { _ERR("failed to set layout file"); - evas_object_del(layout); - free(priv); + goto err2; + } + + ldata = _create_listmgr_data(); + if (!ldata) { + _ERR("failed to create listmgr data"); + goto err2; + } + + listmgr = listmgr_create(layout, (void *)ldata); + if (!listmgr) { + _ERR("failed to create listmgr"); + goto err3; + } + + md = mediadata_create(LIST_MEDIA_COND, E_SOURCE_ALL, E_SORT_DATE); + if (!md) { + _ERR("failed to create mediadata"); + listmgr_destroy(listmgr); + goto err3; } priv->base = base; priv->layout = layout; priv->lmgr = lmgr; + priv->listmgr = listmgr; + priv->md = md; layoutmgr_set_layout_data(lmgr, LAYOUT_GALLERY, priv); + if (!listmgr_draw_list_area(listmgr)) { + _ERR("failed to draw list area"); + mediadata_destroy(md); + listmgr_destroy(listmgr); + goto err3; + } + return true; + +err3: + free(ldata); +err2: + evas_object_del(layout); +err: + free(priv); + return false; } static void _destroy(void *layout_data) @@ -83,6 +226,11 @@ static void _destroy(void *layout_data) priv = layout_data; + mediadata_free_list(priv->media_list); + mediadata_destroy(priv->md); + + listmgr_destroy(priv->listmgr); + evas_object_del(priv->layout); free(priv); } @@ -120,6 +268,16 @@ static void _hide(void *layout_data) static void _update(void *layout_data, int update_type, void *data) { + struct _priv *priv; + + if (!layout_data) { + _ERR("failed to get layout data"); + return; + } + + priv = layout_data; + + _update_list_area(priv); } static layout_class _lclass = { diff --git a/src/layout/movie.c b/src/layout/movie.c index af6855a..326de60 100644 --- a/src/layout/movie.c +++ b/src/layout/movie.c @@ -24,6 +24,7 @@ #include "define.h" #include "data/mediadata.h" #include "util/listmgr.h" +#include "util/util.h" #define LIST_MEDIA_COND "media_type=1 AND copyright NOT LIKE \"Unknown\"" @@ -84,13 +85,8 @@ static Evas_Object *_grid_content_get(void *data, am = data; + image = NULL; if (!strcmp(part, PART_ELM_SWALLOW_THUMBNAIL)) { - image = elm_image_add(obj); - if (!image) { - _ERR("failed to create image object"); - return NULL; - } - info = app_media_get_info(am); if (!info) { _ERR("failed to get media info"); @@ -98,15 +94,16 @@ static Evas_Object *_grid_content_get(void *data, return NULL; } - elm_image_file_set(image, info->thumbnail_path, NULL); - elm_image_aspect_fixed_set(image, EINA_FALSE); + image = util_add_image(obj, info->thumbnail_path); + if (!image) { + _ERR("failed to create image object"); + return NULL; + } evas_object_show(image); - - return image; } - return NULL; + return image; } static struct grid_class _gclass = { diff --git a/src/util/util.c b/src/util/util.c index df8abad..e89555a 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -69,6 +69,25 @@ Evas_Object *util_add_gengrid(Evas_Object *base, return grid; } +Evas_Object *util_add_image(Evas_Object *base, const char *file) +{ + Evas_Object *image; + + if (!base || !file) + return NULL; + + image = elm_image_add(base); + if (!image) { + _ERR("failed to create image object"); + return NULL; + } + + elm_image_file_set(image, file, NULL); + elm_image_aspect_fixed_set(image, EINA_FALSE); + + return image; +} + Evas_Object *util_add_scroller(Evas_Object *base) { Evas_Object *scr; diff --git a/src/view/base.c b/src/view/base.c index 07247de..7185c77 100644 --- a/src/view/base.c +++ b/src/view/base.c @@ -140,7 +140,7 @@ static bool _draw_menu_btn(struct _priv *priv) return false; } - elm_object_style_set(btn, STYLE_MENU_BTN); + elm_object_style_set(btn, STYLE_BTN_MENU); elm_object_text_set(btn, g_menu_item[i].name); elm_box_pack_end(box, btn); -- 2.7.4