From bde1bedb1f69243159e84aed0fc94c8ce4e907e3 Mon Sep 17 00:00:00 2001 From: JuWan Kim Date: Thu, 5 Mar 2015 11:24:21 +0900 Subject: [PATCH] Add PhotoLayout, VideoLayout, MusicLayout code and layout change code Change-Id: Ia1c7601f549a874db91a78a0e7b911f51bdd6d4f Signed-off-by: JuWan Kim --- include/FbAllLayout.h | 5 - include/FbMusicLayout.h | 10 +- include/FbPhotoLayout.h | 10 +- include/FbVideoLayout.h | 10 +- res/edc/file-browser.edc | 5 +- .../views/{base-layout.edc => music-layout.edc} | 2 +- res/edc/views/photo-layout.edc | 19 +++ res/edc/views/video-layout.edc | 19 +++ src/layouts/FbAllLayout.cpp | 43 ++---- src/layouts/FbMusicLayout.cpp | 141 +++++++++++++++--- src/layouts/FbPhotoLayout.cpp | 141 +++++++++++++++--- src/layouts/FbVideoLayout.cpp | 141 +++++++++++++++--- src/views/BaseView/FbBaseView.cpp | 160 +++++++++++++-------- src/views/BaseView/FileGrid.cpp | 2 +- 14 files changed, 536 insertions(+), 172 deletions(-) rename res/edc/views/{base-layout.edc => music-layout.edc} (91%) create mode 100644 res/edc/views/photo-layout.edc create mode 100644 res/edc/views/video-layout.edc diff --git a/include/FbAllLayout.h b/include/FbAllLayout.h index e1be079..0b31ba2 100644 --- a/include/FbAllLayout.h +++ b/include/FbAllLayout.h @@ -18,8 +18,6 @@ private: protected: //! Show this layout instance. This function is invoked by CLayoutMgr. virtual void t_OnShow(void); - //! Hide this layout instance. this function is invoked by CLayoutMgr. - virtual void t_OnHide(void); public: CFbAllLayout(const char *szLayoutId) : CBaseLayout(szLayoutId), m(0) {} @@ -28,10 +26,7 @@ public: bool Create(CLayoutMgr *mgr, void *data); virtual void Destroy(void); - void Update(bool flag); - void SetFocus(Eina_Bool flag); - Evas_Object* Grid(void); void Action(void); }; diff --git a/include/FbMusicLayout.h b/include/FbMusicLayout.h index 9b8904d..f16c3d1 100644 --- a/include/FbMusicLayout.h +++ b/include/FbMusicLayout.h @@ -7,14 +7,17 @@ private: struct SFbMusicLayout *m; private: + static void sm_CbUpdateEmptyFocusSequence(void* cookie); + static void sm_CbUpdatedGrid(void* cookie); + static void sm_CbUnsetFocus(void* cookie); + static void sm_CbLinkApp(void* cookie, int type, int source_type, char *path); + bool t_CreateFileGrid(Evas_Object *layout); void t_DestroyFileGrid(void); protected: //! Show this layout instance. This function is invoked by CLayoutMgr. virtual void t_OnShow(void); - //! Hide this layout instance. this function is invoked by CLayoutMgr. - virtual void t_OnHide(void); public: CFbMusicLayout(const char *szLayoutId) : CBaseLayout(szLayoutId), m(0) {} @@ -23,10 +26,7 @@ public: bool Create(CLayoutMgr *mgr, void *data); virtual void Destroy(void); - void Update(bool flag); - void SetFocus(Eina_Bool flag); - Evas_Object* Grid(void); void Action(void); }; diff --git a/include/FbPhotoLayout.h b/include/FbPhotoLayout.h index 4e0a2cf..37bcb7f 100644 --- a/include/FbPhotoLayout.h +++ b/include/FbPhotoLayout.h @@ -7,14 +7,17 @@ private: struct SFbPhotoLayout *m; private: + static void sm_CbUpdateEmptyFocusSequence(void* cookie); + static void sm_CbUpdatedGrid(void* cookie); + static void sm_CbUnsetFocus(void* cookie); + static void sm_CbLinkApp(void* cookie, int type, int source_type, char *path); + bool t_CreateFileGrid(Evas_Object *layout); void t_DestroyFileGrid(void); protected: //! Show this layout instance. This function is invoked by CLayoutMgr. virtual void t_OnShow(void); - //! Hide this layout instance. this function is invoked by CLayoutMgr. - virtual void t_OnHide(void); public: CFbPhotoLayout(const char *szLayoutId) : CBaseLayout(szLayoutId), m(0) {} @@ -23,10 +26,7 @@ public: bool Create(CLayoutMgr *mgr, void *data); virtual void Destroy(void); - void Update(bool flag); - void SetFocus(Eina_Bool flag); - Evas_Object* Grid(void); void Action(void); }; diff --git a/include/FbVideoLayout.h b/include/FbVideoLayout.h index ba1a7c5..90f2c51 100644 --- a/include/FbVideoLayout.h +++ b/include/FbVideoLayout.h @@ -7,14 +7,17 @@ private: struct SFbVideoLayout *m; private: + static void sm_CbUpdateEmptyFocusSequence(void* cookie); + static void sm_CbUpdatedGrid(void* cookie); + static void sm_CbUnsetFocus(void* cookie); + static void sm_CbLinkApp(void* cookie, int type, int source_type, char *path); + bool t_CreateFileGrid(Evas_Object *layout); void t_DestroyFileGrid(void); protected: //! Show this layout instance. This function is invoked by CLayoutMgr. virtual void t_OnShow(void); - //! Hide this layout instance. this function is invoked by CLayoutMgr. - virtual void t_OnHide(void); public: CFbVideoLayout(const char *szLayoutId) : CBaseLayout(szLayoutId), m(0) {} @@ -23,10 +26,7 @@ public: bool Create(CLayoutMgr *mgr, void *data); virtual void Destroy(void); - void Update(bool flag); - void SetFocus(Eina_Bool flag); - Evas_Object* Grid(void); void Action(void); }; diff --git a/res/edc/file-browser.edc b/res/edc/file-browser.edc index 84dd8e7..03aa908 100644 --- a/res/edc/file-browser.edc +++ b/res/edc/file-browser.edc @@ -2,6 +2,9 @@ collections { #include "views/common.edc" #include "views/base-view.edc" - #include "views/base-layout.edc" + #include "views/all-layout.edc" + #include "views/photo-layout.edc" + #include "views/video-layout.edc" + #include "views/music-layout.edc" #include "views/context-view.edc" } diff --git a/res/edc/views/base-layout.edc b/res/edc/views/music-layout.edc similarity index 91% rename from res/edc/views/base-layout.edc rename to res/edc/views/music-layout.edc index f8b68a9..2cafb42 100644 --- a/res/edc/views/base-layout.edc +++ b/res/edc/views/music-layout.edc @@ -1,5 +1,5 @@ group { - name: FB_ALL_LAYOUT; + name: FB_MUSIC_LAYOUT; parts { part { name: "bg"; diff --git a/res/edc/views/photo-layout.edc b/res/edc/views/photo-layout.edc new file mode 100644 index 0000000..e96f36e --- /dev/null +++ b/res/edc/views/photo-layout.edc @@ -0,0 +1,19 @@ +group { + name: FB_PHOTO_LAYOUT; + parts { + part { + name: "bg"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + visible: 0; + } + } + PART_RECT_PADDING(padding_grid, 0 0, bg) + PART_SWALLOW_BASIC(FBR_PART_MEDIA_GRID, 1395+20 848, + padding_grid, 0 0) + } +} + + diff --git a/res/edc/views/video-layout.edc b/res/edc/views/video-layout.edc new file mode 100644 index 0000000..b0d1525 --- /dev/null +++ b/res/edc/views/video-layout.edc @@ -0,0 +1,19 @@ +group { + name: FB_VIDEO_LAYOUT; + parts { + part { + name: "bg"; + type: RECT; + scale: 1; + description { + state: "default" 0.0; + visible: 0; + } + } + PART_RECT_PADDING(padding_grid, 0 0, bg) + PART_SWALLOW_BASIC(FBR_PART_MEDIA_GRID, 1395+20 848, + padding_grid, 0 0) + } +} + + diff --git a/src/layouts/FbAllLayout.cpp b/src/layouts/FbAllLayout.cpp index 773ad04..9f8a4e6 100644 --- a/src/layouts/FbAllLayout.cpp +++ b/src/layouts/FbAllLayout.cpp @@ -93,6 +93,7 @@ bool CFbAllLayout::t_CreateFileGrid(Evas_Object *layout) cb.cbLinkApp = sm_CbLinkApp; cb.cookie = m->eoBase; if (!m->pFileGrid->Create(m->eoWin, layout, &cb)) { + _DBG("Fail to create FileGrid"); delete m->pFileGrid; m->pFileGrid = NULL; return false; @@ -114,18 +115,10 @@ void CFbAllLayout::t_DestroyFileGrid(void) void CFbAllLayout::t_OnShow(void) { - _DBG(); - -//m->pFileGrid->Update(false); -// CBaseLayout::t_OnShow(); - return; -} - - -void CFbAllLayout::t_OnHide(void) -{ -// CBaseLayout::t_OnHide(); - return; + elm_object_part_content_unset(m->eoBase, FBR_PART_CONTENT); + elm_object_part_content_set(m->eoBase, FBR_PART_CONTENT, Layout()); + m->pFileGrid->Update(false); + CBaseLayout::t_OnShow(); } @@ -133,8 +126,8 @@ bool CFbAllLayout::Create(CLayoutMgr *mgr, void *data) { ASSERT(!m); ASSERT(mgr); - - Evas_Object *layout = NULL; + + Evas_Object* layout = NULL; _CREATE_BEGIN{ _CHECK(m = new SFbAllLayout) @@ -145,7 +138,10 @@ bool CFbAllLayout::Create(CLayoutMgr *mgr, void *data) _CHECK(layout = elm_layout_add(m->eoBase)) _CHECK(elm_layout_file_set(layout, EDJEFILE, FB_ALL_LAYOUT)) _CHECK(t_CreateFileGrid(layout)) - _COMMAND{ elm_object_part_content_set(m->eoBase, FBR_PART_CONTENT, layout); } + _COMMAND{ + elm_object_part_content_unset(m->eoBase, FBR_PART_CONTENT); + elm_object_part_content_set(m->eoBase, FBR_PART_CONTENT, layout); + } _CHECK(CBaseLayout::Create(layout)) _WHEN_SUCCESS{} @@ -176,15 +172,6 @@ void CFbAllLayout::Destroy(void) } -void CFbAllLayout::Update(bool flag) -{ - ASSERT(m); - _DBG(); - - m->pFileGrid->Update(flag); -} - - void CFbAllLayout::SetFocus(Eina_Bool flag) { ASSERT(m); @@ -194,14 +181,6 @@ void CFbAllLayout::SetFocus(Eina_Bool flag) } -Evas_Object* CFbAllLayout::Grid(void) -{ - ASSERT(m); - - return m->pFileGrid->Grid(); -} - - void CFbAllLayout::Action(void) { ASSERT(m); diff --git a/src/layouts/FbMusicLayout.cpp b/src/layouts/FbMusicLayout.cpp index ba0b492..6dd1de3 100644 --- a/src/layouts/FbMusicLayout.cpp +++ b/src/layouts/FbMusicLayout.cpp @@ -24,61 +24,166 @@ struct SFbMusicLayout { }; -bool CFbMusicLayout::t_CreateFileGrid(Evas_Object *layout) +void CFbMusicLayout::sm_CbUpdateEmptyFocusSequence(void* cookie) { - return true; + _DBG(); + CFbBaseView *pfbBaseView = NULL; + Evas_Object *eoBase = (Evas_Object*)cookie; + + if (!eoBase) + return; + + pfbBaseView = (CFbBaseView*)evas_object_data_get(eoBase, BASE_VIEW_DATA); + ASSERT(pfbBaseView); + pfbBaseView->UpdateEmptyFocusSequence(); } -void CFbMusicLayout::t_DestroyFileGrid(void) +void CFbMusicLayout::sm_CbUpdatedGrid(void* cookie) { - return; + _DBG(); + CFbBaseView *pfbBaseView = NULL; + Evas_Object *eoBase = (Evas_Object*)cookie; + if (!eoBase) + return; + + pfbBaseView = (CFbBaseView*)evas_object_data_get(eoBase, BASE_VIEW_DATA); + ASSERT(pfbBaseView); + pfbBaseView->UpdatedGrid(); } -void CFbMusicLayout::t_OnShow(void) +void CFbMusicLayout::sm_CbUnsetFocus(void* cookie) { - return; + _DBG(); + CFbBaseView *pfbBaseView = NULL; + Evas_Object *eoBase = (Evas_Object*)cookie; + if (eoBase) { + pfbBaseView = (CFbBaseView*)evas_object_data_get(eoBase, BASE_VIEW_DATA); + ASSERT(pfbBaseView); + pfbBaseView->UnsetFocus(); + } } -void CFbMusicLayout::t_OnHide(void) +void CFbMusicLayout::sm_CbLinkApp(void* cookie, int type, int source_type, char *path) { - return; + _DBG(); + CFbBaseView *pfbBaseView = NULL; + Evas_Object *eoBase = (Evas_Object*)cookie; + if (eoBase) + { + pfbBaseView = (CFbBaseView*)evas_object_data_get(eoBase, BASE_VIEW_DATA); + ASSERT(pfbBaseView); + pfbBaseView->CbLinkApp(type, source_type, path); + } } -bool CFbMusicLayout::Create(CLayoutMgr *mgr, void *data) +bool CFbMusicLayout::t_CreateFileGrid(Evas_Object *layout) { + m->pFileGrid = new CFileGrid; + if (!m->pFileGrid) + return false; + + CFileGrid::SCallback cb; + cb.cbUpdateEmptyFocusSequence = sm_CbUpdateEmptyFocusSequence; + cb.cbUpdatedGrid = sm_CbUpdatedGrid; + cb.cbUnsetFocus = sm_CbUnsetFocus; + cb.cbLinkApp = sm_CbLinkApp; + cb.cookie = m->eoBase; + if (!m->pFileGrid->Create(m->eoWin, layout, &cb)) { + _DBG("Fail to create FileGrid"); + delete m->pFileGrid; + m->pFileGrid = NULL; + return false; + } return true; } -void CFbMusicLayout::Destroy(void) +void CFbMusicLayout::t_DestroyFileGrid(void) +{ + if (!m->pFileGrid) + return; + + m->pFileGrid->Destroy(); + delete m->pFileGrid; + m->pFileGrid = NULL; +} + + +void CFbMusicLayout::t_OnShow(void) { - return; + elm_object_part_content_unset(m->eoBase, FBR_PART_CONTENT); + elm_object_part_content_set(m->eoBase, FBR_PART_CONTENT, Layout()); + m->pFileGrid->Update(false); + CBaseLayout::t_OnShow(); } -void CFbMusicLayout::Update(bool flag) +bool CFbMusicLayout::Create(CLayoutMgr *mgr, void *data) { - return; + ASSERT(!m); + ASSERT(mgr); + + Evas_Object* layout = NULL; + + _CREATE_BEGIN{ + _CHECK(m = new SFbMusicLayout) + _CHECK(m->pLayoutMgr = mgr) + _CHECK(m->pViewMgr = CViewMgr::GetInstance()) + _CHECK(m->eoBase = m->pLayoutMgr->Base()) + _CHECK(m->eoWin = m->pViewMgr->Window()) + _CHECK(layout = elm_layout_add(m->eoBase)) + _CHECK(elm_layout_file_set(layout, EDJEFILE, FB_MUSIC_LAYOUT)) + _CHECK(t_CreateFileGrid(layout)) + _COMMAND{ + elm_object_part_content_unset(m->eoBase, FBR_PART_CONTENT); + elm_object_part_content_set(m->eoBase, FBR_PART_CONTENT, layout); + } + _CHECK(CBaseLayout::Create(layout)) + + _WHEN_SUCCESS{} + + _CHECK_FAIL{ CBaseLayout::Destroy(); } + _CHECK_FAIL{ t_DestroyFileGrid(); } + _CHECK_FAIL{ /* elm_layout_file_set */ } + _CHECK_FAIL{ /* elm_layout_add */ } + _CHECK_FAIL{ /* m->pViewMgr->Window()*/ } + _CHECK_FAIL{ /* m->pLayoutMgr->Base() */ } + _CHECK_FAIL{ /* CViewMgr::GetInstace() */ } + _CHECK_FAIL{ /* m->pLayoutMgr = mgr */ } + _CHECK_FAIL{ delete m; m = NULL; } + } _CREATE_END_AND_CATCH{ return false; } + + return true; } -void CFbMusicLayout::SetFocus(Eina_Bool flag) +void CFbMusicLayout::Destroy(void) { - return; + ASSERT(m); + + CBaseLayout::Destroy(); + t_DestroyFileGrid(); + delete m; + m = NULL; } -Evas_Object* CFbMusicLayout::Grid(void) +void CFbMusicLayout::SetFocus(Eina_Bool flag) { - return NULL; + ASSERT(m); + _DBG(); + + m->pFileGrid->SetFocus(flag); } void CFbMusicLayout::Action(void) { - return; + ASSERT(m); + + return m->pFileGrid->Action(); } diff --git a/src/layouts/FbPhotoLayout.cpp b/src/layouts/FbPhotoLayout.cpp index f7264cf..5e55159 100644 --- a/src/layouts/FbPhotoLayout.cpp +++ b/src/layouts/FbPhotoLayout.cpp @@ -24,61 +24,166 @@ struct SFbPhotoLayout { }; -bool CFbPhotoLayout::t_CreateFileGrid(Evas_Object *layout) +void CFbPhotoLayout::sm_CbUpdateEmptyFocusSequence(void* cookie) { - return true; + _DBG(); + CFbBaseView *pfbBaseView = NULL; + Evas_Object *eoBase = (Evas_Object*)cookie; + + if (!eoBase) + return; + + pfbBaseView = (CFbBaseView*)evas_object_data_get(eoBase, BASE_VIEW_DATA); + ASSERT(pfbBaseView); + pfbBaseView->UpdateEmptyFocusSequence(); } -void CFbPhotoLayout::t_DestroyFileGrid(void) +void CFbPhotoLayout::sm_CbUpdatedGrid(void* cookie) { - return; + _DBG(); + CFbBaseView *pfbBaseView = NULL; + Evas_Object *eoBase = (Evas_Object*)cookie; + if (!eoBase) + return; + + pfbBaseView = (CFbBaseView*)evas_object_data_get(eoBase, BASE_VIEW_DATA); + ASSERT(pfbBaseView); + pfbBaseView->UpdatedGrid(); } -void CFbPhotoLayout::t_OnShow(void) +void CFbPhotoLayout::sm_CbUnsetFocus(void* cookie) { - return; + _DBG(); + CFbBaseView *pfbBaseView = NULL; + Evas_Object *eoBase = (Evas_Object*)cookie; + if (eoBase) { + pfbBaseView = (CFbBaseView*)evas_object_data_get(eoBase, BASE_VIEW_DATA); + ASSERT(pfbBaseView); + pfbBaseView->UnsetFocus(); + } } -void CFbPhotoLayout::t_OnHide(void) +void CFbPhotoLayout::sm_CbLinkApp(void* cookie, int type, int source_type, char *path) { - return; + _DBG(); + CFbBaseView *pfbBaseView = NULL; + Evas_Object *eoBase = (Evas_Object*)cookie; + if (eoBase) + { + pfbBaseView = (CFbBaseView*)evas_object_data_get(eoBase, BASE_VIEW_DATA); + ASSERT(pfbBaseView); + pfbBaseView->CbLinkApp(type, source_type, path); + } } -bool CFbPhotoLayout::Create(CLayoutMgr *mgr, void *data) +bool CFbPhotoLayout::t_CreateFileGrid(Evas_Object *layout) { + m->pFileGrid = new CFileGrid; + if (!m->pFileGrid) + return false; + + CFileGrid::SCallback cb; + cb.cbUpdateEmptyFocusSequence = sm_CbUpdateEmptyFocusSequence; + cb.cbUpdatedGrid = sm_CbUpdatedGrid; + cb.cbUnsetFocus = sm_CbUnsetFocus; + cb.cbLinkApp = sm_CbLinkApp; + cb.cookie = m->eoBase; + if (!m->pFileGrid->Create(m->eoWin, layout, &cb)) { + _DBG("Fail to create FileGrid"); + delete m->pFileGrid; + m->pFileGrid = NULL; + return false; + } return true; } -void CFbPhotoLayout::Destroy(void) +void CFbPhotoLayout::t_DestroyFileGrid(void) +{ + if (!m->pFileGrid) + return; + + m->pFileGrid->Destroy(); + delete m->pFileGrid; + m->pFileGrid = NULL; +} + + +void CFbPhotoLayout::t_OnShow(void) { - return; + elm_object_part_content_unset(m->eoBase, FBR_PART_CONTENT); + elm_object_part_content_set(m->eoBase, FBR_PART_CONTENT, Layout()); + m->pFileGrid->Update(false); + CBaseLayout::t_OnShow(); } -void CFbPhotoLayout::Update(bool flag) +bool CFbPhotoLayout::Create(CLayoutMgr *mgr, void *data) { - return; + ASSERT(!m); + ASSERT(mgr); + + Evas_Object* layout = NULL; + + _CREATE_BEGIN{ + _CHECK(m = new SFbPhotoLayout) + _CHECK(m->pLayoutMgr = mgr) + _CHECK(m->pViewMgr = CViewMgr::GetInstance()) + _CHECK(m->eoBase = m->pLayoutMgr->Base()) + _CHECK(m->eoWin = m->pViewMgr->Window()) + _CHECK(layout = elm_layout_add(m->eoBase)) + _CHECK(elm_layout_file_set(layout, EDJEFILE, FB_PHOTO_LAYOUT)) + _CHECK(t_CreateFileGrid(layout)) + _COMMAND{ + elm_object_part_content_unset(m->eoBase, FBR_PART_CONTENT); + elm_object_part_content_set(m->eoBase, FBR_PART_CONTENT, layout); + } + _CHECK(CBaseLayout::Create(layout)) + + _WHEN_SUCCESS{} + + _CHECK_FAIL{ CBaseLayout::Destroy(); } + _CHECK_FAIL{ t_DestroyFileGrid(); } + _CHECK_FAIL{ /* elm_layout_file_set */ } + _CHECK_FAIL{ /* elm_layout_add */ } + _CHECK_FAIL{ /* m->pViewMgr->Window()*/ } + _CHECK_FAIL{ /* m->pLayoutMgr->Base() */ } + _CHECK_FAIL{ /* CViewMgr::GetInstace() */ } + _CHECK_FAIL{ /* m->pLayoutMgr = mgr */ } + _CHECK_FAIL{ delete m; m = NULL; } + } _CREATE_END_AND_CATCH{ return false; } + + return true; } -void CFbPhotoLayout::SetFocus(Eina_Bool flag) +void CFbPhotoLayout::Destroy(void) { - return; + ASSERT(m); + + CBaseLayout::Destroy(); + t_DestroyFileGrid(); + delete m; + m = NULL; } -Evas_Object* CFbPhotoLayout::Grid(void) +void CFbPhotoLayout::SetFocus(Eina_Bool flag) { - return NULL; + ASSERT(m); + _DBG(); + + m->pFileGrid->SetFocus(flag); } void CFbPhotoLayout::Action(void) { - return; + ASSERT(m); + + return m->pFileGrid->Action(); } diff --git a/src/layouts/FbVideoLayout.cpp b/src/layouts/FbVideoLayout.cpp index c2229c1..3ba8d47 100644 --- a/src/layouts/FbVideoLayout.cpp +++ b/src/layouts/FbVideoLayout.cpp @@ -24,61 +24,166 @@ struct SFbVideoLayout { }; -bool CFbVideoLayout::t_CreateFileGrid(Evas_Object *layout) +void CFbVideoLayout::sm_CbUpdateEmptyFocusSequence(void* cookie) { - return true; + _DBG(); + CFbBaseView *pfbBaseView = NULL; + Evas_Object *eoBase = (Evas_Object*)cookie; + + if (!eoBase) + return; + + pfbBaseView = (CFbBaseView*)evas_object_data_get(eoBase, BASE_VIEW_DATA); + ASSERT(pfbBaseView); + pfbBaseView->UpdateEmptyFocusSequence(); } -void CFbVideoLayout::t_DestroyFileGrid(void) +void CFbVideoLayout::sm_CbUpdatedGrid(void* cookie) { - return; + _DBG(); + CFbBaseView *pfbBaseView = NULL; + Evas_Object *eoBase = (Evas_Object*)cookie; + if (!eoBase) + return; + + pfbBaseView = (CFbBaseView*)evas_object_data_get(eoBase, BASE_VIEW_DATA); + ASSERT(pfbBaseView); + pfbBaseView->UpdatedGrid(); } -void CFbVideoLayout::t_OnShow(void) +void CFbVideoLayout::sm_CbUnsetFocus(void* cookie) { - return; + _DBG(); + CFbBaseView *pfbBaseView = NULL; + Evas_Object *eoBase = (Evas_Object*)cookie; + if (eoBase) { + pfbBaseView = (CFbBaseView*)evas_object_data_get(eoBase, BASE_VIEW_DATA); + ASSERT(pfbBaseView); + pfbBaseView->UnsetFocus(); + } } -void CFbVideoLayout::t_OnHide(void) +void CFbVideoLayout::sm_CbLinkApp(void* cookie, int type, int source_type, char *path) { - return; + _DBG(); + CFbBaseView *pfbBaseView = NULL; + Evas_Object *eoBase = (Evas_Object*)cookie; + if (eoBase) + { + pfbBaseView = (CFbBaseView*)evas_object_data_get(eoBase, BASE_VIEW_DATA); + ASSERT(pfbBaseView); + pfbBaseView->CbLinkApp(type, source_type, path); + } } -bool CFbVideoLayout::Create(CLayoutMgr *mgr, void *data) +bool CFbVideoLayout::t_CreateFileGrid(Evas_Object *layout) { + m->pFileGrid = new CFileGrid; + if (!m->pFileGrid) + return false; + + CFileGrid::SCallback cb; + cb.cbUpdateEmptyFocusSequence = sm_CbUpdateEmptyFocusSequence; + cb.cbUpdatedGrid = sm_CbUpdatedGrid; + cb.cbUnsetFocus = sm_CbUnsetFocus; + cb.cbLinkApp = sm_CbLinkApp; + cb.cookie = m->eoBase; + if (!m->pFileGrid->Create(m->eoWin, layout, &cb)) { + _DBG("Fail to create FileGrid"); + delete m->pFileGrid; + m->pFileGrid = NULL; + return false; + } return true; } -void CFbVideoLayout::Destroy(void) +void CFbVideoLayout::t_DestroyFileGrid(void) +{ + if (!m->pFileGrid) + return; + + m->pFileGrid->Destroy(); + delete m->pFileGrid; + m->pFileGrid = NULL; +} + + +void CFbVideoLayout::t_OnShow(void) { - return; + elm_object_part_content_unset(m->eoBase, FBR_PART_CONTENT); + elm_object_part_content_set(m->eoBase, FBR_PART_CONTENT, Layout()); + m->pFileGrid->Update(false); + CBaseLayout::t_OnShow(); } -void CFbVideoLayout::Update(bool flag) +bool CFbVideoLayout::Create(CLayoutMgr *mgr, void *data) { - return; + ASSERT(!m); + ASSERT(mgr); + + Evas_Object* layout = NULL; + + _CREATE_BEGIN{ + _CHECK(m = new SFbVideoLayout) + _CHECK(m->pLayoutMgr = mgr) + _CHECK(m->pViewMgr = CViewMgr::GetInstance()) + _CHECK(m->eoBase = m->pLayoutMgr->Base()) + _CHECK(m->eoWin = m->pViewMgr->Window()) + _CHECK(layout = elm_layout_add(m->eoBase)) + _CHECK(elm_layout_file_set(layout, EDJEFILE, FB_VIDEO_LAYOUT)) + _CHECK(t_CreateFileGrid(layout)) + _COMMAND{ + elm_object_part_content_unset(m->eoBase, FBR_PART_CONTENT); + elm_object_part_content_set(m->eoBase, FBR_PART_CONTENT, layout); + } + _CHECK(CBaseLayout::Create(layout)) + + _WHEN_SUCCESS{} + + _CHECK_FAIL{ CBaseLayout::Destroy(); } + _CHECK_FAIL{ t_DestroyFileGrid(); } + _CHECK_FAIL{ /* elm_layout_file_set */ } + _CHECK_FAIL{ /* elm_layout_add */ } + _CHECK_FAIL{ /* m->pViewMgr->Window()*/ } + _CHECK_FAIL{ /* m->pLayoutMgr->Base() */ } + _CHECK_FAIL{ /* CViewMgr::GetInstace() */ } + _CHECK_FAIL{ /* m->pLayoutMgr = mgr */ } + _CHECK_FAIL{ delete m; m = NULL; } + } _CREATE_END_AND_CATCH{ return false; } + + return true; } -void CFbVideoLayout::SetFocus(Eina_Bool flag) +void CFbVideoLayout::Destroy(void) { - return; + ASSERT(m); + + CBaseLayout::Destroy(); + t_DestroyFileGrid(); + delete m; + m = NULL; } -Evas_Object* CFbVideoLayout::Grid(void) +void CFbVideoLayout::SetFocus(Eina_Bool flag) { - return NULL; + ASSERT(m); + _DBG(); + + m->pFileGrid->SetFocus(flag); } void CFbVideoLayout::Action(void) { - return; + ASSERT(m); + + return m->pFileGrid->Action(); } diff --git a/src/views/BaseView/FbBaseView.cpp b/src/views/BaseView/FbBaseView.cpp index b646fad..256c7f6 100644 --- a/src/views/BaseView/FbBaseView.cpp +++ b/src/views/BaseView/FbBaseView.cpp @@ -65,6 +65,13 @@ enum topbtns { TOPBTN_SORT, }; +enum layoutId { + ALL_LAYOUT, + PHOTO_LAYOUT, + VIDEO_LAYOUT, + MUSIC_LAYOUT +}; + const char *source_arg[] = { "all", "tv", @@ -79,6 +86,21 @@ const char *linked_app[] = { N_(""), }; +const char* _get_layout_id(int curLayoutId){ + switch(curLayoutId) + { + case ALL_LAYOUT: + return FB_ALL_LAYOUT; + case PHOTO_LAYOUT: + return FB_PHOTO_LAYOUT; + case VIDEO_LAYOUT: + return FB_VIDEO_LAYOUT; + case MUSIC_LAYOUT: + return FB_MUSIC_LAYOUT; + } + return FB_ALL_LAYOUT; // default +} + struct SFbBaseView { Evas_Object *eoWin; Evas_Object *eoBase; @@ -92,11 +114,11 @@ struct SFbBaseView { CLayoutMgr *pLayoutMgr; - char* *pCurrentLayoutId; + int curLayoutId; CFbAllLayout *pFbAllLayout; - //CFbPhotoLayout *pFbPhotoLayout; - //CFbMusicLayout *pFbMusicLayout; - //CFbVideoLayout *pFbVideoLayout; + CFbPhotoLayout *pFbPhotoLayout; + CFbVideoLayout *pFbVideoLayout; + CFbMusicLayout *pFbMusicLayout; SFbBaseView() { int a; @@ -126,12 +148,26 @@ struct SFbBaseView { CHandlerBase(SFbBaseView *ins) : IKeyDownListener(this) { m = ins; } virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) { + _DBG("m->curLayoutId = %d",m->curLayoutId); if (!strcmp(ev->keyname, KEY_EXIT)) elm_exit(); else if (!strcmp(ev->keyname, KEY_ENTER) || !strcmp(ev->keyname, KEY_ENTER_REMOTE)) { if (elm_object_focus_get(m->eoSelectedBtnGroup)) { - m->pFbAllLayout->SetFocus(EINA_TRUE); - // TODO: Each layout SetFocus??? + switch(m->curLayoutId) + { + case ALL_LAYOUT: + m->pFbAllLayout->SetFocus(EINA_TRUE); + break; + case PHOTO_LAYOUT: + m->pFbPhotoLayout->SetFocus(EINA_TRUE); + break; + case VIDEO_LAYOUT: + m->pFbVideoLayout->SetFocus(EINA_TRUE); + break; + case MUSIC_LAYOUT: + m->pFbMusicLayout->SetFocus(EINA_TRUE); + break; + } } } } @@ -151,20 +187,12 @@ struct SFbBaseView { switch (instance->Type()) { case CCtxPopup::TOPBTN_SORT: elm_object_text_set(m->eoBtnSort, text); -#if 1 - m->pFbAllLayout->Update(true); -#else - m->pLayoutMgr->Show(Current_layout); -#endif + m->pLayoutMgr->Show(_get_layout_id(m->curLayoutId)); break; case CCtxPopup::TOPBTN_SOURCE: elm_object_text_set(m->eoBtnSource, text); -#if 1 - m->pFbAllLayout->Update(false); -#else - m->pLayoutMgr->Show(Current_layout); -#endif + m->pLayoutMgr->Show(_get_layout_id(m->curLayoutId)); break; default: @@ -176,14 +204,17 @@ struct SFbBaseView { CHandlerButton(SFbBaseView *ins) : IKeyDownListener(this), IMouseMoveListener(this), IMouseClickedListener(this) { m = ins; } virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) { + _DBG("id = %d", id); if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) elm_object_focus_set(m->eoSelectedBtnGroup, EINA_TRUE); } virtual void OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev) { + _DBG("id = %d", id); if (!elm_object_focus_get(obj)) elm_object_focus_set(obj, EINA_TRUE); } virtual void OnMouseClicked(int id, Evas_Object *obj) { + _DBG("id = %d", id); CSourceCtxPopup::SCallback cb; cb.cookie = m; cb.onSelected = sm_CbCtxPopupSelected; @@ -211,10 +242,12 @@ struct SFbBaseView { IMouseClickedListener(this) { m = ins; } virtual void OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev) { + _DBG("id = %d", id); if (!elm_object_focus_get(obj)) elm_object_focus_set(obj, EINA_TRUE); } virtual void OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev) { + _DBG("id = %d", id); if (!strcmp(ev->keyname, KEY_BACK) || !strcmp(ev->keyname, KEY_BACK_REMOTE)) elm_exit(); } @@ -226,36 +259,32 @@ struct SFbBaseView { m->eoSelectedBtnGroup = obj; elm_object_signal_emit(m->eoSelectedBtnGroup, FBR_SIGNAL_GROUP_SELECTED, ""); -#if 1 - m->pFbAllLayout->Update(false); - // TODO: not update, it should be "Show" as each layout -#else switch(id) { case E_GRP_ALL: - m->pLayoutMgr->Show(FB_ALL_LAYOUT); + m->curLayoutId = ALL_LAYOUT; break; case E_GRP_PHOTO: - m->pLayoutMgr->Show(FB_PHOTO_LAYOUT); + m->curLayoutId = PHOTO_LAYOUT; break; case E_GRP_VIDEO: - m->pLayoutMgr->Show(FB_VIDEO_LAYOUT); + m->curLayoutId = VIDEO_LAYOUT; break; case E_GRP_MUSIC: - m->pLayoutMgr->Show(FB_MUSIC_LAYOUT); + m->curLayoutId = MUSIC_LAYOUT; break; default: - _DBG("Fix it: it can not make it , MouseClicked"); + _ERR("Fix it: it can not make it , MouseClicked"); + m->curLayoutId = ALL_LAYOUT; // default break; - } -#endif + _DBG("id = %d, m->curLayoutId = %d", id, m->curLayoutId); + m->pLayoutMgr->Show(_get_layout_id(m->curLayoutId)); } } *pHandlerGroup[TOTAL_GROUP_BTNS]; }; - Evas_Object *_add_button(Evas_Object *box) { Evas_Object *button; @@ -336,6 +365,7 @@ void CFbBaseView::CbLinkApp(int type, int source_type, char *path) void CFbBaseView::UpdatedGrid(void) { +#if 0 // It will be removed at soon. int i; for (i = 0; i < TOTAL_GROUP_BTNS; i++) @@ -351,6 +381,7 @@ void CFbBaseView::UpdatedGrid(void) elm_object_focus_next_object_set(m->eoBtnSource, m->pFbAllLayout->Grid(), ELM_FOCUS_DOWN); +#endif elm_object_part_text_set(m->eoBase, FBR_PART_NO_CONTENT, ""); elm_object_part_text_set(m->eoBase, FBR_PART_NO_CONTENT_SUB, ""); } @@ -452,14 +483,10 @@ void CFbBaseView::t_CreateLeftSession(void) void CFbBaseView::t_CreateFullView(void) { + _DBG(); t_CreateTopSession(); t_CreateLeftSession(); - _DBG("UpdateLayout"); -#if 1 - m->pFbAllLayout->Update(false); -#else - m->pLayoutMgr->Show(Current_layout); -#endif + m->pLayoutMgr->Show(_get_layout_id(m->curLayoutId)); } void CFbBaseView::t_SetSelectedGroupButton(Evas_Object* obj) @@ -491,9 +518,21 @@ void CFbBaseView::t_OnShow(void) void CFbBaseView::t_OnUpdate(void *data) { - // TODO: When does this function is called? If it don't be used, Remove it. - _DBG(); - m->pFbAllLayout->Action(); + switch(m->curLayoutId) + { + case ALL_LAYOUT: + m->pFbAllLayout->Action(); + break; + case PHOTO_LAYOUT: + m->pFbPhotoLayout->Action(); + break; + case VIDEO_LAYOUT: + m->pFbVideoLayout->Action(); + break; + case MUSIC_LAYOUT: + m->pFbMusicLayout->Action(); + break; + } } void CFbBaseView::t_OnHide(void) @@ -541,17 +580,17 @@ bool CFbBaseView::Create(void *data) _CHECK(m->pLayoutMgr = new CLayoutMgr) _CHECK(m->pLayoutMgr->Create(eoBase, NULL)) _CHECK(m->pFbAllLayout = new CFbAllLayout(FB_ALL_LAYOUT)) - //_CHECK(m->pFbPhotoLayout = new CFbPhotoLayout(FB_PHOTO_LAYOUT)) - //_CHECK(m->pFbVideoLayout = new CFbVideoLayout(FB_VIDEO_LAYOUT)) - //_CHECK(m->pFbMusicLayout = new CFbMusicLayout(FB_MUSIC_LAYOUT)) + _CHECK(m->pFbPhotoLayout = new CFbPhotoLayout(FB_PHOTO_LAYOUT)) + _CHECK(m->pFbVideoLayout = new CFbVideoLayout(FB_VIDEO_LAYOUT)) + _CHECK(m->pFbMusicLayout = new CFbMusicLayout(FB_MUSIC_LAYOUT)) _CHECK(m->pFbAllLayout->Create(m->pLayoutMgr, NULL)) - //_CHECK(m->pFbPhotoLayout->Create(m->pLayoutMgr, NULL)) - //_CHECK(m->pFbVideoLayout->Create(m->pLayoutMgr, NULL)) - //_CHECK(m->pFbMusicLayout->Create(m->pLayoutMgr, NULL)) + _CHECK(m->pFbPhotoLayout->Create(m->pLayoutMgr, NULL)) + _CHECK(m->pFbVideoLayout->Create(m->pLayoutMgr, NULL)) + _CHECK(m->pFbMusicLayout->Create(m->pLayoutMgr, NULL)) _CHECK(m->pLayoutMgr->AddLayout(m->pFbAllLayout)) - //_CHECK(m->pLayoutMgr->AddLayout(m->pFbPhotoLayout)) - //_CHECK(m->pLayoutMgr->AddLayout(m->pFbVideoLayout)) - //_CHECK(m->pLayoutMgr->AddLayout(m->pFbMusicLayout)) + _CHECK(m->pLayoutMgr->AddLayout(m->pFbPhotoLayout)) + _CHECK(m->pLayoutMgr->AddLayout(m->pFbVideoLayout)) + _CHECK(m->pLayoutMgr->AddLayout(m->pFbMusicLayout)) _CHECK(CUsbConnectionListener::Create()) _CHECK(CMediaContentDbUpdateListener::Create()) @@ -559,17 +598,17 @@ bool CFbBaseView::Create(void *data) _CHECK_FAIL{ CMediaContentDbUpdateListener::Destroy(); } _CHECK_FAIL{ CUsbConnectionListener::Destroy(); } - //_CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pFbMusicLayout); } - //_CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pFbVideoLayout); } - //_CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pFbPhotoLayout); } + _CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pFbMusicLayout); } + _CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pFbVideoLayout); } + _CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pFbPhotoLayout); } _CHECK_FAIL{ m->pLayoutMgr->RemoveLayout(m->pFbAllLayout); } - //_CHECK_FAIL{ m->pFbMusicLayout->Destroy(); } - //_CHECK_FAIL{ m->pFbVideoLayout->Destroy(); } - //_CHECK_FAIL{ m->pFbPhotoLayout->Destroy(); } + _CHECK_FAIL{ m->pFbMusicLayout->Destroy(); } + _CHECK_FAIL{ m->pFbVideoLayout->Destroy(); } + _CHECK_FAIL{ m->pFbPhotoLayout->Destroy(); } _CHECK_FAIL{ m->pFbAllLayout->Destroy(); } - //_CHECK_FAIL{ delete m->pFbMusicLayout; m->pFbMusicLayout = NULL; } - //_CHECK_FAIL{ delete m->pFbVideoLayout; m->pFbVideoLayout = NULL; } - //_CHECK_FAIL{ delete m->pFbPhotoLayout; m->pFbPhotoLayout = NULL; } + _CHECK_FAIL{ delete m->pFbMusicLayout; m->pFbMusicLayout = NULL; } + _CHECK_FAIL{ delete m->pFbVideoLayout; m->pFbVideoLayout = NULL; } + _CHECK_FAIL{ delete m->pFbPhotoLayout; m->pFbPhotoLayout = NULL; } _CHECK_FAIL{ delete m->pFbAllLayout; m->pFbAllLayout = NULL; } _CHECK_FAIL{ m->pLayoutMgr->Destroy(); } _CHECK_FAIL{ delete m->pLayoutMgr; m->pLayoutMgr = NULL; } @@ -582,7 +621,8 @@ bool CFbBaseView::Create(void *data) // original create grid CInfo::SetSortType(0/*CSort::SORT_NAME_AZ*/); evas_object_data_set(eoBase, BASE_VIEW_DATA, this); - m->pLayoutMgr->Show(FB_ALL_LAYOUT); + m->curLayoutId = ALL_LAYOUT; + _DBG("curLayoutId = %s", _get_layout_id(m->curLayoutId)); t_CreateFullView(); elm_object_focus_allow_set(eoBase, EINA_FALSE); m->pHandlerBase->Connect(eoBase); @@ -598,7 +638,6 @@ void CFbBaseView::Destroy(void) CMediaContentDbUpdateListener::Destroy(); CUsbConnectionListener::Destroy(); -#if 0 m->pLayoutMgr->RemoveLayout(m->pFbMusicLayout); m->pFbMusicLayout->Destroy(); delete m->pFbMusicLayout; @@ -610,7 +649,6 @@ void CFbBaseView::Destroy(void) m->pLayoutMgr->RemoveLayout(m->pFbPhotoLayout); m->pFbPhotoLayout->Destroy(); delete m->pFbPhotoLayout; -#endif m->pLayoutMgr->RemoveLayout(m->pFbAllLayout); m->pFbAllLayout->Destroy(); @@ -668,11 +706,7 @@ void CFbBaseView::OnUpdated(const SEntity *entity) m->pCtxPopup = NULL; } if (CInfo::SourceType() != E_TV) { -#if 1 - m->pFbAllLayout->Update(false); -#else - m->pLayoutMgr->Show(Current_layout); -#endif + m->pLayoutMgr->Show(_get_layout_id(m->curLayoutId)); elm_object_focus_set(t_SelectedGroupButton(), EINA_TRUE); } } diff --git a/src/views/BaseView/FileGrid.cpp b/src/views/BaseView/FileGrid.cpp index f59efad..ed95029 100644 --- a/src/views/BaseView/FileGrid.cpp +++ b/src/views/BaseView/FileGrid.cpp @@ -267,7 +267,7 @@ void CFileGrid::t_Empty(bool sort_flag) m->pGengridItemClass = NULL; } - if (sort_flag == false) { + if (sort_flag == false && m->elFile != NULL) { eina_list_free(m->elFile); m->elFile = NULL; } -- 2.7.4