migration merge<Jiyoun Park>
[framework/uifw/elementary.git] / src / lib / elm_image.h
1 /**
2  * @defgroup Image Image
3  *
4  * @image html img/widget/image/preview-00.png
5  * @image latex img/widget/image/preview-00.eps
6
7  *
8  * An object that allows one to load an image file to it. It can be used
9  * anywhere like any other elementary widget.
10  *
11  * This widget provides most of the functionality provided from @ref Bg or @ref
12  * Icon, but with a slightly different API (use the one that fits better your
13  * needs).
14  *
15  * The features not provided by those two other image widgets are:
16  * @li allowing to get the basic @c Evas_Object with elm_image_object_get();
17  * @li change the object orientation with elm_image_orient_set();
18  * @li and turning the image editable with elm_image_editable_set().
19  *
20  * Signals that you can add callbacks for are:
21  *
22  * @li @c "clicked" - This is called when a user has clicked the image
23  *
24  * An example of usage for this API follows:
25  * @li @ref tutorial_image
26  */
27
28 /**
29  * @addtogroup Image
30  * @{
31  */
32
33 /**
34  * Possible orientation options for elm_image_orient_set().
35  *
36  * @image html elm_image_orient_set.png
37  * @image latex elm_image_orient_set.eps width=\textwidth
38  *
39  * @ingroup Image
40  */
41 typedef enum
42 {
43    ELM_IMAGE_ORIENT_NONE = 0, /**< no orientation change */
44    ELM_IMAGE_ORIENT_0 = 0, /**< no orientation change */
45    ELM_IMAGE_ROTATE_90 = 1, /**< rotate 90 degrees clockwise */
46    ELM_IMAGE_ROTATE_180 = 2, /**< rotate 180 degrees clockwise */
47    ELM_IMAGE_ROTATE_270 = 3, /**< rotate 90 degrees counter-clockwise (i.e. 270 degrees clockwise) */
48    ELM_IMAGE_FLIP_HORIZONTAL = 4, /**< flip image horizontally */
49    ELM_IMAGE_FLIP_VERTICAL = 5, /**< flip image vertically */
50    ELM_IMAGE_FLIP_TRANSPOSE = 6, /**< flip the image along the y = (width - x) line (bottom-left to top-right) */
51    ELM_IMAGE_FLIP_TRANSVERSE = 7 /**< flip the image along the y = x line (top-left to bottom-right) */
52 } Elm_Image_Orient;
53
54 /**
55  * Add a new image to the parent.
56  *
57  * @param parent The parent object
58  * @return The new object or NULL if it cannot be created
59  *
60  * @see elm_image_file_set()
61  *
62  * @ingroup Image
63  */
64 EAPI Evas_Object     *elm_image_add(Evas_Object *parent);
65
66 /**
67  * Set the file that will be used as image.
68  *
69  * @param obj The image object
70  * @param file The path to file that will be used as image
71  * @param group The group that the image belongs in edje file (if it's an
72  * edje image)
73  *
74  * @return (@c EINA_TRUE = success, @c EINA_FALSE = error)
75  *
76  * @see elm_image_file_get()
77  *
78  * @ingroup Image
79  */
80 EAPI Eina_Bool        elm_image_file_set(Evas_Object *obj, const char *file, const char *group);
81
82 /**
83  * Get the file that will be used as image.
84  *
85  * @param obj The image object
86  * @param file The path to file
87  * @param group The group that the image belongs in edje file
88  *
89  * @see elm_image_file_set()
90  *
91  * @ingroup Image
92  */
93 EAPI void             elm_image_file_get(const Evas_Object *obj, const char **file, const char **group);
94
95 /**
96  * Set the smooth effect for an image.
97  *
98  * @param obj The image object
99  * @param smooth @c EINA_TRUE if smooth scaling should be used, @c EINA_FALSE
100  * otherwise. Default is @c EINA_TRUE.
101  *
102  * Set the scaling algorithm to be used when scaling the image. Smooth
103  * scaling provides a better resulting image, but is slower.
104  *
105  * The smooth scaling should be disabled when making animations that change
106  * the image size, since it will be faster. Animations that don't require
107  * resizing of the image can keep the smooth scaling enabled (even if the
108  * image is already scaled, since the scaled image will be cached).
109  *
110  * @see elm_image_smooth_get()
111  *
112  * @ingroup Image
113  */
114 EAPI void             elm_image_smooth_set(Evas_Object *obj, Eina_Bool smooth);
115
116 /**
117  * Get the smooth effect for an image.
118  *
119  * @param obj The image object
120  * @return @c EINA_TRUE if smooth scaling is enabled, @c EINA_FALSE otherwise.
121  *
122  * @see elm_image_smooth_get()
123  *
124  * @ingroup Image
125  */
126 EAPI Eina_Bool        elm_image_smooth_get(const Evas_Object *obj);
127
128 /**
129  * Gets the current size of the image.
130  *
131  * @param obj The image object.
132  * @param w Pointer to store width, or NULL.
133  * @param h Pointer to store height, or NULL.
134  *
135  * This is the real size of the image, not the size of the object.
136  *
137  * @ingroup Image
138  */
139 EAPI void             elm_image_object_size_get(const Evas_Object *obj, int *w, int *h);
140
141 /**
142  * Disable scaling of this object.
143  *
144  * @param obj The image object.
145  * @param no_scale @c EINA_TRUE if the object is not scalable, @c EINA_FALSE
146  * otherwise. Default is @c EINA_FALSE.
147  *
148  * This function disables scaling of the elm_image widget through the
149  * function elm_object_scale_set(). However, this does not affect the widget
150  * size/resize in any way. For that effect, take a look at
151  * elm_image_resizable_set().
152  *
153  * @see elm_image_no_scale_get()
154  * @see elm_image_resizable_set()
155  * @see elm_object_scale_set()
156  *
157  * @ingroup Image
158  */
159 EAPI void             elm_image_no_scale_set(Evas_Object *obj, Eina_Bool no_scale);
160
161 /**
162  * Get whether scaling is disabled on the object.
163  *
164  * @param obj The image object
165  * @return @c EINA_TRUE if scaling is disabled, @c EINA_FALSE otherwise
166  *
167  * @see elm_image_no_scale_set()
168  *
169  * @ingroup Image
170  */
171 EAPI Eina_Bool        elm_image_no_scale_get(const Evas_Object *obj);
172
173 /**
174  * Set if the object is (up/down) resizable.
175  *
176  * @param obj The image object
177  * @param size_up A bool to set if the object is resizable up. Default is
178  * @c EINA_TRUE.
179  * @param size_down A bool to set if the object is resizable down. Default
180  * is @c EINA_TRUE.
181  *
182  * This function limits the image resize ability. If @p size_up is set to
183  * @c EINA_FALSE, the object can't have its height or width resized to a value
184  * higher than the original image size. Same is valid for @p size_down.
185  *
186  * @see elm_image_resizable_get()
187  *
188  * @ingroup Image
189  */
190 EAPI void             elm_image_resizable_set(Evas_Object *obj, Eina_Bool size_up, Eina_Bool size_down);
191
192 /**
193  * Get if the object is (up/down) resizable.
194  *
195  * @param obj The image object
196  * @param size_up A bool to set if the object is resizable up
197  * @param size_down A bool to set if the object is resizable down
198  *
199  * @see elm_image_resizable_set()
200  *
201  * @ingroup Image
202  */
203 EAPI void             elm_image_resizable_get(const Evas_Object *obj, Eina_Bool *size_up, Eina_Bool *size_down);
204
205 /**
206  * Set if the image fills the entire object area, when keeping the aspect ratio.
207  *
208  * @param obj The image object
209  * @param fill_outside @c EINA_TRUE if the object is filled outside,
210  * @c EINA_FALSE otherwise. Default is @c EINA_FALSE.
211  *
212  * When the image should keep its aspect ratio even if resized to another
213  * aspect ratio, there are two possibilities to resize it: keep the entire
214  * image inside the limits of height and width of the object (@p fill_outside
215  * is @c EINA_FALSE) or let the extra width or height go outside of the object,
216  * and the image will fill the entire object (@p fill_outside is @c EINA_TRUE).
217  *
218  * @note This option will have no effect if
219  * elm_image_aspect_fixed_set() is set to @c EINA_FALSE.
220  *
221  * @see elm_image_fill_outside_get()
222  * @see elm_image_aspect_fixed_set()
223  *
224  * @ingroup Image
225  */
226 EAPI void             elm_image_fill_outside_set(Evas_Object *obj, Eina_Bool fill_outside);
227
228 /**
229  * Get if the object is filled outside
230  *
231  * @param obj The image object
232  * @return @c EINA_TRUE if the object is filled outside, @c EINA_FALSE otherwise.
233  *
234  * @see elm_image_fill_outside_set()
235  *
236  * @ingroup Image
237  */
238 EAPI Eina_Bool        elm_image_fill_outside_get(const Evas_Object *obj);
239
240 /**
241  * Enable or disable preloading of the image
242  *
243  * @param obj The image object
244  * @param disabled If EINA_TRUE, preloading will be disabled
245  * @ingroup Icon
246  */
247 EAPI void                  elm_image_preload_disabled_set(Evas_Object *obj, Eina_Bool disabled);
248
249 /**
250  * Set the prescale size for the image
251  *
252  * @param obj The image object
253  * @param size The prescale size. This value is used for both width and
254  * height.
255  *
256  * This function sets a new size for pixmap representation of the given
257  * image. It allows the image to be loaded already in the specified size,
258  * reducing the memory usage and load time when loading a big image with load
259  * size set to a smaller size.
260  *
261  * It's equivalent to the elm_bg_load_size_set() function for bg.
262  *
263  * @note this is just a hint, the real size of the pixmap may differ
264  * depending on the type of image being loaded, being bigger than requested.
265  *
266  * @see elm_image_prescale_get()
267  * @see elm_bg_load_size_set()
268  *
269  * @ingroup Image
270  */
271 EAPI void             elm_image_prescale_set(Evas_Object *obj, int size);
272
273 /**
274  * Get the prescale size for the image
275  *
276  * @param obj The image object
277  * @return The prescale size
278  *
279  * @see elm_image_prescale_set()
280  *
281  * @ingroup Image
282  */
283 EAPI int              elm_image_prescale_get(const Evas_Object *obj);
284
285 /**
286  * Set the image orientation.
287  *
288  * @param obj The image object
289  * @param orient The image orientation @ref Elm_Image_Orient
290  *  Default is #ELM_IMAGE_ORIENT_NONE.
291  *
292  * This function allows to rotate or flip the given image.
293  *
294  * @see elm_image_orient_get()
295  * @see @ref Elm_Image_Orient
296  *
297  * @ingroup Image
298  */
299 EAPI void             elm_image_orient_set(Evas_Object *obj, Elm_Image_Orient orient);
300
301 /**
302  * Get the image orientation.
303  *
304  * @param obj The image object
305  * @return The image orientation @ref Elm_Image_Orient
306  *
307  * @see elm_image_orient_set()
308  * @see @ref Elm_Image_Orient
309  *
310  * @ingroup Image
311  */
312 EAPI Elm_Image_Orient elm_image_orient_get(const Evas_Object *obj);
313
314 /**
315  * Make the image 'editable'.
316  *
317  * @param obj Image object.
318  * @param set Turn on or off editability. Default is @c EINA_FALSE.
319  *
320  * This means the image is a valid drag target for drag and drop, and can be
321  * cut or pasted too.
322  *
323  * @ingroup Image
324  */
325 EAPI void             elm_image_editable_set(Evas_Object *obj, Eina_Bool set);
326
327 /**
328  * Check if the image is 'editable'.
329  *
330  * @param obj Image object.
331  * @return Editability.
332  *
333  * A return value of EINA_TRUE means the image is a valid drag target
334  * for drag and drop, and can be cut or pasted too.
335  *
336  * @ingroup Image
337  */
338 EAPI Eina_Bool        elm_image_editable_get(const Evas_Object *obj);
339
340 /**
341  * Get the inlined image object of the image widget.
342  *
343  * @param obj The image object to get the inlined image from
344  * @return The inlined image object, or NULL if none exists
345  *
346  * This function allows one to get the underlying @c Evas_Object of type
347  * Image from this elementary widget. It can be useful to do things like get
348  * the pixel data, save the image to a file, etc.
349  *
350  * @note Be careful to not manipulate it, as it is under control of
351  * elementary.
352  *
353  * @ingroup Image
354  */
355 EAPI Evas_Object     *elm_image_object_get(const Evas_Object *obj);
356
357 /**
358  * Set whether the original aspect ratio of the image should be kept on resize.
359  *
360  * @param obj The image object.
361  * @param fixed @c EINA_TRUE if the image should retain the aspect,
362  * @c EINA_FALSE otherwise.
363  *
364  * The original aspect ratio (width / height) of the image is usually
365  * distorted to match the object's size. Enabling this option will retain
366  * this original aspect, and the way that the image is fit into the object's
367  * area depends on the option set by elm_image_fill_outside_set().
368  *
369  * @see elm_image_aspect_fixed_get()
370  * @see elm_image_fill_outside_set()
371  *
372  * @ingroup Image
373  */
374 EAPI void             elm_image_aspect_fixed_set(Evas_Object *obj, Eina_Bool fixed);
375
376 /**
377  * Get if the object retains the original aspect ratio.
378  *
379  * @param obj The image object.
380  * @return @c EINA_TRUE if the object keeps the original aspect, @c EINA_FALSE
381  * otherwise.
382  *
383  * @ingroup Image
384  */
385 EAPI Eina_Bool        elm_image_aspect_fixed_get(const Evas_Object *obj);
386
387 /**
388  * @}
389  */