2 * Copyright 2012 Samsung Electronics Co., Ltd
4 * Licensed under the Flora License, Version 1.1 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://floralicense.org/license/
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #include "homescreen-efl.h"
19 #include "page_scroller.h"
21 #include "dynamic_index.h"
24 Evas_Object *all_apps;
29 dynamic_index_t *index;
31 bool anim_base_positions_actual;
43 /*these variables are used during animation transitions:*/
44 .anim_base_positions_actual = false,
45 .anim_base_pos_x = -1,
50 static bool __all_apps_fill(void);
52 HAPI void all_apps_detach_from_grid(Elm_Object_Item *grid_item)
56 LOGE("[INVALID_ARG][grid_item='%p']" , grid_item);
60 app_grid_unpack_item(grid_item);
61 elm_object_item_del(grid_item);
64 HAPI Elm_Object_Item *all_apps_attach_to_grid(Evas_Object *icon, int grid_num)
66 Evas_Object *grid = NULL;
73 grid = page_scroller_get_page(s_info.all_apps, grid_num);
75 if (home_screen_get_view_type() == HOMESCREEN_VIEW_ALL_APPS_CHOOSE)
76 elm_object_signal_emit(icon, SIGNAL_EDIT_MODE_OFF, SIGNAL_SOURCE);
78 return app_grid_append_item(grid, icon);
81 HAPI Evas_Object *all_apps_create(Evas_Object *parent, void *data)
83 Evas_Object *p_edje = NULL;
87 LOGE("[INVALID_ARG][parent='%p'][data='%p']" , parent, data);
90 s_info.parent = parent;
92 p_edje = elm_layout_edje_get(parent);
93 edje_object_part_geometry_get(p_edje, PART_CONTENT , NULL , NULL, &s_info.w, &s_info.h);
95 if (s_info.w < 0 || s_info.h < 0) {
96 LOGE("[FAILED][edje_object_part_geometry_get][w='%d'][h='%d']", s_info.w, s_info.h);
100 s_info.all_apps = page_scroller_create(s_info.w, s_info.h);
101 if (!s_info.all_apps) {
102 LOGE("[FAILED][page_scroller_create]");
106 if (!__all_apps_fill()) {
107 LOGE("[FAILED][__all_apps_fill]");
108 page_scroller_destroy(s_info.all_apps);
109 s_info.all_apps = NULL;
113 s_info.index = dynamic_index_new(s_info.all_apps);
115 LOGE("[FAILED][dynamic_index_new]");
116 page_scroller_destroy(s_info.all_apps);
117 s_info.all_apps = NULL;
121 evas_object_size_hint_min_set(s_info.all_apps, home_screen_get_root_width(), home_screen_get_root_height());
122 evas_object_resize(s_info.all_apps, home_screen_get_root_width(), home_screen_get_root_height());
123 evas_object_move(s_info.all_apps, 0, home_screen_get_root_height());
125 return s_info.all_apps;
128 HAPI void all_apps_show(void)
131 elm_object_part_content_set(s_info.parent, PART_INDEX, s_info.index->box);
132 evas_object_show(s_info.index->box);
136 HAPI void all_apps_hide(void)
138 elm_object_part_content_unset(s_info.parent, PART_INDEX);
140 evas_object_hide(s_info.index->box);
144 HAPI void all_apps_del(void)
146 /*app_grids was added into all_apps so it should be removed
147 when this object will be deleted.*/
148 dynamic_index_del(s_info.index);
151 evas_object_del(s_info.all_apps);
152 s_info.all_apps = NULL;
155 HAPI void all_apps_set_view_mode(homescreen_view_t view)
157 data_model_set_view_mode(view);
160 HAPI void all_apps_set_scrolling_blocked_state(bool is_blocked)
162 if (is_blocked) page_scroller_freeze(s_info.all_apps);
163 else page_scroller_unfreeze(s_info.all_apps);
166 HAPI bool all_apps_append_page(Tree_node_t *page_item)
168 Evas_Object *app_grid = app_grid_create(s_info.all_apps, page_item, s_info.w, s_info.h, APP_GRID_TYPE_ALL_APPS);
171 LOGE("[FAILED][app_grid_create]");
175 if (!page_scroller_add_page(s_info.all_apps, app_grid)) {
176 LOGE("[FAILED][page_scroller_page_add]");
177 evas_object_del(app_grid);
184 HAPI void all_apps_remove_empty_pages(void)
186 Evas_Object *empty_page_layout = NULL, *page_layout = NULL, *gengrid_inside_layout = NULL;
191 empty_page_layout = NULL;
193 while ((page_layout = page_scroller_get_page(s_info.all_apps, i++))) {
194 gengrid_inside_layout = elm_object_part_content_get(page_layout, PART_APP_GRID_CONTENT);
196 if (elm_gengrid_items_count(gengrid_inside_layout) == 0) {
197 empty_page_layout = page_layout;
201 page_scroller_remove_page(s_info.all_apps, empty_page_layout);
202 } while (empty_page_layout);
205 HAPI void all_apps_update_dynamic_index_count(void)
207 elm_object_signal_emit(s_info.all_apps, "scroller,count,changed", "layout");
210 static bool __all_apps_fill(void)
212 Tree_node_t *it = NULL;
213 Tree_node_t *data_model = (Tree_node_t *)data_model_get_all_apps();
216 LOGE("[FAILED][data_model_tree_get");
220 TREE_NODE_FOREACH(data_model, it)
221 if (!all_apps_append_page(it))