Apply CCtxPopup to CMusicBaseView. 21/35521/4 accepted/tizen/tv/20150217.123549 submit/tizen/20150217.072946
authorKim Tae Soo <taesoo46.kim@samsung.com>
Tue, 17 Feb 2015 05:44:41 +0000 (14:44 +0900)
committerKim Tae Soo <taesoo46.kim@samsung.com>
Tue, 17 Feb 2015 06:55:46 +0000 (15:55 +0900)
Change-Id: Ifaf2c72df977e61f35bfecc317aec6f534fbf833
Signed-off-by: Kim Tae Soo <taesoo46.kim@samsung.com>
17 files changed:
CMakeLists.txt
include/Info.h [new file with mode: 0644]
include/base-view.h
include/define.h
include/music-controller.h
src/playback/music-controller.cpp
src/playback/playback-mgr.cpp
src/views/Info.cpp [new file with mode: 0644]
src/views/SortCtxPopup.cpp [new file with mode: 0644]
src/views/SortCtxPopup.h [new file with mode: 0644]
src/views/SourceCtxPopup.cpp [new file with mode: 0644]
src/views/SourceCtxPopup.h [new file with mode: 0644]
src/views/album-layout.cpp
src/views/base-view.cpp
src/views/category-layout.cpp
src/views/folder-layout.cpp
src/views/song-layout.cpp

