Fix Bug 89/37489/2
authorKim Tae Soo <taesoo46.kim@samsung.com>
Sat, 28 Mar 2015 14:54:37 +0000 (23:54 +0900)
committerKim Tae Soo <taesoo46.kim@samsung.com>
Sat, 28 Mar 2015 15:31:56 +0000 (00:31 +0900)
: Fix to use IKeyDownListener instead of IFocusedListener to show the first depth of layout when one of group button is focused.
: Using IFocusedListener can make a critical bug because OnFocused function can be  called unintentionally when elm_object_part_content_unset is called.

Change-Id: Ied4f0a9a6d05f67de9058fb27deb9783ec78861f
Signed-off-by: Kim Tae Soo <taesoo46.kim@samsung.com>
include/base-view.h
src/views/album-songs-layout.cpp
src/views/base-view.cpp
src/views/song-layout.cpp

index 39ecb51..3b1482b 100644 (file)
@@ -32,8 +32,7 @@ class CMusicBaseView :
        public CBaseView,
        public IMouseMoveListener,
        public IMouseClickedListener,
-       public IMusicControllerListener,
-       public IFocusedListener {
+       public IMusicControllerListener {
 private:
        struct SMusicBaseView* m;
 
@@ -44,6 +43,9 @@ private:
        static void sm_CbCtxPopupBtnSelected(void* cookie, CCtxPopup* instance, const char* text);
        void m_CbCtxPopupBtnSelected(CCtxPopup* instance, const char* text);
 
+       static Eina_Bool sm_CbShowLayoutIdler(void *cookie);
+       void m_OnShowLayoutIdler(void);
+
 private:
        void m_UpdateFocusSequence(void);
        void m_UpdateEmptyFocusSequence(void);
@@ -78,7 +80,6 @@ public:
                CBaseView(pViewId),
                IMouseMoveListener(this),
                IMouseClickedListener(this),
-               IFocusedListener(this),
                m(0) {}
        virtual ~CMusicBaseView() {}
 
@@ -92,7 +93,6 @@ public:
        virtual void OnKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_Key_Up *ev);
        virtual void OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev);
        virtual void OnMouseClicked(int id, Evas_Object *obj);
-       virtual void OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item);
 
        virtual void OnComplete(void);
        virtual void OnError(void);
index f167d2e..f8efc2a 100644 (file)
@@ -62,6 +62,7 @@ struct SAlbumSongsLayout {
        Evas_Object *base;
        Evas_Object *songlist;
        Evas_Object *addBtns[TOTAL_ADD_BTNS];
+       Evas_Object *albumCover;
        Elm_Object_Item *focused_item;
        
        CMusicController* mhandle;
@@ -337,6 +338,18 @@ void CAlbumSongsLayout::m_EmptySongList(void)
                m->it_infolist = NULL;
        }
 
+       if (m->albumCover)
+               evas_object_del(m->albumCover);
+       m->albumCover = NULL;
+
+       int i;
+
+       for (i = 0; i < TOTAL_ADD_BTNS; i++) {
+               if (m->addBtns[i])
+                       evas_object_del(m->addBtns[i]);
+               m->addBtns[i] = NULL;
+       }
+
        m->total_duration = 0;
 }
 
