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
14 #include "CicoHSMenuTile.h"
15 #include "CicoHSMenuTouch.h"
21 #include <tzplatform_config.h>
23 /*============================================================================*/
25 /*============================================================================*/
26 /*--------------------------------------------------------------------------*/
28 * @brief CicoHSMenuTile::CicoHSMenuTile
32 * @param[in] icon_image_path
39 /*--------------------------------------------------------------------------*/
40 CicoHSMenuTile::CicoHSMenuTile(const char *appid,
41 const char *icon_image_path,
42 int page, int subpage,
43 int position, int width, int height)
45 ICO_TRA("CicoHSMenuTile::CicoHSMenuTile Enter");
48 strncpy(this->appid, appid, ICO_HS_MAX_PROCESS_NAME);
50 if ((icon_image_path != NULL) && (strlen(icon_image_path) != 0)) {
51 strncpy(this->icon_image_path,icon_image_path,ICO_HS_MAX_PATH_BUFF_LEN);
54 strncpy(this->icon_image_path,
55 tzplatform_mkpath(TZ_SYS_RO_APP,
56 ICO_HS_MENUTILE_DEFAULT_ICON_PATH),
57 ICO_HS_MAX_PATH_BUFF_LEN);
59 ICO_DBG("CicoHSMenuTile::CicoHSMenuTile:image_path %s:%s",
60 appid, this->icon_image_path);
63 thumb.pixel_data = NULL;
64 thumb.thumb_timer = NULL;
67 this->subpage = subpage;
68 this->position = position;
70 this->height = height;
71 pos_x = GetPositionX();
72 pos_y = GetPositionY();
74 (void) mkdir(ICO_HS_THUMB_ICODIR, 0755);
75 (void) mkdir(ICO_HS_THUMB_ICODIR ICO_HS_THUMB_FILEDIR, 0755);
77 ICO_TRA("CicoHSMenuTile::CicoHSMenuTile Leave");
80 /*--------------------------------------------------------------------------*/
82 * @brief CicoHSMenuTile::CicoHSMenuTile
88 /*--------------------------------------------------------------------------*/
89 CicoHSMenuTile::~CicoHSMenuTile(void)
91 if (thumb.thumb_timer) {
92 ecore_timer_del(thumb.thumb_timer);
93 thumb.thumb_timer = NULL;
97 /*--------------------------------------------------------------------------*/
99 * @brief CicoHSMenuTile::CreateObject
105 /*--------------------------------------------------------------------------*/
107 CicoHSMenuTile::CreateObject(Evas *evas)
109 ICO_DBG("CicoHSMenuTile::CreateObject Enter(appid=<%s> x/y=%d/%d)",
110 appid, pos_x, pos_y);
118 thumb_reduce_x = ICO_HS_MENUTILE_THUMBNAIL_REDUCE_PIX;
119 thumb_reduce_y = ICO_HS_MENUTILE_THUMBNAIL_REDUCE_PIX;
120 if (thumb.thumb_timer) {
121 ecore_timer_del(thumb.thumb_timer);
122 thumb.thumb_timer = NULL;
126 tile = evas_object_image_filled_add(evas);
127 evas_object_image_file_set(tile, icon_image_path, NULL);
128 evas_object_move(tile, pos_x, pos_y);
129 evas_object_resize(tile, width, height);
130 evas_object_event_callback_add(tile, EVAS_CALLBACK_MOUSE_DOWN,
131 CicoHSMenuTouch::TouchDownMenu, appid);
132 evas_object_event_callback_add(tile, EVAS_CALLBACK_MOUSE_UP,
133 CicoHSMenuTouch::TouchUpMenu, appid);
135 evas_object_show(icon);
138 term_icon = evas_object_image_filled_add(evas);
139 evas_object_image_file_set(term_icon,
140 tzplatform_mkpath(TZ_SYS_RO_APP,
141 ICO_HS_MENUTILE_TERM_ICON_PATH), NULL);
142 evas_object_move(term_icon, pos_x + width - ICO_HS_MENUTILE_TERM_ICON_WIDTH, pos_y);
143 evas_object_resize(term_icon, ICO_HS_MENUTILE_TERM_ICON_WIDTH,
144 ICO_HS_MENUTILE_TERM_ICON_HEIGHT);
145 evas_object_event_callback_add(term_icon, EVAS_CALLBACK_MOUSE_DOWN,
146 CicoHSMenuTouch::TouchDownTerm, appid);
147 evas_object_event_callback_add(term_icon, EVAS_CALLBACK_MOUSE_UP,
148 CicoHSMenuTouch::TouchUpTerm, appid);
149 ICO_DBG("CicoHSMenuTile::CreateObject Leave(%s Tile=(%d,%d) w/h=%d/%d",
150 appid, pos_x, pos_y, width, height);
153 /*--------------------------------------------------------------------------*/
155 * @brief CicoHSMenuTile::ShowTermIcon
161 /*--------------------------------------------------------------------------*/
163 CicoHSMenuTile::ShowTermIcon()
165 evas_object_raise(term_icon);
166 evas_object_show(term_icon);
169 /*--------------------------------------------------------------------------*/
171 * @brief CicoHSMenuTile::HideTermIcon
177 /*--------------------------------------------------------------------------*/
179 CicoHSMenuTile::HideTermIcon(void)
181 evas_object_hide(term_icon);
184 /*--------------------------------------------------------------------------*/
186 * @brief CicoHSMenuTile::FreeObject
192 /*--------------------------------------------------------------------------*/
194 CicoHSMenuTile::FreeObject(void)
196 char sWork[PATH_MAX];
198 ICO_DBG("CicoHSMenuTile::FreeObject(appid=%p<%s>)", this->appid, appid);
201 sprintf(sWork, "%s/%08x.bpm", ICO_HS_THUMB_ICODIR ICO_HS_THUMB_FILEDIR,
203 (void) unlink(sWork);
204 ico_syc_unmap_thumb(thumb.surface);
207 if (thumb.thumb_timer) {
208 ecore_timer_del(thumb.thumb_timer);
209 thumb.thumb_timer = NULL;
212 evas_object_del(tile);
215 if (small_icon != NULL){
216 evas_object_del(small_icon);
219 if (thumb_tile != NULL) {
220 evas_object_del(thumb_tile);
223 if (term_icon != NULL) {
224 evas_object_del(term_icon);
229 /*--------------------------------------------------------------------------*/
231 * @brief CicoHSMenuTile::Resize
232 * resize tile(currently unused)
234 * @param[in] width width
235 * @param[in] height height
238 /*--------------------------------------------------------------------------*/
240 CicoHSMenuTile::Resize(int width, int height)
242 ICO_DBG("CicoHSMenuTile::Resize (%d,%d)-(%d,%d) Unused",
243 this->width, this->height, width, height);
246 /*--------------------------------------------------------------------------*/
248 * @brief CicoHSMenuTile::MovePosition
249 * move tile base position
251 * @param[in] page page
252 * @param[in] position position of tile
255 /*--------------------------------------------------------------------------*/
257 CicoHSMenuTile::MovePosition(int page, int position)
260 this->position= position;
261 pos_x = GetPositionX();
262 pos_y = GetPositionY();
264 ICO_DBG("CicoHSMenuTile::MovePosition(appid=%p<%s> tile=(%d,%d))",
265 this->appid, appid, pos_x, pos_y);
267 evas_object_move(tile, pos_x, pos_y);
269 evas_object_move(thumb_tile, pos_x + thumb_reduce_x, pos_y + thumb_reduce_y);
272 evas_object_move(small_icon,
273 pos_x + thumb_reduce_x - ICO_HS_MENUTILE_THUMBNAIL_REDUCE_PIX2,
274 pos_y + height - thumb_reduce_y - height
275 / ICO_HS_MENUTILE_THUMBNAIL_REDUCTION
276 + ICO_HS_MENUTILE_THUMBNAIL_REDUCE_PIX2);
278 evas_object_move(term_icon, pos_x + width - ICO_HS_MENUTILE_TERM_ICON_WIDTH, pos_y);
281 /*--------------------------------------------------------------------------*/
283 * @brief CicoHSMenuTile::OffsetMove
284 * move from base position
286 * @param[in] offset_x offset_x from base position
287 * @param[in] offset_y offset_y from base position
290 /*--------------------------------------------------------------------------*/
292 CicoHSMenuTile::OffsetMove(int offset_x, int offset_y)
294 pos_x = GetPositionX() + offset_x;
295 pos_y = GetPositionY() + offset_y;
297 ICO_DBG("CicoHSMenuTile::OffsetMove(appid=%p<%s> offset=%d,%d tile=(%d,%d) obj=%p %p %p)",
298 this->appid, appid, offset_x, offset_y, pos_x, pos_y,
299 this->icon, this->tile, this->thumb_tile);
301 evas_object_move(tile, pos_x, pos_y);
303 evas_object_move(thumb_tile, pos_x + thumb_reduce_x, pos_y + thumb_reduce_y);
306 evas_object_move(small_icon,
307 pos_x + thumb_reduce_x - ICO_HS_MENUTILE_THUMBNAIL_REDUCE_PIX2,
308 pos_y + height - thumb_reduce_y - height
309 / ICO_HS_MENUTILE_THUMBNAIL_REDUCTION
310 + ICO_HS_MENUTILE_THUMBNAIL_REDUCE_PIX2);
312 evas_object_move(term_icon, pos_x + width - ICO_HS_MENUTILE_TERM_ICON_WIDTH, pos_y);
315 /*--------------------------------------------------------------------------*/
317 * @brief CicoHSMenuTile::GetImagePath
318 * get icon image path
321 * @return icon image path
323 /*--------------------------------------------------------------------------*/
325 CicoHSMenuTile::GetImagePath(void)
327 return icon_image_path;
330 /*--------------------------------------------------------------------------*/
332 * @brief CicoHSMenuTile::GetAppId
336 * @return application id
338 /*--------------------------------------------------------------------------*/
340 CicoHSMenuTile::GetAppId(void)
345 /*--------------------------------------------------------------------------*/
347 * @brief CicoHSMenuTile::GetWidth
353 /*--------------------------------------------------------------------------*/
355 CicoHSMenuTile::GetWidth(void)
360 /*--------------------------------------------------------------------------*/
362 * @brief CicoHSMenuTile::GetHeight
368 /*--------------------------------------------------------------------------*/
370 CicoHSMenuTile::GetHeight(void)
375 /*--------------------------------------------------------------------------*/
377 * @brief CicoHSMenuTile::GetPosition
383 /*--------------------------------------------------------------------------*/
385 CicoHSMenuTile::GetPosition(void)
390 /*--------------------------------------------------------------------------*/
392 * @brief CicoHSMenuTile::GetPage
398 /*--------------------------------------------------------------------------*/
400 CicoHSMenuTile::GetPage(void)
405 /*--------------------------------------------------------------------------*/
407 * @brief CicoHSMenuTile::GetSubPage
413 /*--------------------------------------------------------------------------*/
415 CicoHSMenuTile::GetSubPage(void)
420 /*--------------------------------------------------------------------------*/
422 * @brief CicoHSMenuTile::GetPositionX
428 /*--------------------------------------------------------------------------*/
430 CicoHSMenuTile::GetPositionX(void)
434 if ((position == ICO_HS_MENUTILE_POSITION_0) ||
435 (position == ICO_HS_MENUTILE_POSITION_3) ||
436 (position == ICO_HS_MENUTILE_POSITION_6) ||
437 (position == ICO_HS_MENUTILE_POSITION_9)) {
438 ret = ICO_HS_MENUTILE_START_POS_X;
440 else if ((position == ICO_HS_MENUTILE_POSITION_1) ||
441 (position == ICO_HS_MENUTILE_POSITION_4) ||
442 (position == ICO_HS_MENUTILE_POSITION_7) ||
443 (position == ICO_HS_MENUTILE_POSITION_10)) {
444 ret = ICO_HS_MENUTILE_START_POS_X +
445 (CicoHSMenuWindow::Tile_Width() + ICO_HS_MENUTILE_SPACE_TILE_AND_TILE);
447 else if ((position == ICO_HS_MENUTILE_POSITION_2) ||
448 (position == ICO_HS_MENUTILE_POSITION_5) ||
449 (position == ICO_HS_MENUTILE_POSITION_8) ||
450 (position == ICO_HS_MENUTILE_POSITION_11)) {
451 ret = ICO_HS_MENUTILE_START_POS_X +
452 ((CicoHSMenuWindow::Tile_Width() + ICO_HS_MENUTILE_SPACE_TILE_AND_TILE) * 2);
457 /*--------------------------------------------------------------------------*/
459 * @brief CicoHSMenuTile::GetPositionY
465 /*--------------------------------------------------------------------------*/
467 CicoHSMenuTile::GetPositionY(void)
471 if ((position == ICO_HS_MENUTILE_POSITION_0) ||
472 (position == ICO_HS_MENUTILE_POSITION_1) ||
473 (position == ICO_HS_MENUTILE_POSITION_2)) {
474 ret = ICO_HS_MENUTILE_START_POS_Y;
476 else if ((position == ICO_HS_MENUTILE_POSITION_3) ||
477 (position == ICO_HS_MENUTILE_POSITION_4) ||
478 (position == ICO_HS_MENUTILE_POSITION_5)) {
479 ret = ICO_HS_MENUTILE_START_POS_Y +
480 (CicoHSMenuWindow::Tile_Height() + ICO_HS_MENUTILE_SPACE_TILE_AND_TILE);
482 else if ((position == ICO_HS_MENUTILE_POSITION_6) ||
483 (position == ICO_HS_MENUTILE_POSITION_7) ||
484 (position == ICO_HS_MENUTILE_POSITION_8)) {
485 ret = ICO_HS_MENUTILE_START_POS_Y +
486 ((CicoHSMenuWindow::Tile_Height() + ICO_HS_MENUTILE_SPACE_TILE_AND_TILE) * 2);
488 else if ((position == ICO_HS_MENUTILE_POSITION_9) ||
489 (position == ICO_HS_MENUTILE_POSITION_10) ||
490 (position == ICO_HS_MENUTILE_POSITION_11)) {
491 ret = ICO_HS_MENUTILE_START_POS_Y +
492 ((CicoHSMenuWindow::Tile_Height() + ICO_HS_MENUTILE_SPACE_TILE_AND_TILE) * 3);
497 /*--------------------------------------------------------------------------*/
499 * @brief CicoHSMenuTile::ValidMenuIcon
500 * tile is icon(app terminated)
505 /*--------------------------------------------------------------------------*/
507 CicoHSMenuTile::ValidMenuIcon(void)
510 ICO_DBG("CicoHSMenuTile::ValidMenuIcon: %s show icon", appid);
512 free(thumb.pixel_data);
513 thumb.pixel_data = NULL;
514 if (icon == thumb_tile) {
517 evas_object_hide(thumb_tile);
520 evas_object_show(tile);
523 if (thumb.thumb_timer) {
524 ecore_timer_del(thumb.thumb_timer);
525 thumb.thumb_timer = NULL;
528 evas_object_hide(small_icon);
533 /*--------------------------------------------------------------------------*/
535 * @brief CicoHSMenuTile::ValidThumbnail
536 * tile is thumbnail(app started)
538 * @param[in] surface surface
541 /*--------------------------------------------------------------------------*/
543 CicoHSMenuTile::ValidThumbnail(int surface)
545 char sWork[PATH_MAX];
547 ICO_DBG("CicoHSMenuTile::ValidThumbnail(appid=%p<%s>) run=%d surf=%08x",
548 this->appid, appid, app_running, surface);
550 thumb.orgsurface = surface;
552 if ((! app_running) || (surface == 0)) {
553 if (thumb.surface != 0) {
554 sprintf(sWork, ICO_HS_THUMB_ICODIR ICO_HS_THUMB_FILEDIR "/%08x."
555 ICO_HS_THUMB_FILEEXT, thumb.surface);
556 (void) unlink(sWork);
557 ico_syc_unmap_thumb(thumb.surface);
559 free(thumb.pixel_data);
560 thumb.pixel_data = NULL;
563 thumb.surface = surface;
566 sprintf(sWork, ICO_HS_THUMB_ICODIR ICO_HS_THUMB_FILEDIR "/%08x."
567 ICO_HS_THUMB_FILEEXT, thumb.surface);
568 (void) unlink(sWork);
569 ico_syc_map_thumb(thumb.surface,
570 menu_show ? ICO_HS_MENUTILE_THUMBNAIL_FPS_SHOW :
571 ICO_HS_MENUTILE_THUMBNAIL_FPS_HIDE, sWork);
573 small_icon = evas_object_image_filled_add(menu_evas);
574 evas_object_image_file_set(small_icon, icon_image_path, NULL);
575 evas_object_move(small_icon,
576 pos_x + thumb_reduce_x
577 - ICO_HS_MENUTILE_THUMBNAIL_REDUCE_PIX2,
578 pos_y + height - thumb_reduce_y - height
579 / ICO_HS_MENUTILE_THUMBNAIL_REDUCTION
580 + ICO_HS_MENUTILE_THUMBNAIL_REDUCE_PIX2);
581 evas_object_resize(small_icon, width / ICO_HS_MENUTILE_THUMBNAIL_REDUCTION,
582 height / ICO_HS_MENUTILE_THUMBNAIL_REDUCTION);
583 evas_object_event_callback_add(small_icon, EVAS_CALLBACK_MOUSE_DOWN,
584 CicoHSMenuTouch::TouchDownMenu, appid);
585 evas_object_event_callback_add(small_icon, EVAS_CALLBACK_MOUSE_UP,
586 CicoHSMenuTouch::TouchUpMenu, appid);
587 evas_object_raise(small_icon);
588 evas_object_raise(term_icon);
590 evas_object_show(small_icon);
591 ICO_DBG("CicoHSMenuTile::ValidThumbnail: %s(%08x) show small icon",
596 if (icon == thumb_tile) {
597 ICO_DBG("CicoHSMenuTile::ValidThumbnail: %s change thumb->icon", appid);
600 evas_object_hide(thumb_tile);
602 evas_object_show(tile);
605 evas_object_hide(small_icon);
607 if (thumb.thumb_timer) {
608 ecore_timer_del(thumb.thumb_timer);
609 thumb.thumb_timer = NULL;
611 ICO_DBG("CicoHSMenuTile::ValidThumbnail: %s(%08x) hide small icon",
617 /*--------------------------------------------------------------------------*/
619 * @brief CicoHSMenuTile::RetryThumbnail
620 * check and retry thumbnail
625 /*--------------------------------------------------------------------------*/
627 CicoHSMenuTile::RetryThumbnail(void)
629 thumb.thumb_timer = NULL;
631 ICO_DBG("CicoHSMenuTile::RetryThumbnaili: surf=%08x app=%s", thumb.orgsurface, appid);
633 if ((icon == tile) && (thumb.orgsurface != 0)) {
635 ValidThumbnail(thumb.orgsurface);
639 /*--------------------------------------------------------------------------*/
641 * @brief CicoHSMenuTile::SetThumbnail
644 * @param[in] info thumbnail information, if NULL reset thumbnail
647 /*--------------------------------------------------------------------------*/
649 CicoHSMenuTile::SetThumbnail(ico_syc_thumb_info_t *info)
651 Evas_Object *old_icon = icon;
655 char sWork[PATH_MAX];
656 #if 0 /* for BMP format */
657 #pragma pack(push, 1)
679 ICO_DBG("CicoHSMenuTile::SetThumbnail(appid=%p<%s>) info=%p surf=%08x",
680 this->appid, appid, info, info ? info->surface : 0);
682 if ((info == NULL) || (info->surface == 0)) {
687 if (thumb.surface != info->surface) {
688 if (thumb.surface != 0) {
689 ICO_DBG("CicoHSMenuTile::SetThumbnail: surface change(%08x->%08x)",
690 thumb.surface, info->surface);
691 ico_syc_unmap_thumb(thumb.surface);
692 sprintf(sWork, ICO_HS_THUMB_ICODIR ICO_HS_THUMB_FILEDIR "/%08x."
693 ICO_HS_THUMB_FILEEXT, thumb.surface);
694 (void) unlink(sWork);
696 thumb.surface = info->surface;
697 sprintf(sWork, ICO_HS_THUMB_ICODIR ICO_HS_THUMB_FILEDIR "/%08x."
698 ICO_HS_THUMB_FILEEXT, thumb.surface);
699 ico_syc_map_thumb(thumb.surface,
700 menu_show ? ICO_HS_MENUTILE_THUMBNAIL_FPS_SHOW :
701 ICO_HS_MENUTILE_THUMBNAIL_FPS_HIDE, sWork);
704 sprintf(sWork, ICO_HS_THUMB_ICODIR ICO_HS_THUMB_FILEDIR "/%08x."
705 ICO_HS_THUMB_FILEEXT, thumb.surface);
707 thumb.type = info->type;
708 thumb.width = info->width;
709 thumb.height = info->height;
710 thumb.stride = info->stride;
711 thumb.format = info->format;
712 #if 0 /* too many log */
713 ICO_DBG("CicoHSMenuTile::SetThumbnail: make thumbnail %s(%08x) "
714 "type=%d w/h/s=%d/%d/%d tile w/h=%d/%d",
715 appid, thumb.surface, thumb.type,
716 thumb.width, thumb.height, thumb.stride, width, height);
718 if ((info->width <= 1) || (info->height <= 1)) {
719 ICO_DBG("CicoHSMenuTile::SetThumbnail: small surface(%d,%d) skip",
720 info->width, info->height);
723 // create thumbnail image
724 svx = thumb_reduce_x;
725 svy = thumb_reduce_y;
726 if (thumb.width > (thumb.height + 64)) {
727 thumb_reduce_x = ICO_HS_MENUTILE_THUMBNAIL_REDUCE_PIX;
728 thumb_reduce_y = height / ICO_HS_MENUTILE_THUMBNAIL_REDUCE_RATE;
730 else if (thumb.width < (thumb.height - 64)) {
731 thumb_reduce_y = ICO_HS_MENUTILE_THUMBNAIL_REDUCE_PIX;
732 thumb_reduce_x = width / ICO_HS_MENUTILE_THUMBNAIL_REDUCE_RATE;
735 thumb_reduce_x = ICO_HS_MENUTILE_THUMBNAIL_REDUCE_PIX;
736 thumb_reduce_y = ICO_HS_MENUTILE_THUMBNAIL_REDUCE_PIX;
739 thumb_tile = evas_object_image_filled_add(menu_evas);
740 evas_object_resize(thumb_tile, width - thumb_reduce_x * 2,
741 height - thumb_reduce_y * 2);
742 evas_object_move(thumb_tile, pos_x + thumb_reduce_x,
743 pos_y + thumb_reduce_y);
744 evas_object_event_callback_add(thumb_tile, EVAS_CALLBACK_MOUSE_DOWN,
745 CicoHSMenuTouch::TouchDownMenu, appid);
746 evas_object_event_callback_add(thumb_tile, EVAS_CALLBACK_MOUSE_UP,
747 CicoHSMenuTouch::TouchUpMenu, appid);
748 ICO_DBG("CicoHSMenuTile::SetThumbnail: create thumb_tile %s "
749 "tile=(%d+%d,%d+%d)", appid,
750 pos_x, thumb_reduce_x, pos_y, thumb_reduce_y);
752 evas_object_move(small_icon,
753 pos_x + thumb_reduce_x
754 - ICO_HS_MENUTILE_THUMBNAIL_REDUCE_PIX2,
755 pos_y + height - thumb_reduce_y - height
756 / ICO_HS_MENUTILE_THUMBNAIL_REDUCTION
757 + ICO_HS_MENUTILE_THUMBNAIL_REDUCE_PIX2);
758 evas_object_raise(small_icon);
760 evas_object_raise(term_icon);
762 else if ((svx != thumb_reduce_x) || (svy != thumb_reduce_y)) {
763 evas_object_resize(thumb_tile, width - thumb_reduce_x * 2,
764 height - thumb_reduce_y * 2);
765 evas_object_move(thumb_tile, pos_x + thumb_reduce_x,
766 pos_y + thumb_reduce_y);
768 evas_object_move(small_icon,
769 pos_x + thumb_reduce_x
770 - ICO_HS_MENUTILE_THUMBNAIL_REDUCE_PIX2,
771 pos_y + height - thumb_reduce_y - height
772 / ICO_HS_MENUTILE_THUMBNAIL_REDUCTION
773 + ICO_HS_MENUTILE_THUMBNAIL_REDUCE_PIX2);
776 /* read surface image pixel */
777 int bufsize = ((thumb.width * thumb.height * 4 + 4095) / 4096) * 4096;
778 if ((! thumb.pixel_data) || (bufsize > thumb.pixel_bufsize)) {
779 free(thumb.pixel_data);
780 thumb.pixel_data = (char *)malloc(bufsize);
781 thumb.pixel_bufsize = bufsize;
782 if (thumb.pixel_data) {
783 memset(thumb.pixel_data, 0, bufsize);
786 if (thumb.pixel_data) {
787 fd = open(sWork, O_RDONLY, 0644);
789 #if 0 /* for BMP format */
790 if (read(fd, &bmphead, sizeof(bmphead)) != sizeof(bmphead)) {
791 ICO_ERR("CicoHSMenuTile::SetThumbnail: can not read pixel file(%s)",
796 if (read(fd, thumb.pixel_data, bufsize) <= 0) {
797 ICO_ERR("CicoHSMenuTile::SetThumbnail: can not read pixel file(%s)",
802 ICO_DBG("CicoHSMenuTile::SetThumbnail: can not open pixel file(%s)",
807 (void) unlink(sWork);
809 evas_object_image_data_update_add(
810 thumb_tile, 0, 0, thumb.width, thumb.height);
812 evas_object_image_size_set(thumb_tile, thumb.width, thumb.height);
813 evas_object_image_data_set(thumb_tile, thumb.pixel_data);
814 evas_object_image_filled_set(thumb_tile, EINA_TRUE);
815 evas_object_resize(thumb_tile, width - thumb_reduce_x * 2,
816 height - thumb_reduce_y * 2);
817 evas_object_move(thumb_tile,
818 pos_x + thumb_reduce_x, pos_y + thumb_reduce_y);
821 ICO_ERR("CicoHSMenuTile::SetThumbnail: can not malloc pixel buffer");
828 ICO_DBG("CicoHSMenuTile::SetThumbnail: unmap thumbnail %08x", thumb.surface);
830 sprintf(sWork, ICO_HS_THUMB_ICODIR ICO_HS_THUMB_FILEDIR "/%08x."
831 ICO_HS_THUMB_FILEEXT, thumb.surface);
832 (void) unlink(sWork);
833 ico_syc_unmap_thumb(thumb.surface);
836 free(thumb.pixel_data);
837 thumb.pixel_data = NULL;
839 if (thumb.thumb_timer) {
840 ecore_timer_del(thumb.thumb_timer);
842 thumb.thumb_timer = ecore_timer_add(ICO_HS_MENUTILE_THUMBNAIL_RETRYTIME,
843 CicoHSMenuTile::TimerThumbnail, (void *)this);
846 if (icon != old_icon) {
848 evas_object_hide(old_icon);
850 evas_object_show(icon);
852 if (icon == thumb_tile) {
853 evas_object_show(small_icon);
854 // remake thumbnail for first build image
855 CicoHSMenuTile::SetThumbnail(info);
858 evas_object_hide(small_icon);
864 /*--------------------------------------------------------------------------*/
866 * @brief CicoHSMenuTile::TimerThumbnail
869 * @param[in] data CicoHSMenuTile object
870 * @return fixed ECORE_CALLBACK_CANCEL
872 /*--------------------------------------------------------------------------*/
874 CicoHSMenuTile::TimerThumbnail(void *data)
876 CicoHSMenuTile *tile = (CicoHSMenuTile *)data;
878 tile->RetryThumbnail();
880 return ECORE_CALLBACK_CANCEL;
883 /*--------------------------------------------------------------------------*/
885 * @brief CicoHSMenuTile::ShowMenu
886 * change menu show/hide for live thumbnail update cycle
888 * @param[in] show surface
889 * @return nonmenu show(true)/fide(false)
891 /*--------------------------------------------------------------------------*/
893 CicoHSMenuTile::ShowMenu(bool show)
895 char sWork[PATH_MAX];
897 if ((thumb_tile) && (thumb.surface != 0)) {
898 sprintf(sWork, ICO_HS_THUMB_ICODIR ICO_HS_THUMB_FILEDIR "/%08x."
899 ICO_HS_THUMB_FILEEXT, thumb.surface);
900 (void) unlink(sWork);
901 ico_syc_map_thumb(thumb.surface,
902 menu_show ? ICO_HS_MENUTILE_THUMBNAIL_FPS_SHOW :
903 ICO_HS_MENUTILE_THUMBNAIL_FPS_HIDE, sWork);
907 /*--------------------------------------------------------------------------*/
909 * @brief CicoHSMenuTile::SetOrgThumbnail
910 * set thumbnail form org tile
912 * @param[in] info org tile
915 /*--------------------------------------------------------------------------*/
917 CicoHSMenuTile::SetOrgThumbnail(CicoHSMenuTile *orgTile)
920 ICO_DBG("CicoHSMenuTile::SetOrgThumbnail Enter(appid=%p<%s>) run=%d surf=%08x",
921 this->appid, this->appid, app_running, orgTile->thumb.surface );
923 /* check surface of orgTile */
924 if ( orgTile == NULL || orgTile->thumb.surface == 0 ) {
929 this->ValidThumbnail( orgTile->thumb.surface );
931 /* set new thumbnail */
932 ico_syc_thumb_info_t info;
934 info.surface = orgTile->thumb.surface;
935 info.type = orgTile->thumb.type;
936 info.width = orgTile->thumb.width;
937 info.height = orgTile->thumb.height;
938 info.stride = orgTile->thumb.stride;
939 info.format = orgTile->thumb.format;
941 SetThumbnail( &info );
943 ICO_DBG("CicoHSMenuTile::SetOrgThumbnail Leave(appid=%p<%s>) run=%d surf=%08x",
944 this->appid, this->appid, app_running, orgTile->thumb.surface );
947 // vim: set expandtab ts=4 sw=4: