aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/libraries/edje/src/lib/edje_container.h
blob: 0fba62c45d79bd3ba9a186229c370f92c869b7e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
#include "edje_private.h"


#define E_SMART_OBJ_GET(smart, o, type) \
     { \
	char *_e_smart_str; \
	\
	if (!o) return; \
	smart = evas_object_smart_data_get(o); \
	if (!smart) return; \
	_e_smart_str = (char *)evas_object_type_get(o); \
	if (!_e_smart_str) return; \
	if (strcmp(_e_smart_str, type)) return; \
     }

#define E_SMART_OBJ_GET_RETURN(smart, o, type, ret) \
   { \
      char *_e_smart_str; \
      \
      if (!o) return ret; \
      smart = evas_object_smart_data_get(o); \
      if (!smart) return ret; \
      _e_smart_str = (char *)evas_object_type_get(o); \
      if (!_e_smart_str) return ret; \
      if (strcmp(_e_smart_str, type)) return ret; \
   }

#define E_OBJ_NAME "edje_container_object"

typedef struct _Smart_Data         Smart_Data;
typedef struct _Smart_Data_Colinfo Smart_Data_Colinfo;

struct _Smart_Data
{
   Evas_Coord     x, y, w, h;
   Eina_List     *children;
   Evas_Object   *smart_obj;
   int            cols, rows;

   Evas_Coord     contents_w, contents_h;
   Evas_Coord     min_row_h, max_row_h;
   Evas_Coord     min_w, max_w, min_h, max_h;

   Smart_Data_Colinfo *colinfo;

   int            freeze;

   double         scroll_x, scroll_y;
   double         align_x, align_y;

   unsigned char  changed : 1;
   unsigned char  change_child : 1;
   unsigned char  change_child_list : 1;
   unsigned char  change_cols : 1;
   unsigned char  change_scroll : 1;

   unsigned char  need_layout : 1;

   unsigned char  homogenous : 1;
};

struct _Smart_Data_Colinfo
{
   Evas_Coord minw, maxw;
};

/* All items are virtual constructs that provide Evas_Objects at some point.
 * Edje may move, resize, show, hide, clip, unclip, raise, lower etc. this
 * item AFTER it calls the item's add() method and before it calls the del()
 * method. Edje may call add() and del() at any time as often items may not
 * be visible and so may not need to exist at all - they are merely information
 * used for layout, and nothing more. this helps save cpu and memory keeping
 * things responsive for BIG lists of items. you create an item from an item
 * class then ask that item to be appended/prepended etc. to the container.
 */
typedef struct _Edje_Item       Edje_Item;
typedef struct _Edje_Item_Cell  Edje_Item_Cell;
typedef struct _Edje_Item_Class Edje_Item_Class;

struct _Edje_Item_Class
{
   Evas_Object *(*add)      (Edje_Item *ei);
   void         (*del)      (Edje_Item *ei);
   void         (*select)   (Edje_Item *ei);
   void         (*deselect) (Edje_Item *ei);
   void         (*focus)    (Edje_Item *ei);
   void         (*unfocus)  (Edje_Item *ei);
};

/* private */
struct _Edje_Item
{
   Edje_Item_Class *class;
   void            *class_data;

   void            *sd;

   void            *data;

   Evas_Object     *object;
   Evas_Object     *overlay_object;
   int              freeze;
   Evas_Coord       y, h;

   Evas_Coord       minh, maxh;

   int              cells_num;
   Edje_Item_Cell  *cells;

   unsigned char    accessible : 1;

   unsigned char    recalc : 1;
   unsigned char    selected : 1;
   unsigned char    disabled : 1;
   unsigned char    focused : 1;
};

struct _Edje_Item_Cell
{
   Evas_Object *obj;
   Evas_Coord   x, w;
   Evas_Coord   minw, minh, maxw, maxh;
};

/* here is an item for a vertical list - with 1 or more columns. this has 3 */
/* just rotate for a horizontal list */

/*
 *             COL 0                 COL 1          COL 2
 *
 * +-----------------------------+ +-------+ +----------------+
 * |          pad_top            | |       | |                |
 * | pad_left  OBJECT  pad_right | |  OBJ  | |     OBJECT     | ROW 0
 * |         pad_bottom          | |       | |                |
 * +-----------------------------+ +-------+ +----------------+
 *               /\              /|\
 *     space_row ||               +-- space_col
 *               \/
 * +-----------------------------+ +-------+ +----------------+
 * |                             | |       | |                |
 * |                             | |       | |                | ROW 1
 * |                             | |       | |                |
 * +-----------------------------+ +-------+ +----------------+
 *
 * spacer object:
 * 1 Edje object goes in-between each row as a spacer object (opt)
 * 1 Edje object goes in-between each column as a spacer object (opt)
 *
 * surround object:
 * 1 Edje object goes around each item - item swallowed into "item" part (opt)
 *   if no "item" part then just underlay it
 *   on select send "select" "" signal
 *   on unselect send "unselect" "" signal
 *   on focus send "focus" "" signal
 *   on unfocus send "unfocus" signal
 *
 *   if any list item/cell is an Edje object emit this to them too.
 *
 *   also call callbacks.
 *   if a surround object emits such a signal itself then call callbacks too
 *
 * only 1 or 0 items can be focused
 * disabled items cannot be focused or selected/deselected
 *
 */