@@ -397,7 +410,6 @@ Evas_Object *CAlbumSongsLayout::m_AddAlbumCover(void)
 
 void CAlbumSongsLayout::m_CreateTopSection(void)
 {
-       Evas_Object *thumb = NULL;
        int i;
        Evas_Object *btn;
        Evas_Object *img = NULL;
@@ -424,8 +436,8 @@ void CAlbumSongsLayout::m_CreateTopSection(void)
        btninfo[BTN_LAST].icon = MUSIC_IMAGE_ADD_LAST;
        btninfo[BTN_LAST].type = ALBUM_SONGS_LAST_BUTTON;
 
-       thumb = m_AddAlbumCover();
-       if (!thumb)
+       m->albumCover = m_AddAlbumCover();
+       if (!m->albumCover)
                return;
 
        for (i = 0; i < TOTAL_ADD_BTNS; i++) {
@@ -459,18 +471,18 @@ void CAlbumSongsLayout::m_CreateTopSection(void)
 
        path = m->alinfo->ThumbnailPath();
        if (path) {
-               elm_image_file_set(thumb, path, NULL);
-               elm_image_aspect_fixed_set(thumb, EINA_FALSE);
+               elm_image_file_set(m->albumCover, path, NULL);
+               elm_image_aspect_fixed_set(m->albumCover, EINA_FALSE);
        }
        else {
                snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
                        MUSIC_IMAGE_DEFAULT_THUMB_126);
-               elm_image_file_set(thumb, buf, NULL);
-               elm_image_no_scale_set(thumb, EINA_TRUE);
+               elm_image_file_set(m->albumCover, buf, NULL);
+               elm_image_no_scale_set(m->albumCover, EINA_TRUE);
        }
 
        elm_object_part_content_set(layout, MUSIC_PART_ALBUM_THUMB,
-               thumb);
+               m->albumCover);
        elm_object_part_text_set(layout, MUSIC_PART_ALBUM_NAME,
                m->alinfo->Name());
        elm_object_part_text_set(layout, MUSIC_PART_ALBUM_ARTIST,
index 93ff5fb..2ce9eb5 100644 (file)
@@ -169,6 +169,8 @@ struct SMusicBaseView {
 
        CHandleVolume *pHandleVolume;
 
+       Ecore_Idler *eiShowLayout;
+
        SMusicBaseView() {
                memset(this, 0, sizeof(SMusicBaseView));
                pHandleVolume = new CHandleVolume;
@@ -413,6 +415,25 @@ void CMusicBaseView::m_CbCtxPopupBtnSelected(CCtxPopup* instance, const char* te
 }
 
 
+Eina_Bool CMusicBaseView::sm_CbShowLayoutIdler(void *cookie)
+{
+       CMusicBaseView *root = (CMusicBaseView*)cookie;
+       if (root)
+               root->m_OnShowLayoutIdler();
+
+       return ECORE_CALLBACK_CANCEL;
+}
+
+
+void CMusicBaseView::m_OnShowLayoutIdler(void)
+{
+       m->eiShowLayout = NULL;
+
+       if (elm_object_focus_get(m->c_grpbtn))
+               m_ShowCurrentLayout();
+}
+
+
 Evas_Object *CMusicBaseView::m_CreateLoadingPopup(void)
 {
        Evas_Object *popup = NULL, *label = NULL, *icon = NULL;
@@ -993,6 +1014,8 @@ void CMusicBaseView::OnKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_Key
                        parcel.keyEvent = ev->keyname;
                        CViewMgr::GetInstance()->UpdateView((const char *)MUSIC_PLAYBACK_VIEW, &parcel);
                }
+               else if (!strcmp(ev->keyname, KEY_LEFT))
+                       m->eiShowLayout = ecore_idler_add(sm_CbShowLayoutIdler, this);
                break;
 
        case BASE_VIEW_PLAY_BUTTON:
@@ -1131,7 +1154,7 @@ void CMusicBaseView::OnMouseClicked(int id, Evas_Object *obj)
        case BASE_VIEW_GROUP_PLAYLIST:
                {
                        if (m->c_grpbtn == obj)
-                       return;
+                               return;
 
                        elm_object_signal_emit(m->c_grpbtn,
                                MUSIC_SIGNAL_GROUP_UNSELECTED, MUSIC_BASE_VIEW);
@@ -1164,27 +1187,6 @@ void CMusicBaseView::OnMouseClicked(int id, Evas_Object *obj)
 }
 
 
-void CMusicBaseView::OnFocused(int id, Evas_Object *obj, Elm_Object_Item *item)
-{
-       switch (id) {
-       case BASE_VIEW_GROUP_SONG:
-       case BASE_VIEW_GROUP_ALBUM:
-       case BASE_VIEW_GROUP_ARTIST:
-       case BASE_VIEW_GROUP_GENRE:
-       case BASE_VIEW_GROUP_FOLDER:
-       case BASE_VIEW_GROUP_PLAYLIST:
-               if (m->lmgr->Layout()) {
-                       m_ShowCurrentLayout();
-                       m_UpdateCurrentLayout(false);
-               }
-               break;
-
-       default:
-               break;
-       }
-}
-
-
 void CMusicBaseView::OnComplete(void)
 {
        m_UpdatePlaysongLabel();
index 69a92f1..ac82f67 100644 (file)
@@ -382,7 +382,7 @@ void CSongLayout::m_UpdateSongList(bool sort_flag)
        CSongInfo *sinfo;
        void *obj;
        Eina_List *l;
-       struct SSongItemInfo *itinfo;
+       SSongItemInfo *itinfo;
        Elm_Object_Item *item;
 
        /* Remove existing songlist and prepare afresh */