elementary/map - map supports language,changed
[framework/uifw/elementary.git] / src / lib / elm_widget_photocam.h
1 #ifndef ELM_WIDGET_PHOTOCAM_H
2 #define ELM_WIDGET_PHOTOCAM_H
3
4 #include "elm_interface_scrollable.h"
5
6 /**
7  * @addtogroup Widget
8  * @{
9  *
10  * @section elm-photocam-class The Elementary Photocam Class
11  *
12  * Elementary, besides having the @ref Photocam widget, exposes its
13  * foundation -- the Elementary Photocam Class -- in order to create
14  * other widgets which are a photocam with some more logic on top.
15  */
16
17 /**
18  * @def ELM_PHOTOCAM_CLASS
19  *
20  * Use this macro to cast whichever subclass of
21  * #Elm_Photocam_Smart_Class into it, so to access its fields.
22  *
23  * @ingroup Widget
24  */
25 #define ELM_PHOTOCAM_CLASS(x) ((Elm_Photocam_Smart_Class *) x)
26
27 /**
28  * @def ELM_PHOTOCAM_DATA
29  *
30  * Use this macro to cast whichever subdata of
31  * #Elm_Photocam_Smart_Data into it, so to access its fields.
32  *
33  * @ingroup Widget
34  */
35 #define ELM_PHOTOCAM_DATA(x) ((Elm_Photocam_Smart_Data *) x)
36
37 /**
38  * @def ELM_PHOTOCAM_SMART_CLASS_VERSION
39  *
40  * Current version for Elementary photocam @b base smart class, a value
41  * which goes to _Elm_Photocam_Smart_Class::version.
42  *
43  * @ingroup Widget
44  */
45 #define ELM_PHOTOCAM_SMART_CLASS_VERSION 1
46
47 /**
48  * @def ELM_PHOTOCAM_SMART_CLASS_INIT
49  *
50  * Initializer for a whole #Elm_Photocam_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_PHOTOCAM_SMART_CLASS_INIT_NULL
59  * @see ELM_PHOTOCAM_SMART_CLASS_INIT_NAME_VERSION
60  *
61  * @ingroup Widget
62  */
63 #define ELM_PHOTOCAM_SMART_CLASS_INIT(smart_class_init)                        \
64   {smart_class_init, ELM_PHOTOCAM_SMART_CLASS_VERSION}
65
66 /**
67  * @def ELM_PHOTOCAM_SMART_CLASS_INIT_NULL
68  *
69  * Initializer to zero out a whole #Elm_Photocam_Smart_Class structure.
70  *
71  * @see ELM_PHOTOCAM_SMART_CLASS_INIT_NAME_VERSION
72  * @see ELM_PHOTOCAM_SMART_CLASS_INIT
73  *
74  * @ingroup Widget
75  */
76 #define ELM_PHOTOCAM_SMART_CLASS_INIT_NULL \
77   ELM_PHOTOCAM_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
78
79 /**
80  * @def ELM_PHOTOCAM_SMART_CLASS_INIT_NAME_VERSION
81  *
82  * Initializer to zero out a whole #Elm_Photocam_Smart_Class structure and
83  * set its name and version.
84  *
85  * This is similar to #ELM_PHOTOCAM_SMART_CLASS_INIT_NULL, but it will
86  * also set the version field of #Elm_Photocam_Smart_Class (base field)
87  * to the latest #ELM_PHOTOCAM_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_PHOTOCAM_SMART_CLASS_INIT_NULL
95  * @see ELM_PHOTOCAM_SMART_CLASS_INIT
96  *
97  * @ingroup Widget
98  */
99 #define ELM_PHOTOCAM_SMART_CLASS_INIT_NAME_VERSION(name) \
100   ELM_PHOTOCAM_SMART_CLASS_INIT(ELM_WIDGET_SMART_CLASS_INIT_NAME_VERSION(name))
101
102 /**
103  * Elementary photocam base smart class. This inherits directly from
104  * #Elm_Widget_Smart_Class and is meant to build widgets extending the
105  * behavior of a photocam.
106  *
107  * All of the functions listed on @ref Photocam namespace will work for
108  * objects deriving from #Elm_Photocam_Smart_Class.
109  */
110 typedef struct _Elm_Photocam_Smart_Class
111 {
112    Elm_Widget_Smart_Class base;
113
114    int                    version; /**< Version of this smart class definition */
115 } Elm_Photocam_Smart_Class;
116
117 /**
118  * Base widget smart data extended with photocam instance data.
119  */
120 typedef struct _Elm_Photocam_Smart_Data     Elm_Photocam_Smart_Data;
121 typedef struct _Elm_Photocam_Pan_Smart_Data Elm_Photocam_Pan_Smart_Data;
122 typedef struct _Elm_Phocam_Grid             Elm_Phocam_Grid;
123 typedef struct _Elm_Photocam_Grid_Item      Elm_Photocam_Grid_Item;
124
125 struct _Elm_Photocam_Grid_Item
126 {
127    Elm_Photocam_Smart_Data *sd;
128    Evas_Object             *img;
129
130    struct
131    {
132       int x, y, w, h;
133    } src, out;
134
135    Eina_Bool                want : 1;
136    Eina_Bool                have : 1;
137 };
138
139 struct _Elm_Phocam_Grid
140 {
141    int                     tsize; /* size of tile (tsize x tsize pixels) */
142    int                     zoom; /* zoom level tiles want for optimal
143                                   * display (1, 2, 4, 8) */
144    int                     iw, ih; /* size of image in pixels */
145    int                     w, h; /* size of grid image in pixels
146                                   * (represented by grid) */
147    int                     gw, gh; /* size of grid in tiles */
148    Elm_Photocam_Grid_Item *grid;  /* the grid (gw * gh items) */
149    Eina_Bool               dead : 1; /* old grid. will die as soon as anim is
150                                       * over */
151 };
152
153 struct _Elm_Photocam_Smart_Data
154 {
155    Elm_Widget_Smart_Data                 base; /* base widget smart data as
156                                                 * first member obligatory, as
157                                                 * we're inheriting from it */
158
159    Evas_Object                          *hit_rect;
160    Evas_Object                          *g_layer;
161
162    const Elm_Scrollable_Smart_Interface *s_iface;
163
164    Evas_Object                          *pan_obj;
165
166    Evas_Coord                            pan_x, pan_y, minw, minh;
167
168    double                                g_layer_start;
169    double                                zoom;
170    Elm_Photocam_Zoom_Mode                mode;
171    Evas_Coord                            pvx, pvy, px, py, zoom_point_x,
172                                          zoom_point_y;
173
174    struct
175    {
176       int imx, imy;
177       struct
178       {
179          int             x_start, y_start;
180          int             x_end, y_end;
181          double          t_start;
182          double          t_end;
183          Ecore_Animator *animator;
184       } bounce;
185    } g_layer_zoom;
186
187    const char     *file;
188
189    Ecore_Job      *calc_job;
190    Ecore_Timer    *scr_timer;
191    Ecore_Timer    *long_timer;
192    Ecore_Animator *zoom_animator;
193    double          t_start, t_end;
194
195    struct
196    {
197       int imw, imh;
198       int w, h;
199       int ow, oh, nw, nh;
200       struct
201       {
202          double x, y;
203       } spos;
204    } size;
205
206    struct
207    {
208       Eina_Bool  show : 1;
209       Evas_Coord x, y, w, h;
210    } show;
211
212    int          tsize;
213    Evas_Object *img;  /* low res version of image (scale down == 8) */
214    int          no_smooth;
215    int          preload_num;
216
217    Eina_List   *grids;
218
219    Eina_Bool    main_load_pending : 1;
220    Eina_Bool    longpressed : 1;
221    Eina_Bool    do_gesture : 1;
222    Eina_Bool    do_region : 1;
223    Eina_Bool    zoom_g_layer : 1;
224    Eina_Bool    resized : 1;
225    Eina_Bool    on_hold : 1;
226    Eina_Bool    paused : 1;
227 };
228
229 typedef struct _Elm_Photocam_Pan_Smart_Class
230 {
231    Elm_Pan_Smart_Class base;
232 } Elm_Photocam_Pan_Smart_Class;
233
234 struct _Elm_Photocam_Pan_Smart_Data
235 {
236    Elm_Pan_Smart_Data       base;
237    Elm_Photocam_Smart_Data *wsd;
238 };
239
240 /**
241  * @}
242  */
243
244 EAPI extern const char ELM_PHOTOCAM_SMART_NAME[];
245 EAPI extern const char ELM_PHOTOCAM_PAN_SMART_NAME[];
246 EAPI const Elm_Photocam_Smart_Class *elm_photocam_smart_class_get(void);
247
248 #define ELM_PHOTOCAM_DATA_GET(o, sd) \
249   Elm_Photocam_Smart_Data * sd = evas_object_smart_data_get(o)
250
251 #define ELM_PHOTOCAM_PAN_DATA_GET(o, sd) \
252   Elm_Photocam_Pan_Smart_Data * sd = evas_object_smart_data_get(o)
253
254 #define ELM_PHOTOCAM_DATA_GET_OR_RETURN(o, ptr)      \
255   ELM_PHOTOCAM_DATA_GET(o, ptr);                     \
256   if (!ptr)                                          \
257     {                                                \
258        CRITICAL("No widget data for object %p (%s)", \
259                 o, evas_object_type_get(o));         \
260        return;                                       \
261     }
262
263 #define ELM_PHOTOCAM_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
264   ELM_PHOTOCAM_DATA_GET(o, ptr);                         \
265   if (!ptr)                                              \
266     {                                                    \
267        CRITICAL("No widget data for object %p (%s)",     \
268                 o, evas_object_type_get(o));             \
269        return val;                                       \
270     }
271
272 #define ELM_PHOTOCAM_CHECK(obj)                     \
273   if (!obj || !elm_widget_type_check                \
274         ((obj), ELM_PHOTOCAM_SMART_NAME, __func__)) \
275     return
276
277 #endif