[access] call a callback function with information
[framework/uifw/elementary.git] / src / lib / elm_widget_flip.h
1 #ifndef ELM_WIDGET_FLIP_H
2 #define ELM_WIDGET_FLIP_H
3
4 #include "elm_widget_container.h"
5
6 /**
7  * @addtogroup Widget
8  * @{
9  *
10  * @section elm-flip-class The Elementary Flip Class
11  *
12  * Elementary, besides having the @ref Flip widget, exposes its
13  * foundation -- the Elementary Flip Class -- in order to create other
14  * widgets which are a flip with some more logic on top.
15  */
16
17 /**
18  * @def ELM_FLIP_CLASS
19  *
20  * Use this macro to cast whichever subclass of
21  * #Elm_Flip_Smart_Class into it, so to access its fields.
22  *
23  * @ingroup Widget
24  */
25 #define ELM_FLIP_CLASS(x) ((Elm_Flip_Smart_Class *)x)
26
27 /**
28  * @def ELM_FLIP_DATA
29  *
30  * Use this macro to cast whichever subdata of
31  * #Elm_Flip_Smart_Data into it, so to access its fields.
32  *
33  * @ingroup Widget
34  */
35 #define ELM_FLIP_DATA(x)  ((Elm_Flip_Smart_Data *)x)
36
37 /**
38  * @def ELM_FLIP_SMART_CLASS_VERSION
39  *
40  * Current version for Elementary flip @b base smart class, a value
41  * which goes to _Elm_Flip_Smart_Class::version.
42  *
43  * @ingroup Widget
44  */
45 #define ELM_FLIP_SMART_CLASS_VERSION 1
46
47 /**
48  * @def ELM_FLIP_SMART_CLASS_INIT
49  *
50  * Initializer for a whole #Elm_Flip_Smart_Class structure, with
51  * @c NULL values on its specific fields.
52  *
53  * @param smart_class_init initializer to use for the "base" field
54  * (#Evas_Smart_Class).
55  *
56  * @see EVAS_SMART_CLASS_INIT_NULL
57  * @see EVAS_SMART_CLASS_INIT_NAME_VERSION
58  * @see ELM_FLIP_SMART_CLASS_INIT_NULL
59  * @see ELM_FLIP_SMART_CLASS_INIT_NAME_VERSION
60  *
61  * @ingroup Widget
62  */
63 #define ELM_FLIP_SMART_CLASS_INIT(smart_class_init) \
64   {smart_class_init, ELM_FLIP_SMART_CLASS_VERSION}
65
66 /**
67  * @def ELM_FLIP_SMART_CLASS_INIT_NULL
68  *
69  * Initializer to zero out a whole #Elm_Flip_Smart_Class structure.
70  *
71  * @see ELM_FLIP_SMART_CLASS_INIT_NAME_VERSION
72  * @see ELM_FLIP_SMART_CLASS_INIT
73  *
74  * @ingroup Widget
75  */
76 #define ELM_FLIP_SMART_CLASS_INIT_NULL \
77   ELM_FLIP_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
78
79 /**
80  * @def ELM_FLIP_SMART_CLASS_INIT_NAME_VERSION
81  *
82  * Initializer to zero out a whole #Elm_Flip_Smart_Class structure and
83  * set its name and version.
84  *
85  * This is similar to #ELM_FLIP_SMART_CLASS_INIT_NULL, but it will
86  * also set the version field of #Elm_Flip_Smart_Class (base field)
87  * to the latest #ELM_FLIP_SMART_CLASS_VERSION and name it to the
88  * specific value.
89  *
90  * It will keep a reference to the name field as a <c>"const char *"</c>,
91  * i.e., the name must be available while the structure is
92  * used (hint: static or global variable!) and must not be modified.
93  *
94  * @see ELM_FLIP_SMART_CLASS_INIT_NULL
95  * @see ELM_FLIP_SMART_CLASS_INIT
96  *
97  * @ingroup Widget
98  */
99 #define ELM_FLIP_SMART_CLASS_INIT_NAME_VERSION(name) \
100   ELM_FLIP_SMART_CLASS_INIT(ELM_CONTAINER_SMART_CLASS_INIT_NAME_VERSION(name))
101
102 /**
103  * Elementary flip base smart class. This inherits directly from
104  * #Elm_Container_Smart_Class and is meant to build widgets extending the
105  * behavior of a flip.
106  *
107  * All of the functions listed on @ref Flip namespace will work for
108  * objects deriving from #Elm_Flip_Smart_Class.
109  */
110 typedef struct _Elm_Flip_Smart_Class
111 {
112    Elm_Container_Smart_Class base;
113
114    int                       version; /**< Version of this smart class definition */
115 } Elm_Flip_Smart_Class;
116
117 typedef struct _Slice               Slice;
118
119 /**
120  * Base widget smart data extended with flip instance data.
121  */
122 typedef struct _Elm_Flip_Smart_Data Elm_Flip_Smart_Data;
123 struct _Elm_Flip_Smart_Data
124 {
125    Elm_Widget_Smart_Data base;
126
127    Evas_Object          *clip;
128    Evas_Object          *event[4];
129    struct
130    {
131       Evas_Object *content, *clip;
132    } front, back;
133
134    Ecore_Animator       *animator;
135    double                start, len;
136    Ecore_Job            *job;
137    Evas_Coord            down_x, down_y, x, y, ox, oy, w, h;
138    Elm_Flip_Interaction  intmode;
139    Elm_Flip_Mode         mode;
140    int                   dir;
141    double                dir_hitsize[4];
142    Eina_Bool             dir_enabled[4];
143    int                   slices_w, slices_h;
144    Slice               **slices, **slices2;
145
146    Eina_Bool             state : 1;
147    Eina_Bool             next_state : 1;
148    Eina_Bool             down : 1;
149    Eina_Bool             finish : 1;
150    Eina_Bool             started : 1;
151    Eina_Bool             backflip : 1;
152    Eina_Bool             pageflip : 1;
153    Eina_Bool             manual : 1;
154 };
155
156 typedef struct _Vertex2             Vertex2;
157 typedef struct _Vertex3             Vertex3;
158
159 struct _Slice
160 {
161    Evas_Object *obj;
162    double       u[4], v[4], x[4], y[4], z[4];
163 };
164
165 struct _Vertex2
166 {
167    double x, y;
168 };
169
170 struct _Vertex3
171 {
172    double x, y, z;
173 };
174
175 /**
176  * @}
177  */
178
179 EAPI extern const char ELM_FLIP_SMART_NAME[];
180 EAPI const Elm_Flip_Smart_Class *elm_flip_smart_class_get(void);
181
182 #define ELM_FLIP_DATA_GET(o, sd) \
183   Elm_Flip_Smart_Data * sd = evas_object_smart_data_get(o)
184
185 #define ELM_FLIP_DATA_GET_OR_RETURN(o, ptr)          \
186   ELM_FLIP_DATA_GET(o, ptr);                         \
187   if (!ptr)                                          \
188     {                                                \
189        CRITICAL("No widget data for object %p (%s)", \
190                 o, evas_object_type_get(o));         \
191        return;                                       \
192     }
193
194 #define ELM_FLIP_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
195   ELM_FLIP_DATA_GET(o, ptr);                         \
196   if (!ptr)                                          \
197     {                                                \
198        CRITICAL("No widget data for object %p (%s)", \
199                 o, evas_object_type_get(o));         \
200        return val;                                   \
201     }
202
203 #define ELM_FLIP_CHECK(obj)                                                 \
204   if (!obj || !elm_widget_type_check((obj), ELM_FLIP_SMART_NAME, __func__)) \
205     return
206
207 #endif