summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMinkyu Kang <mk7.kang@samsung.com>2015-06-30 19:58:51 +0900
committerMinkyu Kang <mk7.kang@samsung.com>2015-07-01 10:40:20 +0900
commit241e5fc9ffb0689f3fded34c719a037e219b284f (patch)
tree3edaff35523cbbd6494e3d160900b891bfd9721d
parent7751cd59ff62f53dcd8d5f006db4f2f083f5fe75 (diff)
downloadair_mediahub-241e5fc9ffb0689f3fded34c719a037e219b284f.tar.gz
air_mediahub-241e5fc9ffb0689f3fded34c719a037e219b284f.tar.bz2
air_mediahub-241e5fc9ffb0689f3fded34c719a037e219b284f.zip
add timeout_handler for show/hide the bar
Change-Id: If65892b0199abf91fec094727c8b08ea258040fa Signed-off-by: Minkyu Kang <mk7.kang@samsung.com>
-rw-r--r--CMakeLists.txt1
-rw-r--r--include/util/controller.h2
-rw-r--r--include/util/timeout_handler.h32
-rw-r--r--include/view/viewer.h3
-rw-r--r--res/edc/view/viewer.edc28
-rw-r--r--src/util/controller.c51
-rw-r--r--src/util/timeout_handler.c144
-rw-r--r--src/view/viewer.c54
8 files changed, 312 insertions, 3 deletions
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 <stdbool.h>
+#include <Elementary.h>
+#include <app_debug.h>
+
+#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);