2 * Copyright (c) 2013, TOYOTA MOTOR CORPORATION.
4 * This program is licensed under the terms and conditions of the
5 * Apache License, version 2.0. The full text of the Apache License is at
6 * http://www.apache.org/licenses/LICENSE-2.0
10 * @brief Menu Window class
14 #include "CicoHSMenuWindow.h"
15 #include "CicoHSMenuTouch.h"
16 #include "CicoResourceConfig.h"
17 #include "CicoHomeScreen.h"
18 #include "CicoHSSystemState.h"
21 /*============================================================================*/
23 /*============================================================================*/
24 CicoHSMenuWindow *CicoHSMenuWindow::menu_window_instance;
25 int CicoHSMenuWindow::menu_tile_width = 290;
26 int CicoHSMenuWindow::menu_tile_height = 290;
28 /*============================================================================*/
30 /*============================================================================*/
31 /*--------------------------------------------------------------------------*/
33 * @brief CicoHSMenuWindow::CicoHSMenuWindo
39 /*--------------------------------------------------------------------------*/
40 CicoHSMenuWindow::CicoHSMenuWindow(void)
42 CicoGKeyFileConfig config;
43 config.Initialize(ICO_HOMESCREEN_CONFIG_FILE);
44 const char *value = config.ConfigGetString("homescreen", "background", "picture");
45 transparent_background = false;
46 if (strcmp(value, "picture") != 0)
47 transparent_background = true;
50 terminate_mode = false;
58 for (int ii = 0;ii < ICO_HS_MENU_MAX_TILE_NUM;ii++) {
61 for (int ii = 0;ii < ICO_HS_MENU_MAX_MENU_PAGE_NUM;ii++) {
62 page_pointer[ii] = NULL;
67 menu_window_instance = this;
69 life_cycle_controller = CicoHSLifeCycleController::getInstance();
71 CicoResourceConfig::GetImagePath(img_dir_path, ICO_HS_MAX_PATH_BUFF_LEN);
76 /*--------------------------------------------------------------------------*/
78 * @brief CicoHSMenuWindow::~CicoHSMenuWindo
84 /*--------------------------------------------------------------------------*/
85 CicoHSMenuWindow::~CicoHSMenuWindow(void)
87 /* Do not somthing to do */
90 /*--------------------------------------------------------------------------*/
92 * @brief CicoHSMenuWindow::SetMenuBack
93 * create object and show (background of menu)
98 /*--------------------------------------------------------------------------*/
100 CicoHSMenuWindow::SetMenuBack(void)
102 char img_path[ICO_HS_MAX_PATH_BUFF_LEN];
106 if (transparent_background) {
108 snprintf(img_path, sizeof(img_path), "%s%s",
109 img_dir_path, ICO_HS_IMAGE_FILE_MENU_BACK_GROUND_BLANK);
111 rectangle = evas_object_rectangle_add(evas);
112 if (true == CicoHSSystemState::getInstance()->getNightMode()) {
113 evas_object_color_set(rectangle,0,0,0,178);
116 evas_object_color_set(rectangle,120,120,120,178);
118 evas_object_move(rectangle, 0, 0);
119 evas_object_resize(rectangle, width, height);
120 evas_object_show(rectangle);
122 snprintf(img_path, sizeof(img_path), "%s%s",
123 img_dir_path, ICO_HS_IMAGE_FILE_MENU_BACK_GROUND_PICTURE);
126 canvas = evas_object_image_filled_add(evas);
127 evas_object_image_file_set(canvas, img_path, NULL);
128 int err = evas_object_image_load_error_get(canvas);
129 if (err != EVAS_LOAD_ERROR_NONE) {
130 ICO_ERR("CicoHSMenuWindow::SetMenuBack: backgound image is not exist");
131 ICO_TRA("CicoHSMenuWindow::SetMenuBack Leave(ERR)");
132 evas_object_del(canvas);
135 evas_object_event_callback_add(canvas, EVAS_CALLBACK_MOUSE_DOWN,
136 CicoHSMenuTouch::TouchDownMenu,NULL);
137 evas_object_event_callback_add(canvas, EVAS_CALLBACK_MOUSE_UP,
138 CicoHSMenuTouch::TouchUpMenu,NULL);
139 evas_event_callback_add(evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT,
140 CicoHSMenuTouch::FocusOutEvas, (void *)canvas);
141 evas_object_move(canvas, 0, 0);
142 evas_object_resize(canvas, width, height);
143 evas_object_show(canvas);
145 ICO_TRA("CicoHSMenuWindow::SetMenuBack Leave(EOK)");
149 /*--------------------------------------------------------------------------*/
151 * @brief CicoHSMenuWindow::FreeMenuBack
152 * free object (background of menu)
157 /*--------------------------------------------------------------------------*/
159 CicoHSMenuWindow::FreeMenuBack(void)
161 evas_object_del(canvas);
162 if (transparent_background)
163 evas_object_del(rectangle);
166 /*--------------------------------------------------------------------------*/
168 * @brief CicoHSMenuWindow::GetLayout
171 * @param[in] filename layout file name
172 * @param[out] layout layout data
173 * @param[out] num num of tile
176 /*--------------------------------------------------------------------------*/
178 CicoHSMenuWindow::GetLayout(const char *filename,CicoLayoutInfo *layout,int *num)
183 fp = fopen(filename,"r");
188 while( ( ret = fscanf( fp, "%d,%d,%d,%d,%d",
189 &layout[idx].appidx, &layout[idx].page, &layout[idx].position,
190 &layout[idx].tile_width, &layout[idx].tile_height ) ) != EOF ){
198 /*--------------------------------------------------------------------------*/
200 * @brief CicoHSMenuWindow::GetCategory
203 * @param[in] filename category file name
204 * @param[out] category category data
205 * @param[out] num num of category
208 /*--------------------------------------------------------------------------*/
210 CicoHSMenuWindow::GetCategory(const char *filename, int *category, int *num)
215 fp = fopen(filename,"r");
220 while( ( ret = fscanf( fp, "%d", &category[idx]
228 /*--------------------------------------------------------------------------*/
230 * @brief CicoHSMenuWindow::SetLayout
233 * @param[in] filename layout file name
234 * @param[in] layout layout data
235 * @param[in] num num of tile
238 /*--------------------------------------------------------------------------*/
240 CicoHSMenuWindow::SetLayout(const char *filename,CicoLayoutInfo *layout,int num)
245 fp = fopen(filename,"w+");
249 for (int ii = 0;ii < num;ii++) {
250 ret = fprintf(fp, "%d,%d,%d,%d,%d\n",
251 layout[ii].appidx,layout[ii].page,layout[ii].position,
252 layout[ii].tile_width,layout[ii].tile_height);
260 /*--------------------------------------------------------------------------*/
262 * @brief CicoHSMenuWindow::InitAppTiles
263 * Initialization object (tiles)
268 /*--------------------------------------------------------------------------*/
270 CicoHSMenuWindow::InitAppTiles(void)
272 ICO_TRA("CicoHSMenuWindow::InitAppTiles Enter");
277 for (int ii = 0; ii < ICO_HS_MENU_MAX_MENU_CATEGORY_NUM; ii++){
278 category_info[ii].id= 0;
279 category_info[ii].page = 0;
280 category_info[ii].subpage_max = 0;
281 category_info[ii].tile_num = 0;
287 ICO_TRA("CicoHSMenuWindow::InitAppTiles Leave");
290 /*--------------------------------------------------------------------------*/
292 * @brief CicoHSMenuWindow::SetAppTiles
293 * create object and show (tiles)
296 * @return ERROR or OK
298 /*--------------------------------------------------------------------------*/
300 CicoHSMenuWindow::SetAppTiles(void)
303 int category_num = 0;
304 int category[ICO_HS_MENU_MAX_TILE_NUM];
311 /* get APP information */
312 std::vector<CicoAilItems> aillist =
313 life_cycle_controller->getAilList();
315 /* get category infomation */
316 GetCategory(ICO_HS_MENU_CATEGORY_FILE_PATH, category, &category_num);
317 ICO_DBG("CicoHSMenuWindow::SetAppTiles :category_num %d", category_num);
319 for (int ii = 0; ii < category_num ; ii++) {
320 ICO_DBG("CicoHSMenuWindow::SetAppTiles :category[%d] %d", ii, category[ii]);
323 /* other category add */
324 all_category_num = category_num + 1;
327 for (int ii = 0; ii < all_category_num ; ii++) {
330 category_info[ii].id = ICO_HS_MENU_OTHER_CATEGORY_ID;
331 category_info[ii].page = ii;
335 category_info[ii].id = category[ii - 1];
336 category_info[ii].page = ii;
340 /*first time layout*/
341 for (unsigned int ii = 0; ii < aillist.size(); ii++) {
343 /*all application num*/
344 if((aillist[ii].m_noIcon) ||
345 (strcmp(aillist[ii].m_group.c_str(),
346 ICO_HS_GROUP_SPECIAL) == 0)) {
347 ICO_DBG("CicoHSMenuWindow::SetAppTiles :ignore app appid = [%s] noIcon = [%d]",
348 aillist[ii].m_appid.c_str(),aillist[ii].m_noIcon);
351 ICO_DBG("CicoHSMenuWindow::SetAppTiles :SetApp appid = [%s] noIcon =[%d]",
352 aillist[ii].m_appid.c_str(),aillist[ii].m_noIcon);
353 ICO_DBG("CicoHSMenuWindow::SetAppTile :aillist[%d].m_categoryID = [%d]",
354 ii, aillist[ii].m_categoryID);
357 for (ctg_idx = 0; ctg_idx < category_num ; ctg_idx++ ) {
358 if (aillist[ii].m_categoryID == category[ctg_idx]) {
359 SetCategoryInfo(category[ctg_idx]);
360 GetTileInfo(category[ctg_idx], &page, &subpage, &position);
365 /* Other categories */
366 if (ctg_idx == category_num) {
367 SetCategoryInfo(ICO_HS_MENU_OTHER_CATEGORY_ID);
368 GetTileInfo(ICO_HS_MENU_OTHER_CATEGORY_ID,
369 &page, &subpage, &position);
373 menu_tile[tile_num] =
374 new CicoHSMenuTile(aillist[ii].m_appid.c_str(),
375 aillist[ii].m_icon.c_str(),page, subpage, position,
376 CicoHSMenuWindow::Tile_Width(), CicoHSMenuWindow::Tile_Height());
382 all_tile_num = tile_num;
383 all_page_num = all_category_num;
385 for (int ii = 0; ii < all_category_num ; ii++) {
386 ICO_DBG("CicoHSMenuWindow::SetAppTile :category_info[%d].id = [%d]",
387 ii, category_info[ii].id);
388 ICO_DBG("CicoHSMenuWindow::SetAppTile :category_info[%d].subpage_max = [%d]",
389 ii, category_info[ii].subpage_max);
390 ICO_DBG("CicoHSMenuWindow::SetAppTile :category_info[%d].page = [%d]",
391 ii, category_info[ii].page);
392 ICO_DBG("CicoHSMenuWindow::SetAppTile :category_info[%d].tile_num = [%d]",
393 ii , category_info[ii].tile_num);
396 /*in case of over max num*/
397 if (all_page_num > ICO_HS_MENU_MAX_MENU_PAGE_NUM) {
398 all_page_num = ICO_HS_MENU_MAX_MENU_PAGE_NUM;
402 for (int ii = 0; ii < tile_num; ii++) {
403 if (menu_tile[ii] == NULL) {
406 menu_tile[ii]->CreateObject(evas);
407 if (menu_tile[ii]->GetPage() != 0) {
409 menu_tile[ii]->OffsetMove(width,0);
411 if (menu_tile[ii]->GetSubPage() != 0) {
413 menu_tile[ii]->OffsetMove(height,0);
419 /*--------------------------------------------------------------------------*/
421 * @brief CicoHSMenuWindow::FreeAppTiles
422 * free object (tiles)
427 /*--------------------------------------------------------------------------*/
429 CicoHSMenuWindow::FreeAppTiles(void)
431 for (int ii = 0; ii < all_tile_num; ii++) {
432 if (menu_tile[ii] == NULL) {
435 menu_tile[ii]->FreeObject();
436 delete menu_tile[ii];
440 /*--------------------------------------------------------------------------*/
442 * @brief CicoHSMenuWindow::RenewAppTiles
448 /*--------------------------------------------------------------------------*/
450 CicoHSMenuWindow::RenewAppTiles(void)
452 ICO_TRA("CicoHSMenuWindow::RenewAppTiles Enter");
457 /* backup old data */
458 int all_tile_num_org = all_tile_num;
459 CicoHSMenuTile *menu_tile_org[ICO_HS_MENU_MAX_TILE_NUM];
460 for (cnt=0; cnt < all_tile_num_org; cnt++) {
461 menu_tile_org[cnt]=menu_tile[cnt];
470 ICO_ERR("CicoHSMenuWindow::RenewAppTiles: could not make tiles.");
473 /* update app info list */
474 CicoHomeScreen::RenewAppInfoList();
476 /* set thumbnail from org */
477 for (cnt=0; cnt < all_tile_num; cnt++) {
478 if (menu_tile[cnt] == NULL) {
481 for (cnt2=0; cnt2 < all_tile_num_org; cnt2++) {
482 if (menu_tile_org[cnt2] == NULL) {
485 if (strncmp(menu_tile[cnt]->GetAppId(),
486 menu_tile_org[cnt2]->GetAppId(), ICO_HS_MAX_PROCESS_NAME) == 0) {
487 menu_tile[cnt]->SetOrgThumbnail( menu_tile_org[cnt2] );
493 /* free org app tiles */
494 for (cnt2=0; cnt2 < all_tile_num_org; cnt2++) {
495 if (menu_tile_org[cnt2] == NULL) {
498 menu_tile_org[cnt2]->FreeObject();
499 delete menu_tile_org[cnt2];
502 ICO_TRA("CicoHSMenuWindow::RenewAppTiles Leave");
505 /*--------------------------------------------------------------------------*/
507 * @brief CicoHSMenuWindow::SetPagePointer
508 * create object and show (page pointer)
511 * @return ERROR or OK
513 /*--------------------------------------------------------------------------*/
515 CicoHSMenuWindow::SetPagePointer(void)
518 for (int ii = 0; ii < all_page_num; ii++) {
520 char img_path[ICO_HS_MAX_PATH_BUFF_LEN];
523 if(ii == current_page){
524 snprintf(img_path,sizeof(img_path),"%s%s",
525 img_dir_path,ICO_HS_IMAGE_FILE_MENU_PAGEPOINTER_P);
527 snprintf(img_path,sizeof(img_path),"%s%s",
528 img_dir_path,ICO_HS_IMAGE_FILE_MENU_PAGEPOINTER_N);
531 page_pointer[ii] = evas_object_image_filled_add(evas);
532 evas_object_image_file_set(page_pointer[ii], img_path, NULL);
533 int err = evas_object_image_load_error_get(page_pointer[ii]);
534 if (err != EVAS_LOAD_ERROR_NONE) {
535 ICO_ERR("CicoHSMenuWindow::SetPagePointer: page pointer image is not exist");
536 evas_object_del(page_pointer[ii]);
539 evas_object_event_callback_add(page_pointer[ii],
540 EVAS_CALLBACK_MOUSE_DOWN,
541 CicoHSMenuTouch::TouchDownMenu,NULL);
542 evas_object_event_callback_add(page_pointer[ii],
543 EVAS_CALLBACK_MOUSE_UP,
544 CicoHSMenuTouch::TouchUpMenu,NULL);
546 int pos_x = ICO_HS_MENU_PAGE_POINTER_START_POS_X +
547 (((width - ICO_HS_MENU_PAGE_POINTER_START_POS_X * 2) /
548 all_page_num ) * ii) +
549 (((width - ICO_HS_MENU_PAGE_POINTER_START_POS_X * 2) /
550 all_page_num ) / 2) -
551 (ICO_HS_MENU_PAGE_POINTER_WIDTH / 2);
552 evas_object_move(page_pointer[ii], pos_x,
553 ICO_HS_MENU_PAGE_POINTER_START_POS_Y);
554 evas_object_resize(page_pointer[ii],
555 ICO_HS_MENU_PAGE_POINTER_WIDTH,
556 ICO_HS_MENU_PAGE_POINTER_HEIGHT);
557 evas_object_show(page_pointer[ii]);
562 /*--------------------------------------------------------------------------*/
564 * @brief CicoHSMenuWindow::FreePagePointer
565 * free object (page pointer)
570 /*--------------------------------------------------------------------------*/
572 CicoHSMenuWindow::FreePagePointer(void)
574 for (int ii = 0; ii < all_page_num; ii++) {
575 evas_object_del(page_pointer[ii]);
579 /*--------------------------------------------------------------------------*/
581 * @brief CicoHSMenuWindow::SetTerminateButton
582 * create object and show (terminate button)
585 * @return ERROR or OK
587 /*--------------------------------------------------------------------------*/
589 CicoHSMenuWindow::SetTerminateButton(void)
592 char img_path[ICO_HS_MAX_PATH_BUFF_LEN];
597 terminate_back = evas_object_rectangle_add(evas);
598 evas_object_color_set(terminate_back,0,0,0,178);
599 evas_object_move(terminate_back, 0, 0);
600 evas_object_resize(terminate_back, width, height);
601 evas_object_layer_set(terminate_back, ICO_HS_MENU_TERMINATE_BUTTON_LAYER);
603 snprintf(img_path,sizeof(img_path),"%s%s",
604 img_dir_path,ICO_HS_IMAGE_FILE_MENU_TERMINATE_YES);
605 terminate_button_yes = evas_object_image_filled_add(evas);
606 evas_object_image_file_set(terminate_button_yes, img_path, NULL);
607 err = evas_object_image_load_error_get(terminate_button_yes);
608 if (err != EVAS_LOAD_ERROR_NONE) {
609 ICO_ERR("CicoHSMenuWindow::SetTerminateButton: image is not exist");
610 evas_object_del(terminate_button_yes);
613 evas_object_event_callback_add(terminate_button_yes, EVAS_CALLBACK_MOUSE_UP,
614 CicoHSMenuTouch::TouchUpTerminateYes,
616 evas_object_move(terminate_button_yes, width / 2 - 100 - 64,
618 evas_object_resize(terminate_button_yes,100,64);
619 evas_object_layer_set(terminate_button_yes, ICO_HS_MENU_TERMINATE_BUTTON_LAYER);
622 snprintf(img_path,sizeof(img_path),"%s%s",
623 img_dir_path, ICO_HS_IMAGE_FILE_MENU_TERMINATE_NO);
624 terminate_button_no = evas_object_image_filled_add(evas);
625 evas_object_image_file_set(terminate_button_no, img_path, NULL);
626 err = evas_object_image_load_error_get(terminate_button_no);
627 if (err != EVAS_LOAD_ERROR_NONE) {
628 ICO_ERR("CicoHSMenuWindow::SetTerminateButton: image is not exist");
629 evas_object_del(terminate_button_no);
632 evas_object_event_callback_add(terminate_button_no, EVAS_CALLBACK_MOUSE_UP,
633 CicoHSMenuTouch::TouchUpTerminateNo,
635 evas_object_move(terminate_button_no, width / 2 + 64,
637 evas_object_resize(terminate_button_no,100,64);
638 evas_object_layer_set(terminate_button_no, ICO_HS_MENU_TERMINATE_BUTTON_LAYER);
641 snprintf(img_path,sizeof(img_path),"%s%s",
642 img_dir_path,ICO_HS_IMAGE_FILE_MENU_TERMINATE_REALLY);
643 terminate_really = evas_object_image_filled_add(evas);
644 evas_object_image_file_set(terminate_really, img_path, NULL);
645 err = evas_object_image_load_error_get(terminate_really);
646 if (err != EVAS_LOAD_ERROR_NONE) {
647 ICO_ERR("CicoHSMenuWindow::SetTerminateButton: image is not exist");
648 evas_object_del(terminate_really);
651 evas_object_move(terminate_really, width / 2 - 100,
653 evas_object_resize(terminate_really,200,64);
654 evas_object_layer_set(terminate_really, ICO_HS_MENU_TERMINATE_BUTTON_LAYER);
659 /*--------------------------------------------------------------------------*/
661 * @brief CicoHSMenuWindow::FreeTeiminateButton
662 * free object (terminate button)
667 /*--------------------------------------------------------------------------*/
669 CicoHSMenuWindow::FreeTerminateButton(void)
671 evas_object_del(terminate_back);
672 evas_object_del(terminate_really);
673 evas_object_del(terminate_button_yes);
674 evas_object_del(terminate_button_no);
677 /*--------------------------------------------------------------------------*/
679 * @brief CicoHSMenuWindow::ShowTerminateButton
680 * show terminate button
683 * @return ERROR or OK
685 /*--------------------------------------------------------------------------*/
687 CicoHSMenuWindow::ShowTerminateButton(void)
689 evas_object_show(terminate_back);
690 evas_object_show(terminate_really);
691 evas_object_show(terminate_button_yes);
692 evas_object_show(terminate_button_no);
695 /*--------------------------------------------------------------------------*/
697 * @brief CicoHSMenuWindow::HideTerminateButton
698 * show terminate button
703 /*--------------------------------------------------------------------------*/
705 CicoHSMenuWindow::HideTerminateButton(void)
707 evas_object_hide(terminate_back);
708 evas_object_hide(terminate_really);
709 evas_object_hide(terminate_button_yes);
710 evas_object_hide(terminate_button_no);
713 /*--------------------------------------------------------------------------*/
715 * @brief CicoHSMenuWindow::SetPageCursor
716 * create object and show (page cursor)
719 * @return ERROR or OK
721 /*--------------------------------------------------------------------------*/
723 CicoHSMenuWindow::SetPageCursor(void)
725 char img_path[ICO_HS_MAX_PATH_BUFF_LEN];
728 snprintf(img_path,sizeof(img_path),"%s%s",
729 img_dir_path,ICO_HS_IMAGE_FILE_MENU_PAGE_UP_CURSOR);
732 page_up_cursor = evas_object_image_filled_add(evas);
733 evas_object_image_file_set(page_up_cursor, img_path, NULL);
734 int err = evas_object_image_load_error_get(page_up_cursor);
735 if (err != EVAS_LOAD_ERROR_NONE) {
736 ICO_ERR("CicoHSMenuWindow::SetPagePointer: page up cursor image is not exist");
737 evas_object_del(page_up_cursor);
741 evas_object_move(page_up_cursor, ICO_HS_MENU_PAGE_UP_CURSOR_START_POS_X,
742 ICO_HS_MENU_PAGE_UP_CURSOR_START_POS_Y);
743 evas_object_resize(page_up_cursor,
744 ICO_HS_MENU_PAGE_UP_CURSOR_WIDTH,
745 ICO_HS_MENU_PAGE_UP_CURSOR_HEIGHT);
748 snprintf(img_path,sizeof(img_path),"%s%s",
749 img_dir_path,ICO_HS_IMAGE_FILE_MENU_PAGE_DOWN_CURSOR);
752 page_down_cursor = evas_object_image_filled_add(evas);
753 evas_object_image_file_set(page_down_cursor, img_path, NULL);
754 err = evas_object_image_load_error_get(page_down_cursor);
755 if (err != EVAS_LOAD_ERROR_NONE) {
756 ICO_ERR("CicoHSMenuWindow::SetPagePointer: page down cursor image is not exist");
757 evas_object_del(page_down_cursor);
761 evas_object_move(page_down_cursor, ICO_HS_MENU_PAGE_DOWN_CURSOR_START_POS_X,
762 ICO_HS_MENU_PAGE_DOWN_CURSOR_START_POS_Y);
763 evas_object_resize(page_down_cursor,
764 ICO_HS_MENU_PAGE_DOWN_CURSOR_WIDTH,
765 ICO_HS_MENU_PAGE_DOWN_CURSOR_HEIGHT);
772 /*--------------------------------------------------------------------------*/
774 * @brief CicoHSMenuWindow::FreePageCursor
775 * free object (page cursor)
780 /*--------------------------------------------------------------------------*/
782 CicoHSMenuWindow::FreePageCursor(void)
784 evas_object_del(page_up_cursor);
785 evas_object_del(page_down_cursor);
788 /*--------------------------------------------------------------------------*/
790 * @brief CicoHSMenuWindow::CreateMenuWindow
791 * Create menu window (page pointer)
793 * @param[in] pos_x window position x
794 * @param[in] pos_y window position y
795 * @param[in] width window width
796 * @param[in] height window height
799 /*--------------------------------------------------------------------------*/
801 CicoHSMenuWindow::CreateMenuWindow(int pos_x, int pos_y, int width, int height)
806 ret = CreateWindow(ICO_HS_MENU_WINDOW_TITLE,
807 pos_x, pos_y, width, height, EINA_TRUE);
813 CicoHSMenuWindow::menu_tile_width = (width - (ICO_HS_MENUTILE_START_POS_X * 2)
814 - (ICO_HS_MENUTILE_SPACE_TILE_AND_TILE
815 * (ICO_HS_MENUTILE_ROW-1)))
816 / ICO_HS_MENUTILE_ROW;
817 if (CicoHSMenuWindow::menu_tile_width < 150) {
818 CicoHSMenuWindow::menu_tile_width = 150;
820 CicoHSMenuWindow::menu_tile_height = (height - (ICO_HS_STATUSBAR_WINDOW_HEIGHT
821 + ICO_HS_CONTROLBAR_WINDOW_HEIGHT
822 + ICO_HS_MENUTILE_HEIGHT + 8)
823 - (ICO_HS_MENUTILE_SPACE_TILE_AND_TILE
824 * (ICO_HS_MENUTILE_COLUMN-1)))
825 / ICO_HS_MENUTILE_COLUMN;
826 if (CicoHSMenuWindow::menu_tile_height < 150) {
827 CicoHSMenuWindow::menu_tile_height = 150;
829 ICO_DBG("CicoHSMenuWindow::CreateMenuWindow: tile size(w/h)=%d/%d",
830 CicoHSMenuWindow::menu_tile_width, CicoHSMenuWindow::menu_tile_height);
831 if (CicoHSMenuWindow::menu_tile_width > CicoHSMenuWindow::menu_tile_height) {
832 CicoHSMenuWindow::menu_tile_width = CicoHSMenuWindow::menu_tile_height;
835 CicoHSMenuWindow::menu_tile_height = CicoHSMenuWindow::menu_tile_width;
839 evas = ecore_evas_get(window);
841 ICO_ERR("CicoHSMenuWindow::CreateMenuWindow: could not get evas.");
848 ICO_ERR("CicoHSMenuWindow::CreateMenuWindow: could not make back ground.");
855 ICO_ERR("CicoHSMenuWindow::CreateMenuWindow: could not make tiles.");
862 ret = SetPagePointer();
864 ICO_ERR("CicoHSMenuWindow::CreateMenuWindow: could not make page pointer.");
872 ret = SetPageCursor();
874 ICO_ERR("CicoHSMenuWindow::CreateMenuWindow: could not make page cursor.");
882 /* Terminate Button */
883 ret = SetTerminateButton();
885 ICO_ERR("CicoHSMenuWindow::CreateMenuWindow: could not make teminate button.");
894 /* Initialize Action*/
895 CicoHSMenuTouch::Initialize(this);
900 /*--------------------------------------------------------------------------*/
902 * @brief CicoHSMenuWindow::FreeMenuWindow
908 /*--------------------------------------------------------------------------*/
910 CicoHSMenuWindow::FreeMenuWindow(void)
912 FreeTerminateButton();
920 /*--------------------------------------------------------------------------*/
922 * @brief CicoHSMenuWindow::MoveToNextAnimation
923 * animation parts (move to next)
929 /*--------------------------------------------------------------------------*/
931 CicoHSMenuWindow::MoveToNextAnimation(void *data,double pos)
934 double frame = ecore_animator_pos_map(pos, ECORE_POS_MAP_LINEAR, 0.5, 1);
935 current_page = reinterpret_cast<intptr_t>(data);
937 for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
938 if (menu_window_instance->menu_tile[ii] == NULL) {
941 if ((menu_window_instance->menu_tile[ii]->GetPage() != current_page -1) ||
942 (menu_window_instance->menu_tile[ii]->GetSubPage() != 0)) {
945 menu_window_instance->menu_tile[ii]->OffsetMove(-1 *
946 (menu_window_instance->width * frame),0);
949 for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
950 if (menu_window_instance->menu_tile[ii] == NULL) {
953 if ((menu_window_instance->menu_tile[ii]->GetPage() != current_page) ||
954 (menu_window_instance->menu_tile[ii]->GetSubPage() != 0)) {
957 menu_window_instance->menu_tile[ii]->
958 OffsetMove(menu_window_instance->width
959 - (menu_window_instance->width * frame),0);
964 /*--------------------------------------------------------------------------*/
966 * @brief CicoHSMenuWindow::MoveToBackAnimation
967 * animation parts (move to back)
973 /*--------------------------------------------------------------------------*/
975 CicoHSMenuWindow::MoveToBackAnimation(void *data,double pos)
978 double frame = ecore_animator_pos_map(pos, ECORE_POS_MAP_LINEAR, 0.5, 1);
979 current_page = reinterpret_cast<intptr_t>(data);
981 for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
982 if (menu_window_instance->menu_tile[ii] == NULL) {
985 if ((menu_window_instance->menu_tile[ii]->GetPage() != current_page) ||
986 (menu_window_instance->menu_tile[ii]->GetSubPage() != 0)) {
989 menu_window_instance->menu_tile[ii]->OffsetMove(-1 *
990 menu_window_instance->width +
991 (menu_window_instance->width * frame),0);
993 for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
994 if (menu_window_instance->menu_tile[ii] == NULL) {
997 if ((menu_window_instance->menu_tile[ii]->GetPage() != current_page + 1) ||
998 (menu_window_instance->menu_tile[ii]->GetSubPage() != 0)) {
1001 menu_window_instance->menu_tile[ii]->
1002 OffsetMove(menu_window_instance->width * frame,0);
1007 /*--------------------------------------------------------------------------*/
1009 * @brief CicoHSMenuWindow::MoveToNextSubAnimation
1010 * animation parts (move to next)
1016 /*--------------------------------------------------------------------------*/
1018 CicoHSMenuWindow::MoveToNextSubAnimation(void *data,double pos)
1020 CicoCurrentPage *current_info;
1021 double frame = ecore_animator_pos_map(pos, ECORE_POS_MAP_LINEAR, 0.5, 1);
1022 current_info = (CicoCurrentPage *)(data);
1024 for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
1025 if (menu_window_instance->menu_tile[ii] == NULL) {
1028 if (menu_window_instance->menu_tile[ii]->GetSubPage()
1029 != current_info->subcurrent_page -1) {
1032 if (menu_window_instance->menu_tile[ii]->GetPage() != current_info->current_page) {
1035 menu_window_instance->menu_tile[ii]->
1036 OffsetMove(0, -1 * (menu_window_instance->height * frame));
1039 for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
1040 if (menu_window_instance->menu_tile[ii] == NULL) {
1043 if (menu_window_instance->menu_tile[ii]->GetSubPage()
1044 != current_info->subcurrent_page) {
1048 if (menu_window_instance->menu_tile[ii]->GetPage() != current_info->current_page) {
1051 menu_window_instance->menu_tile[ii]->OffsetMove(0, menu_window_instance->height -
1052 (menu_window_instance->height * frame));
1057 /*--------------------------------------------------------------------------*/
1059 * @brief CicoHSMenuWindow::MoveToBackAnimation
1060 * animation parts (move to back)
1066 /*--------------------------------------------------------------------------*/
1068 CicoHSMenuWindow::MoveToBackSubAnimation(void *data,double pos)
1071 CicoCurrentPage *current_info;
1072 double frame = ecore_animator_pos_map(pos, ECORE_POS_MAP_LINEAR, 0.5, 1);
1073 current_info = (CicoCurrentPage *)(data);
1075 for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
1076 if (menu_window_instance->menu_tile[ii] == NULL) {
1079 if (menu_window_instance->menu_tile[ii]->GetSubPage()
1080 != current_info->subcurrent_page) {
1083 if (menu_window_instance->menu_tile[ii]->GetPage() != current_info->current_page) {
1086 menu_window_instance->menu_tile[ii]->
1087 OffsetMove(0, -1 * menu_window_instance->height +
1088 (menu_window_instance->height * frame));
1090 for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
1091 if (menu_window_instance->menu_tile[ii] == NULL) {
1094 if (menu_window_instance->menu_tile[ii]->GetSubPage()
1095 != current_info->subcurrent_page + 1) {
1098 if (menu_window_instance->menu_tile[ii]->GetPage() != current_info->current_page) {
1101 menu_window_instance->menu_tile[ii]->
1102 OffsetMove(0, menu_window_instance->height * frame);
1107 /*--------------------------------------------------------------------------*/
1109 * @brief CicoHSMenuWindow::GoNextMenu
1110 * menu change to next
1115 /*--------------------------------------------------------------------------*/
1117 CicoHSMenuWindow::GoNextMenu(void)
1119 char img_path[ICO_HS_MAX_PATH_BUFF_LEN];
1121 if ((current_page >= all_page_num -1) || (subcurrent_page > 0)) {
1126 snprintf(img_path, sizeof(img_path), "%s%s",
1127 img_dir_path, ICO_HS_IMAGE_FILE_MENU_PAGEPOINTER_N);
1128 evas_object_image_file_set(page_pointer[current_page], img_path, NULL);
1133 /* display cursor */
1134 DspCtrlPageCursor();
1137 snprintf(img_path, sizeof(img_path), "%s%s",
1138 img_dir_path, ICO_HS_IMAGE_FILE_MENU_PAGEPOINTER_P);
1139 evas_object_image_file_set(page_pointer[current_page], img_path, NULL);
1142 ecore_animator_frametime_set(1.0f / 30);
1143 ecore_animator_timeline_add(0.4, MoveToNextAnimation,
1144 reinterpret_cast<void*>(current_page));
1147 /*--------------------------------------------------------------------------*/
1149 * @brief CicoHSMenuWindow::GoNextMenu
1150 * menu change to back
1155 /*--------------------------------------------------------------------------*/
1157 CicoHSMenuWindow::GoBackMenu(void)
1159 char img_path[ICO_HS_MAX_PATH_BUFF_LEN];
1161 if((current_page <= 0) || (subcurrent_page > 0)){
1166 snprintf(img_path,sizeof(img_path),"%s%s",img_dir_path,ICO_HS_IMAGE_FILE_MENU_PAGEPOINTER_N);
1167 evas_object_image_file_set(page_pointer[current_page], img_path, NULL);
1172 /* display cursor */
1173 DspCtrlPageCursor();
1176 snprintf(img_path,sizeof(img_path),"%s%s",img_dir_path,ICO_HS_IMAGE_FILE_MENU_PAGEPOINTER_P);
1177 evas_object_image_file_set(page_pointer[current_page], img_path, NULL);
1180 ecore_animator_frametime_set(1.0f / 30);
1181 ecore_animator_timeline_add(0.4, MoveToBackAnimation,
1182 reinterpret_cast<void*>(current_page));
1186 /*--------------------------------------------------------------------------*/
1188 * @brief CicoHSMenuWindow::DownNextMenu
1189 * menu change to next
1194 /*--------------------------------------------------------------------------*/
1196 CicoHSMenuWindow::DownNextMenu(void)
1198 for (int i = 0; i < all_category_num; i++) {
1199 if (current_page == category_info[i].page) {
1200 if (subcurrent_page >= category_info[i].subpage_max){
1209 /* display cursor */
1210 DspCtrlPageCursor();
1212 /* current page set */
1213 current_info.current_page = current_page;
1214 current_info.subcurrent_page = subcurrent_page;
1217 ecore_animator_frametime_set(1.0f / 30);
1218 ecore_animator_timeline_add(0.4, MoveToNextSubAnimation,
1219 (void*)(¤t_info));
1222 /*--------------------------------------------------------------------------*/
1224 * @brief CicoHSMenuWindow::UpBackMenu
1225 * menu change to back
1230 /*--------------------------------------------------------------------------*/
1232 CicoHSMenuWindow::UpBackMenu(void)
1234 if(subcurrent_page <= 0){
1241 /* display cursor */
1242 DspCtrlPageCursor();
1244 /* current page set */
1245 current_info.current_page = current_page;
1246 current_info.subcurrent_page = subcurrent_page;
1249 ecore_animator_frametime_set(1.0f / 30);
1250 ecore_animator_timeline_add(0.4, MoveToBackSubAnimation,
1251 (void*)(¤t_info));
1254 /*--------------------------------------------------------------------------*/
1256 * @brief CicoHSMenuWindow::DspCtrlPageCursor
1257 * display control page cursor
1262 /*--------------------------------------------------------------------------*/
1264 CicoHSMenuWindow::DspCtrlPageCursor(void)
1266 int subpage_max = 0;
1267 for (int i = 0; i < all_category_num ; i++) {
1268 if (current_page == category_info[i].page) {
1269 subpage_max = category_info[i].subpage_max;
1274 if (subcurrent_page > 0) {
1275 evas_object_show(page_up_cursor);
1278 evas_object_hide(page_up_cursor);
1281 if (subcurrent_page < subpage_max) {
1282 evas_object_show(page_down_cursor);
1285 evas_object_hide(page_down_cursor);
1289 /*--------------------------------------------------------------------------*/
1291 * @brief CicoHSMenuWindow::SetCategoryInfo
1294 * @param[in] id menu category id
1297 /*--------------------------------------------------------------------------*/
1299 CicoHSMenuWindow::SetCategoryInfo(int id)
1301 for (int i = 0; i < all_category_num ; i++) {
1302 if (category_info[i].id == id) {
1304 category_info[i].subpage_max =
1305 category_info[i].tile_num / ICO_HS_MENUTILE_NUM;
1308 category_info[i].tile_num++;
1313 /*--------------------------------------------------------------------------*/
1315 * @brief CicoHSMenuWindow::GetTileInfo
1318 * @param[in] id menu category id
1319 * @param[out] page menu page
1320 * @param[out] subpage menu sub page
1321 * @param[out] position menu tile position
1324 /*--------------------------------------------------------------------------*/
1326 CicoHSMenuWindow::GetTileInfo(int id, int *page, int *subpage, int *position)
1328 for (int i = 0; i < all_category_num ; i++) {
1329 if (category_info[i].id == id) {
1330 if (category_info[i].tile_num == 0) {
1331 ICO_ERR("CicoHSMenuWindow::GetTileInfo: number of tiles is 0.");
1336 *page = category_info[i].page;
1338 *subpage = (category_info[i].tile_num -1) / ICO_HS_MENUTILE_NUM;
1340 *position = (category_info[i].tile_num -1) % ICO_HS_MENUTILE_NUM;
1345 /*--------------------------------------------------------------------------*/
1347 * @brief CicoHSMenuWindow::SetMenuWindowID
1348 * set appid and surface
1353 /*--------------------------------------------------------------------------*/
1355 CicoHSMenuWindow::SetMenuWindowID(const char *appid,int surface)
1357 strncpy(this->appid,appid,ICO_HS_MAX_PROCESS_NAME);
1358 this->surface = surface;
1361 /*--------------------------------------------------------------------------*/
1363 * @brief CicoHSMenuWindow::Show
1369 /*--------------------------------------------------------------------------*/
1371 CicoHSMenuWindow::Show(ico_syc_animation_t *animation)
1373 ICO_TRA("CicoHSMenuWindow::Show Enter");
1375 // if regulation == true, forbid show window.
1376 if (true == CicoHSSystemState::getInstance()->getRegulation()) {
1381 if (true == life_cycle_controller->isAilRenew()) {
1382 ICO_DBG("CicoHSMenuWindow::Show : renew app tiles");
1384 life_cycle_controller->ailRenewFlagOff();
1388 for (int ii = 0; ii < all_tile_num; ii++) {
1389 if (menu_tile[ii]) {
1390 menu_tile[ii]->ShowMenu(true);
1394 ico_syc_show(appid, surface, animation);
1396 ICO_TRA("CicoHSMenuWindow::Show Leave");
1399 /*--------------------------------------------------------------------------*/
1401 * @brief CicoHSMenuWindow::Hide
1407 /*--------------------------------------------------------------------------*/
1409 CicoHSMenuWindow::Hide(ico_syc_animation_t *animation)
1411 ICO_TRA("CicoHSMenuWindow::Hide Enter");
1413 if(terminate_mode == true){
1416 m_showState = false;
1418 ico_syc_hide(appid, surface, animation);
1422 for (int ii = 0; ii < all_tile_num; ii++) {
1423 if (menu_tile[ii]) {
1424 menu_tile[ii]->ShowMenu(false);
1427 ICO_TRA("CicoHSMenuWindow::Hide Leave");
1430 /*--------------------------------------------------------------------------*/
1432 * @brief CicoHSMenuWindow::ExecuteApp
1433 * execute application
1435 * @param[in] appid application id
1438 /*--------------------------------------------------------------------------*/
1440 CicoHSMenuWindow::ExecuteApp(const char *appid)
1442 if(terminate_mode == true){
1443 ICO_DBG("CicoHSMenuWindow::ExecuteApp: exet %s but terminate_mode", appid);
1446 CicoHomeScreen::ExecuteApp(appid);
1449 /*--------------------------------------------------------------------------*/
1451 * @brief CicoHSMenuWindow::TerminateApp
1452 * teminate application
1454 * @param[in] appid application id
1457 /*--------------------------------------------------------------------------*/
1459 CicoHSMenuWindow::TerminateApp(const char *appid)
1461 CicoHomeScreen::TerminateApp(appid);
1463 HideTerminateButton();
1467 /*--------------------------------------------------------------------------*/
1469 * @brief CicoHSMenuWindow::ChangeTerminateMode
1470 * change to terminate mode
1475 /*--------------------------------------------------------------------------*/
1477 CicoHSMenuWindow::ChangeTerminateMode(void)
1482 for (int ii = 0; ii < all_tile_num; ii++) {
1483 if(menu_tile[ii] == NULL){
1486 if(CicoHomeScreen::GetAppStatus(menu_tile[ii]->GetAppId()) == true){
1496 for (int ii = 0; ii < all_tile_num; ii++) {
1497 if(menu_tile[ii] == NULL){
1500 if(CicoHomeScreen::GetAppStatus(menu_tile[ii]->GetAppId()) == false){
1503 menu_tile[ii]->ShowTermIcon();
1505 terminate_mode = true;
1506 ICO_DBG("CicoHSMenuWindow::ChangeTerminateMode: change to terminate mode");
1509 /*--------------------------------------------------------------------------*/
1511 * @brief CicoHSMenuWindow::ChangeNormalMode
1512 * change to terminate mode
1517 /*--------------------------------------------------------------------------*/
1519 CicoHSMenuWindow::ChangeNormalMode(void)
1522 for (int ii = 0; ii < all_tile_num; ii++) {
1523 if(menu_tile[ii] == NULL){
1526 menu_tile[ii]->HideTermIcon();
1528 terminate_mode = false;
1529 ICO_DBG("CicoHSMenuWindow::ChangeNormalMode: change to normal mode");
1532 /*--------------------------------------------------------------------------*/
1534 * @brief CicoHSMenuWindow::ValidMenuIcon
1537 * @param[in] appid application ID
1540 /*--------------------------------------------------------------------------*/
1542 CicoHSMenuWindow::ValidMenuIcon(const char *appid)
1544 ICO_DBG("CicoHSMenuWindow::ValidMenuIcon(%s)", appid ? appid : "(NULL)" );
1545 for (int ii = 0; ii < all_tile_num; ii++) {
1546 if (strncmp(menu_tile[ii]->GetAppId(), appid, ICO_HS_MAX_PROCESS_NAME) == 0) {
1547 menu_tile[ii]->ValidMenuIcon();
1553 /*--------------------------------------------------------------------------*/
1555 * @brief CicoHSMenuWindow::ValidThumbnail
1558 * @param[in] appid application ID
1559 * @param[in] surface surface
1562 /*--------------------------------------------------------------------------*/
1564 CicoHSMenuWindow::ValidThumbnail(const char *appid, int surface)
1566 for (int ii = 0; ii < all_tile_num; ii++) {
1567 if (strncmp(menu_tile[ii]->GetAppId(), appid, ICO_HS_MAX_PROCESS_NAME) == 0) {
1568 menu_tile[ii]->ValidThumbnail(surface);
1574 /*--------------------------------------------------------------------------*/
1576 * @brief CicoHSMenuWindow::SetThumbnail
1579 * @param[in] appid application ID
1580 * @param[in] info thumbnail information
1583 /*--------------------------------------------------------------------------*/
1585 CicoHSMenuWindow::SetThumbnail(const char *appid, ico_syc_thumb_info_t *info)
1587 for (int ii = 0; ii < all_tile_num; ii++) {
1588 if (strncmp(menu_tile[ii]->GetAppId(), appid, ICO_HS_MAX_PROCESS_NAME) == 0) {
1589 menu_tile[ii]->SetThumbnail(info);
1595 /*--------------------------------------------------------------------------*/
1597 * @brief CicoHSMenuWindow::SetNightMode
1598 * set night mode color theme chagne
1603 /*--------------------------------------------------------------------------*/
1605 CicoHSMenuWindow::SetNightMode(void)
1607 ICO_TRA("CicoHSMenuWindow::SetNightMode Enter");
1608 if (transparent_background) {
1609 if (true == CicoHSSystemState::getInstance()->getNightMode()) {
1610 evas_object_color_set(rectangle,0,0,0,178);
1613 evas_object_color_set(rectangle,120,120,120,178);
1616 ICO_TRA("CicoHSMenuWindow::SetNightMode Leave");
1619 /*--------------------------------------------------------------------------*/
1621 * @brief CicoHSMenuWindow::Tile_Width
1625 * @return tile width
1627 /*--------------------------------------------------------------------------*/
1629 CicoHSMenuWindow::Tile_Width(void)
1631 return CicoHSMenuWindow::menu_tile_width;
1634 /*--------------------------------------------------------------------------*/
1636 * @brief CicoHSMenuWindow::Tile_Height
1640 * @return tile height
1642 /*--------------------------------------------------------------------------*/
1644 CicoHSMenuWindow::Tile_Height(void)
1646 return CicoHSMenuWindow::menu_tile_height;
1648 // vim: set expandtab ts=4 sw=4: