1 #ifndef EFL_UI_WIDGET_IMAGE_H
2 #define EFL_UI_WIDGET_IMAGE_H
3 
4 #include "Elementary.h"
5 
6 /* DO NOT USE THIS HEADER UNLESS YOU ARE PREPARED FOR BREAKING OF YOUR
7  * CODE. THIS IS ELEMENTARY'S INTERNAL WIDGET API (for now) AND IS NOT
8  * FINAL. CALL elm_widget_api_check(ELM_INTERNAL_API_VERSION) TO CHECK
9  * IT AT RUNTIME.
10  */
11 
12 typedef enum
13   {
14      EFL_UI_IMAGE_PRELOAD_ENABLED,
15      EFL_UI_IMAGE_PRELOADING,
16      EFL_UI_IMAGE_PRELOADED,
17      EFL_UI_IMAGE_PRELOAD_DISABLED
18   } Efl_Ui_Image_Preload_Status;
19 
20 /**
21  * @addtogroup Widget
22  * @{
23  *
24  * @section elm-image-class The Elementary Image Class
25  *
26  * This class defines a common interface for @b image objects having
27  * an image as their basic graphics. This interface is so that one can
28  * tune various properties of the image, like:
29  * - smooth scaling,
30  * - orientation,
31  * - aspect ratio during resizes, etc.
32  *
33  * Image files may be set via memory buffers, image files, EET files
34  * with image data or Edje files. On the last case (which is
35  * exceptional), most of the properties cited above will @b not be
36  * changeable anymore.
37  */
38 
39 /**
40  * Base widget smart data extended with image instance data.
41  */
42 typedef struct _Efl_Ui_Image_Data Efl_Ui_Image_Data;
43 struct _Efl_Ui_Image_Data
44 {
45    Eo                   *self;
46    Evas_Object          *hit_rect;
47    Evas_Object          *img;
48    Evas_Object          *prev_img;
49    Ecore_Timer          *anim_timer;
50 
51    struct {
52       Eo                *copier;
53       Eina_Binbuf       *binbuf;
54       const char        *key;
55    } remote;
56 
57    double                scale;
58    double                frame_duration;
59    double                playback_speed;
60    double                align_x, align_y;
61 
62    Eina_Size2D           load_size;
63    int                   frame_count;
64    int                   cur_frame;
65 
66    Elm_Image_Orient      image_orient; // to support EAPI
67    Efl_Gfx_Image_Orientation orient;
68 
69    struct {
70       Ecore_Thread      *th;
71       Eina_Stringshare  *file, *key; // only for file_get()
72       void              *todo; // opaque internal
73    } async;
74 
75    Efl_Ui_Image_Preload_Status preload_status;
76    Efl_Gfx_Image_Scale_Method scale_type;
77 
78    const char           *stdicon;
79 
80    struct {
81       Eina_Stringshare  *file;
82       Eina_Stringshare  *key;
83 
84       Eina_Bool          icon : 1;
85    } property;
86 
87    struct {
88       int       requested_size;
89       Eina_Bool use : 1;
90    } freedesktop;
91 
92    Eina_Bool             aspect_fixed : 1;
93    Eina_Bool             fill_inside : 1;
94    Eina_Bool             no_scale : 1;
95    Eina_Bool             smooth : 1;
96    Eina_Bool             show : 1;
97    Eina_Bool             edit : 1;
98    Eina_Bool             edje : 1;
99    Eina_Bool             anim : 1;
100    Eina_Bool             autoplay : 1;
101    Eina_Bool             playback_loop : 1;
102    Eina_Bool             paused : 1;
103    Eina_Bool             async_enable : 1;
104    Eina_Bool             scale_up : 1;
105    Eina_Bool             scale_down : 1;
106    Eina_Bool             legacy_align : 1;
107    Eina_Bool             property_watch : 1;
108    Eina_Bool             in_calc : 1;
109 };
110 
111 /**
112  * @}
113  */
114 
115 #define EFL_UI_IMAGE_DATA_GET(o, sd) \
116   Efl_Ui_Image_Data * sd = efl_data_scope_get(o, EFL_UI_IMAGE_CLASS)
117 
118 #define EFL_UI_IMAGE_DATA_GET_OR_RETURN(o, ptr)         \
119   EFL_UI_IMAGE_DATA_GET(o, ptr);                        \
120   if (EINA_UNLIKELY(!ptr))                           \
121     {                                                \
122        ERR("No widget data for object %p (%s)",      \
123            o, evas_object_type_get(o));              \
124        return;                                       \
125     }
126 
127 #define EFL_UI_IMAGE_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
128   EFL_UI_IMAGE_DATA_GET(o, ptr);                         \
129   if (EINA_UNLIKELY(!ptr))                            \
130     {                                                 \
131        ERR("No widget data for object %p (%s)",       \
132            o, evas_object_type_get(o));               \
133        return val;                                    \
134     }
135 
136 #define EFL_UI_IMAGE_CHECK(obj)                              \
137   if (EINA_UNLIKELY(!efl_isa((obj), EFL_UI_IMAGE_CLASS))) \
138     return
139 
140 #endif
141