From 7a9d253b4e660136cc7f726cb18cf5eaa437dba2 Mon Sep 17 00:00:00 2001 From: Jin Yoon Date: Tue, 1 Sep 2015 12:05:43 +0900 Subject: [PATCH] [Share-panel] Change the layout to the grid style Change-Id: I897314461a48656e239d662bc843528ccbb08c9b --- CMakeLists.txt | 3 +- include/conf.h | 4 +- include/{item.h => grid.h} | 15 ++- include/log.h | 5 + include/share_panel_internal.h | 1 + res/edje/item.edc | 60 ++-------- res/edje/page.edc | 51 +------- src/grid.c | 265 +++++++++++++++++++++++++++++++++++++++++ src/item.c | 180 ---------------------------- src/scroller.c | 29 +++-- src/share_panel.c | 4 +- src/ui_manager.c | 20 ++-- 12 files changed, 338 insertions(+), 299 deletions(-) rename include/{item.h => grid.h} (61%) create mode 100644 src/grid.c delete mode 100644 src/item.c diff --git a/CMakeLists.txt b/CMakeLists.txt index af5d529..fc8f1b1 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -12,7 +12,7 @@ SET(LOCALEDIR "${RESDIR}/locale") SET(SRCS src/index.c - src/item.c + src/grid.c src/ui_manager.c src/list.c src/page.c @@ -48,6 +48,7 @@ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") ADD_DEFINITIONS("-DEDJEDIR=\"${EDJEDIR}\"") ADD_DEFINITIONS("-DLOCALEDIR=\"${LOCALEDIR}\"") +ADD_DEFINITIONS("-DPACKAGE=\"${PACKAGE}\"") ADD_EXECUTABLE(${PROJECT_NAME} ${SRCS}) TARGET_LINK_LIBRARIES(${PROJECT_NAME} ${pkgs_LDFLAGS}) diff --git a/include/conf.h b/include/conf.h index 6e62b5c..6ef3098 100644 --- a/include/conf.h +++ b/include/conf.h @@ -25,7 +25,7 @@ #define ITEM_ICON_HEIGHT 63 /* ITEM_WIDTH is changed from 123 to 107 about 87% decrease because of resolution issues. */ -#define ITEM_WIDTH 107 +#define ITEM_WIDTH 118 /* ITEM_HEIGHT is changed from 166 to 144 about 87% decrease because of resolution issues. */ #define ITEM_HEIGHT 144 @@ -33,7 +33,7 @@ #define TITLE_HEIGHT 54 #define SCROLLER_HEIGHT 300 -#define LINE_MAX 4 +#define SHARE_PANEL_LINE_MAX 4 /* PANEL_HEIGHT is changed from 368 to 320 about 87% decrease because of resolution issues. */ #define PANEL_HEIGHT (SCROLLER_HEIGHT+INDEX_HEIGHT+TITLE_HEIGHT) diff --git a/include/item.h b/include/grid.h similarity index 61% rename from include/item.h rename to include/grid.h index a3c2d7e..059e592 100644 --- a/include/item.h +++ b/include/grid.h @@ -14,12 +14,17 @@ * limitations under the License. */ -#ifndef __TIZEN_SHARE_PANEL_ITEM_H__ -#define __TIZEN_SHARE_PANEL_ITEM_H__ +#ifndef __TIZEN_SHARE_PANEL_GRID_H__ +#define __TIZEN_SHARE_PANEL_GRID_H__ #include -extern Evas_Object *_item_create(Evas_Object *page, item_s *item_info); -extern void _item_destroy(Evas_Object *item); +extern Evas_Object *_grid_create(Evas_Object *page); +extern void _grid_destroy(Evas_Object *grid); -#endif /* __TIZEN_SHARE_PANEL_ITEM_H__ */ +extern Elm_Object_Item *_grid_append_item(Evas_Object *grid, item_s *item_info); +extern void _grid_remove_item(Evas_Object *grid, item_s *item_info); + +extern int _grid_count_item(Evas_Object *grid); + +#endif /* __TIZEN_SHARE_PANEL_GRID_H__ */ diff --git a/include/log.h b/include/log.h index b00f41f..7e5279e 100644 --- a/include/log.h +++ b/include/log.h @@ -22,6 +22,11 @@ #undef LOG_TAG #define LOG_TAG "SHARE_PANEL" +#if defined(D_) +#undef D_ +#endif +#define D_(str) dgettext(PACKAGE, str) + #if !defined(_D) #define _D(fmt, arg...) LOGD(fmt"\n", ##arg) #endif diff --git a/include/share_panel_internal.h b/include/share_panel_internal.h index cc51b40..307d144 100644 --- a/include/share_panel_internal.h +++ b/include/share_panel_internal.h @@ -69,6 +69,7 @@ struct _item { char *appid; char *name; char *icon; + Elm_Object_Item *grid_item; }; typedef struct _item item_s; diff --git a/res/edje/item.edc b/res/edje/item.edc index 0297308..91e316e 100644 --- a/res/edje/item.edc +++ b/res/edje/item.edc @@ -14,76 +14,38 @@ * limitations under the License. */ -styles { - style { - /* Font size is changed from 24 to 20 because of resolution issues. */ - name: "text_style"; - base: "font=Tizen:style=Regular font_size=20 color=#ffffff align=center style=shadow shadow_color=#000000bf wrap=mixed ellipsis=-1"; - tag: "br" "\n"; - tag: "hilight" "+ font_weight=Bold"; - tag: "b" "+ font_weight=Bold"; - tag: "tab" "\t"; - } -} - collections { base_scale: 1.7; group { - name: "item"; + name: "grid,icon"; parts { part { name: "bg"; - type: SWALLOW; - mouse_events: 1; + type: RECT; + scale: 1; + mouse_events: 0; description { state: "default" 0.0; rel1 { relative: 0.0 0.0; } rel2 { relative: 1.0 1.0; } + color: 255 255 255 0; + visible: 1; } } part { name: "icon"; type: SWALLOW; - mouse_events: 1; - scale: 1; - description { - state: "default" 0.0; - rel1 { relative: 0.1 0.1; to: "bg"; } - rel2 { relative: 0.9 0.66; to: "bg"; } - color: 255 255 255 255; - visible: 1; - } - } - part { - name: "name"; - type: TEXTBLOCK; - mouse_events: 1; scale: 1; - description { - state: "default" 0.0; - rel1 { relative: 0.0 0.7; to: "bg"; } - rel2 { relative: 1.0 1.0; to: "bg"; } - align: 0.5 0.0; - color: 0 0 0 100; - text { - style: "text_style"; - align: 0.5 0.0; - } - visible: 1; - } - } - part { - name: "button"; - type: SWALLOW; mouse_events: 1; - repeat_events: 1; description { state: "default" 0.0; - rel1 { relative: 0.0 0.0; to: "bg"; } - rel2 { relative: 1.0 1.0; to: "bg"; } + rel1 { relative: 0.5 0.55; to: "bg"; } + rel2 { relative: 0.5 0.55; to: "bg"; } + fixed: 1 1; + align: 0.5 0.5; visible: 1; } } - } //parts + } } } //collections diff --git a/res/edje/page.edc b/res/edje/page.edc index 0bbc85c..d5264dc 100644 --- a/res/edje/page.edc +++ b/res/edje/page.edc @@ -14,39 +14,6 @@ * limitations under the License. */ -#define ITEM(part_name, relx, rely) \ - part { \ - name: "item_swallow_"part_name; \ - type: SWALLOW; \ - scale: 1; \ - mouse_events: 1; \ - description { \ - state: "default" 0.0; \ - visible: 1; \ - fixed: 1 1; \ - rel1 { relative: (relx) (rely); to, "frame"; } \ - rel2 { relative: (relx) (rely); to, "frame"; } \ - } \ - } \ - -#define ITEM_00_X (1.0/8.0) -#define ITEM_00_Y (1.0/4.0) -#define ITEM_01_X (3.0/8.0) -#define ITEM_01_Y ITEM_00_Y -#define ITEM_02_X (5.0/8.0) -#define ITEM_02_Y ITEM_00_Y -#define ITEM_03_X (7.0/8.0) -#define ITEM_03_Y ITEM_00_Y - -#define ITEM_04_X ITEM_00_X -#define ITEM_04_Y (3.0/4.0) -#define ITEM_05_X ITEM_01_X -#define ITEM_05_Y ITEM_04_Y -#define ITEM_06_X ITEM_02_X -#define ITEM_06_Y ITEM_04_Y -#define ITEM_07_X ITEM_03_X -#define ITEM_07_Y ITEM_04_Y - collections { base_scale: 1.7; group { @@ -65,23 +32,17 @@ collections { } } part { - name: "frame"; - type: SPACER; + name: "grid"; + type: SWALLOW; scale: 1; description { state: "default" 0.0; - rel1 { relative: 24/540 0.05; to: "bg"; } - rel2 { relative: (540-24)/540 0.95; to: "bg"; } + rel1.to: "bg"; + rel2.to: "bg"; + visible: 1; + fixed: 1 1; } } - ITEM("0", ITEM_00_X, ITEM_00_Y) - ITEM("1", ITEM_01_X, ITEM_01_Y) - ITEM("2", ITEM_02_X, ITEM_02_Y) - ITEM("3", ITEM_03_X, ITEM_03_Y) - ITEM("4", ITEM_04_X, ITEM_04_Y) - ITEM("5", ITEM_05_X, ITEM_05_Y) - ITEM("6", ITEM_06_X, ITEM_06_Y) - ITEM("7", ITEM_07_X, ITEM_07_Y) } } // group } // collections diff --git a/src/grid.c b/src/grid.c new file mode 100644 index 0000000..0ef0982 --- /dev/null +++ b/src/grid.c @@ -0,0 +1,265 @@ +/* + * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved + * + * Licensed under the Apache License, Version 2.0 (the License); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an AS IS BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#include +#include +#include + +#include "share_panel_internal.h" +#include "conf.h" +#include "grid.h" +#include "log.h" + + + +static const char *const FILE_LAYOUT_EDJ = EDJEDIR"/layout.edj"; +static struct { + Elm_Gengrid_Item_Class *gic; + char *default_icon; + + int index; +} grid_info = { + .gic = NULL, + .default_icon = "/usr/share/icons/A01-1_icon_Menu.png", + + .index = 0, +}; + + + +static char *__text_get(void *data, Evas_Object *obj, const char *part) +{ + item_s *info = data; + retv_if(!info, NULL); + + retv_if(!info->name, NULL); + if (!strcmp(part, "elm.text")) { + return strdup(D_(info->name)); + } + + return NULL; +} + + + +#define FILE_ITEM_EDJ EDJEDIR"/item.edj" +static Evas_Object *__add_icon(Evas_Object *parent, const char *file) +{ + const char *real_icon_file = NULL; + Evas_Object *icon = NULL; + Evas_Object *icon_layout = NULL; + + real_icon_file = file; + if (access(real_icon_file, R_OK) != 0) { + _E("Failed to access an icon(%s)", real_icon_file); + real_icon_file = DEFAULT_ICON; + } + + icon = elm_icon_add(parent); + retv_if(!icon, NULL); + + if (elm_image_file_set(icon, real_icon_file, NULL) == EINA_FALSE) { + _E("Icon file is not accessible (%s)", real_icon_file); + evas_object_del(icon); + return NULL; + } + + evas_object_size_hint_min_set(icon, ELM_SCALE_SIZE(ITEM_ICON_WIDTH), ELM_SCALE_SIZE(ITEM_ICON_HEIGHT)); + + elm_image_preload_disabled_set(icon, EINA_TRUE); + elm_image_smooth_set(icon, EINA_TRUE); + elm_image_no_scale_set(icon, EINA_FALSE); + evas_object_show(icon); + + icon_layout = elm_layout_add(parent); + retv_if(!icon_layout, NULL); + + elm_layout_file_set(icon_layout, FILE_ITEM_EDJ, "grid,icon"); + evas_object_size_hint_weight_set(icon_layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(icon_layout, EVAS_HINT_FILL, EVAS_HINT_FILL); + evas_object_show(icon_layout); + + elm_object_part_content_set(icon_layout, "icon", icon); + + return icon_layout; +} + + + +static Evas_Object *__content_get(void *data, Evas_Object *obj, const char *part) +{ + item_s *info = data; + + retv_if(!info, NULL); + + if (!strcmp(part, "elm.swallow.end")) { + Evas_Object *bg = evas_object_rectangle_add(evas_object_evas_get(obj)); + retv_if(!bg, NULL); + + evas_object_size_hint_min_set(bg, ELM_SCALE_SIZE(ITEM_WIDTH), ELM_SCALE_SIZE(ITEM_HEIGHT)); + evas_object_color_set(bg, 0, 0, 0, 0); + evas_object_show(bg); + return bg; + } else if (!strcmp(part, "elm.swallow.icon")) { + retv_if(!info->icon, NULL); + return __add_icon(obj, info->icon); + } else if (!strcmp(part, "selected")) { + + } + return NULL; +} + + + +static void __del(void *data, Evas_Object *obj) +{ + ret_if(NULL == data); +} + + + +static void __item_selected(void *data, Evas_Object *obj, void *event_info) +{ + item_s *item_info = data; + Elm_Object_Item *selected_item = NULL; + + int ret = 0; + + ret_if(!item_info); + ret_if(!item_info->appid); + ret_if(!item_info->b); + _D("item clicked, launch app : %s", item_info->appid); + + selected_item = elm_gengrid_selected_item_get(obj); + ret_if(!selected_item); + elm_gengrid_item_selected_set(selected_item, EINA_FALSE); + + + ret = aul_forward_app(item_info->appid, item_info->b); + if (ret < 0) { + _E("Fail to launch app(%d)", ret); + } + + ui_app_exit(); +} + + + +static void __lang_changed_cb(void *data, Evas_Object *grid, void *event_info) +{ + ret_if(!grid); + elm_gengrid_realized_items_update(grid); +} + + + +Evas_Object *_grid_create(Evas_Object *page) +{ + Evas_Object *grid = NULL; + + retv_if(!page, NULL); + + grid = elm_gengrid_add(page); + goto_if(!grid, ERROR); + + evas_object_size_hint_weight_set(grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); + evas_object_size_hint_align_set(grid, EVAS_HINT_FILL, EVAS_HINT_FILL); + + elm_gengrid_item_size_set(grid, ELM_SCALE_SIZE(ITEM_WIDTH), ELM_SCALE_SIZE(ITEM_HEIGHT)); + elm_gengrid_align_set(grid, 0.0, 0.0); + elm_gengrid_horizontal_set(grid, EINA_FALSE); + elm_gengrid_multi_select_set(grid, EINA_FALSE); + + grid_info.gic = elm_gengrid_item_class_new(); + goto_if(!grid_info.gic, ERROR); + grid_info.gic->func.text_get = __text_get; + grid_info.gic->func.content_get = __content_get; + grid_info.gic->func.state_get = NULL; + grid_info.gic->func.del = __del; + grid_info.gic->item_style = "type2"; + + evas_object_smart_callback_add(grid, "language,changed", __lang_changed_cb, NULL); + + elm_scroller_movement_block_set(grid, ELM_SCROLLER_MOVEMENT_BLOCK_VERTICAL); + evas_object_show(grid); + + return grid; + +ERROR: + _grid_destroy(grid); + return NULL; +} + + + +void _grid_destroy(Evas_Object *grid) +{ + ret_if(!grid); + + evas_object_del(grid); +} + + + +Elm_Object_Item *_grid_append_item(Evas_Object *grid, item_s *item_info) +{ + Elm_Object_Item *item = NULL; + + retv_if(!grid, NULL); + retv_if(!item_info, NULL); + + retv_if(!grid_info.gic, NULL); + + item = elm_gengrid_item_append(grid, grid_info.gic, item_info, __item_selected, item_info); + retv_if(!item, NULL); + if (item_info->name) { + _D("grid append item : %s", item_info->name); + } + item_info->grid_item = item; + elm_gengrid_item_show(item, ELM_GENGRID_ITEM_SCROLLTO_NONE); + elm_gengrid_item_update(item); + + return item; +} + + + +void _grid_remove_item(Evas_Object *grid, item_s *item_info) +{ + Elm_Object_Item *item = NULL; + + ret_if(!grid); + ret_if(!item_info); + + item = item_info->grid_item; + + ret_if(!item); + elm_object_item_del(item); + item_info->grid_item = NULL; +} + + + +int _grid_count_item(Evas_Object *grid) +{ + int count = 0; + + retv_if(!grid, 0); + + count = elm_gengrid_items_count(grid); + + return count; +} diff --git a/src/item.c b/src/item.c deleted file mode 100644 index 5c81fdf..0000000 --- a/src/item.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - * Copyright (c) 2015 Samsung Electronics Co., Ltd All Rights Reserved - * - * Licensed under the Apache License, Version 2.0 (the License); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an AS IS BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include -#include - -#include "share_panel_internal.h" -#include "conf.h" -#include "log.h" -#include "item.h" - - - -static void _up_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) -{ - ret_if(!obj); - evas_object_color_set(obj, 255, 255, 255, 255); -} - - - -static void _down_cb(void *data, Evas *e, Evas_Object *obj, void *event_info) -{ - ret_if(!obj); - evas_object_color_set(obj, 100, 100, 100, 100); -} - - - -#define DEFAULT_ICON "/usr/share/icons/A01-1_icon_Menu.png" -static Evas_Object *__add_icon(Evas_Object *parent, const char *file) -{ - const char *real_icon_file = NULL; - Evas_Object *icon = NULL; - - real_icon_file = file; - if (access(real_icon_file, R_OK) != 0) { - _E("Failed to access an icon(%s)", real_icon_file); - real_icon_file = DEFAULT_ICON; - } - - icon = elm_icon_add(parent); - retv_if(!icon, NULL); - - if (elm_image_file_set(icon, real_icon_file, NULL) == EINA_FALSE) { - _E("Icon file is not accessible (%s)", real_icon_file); - evas_object_del(icon); - return NULL; - } - - evas_object_size_hint_min_set(icon, ELM_SCALE_SIZE(ITEM_ICON_WIDTH), ELM_SCALE_SIZE(ITEM_ICON_HEIGHT)); - evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_UP, _up_cb, NULL); - evas_object_event_callback_add(icon, EVAS_CALLBACK_MOUSE_DOWN, _down_cb, NULL); - - elm_image_preload_disabled_set(icon, EINA_TRUE); - elm_image_smooth_set(icon, EINA_TRUE); - elm_image_no_scale_set(icon, EINA_FALSE); - evas_object_show(icon); - - return icon; -} - - - -static void __item_clicked_cb(void *data, Evas_Object *obj, void *event_info) -{ - item_s *item_info = data; - int ret = 0; - - ret_if(!item_info); - ret_if(!item_info->appid); - ret_if(!item_info->b); - _D("item clicked, launch app : %s", item_info->appid); - - ret = aul_forward_app(item_info->appid, item_info->b); - if (ret < 0) { - _E("Fail to launch app(%d)", ret); - } - - ui_app_exit(); -} - - - -#define ITEM_EDJE_FILE EDJEDIR"/item.edj" -Evas_Object *_item_create(Evas_Object *page, item_s *item_info) -{ - Evas_Object *item = NULL; - Evas_Object *item_bg = NULL; - Evas_Object *icon = NULL; - Evas_Object *button = NULL; - Evas *e = NULL; - - char *name = NULL; - - retv_if(!item_info, NULL); - - item = elm_layout_add(page); - retv_if(!item, NULL); - elm_layout_file_set(item, ITEM_EDJE_FILE, "item"); - - e = evas_object_evas_get(page); - goto_if(!e, ERROR); - - item_bg = evas_object_rectangle_add(e); - goto_if(!item_bg, ERROR); - evas_object_size_hint_weight_set(item_bg, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_size_hint_min_set(item_bg, ELM_SCALE_SIZE(ITEM_WIDTH), ELM_SCALE_SIZE(ITEM_HEIGHT)); - evas_object_color_set(item_bg, 0, 0, 0, 0); - evas_object_repeat_events_set(item_bg, EINA_TRUE); - evas_object_show(item_bg); - elm_object_part_content_set(item, "bg", item_bg); - evas_object_show(item); - - icon = __add_icon(item, item_info->icon); - goto_if(!icon, ERROR); - elm_object_part_content_set(item, "icon", icon); - - name = item_info->name; - goto_if(!name, ERROR); - elm_object_part_text_set(item, "name", name); - - button = elm_button_add(item); - goto_if(!button, ERROR); - - elm_object_style_set(button, "focus"); - elm_object_part_content_set(item, "button", button); - evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); - evas_object_show(button); - evas_object_smart_callback_add(button, "clicked", __item_clicked_cb, item_info); - - return item; - -ERROR: - _item_destroy(item); - return NULL; - -} - - - -void _item_destroy(Evas_Object *item) -{ - Evas_Object *bg = NULL; - Evas_Object *button = NULL; - Evas_Object *icon = NULL; - - ret_if(!item); - - button = elm_object_part_content_unset(item, "button"); - if (button) { - evas_object_smart_callback_del(button, "clicked", __item_clicked_cb); - } - - icon = elm_object_part_content_unset(item, "icon"); - if (icon) { - evas_object_event_callback_del(icon, EVAS_CALLBACK_MOUSE_UP, _up_cb); - evas_object_event_callback_del(icon, EVAS_CALLBACK_MOUSE_DOWN, _down_cb); - evas_object_del(icon); - } - bg = elm_object_part_content_unset(item, "bg"); - if (bg) { - evas_object_del(bg); - } - evas_object_del(item); -} diff --git a/src/scroller.c b/src/scroller.c index cfb9d72..a4d3d0d 100644 --- a/src/scroller.c +++ b/src/scroller.c @@ -19,7 +19,7 @@ #include "share_panel.h" #include "share_panel_internal.h" #include "conf.h" -#include "item.h" +#include "grid.h" #include "log.h" #include "page.h" #include "scroller.h" @@ -134,7 +134,7 @@ Evas_Object *_scroller_create(Evas_Object *ui_manager, share_panel_h share_panel goto_if(!box, ERROR); elm_box_horizontal_set(box, EINA_TRUE); - elm_box_align_set(box, 0.5, 0.0); + elm_box_align_set(box, 0.5, 0.5); evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_show(box); @@ -154,10 +154,15 @@ ERROR: void _scroller_destroy(Evas_Object *scroller) { Evas_Object *box = NULL; + Eina_List *list = NULL; ret_if(!scroller); box = elm_object_content_unset(scroller); if (box) { + list = elm_box_children_get(box); + if (list) { + _scroller_remove_list(scroller, list); + } evas_object_del(box); } @@ -240,6 +245,7 @@ void _scroller_remove_page(Evas_Object *scroller, Evas_Object *page) void _scroller_append_list(Evas_Object *scroller, Eina_List *list, int page_width, int page_height) { Evas_Object *page = NULL; + Evas_Object *grid = NULL; int count = 0; int i; @@ -257,17 +263,16 @@ void _scroller_append_list(Evas_Object *scroller, Eina_List *list, int page_widt for (i = 0; i < count; i++) { Evas_Object *item = NULL; - char tmp[256]; if (i % 8 == 0) { page = _page_create(scroller, page_width, page_height); ret_if(!page); _scroller_append_page(scroller, page); + grid = _grid_create(page); + ret_if(!grid); + elm_object_part_content_set(page, "grid", grid); } - item = _item_create(page, eina_list_nth(list, i)); + item = _grid_append_item(grid, eina_list_nth(list, i)); ret_if(!item); - snprintf(tmp, sizeof(tmp), "item_swallow_%d", (i%8)); - _D("swallow : %s", tmp); - elm_object_part_content_set(page, tmp, item); } } @@ -275,10 +280,18 @@ void _scroller_append_list(Evas_Object *scroller, Eina_List *list, int page_widt void _scroller_remove_list(Evas_Object *scroller, Eina_List *list) { + Evas_Object *page = NULL; + Evas_Object *grid = NULL; + ret_if(!scroller); ret_if(!list); - /* We'll implement this part */ + EINA_LIST_FREE(list, page) { + grid = elm_object_part_content_unset(page, "grid"); + continue_if(!grid); + _grid_destroy(grid); + _page_destroy(page); + } } diff --git a/src/share_panel.c b/src/share_panel.c index 05bb103..698990a 100644 --- a/src/share_panel.c +++ b/src/share_panel.c @@ -82,7 +82,7 @@ static void _rotate_cb(void *data, Evas_Object *obj, void *event) angle = elm_win_rotation_get(obj); _D("Angle is %d degree", angle); - if (share_panel->list_count > LINE_MAX) { + if (share_panel->list_count > SHARE_PANEL_LINE_MAX) { return; } @@ -175,7 +175,7 @@ EAPI int share_panel_create(app_control_h control, share_panel_h *share_panel) } else { panel->page_width = panel->root_width; } - panel->page_height = PANEL_HEIGHT; + panel->page_height = ELM_SCALE_SIZE(SCROLLER_HEIGHT); panel->control = control; diff --git a/src/ui_manager.c b/src/ui_manager.c index c156a4b..5a24ab6 100644 --- a/src/ui_manager.c +++ b/src/ui_manager.c @@ -171,6 +171,7 @@ void __destroy_bg_rect(Evas_Object *bg) Evas_Object *_ui_manager_create(share_panel_s *share_panel) { Evas_Object *ui_manager = NULL; + Evas_Object *edje = NULL; retv_if(!share_panel, NULL); @@ -218,18 +219,23 @@ Evas_Object *_ui_manager_create(share_panel_s *share_panel) share_panel->list_count = eina_list_count(share_panel->list); - if (share_panel->list_count <= LINE_MAX) { + _scroller_append_list(share_panel->scroller + , share_panel->list + , share_panel->page_width + , share_panel->page_height); + + edje = elm_layout_edje_get(ui_manager); + goto_if(!edje, ERROR); + + if (share_panel->list_count <= SHARE_PANEL_LINE_MAX) { if (share_panel->root_width < share_panel->root_height) { - elm_object_signal_emit(ui_manager, "1line", "fixed_bg"); + edje_object_signal_emit(edje, "1line", "fixed_bg"); } else { - elm_object_signal_emit(ui_manager, "1line,land", "fixed_bg"); + edje_object_signal_emit(edje, "1line,land", "fixed_bg"); } } - _scroller_append_list(share_panel->scroller - , share_panel->list - , share_panel->page_width - , share_panel->page_height - ELM_SCALE_SIZE(INDEX_HEIGHT)); + edje_object_message_signal_process(edje); return ui_manager; -- 2.7.4