From 1633708cf23b3aad1f2ee7cc7577a6a3ecd06522 Mon Sep 17 00:00:00 2001 From: Jehun Lim Date: Mon, 30 Mar 2015 21:13:45 +0900 Subject: [PATCH] add UP and DOWN key handling to show and hide menu bar in photoviewer view Change-Id: Iefd1d89d353c4a9e68aa1c700c819ff9692a6673 Signed-off-by: Jehun Lim --- include/common/define.h | 2 ++ include/util/timeout_handler.h | 3 ++- src/util/timeout_handler.cpp | 9 +++++++ src/view/photo-viewer/photoviewer_view.cpp | 41 ++++++++++++++++++++---------- 4 files changed, 41 insertions(+), 14 deletions(-) diff --git a/include/common/define.h b/include/common/define.h index f7a0c45..f4bf39a 100644 --- a/include/common/define.h +++ b/include/common/define.h @@ -34,6 +34,8 @@ #define KEY_BACK_REMOTE "XF86Close" #define KEY_RIGHT "Right" #define KEY_LEFT "Left" +#define KEY_UP "Up" +#define KEY_DOWN "Down" #define KEY_MENU "Super_L" #define KEY_MENU_REMOTE "XF86Send" diff --git a/include/util/timeout_handler.h b/include/util/timeout_handler.h index 5f99c78..ad2a711 100644 --- a/include/util/timeout_handler.h +++ b/include/util/timeout_handler.h @@ -45,9 +45,10 @@ public: bool Create(double timeout, ITimeoutListener *listener); virtual void Destroy(void); + void Timeout(void); void Reset(void); void Pause(void); - void Resume(void); + void Resume(void); }; diff --git a/src/util/timeout_handler.cpp b/src/util/timeout_handler.cpp index f0c4588..85619e9 100644 --- a/src/util/timeout_handler.cpp +++ b/src/util/timeout_handler.cpp @@ -56,6 +56,7 @@ Eina_Bool CTimeoutHandler::sm_CbTimer(void *data) Eina_Bool CTimeoutHandler::m_OnTimer(void) { + ecore_timer_del(m->timer); m->timer = NULL; m->listener->OnTimeout(); @@ -149,6 +150,14 @@ error: } +void CTimeoutHandler::Timeout(void) +{ + ASSERT(m); + + m_OnTimer(); +} + + void CTimeoutHandler::Reset(void) { ASSERT(m); diff --git a/src/view/photo-viewer/photoviewer_view.cpp b/src/view/photo-viewer/photoviewer_view.cpp index 1c0cc5b..6c2ee7f 100644 --- a/src/view/photo-viewer/photoviewer_view.cpp +++ b/src/view/photo-viewer/photoviewer_view.cpp @@ -310,8 +310,7 @@ void CPhotoViewerView::m_OnSettingBtnClicked(Evas_Object *obj, m->pCtxPopup = pCtxPopup; pCtxPopup->Create(m->base, &cb); - m->tooltip_timer = NULL; - elm_object_tooltip_hide(m->focusedbtn); + m_OnTimerTooltip(); } @@ -342,8 +341,7 @@ void CPhotoViewerView::m_OnZoomBtnClicked(Evas_Object *obj, m->pCtxPopup = pCtxPopup; pCtxPopup->Create(m->base, &cb); - m->tooltip_timer = NULL; - elm_object_tooltip_hide(m->focusedbtn); + m_OnTimerTooltip(); } @@ -420,7 +418,9 @@ Eina_Bool CPhotoViewerView::sm_CbTimerTooltip(void *cookie) Eina_Bool CPhotoViewerView::m_OnTimerTooltip(void) { + ecore_timer_del(m->tooltip_timer); m->tooltip_timer = NULL; + elm_object_tooltip_hide(m->focusedbtn); return ECORE_CALLBACK_CANCEL; @@ -440,7 +440,9 @@ Eina_Bool CPhotoViewerView::sm_CbTimerPreviewBar(void *cookie) Eina_Bool CPhotoViewerView::m_OnTimerPreviewBar(void) { + ecore_timer_del(m->pvbar_timer); m->pvbar_timer = NULL; + elm_object_signal_emit(m->base, SIG_PREVIEWBAR_HIDE, ""); return ECORE_CALLBACK_CANCEL; @@ -1128,6 +1130,9 @@ void CPhotoViewerView::t_OnPause(void) m->pCtxPopup = NULL; } + if (m->tooltip_timer) + ecore_timer_freeze(m->tooltip_timer); + elm_object_tooltip_hide(m->focusedbtn); if (m->slideshow_timer) @@ -1140,25 +1145,29 @@ void CPhotoViewerView::t_OnResume(void) { ASSERT(m); - if (m->slideshow_timer) - ecore_timer_thaw(m->slideshow_timer); - - m->cTimeoutHandler.Resume(); - - elm_object_focus_set(m->focusedbtn, EINA_TRUE); - - elm_object_tooltip_show(m->focusedbtn); if (m->tooltip_timer) ecore_timer_reset(m->tooltip_timer); else { m->tooltip_timer = ecore_timer_add(TIMEOUT_TOOLTIP, sm_CbTimerTooltip, this); } + + elm_object_tooltip_show(m->focusedbtn); + + if (m->slideshow_timer) + ecore_timer_thaw(m->slideshow_timer); + + m->cTimeoutHandler.Resume(); + + elm_object_focus_set(m->focusedbtn, EINA_TRUE); } void CPhotoViewerView::OnTimeout(void) { + if (m->tooltip_timer) + m_OnTimerTooltip(); + if (m->pCtxPopup && m->pCtxPopup->FlagCreate()) { m->pCtxPopup->Destroy(); delete m->pCtxPopup; @@ -1195,6 +1204,11 @@ Eina_Bool CPhotoViewerView::OnEvent(int type, void *event_info) } else if (!strcmp(ev->keyname, KEY_RIGHT)) { sm_CbNextBtnClicked(this, NULL, NULL, NULL); return EINA_FALSE; + } else if (!strcmp(ev->keyname, KEY_UP)) { + if (m->slideshow_state == STATE_PLAY) + return EINA_FALSE; + + elm_object_signal_emit(m->base, SIG_MENU_SHOW, ""); } else if (!strcmp(ev->keyname, KEY_ENTER) || !strcmp(ev->keyname, KEY_ENTER_REMOTE)) { if (m->slideshow_state == STATE_PLAY) @@ -1240,7 +1254,8 @@ void CPhotoViewerView::OnKeyDown(int id, Evas *e, Evas_Object *obj, !strcmp(ev->keyname, KEY_MENU_REMOTE)) { m->pViewMgr->PushView(VIEW_CTXT_MENU, m->vd); t_OnPause(); - } + } else if (!strcmp(ev->keyname, KEY_DOWN)) + m->cTimeoutHandler.Timeout(); break; default: -- 2.7.4