Imported Upstream version 1.7.1
[platform/upstream/edje.git] / src / lib / edje_container.h
1 #include "edje_private.h"
2
3
4 #define E_SMART_OBJ_GET(smart, o, type) \
5      { \
6         char *_e_smart_str; \
7         \
8         if (!o) return; \
9         smart = evas_object_smart_data_get(o); \
10         if (!smart) return; \
11         _e_smart_str = (char *)evas_object_type_get(o); \
12         if (!_e_smart_str) return; \
13         if (strcmp(_e_smart_str, type)) return; \
14      }
15
16 #define E_SMART_OBJ_GET_RETURN(smart, o, type, ret) \
17    { \
18       char *_e_smart_str; \
19       \
20       if (!o) return ret; \
21       smart = evas_object_smart_data_get(o); \
22       if (!smart) return ret; \
23       _e_smart_str = (char *)evas_object_type_get(o); \
24       if (!_e_smart_str) return ret; \
25       if (strcmp(_e_smart_str, type)) return ret; \
26    }
27
28 #define E_OBJ_NAME "edje_container_object"
29
30 typedef struct _Smart_Data         Smart_Data;
31 typedef struct _Smart_Data_Colinfo Smart_Data_Colinfo;
32
33 struct _Smart_Data
34 {
35    Evas_Coord     x, y, w, h;
36    Eina_List     *children;
37    Evas_Object   *smart_obj;
38    int            cols, rows;
39
40    Evas_Coord     contents_w, contents_h;
41    Evas_Coord     min_row_h, max_row_h;
42    Evas_Coord     min_w, max_w, min_h, max_h;
43
44    Smart_Data_Colinfo *colinfo;
45
46    int            freeze;
47
48    double         scroll_x, scroll_y;
49    double         align_x, align_y;
50
51    unsigned char  changed : 1;
52    unsigned char  change_child : 1;
53    unsigned char  change_child_list : 1;
54    unsigned char  change_cols : 1;
55    unsigned char  change_scroll : 1;
56
57    unsigned char  need_layout : 1;
58
59    unsigned char  homogenous : 1;
60 };
61
62 struct _Smart_Data_Colinfo
63 {
64    Evas_Coord minw, maxw;
65 };
66
67 /* All items are virtual constructs that provide Evas_Objects at some point.
68  * Edje may move, resize, show, hide, clip, unclip, raise, lower etc. this
69  * item AFTER it calls the item's add() method and before it calls the del()
70  * method. Edje may call add() and del() at any time as often items may not
71  * be visible and so may not need to exist at all - they are merely information
72  * used for layout, and nothing more. this helps save cpu and memory keeping
73  * things responsive for BIG lists of items. you create an item from an item
74  * class then ask that item to be appended/prepended etc. to the container.
75  */
76 typedef struct _Edje_Item       Edje_Item;
77 typedef struct _Edje_Item_Cell  Edje_Item_Cell;
78 typedef struct _Edje_Item_Class Edje_Item_Class;
79
80 struct _Edje_Item_Class
81 {
82    Evas_Object *(*add)      (Edje_Item *ei);
83    void         (*del)      (Edje_Item *ei);
84    void         (*select)   (Edje_Item *ei);
85    void         (*deselect) (Edje_Item *ei);
86    void         (*focus)    (Edje_Item *ei);
87    void         (*unfocus)  (Edje_Item *ei);
88 };
89
90 /* private */
91 struct _Edje_Item
92 {
93    Edje_Item_Class *class;
94    void            *class_data;
95
96    void            *sd;
97
98    void            *data;
99
100    Evas_Object     *object;
101    Evas_Object     *overlay_object;
102    int              freeze;
103    Evas_Coord       y, h;
104
105    Evas_Coord       minh, maxh;
106
107    int              cells_num;
108    Edje_Item_Cell  *cells;
109
110    unsigned char    accessible : 1;
111
112    unsigned char    recalc : 1;
113    unsigned char    selected : 1;
114    unsigned char    disabled : 1;
115    unsigned char    focused : 1;
116 };
117
118 struct _Edje_Item_Cell
119 {
120    Evas_Object *obj;
121    Evas_Coord   x, w;
122    Evas_Coord   minw, minh, maxw, maxh;
123 };
124
125 /* here is an item for a vertical list - with 1 or more columns. this has 3 */
126 /* just rotate for a horizontal list */
127
128 /*
129  *             COL 0                 COL 1          COL 2
130  *
131  * +-----------------------------+ +-------+ +----------------+
132  * |          pad_top            | |       | |                |
133  * | pad_left  OBJECT  pad_right | |  OBJ  | |     OBJECT     | ROW 0
134  * |         pad_bottom          | |       | |                |
135  * +-----------------------------+ +-------+ +----------------+
136  *               /\              /|\
137  *     space_row ||               +-- space_col
138  *               \/
139  * +-----------------------------+ +-------+ +----------------+
140  * |                             | |       | |                |
141  * |                             | |       | |                | ROW 1
142  * |                             | |       | |                |
143  * +-----------------------------+ +-------+ +----------------+
144  *
145  * spacer object:
146  * 1 Edje object goes in-between each row as a spacer object (opt)
147  * 1 Edje object goes in-between each column as a spacer object (opt)
148  *
149  * surround object:
150  * 1 Edje object goes around each item - item swallowed into "item" part (opt)
151  *   if no "item" part then just underlay it
152  *   on select send "select" "" signal
153  *   on unselect send "unselect" "" signal
154  *   on focus send "focus" "" signal
155  *   on unfocus send "unfocus" signal
156  *
157  *   if any list item/cell is an Edje object emit this to them too.
158  *
159  *   also call callbacks.
160  *   if a surround object emits such a signal itself then call callbacks too
161  *
162  * only 1 or 0 items can be focused
163  * disabled items cannot be focused or selected/deselected
164  *
165  */