index b790a64..dea5239 100644 (file)
@@ -69,6 +69,9 @@ SET(SRCS src/main.cpp
         src/views/HandleVolume.cpp
         src/views/common-ui.cpp
         src/views/ExtBaseLayout.cpp
+        src/views/Info.cpp
+        src/views/SourceCtxPopup.cpp
+        src/views/SortCtxPopup.cpp
         src/playback/playlist-mgr.cpp
         src/playback/music-controller.cpp
         src/playback/playback-mgr.cpp
diff --git a/include/Info.h b/include/Info.h
new file mode 100644 (file)
index 0000000..e289133
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef __INFO_H__
+#define __INFO_H__
+
+
+class CInfo {
+public:
+
+       static void SetSourceType(int source_type);
+       static int  SourceType(void);
+
+       static void SetSortType(int type);
+       static int  SortType(void);
+};
+
+
+#endif /* __INFO_H__ */
\ No newline at end of file
index 52f7985..04873d8 100644 (file)
@@ -18,6 +18,9 @@
 #define __MUSIC_BASE_VIEW_H__
 
 
+#include <CtxPopup.h>
+
+
 struct SArgList {
        char *album_id;
        char *uri;
@@ -37,11 +40,8 @@ private:
        static void sm_CbHandleEmptyStatus(void *cookie, bool emptyStatus);
        void m_OnHandleEmptyStatus(bool emptyStatus);
 
-       static void sm_CbCtxPopupBtnClicked(void *dt, Evas_Object *obj, void *ev);
-       void m_CbCtxPopupBtnClicked(Evas_Object *obj, void *ev);
-
-       static void sm_CbCtxPopupBtnKeyPressed(void *dt, Evas *e, Evas_Object *obj, void *ei);
-       void m_OnCtxPopupBtnKeyPressed(Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev);
+       static void sm_CbCtxPopupBtnSelected(void* cookie, CCtxPopup* instance, const char* text);
+       void m_CbCtxPopupBtnSelected(CCtxPopup* instance, const char* text);
 
 private:
        void m_UpdateFocusSequence(void);
@@ -50,8 +50,6 @@ private:
        void m_ShowCurrentLayout(void);
        void m_GotoPlayback(void);
 
-       static bool sm_FindIndex(const char **arr, int arrsize, const char *text, int *index);
-
        void m_CreateCtxPopup(int btnType);
        void m_DestroyCtxPopup(void);
 
index 32eeb51..e30b75c 100644 (file)
 #define MUSIC_SWALLOW_ICON             "elm.swallow.icon"
 #define MUSIC_PART_POPUP_BUTTON                "button1"
 
+/* CTXPOPUP POSITION */
+#define POSITION_SORT_POPUP_X 1344
+#define POSITION_SORT_POPUP_Y 155
+#define POSITION_SOURCE_POPUP_X 1654
+#define POSITION_SOURCE_POPUP_Y 155
+
 #endif /* __DEFINE_H__ */
index c2a4192..d60f6ea 100644 (file)
@@ -95,11 +95,6 @@ public:
        int RepeatState(void);
        bool SetRepeatState(int state);
 
-       int SourceType(void);
-       int SortType(void);
-
-       bool SetSourceType(int type);
-       bool SetSortType(int type);
        bool SetPosition(int milsec);
        bool GetPosition(int *const milseconds);
 
index f926be7..781da57 100644 (file)
@@ -29,6 +29,7 @@
 #include "mediadata.h"
 #include "common.h"
 #include "bus.h"
+#include "Info.h"
 
 
 struct SMusicController {
@@ -41,8 +42,6 @@ struct SMusicController {
        int playstate;
        int shufflestate;
        int repeatstate;
-       int source_type;
-       int sort_type;
        struct SCbInfo *cbinfo;
 
        SMusicController() {
@@ -215,8 +214,8 @@ SMusicController *CMusicController::t_Create(void)
        mhandle->shufflestate = SHUFFLE_STATUS_OFF;
        mhandle->repeatstate = REPEAT_STATUS_ALL;
        mhandle->initial_index = 0;
-       mhandle->sort_type = E_SORT_TITLE_A_Z;
-       mhandle->source_type = SOURCE_TYPE_ALL;
+       CInfo::SetSortType(E_SORT_TITLE_A_Z);
+       CInfo::SetSourceType(SOURCE_TYPE_ALL);
        mhandle->alinfo = new CAlbumInfo;
 
        if (!mhandle->alinfo->Create()) {
@@ -724,7 +723,7 @@ bool CMusicController::MediaGetList(int EListType, void *info, Eina_List **list)
 
        Eina_List *mlist;
 
-       mlist = m->pMediadata->Medialist(m->source_type, EListType, info);
+       mlist = m->pMediadata->Medialist(CInfo::SourceType(), EListType, info);
        if (!mlist)
                return false;
 
@@ -934,46 +933,6 @@ bool CMusicController::SetRepeatState(int state)
 }
 
 
-int CMusicController::SourceType(void)
-{
-       if (!m)
-               return -1;
-
-       return m->source_type;
-}
-
-
-int CMusicController::SortType(void)
-{
-       if (!m)
-               return -1;
-
-       return m->sort_type;
-}
-
-
-bool CMusicController::SetSourceType(int type)
-{
-       if (!m)
-               return false;
-
-       m->source_type = type;
-
-       return true;
-}
-
-
-bool CMusicController::SetSortType(int type)
-{
-       if (!m)
-               return false;
-
-       m->sort_type = type;
-
-       return true;
-}
-
-
 void CMusicController::OnConnect(void)
 {
        if (!m)
@@ -983,9 +942,9 @@ void CMusicController::OnConnect(void)
        struct SCbInfo *cbinfo;
        void *obj;
 
-       if (SourceType() == SOURCE_TYPE_USB) {
+       if (CInfo::SourceType() == SOURCE_TYPE_USB) {
                if (!FlagConnected())
-                       SetSourceType(SOURCE_TYPE_ALL);
+                       CInfo::SetSourceType(SOURCE_TYPE_ALL);
        }
 
        EINA_LIST_FOREACH(m->elListener, l, obj) {
index 6a41d29..f2e83f6 100644 (file)
@@ -331,11 +331,11 @@ bool CPlayback::SetPosition(int milsec)
        if (!m->player)
                return false;
 
-       r = player_set_play_position(m->player, milsec, false, _on_seek_completion, m);
+       /*r = player_set_play_position(m->player, milsec, false, _on_seek_completion, m);
        if (r != PLAYER_ERROR_NONE) {
                _ERR("Player set position failed");
                return false;
-       }
+       }*/
 
        return true;
 }
@@ -351,11 +351,12 @@ bool CPlayback::GetPosition(int *const milsec)
        if (!m->player)
                return false;
 
-       r = player_get_play_position(m->player, milsec);
+       /*r = player_get_play_position(m->player, milsec);
        if (r != PLAYER_ERROR_NONE) {
                _ERR("Player set position failed");
                return false;
-       }
+       }*/
+       *milsec = 0;
 
        return true;
 }
\ No newline at end of file
diff --git a/src/views/Info.cpp b/src/views/Info.cpp
new file mode 100644 (file)
index 0000000..f87f754
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+* Copyright (c) 2014 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 <Elementary.h>
+#include <Eina.h>
+#include <Ecore.h>
+#include <utilX.h>
+#include "i18n.h"
+#include "define.h"
+#include "common.h"
+#include "ExtNameInfo.h"
+#include "Info.h"
+
+
+struct SInfo {
+       int source_type;
+       int sort_type;
+};
+
+static SInfo g_info;
+
+void CInfo::SetSourceType(int source_type)
+{
+       g_info.source_type = source_type;
+}
+
+int CInfo::SourceType(void)
+{
+       return g_info.source_type;
+}
+
+void CInfo::SetSortType(int type)
+{
+       g_info.sort_type = type;
+}
+
+int CInfo::SortType(void)
+{
+       return g_info.sort_type;
+}
diff --git a/src/views/SortCtxPopup.cpp b/src/views/SortCtxPopup.cpp
new file mode 100644 (file)
index 0000000..ad5aa01
--- /dev/null
@@ -0,0 +1,200 @@
+/*
+* Copyright (c) 2014 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 <Elementary.h>
+#include <Eina.h>
+#include <Ecore.h>
+#include "i18n.h"
+#include "define.h"
+#include <AppCommon.h>
+#include "dbg.h"
+
+#include "Info.h"
+#include "CtxPopup.h"
+#include <app-res-defines.h>
+#include "SortCtxPopup.h"
+
+const char *sortTextSong[] = {
+       N_("Title A-Z"),
+       N_("Title Z-A"),
+       N_("Artist A-Z"),
+       N_("Artist Z-A"),
+       N_("Album A-Z"),
+       N_("Album Z-A")
+};
+
+const char *sortBtnIdsSong[] = {
+       "Title A-Z",
+       "Title Z-A",
+       "Artist A-Z",
+       "Artist Z-A",
+       "Album A-Z",
+       "Album Z-A"
+};
+
+const char *sortTextAlbum[] = {
+       N_("Album A-Z"),
+       N_("Album Z-A")
+};
+
+const char *sortBtnIdsAlbum[] = {
+       "Album A-Z",
+       "Album Z-A"
+};
+
+const char *sortTextArtist[] = {
+       N_("Artist A-Z"),
+       N_("Artist Z-A")
+};
+
+const char *sortBtnIdsArtist[] = {
+       "Artist A-Z",
+       "Artist Z-A",
+};
+
+const char *sortTextGenre[] = {
+       N_("Genre A-Z"),
+       N_("Genre Z-A")
+};
+
+const char *sortBtnIdsGenre[] = {
+       "Genre A-Z",
+       "Genre Z-A",
+};
+
+const char *sortTextFolder[] = {
+       N_("Title A-Z"),
+       N_("Title Z-A")
+};
+
+const char *sortBtnIdsFolder[] = {
+       "Title A-Z",
+       "Title Z-A",
+};
+
+const char *sortTextPlaylists[] = {
+       N_("Playlist A-Z"),
+       N_("Playlist Z-A")
+};
+
+const char *sortBtnIdsPlaylists[] = {
+       "Playlist A-Z",
+       "Playlist Z-A",
+};
+
+
+const char **sortText;
+const char **sortBtnIds;
+static int arraySize = 0;
+
+void CSortCtxPopup::t_OnConfiguration(void)
+{
+       t_SetList(sortText, arraySize, (int)CInfo::SortType(),
+               CCtxPopup::TOPBTN_SORT, sortBtnIds,
+               POSITION_SORT_POPUP_X, POSITION_SORT_POPUP_Y,
+               MUSIC_STYLE_HOVER_CTXPOPUP,
+               MUSIC_STYLE_HOVER_ENTRY, MUSIC_STYLE_HOVER_ENTRY, MUSIC_STYLE_HOVER_ENTRY);
+}
+
+void CSortCtxPopup::t_OnBtnClicked(Evas_Object* obj, void* ev)
+{
+       if (!obj)
+               return;
+
+       int index = -1;
+       const char *id = (const char*)evas_object_data_get(obj, BTN_ID);
+
+       if (!id)
+               return;
+
+       // Find Index
+       int i;
+       for (i = 0; i < arraySize; i++) {
+               if (sortBtnIds[i] && !strcmp(sortBtnIds[i], id)) {
+                       index = i;
+                       break;
+               }
+       }
+
+       if (index == -1 || index == CInfo::SortType())
+               return;
+
+       CInfo::SetSortType(index);
+       CCtxPopup::t_OnBtnClicked(obj, ev);
+
+       Destroy();
+}
+
+
+bool CSortCtxPopup::Create(Evas_Object* base, const SCallback* callback, ESortBtnType type)
+{
+       switch (type) {
+       case TYPE_SONG:
+               sortText = sortTextSong;
+               sortBtnIds = sortBtnIdsSong;
+               arraySize = sizeof(sortTextSong) / sizeof(sortTextSong[0]);
+               break;
+
+       case TYPE_ALBUM:
+               sortText = sortTextAlbum;
+               sortBtnIds = sortBtnIdsAlbum;
+               arraySize = sizeof(sortTextAlbum) / sizeof(sortTextAlbum[0]);
+               break;
+
+       case TYPE_ARTIST:
+               sortText = sortTextArtist;
+               sortBtnIds = sortBtnIdsArtist;
+               arraySize = sizeof(sortTextArtist) / sizeof(sortTextArtist[0]);
+               break;
+
+       case TYPE_GENRE:
+               sortText = sortTextGenre;
+               sortBtnIds = sortBtnIdsGenre;
+               arraySize = sizeof(sortTextGenre) / sizeof(sortTextGenre[0]);
+               break;
+
+       case TYPE_FOLDER:
+               sortText = sortTextFolder;
+               sortBtnIds = sortBtnIdsFolder;
+               arraySize = sizeof(sortTextFolder) / sizeof(sortTextFolder[0]);
+               break;
+
+       case TYPE_PLAYLIST:
+               sortText = sortTextPlaylists;
+               sortBtnIds = sortBtnIdsPlaylists;
+               arraySize = sizeof(sortTextPlaylists) / sizeof(sortTextPlaylists[0]);
+               break;
+
+       default:
+               _ERR("Invalid Type!!");
+               ASSERT(0);
+               break;
+       }
+
+       bool r = CCtxPopup::Create(base, callback);
+       if (r == false) {
+               _ERR("CCtxPopup::Create failed");
+               return false;
+       }
+
+       return true;
+}
+
+
+const char* CSortCtxPopup::SortText(int index)
+{
+       return sortText[index];
+}
diff --git a/src/views/SortCtxPopup.h b/src/views/SortCtxPopup.h
new file mode 100644 (file)
index 0000000..024ef9e
--- /dev/null
@@ -0,0 +1,28 @@
+#ifndef __SORT_CTX_POPUP_H__
+#define __SORT_CTX_POPUP_H__
+
+
+class CSortCtxPopup : public CCtxPopup {
+public:
+
+       enum ESortBtnType {
+               TYPE_SONG,
+               TYPE_ALBUM,
+               TYPE_ARTIST,
+               TYPE_GENRE,
+               TYPE_FOLDER,
+               TYPE_PLAYLIST
+       };
+
+protected:
+
+       virtual void t_OnConfiguration(void);
+       virtual void t_OnBtnClicked(Evas_Object* obj, void* ev);
+
+public:
+       bool Create(Evas_Object* base, const SCallback* callback, ESortBtnType type);
+       static const char* SortText(int index);
+};
+
+
+#endif /* __SORT_CTX_POPUP_H__ */
diff --git a/src/views/SourceCtxPopup.cpp b/src/views/SourceCtxPopup.cpp
new file mode 100644 (file)
index 0000000..5a29ebd
--- /dev/null
@@ -0,0 +1,86 @@
+/*
+* Copyright (c) 2014 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 <Elementary.h>
+#include <Eina.h>
+#include <Ecore.h>
+#include "i18n.h"
+#include "define.h"
+#include "common.h"
+#include "Info.h"
+#include "CtxPopup.h"
+#include <MediaContentDbListener.h>
+#include <UsbConnectionListener.h>
+#include <app-res-defines.h>
+#include "SourceCtxPopup.h"
+
+const char *sourceText[] = {
+       N_("All Source"),
+       N_("TV"),
+       N_("USB"),
+};
+
+const char *srcBtnIds[] = {
+       "ALL",
+       "TV",
+       "USB"
+};
+
+void CSourceCtxPopup::t_OnConfiguration(void)
+{
+       int size = (sizeof(sourceText) / sizeof(sourceText[0]));
+
+       t_SetList(sourceText, size, (int)CInfo::SourceType(),
+               CCtxPopup::TOPBTN_SOURCE, srcBtnIds,
+               POSITION_SOURCE_POPUP_X, POSITION_SOURCE_POPUP_Y,
+               MUSIC_STYLE_HOVER_CTXPOPUP,
+               MUSIC_STYLE_HOVER_ENTRY, MUSIC_STYLE_HOVER_ENTRY, MUSIC_STYLE_HOVER_ENTRY);
+}
+
+
+void CSourceCtxPopup::t_OnBtnClicked(Evas_Object* obj, void* ev)
+{
+       if (!obj)
+               return;
+
+       int index = -1;
+       const char *id = (const char*)evas_object_data_get(obj, BTN_ID);
+
+       if (!id)
+               return;
+
+       // Find Index
+       int i;
+       int arrsize = (sizeof(srcBtnIds) / sizeof(srcBtnIds[0]));
+       for (i = 0; i < arrsize; i++) {
+               if (srcBtnIds[i] && !strcmp(srcBtnIds[i], id)) {
+                       index = i;
+                       break;
+               }
+       }
+       if (index == -1 || index == CInfo::SourceType())
+               return;
+
+       CInfo::SetSourceType(index);
+       CCtxPopup::t_OnBtnClicked(obj, ev);
+
+       Destroy();
+}
+
+const char* CSourceCtxPopup::SourceText(int index)
+{
+       return sourceText[index];
+}
diff --git a/src/views/SourceCtxPopup.h b/src/views/SourceCtxPopup.h
new file mode 100644 (file)
index 0000000..ce90500
--- /dev/null
@@ -0,0 +1,17 @@
+#ifndef __SOURCE_CTX_POPUP_H__
+#define __SOURCE_CTX_POPUP_H__
+
+
+class CSourceCtxPopup : public CCtxPopup {
+protected:
+
+       virtual void t_OnConfiguration(void);
+       virtual void t_OnBtnClicked(Evas_Object* obj, void* ev);
+
+public:
+
+       static const char* SourceText(int index);
+};
+
+
+#endif /* __SOURCE_CTX_POPUP_H__ */
index 1540bc3..b6fff7e 100644 (file)
@@ -37,6 +37,7 @@
 #include "album-layout.h"
 #include "album-songs-layout.h"
 #include "base-view.h"
+#include "Info.h"
 
 #define GENGRID_ITEM_SIZE_W (263+20)
 #define GENGRID_ITEM_SIZE_H (359+20)
@@ -365,7 +366,7 @@ void CAlbumLayout::m_SortAlbumGrid(void)
                SORT_BY_NAME_ZA,
        };
 
-       sortType = m->mhandle->SortType();
+       sortType = CInfo::SortType();
 
        m->alblist = CSort::Sort(m->alblist, sortFuncId[sortType]);
 }
index ba0e528..233636b 100644 (file)
 #include "BaseLayout.h"
 #include "ExtBaseLayout.h"
 #include "ViewMgr.h"
+#include <CtxPopup.h>
+#include "Info.h"
+#include "SourceCtxPopup.h"
+#include "SortCtxPopup.h"
 #include "base-view.h"
 #include "common-ui.h"
 #include "volume-control.h"
@@ -144,7 +148,7 @@ struct SMusicBaseView {
        Evas_Object *group_btn[TOTAL_GROUP_BTNS];
        Evas_Object *srcbtn;
        Evas_Object *sortbtn;
-       Evas_Object *ctxpopup;
+       CCtxPopup *ctxpopup;
        Evas_Object *popup;
        Elm_Transit *transit;
        Evas_Object *c_grpbtn;
@@ -308,137 +312,55 @@ void CMusicBaseView::m_GotoPlayback(void)
 }
 
 
-bool CMusicBaseView::sm_FindIndex(const char **arr, int arrsize, const char *text, int *index)
-{
-       int i;
-
-       if (!arr || !arrsize || !text)
-               return false;
-
-       for (i = 0; i < arrsize; i++) {
-               if (arr[i] && !strcmp(arr[i], text)) {
-                       *index = i;
-                       return true;
-               }
-       }
-
-       return false;
-}
-
-
 void CMusicBaseView::m_CreateCtxPopup(int btnType)
 {
-       Evas_Object *ctxpopup = NULL, *box = NULL, *btn = NULL;
-       Evas_Object *firstbtn = NULL;
-       int i, size, selected_index;
-       const char **arr;
+       CCtxPopup *ctxPopup = NULL;
        const char *layout_id = NULL;
-       const char *part = NULL;
-
-       if (!m->base)
-               return;
-
-       ctxpopup = elm_ctxpopup_add(m->base);
-       if (!ctxpopup)
-               return;
-
-       box = elm_box_add(ctxpopup);
-       if (!box) {
-               evas_object_del(ctxpopup);
-               return;
-       }
-       evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, 0);
-       evas_object_size_hint_align_set(box, EVAS_HINT_FILL, 0);
+       CCtxPopup::SCallback cb;
+       cb.onSelected = sm_CbCtxPopupBtnSelected;
+       cb.cookie = this;
 
        if (btnType == BTN_SOURCE) {
-               arr = g_sourceText;
-               size = ARRAY_SIZE(g_sourceText);
-               selected_index = m->mhandle->SourceType();
+               CSourceCtxPopup *srcCtxPopup = NULL;
                m->btntype = btnType;
-               part = MUSIC_PART_SOURCE_POPUP;
+               srcCtxPopup = new CSourceCtxPopup;
+               srcCtxPopup->Create(m->base, &cb);
+               ctxPopup = srcCtxPopup;
        }
        else if (btnType == BTN_SORT) {
-               arr = g_sortText;
-               size = ARRAY_SIZE(g_sortText);
+               CSortCtxPopup *sortCtxPopup = NULL;
+               CSortCtxPopup::ESortBtnType sortBtnType;
+               m->btntype = btnType;
                layout_id = m->lmgr->Layout()->LayoutId();
+               sortCtxPopup = new CSortCtxPopup;
                if (layout_id) {
                        if (!strcmp(layout_id, MUSIC_ALBUM_LAYOUT)) {
-                               arr = g_sortTextAlbum;
-                               size = ARRAY_SIZE(g_sortTextAlbum);
+                               sortBtnType = CSortCtxPopup::TYPE_ALBUM;
                        }
                        else if (!strcmp(layout_id, MUSIC_FOLDER_LAYOUT)) {
-                               arr = g_sortTextFolder;
-                               size = ARRAY_SIZE(g_sortTextFolder);
+                               sortBtnType = CSortCtxPopup::TYPE_FOLDER;
                        }
                        else if (!strcmp(layout_id, MUSIC_CATEGORY_PLAYLISTS_LAYOUT)) {
-                               arr = g_sortTextPlaylists;
-                               size = ARRAY_SIZE(g_sortTextPlaylists);
+                               sortBtnType = CSortCtxPopup::TYPE_PLAYLIST;
                        }
                        else if (!strcmp(layout_id, MUSIC_CATEGORY_ARTIST_LAYOUT)) {
-                               arr = g_sortTextArtist;
-                               size = ARRAY_SIZE(g_sortTextArtist);
+                               sortBtnType = CSortCtxPopup::TYPE_ARTIST;
                        }
                        else if (!strcmp(layout_id, MUSIC_CATEGORY_GENRE_LAYOUT)) {
-                               arr = g_sortTextGenre;
-                               size = ARRAY_SIZE(g_sortTextGenre);
+                               sortBtnType = CSortCtxPopup::TYPE_GENRE;
                        }
                }
-               part = MUSIC_PART_SORT_POPUP;
-               selected_index = m->mhandle->SortType();
-               m->btntype = btnType;
+
+               sortCtxPopup->Create(m->base, &cb, sortBtnType);
+               ctxPopup = sortCtxPopup;
        }
        else {
-               evas_object_del(ctxpopup);
+               _ERR("MUST NOT BE HERE!!");
+               ASSERT(0);
                return;
        }
 
-       for (i = 0; i < size; i++) {
-               if (btnType == BTN_SOURCE && i == SOURCE_TYPE_USB &&
-                       !m->mhandle->FlagConnected())
-                       continue;
-
-               btn = s_AddButton(box);
-               if (!btn) {
-                       evas_object_del(ctxpopup);
-                       return;
-               }
-               elm_object_style_set(btn, MUSIC_STYLE_HOVER_ENTRY);
-               elm_object_text_set(btn, _(arr[i]));
-               elm_box_pack_end(box, btn);
-
-               if (i == 0)
-                       firstbtn = btn; /* to set focus later */
-
-               if (i == selected_index)
-                       elm_object_signal_emit(btn,
-                       "elm,action,highlight", "elm");
-
-               if (i == size - 1) {
-                       elm_object_signal_emit(btn,
-                               "elm,action,hideline", "elm");
-                       _ERR("hiding last line");
-               }
-
-               evas_object_smart_callback_add(btn, MUSIC_SIGNAL_CLICKED, sm_CbCtxPopupBtnClicked, this);
-               evas_object_event_callback_add(btn, EVAS_CALLBACK_MOUSE_MOVE, _object_mouse_moved, m);
-               evas_object_event_callback_add(btn, EVAS_CALLBACK_KEY_DOWN, sm_CbCtxPopupBtnKeyPressed, this);
-       }
-
-       elm_object_content_set(ctxpopup, box);
-       elm_object_style_set(ctxpopup, MUSIC_STYLE_HOVER_CTXPOPUP);
-       elm_ctxpopup_direction_priority_set(ctxpopup,
-               ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_DOWN, ELM_CTXPOPUP_DIRECTION_DOWN);
-       elm_object_part_content_set(m->base, part, ctxpopup);
-
-       m->ctxpopup = ctxpopup;
-
-       if (firstbtn && btn) {
-               elm_object_focus_set(firstbtn, EINA_TRUE);
-               elm_object_focus_next_object_set(firstbtn,
-                       btn, ELM_FOCUS_UP);
-               elm_object_focus_next_object_set(btn,
-                       firstbtn, ELM_FOCUS_DOWN);
-       }
+       m->ctxpopup = ctxPopup;
 }
 
 
@@ -447,98 +369,36 @@ void CMusicBaseView::m_DestroyCtxPopup(void)
        if (!m->ctxpopup)
                return;
 
-       evas_object_hide(m->ctxpopup);
-       evas_object_del(m->ctxpopup);
+       if (m->ctxpopup->FlagCreate())
+               m->ctxpopup->Destroy();
+
+       delete m->ctxpopup;
        m->ctxpopup = NULL;
 }
 
 
-void CMusicBaseView::sm_CbCtxPopupBtnClicked(void *dt, Evas_Object *obj, void *ev)
+void CMusicBaseView::sm_CbCtxPopupBtnSelected(void* cookie, CCtxPopup* instance, const char* text)
 {
-       CMusicBaseView *root = (CMusicBaseView*)dt;
+       CMusicBaseView *root = (CMusicBaseView*)cookie;
        if (root)
-               root->m_CbCtxPopupBtnClicked(obj, ev);
+               root->m_CbCtxPopupBtnSelected(instance, text);
 }
 
 
-void CMusicBaseView::m_CbCtxPopupBtnClicked(Evas_Object *obj, void *ev)
+void CMusicBaseView::m_CbCtxPopupBtnSelected(CCtxPopup* instance, const char* text)
 {
-       const char *text = NULL;
-       const char *layout_id = NULL;
-       int size = 0;
-       int type = 0;
-
-       text = elm_object_text_get(obj);
-
        if (m->btntype == BTN_SOURCE) {
-               size = ARRAY_SIZE(g_sourceText);
-               sm_FindIndex(g_sourceText, size, text, &type);
-               m_DestroyCtxPopup();
-               if (type == m->mhandle->SourceType())
-                       return;
-
-               m->mhandle->SetSourceType(type);
                elm_object_text_set(m->srcbtn, _(text));
-       }
-       else {
-               layout_id = m->lmgr->Layout()->LayoutId();
-               if (!strcmp(layout_id, MUSIC_FOLDER_LAYOUT)) {
-                       size = ARRAY_SIZE(g_sortTextFolder);
-                       sm_FindIndex(g_sortTextFolder, size, text, &type);
-               }
-               else if (!strcmp(layout_id, MUSIC_ALBUM_LAYOUT)) {
-                       size = ARRAY_SIZE(g_sortTextAlbum);
-                       sm_FindIndex(g_sortTextAlbum, size, text, &type);
-               }
-               else if (!strcmp(layout_id, MUSIC_CATEGORY_PLAYLISTS_LAYOUT)) {
-                       size = ARRAY_SIZE(g_sortTextPlaylists);
-                       sm_FindIndex(g_sortTextPlaylists, size, text, &type);
-               }
-               else if (!strcmp(layout_id, MUSIC_CATEGORY_ARTIST_LAYOUT)) {
-                       size = ARRAY_SIZE(g_sortTextArtist);
-                       sm_FindIndex(g_sortTextArtist, size, text, &type);
-               }
-               else if (!strcmp(layout_id, MUSIC_CATEGORY_GENRE_LAYOUT)) {
-                       size = ARRAY_SIZE(g_sortTextGenre);
-                       sm_FindIndex(g_sortTextGenre, size, text, &type);
-               }
-               else {
-                       size = ARRAY_SIZE(g_sortText);
-                       sm_FindIndex(g_sortText, size, text, &type);
-               }
-               m_DestroyCtxPopup();
-               if (type == m->mhandle->SortType())
-                       return;
-
-               m->mhandle->SetSortType(type);
-               elm_object_text_set(m->sortbtn, _(text));
-       }
-
-       if (m->btntype == BTN_SOURCE) {
                if (m->c_grpbtn != m->group_btn[GROUP_BTN_PLAYLIST])
                        m_ShowCurrentLayout();
        }
        else {
+               elm_object_text_set(m->sortbtn, _(text));
                m_UpdateCurrentLayout(false);
        }
 }
 
 
-void CMusicBaseView::sm_CbCtxPopupBtnKeyPressed(void *dt, Evas *e, Evas_Object *obj, void *ei)
-{
-       CMusicBaseView *root = (CMusicBaseView*)dt;
-       if (root)
-               root->m_OnCtxPopupBtnKeyPressed(e, obj, (Evas_Event_Key_Down*)ei);
-}
-
-
-void CMusicBaseView::m_OnCtxPopupBtnKeyPressed(Evas *e, Evas_Object *obj, Evas_Event_Key_Down *ev)
-{
-       if (strcmp(ev->keyname, KEY_BACK) == 0)
-               m_DestroyCtxPopup();
-}
-
-
 Evas_Object *CMusicBaseView::m_CreateLoadingPopup(void)
 {
        Evas_Object *popup = NULL, *label = NULL, *icon = NULL;
@@ -702,10 +562,10 @@ void CMusicBaseView::m_CreateTopSection(void)
                        m->sortbtn = btn;
        }
 
-       type = m->mhandle->SourceType();
+       type = CInfo::SourceType();
        elm_object_text_set(m->srcbtn, _(g_sourceText[type]));
 
-       type = m->mhandle->SortType();
+       type = CInfo::SortType();
        elm_object_text_set(m->sortbtn, _(g_sortText[type]));
 }
 
@@ -785,11 +645,11 @@ void CMusicBaseView::m_SetSourceType(void)
                return;
 
        if (!strcmp(g_sourceArg[SOURCE_TYPE_USB], m->arglist->source))
-               m->mhandle->SetSourceType(SOURCE_TYPE_USB);
+               CInfo::SetSourceType(SOURCE_TYPE_USB);
        else if (!strcmp(g_sourceArg[SOURCE_TYPE_TV], m->arglist->source))
-               m->mhandle->SetSourceType(SOURCE_TYPE_TV);
+               CInfo::SetSourceType(SOURCE_TYPE_TV);
        else
-               m->mhandle->SetSourceType(SOURCE_TYPE_ALL);
+               CInfo::SetSourceType(SOURCE_TYPE_ALL);
 }
 
 
@@ -1216,7 +1076,7 @@ void CMusicBaseView::OnMouseClicked(int id, Evas_Object *obj)
                        else
                                elm_object_text_set(m->sortbtn, _(g_sortText[0]));
 
-                       m->mhandle->SetSortType(0);
+                       CInfo::SetSortType(0);
 
                        m_ShowCurrentLayout();
                }
@@ -1251,7 +1111,7 @@ void CMusicBaseView::t_OnUpdateContent(void)
 
        m_DestroyPopup();
        m_DestroyCtxPopup();
-       source = m->mhandle->SourceType();
+       source = CInfo::SourceType();
        elm_object_text_set(m->srcbtn, _(g_sourceText[source]));
 
        if (source != SOURCE_TYPE_TV)
index 88c1585..9ecf1c9 100644 (file)
@@ -38,6 +38,7 @@
 #include "ViewMgr.h"
 #include "category-layout.h"
 #include "base-view.h"
+#include "Info.h"
 
 #define TOTAL_ADD_BTNS 3
 #define TOTAL_SELECT_BTNS 3
@@ -1360,7 +1361,8 @@ void CCategoryLayout::m_SortCatgrid(void)
 
        int sortType;
 
-       sortType = m->pMusicController->SortType();
+       sortType = CInfo::SortType();
+
        m->catlist = CSort::Sort(m->catlist, sortFuncType[sortType]);
 }
 
