Efl interface: Add image interface and start using it.

This commit is contained in:
Tom Hacohen 2014-07-23 17:03:40 +01:00
parent b2eda60802
commit 69219fe1e2
9 changed files with 221 additions and 117 deletions

View File

@ -1,12 +1,15 @@
BUILT_SOURCES += \
lib/efl/interfaces/efl_file.eo.c \
lib/efl/interfaces/efl_file.eo.h \
lib/efl/interfaces/efl_image.eo.c \
lib/efl/interfaces/efl_image.eo.h \
lib/efl/interfaces/efl_text_properties.eo.c \
lib/efl/interfaces/efl_text_properties.eo.h
efleolianfilesdir = $(datadir)/eolian/include/efl-@VMAJ@
efleolianfiles_DATA = \
lib/efl/interfaces/efl_file.eo \
lib/efl/interfaces/efl_image.eo \
lib/efl/interfaces/efl_text_properties.eo
EXTRA_DIST += \
@ -30,4 +33,5 @@ dist_installed_eflheaders_DATA = \
installed_eflinterfacesdir = $(includedir)/efl-@VMAJ@/interfaces
nodist_installed_eflinterfaces_DATA = \
lib/efl/interfaces/efl_file.eo.h \
lib/efl/interfaces/efl_image.eo.h \
lib/efl/interfaces/efl_text_properties.eo.h

View File

@ -4,6 +4,7 @@ if HAVE_CXX11
generated_efl_cxx_bindings = \
lib/efl/interfaces/efl_file.eo.hh \
lib/efl/interfaces/efl_image.eo.hh \
lib/efl/interfaces/efl_text_properties.eo.hh
lib/efl/Efl.hh: $(generated_efl_cxx_bindings)

View File

