2 * Copyright (c) 2014 Samsung Electronics Co., Ltd All Rights Reserved
4 * Licensed under the Apache License, Version 2.0 (the License);
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an AS IS BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include <AppCommon.h>
21 #include "song_info.h"
22 #include "album_info.h"
23 #include "folder_info.h"
24 #include "category_info.h"
25 #include "music-controller.h"
26 #include "ExtBaseLayout.h"
28 #include "SourceCtxPopup.h"
29 #include "SortCtxPopup.h"
30 #include "base-view.h"
31 #include "common-ui.h"
32 #include "volume-control.h"
33 #include "song-layout.h"
34 #include "album-layout.h"
35 #include "category-layout.h"
36 #include "folder-layout.h"
37 #include "album-songs-layout.h"
38 #include "playback-view.h"
39 #include "artist-layout.h"
40 #include "genre-layout.h"
41 #include "playlist-layout.h"
42 #include "HandleVolume.h"
44 #define ARRAY_SIZE(array) (sizeof(array) / sizeof(array[0]))
45 #define PLAYSONG_FONT_SIZE 30
46 #define TOTAL_GROUP_BTNS 5
47 #define TOTAL_TOP_BTNS 3
48 #define VOLUME_TIMER_INTERVAL 5 /* seconds */
49 #define MAX_SHOW_TIME 10
50 #define MUSIC_SLIDE_DURATION 15
51 #define MUSIC_WRAP_WIDTH 400
54 const char *g_sourceText[] = {
55 N_("All Source"), // SOURCE_TYPE_ALL
56 N_("TV"), // SOURCE_TYPE_TV
57 N_("USB") // SOURCE_TYPE_USB
60 const char *g_sortText[] = {
61 N_("Title A-Z"), // E_SORT_TITLE_A_Z
62 N_("Title Z-A"), // E_SORT_TITLE_Z_A
63 N_("Artist A-Z"), // E_SORT_ARTIST_A_Z
64 N_("Artist Z-A"), // E_SORT_ARTIST_Z_A
65 N_("Album A-Z"), // E_SORT_ALBUM_A_Z
66 N_("Album Z-A") // E_SORT_ALBUM_Z_A
69 const char *g_sortTextAlbum[] = {
74 const char *g_sortTextArtist[] = {
79 const char *g_sortTextGenre[] = {
84 const char *g_sortTextFolder[] = {
89 const char *g_sortTextPlaylists[] = {
94 const char *g_sourceArg[] = {
95 "all", // SOURCE_TYPE_ALL
96 "tv", // SOURCE_TYPE_TV
97 "usb" // SOURCE_TYPE_USB
103 BASE_VIEW_PLAY_BUTTON,
104 BASE_VIEW_SOURCE_BUTTON,
105 BASE_VIEW_SORT_BUTTON,
107 BASE_VIEW_GROUP_SONG,
108 BASE_VIEW_GROUP_ALBUM,
109 BASE_VIEW_GROUP_ARTIST,
110 BASE_VIEW_GROUP_GENRE,
111 BASE_VIEW_GROUP_FOLDER,
112 BASE_VIEW_GROUP_PLAYLIST,
130 struct SMusicBaseView {
133 Evas_Object *content;
134 Evas_Object *plbackbtn;
135 Evas_Object *plsonglbl;
136 Evas_Object *group_btn[TOTAL_GROUP_BTNS];
138 Evas_Object *sortbtn;
139 CSortCtxPopup *sortCtxPopup;
140 CSourceCtxPopup *srcCtxPopup;
142 Elm_Transit *transit;
143 Evas_Object *c_grpbtn;
144 CMusicController *pController;
149 bool srcBtnFocusedBySecondBtn;
151 CSongLayout *layoutSong;
152 CAlbumLayout *layoutAlbum;
153 CArtistLayout *layoutArtist;
154 CGenreLayout *layoutGenre;
155 CPlaylistLayout *layoutPlaylists;
156 CFolderLayout *layoutFolder;
158 CHandleVolume *pHandleVolume;
160 Ecore_Idler *eiShowLayout;
163 memset(this, 0, sizeof(SMusicBaseView));
164 pHandleVolume = new CHandleVolume;
167 delete pHandleVolume;
175 const char *icon_path;
180 Evas_Object *s_AddButton(Evas_Object *box)
187 button = elm_button_add(box);
191 evas_object_size_hint_weight_set(button,
192 EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
193 evas_object_show(button);
198 void CMusicBaseView::sm_CbHandleEmptyStatus(void *cookie, bool emptyStatus)
200 CMusicBaseView *root = (CMusicBaseView*)cookie;
202 root->m_OnHandleEmptyStatus(emptyStatus);
206 void CMusicBaseView::m_OnHandleEmptyStatus(bool emptyStatus)
209 m_UpdateEmptyFocusSequence();
211 m_UpdateFocusSequence();
215 void CMusicBaseView::m_UpdateFocusSequence(void)
219 for (i = 0; i < TOTAL_GROUP_BTNS; i++)
220 elm_object_focus_next_object_set(m->group_btn[i],
221 m->content, ELM_FOCUS_RIGHT);
223 elm_object_focus_next_object_set(m->group_btn[GROUP_BTN_SONG], m->group_btn[GROUP_BTN_PLAYLIST], ELM_FOCUS_UP);
224 elm_object_focus_next_object_set(m->group_btn[GROUP_BTN_PLAYLIST], m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_DOWN);
226 if (m->c_grpbtn != NULL)
227 elm_object_focus_next_object_set(m->plbackbtn, m->c_grpbtn, ELM_FOCUS_LEFT);
229 elm_object_focus_next_object_set(m->plbackbtn, m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_LEFT);
231 elm_object_focus_next_object_set(m->plbackbtn, m->plbackbtn, ELM_FOCUS_DOWN);
232 elm_object_focus_next_object_set(m->srcbtn, m->srcbtn, ELM_FOCUS_DOWN);
233 elm_object_focus_next_object_set(m->sortbtn, m->sortbtn, ELM_FOCUS_DOWN);
235 elm_object_part_text_set(Base(), MUSIC_PART_NO_CONTENT, MUSIC_STR_EMPTY);
236 elm_object_part_text_set(Base(), MUSIC_PART_NO_CONTENT_SUB, MUSIC_STR_EMPTY);
240 void CMusicBaseView::m_UpdateEmptyFocusSequence(void)
244 for (i = 0; i < TOTAL_GROUP_BTNS; i++)
245 elm_object_focus_next_object_set(m->group_btn[i],
246 m->plbackbtn, ELM_FOCUS_RIGHT);
248 elm_object_focus_next_object_set(m->group_btn[GROUP_BTN_SONG], m->group_btn[GROUP_BTN_PLAYLIST], ELM_FOCUS_UP);
249 elm_object_focus_next_object_set(m->group_btn[GROUP_BTN_PLAYLIST], m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_DOWN);
250 elm_object_focus_next_object_set(m->plbackbtn, m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_LEFT);
251 elm_object_focus_next_object_set(m->plbackbtn, m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_DOWN);
252 elm_object_focus_next_object_set(m->srcbtn, m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_DOWN);
253 elm_object_focus_next_object_set(m->sortbtn, m->group_btn[GROUP_BTN_SONG], ELM_FOCUS_DOWN);
255 elm_object_part_text_set(Base(), MUSIC_PART_NO_CONTENT, _(NO_MUSIC_MESSAGE));
256 elm_object_part_text_set(Base(), MUSIC_PART_NO_CONTENT_SUB, _(NO_MUSIC_MESSAGE_SUB));
260 void CMusicBaseView::m_ShowCurrentLayout(void)
262 const char *layoutId = NULL;
263 Evas_Object *evasLayout = NULL;
265 elm_object_part_content_unset(Base(), MUSIC_PART_CONTENT);
267 if (m->c_grpbtn == m->group_btn[GROUP_BTN_SONG]) {
268 layoutId = MUSIC_SONG_LAYOUT;
269 evasLayout = m->layoutSong->Layout();
271 else if (m->c_grpbtn == m->group_btn[GROUP_BTN_ALBUM]) {
272 layoutId = MUSIC_ALBUM_LAYOUT;
273 evasLayout = m->layoutAlbum->Layout();
275 else if (m->c_grpbtn == m->group_btn[GROUP_BTN_ARTIST]) {
276 layoutId = MUSIC_CATEGORY_ARTIST_LAYOUT;
277 evasLayout = m->layoutArtist->Layout();
279 else if (m->c_grpbtn == m->group_btn[GROUP_BTN_GENRE]) {
280 layoutId = MUSIC_CATEGORY_GENRE_LAYOUT;
281 evasLayout = m->layoutGenre->Layout();
283 else if (m->c_grpbtn == m->group_btn[GROUP_BTN_PLAYLIST]) {
284 layoutId = MUSIC_CATEGORY_PLAYLISTS_LAYOUT;
285 evasLayout = m->layoutPlaylists->Layout();
287 else if (m->c_grpbtn == m->group_btn[GROUP_BTN_FOLDER]) {
288 layoutId = MUSIC_FOLDER_LAYOUT;
289 evasLayout = m->layoutFolder->Layout();
292 CExtBaseLayout *layout = (CExtBaseLayout*)m->lmgr->Layout();
293 if (layout && layout->EmptyStatus() == true) {
294 m_UpdateEmptyFocusSequence();
297 elm_object_part_content_set(Base(), MUSIC_PART_CONTENT, evasLayout);
298 m->lmgr->Show(layoutId);
299 m_UpdateFocusSequence();
304 void CMusicBaseView::m_GotoPlayback(void)
307 memset(&parcel, 0, sizeof(SParcel));
308 parcel.updateType = E_PLAYLIST_UPDATE;
312 if (!CViewMgr::GetInstance()->UpdateView(MUSIC_PLAYBACK_VIEW, &parcel))
313 _ERR("CViewMgr::UpdateView MUSIC_PLAYBACK_VIEW failed ");
315 if (!CViewMgr::GetInstance()->ShowView(MUSIC_PLAYBACK_VIEW))
316 _ERR("CViewMgr::ShowView MUSIC_PLAYBACK_VIEW failed ");
320 void CMusicBaseView::m_CreateCtxPopup(int btnType)
322 const char *layout_id = NULL;
323 CContextPopup::SCallback cb;
324 cb.onSelected = sm_CbCtxPopupBtnSelected;
327 if (btnType == BTN_SOURCE) {
328 CSourceCtxPopup *srcCtxPopup = NULL;
329 m->btntype = btnType;
330 srcCtxPopup = new CSourceCtxPopup;
331 srcCtxPopup->Create(Base(), &cb);
333 m->srcCtxPopup = srcCtxPopup;
335 else if (btnType == BTN_SORT) {
336 CSortCtxPopup *sortCtxPopup = NULL;
337 CSortCtxPopup::ESortBtnType sortBtnType = CSortCtxPopup::TYPE_SONG;
338 m->btntype = btnType;
339 layout_id = m->lmgr->Layout()->LayoutId();
340 sortCtxPopup = new CSortCtxPopup;
342 if (!strcmp(layout_id, MUSIC_SONG_LAYOUT)) {
343 sortBtnType = CSortCtxPopup::TYPE_SONG;
345 else if (!strcmp(layout_id, MUSIC_ALBUM_LAYOUT)) {
346 sortBtnType = CSortCtxPopup::TYPE_ALBUM;
348 else if (!strcmp(layout_id, MUSIC_FOLDER_LAYOUT)) {
349 sortBtnType = CSortCtxPopup::TYPE_FOLDER;
351 else if (!strcmp(layout_id, MUSIC_CATEGORY_PLAYLISTS_LAYOUT)) {
352 sortBtnType = CSortCtxPopup::TYPE_PLAYLIST;
354 else if (!strcmp(layout_id, MUSIC_CATEGORY_ARTIST_LAYOUT)) {
355 sortBtnType = CSortCtxPopup::TYPE_ARTIST;
357 else if (!strcmp(layout_id, MUSIC_CATEGORY_GENRE_LAYOUT)) {
358 sortBtnType = CSortCtxPopup::TYPE_GENRE;
362 sortCtxPopup->Create(Base(), &cb, sortBtnType);
363 m->sortCtxPopup = sortCtxPopup;
366 _ERR("MUST NOT BE HERE!!");
373 void CMusicBaseView::m_DestroyCtxPopup(void)
375 if (m->sortCtxPopup && m->sortCtxPopup->FlagCreate())
376 m->sortCtxPopup->Destroy();
378 delete m->sortCtxPopup;
379 m->sortCtxPopup = NULL;
381 if (m->srcCtxPopup && m->srcCtxPopup->FlagCreate())
382 m->srcCtxPopup->Destroy();
384 delete m->srcCtxPopup;
385 m->srcCtxPopup = NULL;
389 void CMusicBaseView::sm_CbCtxPopupBtnSelected(void* cookie, CContextPopup* instance, const char* text)
391 CMusicBaseView *root = (CMusicBaseView*)cookie;
393 root->m_CbCtxPopupBtnSelected(instance, text);
397 void CMusicBaseView::m_CbCtxPopupBtnSelected(CContextPopup* instance, const char* text)
399 if (m->btntype == BTN_SOURCE) {
400 elm_object_text_set(m->srcbtn, _(text));
401 if (m->c_grpbtn != m->group_btn[GROUP_BTN_PLAYLIST])
402 m_ShowCurrentLayout();
405 elm_object_text_set(m->sortbtn, _(text));
406 m_UpdateCurrentLayout(false);
411 Eina_Bool CMusicBaseView::sm_CbShowLayoutIdler(void *cookie)
413 CMusicBaseView *root = (CMusicBaseView*)cookie;
415 root->m_OnShowLayoutIdler();
417 return ECORE_CALLBACK_CANCEL;
421 void CMusicBaseView::m_OnShowLayoutIdler(void)
423 m->eiShowLayout = NULL;
425 if (elm_object_focus_get(m->c_grpbtn))
426 m_ShowCurrentLayout();
430 Evas_Object *CMusicBaseView::m_CreateLoadingPopup(void)
432 Evas_Object *popup = NULL, *label = NULL, *icon = NULL, *box = NULL;
434 char buf[MAX_LENGTH];
436 scale = elm_config_scale_get();
438 popup = elm_popup_add(Base());
442 elm_popup_orient_set(popup, ELM_POPUP_ORIENT_TOP_RIGHT);
443 elm_popup_timeout_set(popup, MAX_SHOW_TIME);
444 evas_object_show(popup);
446 box = CCommonUI::AddBox(popup);
448 evas_object_del(popup);
452 label = elm_label_add(popup);
454 evas_object_del(popup);
458 elm_object_text_set(label, _(MUSIC_TEXT_LOADING));
460 icon = elm_icon_add(popup);
462 evas_object_del(popup);
466 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR, MUSIC_IMAGE_LOADING);
467 elm_image_file_set(icon, buf, NULL);
468 evas_object_size_hint_min_set(icon, 48 * scale, 48 * scale);
470 elm_box_horizontal_set(box, EINA_TRUE);
471 elm_box_padding_set(box,
472 MUSIC_EDIT_BTNS_PADDING * elm_config_scale_get(), 0);
474 elm_box_pack_end(box, icon);
475 evas_object_show(icon);
477 elm_box_pack_end(box, label);
478 evas_object_show(label);
480 elm_object_content_set(popup, box);
482 m->transit = elm_transit_add();
484 evas_object_del(popup);
488 elm_transit_object_add(m->transit, icon);
489 elm_transit_effect_rotation_add(m->transit, 0, 360);
490 elm_transit_duration_set(m->transit, 1);
491 elm_transit_repeat_times_set(m->transit, MAX_SHOW_TIME);
492 elm_transit_objects_final_state_keep_set(m->transit, EINA_TRUE);
493 elm_transit_go(m->transit);
499 void CMusicBaseView::m_DestroyPopup(void)
505 elm_transit_del(m->transit);
508 evas_object_del(m->popup);
513 void CMusicBaseView::m_UpdatePlaysongLabel(void)
515 CSongInfo *sinfo = NULL;
516 char buf[MAX_LENGTH];
519 state = m->pController->PlayState();
521 if (state != PLAY_STATUS_INITIAL && state != PLAY_STATUS_STOP) {
523 if (!m->pController->GetCurrentSong(&sinfo)) {
524 _ERR(" failed to find song info ");
528 snprintf(buf, sizeof(buf), "%s - %s", sinfo->Name(), sinfo->Artist());
530 CCommonUI::SetObjectText(m->plsonglbl, buf, PLAYSONG_FONT_SIZE,
532 elm_label_slide_go(m->plsonglbl);
535 CCommonUI::SetObjectText(m->plsonglbl, (char *)MUSIC_STR_EMPTY,
536 PLAYSONG_FONT_SIZE, (const char *)FONT_STYLE_REGULAR);
541 void CMusicBaseView::m_AddPlaysongLabel(void)
543 double scale = elm_config_scale_get();
545 m->plsonglbl = elm_label_add(Base());
549 elm_object_style_set(m->plsonglbl, MUSIC_STYLE_PLAYSONG_LBL);
550 elm_label_wrap_width_set(m->plsonglbl, MUSIC_WRAP_WIDTH * scale);
551 elm_label_slide_duration_set(m->plsonglbl, MUSIC_SLIDE_DURATION);
552 elm_label_slide_mode_set(m->plsonglbl, ELM_LABEL_SLIDE_MODE_AUTO);
553 elm_label_slide_go(m->plsonglbl);
554 evas_object_size_hint_weight_set(m->plsonglbl, EVAS_HINT_EXPAND,
556 elm_object_part_content_set(Base(), MUSIC_PART_PLAYSONG_LBL,
558 evas_object_show(m->plsonglbl);
562 void CMusicBaseView::m_CreateTopSection(void)
566 Evas_Object *btn = NULL;
567 SBtnInfo btninfo[TOTAL_TOP_BTNS];
569 btninfo[BTN_PLAY].part = MUSIC_PART_PLAYBACK_BTN;
570 btninfo[BTN_PLAY].style = MUSIC_STYLE_PLAYBACK_BTN;
571 btninfo[BTN_PLAY].type = BASE_VIEW_PLAY_BUTTON;
573 btninfo[BTN_SOURCE].part = MUSIC_PART_SOURCE_HOVERSEL;
574 btninfo[BTN_SOURCE].style = MUSIC_STYLE_SOURCE_BTN;
575 btninfo[BTN_SOURCE].type = BASE_VIEW_SOURCE_BUTTON;
577 btninfo[BTN_SORT].part = MUSIC_PART_SORT_HOVERSEL;
578 btninfo[BTN_SORT].style = MUSIC_STYLE_SORT_BTN;
579 btninfo[BTN_SORT].type = BASE_VIEW_SORT_BUTTON;
581 elm_object_part_text_set(Base(), MUSIC_PART_TITLE,
582 _(MUSIC_TEXT_TITLE));
584 m_AddPlaysongLabel();
586 for (i = 0; i < TOTAL_TOP_BTNS; i++) {
587 btn = s_AddButton(Base());
589 _ERR(" Adding btn failed ");
593 elm_object_style_set(btn, btninfo[i].style);
594 elm_object_part_content_set(Base(), btninfo[i].part, btn);
596 Connect(btn, btninfo[i].type,
597 TYPE_KEY_DOWN | TYPE_KEY_UP | TYPE_MOUSE_MOVE | TYPE_CLICKED);
601 else if (i == BTN_SOURCE)
603 else if (i == BTN_SORT)
607 type = CInfo::SourceType();
608 elm_object_text_set(m->srcbtn, _(g_sourceText[type]));
610 type = CInfo::SortType();
611 elm_object_text_set(m->sortbtn, _(g_sortText[type]));
615 void CMusicBaseView::m_CreateLeftSection(void)
617 Evas_Object *box = NULL, *ic = NULL;
619 char buf[MAX_LENGTH];
620 static struct SBtnInfo btninfo[TOTAL_GROUP_BTNS];
622 btninfo[GROUP_BTN_SONG].txt = MUSIC_TEXT_SONG;
623 btninfo[GROUP_BTN_SONG].icon_path = MUSIC_IMAGE_GRPBTN_SONG;
624 btninfo[GROUP_BTN_SONG].type = BASE_VIEW_GROUP_SONG;
626 btninfo[GROUP_BTN_ALBUM].txt = MUSIC_TEXT_ALBUM;
627 btninfo[GROUP_BTN_ALBUM].icon_path = MUSIC_IMAGE_GRPBTN_ALBUM;
628 btninfo[GROUP_BTN_ALBUM].type = BASE_VIEW_GROUP_ALBUM;
630 btninfo[GROUP_BTN_ARTIST].txt = MUSIC_TEXT_ARTIST;
631 btninfo[GROUP_BTN_ARTIST].icon_path = MUSIC_IMAGE_GRPBTN_ARTIST;
632 btninfo[GROUP_BTN_ARTIST].type = BASE_VIEW_GROUP_ARTIST;
634 btninfo[GROUP_BTN_GENRE].txt = MUSIC_TEXT_GENRE;
635 btninfo[GROUP_BTN_GENRE].icon_path = MUSIC_IMAGE_GRPBTN_GENRE;
636 btninfo[GROUP_BTN_GENRE].type = BASE_VIEW_GROUP_GENRE;
638 btninfo[GROUP_BTN_FOLDER].txt = MUSIC_TEXT_FOLDER;
639 btninfo[GROUP_BTN_FOLDER].icon_path = MUSIC_IMAGE_GRPBTN_FOLDER;
640 btninfo[GROUP_BTN_FOLDER].type = BASE_VIEW_GROUP_FOLDER;
642 box = CCommonUI::AddBox(Base());
646 for (i = 0; i < TOTAL_GROUP_BTNS; i++) {
647 m->group_btn[i] = s_AddButton(box);
648 if (!m->group_btn[i]) {
649 _ERR(" failed to add button to box ");
653 elm_box_pack_end(box, m->group_btn[i]);
654 elm_object_style_set(m->group_btn[i], MUSIC_STYLE_GROUPBTN);
655 elm_object_text_set(m->group_btn[i], _(btninfo[i].txt));
657 Connect(m->group_btn[i], btninfo[i].type,
658 TYPE_KEY_DOWN | TYPE_MOUSE_MOVE | TYPE_CLICKED | TYPE_FOCUSED);
660 ic = elm_image_add(m->group_btn[i]);
662 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
663 btninfo[i].icon_path);
664 elm_image_file_set(ic, buf, NULL);
665 elm_object_part_content_set(m->group_btn[i],
666 MUSIC_PART_ELM_SWALLOWICON, ic);
670 elm_object_part_content_set(Base(), MUSIC_PART_GROUPBTN_BOX, box);
674 void CMusicBaseView::m_CreateFullView(void)
676 m_CreateTopSection();
677 m_CreateLeftSection();
681 void CMusicBaseView::m_SetSourceType(void)
683 if (!m->arglist || !m->arglist->source || !m->pController)
686 if (!strcmp(g_sourceArg[SOURCE_TYPE_USB], m->arglist->source))
687 CInfo::SetSourceType(SOURCE_TYPE_USB);
688 else if (!strcmp(g_sourceArg[SOURCE_TYPE_TV], m->arglist->source))
689 CInfo::SetSourceType(SOURCE_TYPE_TV);
691 CInfo::SetSourceType(SOURCE_TYPE_ALL);
695 void CMusicBaseView::m_UpdateCurrentLayout(bool focusFlag)
697 ((CExtBaseLayout*)m->lmgr->Layout())->Update(focusFlag);
701 char *CMusicBaseView::m_Argument(void *data)
703 SArgList *arglist = (SArgList *)data;
706 if (arglist && arglist->uri)
708 else if (arglist && arglist->album_id)
709 arg = arglist->album_id;
715 bool CMusicBaseView::Create(void *data, Evas_Object *eoBase)
722 _CHECK(m = new SMusicBaseView)
723 _CHECK(m->win = CViewMgr::GetInstance()->Window())
724 _CHECK(m->pController = new CMusicController)
725 _CHECK(m->pController->Create())
726 _CHECK(eoBase = CCommonUI::AddBase(m->win, MUSIC_BASE_VIEW))
727 _CHECK(CBaseView::Create(NULL, eoBase))
728 _CHECK(m->lmgr = new CLayoutMgr)
729 _CHECK(m->lmgr->Create(eoBase, NULL))
730 _CHECK(m->layoutSong = new CSongLayout(MUSIC_SONG_LAYOUT))
731 _CHECK(m->layoutSong->Create(m->lmgr, m_Argument(data)))
732 _CHECK(m->lmgr->AddLayout(m->layoutSong))
733 _CHECK(m->layoutAlbum = new CAlbumLayout(MUSIC_ALBUM_LAYOUT))
734 _CHECK(m->layoutAlbum->Create(m->lmgr, m_Argument(data)))
735 _CHECK(m->lmgr->AddLayout(m->layoutAlbum))
736 _CHECK(m->layoutArtist = new CArtistLayout(MUSIC_CATEGORY_ARTIST_LAYOUT))
737 _CHECK(m->layoutArtist->Create(m->lmgr))
738 _CHECK(m->lmgr->AddLayout(m->layoutArtist))
739 _CHECK(m->layoutGenre = new CGenreLayout(MUSIC_CATEGORY_GENRE_LAYOUT))
740 _CHECK(m->layoutGenre->Create(m->lmgr))
741 _CHECK(m->lmgr->AddLayout(m->layoutGenre))
742 _CHECK(m->layoutPlaylists = new CPlaylistLayout(MUSIC_CATEGORY_PLAYLISTS_LAYOUT))
743 _CHECK(m->layoutPlaylists->Create(m->lmgr))
744 _CHECK(m->lmgr->AddLayout(m->layoutPlaylists))
745 _CHECK(m->layoutFolder = new CFolderLayout(MUSIC_FOLDER_LAYOUT))
746 _CHECK(m->layoutFolder->Create(m->lmgr))
747 _CHECK(m->lmgr->AddLayout(m->layoutFolder))
748 _CHECK(m->pHandleVolume = new CHandleVolume)
749 _CHECK(m->pHandleVolume->Create(eoBase))
750 _CHECK(m->pController->AddListener(this))
753 m->fresh_view = true;
754 m->arglist = (SArgList *)data;
756 m->layoutAlbum->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this);
757 m->layoutArtist->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this);
758 m->layoutGenre->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this);
759 m->layoutPlaylists->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this);
761 elm_object_part_content_unset(eoBase, MUSIC_PART_CONTENT);
763 evas_object_data_set(eoBase, BASE_VIEW_DATA, m);
766 m_UpdateFocusSequence();
768 Connect(eoBase, BASE_VIEW, TYPE_KEY_DOWN | TYPE_KEY_UP);
771 _CHECK_FAIL{ m->pController->RemoveListener(this); }
772 _CHECK_FAIL{ m->pHandleVolume->Destroy(); }
773 _CHECK_FAIL{ delete m->pHandleVolume; }
774 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutFolder); }
775 _CHECK_FAIL{ m->layoutFolder->Destroy(); }
776 _CHECK_FAIL{ delete m->layoutFolder; }
777 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutPlaylists); }
778 _CHECK_FAIL{ m->layoutPlaylists->Destroy(); }
779 _CHECK_FAIL{ delete m->layoutPlaylists; }
780 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutGenre); }
781 _CHECK_FAIL{ m->layoutGenre->Destroy(); }
782 _CHECK_FAIL{ delete m->layoutGenre; }
783 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutArtist); }
784 _CHECK_FAIL{ m->layoutArtist->Destroy(); }
785 _CHECK_FAIL{ delete m->layoutArtist; }
786 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutAlbum); }
787 _CHECK_FAIL{ m->layoutAlbum->Destroy(); }
788 _CHECK_FAIL{ delete m->layoutAlbum; }
789 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutSong); }
790 _CHECK_FAIL{ m->layoutSong->Destroy(); }
791 _CHECK_FAIL{ delete m->layoutSong; }
792 _CHECK_FAIL{ m->lmgr->Destroy(); }
793 _CHECK_FAIL{ delete m->lmgr; }
794 _CHECK_FAIL{ CBaseView::Destroy(); }
795 _CHECK_FAIL{ evas_object_del(eoBase); }
796 _CHECK_FAIL{ m->pController->Destroy(); }
797 _CHECK_FAIL{ delete m->pController; }
798 _CHECK_FAIL{ /* win */ }
799 _CHECK_FAIL{ delete m; m = NULL; }
800 } _CREATE_END_AND_CATCH{ return false; }
806 void CMusicBaseView::Destroy(void)
810 Evas_Object *eoBase = Base();
814 m->pController->RemoveListener(this);
815 m->pHandleVolume->Destroy();
817 m->lmgr->RemoveLayout(m->layoutFolder);
818 m->layoutFolder->Destroy();
819 delete m->layoutFolder;
821 m->lmgr->RemoveLayout(m->layoutArtist);
822 m->layoutArtist->Destroy();
823 delete m->layoutArtist;
825 m->lmgr->RemoveLayout(m->layoutGenre);
826 m->layoutGenre->Destroy();
827 delete m->layoutGenre;
829 m->lmgr->RemoveLayout(m->layoutPlaylists);
830 m->layoutPlaylists->Destroy();
831 delete m->layoutPlaylists;
833 m->lmgr->RemoveLayout(m->layoutAlbum);
834 m->layoutAlbum->Destroy();
835 delete m->layoutAlbum;
837 m->lmgr->RemoveLayout(m->layoutSong);
838 m->layoutSong->Destroy();
839 delete m->layoutSong;
844 CBaseView::Destroy();
845 evas_object_del(eoBase);
847 m->pController->Destroy();
848 delete m->pController;
854 void CMusicBaseView::t_OnShow(void)
858 evas_object_show(Base());
860 if (!m->fresh_view) {
861 elm_object_focus_set(m->plbackbtn, EINA_TRUE);
862 m_UpdatePlaysongLabel();
866 if (m->arglist && m->arglist->album_id)
867 m->c_grpbtn = m->group_btn[GROUP_BTN_ALBUM];
869 m->c_grpbtn = m->group_btn[GROUP_BTN_SONG];
871 elm_object_signal_emit(m->c_grpbtn,
872 MUSIC_SIGNAL_GROUP_SELECTED, MUSIC_BASE_VIEW);
873 elm_object_focus_set(m->c_grpbtn, EINA_TRUE);
874 m_UpdatePlaysongLabel();
876 m_ShowCurrentLayout();
879 m->fresh_view = false;
883 void CMusicBaseView::t_OnUpdate(void *data)
888 m_ShowCurrentLayout();
892 SParcel *parcel = (SParcel *)data;
894 if (parcel->updateType == E_FOCUS_UPDATE) {
895 if (parcel->keyEvent == SKEY_UP) {
896 Evas_Object *focus = NULL;
898 if (!strcmp(parcel->focusedBtn, MUSIC_FIRST_BTN)) {
899 m->srcBtnFocusedBySecondBtn = false;
900 focus = m->plbackbtn;
902 else if (!strcmp(parcel->focusedBtn, MUSIC_SECOND_BTN)) {
903 if (elm_object_disabled_get(m->sortbtn)) {
904 m->srcBtnFocusedBySecondBtn = true;
908 m->srcBtnFocusedBySecondBtn = false;
912 else if (!strcmp(parcel->focusedBtn, MUSIC_THIRD_BTN)) {
913 m->srcBtnFocusedBySecondBtn = false;
917 elm_object_focus_set(focus, EINA_TRUE);
920 elm_object_focus_set(m->c_grpbtn, EINA_TRUE);
922 else if (parcel->updateType == E_LAYOUT_UPDATE) {
923 if (!parcel->layoutId)
926 if (!strcmp(parcel->layoutId, MUSIC_ALBUM_SONGS_LAYOUT) ||
927 !strcmp(parcel->layoutId, MUSIC_CATEGORY_SONGS_LAYOUT) ||
928 !strcmp(parcel->layoutId, MUSIC_CATEGORY_ALBUM_LAYOUT) ||
929 !strcmp(parcel->layoutId, MUSIC_CATEGORY_SELECTLIST_LAYOUT)) {
930 elm_object_disabled_set(m->sortbtn, EINA_TRUE);
931 elm_object_focus_next_object_set(m->plbackbtn, m->srcbtn, ELM_FOCUS_RIGHT);
932 elm_object_focus_next_object_set(m->srcbtn, m->plbackbtn, ELM_FOCUS_LEFT);
935 elm_object_disabled_set(m->sortbtn, EINA_FALSE);
936 elm_object_focus_next_object_set(m->plbackbtn, m->sortbtn, ELM_FOCUS_RIGHT);
937 elm_object_focus_next_object_set(m->sortbtn, m->srcbtn, ELM_FOCUS_RIGHT);
938 elm_object_focus_next_object_set(m->srcbtn, m->sortbtn, ELM_FOCUS_LEFT);
939 elm_object_focus_next_object_set(m->sortbtn, m->plbackbtn, ELM_FOCUS_LEFT);
942 else if (parcel->updateType == E_DEPTH_UPDATE) {
943 if (!parcel->layoutId)
946 if (!strcmp(parcel->layoutId, MUSIC_ALBUM_SONGS_LAYOUT) ||
947 !strcmp(parcel->layoutId, MUSIC_CATEGORY_ARTIST_SONGS_LAYOUT) ||
948 !strcmp(parcel->layoutId, MUSIC_CATEGORY_GENRE_SONGS_LAYOUT) ||
949 !strcmp(parcel->layoutId, MUSIC_CATEGORY_PLAYLISTS_SONGS_LAYOUT)) {
950 m_ShowCurrentLayout();
951 m_UpdateCurrentLayout(true);
957 void CMusicBaseView::t_OnHide(void)
961 evas_object_hide(Base());
965 void CMusicBaseView::OnSKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_SKey_Down *ev)
971 m->pController->Stop();
976 if (elm_object_focus_get(m->c_grpbtn)) {
977 m_UpdateCurrentLayout(true);
982 m->pHandleVolume->Up();
985 case SKEY_VOLUME_DOWN:
986 m->pHandleVolume->Down();
990 m->pHandleVolume->Mute();
998 memset(&parcel, 0, sizeof(SParcel));
999 parcel.updateType = E_KEY_PRESS;
1000 parcel.keyEvent = ev->skey;
1001 CViewMgr::GetInstance()->UpdateView((const char *)MUSIC_PLAYBACK_VIEW, &parcel);
1005 m->eiShowLayout = ecore_idler_add(sm_CbShowLayoutIdler, this);
1013 case BASE_VIEW_PLAY_BUTTON:
1014 case BASE_VIEW_SORT_BUTTON:
1015 case BASE_VIEW_SOURCE_BUTTON:
1018 elm_object_focus_set(m->c_grpbtn, EINA_TRUE);
1022 if (!((CExtBaseLayout *)m->lmgr->Layout())->EmptyStatus()) {
1023 const char *btnText = NULL;
1025 if (id == BASE_VIEW_PLAY_BUTTON)
1026 btnText = MUSIC_FIRST_BTN;
1027 else if (id == BASE_VIEW_SORT_BUTTON)
1028 btnText = MUSIC_SECOND_BTN;
1029 else { //BASE_VIEW_SOURCE_BUTTON
1030 if (m->srcBtnFocusedBySecondBtn)
1031 btnText = MUSIC_SECOND_BTN;
1033 btnText = MUSIC_THIRD_BTN;
1036 CExtBaseLayout *layout = (CExtBaseLayout *)m->lmgr->Layout();
1037 layout->SetFocus(btnText);
1046 case BASE_VIEW_GROUP_SONG:
1047 case BASE_VIEW_GROUP_ALBUM:
1048 case BASE_VIEW_GROUP_ARTIST:
1049 case BASE_VIEW_GROUP_GENRE:
1050 case BASE_VIEW_GROUP_FOLDER:
1051 case BASE_VIEW_GROUP_PLAYLIST:
1054 m->pController->Stop();
1069 void CMusicBaseView::OnSKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_SKey_Up *ev)
1077 memset(&parcel, 0, sizeof(SParcel));
1078 parcel.updateType = E_KEY_RELEASE;
1079 parcel.keyEvent = ev->skey;
1080 CViewMgr::GetInstance()->UpdateView((const char *)MUSIC_PLAYBACK_VIEW, &parcel);
1081 m_UpdatePlaysongLabel();
1095 void CMusicBaseView::OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev)
1098 case BASE_VIEW_PLAY_BUTTON:
1099 case BASE_VIEW_SORT_BUTTON:
1100 case BASE_VIEW_SOURCE_BUTTON:
1101 case BASE_VIEW_GROUP_SONG:
1102 case BASE_VIEW_GROUP_ALBUM:
1103 case BASE_VIEW_GROUP_ARTIST:
1104 case BASE_VIEW_GROUP_GENRE:
1105 case BASE_VIEW_GROUP_FOLDER:
1106 case BASE_VIEW_GROUP_PLAYLIST:
1107 if (!elm_object_focus_get(obj))
1108 elm_object_focus_set(obj, EINA_TRUE);
1117 void CMusicBaseView::OnMouseClicked(int id, Evas_Object *obj)
1120 case BASE_VIEW_PLAY_BUTTON:
1122 Eina_List *list = NULL;
1126 state = m->pController->PlayState();
1128 if (state != PLAY_STATUS_INITIAL) {
1131 if (!CViewMgr::GetInstance()->UpdateView(MUSIC_PLAYBACK_VIEW, NULL))
1132 _ERR("CViewMgr::UpdateView failed");
1134 if (!CViewMgr::GetInstance()->ShowView(MUSIC_PLAYBACK_VIEW))
1135 _ERR("CViewMgr::ShowView failed");
1140 r = m->pController->MediaGetList(LIST_TYPE_SONG, NULL, &list);
1141 if (r == false || eina_list_count(list) == 0) {
1146 m->pController->Stop();
1147 m->pController->UpdatePlaylist(list, ADD_TYPE_FRESH);
1148 eina_list_free(list);
1154 case BASE_VIEW_SOURCE_BUTTON:
1155 m_CreateCtxPopup(BTN_SOURCE);
1158 case BASE_VIEW_SORT_BUTTON:
1159 m_CreateCtxPopup(BTN_SORT);
1162 case BASE_VIEW_GROUP_SONG:
1163 case BASE_VIEW_GROUP_ALBUM:
1164 case BASE_VIEW_GROUP_ARTIST:
1165 case BASE_VIEW_GROUP_GENRE:
1166 case BASE_VIEW_GROUP_FOLDER:
1167 case BASE_VIEW_GROUP_PLAYLIST:
1169 if (m->c_grpbtn == obj)
1172 elm_object_signal_emit(m->c_grpbtn,
1173 MUSIC_SIGNAL_GROUP_UNSELECTED, MUSIC_BASE_VIEW);
1175 elm_object_signal_emit(m->c_grpbtn,
1176 MUSIC_SIGNAL_GROUP_SELECTED, MUSIC_BASE_VIEW);
1178 if (obj == m->group_btn[GROUP_BTN_FOLDER])
1179 elm_object_text_set(m->sortbtn, _(g_sortTextFolder[0]));
1180 else if (obj == m->group_btn[GROUP_BTN_PLAYLIST])
1181 elm_object_text_set(m->sortbtn, _(g_sortTextPlaylists[0]));
1182 else if (obj == m->group_btn[GROUP_BTN_ALBUM])
1183 elm_object_text_set(m->sortbtn, _(g_sortTextAlbum[0]));
1184 else if (obj == m->group_btn[GROUP_BTN_ARTIST])
1185 elm_object_text_set(m->sortbtn, _(g_sortTextArtist[0]));
1186 else if (obj == m->group_btn[GROUP_BTN_GENRE])
1187 elm_object_text_set(m->sortbtn, _(g_sortTextGenre[0]));
1189 elm_object_text_set(m->sortbtn, _(g_sortText[0]));
1191 CInfo::SetSortType(0);
1193 m_ShowCurrentLayout();
1203 void CMusicBaseView::OnComplete(void)
1205 m_UpdatePlaysongLabel();
1209 void CMusicBaseView::OnError(void)
1214 void CMusicBaseView::OnUsbStatusChanged(SUsbStorageStatus status)
1217 case USB_STORAGE_CONNECTED:
1219 m->popup = m_CreateLoadingPopup();
1222 case USB_STORAGE_DISCONNECTED:
1227 ASSERT(!"Invalid Status");
1233 void CMusicBaseView::OnUpdateContent(void)
1238 m_DestroyCtxPopup();
1239 source = CInfo::SourceType();
1240 elm_object_text_set(m->srcbtn, _(g_sourceText[source]));
1242 if (source != SOURCE_TYPE_TV)
1243 m_ShowCurrentLayout();