4 * Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Sangjin Han <sjhan.han@samsung.com>,
7 * Jiansong Jin <jiansong.jin@samsung.com>,
8 * Jonghyuk Lee <jhyuk47.lee@samsung.com>,
9 * Chaolong Lin <chaolong.lin@samsung.com>,
10 * Yongjun Zhao <yj123.zhao@samsung.com>
12 * Licensed under the Apache License, Version 2.0 (the "License");
13 * you may not use this file except in compliance with the License.
14 * You may obtain a copy of the License at
16 * http://www.apache.org/licenses/LICENSE-2.0
18 * Unless required by applicable law or agreed to in writing, software
19 * distributed under the License is distributed on an "AS IS" BASIS,
20 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21 * See the License for the specific language governing permissions and
22 * limitations under the License.
28 #include "ge-button.h"
30 #ifdef _USE_ROTATE_BG_GE
31 #include "ge-rotate-bg.h"
34 /* Album color level and alpha value */
35 #define GE_TILE_TEXT_COLOR_CNT 6
36 #define GE_TILE_TEXT_COLOR_ALPHA 255
38 typedef struct _ge_tile_color {
44 static ge_tile_color bg_color[] = {
54 int __ge_tile_get_1st_icon_item_idx(int count, int *idx)
57 if (count == GE_TILE_THUMB_2 ||
58 count == GE_ALBUM_COVER_THUMB_NUM_SEC)
60 else if (count == GE_TILE_THUMB_3)
62 else if (count > GE_ALBUM_COVER_THUMB_NUM_SEC){
63 if (count == GE_TILE_THUMB_5)
65 else if (count == GE_TILE_THUMB_6)
74 static Evas_Object *__ge_tile_add_3_icon_bg(Evas_Object *obj, int length,
75 double scale, bg_file_set_cb func,
76 void **data, const char *part)
83 Evas_Object *bg = NULL;
85 #ifdef _USE_ROTATE_BG_GE
86 if (!g_strcmp0(part, GT_TILE_3ICON1)) {
87 wid = (int)(GE_TILE_2X_GRID_S * scale);
90 } else if (!g_strcmp0(part, GT_TILE_3ICON2)) {
91 wid = (int)(GE_TILE_GRID_S * scale);
92 hei = (int)(GE_TILE_2X_GRID_S * scale);
98 bg = _ge_rotate_bg_add(obj);
101 evas_object_size_hint_min_set(bg, wid, hei);
102 evas_object_size_hint_max_set(bg, wid, hei);
103 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
105 evas_object_size_hint_align_set(bg, EVAS_HINT_FILL,
108 _ge_rotate_bg_add_image(bg, wid, hei);
115 Evas_Object *tb = elm_table_add(obj);
117 elm_table_homogeneous_set(tb, EINA_FALSE);
118 elm_table_padding_set(tb, GE_TILE_PAD * scale, GE_TILE_PAD * scale);
120 for (i = 0; i < length - 1; i++) {
124 wid = (int)(GE_TILE_2X_GRID_S * scale);
127 wid = (int)(GE_TILE_GRID_S * scale);
128 hei = (int)(GE_TILE_2X_GRID_S * scale);
131 elm_bg_load_size_set(bg, wid, hei);
132 evas_object_size_hint_min_set(bg, wid, hei);
133 elm_table_padding_set(tb, GE_TILE_PAD_2 * scale,
134 GE_TILE_PAD_2 * scale);
138 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
140 evas_object_size_hint_align_set(bg, 0.0, 1.0);
142 tp_val = EVAS_ASPECT_CONTROL_VERTICAL;
143 evas_object_size_hint_aspect_set(bg, tp_val, 1, 1);
146 elm_table_pack(tb, bg, 0, 0, 2, 2);
148 elm_table_pack(tb, bg, 2, 0, 1, 2);
149 evas_object_show(bg);
156 static Evas_Object *__ge_tile_add_4_icon_bg(Evas_Object *obj, int length,
157 double scale, bg_file_set_cb func,
158 void **data, const char *part)
165 Evas_Object *bg = NULL;
167 #ifdef _USE_ROTATE_BG_GE
168 if (!g_strcmp0(part, GT_TILE_4ICON1)) {
169 wid = (int)(GE_TILE_2X_GRID_S * scale);
172 } else if (!g_strcmp0(part, GT_TILE_4ICON3)) {
173 wid = (int)(GE_TILE_GRID_S * scale);
176 } else if (!g_strcmp0(part, GT_TILE_4ICON4)) {
177 wid = (int)(GE_TILE_GRID_S * scale);
184 bg = _ge_rotate_bg_add(obj);
187 evas_object_size_hint_min_set(bg, wid, hei);
188 evas_object_size_hint_max_set(bg, wid, hei);
189 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
191 evas_object_size_hint_align_set(bg, EVAS_HINT_FILL,
194 _ge_rotate_bg_add_image(bg, wid, hei);
200 Evas_Object *tb = elm_table_add(obj);
202 elm_table_homogeneous_set(tb, EINA_FALSE);
203 elm_table_padding_set(tb, GE_TILE_PAD_2 * scale,
204 GE_TILE_PAD_2 * scale);
205 for (i = 0; i < length; i++) {
212 wid = (int)(GE_TILE_2X_GRID_S * scale);
215 wid = (int)(GE_TILE_GRID_S * scale);
219 elm_bg_load_size_set(bg, wid, hei);
220 evas_object_size_hint_min_set(bg, wid, hei);
224 evas_object_size_hint_aspect_set(bg,
225 EVAS_ASPECT_CONTROL_VERTICAL,
227 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
229 evas_object_size_hint_align_set(bg, 0.0, 1.0);
232 elm_table_pack(tb, bg, 0, 0, 2, 2);
234 elm_table_pack(tb, bg, 2, 0, 1, 1);
236 elm_table_pack(tb, bg, 2, 1, 1, 1);
237 evas_object_show(bg);
244 static Evas_Object *__ge_tile_add_5_icon_bg(Evas_Object *obj, int length,
245 double scale, bg_file_set_cb func,
246 void **data, const char *part)
253 Evas_Object *bg = NULL;
255 #ifdef _USE_ROTATE_BG_GE
256 if (!g_strcmp0(part, GT_TILE_5ICON1)) {
257 wid = (int)(GE_TILE_2X_GRID_S * scale);
258 hei = (int)(GE_TILE_GRID_S * scale);
260 } else if (!g_strcmp0(part, GT_TILE_5ICON2)) {
261 wid = (int)(GE_TILE_2X_GRID_S * scale);
262 hei = (int)(GE_TILE_GRID_S * scale);
264 } else if (!g_strcmp0(part, GT_TILE_5ICON4)) {
265 wid = (int)(GE_TILE_GRID_S * scale);
268 } else if (!g_strcmp0(part, GT_TILE_5ICON5)) {
269 wid = (int)(GE_TILE_GRID_S * scale);
276 bg = _ge_rotate_bg_add(obj);
279 evas_object_size_hint_min_set(bg, wid, hei);
280 evas_object_size_hint_max_set(bg, wid, hei);
281 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
283 evas_object_size_hint_align_set(bg, EVAS_HINT_FILL,
286 _ge_rotate_bg_add_image(bg, wid, hei);
292 Evas_Object *tb = elm_table_add(obj);
294 elm_table_homogeneous_set(tb, EINA_FALSE);
295 elm_table_padding_set(tb, GE_TILE_PAD_2 * scale,
296 GE_TILE_PAD_2 * scale);
297 for (i = 0; i < length; i++) {
303 if (i == 0 || i == 1) {
304 wid = (int)(GE_TILE_2X_GRID_S * scale);
305 hei = (int)(GE_TILE_GRID_S * scale);
307 wid = (int)(GE_TILE_GRID_S * scale);
311 elm_bg_load_size_set(bg, wid, hei);
312 evas_object_size_hint_min_set(bg, wid, hei);
316 evas_object_size_hint_aspect_set(bg,
317 EVAS_ASPECT_CONTROL_VERTICAL,
319 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
321 evas_object_size_hint_align_set(bg, 0.5, 1.0);
323 elm_table_pack(tb, bg, 0, 0, 2, 1);
325 elm_table_pack(tb, bg, 0, 1, 2, 1);
327 elm_table_pack(tb, bg, 2, 0, 1, 1);
329 elm_table_pack(tb, bg, 2, 1, 1, 1);
330 evas_object_show(bg);
337 static Evas_Object *__ge_tile_add_6_icon_bg(Evas_Object *obj, int length,
338 double scale, bg_file_set_cb func,
339 void **data, const char *part)
346 Evas_Object *bg = NULL;
348 #ifdef _USE_ROTATE_BG_GE
349 if (!g_strcmp0(part, GT_TILE_6ICON1)) {
350 wid = (int)(GE_TILE_2X_GRID_S * scale);
351 hei = (int)(GE_TILE_GRID_S * scale);
353 } else if (!g_strcmp0(part, GT_TILE_6ICON3)) {
354 wid = (int)(GE_TILE_GRID_S * scale);
357 } else if (!g_strcmp0(part, GT_TILE_6ICON4)) {
358 wid = (int)(GE_TILE_GRID_S * scale);
361 } else if (!g_strcmp0(part, GT_TILE_6ICON5)) {
362 wid = (int)(GE_TILE_GRID_S * scale);
365 } else if (!g_strcmp0(part, GT_TILE_6ICON6)) {
366 wid = (int)(GE_TILE_GRID_S * scale);
373 bg = _ge_rotate_bg_add(obj);
376 evas_object_size_hint_min_set(bg, wid, hei);
377 evas_object_size_hint_max_set(bg, wid, hei);
378 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
380 evas_object_size_hint_align_set(bg, EVAS_HINT_FILL,
383 _ge_rotate_bg_add_image(bg, wid, hei);
389 Evas_Object *tb = elm_table_add(obj);
391 elm_table_homogeneous_set(tb, EINA_FALSE);
392 elm_table_padding_set(tb, GE_TILE_PAD_2 * scale,
393 GE_TILE_PAD_2 * scale);
394 for (i = 0; i < length; i++) {
401 wid = (int)(GE_TILE_2X_GRID_S * scale);
402 hei = (int)(GE_TILE_GRID_S * scale);
404 wid = (int)(GE_TILE_GRID_S * scale);
408 elm_bg_load_size_set(bg, wid, hei);
409 evas_object_size_hint_min_set(bg, wid, hei);
411 evas_object_size_hint_max_set(bg, wid, hei);
415 evas_object_size_hint_aspect_set(bg,
416 EVAS_ASPECT_CONTROL_VERTICAL,
418 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
420 evas_object_size_hint_align_set(bg, 0.0, 1.0);
422 elm_table_pack(tb, bg, 0, 0, 2, 1);
424 elm_table_pack(tb, bg, 2, 0, 1, 1);
426 elm_table_pack(tb, bg, 0, 1, 1, 1);
428 elm_table_pack(tb, bg, 1, 1, 1, 1);
430 elm_table_pack(tb, bg, 2, 1, 1, 1);
431 evas_object_show(bg);
438 static Evas_Object *__ge_tile_add_7_icon_bg(Evas_Object *obj, int length,
439 double scale, bg_file_set_cb func,
447 Evas_Object *bg = NULL;
449 Evas_Object *tb = elm_table_add(obj);
451 elm_table_homogeneous_set(tb, EINA_TRUE);
452 elm_table_padding_set(tb, GE_TILE_PAD * scale, GE_TILE_PAD * scale);
454 wid = (int)(GE_TILE_GRID_S * scale);
457 for (i = 1; i < length; i++) {
458 #ifdef _USE_ROTATE_BG_GE
459 bg = _ge_rotate_bg_add(tb);
465 #ifdef _USE_ROTATE_BG_GE
466 _ge_rotate_bg_add_image(bg, wid, hei);
468 elm_bg_load_size_set(bg, wid, hei);
473 evas_object_size_hint_aspect_set(bg,
474 EVAS_ASPECT_CONTROL_VERTICAL,
476 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND,
478 evas_object_size_hint_align_set(bg, EVAS_HINT_FILL,
480 elm_table_pack(tb, bg, (int)((i - 1) % 3), (int)((i - 1) / 3),
482 evas_object_show(bg);
488 Evas_Object *__ge_tile_add_1_icon_bg(Evas_Object *obj, int len, double scale,
489 bg_file_set_cb func, void **data)
493 Evas_Object *bg = NULL;
495 #ifdef _USE_ROTATE_BG_GE
496 bg = _ge_rotate_bg_add(obj);
498 bg = elm_bg_add(obj);
505 wid = (int)(GE_TILER_ICON_S * scale);
509 hei = (int)(GE_TILE_2X_GRID_S * scale);
511 #ifdef _USE_ROTATE_BG_GE
512 _ge_rotate_bg_add_image(bg, wid, hei);
514 elm_bg_load_size_set(bg, wid, hei);
519 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
520 evas_object_size_hint_align_set(bg, 0.5, 0.5);
521 evas_object_show(bg);
526 Evas_Object *__ge_tile_add_1st_icon_bg(Evas_Object *obj, int len, double scale,
527 bg_file_set_cb func, void **data)
531 Evas_Object *bg = NULL;
533 #ifdef _USE_ROTATE_BG_GE
534 bg = _ge_rotate_bg_add(obj);
536 bg = elm_bg_add(obj);
540 int wid = (int)(GE_TILE_GRID_S * scale);
543 #ifdef _USE_ROTATE_BG_GE
544 _ge_rotate_bg_add_image(bg, wid, hei);
546 elm_bg_load_size_set(bg, wid, hei);
550 __ge_tile_get_1st_icon_item_idx(len, &idx);
553 evas_object_size_hint_min_set(bg, wid, hei);
554 evas_object_size_hint_aspect_set(bg, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
555 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
556 evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
557 evas_object_show(bg);
561 Evas_Object *__ge_tile_add_icon(Evas_Object *obj, int len, double scale,
562 bg_file_set_cb func, void **data,
565 Evas_Object *icon = NULL;
568 case GE_TILE_THUMB_1:
570 case GE_TILE_THUMB_2:
571 icon = __ge_tile_add_1_icon_bg(obj, len, scale, func, data);
573 case GE_TILE_THUMB_3:
574 icon = __ge_tile_add_3_icon_bg(obj, len, scale, func, data, part);
576 case GE_ALBUM_COVER_THUMB_NUM_SEC:
577 icon = __ge_tile_add_4_icon_bg(obj, len, scale, func, data, part);
579 case GE_TILE_THUMB_5:
580 icon = __ge_tile_add_5_icon_bg(obj, len, scale, func, data, part);
582 case GE_TILE_THUMB_6:
583 icon = __ge_tile_add_6_icon_bg(obj, len, scale, func, data, part);
586 icon = __ge_tile_add_7_icon_bg(obj, len, scale, func, data);
591 evas_object_show(icon);
595 Evas_Object *_ge_tile_show_part_icon(Evas_Object *obj, const char *part,
596 int length, double scale,
597 bg_file_set_cb func, void **data)
600 GE_CHECK_NULL(strlen(part));
602 ge_dbg("part is %s", part);
604 if (!g_strcmp0(part, GT_TILE_ONLYICON)) {
605 if (length != GE_TILE_THUMB_1)
608 Evas_Object *bg = NULL;
609 bg = __ge_tile_add_1_icon_bg(obj, length, scale, func, data);
611 } else if (!g_strcmp0(part, GT_TILE_FIRSTICON)) {
612 if (length <= GE_TILE_THUMB_1)
615 Evas_Object *bg = NULL;
616 bg = __ge_tile_add_1st_icon_bg(obj, length, scale, func, data);
619 #ifdef _USE_ROTATE_BG_GE
620 if ((!g_strcmp0(part, GT_TILE_3ICON1)) ||
621 (!g_strcmp0(part, GT_TILE_3ICON2)) ||
622 (!g_strcmp0(part, GT_TILE_4ICON3)) ||
623 (!g_strcmp0(part, GT_TILE_4ICON4)) ||
624 (!g_strcmp0(part, GT_TILE_5ICON1)) ||
625 (!g_strcmp0(part, GT_TILE_5ICON2)) ||
626 (!g_strcmp0(part, GT_TILE_6ICON4)) ||
627 (!g_strcmp0(part, GT_TILE_6ICON5))) {
628 if (length <= GE_TILE_THUMB_2 || length > GE_TILE_THUMB_6)
631 Evas_Object *tb = NULL;
632 tb = __ge_tile_add_icon(obj, length, scale, func, data, part);
634 } else if (!g_strcmp0(part, GT_TILE_ICON)) {
635 Evas_Object *tb = NULL;
637 if (length == GE_TILE_THUMB_2)
638 tb = __ge_tile_add_1_icon_bg(obj, length, scale, func,
640 else if (length >= GE_ALBUM_COVER_THUMB_NUM)
641 tb = __ge_tile_add_7_icon_bg(obj, length, scale, func,
644 evas_object_show(tb);
648 if (!g_strcmp0(part, GT_TILE_ICON)) {
652 Evas_Object *tb = NULL;
653 tb = __ge_tile_add_icon(obj, length, scale, func, data);
660 Evas_Object *_ge_tile_show_part_label(Evas_Object *obj, int index,
665 Evas *evas = evas_object_evas_get(obj);
667 Evas_Object *bg = NULL;
668 bg = evas_object_rectangle_add(evas);
673 j = GE_TILE_TEXT_COLOR_CNT;
675 j = index % GE_TILE_TEXT_COLOR_CNT;
676 evas_object_color_set(bg, bg_color[j].r, bg_color[j].g, bg_color[j].b,
677 GE_TILE_TEXT_COLOR_ALPHA);
679 evas_object_size_hint_weight_set(bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
680 evas_object_size_hint_align_set(bg, EVAS_HINT_FILL, EVAS_HINT_FILL);
681 evas_object_show(bg);