evas/elm: Add Efl.Image.image_size read-only property

Following a remark in the mailing list, it is pretty clear that
Efl.Gfx.View.view_size is not as simple as "image_size".

I have defined this new image_size as being the size of the
image file, and not what's currently loaded. So it will not
apply to proxies, gl views, 3d scenes, etc... but only to
standard image files loaded with file_set or mmap_set.
Supported objects:
 - Efl.Canvas.Image (evas image)
 - Efl.Ui.Image (elm image)
 - Elm.Photocam (note: still needs some interface work)

@feature
This commit is contained in:
Jean-Philippe Andre 2017-05-24 15:07:21 +09:00
parent d8f59d24c4
commit b114f8c66d
9 changed files with 57 additions and 1 deletions

View File

@ -112,6 +112,23 @@ interface Efl.Image ()
fill: Efl.Gfx.Border_Fill_Mode; [[Fill mode of the center region.]]
}
}
@property image_size {
[[This represents the size of the original image in pixels.
This may be different from the actual geometry on screen or even
the size of the loaded pixel buffer. This is the size of the image
as stored in the original file.
This is a read-only property, and may return 0x0.
@since 1.20
]]
get {}
values {
w: int; [[The image width.]]
h: int; [[The image height.]]
}
}
/* Note: those are obscure features of evas image. Expose in Efl.Image? */
@property content_hint {

View File

@ -1232,6 +1232,18 @@ _efl_ui_image_efl_gfx_view_view_size_get(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data
if (h) *h = th;
}
EOLIAN static void
_efl_ui_image_efl_image_image_size_get(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, int *w, int *h)
{
if (sd->edje)
{
if (w) *w = 0;
if (h) *h = 0;
return;
}
efl_image_size_get(sd->img, w, h);
}
EAPI void
elm_image_prescale_set(Evas_Object *obj,

View File

@ -128,6 +128,7 @@ class Efl.Ui.Image (Elm.Widget, Efl.Ui.Clickable, Efl.Ui.Draggable,
Efl.Gfx.position { set; }
Efl.Gfx.size { set; }
Efl.Gfx.View.view_size { get; }
Efl.Image.image_size { get; }
Efl.Image.Load.load_size { get; set; }
Efl.Image.smooth_scale { get; set; }
Efl.Orientation.orientation { get; set; }

View File

@ -1559,6 +1559,13 @@ _elm_photocam_efl_object_constructor(Eo *obj, Elm_Photocam_Data *_pd EINA_UNUSED
return obj;
}
EOLIAN static void
_elm_photocam_efl_image_image_size_get(Eo *obj EINA_UNUSED, Elm_Photocam_Data *pd, int *w, int *h)
{
if (w) *w = pd->size.imw;
if (h) *h = pd->size.imh;
}
static void
_internal_file_set(Eo *obj, Elm_Photocam_Data *sd, const char *file, Eina_File *f, Evas_Load_Error *ret)
{

View File

@ -1,7 +1,7 @@
class Elm.Photocam (Elm.Widget, Elm.Interface_Scrollable,
Elm.Interface.Atspi_Widget_Action, Efl.File,
Efl.Ui.Clickable, Efl.Ui.Scrollable, Efl.Gfx.View,
Efl.Ui.Zoom, Efl.Orientation, Efl.Flipable)
Efl.Ui.Zoom, Efl.Orientation, Efl.Flipable, Efl.Image)
{
[[Elementary photocam class]]
legacy_prefix: elm_photocam;
@ -53,6 +53,7 @@ class Elm.Photocam (Elm.Widget, Elm.Interface_Scrollable,
Efl.Gfx.position { set; }
Efl.Gfx.size { set; }
Efl.Gfx.View.view_size { get; }
Efl.Image.image_size { get; }
Efl.Ui.Zoom.zoom_animation { set; get; }
Efl.Ui.Zoom.zoom { set; get; }
Efl.Ui.Zoom.zoom_mode { set; get; }

View File

@ -23,6 +23,8 @@ _evas_image_mmap_set(Eo *eo_obj, const Eina_File *f, const char *key)
o->engine_data = ENFN->image_mmap(ENDT, o->cur->u.f, o->cur->key, &o->load_error, &lo);
o->buffer_data_set = EINA_FALSE;
_evas_image_done_set(eo_obj, obj, o);
o->file_size.w = o->cur->image.w;
o->file_size.h = o->cur->image.h;
return EINA_TRUE;
}
@ -84,6 +86,8 @@ _evas_image_file_set(Eo *eo_obj, const char *file, const char *key)
o->engine_data = ENFN->image_load(ENDT, file2, o->cur->key, &o->load_error, &lo);
o->buffer_data_set = EINA_FALSE;
_evas_image_done_set(eo_obj, obj, o);
o->file_size.w = o->cur->image.w;
o->file_size.h = o->cur->image.h;
if ((o->file_obj) && (!efl_vpath_file_keep_get(o->file_obj)))
{
efl_del(o->file_obj);

View File

@ -20,6 +20,7 @@ abstract Efl.Canvas.Image.Internal (Efl.Canvas.Object, Efl.Canvas.Filter.Interna
Efl.Image.border_center_fill { get; set; }
Efl.Image.scale_hint { get; set; }
Efl.Image.content_hint { get; set; }
Efl.Image.image_size { get; }
Efl.Gfx.Buffer.alpha { get; set; }
Efl.Gfx.Buffer.buffer_update_add;
Efl.Gfx.Buffer.colorspace { get; }

View File

@ -118,6 +118,10 @@ struct _Evas_Image_Data
Efl_Flip flip_value;
Efl_Orient orient_value;
struct {
short w, h;
} file_size;
Eina_Bool changed : 1;
Eina_Bool dirty_pixels : 1;
Eina_Bool filled : 1;

View File

@ -395,6 +395,8 @@ _evas_image_done_set(Eo *eo_obj, Evas_Object_Protected_Data *obj, Evas_Image_Dat
}
EINA_COW_IMAGE_STATE_WRITE_END(o, state_write);
}
o->file_size.w = 0;
o->file_size.h = 0;
o->written = EINA_FALSE;
o->changed = EINA_TRUE;
if (resize_call) evas_object_inform_call_image_resize(eo_obj);
@ -702,6 +704,13 @@ _efl_canvas_image_internal_efl_gfx_fill_fill_get(Eo *eo_obj EINA_UNUSED, Evas_Im
if (h) *h = o->cur->fill.h;
}
EOLIAN static void
_efl_canvas_image_internal_efl_image_image_size_get(Eo *eo_obj EINA_UNUSED, Evas_Image_Data *o, int *w, int *h)
{
if (w) *w = o->file_size.w;
if (h) *h = o->file_size.h;
}
EOLIAN static void
_efl_canvas_image_internal_efl_gfx_view_view_size_get(Eo *eo_obj, Evas_Image_Data *o, int *w, int *h)
{