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 #include <tzplatform_config.h>
23 /*============================================================================*/
25 /*============================================================================*/
26 CicoHSMenuWindow *CicoHSMenuWindow::menu_window_instance;
27 int CicoHSMenuWindow::menu_tile_width = 290;
28 int CicoHSMenuWindow::menu_tile_height = 290;
30 /*============================================================================*/
32 /*============================================================================*/
33 /*--------------------------------------------------------------------------*/
35 * @brief CicoHSMenuWindow::CicoHSMenuWindo
41 /*--------------------------------------------------------------------------*/
42 CicoHSMenuWindow::CicoHSMenuWindow(void)
45 terminate_mode = false;
47 /*get menu background image*/
48 CicoGKeyFileConfig config;
49 config.Initialize(ICO_HOMESCREEN_CONFIG_FILE, ICO_SYC_PACKAGE_HOMESCREEN);
51 transparent_background = true;
52 const char *menu_back = config.ConfigGetFilePath("homescreen", "menu",
53 ICO_SYC_CONFIGPATH_HOME_IMAGE,
54 ICO_SYC_PACKAGE_HOMESCREEN
55 "/" ICO_SYC_CONFIGPATH_PACKAGE_IMAGE,
58 strncpy(menu_img_path, menu_back, sizeof(menu_img_path)-1);
59 menu_img_path[sizeof(menu_img_path)-1] = 0;
60 transparent_background = false;
69 for (int ii = 0;ii < ICO_HS_MENU_MAX_TILE_NUM;ii++) {
72 for (int ii = 0;ii < ICO_HS_MENU_MAX_MENU_PAGE_NUM;ii++) {
73 page_pointer[ii] = NULL;
78 menu_window_instance = this;
80 life_cycle_controller = CicoHSLifeCycleController::getInstance();
82 CicoResourceConfig::GetImagePath(img_dir_path, ICO_HS_MAX_PATH_BUFF_LEN);
87 /*--------------------------------------------------------------------------*/
89 * @brief CicoHSMenuWindow::~CicoHSMenuWindo
95 /*--------------------------------------------------------------------------*/
96 CicoHSMenuWindow::~CicoHSMenuWindow(void)
98 /* Do not somthing to do */
101 /*--------------------------------------------------------------------------*/
103 * @brief CicoHSMenuWindow::SetMenuBack
104 * create object and show (background of menu)
107 * @return ERROR or OK
109 /*--------------------------------------------------------------------------*/
111 CicoHSMenuWindow::SetMenuBack(void)
115 if (transparent_background) {
117 snprintf(menu_img_path, sizeof(menu_img_path), "%s%s",
118 img_dir_path, ICO_HS_IMAGE_FILE_MENU_BACK_GROUND);
120 rectangle = evas_object_rectangle_add(evas);
121 if (true == CicoHSSystemState::getInstance()->getNightMode()) {
122 evas_object_color_set(rectangle,0,0,0,178);
125 evas_object_color_set(rectangle,120,120,120,178);
127 evas_object_move(rectangle, 0, 0);
128 evas_object_resize(rectangle, width, height);
129 evas_object_show(rectangle);
133 canvas = evas_object_image_filled_add(evas);
134 evas_object_image_file_set(canvas, menu_img_path, NULL);
135 int err = evas_object_image_load_error_get(canvas);
136 if (err != EVAS_LOAD_ERROR_NONE) {
137 ICO_ERR("CicoHSMenuWindow::SetMenuBack: backgound image(%s) is not exist",
139 ICO_TRA("CicoHSMenuWindow::SetMenuBack Leave(ERR)");
140 evas_object_del(canvas);
143 evas_object_event_callback_add(canvas, EVAS_CALLBACK_MOUSE_DOWN,
144 CicoHSMenuTouch::TouchDownMenu,NULL);
145 evas_object_event_callback_add(canvas, EVAS_CALLBACK_MOUSE_UP,
146 CicoHSMenuTouch::TouchUpMenu,NULL);
147 evas_event_callback_add(evas, EVAS_CALLBACK_CANVAS_FOCUS_OUT,
148 CicoHSMenuTouch::FocusOutEvas, (void *)canvas);
149 evas_object_move(canvas, 0, 0);
150 evas_object_resize(canvas, width, height);
151 evas_object_show(canvas);
153 ICO_TRA("CicoHSMenuWindow::SetMenuBack Leave(EOK)");
157 /*--------------------------------------------------------------------------*/
159 * @brief CicoHSMenuWindow::FreeMenuBack
160 * free object (background of menu)
165 /*--------------------------------------------------------------------------*/
167 CicoHSMenuWindow::FreeMenuBack(void)
169 evas_object_del(canvas);
170 if (transparent_background)
171 evas_object_del(rectangle);
174 /*--------------------------------------------------------------------------*/
176 * @brief CicoHSMenuWindow::GetLayout
179 * @param[in] filename layout file name
180 * @param[out] layout layout data
181 * @param[out] num num of tile
184 /*--------------------------------------------------------------------------*/
186 CicoHSMenuWindow::GetLayout(const char *filename,CicoLayoutInfo *layout,int *num)
191 fp = fopen(filename,"r");
196 while( ( ret = fscanf( fp, "%d,%d,%d,%d,%d",
197 &layout[idx].appidx, &layout[idx].page, &layout[idx].position,
198 &layout[idx].tile_width, &layout[idx].tile_height ) ) != EOF ){
206 /*--------------------------------------------------------------------------*/
208 * @brief CicoHSMenuWindow::GetCategory
211 * @param[in] filename category file name
212 * @param[out] category category data
213 * @param[out] num num of category
216 /*--------------------------------------------------------------------------*/
218 CicoHSMenuWindow::GetCategory(const char *filename, int *category, int *num)
223 fp = fopen(filename,"r");
228 while( ( ret = fscanf( fp, "%d", &category[idx]
236 /*--------------------------------------------------------------------------*/
238 * @brief CicoHSMenuWindow::SetLayout
241 * @param[in] filename layout file name
242 * @param[in] layout layout data
243 * @param[in] num num of tile
246 /*--------------------------------------------------------------------------*/
248 CicoHSMenuWindow::SetLayout(const char *filename,CicoLayoutInfo *layout,int num)
253 fp = fopen(filename,"w+");
257 for (int ii = 0;ii < num;ii++) {
258 ret = fprintf(fp, "%d,%d,%d,%d,%d\n",
259 layout[ii].appidx,layout[ii].page,layout[ii].position,
260 layout[ii].tile_width,layout[ii].tile_height);
268 /*--------------------------------------------------------------------------*/
270 * @brief CicoHSMenuWindow::InitAppTiles
271 * Initialization object (tiles)
276 /*--------------------------------------------------------------------------*/
278 CicoHSMenuWindow::InitAppTiles(void)
280 ICO_TRA("CicoHSMenuWindow::InitAppTiles Enter");
285 for (int ii = 0; ii < ICO_HS_MENU_MAX_MENU_CATEGORY_NUM; ii++){
286 category_info[ii].id= 0;
287 category_info[ii].page = 0;
288 category_info[ii].subpage_max = 0;
289 category_info[ii].tile_num = 0;
295 ICO_TRA("CicoHSMenuWindow::InitAppTiles Leave");
298 /*--------------------------------------------------------------------------*/
300 * @brief CicoHSMenuWindow::SetAppTiles
301 * create object and show (tiles)
304 * @return ERROR or OK
306 /*--------------------------------------------------------------------------*/
308 CicoHSMenuWindow::SetAppTiles(void)
311 int category_num = 0;
312 int category[ICO_HS_MENU_MAX_TILE_NUM];
319 /* get APP information */
320 std::vector<CicoAilItems> aillist =
321 life_cycle_controller->getAilList();
323 /* get category infomation */
324 const char *category_path = tzplatform_mkpath3(TZ_USER_HOME,
325 ICO_SYC_CONFIGPATH_HOME_CONFIG,
326 ICO_HS_MENU_CATEGORY_FILE_NAME);
327 ICO_DBG("CicoHSMenuWindow::SetAppTiles category_path(%s)", category_path);
328 if (access(category_path, R_OK) != 0) {
329 category_path = tzplatform_mkpath(TZ_SYS_RO_APP,
330 ICO_HS_DEFAULT_MENU_CATEGORY_FILE_PATH);
332 GetCategory(category_path, category, &category_num);
333 ICO_DBG("CicoHSMenuWindow::SetAppTiles :category_num %d", category_num);
335 for (int ii = 0; ii < category_num ; ii++) {
336 ICO_DBG("CicoHSMenuWindow::SetAppTiles :category[%d] %d", ii, category[ii]);
339 /* other category add */
340 all_category_num = category_num + 1;
343 for (int ii = 0; ii < all_category_num ; ii++) {
346 category_info[ii].id = ICO_HS_MENU_OTHER_CATEGORY_ID;
347 category_info[ii].page = ii;
351 category_info[ii].id = category[ii - 1];
352 category_info[ii].page = ii;
356 /*first time layout*/
357 for (unsigned int ii = 0; ii < aillist.size(); ii++) {
359 /*all application num*/
360 if((aillist[ii].m_noIcon) ||
361 (strcmp(aillist[ii].m_group.c_str(),
362 ICO_HS_GROUP_SPECIAL) == 0)) {
363 ICO_DBG("CicoHSMenuWindow::SetAppTiles :ignore app appid = [%s] noIcon = [%d]",
364 aillist[ii].m_appid.c_str(),aillist[ii].m_noIcon);
367 ICO_DBG("CicoHSMenuWindow::SetAppTiles :SetApp appid = [%s] noIcon =[%d]",
368 aillist[ii].m_appid.c_str(),aillist[ii].m_noIcon);
369 ICO_DBG("CicoHSMenuWindow::SetAppTile :aillist[%d].m_categoryID = [%d]",
370 ii, aillist[ii].m_categoryID);
373 for (ctg_idx = 0; ctg_idx < category_num ; ctg_idx++ ) {
374 if (aillist[ii].m_categoryID == category[ctg_idx]) {
375 SetCategoryInfo(category[ctg_idx]);
376 GetTileInfo(category[ctg_idx], &page, &subpage, &position);
381 /* Other categories */
382 if (ctg_idx == category_num) {
383 SetCategoryInfo(ICO_HS_MENU_OTHER_CATEGORY_ID);
384 GetTileInfo(ICO_HS_MENU_OTHER_CATEGORY_ID,
385 &page, &subpage, &position);
389 menu_tile[tile_num] =
390 new CicoHSMenuTile(aillist[ii].m_appid.c_str(),
391 aillist[ii].m_icon.c_str(),page, subpage, position,
392 CicoHSMenuWindow::Tile_Width(), CicoHSMenuWindow::Tile_Height());
398 all_tile_num = tile_num;
399 all_page_num = all_category_num;
401 for (int ii = 0; ii < all_category_num ; ii++) {
402 ICO_DBG("CicoHSMenuWindow::SetAppTile :category_info[%d].id = [%d]",
403 ii, category_info[ii].id);
404 ICO_DBG("CicoHSMenuWindow::SetAppTile :category_info[%d].subpage_max = [%d]",
405 ii, category_info[ii].subpage_max);
406 ICO_DBG("CicoHSMenuWindow::SetAppTile :category_info[%d].page = [%d]",
407 ii, category_info[ii].page);
408 ICO_DBG("CicoHSMenuWindow::SetAppTile :category_info[%d].tile_num = [%d]",
409 ii , category_info[ii].tile_num);
412 /*in case of over max num*/
413 if (all_page_num > ICO_HS_MENU_MAX_MENU_PAGE_NUM) {
414 all_page_num = ICO_HS_MENU_MAX_MENU_PAGE_NUM;
418 for (int ii = 0; ii < tile_num; ii++) {
419 if (menu_tile[ii] == NULL) {
422 menu_tile[ii]->CreateObject(evas);
423 if (menu_tile[ii]->GetPage() != 0) {
425 menu_tile[ii]->OffsetMove(width,0);
427 if (menu_tile[ii]->GetSubPage() != 0) {
429 menu_tile[ii]->OffsetMove(height,0);
435 /*--------------------------------------------------------------------------*/
437 * @brief CicoHSMenuWindow::FreeAppTiles
438 * free object (tiles)
443 /*--------------------------------------------------------------------------*/
445 CicoHSMenuWindow::FreeAppTiles(void)
447 for (int ii = 0; ii < all_tile_num; ii++) {
448 if (menu_tile[ii] == NULL) {
451 menu_tile[ii]->FreeObject();
452 delete menu_tile[ii];
456 /*--------------------------------------------------------------------------*/
458 * @brief CicoHSMenuWindow::RenewAppTiles
464 /*--------------------------------------------------------------------------*/
466 CicoHSMenuWindow::RenewAppTiles(void)
468 ICO_TRA("CicoHSMenuWindow::RenewAppTiles Enter");
473 /* backup old data */
474 int all_tile_num_org = all_tile_num;
475 CicoHSMenuTile *menu_tile_org[ICO_HS_MENU_MAX_TILE_NUM];
476 for (cnt=0; cnt < all_tile_num_org; cnt++) {
477 menu_tile_org[cnt]=menu_tile[cnt];
486 ICO_ERR("CicoHSMenuWindow::RenewAppTiles: could not make tiles.");
489 /* update app info list */
490 CicoHomeScreen::RenewAppInfoList();
492 /* set thumbnail from org */
493 for (cnt=0; cnt < all_tile_num; cnt++) {
494 if (menu_tile[cnt] == NULL) {
497 for (cnt2=0; cnt2 < all_tile_num_org; cnt2++) {
498 if (menu_tile_org[cnt2] == NULL) {
501 if (strncmp(menu_tile[cnt]->GetAppId(),
502 menu_tile_org[cnt2]->GetAppId(), ICO_HS_MAX_PROCESS_NAME) == 0) {
503 menu_tile[cnt]->SetOrgThumbnail( menu_tile_org[cnt2] );
509 /* free org app tiles */
510 for (cnt2=0; cnt2 < all_tile_num_org; cnt2++) {
511 if (menu_tile_org[cnt2] == NULL) {
514 menu_tile_org[cnt2]->FreeObject();
515 delete menu_tile_org[cnt2];
518 ICO_TRA("CicoHSMenuWindow::RenewAppTiles Leave");
521 /*--------------------------------------------------------------------------*/
523 * @brief CicoHSMenuWindow::SetPagePointer
524 * create object and show (page pointer)
527 * @return ERROR or OK
529 /*--------------------------------------------------------------------------*/
531 CicoHSMenuWindow::SetPagePointer(void)
534 for (int ii = 0; ii < all_page_num; ii++) {
536 char img_path[ICO_HS_MAX_PATH_BUFF_LEN];
539 if(ii == current_page){
540 snprintf(img_path,sizeof(img_path),"%s%s",
541 img_dir_path,ICO_HS_IMAGE_FILE_MENU_PAGEPOINTER_P);
543 snprintf(img_path,sizeof(img_path),"%s%s",
544 img_dir_path,ICO_HS_IMAGE_FILE_MENU_PAGEPOINTER_N);
547 page_pointer[ii] = evas_object_image_filled_add(evas);
548 evas_object_image_file_set(page_pointer[ii], img_path, NULL);
549 int err = evas_object_image_load_error_get(page_pointer[ii]);
550 if (err != EVAS_LOAD_ERROR_NONE) {
551 ICO_ERR("CicoHSMenuWindow::SetPagePointer: page pointer image is not exist");
552 evas_object_del(page_pointer[ii]);
555 evas_object_event_callback_add(page_pointer[ii],
556 EVAS_CALLBACK_MOUSE_DOWN,
557 CicoHSMenuTouch::TouchDownMenu,NULL);
558 evas_object_event_callback_add(page_pointer[ii],
559 EVAS_CALLBACK_MOUSE_UP,
560 CicoHSMenuTouch::TouchUpMenu,NULL);
562 int pos_x = ICO_HS_MENU_PAGE_POINTER_START_POS_X +
563 (((width - ICO_HS_MENU_PAGE_POINTER_START_POS_X * 2) /
564 all_page_num ) * ii) +
565 (((width - ICO_HS_MENU_PAGE_POINTER_START_POS_X * 2) /
566 all_page_num ) / 2) -
567 (ICO_HS_MENU_PAGE_POINTER_WIDTH / 2);
568 evas_object_move(page_pointer[ii], pos_x,
569 ICO_HS_MENU_PAGE_POINTER_START_POS_Y);
570 evas_object_resize(page_pointer[ii],
571 ICO_HS_MENU_PAGE_POINTER_WIDTH,
572 ICO_HS_MENU_PAGE_POINTER_HEIGHT);
573 evas_object_show(page_pointer[ii]);
578 /*--------------------------------------------------------------------------*/
580 * @brief CicoHSMenuWindow::FreePagePointer
581 * free object (page pointer)
586 /*--------------------------------------------------------------------------*/
588 CicoHSMenuWindow::FreePagePointer(void)
590 for (int ii = 0; ii < all_page_num; ii++) {
591 evas_object_del(page_pointer[ii]);
595 /*--------------------------------------------------------------------------*/
597 * @brief CicoHSMenuWindow::SetTerminateButton
598 * create object and show (terminate button)
601 * @return ERROR or OK
603 /*--------------------------------------------------------------------------*/
605 CicoHSMenuWindow::SetTerminateButton(void)
608 char img_path[ICO_HS_MAX_PATH_BUFF_LEN];
613 terminate_back = evas_object_rectangle_add(evas);
614 evas_object_color_set(terminate_back,0,0,0,178);
615 evas_object_move(terminate_back, 0, 0);
616 evas_object_resize(terminate_back, width, height);
617 evas_object_layer_set(terminate_back, ICO_HS_MENU_TERMINATE_BUTTON_LAYER);
619 snprintf(img_path,sizeof(img_path),"%s%s",
620 img_dir_path,ICO_HS_IMAGE_FILE_MENU_TERMINATE_YES);
621 terminate_button_yes = evas_object_image_filled_add(evas);
622 evas_object_image_file_set(terminate_button_yes, img_path, NULL);
623 err = evas_object_image_load_error_get(terminate_button_yes);
624 if (err != EVAS_LOAD_ERROR_NONE) {
625 ICO_ERR("CicoHSMenuWindow::SetTerminateButton: image is not exist");
626 evas_object_del(terminate_button_yes);
629 evas_object_event_callback_add(terminate_button_yes, EVAS_CALLBACK_MOUSE_UP,
630 CicoHSMenuTouch::TouchUpTerminateYes,
632 evas_object_move(terminate_button_yes, width / 2 - 100 - 64,
634 evas_object_resize(terminate_button_yes,100,64);
635 evas_object_layer_set(terminate_button_yes, ICO_HS_MENU_TERMINATE_BUTTON_LAYER);
638 snprintf(img_path,sizeof(img_path),"%s%s",
639 img_dir_path, ICO_HS_IMAGE_FILE_MENU_TERMINATE_NO);
640 terminate_button_no = evas_object_image_filled_add(evas);
641 evas_object_image_file_set(terminate_button_no, img_path, NULL);
642 err = evas_object_image_load_error_get(terminate_button_no);
643 if (err != EVAS_LOAD_ERROR_NONE) {
644 ICO_ERR("CicoHSMenuWindow::SetTerminateButton: image is not exist");
645 evas_object_del(terminate_button_no);
648 evas_object_event_callback_add(terminate_button_no, EVAS_CALLBACK_MOUSE_UP,
649 CicoHSMenuTouch::TouchUpTerminateNo,
651 evas_object_move(terminate_button_no, width / 2 + 64,
653 evas_object_resize(terminate_button_no,100,64);
654 evas_object_layer_set(terminate_button_no, ICO_HS_MENU_TERMINATE_BUTTON_LAYER);
657 snprintf(img_path,sizeof(img_path),"%s%s",
658 img_dir_path,ICO_HS_IMAGE_FILE_MENU_TERMINATE_REALLY);
659 terminate_really = evas_object_image_filled_add(evas);
660 evas_object_image_file_set(terminate_really, img_path, NULL);
661 err = evas_object_image_load_error_get(terminate_really);
662 if (err != EVAS_LOAD_ERROR_NONE) {
663 ICO_ERR("CicoHSMenuWindow::SetTerminateButton: image is not exist");
664 evas_object_del(terminate_really);
667 evas_object_move(terminate_really, width / 2 - 100,
669 evas_object_resize(terminate_really,200,64);
670 evas_object_layer_set(terminate_really, ICO_HS_MENU_TERMINATE_BUTTON_LAYER);
675 /*--------------------------------------------------------------------------*/
677 * @brief CicoHSMenuWindow::FreeTeiminateButton
678 * free object (terminate button)
683 /*--------------------------------------------------------------------------*/
685 CicoHSMenuWindow::FreeTerminateButton(void)
687 evas_object_del(terminate_back);
688 evas_object_del(terminate_really);
689 evas_object_del(terminate_button_yes);
690 evas_object_del(terminate_button_no);
693 /*--------------------------------------------------------------------------*/
695 * @brief CicoHSMenuWindow::ShowTerminateButton
696 * show terminate button
699 * @return ERROR or OK
701 /*--------------------------------------------------------------------------*/
703 CicoHSMenuWindow::ShowTerminateButton(void)
705 evas_object_show(terminate_back);
706 evas_object_show(terminate_really);
707 evas_object_show(terminate_button_yes);
708 evas_object_show(terminate_button_no);
711 /*--------------------------------------------------------------------------*/
713 * @brief CicoHSMenuWindow::HideTerminateButton
714 * show terminate button
719 /*--------------------------------------------------------------------------*/
721 CicoHSMenuWindow::HideTerminateButton(void)
723 evas_object_hide(terminate_back);
724 evas_object_hide(terminate_really);
725 evas_object_hide(terminate_button_yes);
726 evas_object_hide(terminate_button_no);
729 /*--------------------------------------------------------------------------*/
731 * @brief CicoHSMenuWindow::SetPageCursor
732 * create object and show (page cursor)
735 * @return ERROR or OK
737 /*--------------------------------------------------------------------------*/
739 CicoHSMenuWindow::SetPageCursor(void)
741 char img_path[ICO_HS_MAX_PATH_BUFF_LEN];
744 snprintf(img_path,sizeof(img_path),"%s%s",
745 img_dir_path,ICO_HS_IMAGE_FILE_MENU_PAGE_UP_CURSOR);
748 page_up_cursor = evas_object_image_filled_add(evas);
749 evas_object_image_file_set(page_up_cursor, img_path, NULL);
750 int err = evas_object_image_load_error_get(page_up_cursor);
751 if (err != EVAS_LOAD_ERROR_NONE) {
752 ICO_ERR("CicoHSMenuWindow::SetPagePointer: page up cursor image is not exist");
753 evas_object_del(page_up_cursor);
757 evas_object_move(page_up_cursor, ICO_HS_MENU_PAGE_UP_CURSOR_START_POS_X,
758 ICO_HS_MENU_PAGE_UP_CURSOR_START_POS_Y);
759 evas_object_resize(page_up_cursor,
760 ICO_HS_MENU_PAGE_UP_CURSOR_WIDTH,
761 ICO_HS_MENU_PAGE_UP_CURSOR_HEIGHT);
764 snprintf(img_path,sizeof(img_path),"%s%s",
765 img_dir_path,ICO_HS_IMAGE_FILE_MENU_PAGE_DOWN_CURSOR);
768 page_down_cursor = evas_object_image_filled_add(evas);
769 evas_object_image_file_set(page_down_cursor, img_path, NULL);
770 err = evas_object_image_load_error_get(page_down_cursor);
771 if (err != EVAS_LOAD_ERROR_NONE) {
772 ICO_ERR("CicoHSMenuWindow::SetPagePointer: page down cursor image is not exist");
773 evas_object_del(page_down_cursor);
777 evas_object_move(page_down_cursor, ICO_HS_MENU_PAGE_DOWN_CURSOR_START_POS_X,
778 ICO_HS_MENU_PAGE_DOWN_CURSOR_START_POS_Y);
779 evas_object_resize(page_down_cursor,
780 ICO_HS_MENU_PAGE_DOWN_CURSOR_WIDTH,
781 ICO_HS_MENU_PAGE_DOWN_CURSOR_HEIGHT);
788 /*--------------------------------------------------------------------------*/
790 * @brief CicoHSMenuWindow::FreePageCursor
791 * free object (page cursor)
796 /*--------------------------------------------------------------------------*/
798 CicoHSMenuWindow::FreePageCursor(void)
800 evas_object_del(page_up_cursor);
801 evas_object_del(page_down_cursor);
804 /*--------------------------------------------------------------------------*/
806 * @brief CicoHSMenuWindow::CreateMenuWindow
807 * Create menu window (page pointer)
809 * @param[in] pos_x window position x
810 * @param[in] pos_y window position y
811 * @param[in] width window width
812 * @param[in] height window height
815 /*--------------------------------------------------------------------------*/
817 CicoHSMenuWindow::CreateMenuWindow(int pos_x, int pos_y, int width, int height)
822 ret = CreateWindow(ICO_HS_MENU_WINDOW_TITLE,
823 pos_x, pos_y, width, height, EINA_TRUE);
829 CicoHSMenuWindow::menu_tile_width = (width - (ICO_HS_MENUTILE_START_POS_X * 2)
830 - (ICO_HS_MENUTILE_SPACE_TILE_AND_TILE
831 * (ICO_HS_MENUTILE_ROW-1)))
832 / ICO_HS_MENUTILE_ROW;
833 if (CicoHSMenuWindow::menu_tile_width < 150) {
834 CicoHSMenuWindow::menu_tile_width = 150;
836 CicoHSMenuWindow::menu_tile_height = (height - (ICO_HS_STATUSBAR_WINDOW_HEIGHT
837 + ICO_HS_CONTROLBAR_WINDOW_HEIGHT
838 + ICO_HS_MENUTILE_HEIGHT + 8)
839 - (ICO_HS_MENUTILE_SPACE_TILE_AND_TILE
840 * (ICO_HS_MENUTILE_COLUMN-1)))
841 / ICO_HS_MENUTILE_COLUMN;
842 if (CicoHSMenuWindow::menu_tile_height < 150) {
843 CicoHSMenuWindow::menu_tile_height = 150;
845 ICO_DBG("CicoHSMenuWindow::CreateMenuWindow: tile size(w/h)=%d/%d",
846 CicoHSMenuWindow::menu_tile_width, CicoHSMenuWindow::menu_tile_height);
847 if (CicoHSMenuWindow::menu_tile_width > CicoHSMenuWindow::menu_tile_height) {
848 CicoHSMenuWindow::menu_tile_width = CicoHSMenuWindow::menu_tile_height;
851 CicoHSMenuWindow::menu_tile_height = CicoHSMenuWindow::menu_tile_width;
855 evas = ecore_evas_get(window);
857 ICO_ERR("CicoHSMenuWindow::CreateMenuWindow: could not get evas.");
864 ICO_ERR("CicoHSMenuWindow::CreateMenuWindow: could not make back ground.");
871 ICO_ERR("CicoHSMenuWindow::CreateMenuWindow: could not make tiles.");
878 ret = SetPagePointer();
880 ICO_ERR("CicoHSMenuWindow::CreateMenuWindow: could not make page pointer.");
888 ret = SetPageCursor();
890 ICO_ERR("CicoHSMenuWindow::CreateMenuWindow: could not make page cursor.");
898 /* Terminate Button */
899 ret = SetTerminateButton();
901 ICO_ERR("CicoHSMenuWindow::CreateMenuWindow: could not make teminate button.");
910 /* Initialize Action*/
911 CicoHSMenuTouch::Initialize(this);
916 /*--------------------------------------------------------------------------*/
918 * @brief CicoHSMenuWindow::FreeMenuWindow
924 /*--------------------------------------------------------------------------*/
926 CicoHSMenuWindow::FreeMenuWindow(void)
928 FreeTerminateButton();
936 /*--------------------------------------------------------------------------*/
938 * @brief CicoHSMenuWindow::MoveToNextAnimation
939 * animation parts (move to next)
945 /*--------------------------------------------------------------------------*/
947 CicoHSMenuWindow::MoveToNextAnimation(void *data,double pos)
950 double frame = ecore_animator_pos_map(pos, ECORE_POS_MAP_LINEAR, 0.5, 1);
951 current_page = reinterpret_cast<intptr_t>(data);
953 for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
954 if (menu_window_instance->menu_tile[ii] == NULL) {
957 if ((menu_window_instance->menu_tile[ii]->GetPage() != current_page -1) ||
958 (menu_window_instance->menu_tile[ii]->GetSubPage() != 0)) {
961 menu_window_instance->menu_tile[ii]->OffsetMove(-1 *
962 (menu_window_instance->width * frame),0);
965 for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
966 if (menu_window_instance->menu_tile[ii] == NULL) {
969 if ((menu_window_instance->menu_tile[ii]->GetPage() != current_page) ||
970 (menu_window_instance->menu_tile[ii]->GetSubPage() != 0)) {
973 menu_window_instance->menu_tile[ii]->
974 OffsetMove(menu_window_instance->width
975 - (menu_window_instance->width * frame),0);
980 /*--------------------------------------------------------------------------*/
982 * @brief CicoHSMenuWindow::MoveToBackAnimation
983 * animation parts (move to back)
989 /*--------------------------------------------------------------------------*/
991 CicoHSMenuWindow::MoveToBackAnimation(void *data,double pos)
994 double frame = ecore_animator_pos_map(pos, ECORE_POS_MAP_LINEAR, 0.5, 1);
995 current_page = reinterpret_cast<intptr_t>(data);
997 for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
998 if (menu_window_instance->menu_tile[ii] == NULL) {
1001 if ((menu_window_instance->menu_tile[ii]->GetPage() != current_page) ||
1002 (menu_window_instance->menu_tile[ii]->GetSubPage() != 0)) {
1005 menu_window_instance->menu_tile[ii]->OffsetMove(-1 *
1006 menu_window_instance->width +
1007 (menu_window_instance->width * frame),0);
1009 for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
1010 if (menu_window_instance->menu_tile[ii] == NULL) {
1013 if ((menu_window_instance->menu_tile[ii]->GetPage() != current_page + 1) ||
1014 (menu_window_instance->menu_tile[ii]->GetSubPage() != 0)) {
1017 menu_window_instance->menu_tile[ii]->
1018 OffsetMove(menu_window_instance->width * frame,0);
1023 /*--------------------------------------------------------------------------*/
1025 * @brief CicoHSMenuWindow::MoveToNextSubAnimation
1026 * animation parts (move to next)
1032 /*--------------------------------------------------------------------------*/
1034 CicoHSMenuWindow::MoveToNextSubAnimation(void *data,double pos)
1036 CicoCurrentPage *current_info;
1037 double frame = ecore_animator_pos_map(pos, ECORE_POS_MAP_LINEAR, 0.5, 1);
1038 current_info = (CicoCurrentPage *)(data);
1040 for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
1041 if (menu_window_instance->menu_tile[ii] == NULL) {
1044 if (menu_window_instance->menu_tile[ii]->GetSubPage()
1045 != current_info->subcurrent_page -1) {
1048 if (menu_window_instance->menu_tile[ii]->GetPage() != current_info->current_page) {
1051 menu_window_instance->menu_tile[ii]->
1052 OffsetMove(0, -1 * (menu_window_instance->height * frame));
1055 for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
1056 if (menu_window_instance->menu_tile[ii] == NULL) {
1059 if (menu_window_instance->menu_tile[ii]->GetSubPage()
1060 != current_info->subcurrent_page) {
1064 if (menu_window_instance->menu_tile[ii]->GetPage() != current_info->current_page) {
1067 menu_window_instance->menu_tile[ii]->OffsetMove(0, menu_window_instance->height -
1068 (menu_window_instance->height * frame));
1073 /*--------------------------------------------------------------------------*/
1075 * @brief CicoHSMenuWindow::MoveToBackAnimation
1076 * animation parts (move to back)
1082 /*--------------------------------------------------------------------------*/
1084 CicoHSMenuWindow::MoveToBackSubAnimation(void *data,double pos)
1087 CicoCurrentPage *current_info;
1088 double frame = ecore_animator_pos_map(pos, ECORE_POS_MAP_LINEAR, 0.5, 1);
1089 current_info = (CicoCurrentPage *)(data);
1091 for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
1092 if (menu_window_instance->menu_tile[ii] == NULL) {
1095 if (menu_window_instance->menu_tile[ii]->GetSubPage()
1096 != current_info->subcurrent_page) {
1099 if (menu_window_instance->menu_tile[ii]->GetPage() != current_info->current_page) {
1102 menu_window_instance->menu_tile[ii]->
1103 OffsetMove(0, -1 * menu_window_instance->height +
1104 (menu_window_instance->height * frame));
1106 for (int ii = 0;ii < menu_window_instance->all_tile_num;ii++) {
1107 if (menu_window_instance->menu_tile[ii] == NULL) {
1110 if (menu_window_instance->menu_tile[ii]->GetSubPage()
1111 != current_info->subcurrent_page + 1) {
1114 if (menu_window_instance->menu_tile[ii]->GetPage() != current_info->current_page) {
1117 menu_window_instance->menu_tile[ii]->
1118 OffsetMove(0, menu_window_instance->height * frame);
1123 /*--------------------------------------------------------------------------*/
1125 * @brief CicoHSMenuWindow::GoNextMenu
1126 * menu change to next
1131 /*--------------------------------------------------------------------------*/
1133 CicoHSMenuWindow::GoNextMenu(void)
1135 char img_path[ICO_HS_MAX_PATH_BUFF_LEN];
1137 if ((current_page >= all_page_num -1) || (subcurrent_page > 0)) {
1142 snprintf(img_path, sizeof(img_path), "%s%s",
1143 img_dir_path, ICO_HS_IMAGE_FILE_MENU_PAGEPOINTER_N);
1144 evas_object_image_file_set(page_pointer[current_page], img_path, NULL);
1149 /* display cursor */
1150 DspCtrlPageCursor();
1153 snprintf(img_path, sizeof(img_path), "%s%s",
1154 img_dir_path, ICO_HS_IMAGE_FILE_MENU_PAGEPOINTER_P);
1155 evas_object_image_file_set(page_pointer[current_page], img_path, NULL);
1158 ecore_animator_frametime_set(1.0f / 30);
1159 ecore_animator_timeline_add(0.4, MoveToNextAnimation,
1160 reinterpret_cast<void*>(current_page));
1163 /*--------------------------------------------------------------------------*/
1165 * @brief CicoHSMenuWindow::GoNextMenu
1166 * menu change to back
1171 /*--------------------------------------------------------------------------*/
1173 CicoHSMenuWindow::GoBackMenu(void)
1175 char img_path[ICO_HS_MAX_PATH_BUFF_LEN];
1177 if((current_page <= 0) || (subcurrent_page > 0)){
1182 snprintf(img_path,sizeof(img_path),"%s%s",img_dir_path,ICO_HS_IMAGE_FILE_MENU_PAGEPOINTER_N);
1183 evas_object_image_file_set(page_pointer[current_page], img_path, NULL);
1188 /* display cursor */
1189 DspCtrlPageCursor();
1192 snprintf(img_path,sizeof(img_path),"%s%s",img_dir_path,ICO_HS_IMAGE_FILE_MENU_PAGEPOINTER_P);
1193 evas_object_image_file_set(page_pointer[current_page], img_path, NULL);
1196 ecore_animator_frametime_set(1.0f / 30);
1197 ecore_animator_timeline_add(0.4, MoveToBackAnimation,
1198 reinterpret_cast<void*>(current_page));
1202 /*--------------------------------------------------------------------------*/
1204 * @brief CicoHSMenuWindow::DownNextMenu
1205 * menu change to next
1210 /*--------------------------------------------------------------------------*/
1212 CicoHSMenuWindow::DownNextMenu(void)
1214 for (int i = 0; i < all_category_num; i++) {
1215 if (current_page == category_info[i].page) {
1216 if (subcurrent_page >= category_info[i].subpage_max){
1225 /* display cursor */
1226 DspCtrlPageCursor();
1228 /* current page set */
1229 current_info.current_page = current_page;
1230 current_info.subcurrent_page = subcurrent_page;
1233 ecore_animator_frametime_set(1.0f / 30);
1234 ecore_animator_timeline_add(0.4, MoveToNextSubAnimation,
1235 (void*)(¤t_info));
1238 /*--------------------------------------------------------------------------*/
1240 * @brief CicoHSMenuWindow::UpBackMenu
1241 * menu change to back
1246 /*--------------------------------------------------------------------------*/
1248 CicoHSMenuWindow::UpBackMenu(void)
1250 if(subcurrent_page <= 0){
1257 /* display cursor */
1258 DspCtrlPageCursor();
1260 /* current page set */
1261 current_info.current_page = current_page;
1262 current_info.subcurrent_page = subcurrent_page;
1265 ecore_animator_frametime_set(1.0f / 30);
1266 ecore_animator_timeline_add(0.4, MoveToBackSubAnimation,
1267 (void*)(¤t_info));
1270 /*--------------------------------------------------------------------------*/
1272 * @brief CicoHSMenuWindow::DspCtrlPageCursor
1273 * display control page cursor
1278 /*--------------------------------------------------------------------------*/
1280 CicoHSMenuWindow::DspCtrlPageCursor(void)
1282 int subpage_max = 0;
1283 for (int i = 0; i < all_category_num ; i++) {
1284 if (current_page == category_info[i].page) {
1285 subpage_max = category_info[i].subpage_max;
1290 if (subcurrent_page > 0) {
1291 evas_object_show(page_up_cursor);
1294 evas_object_hide(page_up_cursor);
1297 if (subcurrent_page < subpage_max) {
1298 evas_object_show(page_down_cursor);
1301 evas_object_hide(page_down_cursor);
1305 /*--------------------------------------------------------------------------*/
1307 * @brief CicoHSMenuWindow::SetCategoryInfo
1310 * @param[in] id menu category id
1313 /*--------------------------------------------------------------------------*/
1315 CicoHSMenuWindow::SetCategoryInfo(int id)
1317 for (int i = 0; i < all_category_num ; i++) {
1318 if (category_info[i].id == id) {
1320 category_info[i].subpage_max =
1321 category_info[i].tile_num / ICO_HS_MENUTILE_NUM;
1324 category_info[i].tile_num++;
1329 /*--------------------------------------------------------------------------*/
1331 * @brief CicoHSMenuWindow::GetTileInfo
1334 * @param[in] id menu category id
1335 * @param[out] page menu page
1336 * @param[out] subpage menu sub page
1337 * @param[out] position menu tile position
1340 /*--------------------------------------------------------------------------*/
1342 CicoHSMenuWindow::GetTileInfo(int id, int *page, int *subpage, int *position)
1344 for (int i = 0; i < all_category_num ; i++) {
1345 if (category_info[i].id == id) {
1346 if (category_info[i].tile_num == 0) {
1347 ICO_ERR("CicoHSMenuWindow::GetTileInfo: number of tiles is 0.");
1352 *page = category_info[i].page;
1354 *subpage = (category_info[i].tile_num -1) / ICO_HS_MENUTILE_NUM;
1356 *position = (category_info[i].tile_num -1) % ICO_HS_MENUTILE_NUM;
1361 /*--------------------------------------------------------------------------*/
1363 * @brief CicoHSMenuWindow::SetMenuWindowID
1364 * set appid and surface
1369 /*--------------------------------------------------------------------------*/
1371 CicoHSMenuWindow::SetMenuWindowID(const char *appid,int surface)
1373 strncpy(this->appid,appid,ICO_HS_MAX_PROCESS_NAME);
1374 this->surface = surface;
1377 /*--------------------------------------------------------------------------*/
1379 * @brief CicoHSMenuWindow::Show
1385 /*--------------------------------------------------------------------------*/
1387 CicoHSMenuWindow::Show(ico_syc_animation_t *animation)
1389 ICO_TRA("CicoHSMenuWindow::Show Enter");
1391 // if regulation == true, forbid show window.
1392 if (true == CicoHSSystemState::getInstance()->getRegulation()) {
1397 if (true == life_cycle_controller->isAilRenew()) {
1398 ICO_DBG("CicoHSMenuWindow::Show : renew app tiles");
1400 life_cycle_controller->ailRenewFlagOff();
1404 for (int ii = 0; ii < all_tile_num; ii++) {
1405 if (menu_tile[ii]) {
1406 menu_tile[ii]->ShowMenu(true);
1410 ico_syc_show(appid, surface, animation);
1412 ICO_TRA("CicoHSMenuWindow::Show Leave");
1415 /*--------------------------------------------------------------------------*/
1417 * @brief CicoHSMenuWindow::Hide
1423 /*--------------------------------------------------------------------------*/
1425 CicoHSMenuWindow::Hide(ico_syc_animation_t *animation)
1427 ICO_TRA("CicoHSMenuWindow::Hide Enter");
1429 if(terminate_mode == true){
1432 m_showState = false;
1434 ico_syc_hide(appid, surface, animation);
1438 for (int ii = 0; ii < all_tile_num; ii++) {
1439 if (menu_tile[ii]) {
1440 menu_tile[ii]->ShowMenu(false);
1443 ICO_TRA("CicoHSMenuWindow::Hide Leave");
1446 /*--------------------------------------------------------------------------*/
1448 * @brief CicoHSMenuWindow::ExecuteApp
1449 * execute application
1451 * @param[in] appid application id
1454 /*--------------------------------------------------------------------------*/
1456 CicoHSMenuWindow::ExecuteApp(const char *appid)
1458 if(terminate_mode == true){
1459 ICO_DBG("CicoHSMenuWindow::ExecuteApp: exet %s but terminate_mode", appid);
1462 CicoHomeScreen::ExecuteApp(appid);
1465 /*--------------------------------------------------------------------------*/
1467 * @brief CicoHSMenuWindow::TerminateApp
1468 * teminate application
1470 * @param[in] appid application id
1473 /*--------------------------------------------------------------------------*/
1475 CicoHSMenuWindow::TerminateApp(const char *appid)
1477 CicoHomeScreen::TerminateApp(appid);
1479 HideTerminateButton();
1483 /*--------------------------------------------------------------------------*/
1485 * @brief CicoHSMenuWindow::ChangeTerminateMode
1486 * change to terminate mode
1491 /*--------------------------------------------------------------------------*/
1493 CicoHSMenuWindow::ChangeTerminateMode(void)
1498 for (int ii = 0; ii < all_tile_num; ii++) {
1499 if(menu_tile[ii] == NULL){
1502 if(CicoHomeScreen::GetAppStatus(menu_tile[ii]->GetAppId()) == true){
1512 for (int ii = 0; ii < all_tile_num; ii++) {
1513 if(menu_tile[ii] == NULL){
1516 if(CicoHomeScreen::GetAppStatus(menu_tile[ii]->GetAppId()) == false){
1519 menu_tile[ii]->ShowTermIcon();
1521 terminate_mode = true;
1522 ICO_DBG("CicoHSMenuWindow::ChangeTerminateMode: change to terminate mode");
1525 /*--------------------------------------------------------------------------*/
1527 * @brief CicoHSMenuWindow::ChangeNormalMode
1528 * change to terminate mode
1533 /*--------------------------------------------------------------------------*/
1535 CicoHSMenuWindow::ChangeNormalMode(void)
1538 for (int ii = 0; ii < all_tile_num; ii++) {
1539 if(menu_tile[ii] == NULL){
1542 menu_tile[ii]->HideTermIcon();
1544 terminate_mode = false;
1545 ICO_DBG("CicoHSMenuWindow::ChangeNormalMode: change to normal mode");
1548 /*--------------------------------------------------------------------------*/
1550 * @brief CicoHSMenuWindow::ValidMenuIcon
1553 * @param[in] appid application ID
1556 /*--------------------------------------------------------------------------*/
1558 CicoHSMenuWindow::ValidMenuIcon(const char *appid)
1560 ICO_DBG("CicoHSMenuWindow::ValidMenuIcon(%s)", appid ? appid : "(NULL)" );
1561 for (int ii = 0; ii < all_tile_num; ii++) {
1562 if (strncmp(menu_tile[ii]->GetAppId(), appid, ICO_HS_MAX_PROCESS_NAME) == 0) {
1563 menu_tile[ii]->ValidMenuIcon();
1569 /*--------------------------------------------------------------------------*/
1571 * @brief CicoHSMenuWindow::ValidThumbnail
1574 * @param[in] appid application ID
1575 * @param[in] surface surface
1578 /*--------------------------------------------------------------------------*/
1580 CicoHSMenuWindow::ValidThumbnail(const char *appid, int surface)
1582 for (int ii = 0; ii < all_tile_num; ii++) {
1583 if (strncmp(menu_tile[ii]->GetAppId(), appid, ICO_HS_MAX_PROCESS_NAME) == 0) {
1584 menu_tile[ii]->ValidThumbnail(surface);
1590 /*--------------------------------------------------------------------------*/
1592 * @brief CicoHSMenuWindow::SetThumbnail
1595 * @param[in] appid application ID
1596 * @param[in] info thumbnail information
1599 /*--------------------------------------------------------------------------*/
1601 CicoHSMenuWindow::SetThumbnail(const char *appid, ico_syc_thumb_info_t *info)
1603 for (int ii = 0; ii < all_tile_num; ii++) {
1604 if (strncmp(menu_tile[ii]->GetAppId(), appid, ICO_HS_MAX_PROCESS_NAME) == 0) {
1605 menu_tile[ii]->SetThumbnail(info);
1611 /*--------------------------------------------------------------------------*/
1613 * @brief CicoHSMenuWindow::SetNightMode
1614 * set night mode color theme chagne
1619 /*--------------------------------------------------------------------------*/
1621 CicoHSMenuWindow::SetNightMode(void)
1623 ICO_TRA("CicoHSMenuWindow::SetNightMode Enter");
1624 if (transparent_background) {
1625 if (true == CicoHSSystemState::getInstance()->getNightMode()) {
1626 evas_object_color_set(rectangle,0,0,0,178);
1629 evas_object_color_set(rectangle,120,120,120,178);
1632 ICO_TRA("CicoHSMenuWindow::SetNightMode Leave");
1635 /*--------------------------------------------------------------------------*/
1637 * @brief CicoHSMenuWindow::Tile_Width
1641 * @return tile width
1643 /*--------------------------------------------------------------------------*/
1645 CicoHSMenuWindow::Tile_Width(void)
1647 return CicoHSMenuWindow::menu_tile_width;
1650 /*--------------------------------------------------------------------------*/
1652 * @brief CicoHSMenuWindow::Tile_Height
1656 * @return tile height
1658 /*--------------------------------------------------------------------------*/
1660 CicoHSMenuWindow::Tile_Height(void)
1662 return CicoHSMenuWindow::menu_tile_height;
1664 // vim: set expandtab ts=4 sw=4: