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 6
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(m->base, MUSIC_PART_NO_CONTENT, MUSIC_STR_EMPTY);
236 elm_object_part_text_set(m->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(m->base, MUSIC_PART_NO_CONTENT, _(NO_MUSIC_MESSAGE));
256 elm_object_part_text_set(m->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(m->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(m->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(m->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(m->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(m->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(m->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(m->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(m->base, MUSIC_PART_TITLE,
582 _(MUSIC_TEXT_TITLE));
584 m_AddPlaysongLabel();
586 for (i = 0; i < TOTAL_TOP_BTNS; i++) {
587 btn = s_AddButton(m->base);
589 _ERR(" Adding btn failed ");
593 elm_object_style_set(btn, btninfo[i].style);
594 elm_object_part_content_set(m->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 btninfo[GROUP_BTN_PLAYLIST].txt = MUSIC_TEXT_PLAYLIST;
643 btninfo[GROUP_BTN_PLAYLIST].icon_path = MUSIC_IMAGE_GRPBTN_PLAYLISTS;
644 btninfo[GROUP_BTN_PLAYLIST].type = BASE_VIEW_GROUP_PLAYLIST;
646 box = CCommonUI::AddBox(m->base);
650 for (i = 0; i < TOTAL_GROUP_BTNS; i++) {
651 m->group_btn[i] = s_AddButton(box);
652 if (!m->group_btn[i]) {
653 _ERR(" failed to add button to box ");
657 elm_box_pack_end(box, m->group_btn[i]);
658 elm_object_style_set(m->group_btn[i], MUSIC_STYLE_GROUPBTN);
659 elm_object_text_set(m->group_btn[i], _(btninfo[i].txt));
661 Connect(m->group_btn[i], btninfo[i].type,
662 TYPE_KEY_DOWN | TYPE_MOUSE_MOVE | TYPE_CLICKED | TYPE_FOCUSED);
664 ic = elm_image_add(m->group_btn[i]);
666 snprintf(buf, sizeof(buf), "%s/%s", IMAGEDIR,
667 btninfo[i].icon_path);
668 elm_image_file_set(ic, buf, NULL);
669 elm_object_part_content_set(m->group_btn[i],
670 MUSIC_PART_ELM_SWALLOWICON, ic);
674 elm_object_part_content_set(m->base, MUSIC_PART_GROUPBTN_BOX, box);
678 void CMusicBaseView::m_CreateFullView(void)
680 m_CreateTopSection();
681 m_CreateLeftSection();
685 void CMusicBaseView::m_SetSourceType(void)
687 if (!m->arglist || !m->arglist->source || !m->pController)
690 if (!strcmp(g_sourceArg[SOURCE_TYPE_USB], m->arglist->source))
691 CInfo::SetSourceType(SOURCE_TYPE_USB);
692 else if (!strcmp(g_sourceArg[SOURCE_TYPE_TV], m->arglist->source))
693 CInfo::SetSourceType(SOURCE_TYPE_TV);
695 CInfo::SetSourceType(SOURCE_TYPE_ALL);
699 void CMusicBaseView::m_UpdateCurrentLayout(bool focusFlag)
701 ((CExtBaseLayout*)m->lmgr->Layout())->Update(focusFlag);
705 char *CMusicBaseView::m_Argument(void *data)
707 SArgList *arglist = (SArgList *)data;
710 if (arglist && arglist->uri)
712 else if (arglist && arglist->album_id)
713 arg = arglist->album_id;
719 bool CMusicBaseView::Create(void *data)
724 _CHECK(m = new SMusicBaseView)
725 _CHECK(m->win = CViewMgr::GetInstance()->Window())
726 _CHECK(m->pController = new CMusicController)
727 _CHECK(m->pController->Create())
728 _CHECK(m->base = CCommonUI::AddBase(m->win, MUSIC_BASE_VIEW))
729 _CHECK(m->lmgr = new CLayoutMgr)
730 _CHECK(m->lmgr->Create(m->base, NULL))
731 _CHECK(CBaseView::Create(NULL))
732 _CHECK(m->layoutSong = new CSongLayout(MUSIC_SONG_LAYOUT))
733 _CHECK(m->layoutSong->Create(m->lmgr, m_Argument(data)))
734 _CHECK(m->lmgr->AddLayout(m->layoutSong))
735 _CHECK(m->layoutAlbum = new CAlbumLayout(MUSIC_ALBUM_LAYOUT))
736 _CHECK(m->layoutAlbum->Create(m->lmgr, m_Argument(data)))
737 _CHECK(m->lmgr->AddLayout(m->layoutAlbum))
738 _CHECK(m->layoutArtist = new CArtistLayout(MUSIC_CATEGORY_ARTIST_LAYOUT))
739 _CHECK(m->layoutArtist->Create(m->lmgr))
740 _CHECK(m->lmgr->AddLayout(m->layoutArtist))
741 _CHECK(m->layoutGenre = new CGenreLayout(MUSIC_CATEGORY_GENRE_LAYOUT))
742 _CHECK(m->layoutGenre->Create(m->lmgr))
743 _CHECK(m->lmgr->AddLayout(m->layoutGenre))
744 _CHECK(m->layoutPlaylists = new CPlaylistLayout(MUSIC_CATEGORY_PLAYLISTS_LAYOUT))
745 _CHECK(m->layoutPlaylists->Create(m->lmgr))
746 _CHECK(m->lmgr->AddLayout(m->layoutPlaylists))
747 _CHECK(m->layoutFolder = new CFolderLayout(MUSIC_FOLDER_LAYOUT))
748 _CHECK(m->layoutFolder->Create(m->lmgr))
749 _CHECK(m->lmgr->AddLayout(m->layoutFolder))
750 _CHECK(m->pHandleVolume = new CHandleVolume)
751 _CHECK(m->pHandleVolume->Create(m->base))
752 _CHECK(m->pController->AddListener(this))
755 m->fresh_view = true;
756 m->arglist = (SArgList *)data;
758 m->layoutAlbum->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this);
759 m->layoutArtist->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this);
760 m->layoutGenre->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this);
761 m->layoutPlaylists->SetEmptyStatusHandleCallback(sm_CbHandleEmptyStatus, this);
763 elm_object_part_content_unset(m->base, MUSIC_PART_CONTENT);
765 evas_object_data_set(m->base, BASE_VIEW_DATA, m);
768 m_UpdateFocusSequence();
770 Connect(m->base, BASE_VIEW, TYPE_KEY_DOWN | TYPE_KEY_UP);
773 _CHECK_FAIL{ m->pController->RemoveListener(this); }
774 _CHECK_FAIL{ m->pHandleVolume->Destroy(); }
775 _CHECK_FAIL{ delete m->pHandleVolume; }
776 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutFolder); }
777 _CHECK_FAIL{ m->layoutFolder->Destroy(); }
778 _CHECK_FAIL{ delete m->layoutFolder; }
779 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutPlaylists); }
780 _CHECK_FAIL{ m->layoutPlaylists->Destroy(); }
781 _CHECK_FAIL{ delete m->layoutPlaylists; }
782 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutGenre); }
783 _CHECK_FAIL{ m->layoutGenre->Destroy(); }
784 _CHECK_FAIL{ delete m->layoutGenre; }
785 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutArtist); }
786 _CHECK_FAIL{ m->layoutArtist->Destroy(); }
787 _CHECK_FAIL{ delete m->layoutArtist; }
788 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutAlbum); }
789 _CHECK_FAIL{ m->layoutAlbum->Destroy(); }
790 _CHECK_FAIL{ delete m->layoutAlbum; }
791 _CHECK_FAIL{ m->lmgr->RemoveLayout(m->layoutSong); }
792 _CHECK_FAIL{ m->layoutSong->Destroy(); }
793 _CHECK_FAIL{ delete m->layoutSong; }
794 _CHECK_FAIL{ CBaseView::Destroy(); }
795 _CHECK_FAIL{ m->lmgr->Destroy(); }
796 _CHECK_FAIL{ delete m->lmgr; }
797 _CHECK_FAIL{ evas_object_del(m->base); }
798 _CHECK_FAIL{ m->pController->Destroy(); }
799 _CHECK_FAIL{ delete m->pController; }
800 _CHECK_FAIL{ /* win */ }
801 _CHECK_FAIL{ delete m; m = NULL; }
802 } _CREATE_END_AND_CATCH{ return false; }
808 void CMusicBaseView::Destroy(void)
812 m->pController->RemoveListener(this);
813 m->pHandleVolume->Destroy();
815 m->lmgr->RemoveLayout(m->layoutFolder);
816 m->layoutFolder->Destroy();
817 delete m->layoutFolder;
819 m->lmgr->RemoveLayout(m->layoutArtist);
820 m->layoutArtist->Destroy();
821 delete m->layoutArtist;
823 m->lmgr->RemoveLayout(m->layoutGenre);
824 m->layoutGenre->Destroy();
825 delete m->layoutGenre;
827 m->lmgr->RemoveLayout(m->layoutPlaylists);
828 m->layoutPlaylists->Destroy();
829 delete m->layoutPlaylists;
831 m->lmgr->RemoveLayout(m->layoutAlbum);
832 m->layoutAlbum->Destroy();
833 delete m->layoutAlbum;
835 m->lmgr->RemoveLayout(m->layoutSong);
836 m->layoutSong->Destroy();
837 delete m->layoutSong;
839 CBaseView::Destroy();
842 evas_object_del(m->base);
844 m->pController->Destroy();
845 delete m->pController;
851 Evas_Object* CMusicBaseView::Base(void)
859 void CMusicBaseView::t_OnShow(void)
863 evas_object_show(m->base);
865 if (!m->fresh_view) {
866 elm_object_focus_set(m->plbackbtn, EINA_TRUE);
867 m_UpdatePlaysongLabel();
871 if (m->arglist && m->arglist->album_id)
872 m->c_grpbtn = m->group_btn[GROUP_BTN_ALBUM];
874 m->c_grpbtn = m->group_btn[GROUP_BTN_SONG];
876 elm_object_signal_emit(m->c_grpbtn,
877 MUSIC_SIGNAL_GROUP_SELECTED, MUSIC_BASE_VIEW);
878 elm_object_focus_set(m->c_grpbtn, EINA_TRUE);
879 m_UpdatePlaysongLabel();
881 m_ShowCurrentLayout();
884 m->fresh_view = false;
888 void CMusicBaseView::t_OnUpdate(void *data)
893 m_ShowCurrentLayout();
897 SParcel *parcel = (SParcel *)data;
899 if (parcel->updateType == E_FOCUS_UPDATE) {
900 if (parcel->keyEvent == SKEY_UP) {
901 Evas_Object *focus = NULL;
903 if (!strcmp(parcel->focusedBtn, MUSIC_FIRST_BTN)) {
904 m->srcBtnFocusedBySecondBtn = false;
905 focus = m->plbackbtn;
907 else if (!strcmp(parcel->focusedBtn, MUSIC_SECOND_BTN)) {
908 if (elm_object_disabled_get(m->sortbtn)) {
909 m->srcBtnFocusedBySecondBtn = true;
913 m->srcBtnFocusedBySecondBtn = false;
917 else if (!strcmp(parcel->focusedBtn, MUSIC_THIRD_BTN)) {
918 m->srcBtnFocusedBySecondBtn = false;
922 elm_object_focus_set(focus, EINA_TRUE);
925 elm_object_focus_set(m->c_grpbtn, EINA_TRUE);
927 else if (parcel->updateType == E_LAYOUT_UPDATE) {
928 if (!parcel->layoutId)
931 if (!strcmp(parcel->layoutId, MUSIC_ALBUM_SONGS_LAYOUT) ||
932 !strcmp(parcel->layoutId, MUSIC_CATEGORY_SONGS_LAYOUT) ||
933 !strcmp(parcel->layoutId, MUSIC_CATEGORY_ALBUM_LAYOUT) ||
934 !strcmp(parcel->layoutId, MUSIC_CATEGORY_SELECTLIST_LAYOUT)) {
935 elm_object_disabled_set(m->sortbtn, EINA_TRUE);
936 elm_object_focus_next_object_set(m->plbackbtn, m->srcbtn, ELM_FOCUS_RIGHT);
937 elm_object_focus_next_object_set(m->srcbtn, m->plbackbtn, ELM_FOCUS_LEFT);
940 elm_object_disabled_set(m->sortbtn, EINA_FALSE);
941 elm_object_focus_next_object_set(m->plbackbtn, m->sortbtn, ELM_FOCUS_RIGHT);
942 elm_object_focus_next_object_set(m->sortbtn, m->srcbtn, ELM_FOCUS_RIGHT);
943 elm_object_focus_next_object_set(m->srcbtn, m->sortbtn, ELM_FOCUS_LEFT);
944 elm_object_focus_next_object_set(m->sortbtn, m->plbackbtn, ELM_FOCUS_LEFT);
947 else if (parcel->updateType == E_DEPTH_UPDATE) {
948 if (!parcel->layoutId)
951 if (!strcmp(parcel->layoutId, MUSIC_ALBUM_SONGS_LAYOUT) ||
952 !strcmp(parcel->layoutId, MUSIC_CATEGORY_ARTIST_SONGS_LAYOUT) ||
953 !strcmp(parcel->layoutId, MUSIC_CATEGORY_GENRE_SONGS_LAYOUT) ||
954 !strcmp(parcel->layoutId, MUSIC_CATEGORY_PLAYLISTS_SONGS_LAYOUT)) {
955 m_ShowCurrentLayout();
956 m_UpdateCurrentLayout(true);
962 void CMusicBaseView::t_OnHide(void)
966 evas_object_hide(m->base);
970 void CMusicBaseView::OnSKeyDown(int id, Evas *e, Evas_Object *obj, Evas_Event_SKey_Down *ev)
976 m->pController->Stop();
981 if (elm_object_focus_get(m->c_grpbtn)) {
982 m_UpdateCurrentLayout(true);
987 m->pHandleVolume->Up();
990 case SKEY_VOLUME_DOWN:
991 m->pHandleVolume->Down();
995 m->pHandleVolume->Mute();
1003 memset(&parcel, 0, sizeof(SParcel));
1004 parcel.updateType = E_KEY_PRESS;
1005 parcel.keyEvent = ev->skey;
1006 CViewMgr::GetInstance()->UpdateView((const char *)MUSIC_PLAYBACK_VIEW, &parcel);
1010 m->eiShowLayout = ecore_idler_add(sm_CbShowLayoutIdler, this);
1018 case BASE_VIEW_PLAY_BUTTON:
1019 case BASE_VIEW_SORT_BUTTON:
1020 case BASE_VIEW_SOURCE_BUTTON:
1023 elm_object_focus_set(m->c_grpbtn, EINA_TRUE);
1027 if (!((CExtBaseLayout *)m->lmgr->Layout())->EmptyStatus()) {
1028 const char *btnText = NULL;
1030 if (id == BASE_VIEW_PLAY_BUTTON)
1031 btnText = MUSIC_FIRST_BTN;
1032 else if (id == BASE_VIEW_SORT_BUTTON)
1033 btnText = MUSIC_SECOND_BTN;
1034 else { //BASE_VIEW_SOURCE_BUTTON
1035 if (m->srcBtnFocusedBySecondBtn)
1036 btnText = MUSIC_SECOND_BTN;
1038 btnText = MUSIC_THIRD_BTN;
1041 CExtBaseLayout *layout = (CExtBaseLayout *)m->lmgr->Layout();
1042 layout->SetFocus(btnText);
1051 case BASE_VIEW_GROUP_SONG:
1052 case BASE_VIEW_GROUP_ALBUM:
1053 case BASE_VIEW_GROUP_ARTIST:
1054 case BASE_VIEW_GROUP_GENRE:
1055 case BASE_VIEW_GROUP_FOLDER:
1056 case BASE_VIEW_GROUP_PLAYLIST:
1059 m->pController->Stop();
1074 void CMusicBaseView::OnSKeyUp(int id, Evas *e, Evas_Object *obj, Evas_Event_SKey_Up *ev)
1082 memset(&parcel, 0, sizeof(SParcel));
1083 parcel.updateType = E_KEY_RELEASE;
1084 parcel.keyEvent = ev->skey;
1085 CViewMgr::GetInstance()->UpdateView((const char *)MUSIC_PLAYBACK_VIEW, &parcel);
1086 m_UpdatePlaysongLabel();
1100 void CMusicBaseView::OnMouseMove(int id, Evas *e, Evas_Object *obj, Evas_Event_Mouse_Move *ev)
1103 case BASE_VIEW_PLAY_BUTTON:
1104 case BASE_VIEW_SORT_BUTTON:
1105 case BASE_VIEW_SOURCE_BUTTON:
1106 case BASE_VIEW_GROUP_SONG:
1107 case BASE_VIEW_GROUP_ALBUM:
1108 case BASE_VIEW_GROUP_ARTIST:
1109 case BASE_VIEW_GROUP_GENRE:
1110 case BASE_VIEW_GROUP_FOLDER:
1111 case BASE_VIEW_GROUP_PLAYLIST:
1112 if (!elm_object_focus_get(obj))
1113 elm_object_focus_set(obj, EINA_TRUE);
1122 void CMusicBaseView::OnMouseClicked(int id, Evas_Object *obj)
1125 case BASE_VIEW_PLAY_BUTTON:
1127 Eina_List *list = NULL;
1131 state = m->pController->PlayState();
1133 if (state != PLAY_STATUS_INITIAL) {
1136 if (!CViewMgr::GetInstance()->UpdateView(MUSIC_PLAYBACK_VIEW, NULL))
1137 _ERR("CViewMgr::UpdateView failed");
1139 if (!CViewMgr::GetInstance()->ShowView(MUSIC_PLAYBACK_VIEW))
1140 _ERR("CViewMgr::ShowView failed");
1145 r = m->pController->MediaGetList(LIST_TYPE_SONG, NULL, &list);
1146 if (r == false || eina_list_count(list) == 0) {
1151 m->pController->Stop();
1152 m->pController->UpdatePlaylist(list, ADD_TYPE_FRESH);
1153 eina_list_free(list);
1159 case BASE_VIEW_SOURCE_BUTTON:
1160 m_CreateCtxPopup(BTN_SOURCE);
1163 case BASE_VIEW_SORT_BUTTON:
1164 m_CreateCtxPopup(BTN_SORT);
1167 case BASE_VIEW_GROUP_SONG:
1168 case BASE_VIEW_GROUP_ALBUM:
1169 case BASE_VIEW_GROUP_ARTIST:
1170 case BASE_VIEW_GROUP_GENRE:
1171 case BASE_VIEW_GROUP_FOLDER:
1172 case BASE_VIEW_GROUP_PLAYLIST:
1174 if (m->c_grpbtn == obj)
1177 elm_object_signal_emit(m->c_grpbtn,
1178 MUSIC_SIGNAL_GROUP_UNSELECTED, MUSIC_BASE_VIEW);
1180 elm_object_signal_emit(m->c_grpbtn,
1181 MUSIC_SIGNAL_GROUP_SELECTED, MUSIC_BASE_VIEW);
1183 if (obj == m->group_btn[GROUP_BTN_FOLDER])
1184 elm_object_text_set(m->sortbtn, _(g_sortTextFolder[0]));
1185 else if (obj == m->group_btn[GROUP_BTN_PLAYLIST])
1186 elm_object_text_set(m->sortbtn, _(g_sortTextPlaylists[0]));
1187 else if (obj == m->group_btn[GROUP_BTN_ALBUM])
1188 elm_object_text_set(m->sortbtn, _(g_sortTextAlbum[0]));
1189 else if (obj == m->group_btn[GROUP_BTN_ARTIST])
1190 elm_object_text_set(m->sortbtn, _(g_sortTextArtist[0]));
1191 else if (obj == m->group_btn[GROUP_BTN_GENRE])
1192 elm_object_text_set(m->sortbtn, _(g_sortTextGenre[0]));
1194 elm_object_text_set(m->sortbtn, _(g_sortText[0]));
1196 CInfo::SetSortType(0);
1198 m_ShowCurrentLayout();
1208 void CMusicBaseView::OnComplete(void)
1210 m_UpdatePlaysongLabel();
1214 void CMusicBaseView::OnError(void)
1219 void CMusicBaseView::OnUsbStatusChanged(SUsbStorageStatus status)
1222 case USB_STORAGE_CONNECTED:
1224 m->popup = m_CreateLoadingPopup();
1227 case USB_STORAGE_DISCONNECTED:
1232 ASSERT(!"Invalid Status");
1238 void CMusicBaseView::OnUpdateContent(void)
1243 m_DestroyCtxPopup();
1244 source = CInfo::SourceType();
1245 elm_object_text_set(m->srcbtn, _(g_sourceText[source]));
1247 if (source != SOURCE_TYPE_TV)
1248 m_ShowCurrentLayout();