index 13889df..8249f74 100644 (file)
@@ -37,6 +37,7 @@
 #include "ViewMgr.h"
 #include "folder-layout.h"
 #include "base-view.h"
+#include "Info.h"
 
 #define TOTAL_ADD_BTNS 3
 #define GENGRID_ITEM_SIZE_W (263+20)
@@ -494,7 +495,8 @@ void CFolderLayout::m_SortFolderGrid(void)
        if (!m->flist)
                return;
 
-       sortType = m->mhandle->SortType();
+       sortType = CInfo::SortType();
+       
        m->flist = CSort::Sort(m->flist, sortFuncId[sortType]);
 }
 
@@ -643,7 +645,7 @@ void CFolderLayout::m_UpdateFolderGrid(bool sort_flag)
                        itinfo->item = item;
                        m->it_infolist = eina_list_append(m->it_infolist,
                                itinfo);
-                       source_type = m->mhandle->SourceType();
+                       source_type = CInfo::SourceType();
                        elm_object_part_text_set(Layout(),
                                MUSIC_PART_FOLDER_NAME,
                                _(g_sourceTexts[source_type]));
index bacbe0c..f2a10c2 100644 (file)
@@ -35,6 +35,7 @@
 #include "ViewMgr.h"
 #include "song-layout.h"
 #include "base-view.h"
+#include "Info.h"
 
 
 enum EObjectType {
@@ -392,7 +393,7 @@ void CSongLayout::m_SortSongList(void)
                SORT_BY_ALBUM_ZA
        };
 
-       sortType = m->mhandle->SortType();
+       sortType = CInfo::SortType();
 
        m->slist = CSort::Sort(m->slist, sortFuncId[sortType]);
 }