forked from enlightenment/efl
Interface file: Update file interface and use it for image.
This commit is contained in:
parent
c31c624e01
commit
500c4019dd
|
@ -3,13 +3,73 @@ interface Efl.File {
|
|||
properties {
|
||||
file {
|
||||
set {
|
||||
return Eina_Bool;
|
||||
/*@
|
||||
Set the source file from where an image object must fetch the real
|
||||
image data (it may be an Eet file, besides pure image ones).
|
||||
|
||||
If the file supports multiple data stored in it (as Eet files do),
|
||||
you can specify the key to be used as the index of the image in
|
||||
this file.
|
||||
|
||||
Example:
|
||||
@code
|
||||
img = evas_object_image_add(canvas);
|
||||
evas_object_image_file_set(img, "/path/to/img", NULL);
|
||||
err = evas_object_image_load_error_get(img);
|
||||
if (err != EVAS_LOAD_ERROR_NONE)
|
||||
{
|
||||
fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
|
||||
valid_path, evas_load_error_str(err));
|
||||
}
|
||||
else
|
||||
{
|
||||
evas_object_image_fill_set(img, 0, 0, w, h);
|
||||
evas_object_resize(img, w, h);
|
||||
evas_object_show(img);
|
||||
}
|
||||
@endcode */
|
||||
|
||||
return bool;
|
||||
}
|
||||
get {
|
||||
/*@
|
||||
Retrieve the source file from where an image object is to fetch the
|
||||
real image data (it may be an Eet file, besides pure image ones).
|
||||
|
||||
You must @b not modify the strings on the returned pointers.
|
||||
|
||||
@note Use @c NULL pointers on the file components you're not
|
||||
interested in: they'll be ignored by the function. */
|
||||
}
|
||||
values {
|
||||
const(char) *file; /*@ The path to the file to load @p from */
|
||||
const(char) *group; /*@ The name of the group, in @p file */
|
||||
const(char)* file; /*@ The image file path. */
|
||||
const(char)* key; /*@ The image key in @p file (if its an Eet one), or @c
|
||||
NULL, otherwise. */
|
||||
}
|
||||
}
|
||||
}
|
||||
methods {
|
||||
save @const {
|
||||
/*@
|
||||
Save the given image object's contents to an (image) file.
|
||||
|
||||
The extension suffix on @p file will determine which <b>saver
|
||||
module</b> Evas is to use when saving, thus the final file's
|
||||
format. If the file supports multiple data stored in it (Eet ones),
|
||||
you can specify the key to be used as the index of the image in it.
|
||||
|
||||
You can specify some flags when saving the image. Currently
|
||||
acceptable flags are @c quality and @c compress. Eg.: @c
|
||||
"quality=100 compress=9" */
|
||||
|
||||
return bool;
|
||||
params {
|
||||
@in const(char)* file @nonull; /*@ The filename to be used to save the image (extension
|
||||
obligatory). */
|
||||
@in const(char)* key; /*@ The image key in the file (if an Eet one), or @c NULL,
|
||||
otherwise. */
|
||||
@in const(char)* flags; /*@ String containing the flags to be used (@c NULL for
|
||||
none). */
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1257,6 +1257,77 @@ EAPI Eina_Bool evas_object_image_source_unset(Evas_Object *o
|
|||
*/
|
||||
EAPI void evas_object_image_alpha_mask_set(Evas_Object *obj, Eina_Bool ismask) EINA_ARG_NONNULL(1);
|
||||
|
||||
/**
|
||||
*
|
||||
* Set the source file from where an image object must fetch the real
|
||||
* image data (it may be an Eet file, besides pure image ones).
|
||||
*
|
||||
* If the file supports multiple data stored in it (as Eet files do),
|
||||
* you can specify the key to be used as the index of the image in
|
||||
* this file.
|
||||
*
|
||||
* Example:
|
||||
* @code
|
||||
* img = evas_object_image_add(canvas);
|
||||
* evas_object_image_file_set(img, "/path/to/img", NULL);
|
||||
* err = evas_object_image_load_error_get(img);
|
||||
* if (err != EVAS_LOAD_ERROR_NONE)
|
||||
* {
|
||||
* fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
|
||||
* valid_path, evas_load_error_str(err));
|
||||
* }
|
||||
* else
|
||||
* {
|
||||
* evas_object_image_fill_set(img, 0, 0, w, h);
|
||||
* evas_object_resize(img, w, h);
|
||||
* evas_object_show(img);
|
||||
* }
|
||||
* @endcode
|
||||
*
|
||||
* @param[in] file The image file path.
|
||||
* @param[in] key The image key in @p file (if its an Eet one), or @c
|
||||
NULL, otherwise.
|
||||
*/
|
||||
EAPI void evas_object_image_file_set(Eo *obj, const char *file, const char *key);
|
||||
|
||||
/**
|
||||
*
|
||||
* Retrieve the source file from where an image object is to fetch the
|
||||
* real image data (it may be an Eet file, besides pure image ones).
|
||||
*
|
||||
* You must @b not modify the strings on the returned pointers.
|
||||
*
|
||||
* @note Use @c NULL pointers on the file components you're not
|
||||
* interested in: they'll be ignored by the function.
|
||||
*
|
||||
* @param[out] file The image file path.
|
||||
* @param[out] key The image key in @p file (if its an Eet one), or @c
|
||||
NULL, otherwise.
|
||||
*/
|
||||
EAPI void evas_object_image_file_get(const Eo *obj, const char **file, const char **key);
|
||||
|
||||
/**
|
||||
*
|
||||
* Save the given image object's contents to an (image) file.
|
||||
*
|
||||
* The extension suffix on @p file will determine which <b>saver
|
||||
* module</b> Evas is to use when saving, thus the final file's
|
||||
* format. If the file supports multiple data stored in it (Eet ones),
|
||||
* you can specify the key to be used as the index of the image in it.
|
||||
*
|
||||
* You can specify some flags when saving the image. Currently
|
||||
* acceptable flags are @c quality and @c compress. Eg.: @c
|
||||
* "quality=100 compress=9"
|
||||
*
|
||||
* @param[in] file The filename to be used to save the image (extension
|
||||
obligatory).
|
||||
* @param[in] key The image key in the file (if an Eet one), or @c NULL,
|
||||
otherwise.
|
||||
* @param[in] flags String containing the flags to be used (@c NULL for
|
||||
none).
|
||||
*/
|
||||
EAPI Eina_Bool evas_object_image_save(const Eo *obj, const char *file, const char *key, const char *flags) EINA_ARG_NONNULL(2);
|
||||
|
||||
#include "canvas/evas_image.eo.legacy.h"
|
||||
|
||||
/**
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
class Evas.Image (Evas.Object)
|
||||
class Evas.Image (Evas.Object, Efl.File)
|
||||
{
|
||||
legacy_prefix: evas_object_image;
|
||||
eo_prefix: evas_obj_image;
|
||||
|
@ -435,50 +435,6 @@ class Evas.Image (Evas.Object)
|
|||
Evas_Fill_Spread spread; /*@ One of EVAS_TEXTURE_REFLECT, EVAS_TEXTURE_REPEAT, */
|
||||
}
|
||||
}
|
||||
file {
|
||||
set {
|
||||
/*@
|
||||
Set the source file from where an image object must fetch the real
|
||||
image data (it may be an Eet file, besides pure image ones).
|
||||
|
||||
If the file supports multiple data stored in it (as Eet files do),
|
||||
you can specify the key to be used as the index of the image in
|
||||
this file.
|
||||
|
||||
Example:
|
||||
@code
|
||||
img = evas_object_image_add(canvas);
|
||||
evas_object_image_file_set(img, "/path/to/img", NULL);
|
||||
err = evas_object_image_load_error_get(img);
|
||||
if (err != EVAS_LOAD_ERROR_NONE)
|
||||
{
|
||||
fprintf(stderr, "could not load image '%s'. error string is \"%s\"\n",
|
||||
valid_path, evas_load_error_str(err));
|
||||
}
|
||||
else
|
||||
{
|
||||
evas_object_image_fill_set(img, 0, 0, w, h);
|
||||
evas_object_resize(img, w, h);
|
||||
evas_object_show(img);
|
||||
}
|
||||
@endcode */
|
||||
}
|
||||
get {
|
||||
/*@
|
||||
Retrieve the source file from where an image object is to fetch the
|
||||
real image data (it may be an Eet file, besides pure image ones).
|
||||
|
||||
You must @b not modify the strings on the returned pointers.
|
||||
|
||||
@note Use @c NULL pointers on the file components you're not
|
||||
interested in: they'll be ignored by the function. */
|
||||
}
|
||||
values {
|
||||
const(char)* file; /*@ The image file path. */
|
||||
const(char)* key; /*@ The image key in @p file (if its an Eet one), or @c
|
||||
NULL, otherwise. */
|
||||
}
|
||||
}
|
||||
border_center_fill {
|
||||
set {
|
||||
/*@
|
||||
|
@ -1124,28 +1080,6 @@ class Evas.Image (Evas.Object)
|
|||
@in int frame_num; /*@ Number of frames in the sequence */
|
||||
}
|
||||
}
|
||||
save @const {
|
||||
/*@
|
||||
Save the given image object's contents to an (image) file.
|
||||
|
||||
The extension suffix on @p file will determine which <b>saver
|
||||
module</b> Evas is to use when saving, thus the final file's
|
||||
format. If the file supports multiple data stored in it (Eet ones),
|
||||
you can specify the key to be used as the index of the image in it.
|
||||
|
||||
You can specify some flags when saving the image. Currently
|
||||
acceptable flags are @c quality and @c compress. Eg.: @c
|
||||
"quality=100 compress=9" */
|
||||
return: bool;
|
||||
params {
|
||||
@in const(char)* file @nonull; /*@ The filename to be used to save the image (extension
|
||||
obligatory). */
|
||||
@in const(char)* key; /*@ The image key in the file (if an Eet one), or @c NULL,
|
||||
otherwise. */
|
||||
@in const(char)* flags; /*@ String containing the flags to be used (@c NULL for
|
||||
none). */
|
||||
}
|
||||
}
|
||||
data_set {
|
||||
/*@
|
||||
Sets the raw image data of the given image object.
|
||||
|
@ -1241,5 +1175,8 @@ class Evas.Image (Evas.Object)
|
|||
Eo.Base.constructor;
|
||||
Eo.Base.destructor;
|
||||
Eo.Base.dbg_info_get;
|
||||
Efl.File.file.set;
|
||||
Efl.File.file.get;
|
||||
Efl.File.save;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -568,8 +568,8 @@ _evas_image_mmap_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o, const Eina_File
|
|||
*key = o->cur->key;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_evas_image_file_set(Eo *eo_obj, Evas_Image_Data *o, const char *file, const char *key)
|
||||
EOLIAN static Eina_Bool
|
||||
_evas_image_efl_file_file_set(Eo *eo_obj, Evas_Image_Data *o, const char *file, const char *key)
|
||||
{
|
||||
Evas_Object_Protected_Data *obj = eo_data_scope_get(eo_obj, EVAS_OBJECT_CLASS);
|
||||
Evas_Image_Load_Opts lo;
|
||||
|
@ -577,9 +577,9 @@ _evas_image_file_set(Eo *eo_obj, Evas_Image_Data *o, const char *file, const cha
|
|||
if ((o->cur->u.file) && (file) && (!strcmp(o->cur->u.file, file)))
|
||||
{
|
||||
if ((!o->cur->key) && (!key))
|
||||
return;
|
||||
return EINA_FALSE;
|
||||
if ((o->cur->key) && (key) && (!strcmp(o->cur->key, key)))
|
||||
return;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
/*
|
||||
* WTF? why cancel a null image preload? this is just silly (tm)
|
||||
|
@ -595,10 +595,12 @@ _evas_image_file_set(Eo *eo_obj, Evas_Image_Data *o, const char *file, const cha
|
|||
&o->load_error,
|
||||
&lo);
|
||||
_image_done_set(eo_obj, obj, o);
|
||||
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
EOLIAN static void
|
||||
_evas_image_file_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o, const char **file, const char **key)
|
||||
_evas_image_efl_file_file_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o, const char **file, const char **key)
|
||||
{
|
||||
if (file) *file = o->cur->u.file;
|
||||
if (key) *key = o->cur->key;
|
||||
|
@ -1508,7 +1510,7 @@ _evas_image_reload(Eo *eo_obj, Evas_Image_Data *o)
|
|||
}
|
||||
|
||||
EOLIAN static Eina_Bool
|
||||
_evas_image_save(Eo *eo_obj, Evas_Image_Data *o, const char *file, const char *key, const char *flags)
|
||||
_evas_image_efl_file_save(Eo *eo_obj, Evas_Image_Data *o, const char *file, const char *key, const char *flags)
|
||||
{
|
||||
DATA32 *data = NULL;
|
||||
int quality = 80, compress = 9, ok = 0;
|
||||
|
@ -4958,4 +4960,23 @@ _evas_image_filter_padding_get(Eo *obj EINA_UNUSED, Evas_Image_Data *o,
|
|||
|
||||
/* vim:set ts=8 sw=3 sts=3 expandtab cino=>5n-2f0^-2{2(0W1st0 :*/
|
||||
|
||||
EAPI void
|
||||
evas_object_image_file_set(Eo *obj, const char *file, const char *key)
|
||||
{
|
||||
eo_do((Eo *) obj, efl_file_set(file, key));
|
||||
}
|
||||
|
||||
EAPI void
|
||||
evas_object_image_file_get(const Eo *obj, const char **file, const char **key)
|
||||
{
|
||||
eo_do((Eo *) obj, efl_file_get(file, key));
|
||||
}
|
||||
|
||||
|
||||
EAPI Eina_Bool
|
||||
evas_object_image_save(const Eo *obj, const char *file, const char *key, const char *flags)
|
||||
{
|
||||
return eo_do((Eo *) obj, efl_file_save(file, key, flags));
|
||||
}
|
||||
|
||||
#include "canvas/evas_image.eo.c"
|
||||
|
|
Loading…
Reference in New Issue