From b833a113ff46f02e9fc1f9153cc6460e1856b46d Mon Sep 17 00:00:00 2001 From: Jehun Lim Date: Tue, 14 Apr 2015 17:54:17 +0900 Subject: [PATCH] customize key event handling of photocam in zoom view Change-Id: I2c80172801575c18d0a5def671c6b85b5dc8a6ad Signed-off-by: Jehun Lim --- include/common/define.h | 1 + include/view/photo-viewer/zoom_view.h | 6 +++-- res/edc/views/zoom_view.edc | 10 ++++++++ src/view/photo-viewer/zoom_view.cpp | 47 +++++++++++++++++++++++++++++++++++ 4 files changed, 62 insertions(+), 2 deletions(-) diff --git a/include/common/define.h b/include/common/define.h index 99db960..6faa101 100644 --- a/include/common/define.h +++ b/include/common/define.h @@ -31,6 +31,7 @@ /* Part name definitions */ #define PART_CONTENTAREA "content.area" #define PART_SWALLOWAREA "swallow.area" +#define PART_CONTENT_BTN "content.btn" #define PART_TITLETEXT "title.text" #define PART_RESOLUTIONTEXT "resolution.text" #define PART_SOURCETEXT "source.text" diff --git a/include/view/photo-viewer/zoom_view.h b/include/view/photo-viewer/zoom_view.h index 6a65e29..284bc28 100644 --- a/include/view/photo-viewer/zoom_view.h +++ b/include/view/photo-viewer/zoom_view.h @@ -25,7 +25,8 @@ struct zoom_data { class CPhotoZoomView : public CBaseView, IMouseClickedListener, IMouseMoveListener, - IMouseDownListener, IMouseUpListener, IChangedListener, + IMouseDownListener, IMouseUpListener, + IFocusedListener, IChangedListener, ITimeoutListener { private: struct SPhotoZoomView *m; @@ -66,7 +67,7 @@ public: CPhotoZoomView(const char *szViewId) : CBaseView(szViewId), IMouseClickedListener(this), IMouseMoveListener(this), IMouseDownListener(this), IMouseUpListener(this), - IChangedListener(this), m(0) {} + IFocusedListener(this), IChangedListener(this), m(0) {} virtual ~CPhotoZoomView() {} virtual bool Create(void *data); @@ -84,6 +85,7 @@ public: virtual void OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev); virtual void OnMouseDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Down *ev); virtual void OnMouseUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Up *ev); + virtual void OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item); virtual void OnChanged(int id, Evas_Object *obj); }; diff --git a/res/edc/views/zoom_view.edc b/res/edc/views/zoom_view.edc index 17f4695..f1c48b1 100644 --- a/res/edc/views/zoom_view.edc +++ b/res/edc/views/zoom_view.edc @@ -23,6 +23,16 @@ group { color: 0 0 0 255; } } + part { + name: PART_CONTENT_BTN; + type: SWALLOW; + scale: 1; + description { + state: "default" 0.0; + rel1.to: "bg"; + rel2.to: "bg"; + } + } part{ name: PART_CONTENTAREA; type: SWALLOW; diff --git a/src/view/photo-viewer/zoom_view.cpp b/src/view/photo-viewer/zoom_view.cpp index df94ada..a5907f2 100644 --- a/src/view/photo-viewer/zoom_view.cpp +++ b/src/view/photo-viewer/zoom_view.cpp @@ -52,6 +52,8 @@ enum EObjectType { ZOOM_VIEW = 0, + ZOOM_CONTENT, + ZOOM_CONTENT_BTN, ZOOM_SLIDER, ZOOM_ARROW, ZOOM_NAVI, @@ -63,6 +65,7 @@ struct SPhotoZoomView { Evas_Object *eoBase; Evas_Object *eoPhotocam; + Evas_Object *eoBtn; Evas_Object *eoPhotocamNavi; Evas_Object *eoSlider; double ratio; @@ -385,6 +388,15 @@ bool CPhotoZoomView::m_DrawContent(void) if (!m->eoBase || !m->minfo) return false; + m->eoBtn = elm_button_add(m->eoBase); + if (!m->eoBtn) + return false; + + elm_object_part_content_set(m->eoBase, PART_CONTENT_BTN, m->eoBtn); + evas_object_show(m->eoBtn); + + Connect(m->eoBtn, ZOOM_CONTENT_BTN, TYPE_KEY_DOWN); + minfo = m->minfo; file_path = minfo->Path(); @@ -406,6 +418,8 @@ bool CPhotoZoomView::m_DrawContent(void) elm_object_part_content_set(m->eoBase, PART_CONTENTAREA, m->eoPhotocam); + Connect(m->eoPhotocam, ZOOM_CONTENT, TYPE_FOCUSED); + if (!m_DrawSlider()) return false; @@ -643,6 +657,28 @@ void CPhotoZoomView::OnKeyDown(int id, Evas *e, Evas_Object *obj, case ZOOM_VIEW: m_ViewKeyDown(ev); break; + case ZOOM_CONTENT_BTN: + int x, y, w, h; + + elm_photocam_image_region_get(m->eoPhotocam, &x, &y, &w, &h); + + if (!strcmp(ev->keyname, KEY_LEFT)) { + elm_photocam_image_region_show(m->eoPhotocam, + x - PHOTOCAM_MOVE_SIZE, y, w, h); + } + else if (!strcmp(ev->keyname, KEY_RIGHT)) { + elm_photocam_image_region_show(m->eoPhotocam, + x + PHOTOCAM_MOVE_SIZE, y, w, h); + } + else if (!strcmp(ev->keyname, KEY_UP)) { + elm_photocam_image_region_show(m->eoPhotocam, + x, y - PHOTOCAM_MOVE_SIZE, w, h); + } + else if (!strcmp(ev->keyname, KEY_DOWN)) { + elm_photocam_image_region_show(m->eoPhotocam, + x, y + PHOTOCAM_MOVE_SIZE, w, h); + } + break; case ZOOM_SLIDER: if (!strcmp(ev->keyname, KEY_ENTER) || !strcmp(ev->keyname, KEY_ENTER_REMOTE) @@ -755,6 +791,17 @@ void CPhotoZoomView::OnMouseUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Mou } } +void CPhotoZoomView::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item) +{ + switch (id) { + case ZOOM_CONTENT: + elm_object_focus_set(m->eoBtn, EINA_TRUE); + break; + default: + break; + } +} + void CPhotoZoomView::OnChanged(int id, Evas_Object *obj) { switch (id) { -- 2.7.4