The source code moved from the SPIN with license changed to Flora 1.1
[apps/native/home/homescreen-efl.git] / inc / livebox / livebox_utils.h
1 /*
2  * Copyright 2012  Samsung Electronics Co., Ltd
3  *
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
7  *
8  * http://floralicense.org/license/
9  *
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.
15  */
16
17 #ifndef UTILS_H_
18 #define UTILS_H_
19
20 #include <Elementary.h>
21
22 #include "../util.h"
23 #include "../conf.h"
24
25 /**
26  * @brief Check interection between @p rect and list items bounding
27  * Eina_Rectangles
28  * @details Check interection between @p rect and list items bounding
29  * Eina_Rectangle.
30  * If current list item == @p obj the intersection check won't be performed.
31  * By standard the @p rect is the @p obj bounding rectangle.
32  * So this helps to avoid interesction check with obj itself
33  * @param rect rectangle
34  * @param obj filter object. Can be NULL
35  * @param list of objects
36  * @return TRUE if intersection was found ELSE otherwise
37  */
38 extern bool livebox_utils_check_rect_list_grid_interesction(
39         Eina_Rectangle *rect, Evas_Object *obj, Eina_List *list);
40
41 /**
42  * @brief Returns the list of liveboxes on grid
43  * @details Function returns liveboxes put on @p grid but but without the
44  * @a shadow object
45  * @param grid
46  * @return list of liveboxes. Has to be freed
47  */
48 extern Eina_List *livebox_utils_get_liveboxes_on_gird(Evas_Object *grid);
49
50 /**
51  * @brief Returns the list of liveboxes on page
52  * @details Page is a layout described by "livebox_container.edc" Which
53  * contains a elm_grid object. All objects in the grid are returned.
54  * @param obj livebox page
55  * @return list of liveboxes. Has to be freed
56  */
57 extern Eina_List *livebox_utils_get_liveboxes_on_page_list(Evas_Object *obj);
58
59
60 /**
61  * @brief Returns the livebox container that contains the selected livebox
62  * @return Livebox container
63  */
64 extern Evas_Object *livebox_utils_get_selected_livebox_layout(void);
65
66 /**
67  * @brief Returns the that previously contained the selected livebox.
68  * Used when livebox in repositioned to different container
69  * @return Livebox container
70  */
71 extern Evas_Object *livebox_utils_get_prev_livebox_layout(void);
72
73 /**
74  * @brief Returns the selected livebox
75  * @return selected livebox
76  */
77 extern Evas_Object *livebox_utils_selected_livebox_get(void);
78
79 /**
80  * @brief Sets the selected livebox
81  * @note Use this when livebox is selected
82  * @param livebox Selected livebox
83  * @param layout livbox container holding the selected livebox
84  */
85 extern void livebox_utils_set_selected_livebox(Evas_Object *livebox,
86         Evas_Object *layout);
87
88 /**
89  * @brief Crate the shadow visible when a object is repositioned
90  * @param parent Shadow parent
91  */
92 extern void livebox_utils_create_shadow(Evas_Object *parent);
93
94 /**
95  * @brief Pack the shadow object to given container based on livebox position
96  * @note Used in reposition
97  * @param livebox item repositioned using drag&drop
98  * @param page container where the shadow will be packed
99  */
100 extern void livebox_utils_set_shadow_pack(Evas_Object *livebox,
101         Evas_Object *page);
102
103 /**
104  * @brief Shadow is repacked from one livebox_container to different one
105  * @details Shadow object is unpacked from its current grid and packed to grid
106  * in page_to livebox_container
107  * @param livebox livebox item repositioned using drag&drop
108  * @param page_to livebo_container where the shadow will be packed
109  */
110 extern void livebox_utils_repack_shadow(Evas_Object *livebox,
111         Evas_Object *page_to);
112
113 /**
114  * @brief Sets the visiblity of the shadow object
115  * @param visible TRUE shadow will be visible
116  */
117 extern void livebox_utils_set_shadow_visibility(bool visible);
118
119 /**
120  * @brief Creates the clipper for the shadow object
121  * @details The clipper is added to the @p livebox_container and is clipped
122  * by the shadow object.
123  * This way only the part of the clipper will be visible where the repositioned
124  * livebox can be dropped
125  * @param livebox_container Layout containing the clipper
126  */
127 extern void livebox_utils_create_grid_shadow_clipper(Evas_Object*
128         livebox_container);
129
130 /**
131  * @brief Returns position fitting given grid
132  * @details The input parameteters should be given in virtual coordinates of
133  * a grid. If the item coordinates don't fit the grid they will be modified
134  * properly.
135  *      @code
136  *              if(obj_x < 0)
137  *              {
138  *                      *out_x = 0;
139  *              }
140  *
141  *              if obj_x + obj_w > grid_width
142  *              {
143  *                      *out_x = grid_width - obj_w
144  *              }
145  *      @endcode
146  *
147  * @param[in] obj_x
148  * @param[in] obj_y
149  * @param[in] obj_w
150  * @param[in] obj_h
151  * @param[out] out_x
152  * @param[out] out_y
153  */
154 extern void livebox_utils_normalize_grid_pos(int obj_x, int obj_y, int obj_w,
155         int obj_h, int *out_x, int *out_y);
156
157 /**
158  * @brief Returns the grid put into the @p container widget
159  * @param container The container wodth grid
160  * @return Grid object or NULL on error
161  */
162 extern Evas_Object *livebox_utils_get_livebox_container_grid(Evas_Object *container);
163
164 /**
165  * @brief Returns the shadow object
166  * @return shadow object
167  */
168 extern Evas_Object *livebox_utils_get_shadow(void);
169
170 /**
171  * @brief unpacks the grid object from the grid its currently packed to
172  */
173 extern void livebox_utils_shadow_unpack(void);
174
175 /**
176  * @brief Transforms the @p livebox geometry to @p grid virtual coordinates
177  * @param[in] livebox object to read the geometry from
178  * @param[in] grid elm_grid which virtual coordinates will be used
179  * @param[out] out_x @p livebox transformed horizontal position
180  * @param[out] out_y @p livebox transformed vertical position
181  * @param[out] out_w @p livebox transformed width
182  * @param[out] out_h @p livebox transformed height
183  */
184 extern void livebox_utils_convert_size_to_grid_coord(Evas_Object *livebox,
185         Evas_Object *grid, int *out_x, int *out_y, int *out_w, int *out_h);
186
187 /**
188  * @brief Sets the packing of @p item_to_pack to the @p grid
189  * @details The @p livebox object is used to determine the position of @p
190  * item_to_pack in the @p grid.
191  * Note that the @p item_to_pack has to be packet in the gird allready
192  * @param livebox Position of this object will be used to determine the
193  * position of @p item_to_pack in the @p grid
194  * @param item_to_pack Object to be packed to the @p grid
195  * @param grid The grid object. Must be elm_grid
196  */
197 extern void livebox_utils_set_grid_object_pack(Evas_Object *livebox,
198         Evas_Object *item_to_pack, Evas_Object *grid);
199
200 /**
201  * @brief Repacks @p item_to_pack from @p grid_from to @p grid_to
202  * @details The @p livebox object is used to determine the position of @p
203  * item_to_pack in the @p grid_to.
204  * The item_to_pack will be unpacked from @p grid_from and @p packed to @p
205  * grid_to
206  *
207  * @param livebox ivebox Position of this object will be used to determine
208  * the position of @p item_to_pack in the @p grid_to
209  * @param item_to_pack Repacked item
210  * @param grid_from Source grid
211  * @param grid_to D Destination grid
212  */
213 extern void livebox_utils_repack_grid_object(Evas_Object *livebox,
214         Evas_Object *item_to_pack, Evas_Object *grid_from,
215         Evas_Object *grid_to);
216
217 /**
218  * @brief Transforms virtual @ grid virtual coordinates to screen coordinates
219  * @param grid elm_grid
220  * @param x Horizontal position in @p grid
221  * @param y Vertical position in @p grid
222  * @param w Width in @p grid
223  * @param h Height in @p grid
224  * @return Eina_Rectangle containing the postion transformed
225  * to screen coordinates
226  */
227 extern Eina_Rectangle *livebox_utils_convert_virtual_grid_geo_to_screen(
228         Evas_Object *grid, int x, int y, int w, int h);
229
230 /**
231  * @brief Returns the bounding rectangle of the @p obj object
232  * @details Bounding rectangle contains (x position, y position, width, height)
233  * of the @p obj
234  * @param obj to get the bounding rectangle from
235  * @return Bounding rectangle
236  */
237 extern Eina_Rectangle *livebox_utils_get_widget_rectangle(Evas_Object *obj);
238
239 /**
240  * @brief Returns the bounding rectangle of the @p obj object in grid virtual
241  * coordinates
242  * @details Bounding rectangle contains (x position, y position, width, height)
243  * of the @p obj.
244  * @p Obj has to be packed into a grid.
245  * @param obj to get the bounding rectangle from
246  * @return Bounding rectangle
247  */
248 extern Eina_Rectangle *livebox_utils_get_grid_widget_rectangle(
249         Evas_Object *obj);
250
251 /**
252  * @brief get the current cursor position
253  * @param mx position x
254  * @param my position y
255  */
256 extern void livebox_utils_get_cursor_pos(int *mx, int *my);
257
258
259 #endif /* UTILS_H_ */