1 #ifndef ELM_WIDGET_IMAGE_H
2 #define ELM_WIDGET_IMAGE_H
8 * @section elm-image-class The Elementary Image Class
10 * This class defines a common interface for @b image objects having
11 * an image as their basic graphics. This interface is so that one can
12 * tune various properties of the image, like:
15 * - aspect ratio during resizes, etc.
17 * Image files may be set via memory buffers, image files, EET files
18 * with image data or Edje files. On the last case (which is
19 * exceptional), most of the properties cited above will @b not be
24 * @def ELM_IMAGE_CLASS
26 * Use this macro to cast whichever subclass of
27 * #Elm_Image_Smart_Class into it, so to access its fields.
31 #define ELM_IMAGE_CLASS(x) ((Elm_Image_Smart_Class *) x)
36 * Use this macro to cast whichever subdata of
37 * #Elm_Image_Smart_Data into it, so to access its fields.
41 #define ELM_IMAGE_DATA(x) ((Elm_Image_Smart_Data *) x)
44 * @def ELM_IMAGE_SMART_CLASS_VERSION
46 * Current version for Elementary image @b base smart class, a value
47 * which goes to _Elm_Image_Smart_Class::version.
51 #define ELM_IMAGE_SMART_CLASS_VERSION 1
54 * @def ELM_IMAGE_SMART_CLASS_INIT
56 * Initializer for a whole #Elm_Image_Smart_Class structure, with
57 * @c NULL values on its specific fields.
59 * @param smart_class_init initializer to use for the "base" field
60 * (#Evas_Smart_Class).
62 * @see EVAS_SMART_CLASS_INIT_NULL
63 * @see EVAS_SMART_CLASS_INIT_NAME_VERSION
64 * @see ELM_IMAGE_SMART_CLASS_INIT_NULL
65 * @see ELM_IMAGE_SMART_CLASS_INIT_NAME_VERSION
69 #define ELM_IMAGE_SMART_CLASS_INIT(smart_class_init) \
70 {smart_class_init, ELM_IMAGE_SMART_CLASS_VERSION, NULL, NULL, NULL, NULL, \
71 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, \
72 NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL}
75 * @def ELM_IMAGE_SMART_CLASS_INIT_NULL
77 * Initializer to zero out a whole #Elm_Image_Smart_Class structure.
79 * @see ELM_IMAGE_SMART_CLASS_INIT_NAME_VERSION
80 * @see ELM_IMAGE_SMART_CLASS_INIT
84 #define ELM_IMAGE_SMART_CLASS_INIT_NULL \
85 ELM_IMAGE_SMART_CLASS_INIT(EVAS_SMART_CLASS_INIT_NULL)
88 * @def ELM_IMAGE_SMART_CLASS_INIT_NAME_VERSION
90 * Initializer to zero out a whole #Elm_Image_Smart_Class structure and
91 * set its name and version.
93 * This is similar to #ELM_IMAGE_SMART_CLASS_INIT_NULL, but it will
94 * also set the version field of #Elm_Image_Smart_Class (base field)
95 * to the latest #ELM_IMAGE_SMART_CLASS_VERSION and name it to the
98 * It will keep a reference to the name field as a <c>"const char *"</c>,
99 * i.e., the name must be available while the structure is
100 * used (hint: static or global variable!) and must not be modified.
102 * @see ELM_IMAGE_SMART_CLASS_INIT_NULL
103 * @see ELM_IMAGE_SMART_CLASS_INIT
107 #define ELM_IMAGE_SMART_CLASS_INIT_NAME_VERSION(name) \
108 ELM_IMAGE_SMART_CLASS_INIT(ELM_WIDGET_SMART_CLASS_INIT_NAME_VERSION(name))
111 * Elementary image base smart class. This inherits directly from
112 * #Elm_Widget_Smart_Class and is meant to build widgets relying on an
113 * image as the building block of its visuals.
116 typedef struct _Elm_Image_Smart_Class
118 Elm_Widget_Smart_Class base; /**< Base Elementary widget class struct, since we're inheriting from it */
120 int version; /**< Version of this smart class definition */
122 void (*sizing_eval)(Evas_Object *obj); /* 'Virtual' function on evalutating the object's final geometry */
123 Eina_Bool (*memfile_set)(Evas_Object *obj,
127 const char *key); /* 'Virtual' function on setting the image content on the object via a memory buffer */
128 Eina_Bool (*file_set)(Evas_Object *obj,
130 const char *key); /* 'Virtual' function on setting the image content on the object via a file. It may be a direct image, an EET-encoded image or an Edje file. They @a key argument will be used for the last two cases mentioned (@c NULL must be used on the first). Beware that the Edje case will only be detected by an @c "edj" extension on the file name. */
131 void (*file_get)(const Evas_Object *obj,
133 const char **key); /* 'Virtual' function on retrieving back the image object's file path and key */
135 Evas_Object *(*image_object_get)(const Evas_Object *obj); /* 'Virtual' function on retrieving the object's internal image file, which may me an Evas image or an Edje file */
137 void (*size_get)(const Evas_Object *obj,
139 int *h); /* 'Virtual' function on retrieving the size of the object's internal image. */
141 void (*preload_set)(Evas_Object *obj,
142 Eina_Bool disable); /* 'Virtual' function on enabling/disabling pre-loading for the object's image data. */
143 void (*fill_inside_set)(Evas_Object *obj,
144 Eina_Bool fill_inside); /* 'Virtual' function on how to resize the object's internal image, when maintaining a given aspect ratio -- leave blank spaces or scale to fill all space, with pixels out of bounds. */
145 Eina_Bool (*fill_inside_get)(const Evas_Object *obj); /* 'Virtual' function on retrieving how the object's internal image is to be resized, when maintaining a given aspect ratio. */
147 void (*scale_set)(Evas_Object *obj,
148 double scale); /* 'Virtual' function on setting the scale for the object's image size (@c 1.0 meaning original size). */
149 double (*scale_get)(const Evas_Object *obj); /* 'Virtual' function on retrieving the scale for the object's image size. */
151 void (*smooth_scale_set)(Evas_Object *obj,
152 Eina_Bool smooth); /* 'Virtual' function on setting whether the object's image should be scaled smoothly or not. */
153 Eina_Bool (*smooth_scale_get)(const Evas_Object *obj); /* 'Virtual' function on retrieving whether the object's image is to scaled smoothly or not. */
154 void (*resize_up_set)(Evas_Object *obj,
155 Eina_Bool resize_up); /* 'Virtual' function on setting whether the object's image can be resized to a size greater than the original one. */
156 Eina_Bool (*resize_up_get)(const Evas_Object *obj); /* 'Virtual' function on retrieving whether the object's image can be resized to a size greater than the original one. */
157 void (*resize_down_set)(Evas_Object *obj,
158 Eina_Bool resize_down); /* 'Virtual' function on setting whether the object's image can be resized to a size smaller than the original one. */
159 Eina_Bool (*resize_down_get)(const Evas_Object *obj); /* 'Virtual' function on retrieving whether the object's image can be resized to a size smaller than the original one. */
160 void (*load_size_set)(Evas_Object *obj,
161 int size); /* 'Virtual' function on setting the object's image loading size (in pixels, applied to both axis). */
162 int (*load_size_get)(const Evas_Object *obj); /* 'Virtual' function on retrieving the object's image loading size. */
164 void (*orient_set)(Evas_Object *obj,
165 Elm_Image_Orient orient); /* 'Virtual' function on setting the object's image orientation. */
166 Elm_Image_Orient (*orient_get)(const Evas_Object *obj); /* 'Virtual' function on retrieving the object's image orientation. */
168 void (*aspect_fixed_set)(Evas_Object *obj,
169 Eina_Bool fixed); /* 'Virtual' function on setting whether the original aspect ratio of the object's image should be kept if it's resized. */
170 Eina_Bool (*aspect_fixed_get)(const Evas_Object *obj); /* 'Virtual' function on retrieving whether the original aspect ratio of the object's image is to be kept if it's resized. */
172 void (*edit_set)(Evas_Object *obj,
174 Evas_Object *parent); /* 'Virtual' function on setting whether the object is a valid target/source for drag and drop actions. */
175 Eina_Bool (*edit_get)(const Evas_Object *obj); /* 'Virtual' function on retrieving whether the object is a valid target/source for drag and drop actions. */
176 } Elm_Image_Smart_Class;
179 * Base widget smart data extended with image instance data.
181 typedef struct _Elm_Image_Smart_Data Elm_Image_Smart_Data;
182 struct _Elm_Image_Smart_Data
184 Elm_Widget_Smart_Data base;
186 Evas_Object *hit_rect;
188 Evas_Object *prev_img;
190 Evas_Coord img_x, img_y, img_w, img_h;
194 Elm_Image_Orient orient;
198 double frame_duration;
200 Eina_Bool aspect_fixed : 1;
201 Eina_Bool fill_inside : 1;
202 Eina_Bool resize_down : 1;
203 Eina_Bool preloading : 1;
204 Eina_Bool resize_up : 1;
205 Eina_Bool no_scale : 1;
206 Eina_Bool smooth : 1;
213 Ecore_Timer *anim_timer;
220 EAPI extern const char ELM_IMAGE_SMART_NAME[];
221 EAPI const Elm_Image_Smart_Class *elm_image_smart_class_get(void);
223 #define ELM_IMAGE_DATA_GET(o, sd) \
224 Elm_Image_Smart_Data * sd = evas_object_smart_data_get(o)
226 #define ELM_IMAGE_DATA_GET_OR_RETURN(o, ptr) \
227 ELM_IMAGE_DATA_GET(o, ptr); \
230 CRITICAL("No widget data for object %p (%s)", \
231 o, evas_object_type_get(o)); \
235 #define ELM_IMAGE_DATA_GET_OR_RETURN_VAL(o, ptr, val) \
236 ELM_IMAGE_DATA_GET(o, ptr); \
239 CRITICAL("No widget data for object %p (%s)", \
240 o, evas_object_type_get(o)); \
244 #define ELM_IMAGE_CHECK(obj) \
245 if (!obj || !elm_widget_type_check((obj), ELM_IMAGE_SMART_NAME, __func__)) \