@ -2641,7 +2641,7 @@ _edje_proxy_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edj
p3->type.common.fill.y,
p3->type.common.fill.w,
p3->type.common.fill.h),
evas_obj_image_smooth_scale_set(p3->smooth),
efl_image_smooth_scale_set(p3->smooth),
evas_obj_image_source_visible_set(chosen_desc->proxy.source_visible),
evas_obj_image_source_clip_set(chosen_desc->proxy.source_clip));
}
@ -2656,7 +2656,7 @@ _edje_image_recalc_apply(Edje *ed, Edje_Real_Part *ep, Edje_Calc_Params *p3, Edj
eo_do(ep->object,
evas_obj_image_fill_set(p3->type.common.fill.x, p3->type.common.fill.y,
p3->type.common.fill.w, p3->type.common.fill.h),
evas_obj_image_smooth_scale_set(p3->smooth));
efl_image_smooth_scale_set(p3->smooth));
if (chosen_desc->image.border.scale)
{
if (p3->type.common.spec.image.border_scale_by > FROM_DOUBLE(0.0))

View File

@ -5,6 +5,7 @@
/* Interfaces */
#include "interfaces/efl_file.eo.h"
#include "interfaces/efl_image.eo.h"
#include "interfaces/efl_text_properties.eo.h"
#endif

View File

@ -0,0 +1,56 @@
interface Efl.Image {
legacy_prefix: null;
properties {
animated {
get {
/*@
Check if an image can be animated (have multiple frames)
@return whether the image support animation
*/
}
values {
bool is_animated; /*@ If it's animated or not. */
}
}
load_size {
set {
/*@
Set the loading size of an image. The image will be loaded into memory as if it was
the set size instead of the original size. This can save a lot of memory, and is
important for scalable types like svg.
*/
}
get {
}
values {
int w; /*@ The new width of the image's load size. */
int h; /*@ The new height of the image's load size. */
}
}
smooth_scale {
set {
/*@
Sets whether to use high-quality image scaling algorithm on the
given image.
When enabled, a higher quality image scaling algorithm is used when
scaling images to sizes other than the source image's original
one. This gives better results but is more computationally
expensive.
*/
}
get {
/*@
Retrieves whether the given image is using high-quality
image scaling algorithm.
@return Whether smooth scale is being used.
*/
}
values {
bool smooth_scale; /*@ Whether to use smooth scale or not. */
}
}
}
}

View File

@ -5,4 +5,5 @@
#include <Efl.h>
#include "interfaces/efl_file.eo.c"
#include "interfaces/efl_image.eo.c"
#include "interfaces/efl_text_properties.eo.c"

View File

@ -1328,6 +1328,121 @@ none).
*/
EAPI Eina_Bool evas_object_image_save(const Eo *obj, const char *file, const char *key, const char *flags) EINA_ARG_NONNULL(2);
/**
*
* Check if an image object can be animated (have multiple frames)
*
* @return whether obj support animation
*
* This returns if the image file of an image object is capable of animation
* such as an animated gif file might. This is only useful to be called once
* the image object file has been set.
*
* Example:
* @code
* extern Evas_Object *obj;
*
* if (evas_object_image_animated_get(obj))
* {
* int frame_count;
* int loop_count;
* Evas_Image_Animated_Loop_Hint loop_type;
* double duration;
*
* frame_count = evas_object_image_animated_frame_count_get(obj);
* printf("This image has %d frames\n",frame_count);
*
* duration = evas_object_image_animated_frame_duration_get(obj,1,0);
* printf("Frame 1's duration is %f. You had better set object's frame to 2 after this duration using timer\n");
*
* loop_count = evas_object_image_animated_loop_count_get(obj);
* printf("loop count is %d. You had better run loop %d times\n",loop_count,loop_count);
*
* loop_type = evas_object_image_animated_loop_type_get(obj);
* if (loop_type == EVAS_IMAGE_ANIMATED_HINT_LOOP)
* printf("You had better set frame like 1->2->3->1->2->3...\n");
* else if (loop_type == EVAS_IMAGE_ANIMATED_HINT_PINGPONG)
* printf("You had better set frame like 1->2->3->2->1->2...\n");
* else
* printf("Unknown loop type\n");
*
* evas_object_image_animated_frame_set(obj,1);
* printf("You set image object's frame to 1. You can see frame 1\n");
* }
* @endcode
*
* @see evas_object_image_animated_get()
* @see evas_object_image_animated_frame_count_get()
* @see evas_object_image_animated_loop_type_get()
* @see evas_object_image_animated_loop_count_get()
* @see evas_object_image_animated_frame_duration_get()
* @see evas_object_image_animated_frame_set()
* @since 1.1
*
*/
EAPI Eina_Bool evas_object_image_animated_get(const Eo *obj);
/**
*
* Set the size of a given image object's source image, when loading
* it.
*
* This function sets a new (loading) size for the given canvas
* image.
*
* @see evas_object_image_load_size_get()
*
* @param[in] w The new width of the image's load size.
* @param[in] h The new height of the image's load size.
*/
EAPI void evas_object_image_load_size_set(Eo *obj, int w, int h);
/**
*
* Get the size of a given image object's source image, when loading
* it.
*
* @note Use @c NULL pointers on the size components you're not
* interested in: they'll be ignored by the function.
*
* @see evas_object_image_load_size_set() for more details
*
* @param[out] w The new width of the image's load size.
* @param[out] h The new height of the image's load size.
*/
EAPI void evas_object_image_load_size_get(const Eo *obj, int *w, int *h);
/**
*
* Sets whether to use high-quality image scaling algorithm on the
* given image object.
*
* When enabled, a higher quality image scaling algorithm is used when
* scaling images to sizes other than the source image's original
* one. This gives better results but is more computationally
* expensive.
*
* @note Image objects get created originally with smooth scaling @b
* on.
*
* @see evas_object_image_smooth_scale_get()
*
* @param[in] smooth_scale Whether to use smooth scale or not.
*/
EAPI void evas_object_image_smooth_scale_set(Eo *obj, Eina_Bool smooth_scale);
/**
*
* Retrieves whether the given image object is using high-quality
* image scaling algorithm.
*
* @return Whether smooth scale is being used.
*
* See @ref evas_object_image_smooth_scale_set() for more details.
*
*/
EAPI Eina_Bool evas_object_image_smooth_scale_get(const Eo *obj);
#include "canvas/evas_image.eo.legacy.h"
/**

View File

@ -1,4 +1,4 @@
class Evas.Image (Evas.Object, Efl.File)
class Evas.Image (Evas.Object, Efl.File, Efl.Image)
{
legacy_prefix: evas_object_image;
eo_prefix: evas_obj_image;
@ -214,32 +214,6 @@ class Evas.Image (Evas.Object, Efl.File)
or not (@c EINA_FALSE). */
}
}
load_size {
set {
/*@
Set the size of a given image object's source image, when loading
it.
This function sets a new (loading) size for the given canvas
image.
@see evas_object_image_load_size_get() */
}
get {
/*@
Get the size of a given image object's source image, when loading
it.
@note Use @c NULL pointers on the size components you're not
interested in: they'll be ignored by the function.
@see evas_object_image_load_size_set() for more details */
}
values {
int w; /*@ The new width of the image's load size. */
int h; /*@ The new height of the image's load size. */
}
}
border {
set {
/*@
@ -295,35 +269,6 @@ class Evas.Image (Evas.Object, Efl.File)
int b; /*@ The border's bottom width. */
}
}
smooth_scale {
set {
/*@
Sets whether to use high-quality image scaling algorithm on the
given image object.
When enabled, a higher quality image scaling algorithm is used when
scaling images to sizes other than the source image's original
one. This gives better results but is more computationally
expensive.
@note Image objects get created originally with smooth scaling @b
on.
@see evas_object_image_smooth_scale_get() */
}
get {
/*@
Retrieves whether the given image object is using high-quality
image scaling algorithm.
@return Whether smooth scale is being used.
See @ref evas_object_image_smooth_scale_set() for more details. */
}
values {
bool smooth_scale; /*@ Whether to use smooth scale or not. */
}
}
border_scale {
set {
/*@
@ -849,60 +794,6 @@ class Evas.Image (Evas.Object, Efl.File)
return: int @warn_unused;
}
}
animated {
get {
/*@
Check if an image object can be animated (have multiple frames)
@return whether obj support animation
This returns if the image file of an image object is capable of animation
such as an animated gif file might. This is only useful to be called once
the image object file has been set.
Example:
@code
extern Evas_Object *obj;
if (evas_object_image_animated_get(obj))
{
int frame_count;
int loop_count;
Evas_Image_Animated_Loop_Hint loop_type;
double duration;
frame_count = evas_object_image_animated_frame_count_get(obj);
printf("This image has %d frames\n",frame_count);
duration = evas_object_image_animated_frame_duration_get(obj,1,0);
printf("Frame 1's duration is %f. You had better set object's frame to 2 after this duration using timer\n");
loop_count = evas_object_image_animated_loop_count_get(obj);
printf("loop count is %d. You had better run loop %d times\n",loop_count,loop_count);
loop_type = evas_object_image_animated_loop_type_get(obj);
if (loop_type == EVAS_IMAGE_ANIMATED_HINT_LOOP)
printf("You had better set frame like 1->2->3->1->2->3...\n");
else if (loop_type == EVAS_IMAGE_ANIMATED_HINT_PINGPONG)
printf("You had better set frame like 1->2->3->2->1->2...\n");
else
printf("Unknown loop type\n");
evas_object_image_animated_frame_set(obj,1);
printf("You set image object's frame to 1. You can see frame 1\n");
}
@endcode
@see evas_object_image_animated_get()
@see evas_object_image_animated_frame_count_get()
@see evas_object_image_animated_loop_type_get()
@see evas_object_image_animated_loop_count_get()
@see evas_object_image_animated_frame_duration_get()
@see evas_object_image_animated_frame_set()
@since 1.1 */
return: bool;
}
}
animated_loop_type {
get {
/*@
@ -1178,5 +1069,10 @@ class Evas.Image (Evas.Object, Efl.File)
Efl.File.file.set;
Efl.File.file.get;
Efl.File.save;
Efl.Image.animated.get;
Efl.Image.load_size.set;
Efl.Image.load_size.get;
Efl.Image.smooth_scale.set;
Efl.Image.smooth_scale.get;
}
}

View File

@ -1455,7 +1455,7 @@ _evas_image_alpha_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o)
}
EOLIAN static void
_evas_image_smooth_scale_set(Eo *eo_obj, Evas_Image_Data *o, Eina_Bool smooth_scale)
_evas_image_efl_image_smooth_scale_set(Eo *eo_obj, Evas_Image_Data *o, Eina_Bool smooth_scale)
{
Evas_Object_Protected_Data *obj;
@ -1472,7 +1472,7 @@ _evas_image_smooth_scale_set(Eo *eo_obj, Evas_Image_Data *o, Eina_Bool smooth_sc
}
EOLIAN static Eina_Bool
_evas_image_smooth_scale_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o)
_evas_image_efl_image_smooth_scale_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o)
{
return o->cur->smooth_scale;
}
@ -1694,7 +1694,7 @@ _evas_image_load_dpi_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o)
}
EOLIAN static void
_evas_image_load_size_set(Eo *eo_obj, Evas_Image_Data *o, int w, int h)
_evas_image_efl_image_load_size_set(Eo *eo_obj, Evas_Image_Data *o, int w, int h)
{
if ((o->load_opts->w == w) && (o->load_opts->h == h)) return;
@ -1718,7 +1718,7 @@ _evas_image_load_size_set(Eo *eo_obj, Evas_Image_Data *o, int w, int h)
}
EOLIAN static void
_evas_image_load_size_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o, int *w, int *h)
_evas_image_efl_image_load_size_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o, int *w, int *h)
{
if (w) *w = o->load_opts->w;
if (h) *h = o->load_opts->h;
@ -2055,7 +2055,7 @@ _evas_image_region_support_get(Eo *eo_obj, Evas_Image_Data *o)
/* animated feature */
EOLIAN static Eina_Bool
_evas_image_animated_get(Eo *eo_obj, Evas_Image_Data *o)
_evas_image_efl_image_animated_get(Eo *eo_obj, Evas_Image_Data *o)
{
Eina_Bool animated;
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
@ -4979,4 +4979,34 @@ evas_object_image_save(const Eo *obj, const char *file, const char *key, const c
return eo_do((Eo *) obj, efl_file_save(file, key, flags));
}
EAPI Eina_Bool
evas_object_image_animated_get(const Eo *obj)
{
return eo_do((Eo *) obj, efl_image_animated_get());
}
EAPI void
evas_object_image_load_size_set(Eo *obj, int w, int h)
{
eo_do((Eo *) obj, efl_image_load_size_set(w, h));
}
EAPI void
evas_object_image_load_size_get(const Eo *obj, int *w, int *h)
{
eo_do((Eo *) obj, efl_image_load_size_get(w, h));
}
EAPI void
evas_object_image_smooth_scale_set(Eo *obj, Eina_Bool smooth_scale)
{
eo_do((Eo *) obj, efl_image_smooth_scale_set(smooth_scale));
}
EAPI Eina_Bool
evas_object_image_smooth_scale_get(const Eo *obj)
{
return eo_do((Eo *) obj, efl_image_smooth_scale_get());
}
#include "canvas/evas_image.eo.c"