2013-04-25 22:13:00 -07:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "elementary_config.h"
|
|
|
|
#endif
|
|
|
|
|
2017-09-11 23:48:39 -07:00
|
|
|
#define EFL_ACCESS_IMAGE_PROTECTED
|
2018-04-03 04:27:30 -07:00
|
|
|
#define EFL_ACCESS_OBJECT_PROTECTED
|
2018-02-14 18:14:52 -08:00
|
|
|
#define EFL_ACCESS_COMPONENT_PROTECTED
|
2017-11-15 18:31:26 -08:00
|
|
|
#define EFL_ACCESS_WIDGET_ACTION_PROTECTED
|
2017-12-04 22:29:07 -08:00
|
|
|
#define EFL_LAYOUT_CALC_PROTECTED
|
2019-07-29 02:42:34 -07:00
|
|
|
#define EFL_INPUT_CLICKABLE_PROTECTED
|
2014-10-17 08:56:11 -07:00
|
|
|
|
2009-04-22 20:48:41 -07:00
|
|
|
#include <Elementary.h>
|
2013-04-25 22:13:00 -07:00
|
|
|
|
2009-04-22 20:48:41 -07:00
|
|
|
#include "elm_priv.h"
|
2016-05-31 03:38:21 -07:00
|
|
|
#include "efl_ui_widget_image.h"
|
2009-04-22 20:48:41 -07:00
|
|
|
|
2013-02-16 19:53:02 -08:00
|
|
|
#define FMT_SIZE_T "%zu"
|
2009-04-22 20:48:41 -07:00
|
|
|
|
2016-05-31 03:38:21 -07:00
|
|
|
#define MY_CLASS EFL_UI_IMAGE_CLASS
|
|
|
|
#define MY_CLASS_NAME "Efl.Ui.Image"
|
2012-05-25 12:53:59 -07:00
|
|
|
|
2016-04-27 06:35:23 -07:00
|
|
|
#define NON_EXISTING (void *)-1
|
|
|
|
static const char *icon_theme = NULL;
|
|
|
|
|
2012-05-25 12:53:59 -07:00
|
|
|
static const char SIG_DND[] = "drop";
|
|
|
|
static const char SIG_CLICKED[] = "clicked";
|
2013-08-09 05:12:29 -07:00
|
|
|
static const char SIG_DOWNLOAD_START[] = "download,start";
|
|
|
|
static const char SIG_DOWNLOAD_PROGRESS[] = "download,progress";
|
|
|
|
static const char SIG_DOWNLOAD_DONE[] = "download,done";
|
|
|
|
static const char SIG_DOWNLOAD_ERROR[] = "download,error";
|
2016-09-21 23:24:40 -07:00
|
|
|
static const char SIG_LOAD_OPEN[] = "load,open";
|
|
|
|
static const char SIG_LOAD_READY[] = "load,ready";
|
|
|
|
static const char SIG_LOAD_ERROR[] = "load,error";
|
|
|
|
static const char SIG_LOAD_CANCEL[] = "load,cancel";
|
2012-05-25 12:53:59 -07:00
|
|
|
static const Evas_Smart_Cb_Description _smart_callbacks[] = {
|
|
|
|
{SIG_DND, ""},
|
2011-04-15 10:05:34 -07:00
|
|
|
{SIG_CLICKED, ""},
|
2013-08-09 05:12:29 -07:00
|
|
|
{SIG_DOWNLOAD_START, ""},
|
|
|
|
{SIG_DOWNLOAD_PROGRESS, ""},
|
|
|
|
{SIG_DOWNLOAD_DONE, ""},
|
|
|
|
{SIG_DOWNLOAD_ERROR, ""},
|
2016-09-21 23:24:40 -07:00
|
|
|
{SIG_LOAD_OPEN, "Triggered when the file has been opened (image size is known)"},
|
|
|
|
{SIG_LOAD_READY, "Triggered when the image file is ready for display"},
|
2017-12-13 09:53:33 -08:00
|
|
|
{SIG_LOAD_ERROR, "Triggered whenener an I/O or decoding error occurred"},
|
2016-09-21 23:24:40 -07:00
|
|
|
{SIG_LOAD_CANCEL, "Triggered whenener async I/O was cancelled"},
|
2011-04-15 10:05:34 -07:00
|
|
|
{NULL, NULL}
|
|
|
|
};
|
|
|
|
|
2014-04-14 22:49:35 -07:00
|
|
|
static Eina_Bool _key_action_activate(Evas_Object *obj, const char *params);
|
2019-02-27 10:17:09 -08:00
|
|
|
static Eina_Error _efl_ui_image_smart_internal_file_set(Eo *obj, Efl_Ui_Image_Data *sd);
|
2016-11-22 07:24:16 -08:00
|
|
|
static void _efl_ui_image_remote_copier_cancel(Eo *obj, Efl_Ui_Image_Data *sd);
|
2017-01-31 12:17:58 -08:00
|
|
|
static void _efl_ui_image_model_properties_changed_cb(void *data, const Efl_Event *event);
|
2017-07-06 00:14:06 -07:00
|
|
|
static void _on_size_hints_changed(void *data, const Efl_Event *e);
|
2019-02-27 10:17:09 -08:00
|
|
|
static Eina_Bool _efl_ui_image_download(Eo *obj, Efl_Ui_Image_Data *sd, const char *url);
|
2019-07-10 17:56:20 -07:00
|
|
|
static void _update_viewmodel(Eo *obj, Efl_Ui_Image_Data *pd);
|
2014-04-14 22:49:35 -07:00
|
|
|
|
|
|
|
static const Elm_Action key_actions[] = {
|
|
|
|
{"activate", _key_action_activate},
|
|
|
|
{NULL, NULL}
|
|
|
|
};
|
2013-10-29 16:32:43 -07:00
|
|
|
|
2016-09-07 23:00:22 -07:00
|
|
|
typedef struct _Async_Open_Data Async_Open_Data;
|
|
|
|
|
|
|
|
struct _Async_Open_Data
|
|
|
|
{
|
|
|
|
Eo *obj;
|
2015-04-09 01:09:53 -07:00
|
|
|
Eina_Stringshare *file, *key;
|
2016-09-07 23:00:22 -07:00
|
|
|
Eina_File *f_set, *f_open;
|
|
|
|
void *map;
|
2015-04-09 01:09:53 -07:00
|
|
|
};
|
|
|
|
|
2016-11-21 01:52:27 -08:00
|
|
|
static void
|
|
|
|
_prev_img_del(Efl_Ui_Image_Data *sd)
|
|
|
|
{
|
|
|
|
elm_widget_sub_object_del(sd->self, sd->prev_img);
|
|
|
|
evas_object_smart_member_del(sd->prev_img);
|
|
|
|
evas_object_del(sd->prev_img);
|
|
|
|
sd->prev_img = NULL;
|
|
|
|
}
|
|
|
|
|
2018-08-02 06:22:59 -07:00
|
|
|
static void
|
|
|
|
_recover_status(Eo *obj, Efl_Ui_Image_Data *sd)
|
|
|
|
{
|
|
|
|
int r, g, b, a;
|
2019-02-27 10:17:37 -08:00
|
|
|
Evas_Object *pclip = efl_canvas_object_clipper_get(obj);
|
|
|
|
if (pclip) efl_canvas_object_clipper_set(sd->img, pclip);
|
2018-08-02 06:22:59 -07:00
|
|
|
|
|
|
|
efl_gfx_color_get(obj, &r, &g, &b, &a);
|
|
|
|
efl_gfx_color_set(sd->img, r, g, b, a);
|
|
|
|
efl_gfx_entity_visible_set(sd->img, sd->show);
|
|
|
|
}
|
|
|
|
|
2009-04-22 20:48:41 -07:00
|
|
|
static void
|
2012-05-25 12:53:59 -07:00
|
|
|
_on_image_preloaded(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas *e EINA_UNUSED,
|
2012-05-25 12:53:59 -07:00
|
|
|
Evas_Object *obj,
|
2014-01-06 06:30:02 -08:00
|
|
|
void *event EINA_UNUSED)
|
2009-04-22 20:48:41 -07:00
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
Efl_Ui_Image_Data *sd = data;
|
2016-09-21 23:24:40 -07:00
|
|
|
Evas_Load_Error err;
|
|
|
|
|
2016-05-31 03:38:21 -07:00
|
|
|
sd->preload_status = EFL_UI_IMAGE_PRELOADED;
|
2012-05-25 12:53:59 -07:00
|
|
|
if (sd->show) evas_object_show(obj);
|
2016-11-21 01:52:27 -08:00
|
|
|
_prev_img_del(sd);
|
2016-09-21 23:24:40 -07:00
|
|
|
err = evas_object_image_load_error_get(obj);
|
2020-02-10 08:05:35 -08:00
|
|
|
if (!err)
|
|
|
|
{
|
|
|
|
evas_object_smart_callback_call(sd->self, SIG_LOAD_READY, NULL);
|
|
|
|
if (sd->autoplay) efl_player_playing_set(sd->self, EINA_TRUE);
|
|
|
|
}
|
2016-09-21 23:24:40 -07:00
|
|
|
else evas_object_smart_callback_call(sd->self, SIG_LOAD_ERROR, NULL);
|
2009-04-22 20:48:41 -07:00
|
|
|
}
|
|
|
|
|
2009-11-13 14:22:05 -08:00
|
|
|
static void
|
2012-05-25 12:53:59 -07:00
|
|
|
_on_mouse_up(void *data,
|
2014-01-06 06:30:02 -08:00
|
|
|
Evas *e EINA_UNUSED,
|
|
|
|
Evas_Object *obj EINA_UNUSED,
|
2012-11-14 02:49:54 -08:00
|
|
|
void *event_info)
|
2012-05-25 12:53:59 -07:00
|
|
|
{
|
2015-07-29 12:18:17 -07:00
|
|
|
ELM_WIDGET_DATA_GET_OR_RETURN(data, wd);
|
|
|
|
|
2012-11-14 02:49:54 -08:00
|
|
|
Evas_Event_Mouse_Up *ev = event_info;
|
|
|
|
|
|
|
|
if (ev->button != 1) return;
|
|
|
|
if (ev->event_flags & EVAS_EVENT_FLAG_ON_HOLD) return;
|
2015-07-29 12:18:17 -07:00
|
|
|
if (!wd->still_in) return;
|
2012-11-14 02:49:54 -08:00
|
|
|
|
2019-05-14 12:50:39 -07:00
|
|
|
evas_object_smart_callback_call(data, "clicked", NULL);
|
2012-05-25 12:53:59 -07:00
|
|
|
}
|
|
|
|
|
2012-05-28 13:35:29 -07:00
|
|
|
static Eina_Bool
|
2016-05-31 03:38:21 -07:00
|
|
|
_efl_ui_image_animate_cb(void *data)
|
2012-05-28 13:35:29 -07:00
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_DATA_GET(data, sd);
|
2012-05-28 13:35:29 -07:00
|
|
|
|
|
|
|
if (!sd->anim) return ECORE_CALLBACK_CANCEL;
|
|
|
|
|
|
|
|
sd->cur_frame++;
|
2015-07-08 19:08:34 -07:00
|
|
|
if ((sd->frame_count > 0) && (sd->cur_frame > sd->frame_count))
|
2020-02-10 09:11:03 -08:00
|
|
|
{
|
|
|
|
if (sd->playback_loop)
|
|
|
|
sd->cur_frame = sd->cur_frame % sd->frame_count;
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sd->anim_timer = NULL;
|
|
|
|
sd->cur_frame = 0;
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
}
|
2012-05-28 13:35:29 -07:00
|
|
|
|
|
|
|
evas_object_image_animated_frame_set(sd->img, sd->cur_frame);
|
|
|
|
|
|
|
|
sd->frame_duration = evas_object_image_animated_frame_duration_get
|
|
|
|
(sd->img, sd->cur_frame, 0);
|
|
|
|
|
|
|
|
if (sd->frame_duration > 0)
|
2019-09-25 03:47:49 -07:00
|
|
|
ecore_timer_interval_set(sd->anim_timer, sd->frame_duration / sd->playback_speed);
|
2012-05-28 13:35:29 -07:00
|
|
|
|
|
|
|
return ECORE_CALLBACK_RENEW;
|
|
|
|
}
|
|
|
|
|
2012-05-25 12:53:59 -07:00
|
|
|
static Evas_Object *
|
|
|
|
_img_new(Evas_Object *obj)
|
2009-11-13 14:22:05 -08:00
|
|
|
{
|
2012-05-25 12:53:59 -07:00
|
|
|
Evas_Object *img;
|
|
|
|
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
2012-05-25 12:53:59 -07:00
|
|
|
|
|
|
|
img = evas_object_image_add(evas_object_evas_get(obj));
|
|
|
|
evas_object_image_scale_hint_set(img, EVAS_IMAGE_SCALE_HINT_STATIC);
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(img, EVAS_CALLBACK_IMAGE_PRELOADED, _on_image_preloaded, sd);
|
|
|
|
evas_object_smart_member_add(img, obj);
|
|
|
|
elm_widget_sub_object_add(obj, img);
|
2009-11-13 14:22:05 -08:00
|
|
|
|
2012-05-25 12:53:59 -07:00
|
|
|
return img;
|
2009-11-13 14:22:05 -08:00
|
|
|
}
|
|
|
|
|
2009-04-22 20:48:41 -07:00
|
|
|
static void
|
2019-08-21 09:53:46 -07:00
|
|
|
_image_sizing_eval(Eo *obj, Efl_Ui_Image_Data *sd, Evas_Object *img)
|
2009-04-22 20:48:41 -07:00
|
|
|
{
|
2017-09-19 01:32:09 -07:00
|
|
|
Evas_Coord x = 0, y = 0, w = 1, h = 1;
|
2019-08-21 09:53:46 -07:00
|
|
|
int ox, oy, ow, oh;
|
2020-05-17 20:39:59 -07:00
|
|
|
Eina_Bool img_no_resize = EINA_FALSE;
|
2012-05-25 12:53:59 -07:00
|
|
|
|
2019-08-21 09:53:46 -07:00
|
|
|
evas_object_geometry_get(obj, &ox, &oy, &ow, &oh);
|
2017-12-05 19:15:39 -08:00
|
|
|
if (efl_isa(img, EFL_CANVAS_LAYOUT_CLASS))
|
2012-05-25 12:53:59 -07:00
|
|
|
{
|
2019-08-21 09:53:46 -07:00
|
|
|
x = ox;
|
|
|
|
y = oy;
|
|
|
|
w = ow;
|
|
|
|
h = oh;
|
2017-09-19 01:32:09 -07:00
|
|
|
goto done;
|
2012-05-25 12:53:59 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-07-06 00:14:06 -07:00
|
|
|
double alignh = 0.5, alignv = 0.5;
|
2016-05-11 21:25:13 -07:00
|
|
|
int iw = 0, ih = 0, offset_x = 0, offset_y = 0;
|
|
|
|
|
|
|
|
//1. Get the original image size (iw x ih)
|
2017-08-23 11:24:11 -07:00
|
|
|
evas_object_image_size_get(img, &iw, &ih);
|
2018-08-07 23:52:37 -07:00
|
|
|
|
|
|
|
//Exception Case
|
2019-08-21 09:53:46 -07:00
|
|
|
if ((iw == 0) || (ih == 0) || (ow == 0) || (oh == 0))
|
2018-08-07 23:52:37 -07:00
|
|
|
{
|
2020-05-17 20:39:59 -07:00
|
|
|
img_no_resize = EINA_TRUE;
|
2018-08-07 23:52:37 -07:00
|
|
|
}
|
|
|
|
|
2012-05-25 12:53:59 -07:00
|
|
|
iw = ((double)iw) * sd->scale;
|
|
|
|
ih = ((double)ih) * sd->scale;
|
|
|
|
|
|
|
|
if (iw < 1) iw = 1;
|
|
|
|
if (ih < 1) ih = 1;
|
|
|
|
|
2016-05-11 21:25:13 -07:00
|
|
|
//2. Calculate internal image size (w x h)
|
2019-08-21 09:53:46 -07:00
|
|
|
// according to (iw x ih), (ow x oh), and scale_type
|
2016-05-11 21:25:13 -07:00
|
|
|
switch (sd->scale_type)
|
2012-05-25 12:53:59 -07:00
|
|
|
{
|
2019-09-16 02:06:02 -07:00
|
|
|
case EFL_GFX_IMAGE_SCALE_METHOD_NONE:
|
2016-05-11 21:25:13 -07:00
|
|
|
w = iw;
|
|
|
|
h = ih;
|
|
|
|
break;
|
2019-09-16 02:06:02 -07:00
|
|
|
case EFL_GFX_IMAGE_SCALE_METHOD_FILL:
|
2019-08-21 09:53:46 -07:00
|
|
|
w = ow;
|
|
|
|
h = oh;
|
2016-05-11 21:25:13 -07:00
|
|
|
break;
|
2019-09-16 02:06:02 -07:00
|
|
|
case EFL_GFX_IMAGE_SCALE_METHOD_FIT:
|
2019-08-21 09:53:46 -07:00
|
|
|
w = ow;
|
2016-05-11 21:25:13 -07:00
|
|
|
h = ((double)ih * w) / (double)iw;
|
2019-08-21 09:53:46 -07:00
|
|
|
if (h > oh)
|
2016-05-11 21:25:13 -07:00
|
|
|
{
|
2019-08-21 09:53:46 -07:00
|
|
|
h = oh;
|
2016-05-11 21:25:13 -07:00
|
|
|
w = ((double)iw * h) / (double)ih;
|
|
|
|
}
|
|
|
|
break;
|
2019-09-16 02:06:02 -07:00
|
|
|
case EFL_GFX_IMAGE_SCALE_METHOD_FIT_WIDTH:
|
2019-08-21 09:53:46 -07:00
|
|
|
w = ow;
|
2016-05-11 21:25:13 -07:00
|
|
|
h = ((double)ih * w) / (double)iw;
|
2019-08-21 12:27:53 -07:00
|
|
|
break;
|
2019-09-16 02:06:02 -07:00
|
|
|
case EFL_GFX_IMAGE_SCALE_METHOD_FIT_HEIGHT:
|
2019-08-21 12:27:53 -07:00
|
|
|
h = oh;
|
|
|
|
w = ((double)iw * h) / (double)ih;
|
|
|
|
break;
|
2019-09-16 02:06:02 -07:00
|
|
|
case EFL_GFX_IMAGE_SCALE_METHOD_EXPAND:
|
2020-08-02 08:26:09 -07:00
|
|
|
w = ow;
|
|
|
|
h = ((double)ih * w) / (double)iw;
|
|
|
|
if (h < oh)
|
2016-05-11 21:25:13 -07:00
|
|
|
{
|
2019-08-21 12:27:53 -07:00
|
|
|
h = oh;
|
|
|
|
w = ((double)iw * h) / (double)ih;
|
2016-05-11 21:25:13 -07:00
|
|
|
}
|
|
|
|
break;
|
2019-09-16 02:06:02 -07:00
|
|
|
case EFL_GFX_IMAGE_SCALE_METHOD_TILE:
|
2019-08-21 09:53:46 -07:00
|
|
|
evas_object_geometry_get(obj, &x, &y, &w, &h);
|
2017-09-19 01:32:09 -07:00
|
|
|
evas_object_image_fill_set(img, x, y, iw, ih);
|
|
|
|
goto done;
|
2012-05-25 12:53:59 -07:00
|
|
|
}
|
2019-08-21 12:27:53 -07:00
|
|
|
if (((!sd->scale_up) && (w > iw))
|
|
|
|
|| ((!sd->scale_down) && (w < iw)))
|
|
|
|
{
|
|
|
|
w = iw;
|
|
|
|
}
|
|
|
|
if (((!sd->scale_up) && (h > ih))
|
|
|
|
|| ((!sd->scale_down) && (h < ih)))
|
|
|
|
{
|
|
|
|
h = ih;
|
|
|
|
}
|
2016-05-11 21:25:13 -07:00
|
|
|
//3. Calculate offset according to align value
|
2017-08-23 11:24:11 -07:00
|
|
|
if (!elm_widget_is_legacy(sd->self))
|
2017-07-06 00:14:06 -07:00
|
|
|
{
|
2019-08-21 09:53:46 -07:00
|
|
|
offset_x = ((ow - w) * sd->align_x);
|
|
|
|
offset_y = ((oh - h) * sd->align_y);
|
2017-07-06 00:14:06 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2017-08-23 11:24:11 -07:00
|
|
|
evas_object_size_hint_align_get(sd->self, &alignh, &alignv);
|
2017-07-06 00:14:06 -07:00
|
|
|
if (EINA_DBL_EQ(alignh, EVAS_HINT_FILL)) alignh = 0.5;
|
|
|
|
if (EINA_DBL_EQ(alignv, EVAS_HINT_FILL)) alignv = 0.5;
|
|
|
|
|
2019-08-21 09:53:46 -07:00
|
|
|
offset_x = ((ow - w) * alignh);
|
|
|
|
offset_y = ((oh - h) * alignv);
|
2017-07-06 00:14:06 -07:00
|
|
|
}
|
2014-12-23 21:07:32 -08:00
|
|
|
|
2019-08-21 09:53:46 -07:00
|
|
|
x = ox + offset_x;
|
|
|
|
y = oy + offset_y;
|
2012-05-25 12:53:59 -07:00
|
|
|
|
2016-05-11 21:25:13 -07:00
|
|
|
//4. Fill, move, resize
|
|
|
|
if (offset_x >= 0) offset_x = 0;
|
|
|
|
if (offset_y >= 0) offset_y = 0;
|
|
|
|
|
2017-08-23 11:24:11 -07:00
|
|
|
evas_object_image_fill_set(img, offset_x, offset_y, w, h);
|
2016-05-11 21:25:13 -07:00
|
|
|
|
efl_ui_image: keep efl_ui_image size for internal image
Summary:
The size of internal image could be bigger than the size of efl_ui_image
with following code.
image = elm_image_add
elm_image_fill_outside_set(image, EINA_TRUE);
If the internal image object is 300x300, and efl_ui_image is 360x77, then
the internal image object will resize to 360x360 which is bigger than the
size of efl_ui_image.
This is a compatibility issue. This patch will make efl_ui_image work as
before commit 8cb6c3e Elm_image: implement 'scale_type' and 'scalable'...
Test Plan:
This is old example to reproduce the problem.
{F3859361}
This is newly added example to check if this patch breaks compatibility or not.
{F3859390}
You can use the example with following image.
{F3859391}
This is result before applying this patch.
{F3859388}
This is result after applying this patch.
{F3859389}
The translucent rectangle is the size of the efl_ui_image.
As you might be noticed, only FIT_WIDTH (the 4th one of each row),
and EXPAND (the 6th one of each row) are different.
One more difference the 1st one of 2nd row; NONE.
F.Y.I. and for quick understanding of example.
The 1st row efl_ui_image is bigger than internal image.
The 2nd row efl_ui_image is smaller than internal image.
From the left the scale type is NONE, FILL, FIT, FIT_WIDTH,
FIT_HEIGHT, EXPAND, and TILE.
Reviewers: Hermet, jsuya, herb
Reviewed By: Hermet
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D11587
2020-03-25 03:12:16 -07:00
|
|
|
if (ow - w < 0)
|
2016-05-11 21:25:13 -07:00
|
|
|
{
|
2019-08-21 09:53:46 -07:00
|
|
|
x = ox;
|
|
|
|
w = ow;
|
2015-01-07 22:47:24 -08:00
|
|
|
}
|
efl_ui_image: keep efl_ui_image size for internal image
Summary:
The size of internal image could be bigger than the size of efl_ui_image
with following code.
image = elm_image_add
elm_image_fill_outside_set(image, EINA_TRUE);
If the internal image object is 300x300, and efl_ui_image is 360x77, then
the internal image object will resize to 360x360 which is bigger than the
size of efl_ui_image.
This is a compatibility issue. This patch will make efl_ui_image work as
before commit 8cb6c3e Elm_image: implement 'scale_type' and 'scalable'...
Test Plan:
This is old example to reproduce the problem.
{F3859361}
This is newly added example to check if this patch breaks compatibility or not.
{F3859390}
You can use the example with following image.
{F3859391}
This is result before applying this patch.
{F3859388}
This is result after applying this patch.
{F3859389}
The translucent rectangle is the size of the efl_ui_image.
As you might be noticed, only FIT_WIDTH (the 4th one of each row),
and EXPAND (the 6th one of each row) are different.
One more difference the 1st one of 2nd row; NONE.
F.Y.I. and for quick understanding of example.
The 1st row efl_ui_image is bigger than internal image.
The 2nd row efl_ui_image is smaller than internal image.
From the left the scale type is NONE, FILL, FIT, FIT_WIDTH,
FIT_HEIGHT, EXPAND, and TILE.
Reviewers: Hermet, jsuya, herb
Reviewed By: Hermet
Subscribers: cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D11587
2020-03-25 03:12:16 -07:00
|
|
|
if (oh - h < 0)
|
2015-01-07 22:47:24 -08:00
|
|
|
{
|
2019-08-21 09:53:46 -07:00
|
|
|
y = oy;
|
|
|
|
h = oh;
|
2015-01-07 22:47:24 -08:00
|
|
|
}
|
2012-05-25 12:53:59 -07:00
|
|
|
}
|
2017-09-19 01:32:09 -07:00
|
|
|
done:
|
2020-05-17 20:39:59 -07:00
|
|
|
if (img_no_resize)
|
|
|
|
evas_object_geometry_set(img, 0, 0, 0, 0);
|
|
|
|
else
|
|
|
|
evas_object_geometry_set(img, x, y, w, h);
|
2017-09-19 01:32:09 -07:00
|
|
|
|
2018-11-21 07:59:17 -08:00
|
|
|
evas_object_geometry_set(sd->hit_rect, x, y, w, h);
|
2009-04-22 20:48:41 -07:00
|
|
|
}
|
|
|
|
|
2015-04-09 01:09:53 -07:00
|
|
|
static inline void
|
|
|
|
_async_open_data_free(Async_Open_Data *data)
|
|
|
|
{
|
|
|
|
if (!data) return;
|
|
|
|
eina_stringshare_del(data->file);
|
|
|
|
eina_stringshare_del(data->key);
|
|
|
|
if (data->map) eina_file_map_free(data->f_open, data->map);
|
|
|
|
if (data->f_open) eina_file_close(data->f_open);
|
|
|
|
if (data->f_set) eina_file_close(data->f_set);
|
|
|
|
free(data);
|
|
|
|
}
|
|
|
|
|
2015-03-30 19:58:10 -07:00
|
|
|
static void
|
2016-09-07 23:00:22 -07:00
|
|
|
_efl_ui_image_async_open_do(void *data, Ecore_Thread *thread)
|
2015-03-30 19:58:10 -07:00
|
|
|
{
|
2016-09-07 23:00:22 -07:00
|
|
|
Async_Open_Data *todo = data;
|
2015-04-09 01:09:53 -07:00
|
|
|
Eina_File *f;
|
2015-03-30 19:58:10 -07:00
|
|
|
void *map = NULL;
|
2016-09-19 16:12:31 -07:00
|
|
|
size_t size;
|
2015-03-30 19:58:10 -07:00
|
|
|
|
2016-09-07 23:00:22 -07:00
|
|
|
if (ecore_thread_check(thread)) return;
|
2015-04-09 01:09:53 -07:00
|
|
|
|
2016-09-14 16:52:08 -07:00
|
|
|
if (todo->f_set) f = eina_file_dup(todo->f_set);
|
2015-04-09 01:09:53 -07:00
|
|
|
else if (todo->file)
|
2015-03-30 19:58:10 -07:00
|
|
|
{
|
2015-04-09 01:09:53 -07:00
|
|
|
// blocking
|
|
|
|
f = eina_file_open(todo->file, EINA_FALSE);
|
2016-09-07 23:00:22 -07:00
|
|
|
if (!f) return;
|
2015-03-30 19:58:10 -07:00
|
|
|
}
|
2015-04-09 01:09:53 -07:00
|
|
|
else
|
2015-03-30 19:58:10 -07:00
|
|
|
{
|
2015-04-09 01:09:53 -07:00
|
|
|
CRI("Async open has no input file!");
|
|
|
|
return;
|
2015-03-30 19:58:10 -07:00
|
|
|
}
|
2016-09-07 23:00:22 -07:00
|
|
|
if (ecore_thread_check(thread))
|
2015-03-30 19:58:10 -07:00
|
|
|
{
|
2015-04-09 01:09:53 -07:00
|
|
|
if (!todo->f_set) eina_file_close(f);
|
|
|
|
return;
|
2015-03-30 19:58:10 -07:00
|
|
|
}
|
|
|
|
|
2015-04-09 01:09:53 -07:00
|
|
|
// Read just enough data for map to actually do something.
|
2016-09-07 23:00:22 -07:00
|
|
|
size = eina_file_size_get(f);
|
|
|
|
// Read and ensure all pages are in memory for sure first just
|
|
|
|
// 1 byte per page will do. also keep a limit on how much we will
|
2016-09-19 16:07:03 -07:00
|
|
|
// blindly load in here to let's say 32KB (Should be enough to get
|
|
|
|
// image headers without getting to much data from the hard drive).
|
|
|
|
size = size > 32 * 1024 ? 32 * 1024 : size;
|
2017-09-14 22:39:14 -07:00
|
|
|
map = eina_file_map_all(f, EINA_FILE_SEQUENTIAL);
|
|
|
|
eina_file_map_populate(f, EINA_FILE_POPULATE, map, 0, size);
|
2015-04-09 01:09:53 -07:00
|
|
|
|
2016-09-07 23:00:22 -07:00
|
|
|
if (ecore_thread_check(thread))
|
2015-04-09 01:09:53 -07:00
|
|
|
{
|
|
|
|
if (map) eina_file_map_free(f, map);
|
|
|
|
if (!todo->f_set) eina_file_close(f);
|
|
|
|
return;
|
|
|
|
}
|
2016-09-07 23:00:22 -07:00
|
|
|
todo->f_open = f;
|
|
|
|
todo->map = map;
|
|
|
|
}
|
2015-04-09 01:09:53 -07:00
|
|
|
|
2016-09-07 23:00:22 -07:00
|
|
|
static void
|
|
|
|
_async_clear(Efl_Ui_Image_Data *sd)
|
|
|
|
{
|
|
|
|
sd->async.th = NULL;
|
2015-04-09 01:09:53 -07:00
|
|
|
sd->async.todo = NULL;
|
2016-09-07 23:00:22 -07:00
|
|
|
eina_stringshare_del(sd->async.file);
|
|
|
|
eina_stringshare_del(sd->async.key);
|
|
|
|
sd->async.file = NULL;
|
|
|
|
sd->async.key = NULL;
|
|
|
|
}
|
2015-04-09 01:09:53 -07:00
|
|
|
|
2016-09-07 23:00:22 -07:00
|
|
|
static void
|
|
|
|
_async_cancel(Efl_Ui_Image_Data *sd)
|
|
|
|
{
|
|
|
|
if (sd->async.th)
|
2015-04-09 01:09:53 -07:00
|
|
|
{
|
2016-09-07 23:00:22 -07:00
|
|
|
ecore_thread_cancel(sd->async.th);
|
|
|
|
((Async_Open_Data *)(sd->async.todo))->obj = NULL;
|
|
|
|
_async_clear(sd);
|
2015-04-09 01:09:53 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-09-07 23:00:22 -07:00
|
|
|
_efl_ui_image_async_open_cancel(void *data, Ecore_Thread *thread)
|
2015-04-09 01:09:53 -07:00
|
|
|
{
|
2016-09-07 23:00:22 -07:00
|
|
|
Async_Open_Data *todo = data;
|
2015-04-09 01:09:53 -07:00
|
|
|
|
|
|
|
DBG("Async open thread was canceled");
|
2016-09-07 23:00:22 -07:00
|
|
|
if (todo->obj)
|
|
|
|
{
|
|
|
|
EFL_UI_IMAGE_DATA_GET(todo->obj, sd);
|
|
|
|
if (sd)
|
|
|
|
{
|
2016-09-21 23:24:40 -07:00
|
|
|
evas_object_smart_callback_call(todo->obj, SIG_LOAD_CANCEL, NULL);
|
2016-09-07 23:00:22 -07:00
|
|
|
if (thread == sd->async.th) _async_clear(sd);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
_async_open_data_free(todo);
|
2015-03-30 19:58:10 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-09-07 23:00:22 -07:00
|
|
|
_efl_ui_image_async_open_done(void *data, Ecore_Thread *thread)
|
2015-03-30 19:58:10 -07:00
|
|
|
{
|
2016-09-07 23:00:22 -07:00
|
|
|
Async_Open_Data *todo = data;
|
2019-02-27 10:17:09 -08:00
|
|
|
const char *key;
|
2015-03-30 19:58:10 -07:00
|
|
|
Eina_Bool ok;
|
|
|
|
Eina_File *f;
|
|
|
|
void *map;
|
|
|
|
|
2016-09-07 23:00:22 -07:00
|
|
|
if (todo->obj)
|
2015-03-30 19:58:10 -07:00
|
|
|
{
|
2016-09-07 23:00:22 -07:00
|
|
|
EFL_UI_IMAGE_DATA_GET(todo->obj, sd);
|
|
|
|
if (sd)
|
|
|
|
{
|
|
|
|
if (thread == sd->async.th)
|
|
|
|
{
|
|
|
|
DBG("Async open succeeded");
|
|
|
|
_async_clear(sd);
|
|
|
|
key = todo->key;
|
|
|
|
map = todo->map;
|
|
|
|
f = todo->f_open;
|
|
|
|
ok = f && map;
|
|
|
|
|
|
|
|
if (ok)
|
|
|
|
{
|
2019-02-27 10:17:09 -08:00
|
|
|
efl_file_key_set(sd->self, key);
|
|
|
|
ok = !efl_file_mmap_set(sd->self, f);
|
|
|
|
if (ok)
|
2017-04-20 02:29:26 -07:00
|
|
|
{
|
2019-02-27 10:17:09 -08:00
|
|
|
if (sd->edje)
|
|
|
|
{
|
|
|
|
_prev_img_del(sd);
|
|
|
|
ok = edje_object_mmap_set(sd->img, f, key);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ok = !_efl_ui_image_smart_internal_file_set(sd->self, sd);
|
2017-04-20 02:29:26 -07:00
|
|
|
}
|
2016-09-07 23:00:22 -07:00
|
|
|
}
|
2020-02-10 08:05:35 -08:00
|
|
|
if (ok)
|
|
|
|
{
|
|
|
|
evas_object_smart_callback_call(sd->self, SIG_LOAD_OPEN, NULL);
|
|
|
|
if (sd->autoplay) efl_player_playing_set(sd->self, EINA_TRUE);
|
|
|
|
}
|
2016-09-21 23:24:40 -07:00
|
|
|
else evas_object_smart_callback_call(sd->self, SIG_LOAD_ERROR, NULL);
|
2016-09-07 23:00:22 -07:00
|
|
|
}
|
|
|
|
}
|
2015-03-30 19:58:10 -07:00
|
|
|
}
|
2015-04-09 01:09:53 -07:00
|
|
|
// close f, map and free strings
|
2016-09-07 23:00:22 -07:00
|
|
|
_async_open_data_free(todo);
|
2015-03-30 19:58:10 -07:00
|
|
|
}
|
|
|
|
|
2019-02-27 10:17:09 -08:00
|
|
|
static Eina_Error
|
|
|
|
_efl_ui_image_async_file_set(Eo *obj, Efl_Ui_Image_Data *sd)
|
2015-03-30 19:58:10 -07:00
|
|
|
{
|
2015-04-09 01:09:53 -07:00
|
|
|
Async_Open_Data *todo;
|
2019-02-27 10:17:09 -08:00
|
|
|
const char *file = efl_file_get(obj);
|
|
|
|
const char *key = efl_file_key_get(obj);
|
|
|
|
const Eina_File *f = efl_file_mmap_get(obj);
|
2015-03-30 19:58:10 -07:00
|
|
|
|
2016-09-07 23:00:22 -07:00
|
|
|
if (sd->async.th &&
|
2015-04-13 04:29:05 -07:00
|
|
|
((file == sd->async.file) ||
|
|
|
|
(file && sd->async.file && !strcmp(file, sd->async.file))) &&
|
|
|
|
((key == sd->async.key) ||
|
|
|
|
(key && sd->async.key && !strcmp(key, sd->async.key))))
|
2019-02-27 10:17:09 -08:00
|
|
|
return 0;
|
2015-04-13 04:29:05 -07:00
|
|
|
|
2015-04-09 01:09:53 -07:00
|
|
|
todo = calloc(1, sizeof(Async_Open_Data));
|
2016-09-07 23:00:22 -07:00
|
|
|
if (!todo) return EINA_FALSE;
|
2015-04-09 01:09:53 -07:00
|
|
|
|
2016-09-07 23:00:22 -07:00
|
|
|
_async_cancel(sd);
|
|
|
|
|
|
|
|
todo->obj = obj;
|
2015-04-09 01:09:53 -07:00
|
|
|
todo->file = eina_stringshare_add(file);
|
|
|
|
todo->key = eina_stringshare_add(key);
|
|
|
|
todo->f_set = f ? eina_file_dup(f) : NULL;
|
|
|
|
|
2016-09-07 23:00:22 -07:00
|
|
|
eina_stringshare_replace(&sd->async.file, file);
|
|
|
|
eina_stringshare_replace(&sd->async.key, key);
|
|
|
|
|
|
|
|
sd->async.todo = todo;
|
|
|
|
sd->async.th = ecore_thread_run(_efl_ui_image_async_open_do,
|
|
|
|
_efl_ui_image_async_open_done,
|
|
|
|
_efl_ui_image_async_open_cancel, todo);
|
2019-02-27 10:17:09 -08:00
|
|
|
if (sd->async.th) return 0;
|
2016-09-07 23:00:22 -07:00
|
|
|
|
|
|
|
_async_open_data_free(todo);
|
|
|
|
_async_clear(sd);
|
|
|
|
DBG("Could not spawn an async thread!");
|
2019-02-27 10:17:09 -08:00
|
|
|
return EFL_GFX_IMAGE_LOAD_ERROR_GENERIC;
|
2015-03-30 19:58:10 -07:00
|
|
|
}
|
|
|
|
|
2019-02-27 10:17:09 -08:00
|
|
|
static Eina_Error
|
|
|
|
_efl_ui_image_edje_file_set(Evas_Object *obj)
|
2012-05-25 12:53:59 -07:00
|
|
|
{
|
2019-02-27 10:17:09 -08:00
|
|
|
Eina_Error err;
|
|
|
|
const Eina_File *f;
|
|
|
|
const char *key;
|
|
|
|
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
2012-05-25 12:53:59 -07:00
|
|
|
|
2019-02-27 10:17:09 -08:00
|
|
|
err = efl_file_load(efl_super(obj, MY_CLASS));
|
|
|
|
if (err) return err;
|
|
|
|
|
|
|
|
f = efl_file_mmap_get(obj);
|
|
|
|
key = efl_file_key_get(obj);
|
2016-11-21 01:52:27 -08:00
|
|
|
_prev_img_del(sd);
|
2012-05-25 12:53:59 -07:00
|
|
|
|
|
|
|
if (!sd->edje)
|
|
|
|
{
|
2014-01-21 17:38:55 -08:00
|
|
|
evas_object_del(sd->img);
|
2009-07-06 23:46:51 -07:00
|
|
|
|
2012-05-25 12:53:59 -07:00
|
|
|
/* Edje object instead */
|
|
|
|
sd->img = edje_object_add(evas_object_evas_get(obj));
|
2018-08-02 06:22:59 -07:00
|
|
|
_recover_status(obj, sd);
|
|
|
|
sd->edje = EINA_TRUE;
|
2012-05-25 12:53:59 -07:00
|
|
|
evas_object_smart_member_add(sd->img, obj);
|
|
|
|
}
|
|
|
|
|
2016-09-07 23:00:22 -07:00
|
|
|
_async_cancel(sd);
|
|
|
|
|
2015-03-30 19:58:10 -07:00
|
|
|
if (!sd->async_enable)
|
2013-08-09 05:12:29 -07:00
|
|
|
{
|
2019-02-27 10:17:09 -08:00
|
|
|
efl_file_key_set(sd->img, key);
|
|
|
|
err = efl_file_mmap_set(sd->img, f);
|
|
|
|
if (!err) err = efl_file_load(sd->img);
|
|
|
|
if (err)
|
2015-03-30 19:58:10 -07:00
|
|
|
{
|
2019-02-27 10:17:09 -08:00
|
|
|
ERR("failed to set edje file '%s', group '%s': %s", eina_file_filename_get(f), key,
|
|
|
|
edje_load_error_str(edje_object_load_error_get(sd->img)));
|
|
|
|
return err;
|
2013-08-09 05:12:29 -07:00
|
|
|
}
|
|
|
|
}
|
2015-03-30 19:58:10 -07:00
|
|
|
else
|
2019-02-27 10:17:09 -08:00
|
|
|
return _efl_ui_image_async_file_set(obj, sd);
|
2020-02-10 08:05:35 -08:00
|
|
|
if (sd->autoplay) efl_player_playing_set(sd->self, EINA_TRUE);
|
2012-05-25 12:53:59 -07:00
|
|
|
|
|
|
|
/* FIXME: do i want to update icon on file change ? */
|
2019-08-21 09:31:35 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2012-05-25 12:53:59 -07:00
|
|
|
|
2019-02-27 10:17:09 -08:00
|
|
|
return 0;
|
2012-05-25 12:53:59 -07:00
|
|
|
}
|
|
|
|
|
2014-03-23 04:05:20 -07:00
|
|
|
EOLIAN static void
|
2018-04-19 04:26:59 -07:00
|
|
|
_efl_ui_image_efl_gfx_image_smooth_scale_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, Eina_Bool smooth)
|
2012-05-25 12:53:59 -07:00
|
|
|
{
|
2016-08-03 02:24:16 -07:00
|
|
|
sd->smooth = smooth;
|
2019-04-16 05:55:11 -07:00
|
|
|
if (sd->img && (!sd->edje)) evas_object_image_smooth_scale_set(sd->img, smooth);
|
2012-05-25 12:53:59 -07:00
|
|
|
}
|
|
|
|
|
2014-03-23 04:05:20 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2018-04-19 04:26:59 -07:00
|
|
|
_efl_ui_image_efl_gfx_image_smooth_scale_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
2012-05-25 12:53:59 -07:00
|
|
|
{
|
2016-08-03 02:24:16 -07:00
|
|
|
return sd->smooth;
|
2012-05-25 12:53:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
2016-05-31 03:38:21 -07:00
|
|
|
_efl_ui_image_drag_n_drop_cb(void *elm_obj,
|
2014-07-23 09:19:26 -07:00
|
|
|
Evas_Object *obj,
|
|
|
|
Elm_Selection_Data *drop)
|
2012-05-25 12:53:59 -07:00
|
|
|
{
|
2012-11-25 22:32:53 -08:00
|
|
|
Eina_Bool ret = EINA_FALSE;
|
2019-02-27 10:17:09 -08:00
|
|
|
ret = efl_file_simple_load(obj, drop->data, NULL);
|
2014-05-10 07:15:54 -07:00
|
|
|
if (ret)
|
2012-05-25 12:53:59 -07:00
|
|
|
{
|
2013-06-04 22:40:03 -07:00
|
|
|
DBG("dnd: %s, %s, %s", elm_widget_type_get(elm_obj),
|
2014-07-23 09:19:26 -07:00
|
|
|
SIG_DND, (char *)drop->data);
|
2012-05-25 12:53:59 -07:00
|
|
|
|
2016-08-22 15:40:39 -07:00
|
|
|
efl_event_callback_legacy_call(elm_obj, EFL_UI_IMAGE_EVENT_DROP, drop->data);
|
2012-05-25 12:53:59 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2012-05-29 12:38:24 -07:00
|
|
|
return EINA_FALSE;
|
2012-05-25 12:53:59 -07:00
|
|
|
}
|
|
|
|
|
2014-03-23 04:05:20 -07:00
|
|
|
EOLIAN static void
|
2016-06-17 01:26:08 -07:00
|
|
|
_efl_ui_image_efl_canvas_group_group_add(Eo *obj, Efl_Ui_Image_Data *priv)
|
2012-05-25 12:53:59 -07:00
|
|
|
{
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_canvas_group_add(efl_super(obj, MY_CLASS));
|
2013-09-24 21:33:39 -07:00
|
|
|
|
2012-11-27 01:29:16 -08:00
|
|
|
priv->hit_rect = evas_object_rectangle_add(evas_object_evas_get(obj));
|
|
|
|
evas_object_smart_member_add(priv->hit_rect, obj);
|
|
|
|
elm_widget_sub_object_add(obj, priv->hit_rect);
|
|
|
|
|
|
|
|
evas_object_color_set(priv->hit_rect, 0, 0, 0, 0);
|
|
|
|
evas_object_show(priv->hit_rect);
|
2015-04-14 19:03:12 -07:00
|
|
|
evas_object_repeat_events_set(priv->hit_rect, EINA_TRUE);
|
2012-11-27 01:29:16 -08:00
|
|
|
|
2019-05-14 12:50:39 -07:00
|
|
|
if (elm_widget_is_legacy(obj))
|
|
|
|
{
|
|
|
|
evas_object_event_callback_add
|
|
|
|
(priv->hit_rect, EVAS_CALLBACK_MOUSE_UP, _on_mouse_up, obj);
|
2020-02-10 09:11:03 -08:00
|
|
|
priv->playback_loop = EINA_TRUE;
|
2019-05-14 12:50:39 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-08-01 22:03:38 -07:00
|
|
|
efl_ui_action_connector_bind_clickable_to_object(priv->hit_rect, obj);
|
2019-05-14 12:50:39 -07:00
|
|
|
}
|
2012-11-27 01:29:16 -08:00
|
|
|
|
2012-05-25 12:53:59 -07:00
|
|
|
priv->smooth = EINA_TRUE;
|
|
|
|
priv->fill_inside = EINA_TRUE;
|
|
|
|
priv->aspect_fixed = EINA_TRUE;
|
2017-12-18 00:33:49 -08:00
|
|
|
priv->load_size = EINA_SIZE2D(0, 0);
|
2012-05-25 12:53:59 -07:00
|
|
|
priv->scale = 1.0;
|
2016-05-11 21:25:13 -07:00
|
|
|
priv->scale_up = EINA_TRUE;
|
|
|
|
priv->scale_down = EINA_TRUE;
|
2016-05-27 04:58:25 -07:00
|
|
|
priv->align_x = 0.5;
|
|
|
|
priv->align_y = 0.5;
|
2012-05-25 12:53:59 -07:00
|
|
|
|
|
|
|
elm_widget_can_focus_set(obj, EINA_FALSE);
|
|
|
|
}
|
|
|
|
|
2014-03-23 04:05:20 -07:00
|
|
|
EOLIAN static void
|
2016-06-17 01:26:08 -07:00
|
|
|
_efl_ui_image_efl_canvas_group_group_del(Eo *obj, Efl_Ui_Image_Data *sd)
|
2012-05-25 12:53:59 -07:00
|
|
|
{
|
2019-02-12 10:52:43 -08:00
|
|
|
Efl_Model *model;
|
|
|
|
|
2017-08-10 00:43:30 -07:00
|
|
|
if (elm_widget_is_legacy(obj))
|
2019-02-21 09:46:36 -08:00
|
|
|
efl_event_callback_del(obj, EFL_GFX_ENTITY_EVENT_HINTS_CHANGED,
|
2017-07-06 00:14:06 -07:00
|
|
|
_on_size_hints_changed, sd);
|
2014-01-21 06:16:41 -08:00
|
|
|
ecore_timer_del(sd->anim_timer);
|
|
|
|
evas_object_del(sd->img);
|
2016-11-21 01:52:27 -08:00
|
|
|
_prev_img_del(sd);
|
2016-09-07 23:00:22 -07:00
|
|
|
_async_cancel(sd);
|
2016-11-22 07:24:16 -08:00
|
|
|
if (sd->remote.copier) _efl_ui_image_remote_copier_cancel(obj, sd);
|
|
|
|
if (sd->remote.binbuf) ELM_SAFE_FREE(sd->remote.binbuf, eina_binbuf_free);
|
|
|
|
ELM_SAFE_FREE(sd->remote.key, eina_stringshare_del);
|
2017-01-31 12:17:58 -08:00
|
|
|
|
2019-02-12 10:52:43 -08:00
|
|
|
model = efl_ui_view_model_get(obj);
|
|
|
|
if (model)
|
2017-01-31 12:17:58 -08:00
|
|
|
{
|
2019-02-12 10:52:43 -08:00
|
|
|
efl_event_callback_del(model, EFL_MODEL_EVENT_PROPERTIES_CHANGED,
|
2018-01-26 11:37:00 -08:00
|
|
|
_efl_ui_image_model_properties_changed_cb, obj);
|
2017-01-31 12:17:58 -08:00
|
|
|
}
|
|
|
|
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_canvas_group_del(efl_super(obj, MY_CLASS));
|
2012-05-25 12:53:59 -07:00
|
|
|
}
|
|
|
|
|
2019-08-21 09:53:46 -07:00
|
|
|
/* this function exists solely to call efl_canvas_group_change */
|
2014-03-23 04:05:20 -07:00
|
|
|
EOLIAN static void
|
2019-08-21 09:53:46 -07:00
|
|
|
_efl_ui_image_efl_gfx_entity_position_set(Eo *obj, Efl_Ui_Image_Data *sd EINA_UNUSED, Eina_Position2D pos)
|
2012-05-25 12:53:59 -07:00
|
|
|
{
|
2017-09-14 20:14:32 -07:00
|
|
|
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_MOVE, 0, pos.x, pos.y))
|
2016-10-10 20:39:05 -07:00
|
|
|
return;
|
|
|
|
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_position_set(efl_super(obj, MY_CLASS), pos);
|
2019-08-21 09:31:35 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2012-05-25 12:53:59 -07:00
|
|
|
}
|
|
|
|
|
2019-08-21 09:53:46 -07:00
|
|
|
/* this function exists solely to call efl_canvas_group_change */
|
2014-03-23 04:05:20 -07:00
|
|
|
EOLIAN static void
|
2019-08-21 09:53:46 -07:00
|
|
|
_efl_ui_image_efl_gfx_entity_size_set(Eo *obj, Efl_Ui_Image_Data *sd EINA_UNUSED, Eina_Size2D sz)
|
2012-05-25 12:53:59 -07:00
|
|
|
{
|
2017-09-15 02:37:25 -07:00
|
|
|
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_RESIZE, 0, sz.w, sz.h))
|
evas/elm: Remove function group_resize
This is an override of efl_gfx_size_set. Same as before, the
order of operations matter so it is possible that a corner
case will break. In particular, legacy code was:
- intercept
- smart resize (do stuff), super, super, super
- evas object resize
The new code is more like:
- intercept
- super, super, super, evas object resize
- do stuff
But unfortunately this broke elm_widget (read: all widgets) as
the internal resize was done before the object resize. So,
inside the resize event cb, the resize_obj size would not match
the smart object size. >_<
2016-10-11 00:54:31 -07:00
|
|
|
return;
|
2012-05-25 12:53:59 -07:00
|
|
|
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_size_set(efl_super(obj, MY_CLASS), sz);
|
2019-08-21 09:53:46 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2012-05-25 12:53:59 -07:00
|
|
|
}
|
|
|
|
|
2016-10-10 02:59:42 -07:00
|
|
|
static void
|
|
|
|
_efl_ui_image_show(Eo *obj, Efl_Ui_Image_Data *sd)
|
2012-05-25 12:53:59 -07:00
|
|
|
{
|
|
|
|
sd->show = EINA_TRUE;
|
|
|
|
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_visible_set(efl_super(obj, MY_CLASS), EINA_TRUE);
|
2016-10-31 23:49:20 -07:00
|
|
|
|
|
|
|
if (sd->preload_status == EFL_UI_IMAGE_PRELOADING) return;
|
2018-08-02 06:22:59 -07:00
|
|
|
if (sd->img) efl_gfx_entity_visible_set(sd->img, EINA_TRUE);
|
2016-11-21 01:52:27 -08:00
|
|
|
_prev_img_del(sd);
|
2016-10-10 02:59:42 -07:00
|
|
|
}
|
2012-05-25 12:53:59 -07:00
|
|
|
|
2016-10-10 02:59:42 -07:00
|
|
|
static void
|
|
|
|
_efl_ui_image_hide(Eo *obj, Efl_Ui_Image_Data *sd)
|
|
|
|
{
|
|
|
|
sd->show = EINA_FALSE;
|
2018-04-05 01:47:26 -07:00
|
|
|
efl_gfx_entity_visible_set(efl_super(obj, MY_CLASS), EINA_FALSE);
|
2018-08-02 06:22:59 -07:00
|
|
|
if (sd->img) efl_gfx_entity_visible_set(sd->img, EINA_FALSE);
|
2016-11-21 01:52:27 -08:00
|
|
|
_prev_img_del(sd);
|
2012-05-25 12:53:59 -07:00
|
|
|
}
|
|
|
|
|
2014-03-23 04:05:20 -07:00
|
|
|
EOLIAN static void
|
2018-04-05 01:47:26 -07:00
|
|
|
_efl_ui_image_efl_gfx_entity_visible_set(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool vis)
|
2012-05-25 12:53:59 -07:00
|
|
|
{
|
2016-10-10 02:59:42 -07:00
|
|
|
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_VISIBLE, 0, vis))
|
|
|
|
return;
|
2012-05-25 12:53:59 -07:00
|
|
|
|
2016-10-10 02:59:42 -07:00
|
|
|
if (vis) _efl_ui_image_show(obj, sd);
|
|
|
|
else _efl_ui_image_hide(obj, sd);
|
2012-05-25 12:53:59 -07:00
|
|
|
}
|
|
|
|
|
2014-03-23 04:05:20 -07:00
|
|
|
EOLIAN static void
|
2016-06-17 01:26:08 -07:00
|
|
|
_efl_ui_image_efl_canvas_group_group_member_add(Eo *obj, Efl_Ui_Image_Data *sd, Evas_Object *member)
|
2012-11-27 01:29:16 -08:00
|
|
|
{
|
2016-08-15 06:44:41 -07:00
|
|
|
efl_canvas_group_member_add(efl_super(obj, MY_CLASS), member);
|
2012-11-27 01:29:16 -08:00
|
|
|
|
|
|
|
if (sd->hit_rect)
|
|
|
|
evas_object_raise(sd->hit_rect);
|
|
|
|
}
|
|
|
|
|
2014-03-23 04:05:20 -07:00
|
|
|
EOLIAN static void
|
2017-12-19 23:34:01 -08:00
|
|
|
_efl_ui_image_efl_gfx_color_color_set(Eo *obj, Efl_Ui_Image_Data *sd, int r, int g, int b, int a)
|
2012-05-25 12:53:59 -07:00
|
|
|
{
|
2016-10-07 00:25:49 -07:00
|
|
|
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_COLOR_SET, 0, r, g, b, a))
|
|
|
|
return;
|
|
|
|
|
|
|
|
efl_gfx_color_set(efl_super(obj, MY_CLASS), r, g, b, a);
|
2012-05-25 12:53:59 -07:00
|
|
|
|
2012-12-02 19:53:13 -08:00
|
|
|
evas_object_color_set(sd->hit_rect, 0, 0, 0, 0);
|
2018-08-02 06:22:59 -07:00
|
|
|
if (sd->img) evas_object_color_set(sd->img, r, g, b, a);
|
2012-05-25 12:53:59 -07:00
|
|
|
if (sd->prev_img) evas_object_color_set(sd->prev_img, r, g, b, a);
|
|
|
|
}
|
|
|
|
|
2014-03-23 04:05:20 -07:00
|
|
|
EOLIAN static void
|
2019-02-27 10:17:37 -08:00
|
|
|
_efl_ui_image_efl_canvas_object_clipper_set(Eo *obj, Efl_Ui_Image_Data *sd, Evas_Object *clip)
|
2012-05-25 12:53:59 -07:00
|
|
|
{
|
2016-10-10 00:44:48 -07:00
|
|
|
if (_evas_object_intercept_call(obj, EVAS_OBJECT_INTERCEPT_CB_CLIP_SET, 0, clip))
|
|
|
|
return;
|
|
|
|
|
2019-02-27 10:17:37 -08:00
|
|
|
efl_canvas_object_clipper_set(efl_super(obj, MY_CLASS), clip);
|
2012-05-25 12:53:59 -07:00
|
|
|
|
2018-08-02 06:22:59 -07:00
|
|
|
if (sd->img) evas_object_clip_set(sd->img, clip);
|
2012-05-25 12:53:59 -07:00
|
|
|
if (sd->prev_img) evas_object_clip_set(sd->prev_img, clip);
|
|
|
|
}
|
|
|
|
|
2019-03-04 10:37:07 -08:00
|
|
|
EOLIAN static Eina_Error
|
2018-01-07 20:55:35 -08:00
|
|
|
_efl_ui_image_efl_ui_widget_theme_apply(Eo *obj, Efl_Ui_Image_Data *sd EINA_UNUSED)
|
2012-05-25 12:53:59 -07:00
|
|
|
{
|
2019-03-04 10:37:07 -08:00
|
|
|
Eina_Error int_ret = EFL_UI_THEME_APPLY_ERROR_GENERIC;
|
2016-04-27 06:35:23 -07:00
|
|
|
|
|
|
|
if (sd->stdicon)
|
|
|
|
_elm_theme_object_icon_set(obj, sd->stdicon, elm_widget_style_get(obj));
|
|
|
|
|
2017-10-23 22:03:46 -07:00
|
|
|
int_ret = efl_ui_widget_theme_apply(efl_super(obj, MY_CLASS));
|
2019-03-04 10:36:41 -08:00
|
|
|
if (int_ret == EFL_UI_THEME_APPLY_ERROR_GENERIC) return int_ret;
|
2012-05-25 12:53:59 -07:00
|
|
|
|
2019-08-21 09:31:35 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2012-05-25 12:53:59 -07:00
|
|
|
|
theme: return enum from elm_widget_style_set instead of bool
Summary:
if trying to apply incorrect theme, widget apply default theme and return TRUE.
so there is no way to check it really apply correct theme.
To resolve this problem, _elm_theme_set return three type enum
* related history : 4ca3ef45146e05908a13d1010909abeba9693ad6
* elm_object_style_set is public api, so I didn't change it.
* typedef name [ Theme_Apply ] is temporarily, please suggest better one.
@fix
Reviewers: singh.amitesh, herb, Hermet, cedric, jpeg, raster
Subscribers: cedric, jpeg
Differential Revision: https://phab.enlightenment.org/D4073
2016-06-30 23:09:42 -07:00
|
|
|
return int_ret;
|
2012-05-25 12:53:59 -07:00
|
|
|
}
|
|
|
|
|
2014-04-14 22:49:35 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_key_action_activate(Evas_Object *obj, const char *params EINA_UNUSED)
|
|
|
|
{
|
2019-05-13 12:14:13 -07:00
|
|
|
if (elm_widget_is_legacy(obj))
|
|
|
|
evas_object_smart_callback_call(obj, "clicked", NULL);
|
|
|
|
else
|
2019-07-29 02:42:34 -07:00
|
|
|
efl_event_callback_call(obj, EFL_INPUT_EVENT_CLICKED, NULL);
|
2014-04-14 22:49:35 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2019-08-21 09:31:35 -07:00
|
|
|
static void
|
|
|
|
_efl_ui_image_efl_canvas_group_group_calculate(Eo *obj, Efl_Ui_Image_Data *sd)
|
2012-05-25 12:53:59 -07:00
|
|
|
{
|
2020-04-06 11:33:30 -07:00
|
|
|
Evas_Coord minw = -1, minh = -1, maxw = -1, maxh = -1;
|
2017-09-18 04:16:33 -07:00
|
|
|
Eina_Size2D sz;
|
2012-06-14 00:55:55 -07:00
|
|
|
double ts;
|
2012-05-25 12:53:59 -07:00
|
|
|
|
2019-08-21 09:31:35 -07:00
|
|
|
sd->in_calc = EINA_TRUE;
|
2018-08-02 06:22:59 -07:00
|
|
|
// TODO: remove this function after using the widget's scale value instead of image's scale value,
|
2012-05-25 12:53:59 -07:00
|
|
|
if (sd->no_scale)
|
2018-08-02 06:22:59 -07:00
|
|
|
sd->scale = 1.0;
|
2012-05-25 12:53:59 -07:00
|
|
|
else
|
2018-08-02 06:22:59 -07:00
|
|
|
sd->scale = efl_gfx_entity_scale_get(obj) * elm_config_scale_get();
|
2012-05-25 12:53:59 -07:00
|
|
|
|
2012-06-14 00:55:55 -07:00
|
|
|
ts = sd->scale;
|
|
|
|
sd->scale = 1.0;
|
2017-09-18 04:16:33 -07:00
|
|
|
sz = efl_gfx_view_size_get(obj);
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2012-06-14 00:55:55 -07:00
|
|
|
sd->scale = ts;
|
2017-09-18 00:22:01 -07:00
|
|
|
evas_object_size_hint_combined_min_get(obj, &minw, &minh);
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2012-06-14 00:55:55 -07:00
|
|
|
if (sd->no_scale)
|
2009-04-22 20:48:41 -07:00
|
|
|
{
|
2017-09-18 04:16:33 -07:00
|
|
|
maxw = minw = sz.w;
|
|
|
|
maxh = minh = sz.h;
|
2016-06-20 04:05:52 -07:00
|
|
|
if ((sd->scale > 1.0) && (sd->scale_up))
|
2012-06-14 00:55:55 -07:00
|
|
|
{
|
2017-09-18 04:16:33 -07:00
|
|
|
maxw = minw = sz.w * sd->scale;
|
|
|
|
maxh = minh = sz.h * sd->scale;
|
2012-06-14 00:55:55 -07:00
|
|
|
}
|
2016-06-20 04:05:52 -07:00
|
|
|
else if ((sd->scale < 1.0) && (sd->scale_down))
|
2012-06-14 00:55:55 -07:00
|
|
|
{
|
2017-09-18 04:16:33 -07:00
|
|
|
maxw = minw = sz.w * sd->scale;
|
|
|
|
maxh = minh = sz.h * sd->scale;
|
2012-06-14 00:55:55 -07:00
|
|
|
}
|
2009-04-22 20:48:41 -07:00
|
|
|
}
|
2012-06-14 00:55:55 -07:00
|
|
|
else
|
2009-04-22 20:48:41 -07:00
|
|
|
{
|
2016-06-20 04:05:52 -07:00
|
|
|
if (!sd->scale_down)
|
2012-06-14 00:55:55 -07:00
|
|
|
{
|
2017-09-18 04:16:33 -07:00
|
|
|
minw = sz.w * sd->scale;
|
|
|
|
minh = sz.h * sd->scale;
|
2012-06-14 00:55:55 -07:00
|
|
|
}
|
2016-06-20 04:05:52 -07:00
|
|
|
if (!sd->scale_up)
|
2012-06-14 00:55:55 -07:00
|
|
|
{
|
2017-09-18 04:16:33 -07:00
|
|
|
maxw = sz.w * sd->scale;
|
|
|
|
maxh = sz.h * sd->scale;
|
2012-06-14 00:55:55 -07:00
|
|
|
}
|
2009-04-22 20:48:41 -07:00
|
|
|
}
|
2012-07-17 19:25:38 -07:00
|
|
|
|
2019-08-14 06:56:42 -07:00
|
|
|
efl_gfx_hint_size_restricted_min_set(obj, EINA_SIZE2D(minw, minh));
|
2019-08-12 08:14:49 -07:00
|
|
|
efl_gfx_hint_size_restricted_max_set(obj, EINA_SIZE2D(maxw, maxh));
|
2018-08-02 06:22:59 -07:00
|
|
|
|
2019-05-29 06:25:14 -07:00
|
|
|
if (sd->img)
|
2018-08-21 07:38:54 -07:00
|
|
|
{
|
2019-05-29 06:25:14 -07:00
|
|
|
//Retained way. Nothing does, if either way hasn't been changed.
|
|
|
|
if (!sd->edje)
|
|
|
|
efl_gfx_image_orientation_set(sd->img, sd->orient);
|
2018-08-21 07:38:54 -07:00
|
|
|
|
2019-08-21 09:53:46 -07:00
|
|
|
_image_sizing_eval(obj, sd, sd->img);
|
|
|
|
if (sd->prev_img) _image_sizing_eval(obj, sd, sd->prev_img);
|
2019-05-29 06:25:14 -07:00
|
|
|
}
|
2019-08-21 09:31:35 -07:00
|
|
|
sd->in_calc = EINA_FALSE;
|
2018-08-02 06:22:59 -07:00
|
|
|
}
|
|
|
|
|
2017-12-18 00:33:49 -08:00
|
|
|
static void
|
|
|
|
_efl_ui_image_load_size_set_internal(Evas_Object *obj, Efl_Ui_Image_Data *sd)
|
|
|
|
{
|
|
|
|
Eina_Size2D sz = sd->load_size;
|
|
|
|
|
|
|
|
if ((sz.w <= 0) || (sz.h <= 0))
|
|
|
|
sz = efl_gfx_view_size_get(obj);
|
|
|
|
evas_object_image_load_size_set(sd->img, sz.w, sz.h);
|
|
|
|
}
|
|
|
|
|
2013-06-24 19:15:15 -07:00
|
|
|
static void
|
2016-05-31 03:38:21 -07:00
|
|
|
_efl_ui_image_file_set_do(Evas_Object *obj)
|
2013-06-24 19:15:15 -07:00
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
2013-06-24 19:15:15 -07:00
|
|
|
|
2013-10-02 04:18:49 -07:00
|
|
|
ELM_SAFE_FREE(sd->prev_img, evas_object_del);
|
2013-06-24 19:15:15 -07:00
|
|
|
|
2018-08-02 06:22:59 -07:00
|
|
|
sd->prev_img = sd->img;
|
2013-06-24 19:15:15 -07:00
|
|
|
sd->img = _img_new(obj);
|
2018-08-02 06:22:59 -07:00
|
|
|
_recover_status(obj, sd);
|
2013-06-24 19:15:15 -07:00
|
|
|
|
|
|
|
sd->edje = EINA_FALSE;
|
2018-08-02 06:22:59 -07:00
|
|
|
evas_object_image_smooth_scale_set(sd->img, sd->smooth);
|
|
|
|
evas_object_image_load_orientation_set(sd->img, EINA_TRUE);
|
2017-12-18 00:33:49 -08:00
|
|
|
_efl_ui_image_load_size_set_internal(obj, sd);
|
2013-06-24 19:15:15 -07:00
|
|
|
}
|
|
|
|
|
2017-07-06 00:14:06 -07:00
|
|
|
static void
|
2019-08-21 09:31:35 -07:00
|
|
|
_on_size_hints_changed(void *data, const Efl_Event *ev)
|
2017-07-06 00:14:06 -07:00
|
|
|
{
|
2019-08-21 09:31:35 -07:00
|
|
|
Efl_Ui_Image_Data *pd = data;
|
|
|
|
if (!pd->in_calc)
|
|
|
|
efl_canvas_group_change(ev->object);
|
2017-07-06 00:14:06 -07:00
|
|
|
}
|
|
|
|
|
2019-07-10 17:56:20 -07:00
|
|
|
static void
|
|
|
|
_efl_ui_image_model_changed(void *data, const Efl_Event *event)
|
|
|
|
{
|
|
|
|
Efl_Model_Changed_Event *ev = event->info;
|
|
|
|
|
|
|
|
if (ev->previous)
|
|
|
|
efl_event_callback_del(ev->previous, EFL_MODEL_EVENT_PROPERTIES_CHANGED,
|
|
|
|
_efl_ui_image_model_properties_changed_cb, event->object);
|
|
|
|
if (ev->current)
|
|
|
|
efl_event_callback_add(ev->current, EFL_MODEL_EVENT_PROPERTIES_CHANGED,
|
|
|
|
_efl_ui_image_model_properties_changed_cb, event->object);
|
|
|
|
|
|
|
|
_update_viewmodel(event->object, data);
|
|
|
|
}
|
|
|
|
|
2015-05-19 05:34:07 -07:00
|
|
|
EOLIAN static Eo *
|
2016-08-10 07:23:04 -07:00
|
|
|
_efl_ui_image_efl_object_constructor(Eo *obj, Efl_Ui_Image_Data *pd)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2016-08-15 06:44:41 -07:00
|
|
|
obj = efl_constructor(efl_super(obj, MY_CLASS));
|
2016-06-16 22:12:02 -07:00
|
|
|
evas_object_smart_callbacks_descriptions_set(obj, _smart_callbacks);
|
2018-04-03 04:27:30 -07:00
|
|
|
efl_access_object_role_set(obj, EFL_ACCESS_ROLE_IMAGE);
|
2015-05-19 05:34:07 -07:00
|
|
|
|
2019-09-16 02:06:02 -07:00
|
|
|
pd->scale_type = EFL_GFX_IMAGE_SCALE_METHOD_FIT;
|
2016-09-07 11:42:29 -07:00
|
|
|
pd->self = obj;
|
2019-09-24 08:18:57 -07:00
|
|
|
/* legacy elm_image starts paused */
|
|
|
|
pd->paused = elm_widget_is_legacy(obj);
|
2019-09-24 12:43:00 -07:00
|
|
|
pd->playback_speed = 1;
|
2016-06-19 19:18:18 -07:00
|
|
|
|
2015-05-19 05:34:07 -07:00
|
|
|
return obj;
|
2009-04-22 20:48:41 -07:00
|
|
|
}
|
|
|
|
|
2019-07-10 17:56:20 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_object_invalidate(Eo *obj, Efl_Ui_Image_Data *pd EINA_UNUSED)
|
|
|
|
{
|
|
|
|
Efl_Model *model;
|
|
|
|
|
|
|
|
if (pd->property_watch)
|
|
|
|
efl_event_callback_del(obj, EFL_UI_VIEW_EVENT_MODEL_CHANGED,
|
|
|
|
_efl_ui_image_model_changed, pd);
|
|
|
|
|
|
|
|
model = efl_ui_view_model_get(obj);
|
|
|
|
if (model)
|
|
|
|
efl_event_callback_del(model, EFL_MODEL_EVENT_PROPERTIES_CHANGED,
|
|
|
|
_efl_ui_image_model_properties_changed_cb, obj);
|
|
|
|
efl_invalidate(efl_super(obj, EFL_UI_IMAGE_CLASS));
|
|
|
|
}
|
|
|
|
|
2019-02-27 10:17:09 -08:00
|
|
|
static const Eina_Slice remote_uri[] = {
|
|
|
|
EINA_SLICE_STR_LITERAL("http://"),
|
|
|
|
EINA_SLICE_STR_LITERAL("https://"),
|
|
|
|
EINA_SLICE_STR_LITERAL("ftp://"),
|
|
|
|
{ }
|
|
|
|
};
|
|
|
|
|
|
|
|
static inline Eina_Bool
|
|
|
|
_efl_ui_image_is_remote(const char *file)
|
2015-04-05 23:16:25 -07:00
|
|
|
{
|
2019-02-27 10:17:09 -08:00
|
|
|
Eina_Slice s = EINA_SLICE_STR(file);
|
|
|
|
const Eina_Slice *itr;
|
|
|
|
|
|
|
|
for (itr = remote_uri; itr->mem; itr++)
|
|
|
|
if (eina_slice_startswith(s, *itr))
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN Eina_Error
|
|
|
|
_efl_ui_image_efl_file_load(Eo *obj, Efl_Ui_Image_Data *sd)
|
|
|
|
{
|
|
|
|
Eina_Error ret;
|
|
|
|
const char *file = efl_file_get(obj);
|
2015-04-05 23:16:25 -07:00
|
|
|
|
2019-02-27 10:17:09 -08:00
|
|
|
if (efl_file_loaded_get(obj)) return 0;
|
2016-09-07 23:00:22 -07:00
|
|
|
_async_cancel(sd);
|
|
|
|
|
2016-11-22 07:24:16 -08:00
|
|
|
/* stop preloading as it may hit to-be-freed memory */
|
2020-10-09 05:34:23 -07:00
|
|
|
if ((sd->img) && (sd->preload_status == EFL_UI_IMAGE_PRELOADING) && (!sd->edje))
|
2016-11-22 07:24:16 -08:00
|
|
|
evas_object_image_preload(sd->img, EINA_TRUE);
|
|
|
|
|
|
|
|
if (sd->remote.copier) _efl_ui_image_remote_copier_cancel(obj, sd);
|
|
|
|
if (sd->remote.binbuf) ELM_SAFE_FREE(sd->remote.binbuf, eina_binbuf_free);
|
|
|
|
|
2019-02-27 10:17:09 -08:00
|
|
|
if (sd->anim)
|
|
|
|
{
|
|
|
|
ELM_SAFE_FREE(sd->anim_timer, ecore_timer_del);
|
2019-09-24 08:18:57 -07:00
|
|
|
sd->paused = elm_widget_is_legacy(obj);
|
2019-02-27 10:17:09 -08:00
|
|
|
sd->anim = EINA_FALSE;
|
2019-09-24 08:18:57 -07:00
|
|
|
sd->frame_count = -1;
|
|
|
|
sd->cur_frame = -1;
|
|
|
|
sd->frame_duration = -1;
|
2019-02-27 10:17:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (file && _efl_ui_image_is_remote(file))
|
|
|
|
{
|
|
|
|
evas_object_hide(sd->img);
|
|
|
|
if (_efl_ui_image_download(obj, sd, file))
|
|
|
|
{
|
|
|
|
evas_object_smart_callback_call(obj, SIG_DOWNLOAD_START, NULL);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-22 07:14:04 -07:00
|
|
|
if (!sd->async_enable)
|
2019-02-27 10:17:09 -08:00
|
|
|
ret = _efl_ui_image_smart_internal_file_set(obj, sd);
|
2016-03-22 07:14:04 -07:00
|
|
|
else
|
2019-02-27 10:17:09 -08:00
|
|
|
ret = _efl_ui_image_async_file_set(obj, sd);
|
2015-04-05 23:16:25 -07:00
|
|
|
|
2013-11-03 19:17:42 -08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2019-01-25 06:12:41 -08:00
|
|
|
EOLIAN void
|
2019-02-27 10:17:09 -08:00
|
|
|
_efl_ui_image_efl_file_unload(Eo *obj, Efl_Ui_Image_Data *sd)
|
2019-01-25 06:12:41 -08:00
|
|
|
{
|
2019-02-27 10:17:09 -08:00
|
|
|
_async_cancel(sd);
|
|
|
|
|
|
|
|
/* stop preloading as it may hit to-be-freed memory */
|
|
|
|
if (sd->img && sd->preload_status == EFL_UI_IMAGE_PRELOADING)
|
|
|
|
evas_object_image_preload(sd->img, EINA_TRUE);
|
|
|
|
|
|
|
|
if (sd->remote.copier) _efl_ui_image_remote_copier_cancel(obj, sd);
|
|
|
|
if (sd->remote.binbuf) ELM_SAFE_FREE(sd->remote.binbuf, eina_binbuf_free);
|
|
|
|
|
|
|
|
if (sd->anim)
|
|
|
|
{
|
|
|
|
ELM_SAFE_FREE(sd->anim_timer, ecore_timer_del);
|
2019-09-24 08:18:57 -07:00
|
|
|
sd->paused = elm_widget_is_legacy(obj);
|
2019-02-27 10:17:09 -08:00
|
|
|
sd->anim = EINA_FALSE;
|
2019-09-24 08:18:57 -07:00
|
|
|
sd->frame_count = -1;
|
|
|
|
sd->cur_frame = -1;
|
|
|
|
sd->frame_duration = -1;
|
2019-02-27 10:17:09 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
if (sd->prev_img)
|
|
|
|
_prev_img_del(sd);
|
|
|
|
_efl_ui_image_file_set_do(obj);
|
|
|
|
efl_file_unload(sd->img);
|
|
|
|
efl_file_unload(efl_super(obj, MY_CLASS));
|
|
|
|
|
2019-08-21 09:31:35 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2019-01-25 06:12:41 -08:00
|
|
|
}
|
|
|
|
|
2019-02-27 10:17:09 -08:00
|
|
|
static Eina_Error
|
|
|
|
_efl_ui_image_smart_internal_file_set(Eo *obj, Efl_Ui_Image_Data *sd)
|
2013-06-24 19:15:15 -07:00
|
|
|
{
|
2019-02-27 10:17:09 -08:00
|
|
|
Eina_Error err;
|
|
|
|
const Eina_File *f;
|
|
|
|
const char *key;
|
|
|
|
const char *file = efl_file_get(obj);
|
2016-03-16 19:01:56 -07:00
|
|
|
|
2013-06-24 19:15:15 -07:00
|
|
|
if (eina_str_has_extension(file, ".edj"))
|
2019-02-27 10:17:09 -08:00
|
|
|
return _efl_ui_image_edje_file_set(obj);
|
|
|
|
|
|
|
|
err = efl_file_load(efl_super(obj, MY_CLASS));
|
|
|
|
if (err) return err;
|
|
|
|
|
|
|
|
f = efl_file_mmap_get(obj);
|
|
|
|
key = efl_file_key_get(obj);
|
2013-06-24 19:15:15 -07:00
|
|
|
|
2016-05-31 03:38:21 -07:00
|
|
|
_efl_ui_image_file_set_do(obj);
|
2013-06-24 19:15:15 -07:00
|
|
|
|
2019-02-27 10:17:09 -08:00
|
|
|
evas_object_image_mmap_set(sd->img, f, key);
|
2013-06-24 19:15:15 -07:00
|
|
|
|
2016-03-16 19:01:56 -07:00
|
|
|
err = evas_object_image_load_error_get(sd->img);
|
2019-02-27 10:17:09 -08:00
|
|
|
if (err)
|
2013-06-24 19:15:15 -07:00
|
|
|
{
|
2016-03-16 19:01:56 -07:00
|
|
|
if (file || f)
|
|
|
|
{
|
|
|
|
if (key)
|
|
|
|
ERR("Failed to load image '%s' '%s': %s. (%p)",
|
2019-02-27 10:17:09 -08:00
|
|
|
eina_file_filename_get(f), key,
|
2016-03-16 19:01:56 -07:00
|
|
|
evas_load_error_str(err), obj);
|
|
|
|
else
|
|
|
|
ERR("Failed to load image '%s': %s. (%p)",
|
2019-02-27 10:17:09 -08:00
|
|
|
eina_file_filename_get(f),
|
2016-03-16 19:01:56 -07:00
|
|
|
evas_load_error_str(err), obj);
|
|
|
|
}
|
2015-12-20 08:07:14 -08:00
|
|
|
else
|
2016-03-16 19:01:56 -07:00
|
|
|
{
|
|
|
|
ERR("NULL image file passed! (%p)", obj);
|
|
|
|
}
|
2017-05-31 03:01:03 -07:00
|
|
|
_prev_img_del(sd);
|
2019-02-27 10:17:09 -08:00
|
|
|
return err;
|
2013-06-24 19:15:15 -07:00
|
|
|
}
|
|
|
|
|
2017-04-20 02:29:26 -07:00
|
|
|
if (sd->preload_status == EFL_UI_IMAGE_PRELOAD_DISABLED)
|
2020-02-10 08:05:35 -08:00
|
|
|
{
|
|
|
|
_prev_img_del(sd);
|
|
|
|
if (sd->autoplay) efl_player_playing_set(sd->self, EINA_TRUE);
|
|
|
|
}
|
2017-04-20 02:29:26 -07:00
|
|
|
else
|
2015-09-15 01:25:31 -07:00
|
|
|
{
|
|
|
|
evas_object_hide(sd->img);
|
2016-05-31 03:38:21 -07:00
|
|
|
sd->preload_status = EFL_UI_IMAGE_PRELOADING;
|
2015-09-15 01:25:31 -07:00
|
|
|
evas_object_image_preload(sd->img, EINA_FALSE);
|
|
|
|
}
|
|
|
|
|
2019-08-21 09:31:35 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2013-06-24 19:15:15 -07:00
|
|
|
|
2019-02-27 10:17:09 -08:00
|
|
|
return 0;
|
2013-09-30 03:21:31 -07:00
|
|
|
}
|
2013-08-09 05:12:29 -07:00
|
|
|
|
|
|
|
static void
|
2016-11-22 07:24:16 -08:00
|
|
|
_efl_ui_image_remote_copier_del(void *data EINA_UNUSED, const Efl_Event *event)
|
|
|
|
{
|
|
|
|
Eo *dialer = efl_io_copier_source_get(event->object);
|
|
|
|
efl_del(dialer);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_efl_ui_image_remote_copier_cancel(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
|
|
|
{
|
|
|
|
Eo *copier = sd->remote.copier;
|
|
|
|
|
|
|
|
if (!copier) return;
|
2018-04-17 16:17:29 -07:00
|
|
|
/* copier is flagged as close_on_invalidate, thus:
|
2016-11-22 07:24:16 -08:00
|
|
|
* efl_del()
|
|
|
|
* -> efl_io_closer_close()
|
|
|
|
* -> "done" event
|
|
|
|
* -> _efl_ui_image_remote_copier_done()
|
|
|
|
*
|
|
|
|
* flag sd->remote.copier = NULL so _efl_ui_image_remote_copier_done()
|
|
|
|
* knows about it.
|
|
|
|
*/
|
|
|
|
sd->remote.copier = NULL;
|
|
|
|
efl_del(copier);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_efl_ui_image_remote_copier_done(void *data, const Efl_Event *event EINA_UNUSED)
|
2013-08-09 05:12:29 -07:00
|
|
|
{
|
|
|
|
Eo *obj = data;
|
2016-08-15 06:44:41 -07:00
|
|
|
Efl_Ui_Image_Data *sd = efl_data_scope_get(obj, MY_CLASS);
|
2013-08-09 05:12:29 -07:00
|
|
|
Eina_File *f;
|
2016-11-22 07:24:16 -08:00
|
|
|
Eo *dialer;
|
|
|
|
const char *url;
|
2019-02-27 10:17:09 -08:00
|
|
|
Eina_Error ret;
|
2013-08-09 05:12:29 -07:00
|
|
|
|
2016-11-22 07:24:16 -08:00
|
|
|
/* we're called from _efl_ui_image_remote_copier_cancel() */
|
|
|
|
if (!sd->remote.copier) return;
|
|
|
|
|
|
|
|
/* stop preloading as it may hit to-be-freed memory */
|
2018-08-16 07:01:47 -07:00
|
|
|
if (sd->img && sd->preload_status == EFL_UI_IMAGE_PRELOADING)
|
2016-11-22 07:24:16 -08:00
|
|
|
evas_object_image_preload(sd->img, EINA_TRUE);
|
|
|
|
|
|
|
|
if (sd->remote.binbuf) eina_binbuf_free(sd->remote.binbuf);
|
|
|
|
sd->remote.binbuf = efl_io_copier_binbuf_steal(sd->remote.copier);
|
|
|
|
|
|
|
|
dialer = efl_io_copier_source_get(sd->remote.copier);
|
|
|
|
url = efl_net_dialer_address_dial_get(dialer);
|
|
|
|
f = eina_file_virtualize(url,
|
|
|
|
eina_binbuf_string_get(sd->remote.binbuf),
|
|
|
|
eina_binbuf_length_get(sd->remote.binbuf),
|
2013-08-09 05:12:29 -07:00
|
|
|
EINA_FALSE);
|
2019-02-27 10:17:09 -08:00
|
|
|
efl_file_mmap_set(obj, f);
|
|
|
|
ret = _efl_ui_image_smart_internal_file_set(obj, sd);
|
2013-08-09 05:12:29 -07:00
|
|
|
eina_file_close(f);
|
|
|
|
|
2019-02-27 10:17:09 -08:00
|
|
|
if (ret)
|
2013-08-09 05:12:29 -07:00
|
|
|
{
|
2016-05-31 04:44:41 -07:00
|
|
|
Efl_Ui_Image_Error err = { 0, EINA_TRUE };
|
2013-08-09 05:12:29 -07:00
|
|
|
|
2016-11-22 07:24:16 -08:00
|
|
|
ELM_SAFE_FREE(sd->remote.binbuf, eina_binbuf_free);
|
2016-09-21 20:36:27 -07:00
|
|
|
evas_object_smart_callback_call(obj, SIG_DOWNLOAD_ERROR, &err);
|
2013-08-09 05:12:29 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
if (sd->preload_status != EFL_UI_IMAGE_PRELOAD_DISABLED)
|
2013-09-26 02:55:44 -07:00
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
sd->preload_status = EFL_UI_IMAGE_PRELOADING;
|
2013-10-01 02:05:21 -07:00
|
|
|
evas_object_image_preload(sd->img, EINA_FALSE);
|
2013-09-26 02:55:44 -07:00
|
|
|
}
|
2016-09-21 20:36:27 -07:00
|
|
|
evas_object_smart_callback_call(obj, SIG_DOWNLOAD_DONE, NULL);
|
2013-08-09 05:12:29 -07:00
|
|
|
}
|
|
|
|
|
2016-11-22 07:24:16 -08:00
|
|
|
ELM_SAFE_FREE(sd->remote.key, eina_stringshare_del);
|
|
|
|
ELM_SAFE_FREE(sd->remote.copier, efl_del);
|
2013-08-09 05:12:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-11-22 07:24:16 -08:00
|
|
|
_efl_ui_image_remote_copier_error(void *data, const Efl_Event *event)
|
2013-08-09 05:12:29 -07:00
|
|
|
{
|
|
|
|
Eo *obj = data;
|
2016-08-15 06:44:41 -07:00
|
|
|
Efl_Ui_Image_Data *sd = efl_data_scope_get(obj, MY_CLASS);
|
2016-11-22 07:24:16 -08:00
|
|
|
Eina_Error *perr = event->info;
|
|
|
|
Efl_Ui_Image_Error err = { *perr, EINA_FALSE };
|
2013-08-09 05:12:29 -07:00
|
|
|
|
2016-09-21 20:36:27 -07:00
|
|
|
evas_object_smart_callback_call(obj, SIG_DOWNLOAD_ERROR, &err);
|
2013-08-09 05:12:29 -07:00
|
|
|
|
2016-11-22 07:24:16 -08:00
|
|
|
_efl_ui_image_remote_copier_cancel(obj, sd);
|
|
|
|
ELM_SAFE_FREE(sd->remote.key, eina_stringshare_del);
|
2013-08-09 05:12:29 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-11-22 07:24:16 -08:00
|
|
|
_efl_ui_image_remote_copier_progress(void *data, const Efl_Event *event)
|
2013-08-09 05:12:29 -07:00
|
|
|
{
|
|
|
|
Eo *obj = data;
|
2016-05-31 04:44:41 -07:00
|
|
|
Efl_Ui_Image_Progress progress;
|
2016-11-22 07:24:16 -08:00
|
|
|
uint64_t now, total;
|
|
|
|
|
|
|
|
efl_io_copier_progress_get(event->object, &now, NULL, &total);
|
2013-08-09 05:12:29 -07:00
|
|
|
|
|
|
|
progress.now = now;
|
|
|
|
progress.total = total;
|
2016-09-21 20:36:27 -07:00
|
|
|
evas_object_smart_callback_call(obj, SIG_DOWNLOAD_PROGRESS, &progress);
|
2013-08-09 05:12:29 -07:00
|
|
|
}
|
|
|
|
|
2016-11-22 07:24:16 -08:00
|
|
|
EFL_CALLBACKS_ARRAY_DEFINE(_efl_ui_image_remote_copier_cbs,
|
|
|
|
{ EFL_EVENT_DEL, _efl_ui_image_remote_copier_del },
|
|
|
|
{ EFL_IO_COPIER_EVENT_DONE, _efl_ui_image_remote_copier_done },
|
|
|
|
{ EFL_IO_COPIER_EVENT_ERROR, _efl_ui_image_remote_copier_error },
|
|
|
|
{ EFL_IO_COPIER_EVENT_PROGRESS, _efl_ui_image_remote_copier_progress });
|
|
|
|
|
|
|
|
static Eina_Bool
|
2019-02-27 10:17:09 -08:00
|
|
|
_efl_ui_image_download(Eo *obj, Efl_Ui_Image_Data *sd, const char *url)
|
2016-11-22 07:24:16 -08:00
|
|
|
{
|
|
|
|
Eo *dialer;
|
|
|
|
Efl_Ui_Image_Error img_err = { ENOSYS, EINA_FALSE };
|
|
|
|
Eina_Error err;
|
2019-02-27 10:17:09 -08:00
|
|
|
const char *key = efl_file_key_get(obj);
|
2016-11-22 07:24:16 -08:00
|
|
|
|
|
|
|
dialer = efl_add(EFL_NET_DIALER_HTTP_CLASS, obj,
|
|
|
|
efl_net_dialer_http_allow_redirects_set(efl_added, EINA_TRUE));
|
|
|
|
EINA_SAFETY_ON_NULL_GOTO(dialer, error_dialer);
|
|
|
|
|
|
|
|
sd->remote.copier = efl_add(EFL_IO_COPIER_CLASS, obj,
|
|
|
|
efl_io_copier_source_set(efl_added, dialer),
|
2018-04-17 16:17:29 -07:00
|
|
|
efl_io_closer_close_on_invalidate_set(efl_added, EINA_TRUE),
|
2016-11-22 07:24:16 -08:00
|
|
|
efl_event_callback_array_add(efl_added, _efl_ui_image_remote_copier_cbs(), obj));
|
|
|
|
EINA_SAFETY_ON_NULL_GOTO(sd->remote.copier, error_copier);
|
|
|
|
eina_stringshare_replace(&sd->remote.key, key);
|
|
|
|
|
|
|
|
err = efl_net_dialer_dial(dialer, url);
|
|
|
|
if (err)
|
|
|
|
{
|
|
|
|
img_err.status = err;
|
|
|
|
ERR("Could not download %s: %s", url, eina_error_msg_get(err));
|
|
|
|
evas_object_smart_callback_call(obj, SIG_DOWNLOAD_ERROR, &img_err);
|
|
|
|
goto error_dial;
|
|
|
|
}
|
|
|
|
return EINA_TRUE;
|
|
|
|
|
|
|
|
error_dial:
|
|
|
|
evas_object_smart_callback_call(obj, SIG_DOWNLOAD_ERROR, &img_err);
|
|
|
|
_efl_ui_image_remote_copier_cancel(obj, sd);
|
|
|
|
return EINA_FALSE;
|
|
|
|
|
|
|
|
error_copier:
|
|
|
|
efl_del(dialer);
|
|
|
|
error_dialer:
|
|
|
|
evas_object_smart_callback_call(obj, SIG_DOWNLOAD_ERROR, &img_err);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2019-01-23 11:55:51 -08:00
|
|
|
EOLIAN static const char*
|
|
|
|
_efl_ui_image_efl_layout_group_group_data_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, const char *key)
|
|
|
|
{
|
|
|
|
if (sd->edje)
|
|
|
|
return edje_object_data_get(sd->img, key);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_efl_ui_image_efl_layout_group_part_exist_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, const char *part)
|
|
|
|
{
|
|
|
|
if (sd->edje)
|
|
|
|
return edje_object_part_exists(sd->img, part);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-01-06 12:19:00 -08:00
|
|
|
EOLIAN static void
|
2017-12-04 21:39:20 -08:00
|
|
|
_efl_ui_image_efl_layout_signal_signal_emit(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, const char *emission, const char *source)
|
2015-01-06 12:19:00 -08:00
|
|
|
{
|
|
|
|
if (sd->edje)
|
|
|
|
edje_object_signal_emit(sd->img, emission, source);
|
|
|
|
}
|
|
|
|
|
2019-09-17 05:16:14 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_layout_signal_message_send(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd, int id, const Eina_Value msg)
|
|
|
|
{
|
|
|
|
if (pd->edje)
|
|
|
|
efl_layout_signal_message_send(pd->img, id, msg);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_efl_ui_image_efl_layout_signal_signal_callback_add(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd, const char *emission, const char *source, void *func_data, EflLayoutSignalCb func, Eina_Free_Cb func_free_cb)
|
|
|
|
{
|
|
|
|
if (pd->edje)
|
|
|
|
return efl_layout_signal_callback_add(pd->img, emission, source, func_data, func, func_free_cb);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_efl_ui_image_efl_layout_signal_signal_callback_del(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd, const char *emission, const char *source, void *func_data, EflLayoutSignalCb func, Eina_Free_Cb func_free_cb)
|
|
|
|
{
|
|
|
|
if (pd->edje)
|
|
|
|
return efl_layout_signal_callback_del(pd->img, emission, source, func_data, func, func_free_cb);
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_layout_signal_signal_process(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd, Eina_Bool recurse)
|
|
|
|
{
|
|
|
|
if (pd->edje)
|
|
|
|
efl_layout_signal_process(pd->img, recurse);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2017-09-18 01:01:10 -07:00
|
|
|
EOLIAN static Eina_Size2D
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_image_efl_layout_group_group_size_min_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
2015-01-21 12:15:43 -08:00
|
|
|
{
|
|
|
|
if (sd->edje)
|
2017-12-04 23:00:08 -08:00
|
|
|
return efl_layout_group_size_min_get(sd->img);
|
2015-01-21 12:15:43 -08:00
|
|
|
else
|
2017-09-18 01:01:10 -07:00
|
|
|
return EINA_SIZE2D(0, 0);
|
2015-01-21 12:15:43 -08:00
|
|
|
}
|
|
|
|
|
2017-09-18 01:01:10 -07:00
|
|
|
EOLIAN static Eina_Size2D
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_image_efl_layout_group_group_size_max_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
2015-01-21 12:15:43 -08:00
|
|
|
{
|
|
|
|
if (sd->edje)
|
2017-12-04 23:00:08 -08:00
|
|
|
return efl_layout_group_size_max_get(sd->img);
|
2015-01-21 12:15:43 -08:00
|
|
|
else
|
2017-09-18 01:01:10 -07:00
|
|
|
return EINA_SIZE2D(0, 0);
|
2015-01-21 12:15:43 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2017-12-04 22:29:07 -08:00
|
|
|
_efl_ui_image_efl_layout_calc_calc_force(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
2015-01-21 12:15:43 -08:00
|
|
|
{
|
|
|
|
if (sd->edje)
|
|
|
|
edje_object_calc_force(sd->img);
|
|
|
|
}
|
|
|
|
|
2017-09-18 01:19:03 -07:00
|
|
|
EOLIAN static Eina_Size2D
|
2017-12-04 22:29:07 -08:00
|
|
|
_efl_ui_image_efl_layout_calc_calc_size_min(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, Eina_Size2D restricted)
|
2015-01-21 12:15:43 -08:00
|
|
|
{
|
|
|
|
if (sd->edje)
|
2017-12-04 22:29:07 -08:00
|
|
|
return efl_layout_calc_size_min(sd->img, restricted);
|
2015-01-21 12:15:43 -08:00
|
|
|
else
|
2017-09-18 01:31:54 -07:00
|
|
|
{
|
|
|
|
// Ignore restricted here? Combine with min? Hmm...
|
2019-02-21 09:19:45 -08:00
|
|
|
return efl_gfx_hint_size_combined_min_get(sd->img);
|
2017-09-18 01:31:54 -07:00
|
|
|
}
|
2015-01-21 12:15:43 -08:00
|
|
|
}
|
|
|
|
|
2019-01-23 12:39:43 -08:00
|
|
|
EOLIAN Eina_Rect
|
|
|
|
_efl_ui_image_efl_layout_calc_calc_parts_extends(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
|
|
|
{
|
|
|
|
if (sd->edje)
|
|
|
|
return efl_layout_calc_parts_extends(sd->img);
|
|
|
|
return efl_gfx_entity_geometry_get(sd->img);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static int
|
|
|
|
_efl_ui_image_efl_layout_calc_calc_freeze(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
|
|
|
{
|
|
|
|
if (sd->edje) return edje_object_freeze(sd->img);
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static int
|
|
|
|
_efl_ui_image_efl_layout_calc_calc_thaw(Eo *obj, Efl_Ui_Image_Data *sd)
|
|
|
|
{
|
|
|
|
if (sd->edje)
|
|
|
|
{
|
|
|
|
int ret = edje_object_thaw(sd->img);
|
2019-07-30 10:11:19 -07:00
|
|
|
efl_canvas_group_calculate(obj);
|
2019-01-23 12:39:43 -08:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN void
|
|
|
|
_efl_ui_image_efl_layout_calc_calc_auto_update_hints_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, Eina_Bool update)
|
|
|
|
{
|
|
|
|
if (sd->edje)
|
|
|
|
efl_layout_calc_auto_update_hints_set(sd->img, update);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN Eina_Bool
|
|
|
|
_efl_ui_image_efl_layout_calc_calc_auto_update_hints_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
|
|
|
{
|
|
|
|
if (sd->edje) return efl_layout_calc_auto_update_hints_get(sd->img);
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2016-09-21 23:24:40 -07:00
|
|
|
#if 0
|
|
|
|
// Kept for reference: wait for async open to complete - probably unused.
|
2015-03-30 19:58:10 -07:00
|
|
|
static Eina_Bool
|
2016-05-31 03:38:21 -07:00
|
|
|
_efl_ui_image_efl_file_async_wait(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd)
|
2015-03-30 19:58:10 -07:00
|
|
|
{
|
|
|
|
Eina_Bool ok = EINA_TRUE;
|
|
|
|
if (!pd->async.th) return ok;
|
|
|
|
if (!ecore_thread_wait(pd->async.th, 1.0))
|
|
|
|
{
|
|
|
|
ERR("Failed to wait on async file open!");
|
|
|
|
ok = EINA_FALSE;
|
|
|
|
}
|
|
|
|
return ok;
|
|
|
|
}
|
2016-09-21 23:24:40 -07:00
|
|
|
#endif
|
2015-03-30 19:58:10 -07:00
|
|
|
|
2016-09-21 23:24:40 -07:00
|
|
|
/* Legacy style async API. While legacy only, this is new from 1.19.
|
|
|
|
* Tizen has used elm_image_async_open_set() internally for a while, despite
|
|
|
|
* EFL upstream not exposing a proper async API. */
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_image_async_open_set(Eo *obj, Eina_Bool async)
|
2015-03-30 19:58:10 -07:00
|
|
|
{
|
2016-09-21 23:24:40 -07:00
|
|
|
Efl_Ui_Image_Data *pd;
|
|
|
|
|
|
|
|
EINA_SAFETY_ON_FALSE_RETURN(efl_isa(obj, MY_CLASS));
|
|
|
|
pd = efl_data_scope_get(obj, MY_CLASS);
|
2016-09-07 23:00:22 -07:00
|
|
|
if (pd->async_enable == async) return;
|
2015-03-30 19:58:10 -07:00
|
|
|
pd->async_enable = async;
|
2016-09-07 23:00:22 -07:00
|
|
|
if (!async) _async_cancel(pd);
|
2015-03-30 19:58:10 -07:00
|
|
|
}
|
|
|
|
|
2017-09-18 04:16:33 -07:00
|
|
|
EOLIAN static Eina_Size2D
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_image_efl_gfx_view_view_size_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2013-06-24 19:15:15 -07:00
|
|
|
int tw, th;
|
|
|
|
|
2018-08-02 06:22:59 -07:00
|
|
|
if (!sd->img)
|
|
|
|
{
|
|
|
|
tw = 0; th = 0;
|
|
|
|
}
|
|
|
|
else if (efl_isa(sd->img, EFL_CANVAS_LAYOUT_CLASS))
|
2013-06-24 19:15:15 -07:00
|
|
|
edje_object_size_min_get(sd->img, &tw, &th);
|
|
|
|
else
|
|
|
|
evas_object_image_size_get(sd->img, &tw, &th);
|
2017-09-18 04:16:33 -07:00
|
|
|
|
|
|
|
return EINA_SIZE2D(tw, th);
|
2013-06-24 19:15:15 -07:00
|
|
|
}
|
|
|
|
|
2017-09-18 04:49:56 -07:00
|
|
|
EOLIAN static Eina_Size2D
|
2018-04-19 04:26:59 -07:00
|
|
|
_efl_ui_image_efl_gfx_image_image_size_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
2017-05-23 23:07:21 -07:00
|
|
|
{
|
2018-08-02 06:22:59 -07:00
|
|
|
if (!sd->img || sd->edje)
|
2017-09-18 04:49:56 -07:00
|
|
|
return EINA_SIZE2D(0, 0);
|
2017-05-23 23:07:21 -07:00
|
|
|
|
2018-04-19 04:26:59 -07:00
|
|
|
return efl_gfx_image_size_get(sd->img);
|
2017-05-23 23:07:21 -07:00
|
|
|
}
|
2010-10-27 07:38:37 -07:00
|
|
|
|
2019-09-21 08:37:07 -07:00
|
|
|
EOLIAN static double
|
|
|
|
_efl_ui_image_efl_gfx_image_ratio_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd)
|
|
|
|
{
|
|
|
|
if (pd->edje) return 1.0; //documented value for the case that ratio cannot be calculated
|
|
|
|
return efl_gfx_image_ratio_get(pd->img);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Rect
|
|
|
|
_efl_ui_image_efl_gfx_image_content_region_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd)
|
|
|
|
{
|
|
|
|
if (pd->edje)
|
|
|
|
{
|
|
|
|
Eina_Size2D size = efl_gfx_entity_size_get(pd->img);
|
|
|
|
return EINA_RECT(0, 0, size.w, size.h);
|
|
|
|
}
|
|
|
|
|
|
|
|
return efl_gfx_image_content_region_get(pd->img);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_gfx_image_border_insets_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd, int l, int r, int t, int b)
|
|
|
|
{
|
|
|
|
if (pd->edje) return;
|
|
|
|
efl_gfx_image_border_insets_set(pd->img, l, r, t, b);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_gfx_image_border_insets_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd, int *l, int *r, int *t, int *b)
|
|
|
|
{
|
|
|
|
if (pd->edje)
|
|
|
|
{
|
|
|
|
if (l) *l = 0;
|
|
|
|
if (r) *r = 0;
|
|
|
|
if (t) *t = 0;
|
|
|
|
if (b) *b = 0;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
efl_gfx_image_border_insets_get(pd->img, l, r, t, b);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_gfx_image_border_insets_scale_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd, double scale)
|
|
|
|
{
|
|
|
|
if (pd->edje) return;
|
|
|
|
efl_gfx_image_border_insets_scale_set(pd->img, scale);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static double
|
|
|
|
_efl_ui_image_efl_gfx_image_border_insets_scale_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd)
|
|
|
|
{
|
|
|
|
if (pd->edje) return 0.0;
|
|
|
|
return efl_gfx_image_border_insets_scale_get(pd->img);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_gfx_image_center_fill_mode_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd, Efl_Gfx_Center_Fill_Mode fill)
|
|
|
|
{
|
|
|
|
if (pd->edje) return;
|
|
|
|
efl_gfx_image_center_fill_mode_set(pd->img, fill);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EOLIAN static Efl_Gfx_Center_Fill_Mode
|
|
|
|
_efl_ui_image_efl_gfx_image_center_fill_mode_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd)
|
|
|
|
{
|
|
|
|
if (pd->edje) return EFL_GFX_CENTER_FILL_MODE_DEFAULT;
|
|
|
|
return efl_gfx_image_center_fill_mode_get(pd->img);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Error
|
|
|
|
_efl_ui_image_efl_gfx_image_stretch_region_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd, Eina_Iterator *horizontal, Eina_Iterator *vertical)
|
|
|
|
{
|
|
|
|
if (pd->edje)
|
|
|
|
{
|
|
|
|
eina_iterator_free(horizontal);
|
|
|
|
eina_iterator_free(vertical);
|
|
|
|
return EINA_ERROR_NO_ERROR;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return efl_gfx_image_stretch_region_set(pd->img, horizontal, vertical);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_gfx_image_stretch_region_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd, Eina_Iterator **horizontal, Eina_Iterator **vertical)
|
|
|
|
{
|
|
|
|
if (pd->edje)
|
|
|
|
{
|
2019-09-26 14:59:54 -07:00
|
|
|
if (horizontal) *horizontal = NULL;
|
|
|
|
if (vertical) *vertical = NULL;
|
2019-09-21 08:37:07 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
efl_gfx_image_stretch_region_get(pd->img, horizontal, vertical);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_gfx_image_scale_hint_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd, Efl_Gfx_Image_Scale_Hint hint)
|
|
|
|
{
|
|
|
|
if (pd->edje) return;
|
|
|
|
return efl_gfx_image_scale_hint_set(pd->img, hint);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Efl_Gfx_Image_Scale_Hint
|
|
|
|
_efl_ui_image_efl_gfx_image_scale_hint_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd)
|
|
|
|
{
|
|
|
|
if (pd->edje) return EFL_GFX_IMAGE_SCALE_HINT_NONE;
|
|
|
|
return efl_gfx_image_scale_hint_get(pd->img);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_gfx_image_content_hint_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd, Efl_Gfx_Image_Content_Hint hint)
|
|
|
|
{
|
|
|
|
if (pd->edje) return;
|
|
|
|
return efl_gfx_image_content_hint_set(pd->img, hint);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Efl_Gfx_Image_Content_Hint
|
|
|
|
_efl_ui_image_efl_gfx_image_content_hint_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd)
|
|
|
|
{
|
|
|
|
if (pd->edje) return EFL_GFX_IMAGE_CONTENT_HINT_NONE;
|
|
|
|
return efl_gfx_image_content_hint_get(pd->img);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Error
|
|
|
|
_efl_ui_image_efl_gfx_image_image_load_error_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd)
|
|
|
|
{
|
|
|
|
if (pd->edje) return EINA_ERROR_NO_ERROR;
|
|
|
|
|
|
|
|
return efl_gfx_image_load_error_get(pd->img);
|
|
|
|
}
|
|
|
|
|
2009-04-22 20:48:41 -07:00
|
|
|
EAPI void
|
2012-05-25 12:53:59 -07:00
|
|
|
elm_image_prescale_set(Evas_Object *obj,
|
|
|
|
int size)
|
2009-04-22 20:48:41 -07:00
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_CHECK(obj);
|
2018-04-19 04:26:59 -07:00
|
|
|
efl_gfx_image_load_controller_load_size_set(obj, EINA_SIZE2D(size, size));
|
2009-04-22 20:48:41 -07:00
|
|
|
}
|
|
|
|
|
2014-03-23 04:05:20 -07:00
|
|
|
EOLIAN static void
|
2018-04-19 04:26:59 -07:00
|
|
|
_efl_ui_image_efl_gfx_image_load_controller_load_size_set(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Size2D sz)
|
2013-06-24 19:15:15 -07:00
|
|
|
{
|
2017-12-18 00:33:49 -08:00
|
|
|
sd->load_size = sz;
|
2018-08-16 07:01:47 -07:00
|
|
|
|
|
|
|
if (!sd->img) return;
|
2017-12-18 00:33:49 -08:00
|
|
|
_efl_ui_image_load_size_set_internal(obj, sd);
|
2013-06-24 19:15:15 -07:00
|
|
|
}
|
|
|
|
|
2019-09-21 08:37:07 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_gfx_image_load_controller_load_async_start(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd)
|
|
|
|
{
|
|
|
|
if (pd->edje) return;
|
|
|
|
efl_gfx_image_load_controller_load_async_start(pd->img);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_gfx_image_load_controller_load_async_cancel(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd)
|
|
|
|
{
|
|
|
|
if (pd->edje) return;
|
|
|
|
efl_gfx_image_load_controller_load_async_cancel(pd->img);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_gfx_image_load_controller_load_dpi_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd, double dpi)
|
|
|
|
{
|
|
|
|
if (pd->edje) return;
|
|
|
|
efl_gfx_image_load_controller_load_dpi_set(pd->img, dpi);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EOLIAN static double
|
|
|
|
_efl_ui_image_efl_gfx_image_load_controller_load_dpi_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd)
|
|
|
|
{
|
|
|
|
if (pd->edje) return 0.0;
|
|
|
|
return efl_gfx_image_load_controller_load_dpi_get(pd->img);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_gfx_image_load_controller_load_orientation_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd, Eina_Bool enable)
|
|
|
|
{
|
|
|
|
if (pd->edje) return;
|
|
|
|
efl_gfx_image_load_controller_load_orientation_set(pd->img, enable);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_efl_ui_image_efl_gfx_image_load_controller_load_orientation_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd)
|
|
|
|
{
|
|
|
|
if (pd->edje) return EINA_FALSE;
|
|
|
|
return efl_gfx_image_load_controller_load_orientation_get(pd->img);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_gfx_image_load_controller_load_scale_down_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd, int div)
|
|
|
|
{
|
|
|
|
if (pd->edje) return;
|
|
|
|
efl_gfx_image_load_controller_load_scale_down_set(pd->img, div);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static int
|
|
|
|
_efl_ui_image_efl_gfx_image_load_controller_load_scale_down_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd)
|
|
|
|
{
|
|
|
|
if (pd->edje) return EINA_FALSE;
|
|
|
|
return efl_gfx_image_load_controller_load_scale_down_get(pd->img);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_gfx_image_load_controller_load_skip_header_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd, Eina_Bool skip)
|
|
|
|
{
|
|
|
|
if (pd->edje) return;
|
|
|
|
return efl_gfx_image_load_controller_load_skip_header_set(pd->img, skip);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_efl_ui_image_efl_gfx_image_load_controller_load_skip_header_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd)
|
|
|
|
{
|
|
|
|
if (pd->edje) return EINA_FALSE;
|
|
|
|
return efl_gfx_image_load_controller_load_skip_header_get(pd->img);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_gfx_image_load_controller_load_region_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd, Eina_Rect region)
|
|
|
|
{
|
|
|
|
if (pd->edje) return;
|
|
|
|
return efl_gfx_image_load_controller_load_region_set(pd->img, region);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EOLIAN static Eina_Rect
|
|
|
|
_efl_ui_image_efl_gfx_image_load_controller_load_region_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd)
|
|
|
|
{
|
|
|
|
|
|
|
|
if (pd->edje) return EINA_RECT(0, 0, 0, 0);
|
|
|
|
return efl_gfx_image_load_controller_load_region_get(pd->img);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_efl_ui_image_efl_gfx_image_load_controller_load_region_support_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd)
|
|
|
|
{
|
|
|
|
if (pd->edje) return EINA_FALSE;
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2010-10-27 07:38:37 -07:00
|
|
|
EAPI int
|
|
|
|
elm_image_prescale_get(const Evas_Object *obj)
|
|
|
|
{
|
2017-09-18 04:56:45 -07:00
|
|
|
Eina_Size2D sz;
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_CHECK(obj) 0;
|
2010-10-27 07:38:37 -07:00
|
|
|
|
2018-04-19 04:26:59 -07:00
|
|
|
sz = efl_gfx_image_load_controller_load_size_get(obj);
|
2017-12-18 00:33:49 -08:00
|
|
|
|
|
|
|
return MAX(sz.w, sz.h);
|
2010-10-27 07:38:37 -07:00
|
|
|
}
|
|
|
|
|
2017-09-18 04:56:45 -07:00
|
|
|
EOLIAN static Eina_Size2D
|
2018-04-19 04:26:59 -07:00
|
|
|
_efl_ui_image_efl_gfx_image_load_controller_load_size_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
2009-04-22 20:48:41 -07:00
|
|
|
{
|
2017-12-18 00:33:49 -08:00
|
|
|
return sd->load_size;
|
2009-04-22 20:48:41 -07:00
|
|
|
}
|
2010-09-07 21:55:20 -07:00
|
|
|
|
2015-01-11 18:28:13 -08:00
|
|
|
EOLIAN static void
|
2019-07-12 01:22:16 -07:00
|
|
|
_efl_ui_image_efl_gfx_image_orientable_image_orientation_set(Eo *obj, Efl_Ui_Image_Data *sd, Efl_Gfx_Image_Orientation orient)
|
2015-01-11 18:28:13 -08:00
|
|
|
{
|
|
|
|
if (sd->edje) return;
|
|
|
|
if (sd->orient == orient) return;
|
|
|
|
|
2015-02-20 05:26:01 -08:00
|
|
|
sd->orient = orient;
|
2019-08-21 09:31:35 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2013-06-24 19:15:15 -07:00
|
|
|
}
|
|
|
|
|
2019-05-22 11:16:16 -07:00
|
|
|
EOLIAN static Efl_Gfx_Image_Orientation
|
2019-07-12 01:22:16 -07:00
|
|
|
_efl_ui_image_efl_gfx_image_orientable_image_orientation_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
2010-10-27 07:38:37 -07:00
|
|
|
{
|
2014-03-23 04:05:20 -07:00
|
|
|
return sd->orient;
|
2010-09-07 21:55:20 -07:00
|
|
|
}
|
|
|
|
|
2013-06-24 19:15:15 -07:00
|
|
|
/**
|
|
|
|
* Turns on editing through drag and drop and copy and paste.
|
|
|
|
*/
|
2014-03-23 04:05:20 -07:00
|
|
|
EOLIAN static void
|
2016-06-10 01:42:03 -07:00
|
|
|
_efl_ui_image_efl_ui_draggable_drag_target_set(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool edit)
|
2013-06-24 19:15:15 -07:00
|
|
|
{
|
|
|
|
if (sd->edje)
|
|
|
|
{
|
|
|
|
WRN("No editing edje objects yet (ever)\n");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
edit = !!edit;
|
|
|
|
|
|
|
|
if (edit == sd->edit) return;
|
|
|
|
|
|
|
|
sd->edit = edit;
|
|
|
|
|
|
|
|
if (sd->edit)
|
|
|
|
elm_drop_target_add
|
|
|
|
(obj, ELM_SEL_FORMAT_IMAGE,
|
|
|
|
NULL, NULL,
|
|
|
|
NULL, NULL,
|
|
|
|
NULL, NULL,
|
2016-05-31 03:38:21 -07:00
|
|
|
_efl_ui_image_drag_n_drop_cb, obj);
|
2013-06-24 19:15:15 -07:00
|
|
|
else
|
2013-11-04 05:08:53 -08:00
|
|
|
elm_drop_target_del
|
|
|
|
(obj, ELM_SEL_FORMAT_IMAGE,
|
|
|
|
NULL, NULL,
|
|
|
|
NULL, NULL,
|
|
|
|
NULL, NULL,
|
2016-05-31 03:38:21 -07:00
|
|
|
_efl_ui_image_drag_n_drop_cb, obj);
|
2013-06-24 19:15:15 -07:00
|
|
|
}
|
|
|
|
|
2014-03-23 04:05:20 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_image_efl_ui_draggable_drag_target_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
2013-06-24 19:15:15 -07:00
|
|
|
{
|
2014-03-23 04:05:20 -07:00
|
|
|
return sd->edit;
|
2013-06-24 19:15:15 -07:00
|
|
|
}
|
|
|
|
|
2015-06-17 02:17:19 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_image_animated_available_get(const Evas_Object *obj)
|
|
|
|
{
|
2019-09-24 06:39:21 -07:00
|
|
|
return efl_playable_get(obj);
|
2015-06-17 02:17:19 -07:00
|
|
|
}
|
|
|
|
|
2014-03-23 04:05:20 -07:00
|
|
|
EOLIAN static Eina_Bool
|
2019-09-24 06:39:21 -07:00
|
|
|
_efl_ui_image_efl_playable_playable_get(const Eo *obj, Efl_Ui_Image_Data *sd)
|
2012-05-28 13:35:29 -07:00
|
|
|
{
|
2017-06-07 02:50:46 -07:00
|
|
|
if (sd->edje) return EINA_TRUE;
|
2012-11-25 22:32:53 -08:00
|
|
|
|
2014-03-23 04:05:20 -07:00
|
|
|
return evas_object_image_animated_get(elm_image_object_get(obj));
|
2012-05-28 13:35:29 -07:00
|
|
|
}
|
|
|
|
|
2019-09-24 08:18:57 -07:00
|
|
|
static Eina_Bool
|
2016-05-31 03:38:21 -07:00
|
|
|
_efl_ui_image_animated_set_internal(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool anim)
|
2012-05-28 13:35:29 -07:00
|
|
|
{
|
|
|
|
anim = !!anim;
|
2019-09-24 08:18:57 -07:00
|
|
|
if (sd->anim == anim) return EINA_TRUE;
|
2012-05-28 13:35:29 -07:00
|
|
|
|
2015-01-21 12:14:20 -08:00
|
|
|
if (sd->edje)
|
|
|
|
{
|
|
|
|
edje_object_animation_set(sd->img, anim);
|
2019-09-24 08:18:57 -07:00
|
|
|
sd->anim = anim;
|
2020-02-10 09:11:03 -08:00
|
|
|
efl_player_playback_loop_set(sd->img, sd->playback_loop);
|
2019-09-24 08:18:57 -07:00
|
|
|
return EINA_TRUE;
|
2015-01-21 12:14:20 -08:00
|
|
|
}
|
2012-05-28 13:35:29 -07:00
|
|
|
sd->img = elm_image_object_get(obj);
|
2019-10-07 06:38:14 -07:00
|
|
|
|
|
|
|
if (elm_widget_is_legacy(obj)) sd->anim = anim; //legacy
|
|
|
|
|
2019-09-24 08:18:57 -07:00
|
|
|
if (!evas_object_image_animated_get(sd->img)) return EINA_FALSE;
|
|
|
|
sd->anim = anim;
|
2012-05-28 13:35:29 -07:00
|
|
|
|
|
|
|
if (anim)
|
|
|
|
{
|
|
|
|
sd->frame_count = evas_object_image_animated_frame_count_get(sd->img);
|
2020-03-09 01:54:33 -07:00
|
|
|
sd->cur_frame = 1;
|
2012-05-28 13:35:29 -07:00
|
|
|
sd->frame_duration =
|
|
|
|
evas_object_image_animated_frame_duration_get
|
|
|
|
(sd->img, sd->cur_frame, 0);
|
|
|
|
evas_object_image_animated_frame_set(sd->img, sd->cur_frame);
|
2019-09-24 08:18:57 -07:00
|
|
|
if (!sd->paused)//legacy
|
|
|
|
sd->anim_timer = ecore_timer_add
|
2019-09-25 03:47:49 -07:00
|
|
|
(sd->frame_duration / sd->playback_speed, _efl_ui_image_animate_cb, obj);
|
2012-05-28 13:35:29 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sd->frame_count = -1;
|
|
|
|
sd->cur_frame = -1;
|
|
|
|
sd->frame_duration = -1;
|
2019-09-24 08:18:57 -07:00
|
|
|
ELM_SAFE_FREE(sd->anim_timer, ecore_timer_del);
|
2012-05-28 13:35:29 -07:00
|
|
|
}
|
2019-09-24 08:18:57 -07:00
|
|
|
return EINA_TRUE;
|
2012-05-28 13:35:29 -07:00
|
|
|
}
|
|
|
|
|
2015-06-17 02:17:19 -07:00
|
|
|
static Eina_Bool
|
2016-05-31 03:38:21 -07:00
|
|
|
_efl_ui_image_animated_get_internal(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
2012-05-28 13:35:29 -07:00
|
|
|
{
|
2015-01-21 12:14:20 -08:00
|
|
|
if (sd->edje)
|
|
|
|
return edje_object_animation_get(sd->img);
|
2014-03-23 04:05:20 -07:00
|
|
|
return sd->anim;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
|
|
|
|
2015-06-17 02:17:19 -07:00
|
|
|
EAPI void
|
|
|
|
elm_image_animated_set(Evas_Object *obj, Eina_Bool anim)
|
|
|
|
{
|
2016-08-15 06:44:41 -07:00
|
|
|
Efl_Ui_Image_Data *sd = efl_data_scope_get(obj, MY_CLASS);
|
2015-06-17 02:17:19 -07:00
|
|
|
if (!sd) return;
|
2016-05-31 03:38:21 -07:00
|
|
|
_efl_ui_image_animated_set_internal(obj, sd, anim);
|
2015-06-17 02:17:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_image_animated_get(const Evas_Object *obj)
|
|
|
|
{
|
2016-08-15 06:44:41 -07:00
|
|
|
Efl_Ui_Image_Data *sd = efl_data_scope_get(obj, MY_CLASS);
|
2015-06-17 02:17:19 -07:00
|
|
|
if (!sd) return EINA_FALSE;
|
2016-05-31 03:38:21 -07:00
|
|
|
return _efl_ui_image_animated_get_internal(obj, sd);
|
2015-06-17 02:17:19 -07:00
|
|
|
}
|
|
|
|
|
2019-09-24 08:18:57 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_efl_ui_image_efl_player_playing_set(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool playing)
|
|
|
|
{
|
|
|
|
return _efl_ui_image_animated_set_internal(obj, sd, playing);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_efl_ui_image_efl_player_playing_get(const Eo *obj, Efl_Ui_Image_Data *sd)
|
2012-11-25 22:32:53 -08:00
|
|
|
{
|
2019-09-24 08:18:57 -07:00
|
|
|
return _efl_ui_image_animated_get_internal(obj, sd);
|
|
|
|
}
|
|
|
|
|
2020-02-10 09:11:03 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_player_playback_loop_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, Eina_Bool playback_loop)
|
|
|
|
{
|
|
|
|
playback_loop = !!playback_loop;
|
|
|
|
sd->playback_loop = playback_loop;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_efl_ui_image_efl_player_playback_loop_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
|
|
|
{
|
|
|
|
return sd->playback_loop;
|
|
|
|
}
|
|
|
|
|
2020-02-10 08:05:35 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_player_autoplay_set(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool autoplay)
|
|
|
|
{
|
|
|
|
autoplay = !!autoplay;
|
|
|
|
if (sd->autoplay == autoplay) return;
|
|
|
|
sd->autoplay = autoplay;
|
|
|
|
if (sd->img && (!sd->edje))
|
|
|
|
{
|
|
|
|
/* filter cases where we aren't going to immediately start playing */
|
|
|
|
if (!autoplay) return;
|
|
|
|
if ((sd->preload_status != EFL_UI_IMAGE_PRELOADED) &&
|
|
|
|
(sd->preload_status != EFL_UI_IMAGE_PRELOAD_DISABLED))
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
efl_player_playing_set(obj, EINA_TRUE);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_efl_ui_image_efl_player_autoplay_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
|
|
|
{
|
|
|
|
return sd->autoplay;
|
|
|
|
}
|
|
|
|
|
2019-09-24 12:43:00 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_player_playback_speed_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, double factor)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_TRUE_RETURN(factor < 0.0);
|
|
|
|
EINA_SAFETY_ON_TRUE_RETURN(EINA_DBL_EQ(factor, 0.0));
|
|
|
|
if (EINA_DBL_EQ(sd->playback_speed, factor)) return;
|
|
|
|
sd->playback_speed = factor;
|
|
|
|
if (sd->edje)
|
|
|
|
efl_player_playback_speed_set(sd->img, factor);
|
|
|
|
else if (sd->anim_timer)
|
|
|
|
{
|
2019-09-25 03:47:49 -07:00
|
|
|
ecore_timer_interval_set(sd->anim_timer, sd->frame_duration / sd->playback_speed);
|
2019-09-24 12:43:00 -07:00
|
|
|
ecore_timer_reset(sd->anim_timer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static double
|
|
|
|
_efl_ui_image_efl_player_playback_speed_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
|
|
|
{
|
|
|
|
return sd->playback_speed;
|
|
|
|
}
|
|
|
|
|
2019-09-24 12:27:24 -07:00
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_player_playback_position_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, double sec)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_TRUE_RETURN(sec < 0.0);
|
|
|
|
if (sd->edje)
|
|
|
|
efl_player_playback_position_set(sd->img, sec);
|
|
|
|
else if ((sd->frame_count > 0) && (sd->frame_duration > 0.0))
|
|
|
|
{
|
|
|
|
/* validate total animation time */
|
|
|
|
EINA_SAFETY_ON_TRUE_RETURN(sd->frame_count * sd->frame_duration < sec);
|
|
|
|
sd->cur_frame = lround(sec / sd->frame_duration);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static double
|
|
|
|
_efl_ui_image_efl_player_playback_position_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
|
|
|
{
|
|
|
|
if (sd->edje)
|
|
|
|
efl_player_playback_position_get(sd->img);
|
|
|
|
else if ((sd->frame_count > 0) && (sd->frame_duration > 0.0))
|
|
|
|
return sd->cur_frame * sd->frame_duration;
|
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
2019-09-24 12:30:11 -07:00
|
|
|
EOLIAN static double
|
|
|
|
_efl_ui_image_efl_player_playback_progress_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
|
|
|
{
|
|
|
|
if (sd->edje)
|
|
|
|
efl_player_playback_progress_get(sd->img);
|
2019-12-31 06:53:10 -08:00
|
|
|
else if (sd->frame_count > 1)
|
2020-03-09 01:54:33 -07:00
|
|
|
return ((double)sd->cur_frame - 1.0) / ((double)sd->frame_count - 1.0);
|
2019-09-24 12:30:11 -07:00
|
|
|
return 0.0;
|
|
|
|
}
|
|
|
|
|
2019-12-31 06:53:10 -08:00
|
|
|
EOLIAN static void
|
|
|
|
_efl_ui_image_efl_player_playback_progress_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, double progress)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_TRUE_RETURN(progress > 1 || progress < 0);
|
|
|
|
if (sd->edje)
|
|
|
|
efl_player_playback_progress_set(sd->img, progress);
|
2020-03-09 01:54:33 -07:00
|
|
|
else if (sd->frame_count > 0)
|
|
|
|
sd->cur_frame = (lround(progress * (sd->frame_count - 1)) + 1);
|
2019-12-31 06:53:10 -08:00
|
|
|
else
|
2020-03-09 01:54:33 -07:00
|
|
|
sd->cur_frame = 1;
|
2019-12-31 06:53:10 -08:00
|
|
|
}
|
|
|
|
|
2019-09-24 08:18:57 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_efl_ui_image_animated_paused_set_internal(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool paused)
|
|
|
|
{
|
|
|
|
paused = !!paused;
|
|
|
|
if (!sd->anim) return EINA_FALSE;
|
|
|
|
if (sd->paused == paused) return EINA_TRUE;
|
|
|
|
sd->paused = paused;
|
2015-01-21 12:14:20 -08:00
|
|
|
if (sd->edje)
|
|
|
|
{
|
2019-09-24 08:18:57 -07:00
|
|
|
edje_object_play_set(sd->img, !paused);
|
|
|
|
return EINA_TRUE;
|
2015-01-21 12:14:20 -08:00
|
|
|
}
|
2019-09-24 08:18:57 -07:00
|
|
|
if (!paused)
|
2012-05-28 13:35:29 -07:00
|
|
|
{
|
|
|
|
sd->anim_timer = ecore_timer_add
|
2019-09-25 03:47:49 -07:00
|
|
|
(sd->frame_duration / sd->playback_speed, _efl_ui_image_animate_cb, obj);
|
2012-05-28 13:35:29 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-29 04:56:07 -07:00
|
|
|
ELM_SAFE_FREE(sd->anim_timer, ecore_timer_del);
|
2012-05-28 13:35:29 -07:00
|
|
|
}
|
2019-09-24 08:18:57 -07:00
|
|
|
return EINA_TRUE;
|
2012-05-28 13:35:29 -07:00
|
|
|
}
|
|
|
|
|
2015-06-17 02:17:19 -07:00
|
|
|
static Eina_Bool
|
2019-09-24 08:18:57 -07:00
|
|
|
_efl_ui_image_animated_paused_get_internal(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
2012-05-28 13:35:29 -07:00
|
|
|
{
|
2015-01-21 12:14:20 -08:00
|
|
|
if (sd->edje)
|
2019-09-24 08:18:57 -07:00
|
|
|
return !edje_object_play_get(sd->img);
|
|
|
|
return sd->paused;
|
2012-11-25 22:32:53 -08:00
|
|
|
}
|
2012-05-28 13:35:29 -07:00
|
|
|
|
2015-06-17 02:17:19 -07:00
|
|
|
EAPI void
|
|
|
|
elm_image_animated_play_set(Elm_Image *obj, Eina_Bool play)
|
|
|
|
{
|
2016-08-15 06:44:41 -07:00
|
|
|
Efl_Ui_Image_Data *sd = efl_data_scope_get(obj, MY_CLASS);
|
2015-06-17 02:17:19 -07:00
|
|
|
if (!sd) return;
|
2019-09-24 08:18:57 -07:00
|
|
|
_efl_ui_image_animated_paused_set_internal(obj, sd, !play);
|
2015-06-17 02:17:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_image_animated_play_get(const Elm_Image *obj)
|
|
|
|
{
|
2016-08-15 06:44:41 -07:00
|
|
|
Efl_Ui_Image_Data *sd = efl_data_scope_get(obj, MY_CLASS);
|
2015-06-17 02:17:19 -07:00
|
|
|
if (!sd) return EINA_FALSE;
|
2019-09-26 06:00:09 -07:00
|
|
|
return !_efl_ui_image_animated_paused_get_internal(obj, sd);
|
2015-06-17 02:17:19 -07:00
|
|
|
}
|
|
|
|
|
2019-09-24 08:18:57 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_efl_ui_image_efl_player_paused_set(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool paused)
|
2015-06-17 02:17:19 -07:00
|
|
|
{
|
2019-09-24 08:18:57 -07:00
|
|
|
return _efl_ui_image_animated_paused_set_internal(obj, sd, paused);
|
2015-06-17 02:17:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2019-09-24 08:18:57 -07:00
|
|
|
_efl_ui_image_efl_player_paused_get(const Eo *obj, Efl_Ui_Image_Data *sd)
|
2015-06-17 02:17:19 -07:00
|
|
|
{
|
2019-09-24 08:18:57 -07:00
|
|
|
return _efl_ui_image_animated_paused_get_internal(obj, sd);
|
2015-06-17 02:17:19 -07:00
|
|
|
}
|
|
|
|
|
2016-04-28 19:50:59 -07:00
|
|
|
EOLIAN static void
|
2019-09-16 02:06:02 -07:00
|
|
|
_efl_ui_image_efl_gfx_image_scale_method_set(Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd EINA_UNUSED, Efl_Gfx_Image_Scale_Method scale_type)
|
2016-04-28 19:50:59 -07:00
|
|
|
{
|
2016-05-11 21:25:13 -07:00
|
|
|
if (scale_type == sd->scale_type) return;
|
|
|
|
|
|
|
|
sd->scale_type = scale_type;
|
|
|
|
|
2019-08-21 09:31:35 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2016-04-28 19:50:59 -07:00
|
|
|
}
|
|
|
|
|
2019-09-16 02:06:02 -07:00
|
|
|
EOLIAN static Efl_Gfx_Image_Scale_Method
|
|
|
|
_efl_ui_image_efl_gfx_image_scale_method_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
2016-04-28 19:50:59 -07:00
|
|
|
{
|
2016-05-11 21:25:13 -07:00
|
|
|
return sd->scale_type;
|
2016-04-28 19:50:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2019-08-22 05:35:44 -07:00
|
|
|
_efl_ui_image_efl_gfx_image_can_upscale_set(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool can_upscale)
|
2016-04-28 19:50:59 -07:00
|
|
|
{
|
2019-08-22 05:35:44 -07:00
|
|
|
if (can_upscale == sd->scale_up) return;
|
2016-05-11 21:25:13 -07:00
|
|
|
|
2019-08-22 05:35:44 -07:00
|
|
|
sd->scale_up = !!can_upscale;
|
2016-05-11 21:25:13 -07:00
|
|
|
|
2019-08-21 09:31:35 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2016-04-28 19:50:59 -07:00
|
|
|
}
|
|
|
|
|
2019-08-22 05:35:44 -07:00
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_efl_ui_image_efl_gfx_image_can_upscale_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
|
|
|
{
|
|
|
|
return sd->scale_up;
|
|
|
|
}
|
|
|
|
|
2016-04-28 19:50:59 -07:00
|
|
|
EOLIAN static void
|
2019-08-22 05:35:44 -07:00
|
|
|
_efl_ui_image_efl_gfx_image_can_downscale_set(Eo *obj, Efl_Ui_Image_Data *sd, Eina_Bool can_downscale)
|
|
|
|
{
|
|
|
|
if (can_downscale == sd->scale_down) return;
|
|
|
|
|
|
|
|
sd->scale_down = !!can_downscale;
|
|
|
|
|
|
|
|
efl_canvas_group_change(obj);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
|
|
|
_efl_ui_image_efl_gfx_image_can_downscale_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
2016-04-28 19:50:59 -07:00
|
|
|
{
|
2019-08-22 05:35:44 -07:00
|
|
|
return sd->scale_down;
|
2016-04-28 19:50:59 -07:00
|
|
|
}
|
|
|
|
|
2016-05-27 04:58:25 -07:00
|
|
|
EOLIAN static void
|
2019-08-21 09:59:30 -07:00
|
|
|
_efl_ui_image_efl_gfx_arrangement_content_align_set(Eo *obj, Efl_Ui_Image_Data *sd, double align_x, double align_y)
|
2016-05-27 04:58:25 -07:00
|
|
|
{
|
|
|
|
if (align_x > 1.0)
|
|
|
|
align_x = 1.0;
|
|
|
|
else if (align_x < 0.0)
|
|
|
|
align_x = 0.0;
|
|
|
|
|
|
|
|
if (align_y > 1.0)
|
|
|
|
align_y = 1.0;
|
|
|
|
else if (align_y < 0.0)
|
|
|
|
align_y = 0.0;
|
|
|
|
|
2017-01-06 09:57:46 -08:00
|
|
|
if ((EINA_DBL_EQ(align_x, sd->align_x)) && (EINA_DBL_EQ(align_y, sd->align_y))) return;
|
2016-05-27 04:58:25 -07:00
|
|
|
|
|
|
|
sd->align_x = align_x;
|
|
|
|
sd->align_y = align_y;
|
|
|
|
|
2019-08-21 09:31:35 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2016-05-27 04:58:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static void
|
2019-08-21 09:59:30 -07:00
|
|
|
_efl_ui_image_efl_gfx_arrangement_content_align_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd, double *align_x, double *align_y)
|
2016-05-27 04:58:25 -07:00
|
|
|
{
|
|
|
|
if (align_x) *align_x = sd->align_x;
|
|
|
|
if (align_y) *align_y = sd->align_y;
|
|
|
|
}
|
|
|
|
|
2014-05-27 00:23:13 -07:00
|
|
|
// A11Y
|
|
|
|
|
2018-02-14 18:14:52 -08:00
|
|
|
EOLIAN static Eina_Rect
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_image_efl_access_component_extents_get(const Eo *obj, Efl_Ui_Image_Data *sd EINA_UNUSED, Eina_Bool screen_coords)
|
2014-05-27 00:23:13 -07:00
|
|
|
{
|
2018-02-14 18:14:52 -08:00
|
|
|
Eina_Rect r;
|
2014-05-27 00:23:13 -07:00
|
|
|
Evas_Object *image = elm_image_object_get(obj);
|
|
|
|
|
2018-02-14 18:14:52 -08:00
|
|
|
r.x = r.y = r.w = r.h = -1;
|
|
|
|
if (!image) return r;
|
|
|
|
|
|
|
|
evas_object_geometry_get(image, &r.x, &r.y, NULL, NULL);
|
2014-05-27 00:23:13 -07:00
|
|
|
if (screen_coords)
|
|
|
|
{
|
2021-06-02 20:44:24 -07:00
|
|
|
r = _efl_access_component_screen_coords_extents_get(obj, r);
|
2014-05-27 00:23:13 -07:00
|
|
|
}
|
2018-02-14 18:14:52 -08:00
|
|
|
elm_image_object_size_get(obj, &r.w, &r.h);
|
|
|
|
return r;
|
2014-05-27 00:23:13 -07:00
|
|
|
}
|
|
|
|
|
2017-11-15 18:55:06 -08:00
|
|
|
EOLIAN const Efl_Access_Action_Data *
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_image_efl_access_widget_action_elm_actions_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *pd EINA_UNUSED)
|
2014-07-11 01:28:29 -07:00
|
|
|
{
|
2017-11-15 18:55:06 -08:00
|
|
|
static Efl_Access_Action_Data atspi_actions[] = {
|
2014-07-25 01:33:19 -07:00
|
|
|
{ "activate", "activate", NULL, _key_action_activate },
|
|
|
|
{ NULL, NULL, NULL, NULL },
|
|
|
|
};
|
|
|
|
return &atspi_actions[0];
|
2014-07-11 01:28:29 -07:00
|
|
|
}
|
|
|
|
|
2016-04-27 06:35:23 -07:00
|
|
|
static Eina_Bool
|
|
|
|
_icon_standard_set(Evas_Object *obj, const char *name)
|
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
2016-04-27 06:35:23 -07:00
|
|
|
|
|
|
|
if (_elm_theme_object_icon_set(obj, name, "default"))
|
|
|
|
{
|
|
|
|
/* TODO: elm_unneed_efreet() */
|
|
|
|
sd->freedesktop.use = EINA_FALSE;
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static Eina_Bool
|
|
|
|
_icon_freedesktop_set(Evas_Object *obj, const char *name, int size)
|
|
|
|
{
|
|
|
|
const char *path;
|
|
|
|
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
2016-04-27 06:35:23 -07:00
|
|
|
|
|
|
|
elm_need_efreet();
|
|
|
|
|
|
|
|
if (icon_theme == NON_EXISTING) return EINA_FALSE;
|
|
|
|
|
|
|
|
if (!icon_theme)
|
|
|
|
{
|
|
|
|
Efreet_Icon_Theme *theme;
|
|
|
|
/* TODO: Listen for EFREET_EVENT_ICON_CACHE_UPDATE */
|
|
|
|
theme = efreet_icon_theme_find(elm_config_icon_theme_get());
|
|
|
|
if (!theme)
|
|
|
|
{
|
|
|
|
const char **itr;
|
|
|
|
static const char *themes[] = {
|
|
|
|
"gnome", "Human", "oxygen", "hicolor", NULL
|
|
|
|
};
|
|
|
|
for (itr = themes; *itr; itr++)
|
|
|
|
{
|
|
|
|
theme = efreet_icon_theme_find(*itr);
|
|
|
|
if (theme) break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!theme)
|
|
|
|
{
|
|
|
|
icon_theme = NON_EXISTING;
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
icon_theme = eina_stringshare_add(theme->name.internal);
|
|
|
|
}
|
|
|
|
path = efreet_icon_path_find(icon_theme, name, size);
|
|
|
|
sd->freedesktop.use = !!path;
|
|
|
|
if (sd->freedesktop.use)
|
|
|
|
{
|
|
|
|
sd->freedesktop.requested_size = size;
|
2019-02-27 10:17:09 -08:00
|
|
|
efl_file_simple_load(obj, path, NULL);
|
2016-04-27 06:35:23 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline int
|
|
|
|
_icon_size_min_get(Evas_Object *image)
|
|
|
|
{
|
|
|
|
int w, h;
|
|
|
|
|
|
|
|
evas_object_geometry_get(image, NULL, NULL, &w, &h);
|
|
|
|
|
|
|
|
return MAX(16, MIN(w, h));
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: move this code to ecore */
|
|
|
|
#ifdef _WIN32
|
|
|
|
static Eina_Bool
|
|
|
|
_path_is_absolute(const char *path)
|
|
|
|
{
|
|
|
|
//TODO: Check if this works with all absolute paths in windows
|
|
|
|
return (isalpha(*path)) && (*(path + 1) == ':') &&
|
|
|
|
((*(path + 2) == '\\') || (*(path + 2) == '/'));
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
static Eina_Bool
|
|
|
|
_path_is_absolute(const char *path)
|
|
|
|
{
|
|
|
|
return *path == '/';
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
static Eina_Bool
|
2016-05-31 03:38:21 -07:00
|
|
|
_internal_efl_ui_image_icon_set(Evas_Object *obj, const char *name, Eina_Bool *fdo)
|
2016-04-27 06:35:23 -07:00
|
|
|
{
|
|
|
|
char *tmp;
|
|
|
|
Eina_Bool ret = EINA_FALSE;
|
|
|
|
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
2016-04-27 06:35:23 -07:00
|
|
|
|
|
|
|
/* try locating the icon using the specified theme */
|
|
|
|
if (!strcmp(ELM_CONFIG_ICON_THEME_ELEMENTARY, elm_config_icon_theme_get()))
|
|
|
|
{
|
|
|
|
ret = _icon_standard_set(obj, name);
|
|
|
|
if (ret && fdo) *fdo = EINA_FALSE;
|
2020-02-24 06:02:30 -08:00
|
|
|
if (!ret)
|
|
|
|
{
|
|
|
|
ret = _icon_freedesktop_set(obj, name, _icon_size_min_get(obj));
|
|
|
|
if (ret && fdo) *fdo = EINA_TRUE;
|
|
|
|
}
|
2016-04-27 06:35:23 -07:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ret = _icon_freedesktop_set(obj, name, _icon_size_min_get(obj));
|
|
|
|
if (ret && fdo) *fdo = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ret)
|
|
|
|
{
|
|
|
|
eina_stringshare_replace(&sd->stdicon, name);
|
2019-08-21 09:31:35 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2016-04-27 06:35:23 -07:00
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
2017-06-05 01:01:25 -07:00
|
|
|
else
|
|
|
|
eina_stringshare_replace(&sd->stdicon, NULL);
|
2016-04-27 06:35:23 -07:00
|
|
|
|
|
|
|
if (_path_is_absolute(name))
|
|
|
|
{
|
|
|
|
if (fdo)
|
|
|
|
*fdo = EINA_FALSE;
|
2019-02-27 10:17:09 -08:00
|
|
|
return efl_file_simple_load(obj, name, NULL);
|
2016-04-27 06:35:23 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
/* if that fails, see if icon name is in the format size/name. if so,
|
|
|
|
try locating a fallback without the size specification */
|
|
|
|
if (!(tmp = strchr(name, '/'))) return EINA_FALSE;
|
|
|
|
++tmp;
|
2016-05-31 03:38:21 -07:00
|
|
|
if (*tmp) return _internal_efl_ui_image_icon_set(obj, tmp, fdo);
|
2016-04-27 06:35:23 -07:00
|
|
|
/* give up */
|
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
2016-05-31 03:38:21 -07:00
|
|
|
_efl_ui_image_icon_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
2016-04-27 06:35:23 -07:00
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_DATA_GET(data, sd);
|
2016-04-27 06:35:23 -07:00
|
|
|
const char *refup = eina_stringshare_ref(sd->stdicon);
|
|
|
|
Eina_Bool fdo = EINA_FALSE;
|
|
|
|
|
2016-05-31 03:38:21 -07:00
|
|
|
if (!_internal_efl_ui_image_icon_set(obj, sd->stdicon, &fdo) || (!fdo))
|
2016-04-27 06:35:23 -07:00
|
|
|
evas_object_event_callback_del_full
|
2016-05-31 03:38:21 -07:00
|
|
|
(obj, EVAS_CALLBACK_RESIZE, _efl_ui_image_icon_resize_cb, data);
|
2016-04-27 06:35:23 -07:00
|
|
|
eina_stringshare_del(refup);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eina_Bool
|
2016-05-31 03:38:21 -07:00
|
|
|
_efl_ui_image_icon_set(Eo *obj, Efl_Ui_Image_Data *_pd EINA_UNUSED, const char *name)
|
2016-04-27 06:35:23 -07:00
|
|
|
{
|
|
|
|
Eina_Bool fdo = EINA_FALSE;
|
|
|
|
|
|
|
|
if (!name) return EINA_FALSE;
|
|
|
|
|
|
|
|
evas_object_event_callback_del_full
|
2016-05-31 03:38:21 -07:00
|
|
|
(obj, EVAS_CALLBACK_RESIZE, _efl_ui_image_icon_resize_cb, obj);
|
2016-04-27 06:35:23 -07:00
|
|
|
|
2016-05-31 03:38:21 -07:00
|
|
|
Eina_Bool int_ret = _internal_efl_ui_image_icon_set(obj, name, &fdo);
|
2016-04-27 06:35:23 -07:00
|
|
|
|
|
|
|
if (fdo)
|
|
|
|
evas_object_event_callback_add
|
2016-05-31 03:38:21 -07:00
|
|
|
(obj, EVAS_CALLBACK_RESIZE, _efl_ui_image_icon_resize_cb, obj);
|
2016-04-27 06:35:23 -07:00
|
|
|
|
|
|
|
return int_ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static const char*
|
2018-04-17 11:09:44 -07:00
|
|
|
_efl_ui_image_icon_get(const Eo *obj EINA_UNUSED, Efl_Ui_Image_Data *sd)
|
2016-04-27 06:35:23 -07:00
|
|
|
{
|
|
|
|
return sd->stdicon;
|
|
|
|
}
|
|
|
|
|
2018-01-26 11:37:00 -08:00
|
|
|
void
|
|
|
|
_update_viewmodel(Eo *obj, Efl_Ui_Image_Data *pd)
|
2017-01-31 12:17:58 -08:00
|
|
|
{
|
2018-01-26 11:37:00 -08:00
|
|
|
Eina_Value *vfile = NULL;
|
|
|
|
Eina_Value *vkey = NULL;
|
|
|
|
Eina_File *f = NULL;
|
|
|
|
char *file = NULL;
|
|
|
|
char *key = NULL;
|
2019-02-12 10:52:43 -08:00
|
|
|
Efl_Model *model;
|
2017-01-31 12:17:58 -08:00
|
|
|
|
2019-07-10 17:56:20 -07:00
|
|
|
if (!pd->property.file) return ;
|
|
|
|
|
|
|
|
if (!pd->property_watch)
|
|
|
|
{
|
|
|
|
efl_event_callback_add(obj, EFL_UI_VIEW_EVENT_MODEL_CHANGED,
|
|
|
|
_efl_ui_image_model_changed, pd);
|
|
|
|
pd->property_watch = EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2019-02-12 10:52:43 -08:00
|
|
|
model = efl_ui_view_model_get(obj);
|
|
|
|
if (!model) return ;
|
2017-01-31 12:17:58 -08:00
|
|
|
|
2019-02-12 10:52:43 -08:00
|
|
|
vfile = efl_model_property_get(model, pd->property.file);
|
2018-06-07 14:44:37 -07:00
|
|
|
if (!vfile) return;
|
2019-02-12 10:52:43 -08:00
|
|
|
vkey = efl_model_property_get(model, pd->property.key);
|
2017-01-31 12:17:58 -08:00
|
|
|
|
2018-06-07 14:44:37 -07:00
|
|
|
if (eina_value_type_get(vfile) == EINA_VALUE_TYPE_ERROR)
|
|
|
|
goto err;
|
|
|
|
|
2018-01-26 11:37:00 -08:00
|
|
|
if (pd->property.icon)
|
2017-01-31 12:17:58 -08:00
|
|
|
{
|
2018-01-26 11:37:00 -08:00
|
|
|
file = eina_value_to_string(vfile);
|
2017-01-31 12:17:58 -08:00
|
|
|
|
2018-01-26 11:37:00 -08:00
|
|
|
efl_ui_image_icon_set(obj, file);
|
2017-01-31 12:17:58 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-06-07 14:44:37 -07:00
|
|
|
if (vkey && eina_value_type_get(vkey) != EINA_VALUE_TYPE_ERROR)
|
|
|
|
key = eina_value_to_string(vkey);
|
2018-01-26 11:37:00 -08:00
|
|
|
if (eina_value_type_get(vfile) == EINA_VALUE_TYPE_FILE)
|
|
|
|
{
|
|
|
|
eina_value_get(vfile, &f);
|
2017-01-31 12:17:58 -08:00
|
|
|
|
2019-02-27 10:17:09 -08:00
|
|
|
efl_file_simple_mmap_load(obj, f, key);
|
2018-01-26 11:37:00 -08:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
file = eina_value_to_string(vfile);
|
2017-01-31 12:17:58 -08:00
|
|
|
|
2019-02-27 10:17:09 -08:00
|
|
|
efl_file_simple_load(obj, file, key);
|
2018-01-26 11:37:00 -08:00
|
|
|
}
|
2017-01-31 12:17:58 -08:00
|
|
|
}
|
|
|
|
|
2018-01-26 11:37:00 -08:00
|
|
|
free(file);
|
|
|
|
free(key);
|
2018-06-07 14:44:37 -07:00
|
|
|
err:
|
|
|
|
eina_value_free(vfile);
|
|
|
|
eina_value_free(vkey);
|
2017-01-31 12:17:58 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
static void
|
|
|
|
_efl_ui_image_model_properties_changed_cb(void *data, const Efl_Event *event)
|
|
|
|
{
|
|
|
|
Efl_Model_Property_Event *evt = event->info;
|
2018-01-26 11:37:00 -08:00
|
|
|
Eina_Array_Iterator it;
|
2017-01-31 12:17:58 -08:00
|
|
|
Eo *obj = data;
|
2018-01-26 11:37:00 -08:00
|
|
|
const char *prop;
|
|
|
|
unsigned int i;
|
|
|
|
Eina_Bool refresh = EINA_FALSE;
|
2017-01-31 12:17:58 -08:00
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, pd);
|
|
|
|
|
|
|
|
if (!evt->changed_properties)
|
|
|
|
return;
|
|
|
|
|
2018-01-26 11:37:00 -08:00
|
|
|
EINA_ARRAY_ITER_NEXT(evt->changed_properties, i, prop, it)
|
2017-01-31 12:17:58 -08:00
|
|
|
{
|
2018-01-26 11:37:00 -08:00
|
|
|
if (pd->property.file &&
|
|
|
|
(pd->property.file == prop || !strcmp(pd->property.file, prop)))
|
|
|
|
{
|
|
|
|
refresh = EINA_TRUE;
|
|
|
|
break ;
|
|
|
|
}
|
|
|
|
if (pd->property.key &&
|
|
|
|
(pd->property.key == prop || !strcmp(pd->property.key, prop)))
|
|
|
|
{
|
|
|
|
refresh = EINA_TRUE;
|
|
|
|
break ;
|
|
|
|
}
|
2017-01-31 12:17:58 -08:00
|
|
|
}
|
2018-01-26 11:37:00 -08:00
|
|
|
|
|
|
|
if (refresh) _update_viewmodel(obj, pd);
|
2017-01-31 12:17:58 -08:00
|
|
|
}
|
|
|
|
|
2019-02-12 11:55:03 -08:00
|
|
|
EOLIAN static Eina_Error
|
2019-01-31 03:59:19 -08:00
|
|
|
_efl_ui_image_efl_ui_property_bind_property_bind(Eo *obj, Efl_Ui_Image_Data *pd, const char *key, const char *property)
|
2017-01-31 12:17:58 -08:00
|
|
|
{
|
2019-02-12 16:47:31 -08:00
|
|
|
Eina_Stringshare *sk;
|
|
|
|
|
2019-07-10 17:56:20 -07:00
|
|
|
if (efl_ui_property_bind(efl_super(obj, EFL_UI_IMAGE_CLASS), key, property) == 0)
|
|
|
|
return 0;
|
|
|
|
|
2019-01-31 03:59:19 -08:00
|
|
|
if (strcmp(key, "filename") == 0)
|
2017-01-31 12:17:58 -08:00
|
|
|
{
|
2018-01-26 11:37:00 -08:00
|
|
|
pd->property.icon = EINA_FALSE;
|
|
|
|
eina_stringshare_replace(&pd->property.file, property);
|
2017-01-31 12:17:58 -08:00
|
|
|
}
|
2019-01-31 03:59:19 -08:00
|
|
|
else if (strcmp(key, "icon") == 0)
|
2017-01-31 12:17:58 -08:00
|
|
|
{
|
2018-01-26 11:37:00 -08:00
|
|
|
pd->property.icon = EINA_TRUE;
|
|
|
|
eina_stringshare_replace(&pd->property.file, property);
|
|
|
|
eina_stringshare_replace(&pd->property.key, NULL);
|
2017-01-31 12:17:58 -08:00
|
|
|
}
|
2019-01-31 03:59:19 -08:00
|
|
|
else if (strcmp(key, "key") == 0)
|
2017-01-31 12:17:58 -08:00
|
|
|
{
|
2018-01-26 11:37:00 -08:00
|
|
|
eina_stringshare_replace(&pd->property.key, property);
|
2017-01-31 12:17:58 -08:00
|
|
|
}
|
2019-02-12 10:52:43 -08:00
|
|
|
else
|
|
|
|
{
|
2019-07-10 17:56:20 -07:00
|
|
|
return EFL_PROPERTY_ERROR_INVALID_KEY;
|
2019-02-12 10:52:43 -08:00
|
|
|
}
|
2017-01-31 12:17:58 -08:00
|
|
|
|
|
|
|
_update_viewmodel(obj, pd);
|
2019-02-12 16:47:31 -08:00
|
|
|
|
|
|
|
sk = eina_stringshare_add(key);
|
|
|
|
efl_event_callback_call(obj, EFL_UI_PROPERTY_BIND_EVENT_PROPERTY_BOUND, (void*) sk);
|
|
|
|
eina_stringshare_del(sk);
|
|
|
|
|
2019-02-12 11:55:03 -08:00
|
|
|
return 0;
|
2017-01-31 12:17:58 -08:00
|
|
|
}
|
|
|
|
|
2016-03-03 03:27:23 -08:00
|
|
|
EAPI void
|
|
|
|
elm_image_smooth_set(Evas_Object *obj, Eina_Bool smooth)
|
|
|
|
{
|
2016-10-31 20:01:42 -07:00
|
|
|
EINA_SAFETY_ON_FALSE_RETURN(efl_isa(obj, MY_CLASS));
|
2018-04-19 04:26:59 -07:00
|
|
|
efl_gfx_image_smooth_scale_set(obj, smooth);
|
2019-08-21 09:31:35 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2016-03-03 03:27:23 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_image_smooth_get(const Evas_Object *obj)
|
|
|
|
{
|
2016-10-31 20:01:42 -07:00
|
|
|
EINA_SAFETY_ON_FALSE_RETURN_VAL(efl_isa(obj, MY_CLASS), EINA_FALSE);
|
2018-04-19 04:26:59 -07:00
|
|
|
return efl_gfx_image_smooth_scale_get(obj);
|
2016-03-03 03:27:23 -08:00
|
|
|
}
|
2014-05-27 00:23:13 -07:00
|
|
|
|
|
|
|
// A11Y - END
|
|
|
|
|
2016-03-18 18:30:19 -07:00
|
|
|
/* Legacy deprecated functions */
|
|
|
|
EAPI void
|
|
|
|
elm_image_editable_set(Evas_Object *obj, Eina_Bool edit)
|
|
|
|
{
|
2016-06-10 01:42:03 -07:00
|
|
|
efl_ui_draggable_drag_target_set(obj, edit);
|
2016-03-18 18:30:19 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_image_editable_get(const Evas_Object *obj)
|
|
|
|
{
|
2016-06-10 01:42:03 -07:00
|
|
|
return efl_ui_draggable_drag_target_get(obj);
|
2016-03-18 18:30:19 -07:00
|
|
|
}
|
|
|
|
|
2016-03-22 07:14:04 -07:00
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_image_file_set(Evas_Object *obj, const char *file, const char *group)
|
|
|
|
{
|
|
|
|
Eina_Bool ret = EINA_FALSE;
|
|
|
|
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_CHECK(obj) EINA_FALSE;
|
elm_image: keep backword compatibility for elm_image_file_set API when setting url file set twice
Summary:
when trying to set file using url path twice, the second api call's return value is EINA_FALSE
since image obj has already has same file path. After applying Efl.File interface, the behavior is changed compared to before.
both of the return values should be EINA_TRUE.
@fix
ex)
Eina_Bool ret1, ret2;
ret1 = elm_image_file_set(image, "http://sameurl/image.jpg", NULL);
ret2 = elm_image_file_set(image, "http://sameurl/image.jpg", NULL);
ret1 and ret2 should be EINA_TURE
Test Plan:
1. call elm_image_file_set api with same url path
2. see the return value
Reviewers: Hermet, kimcinoo, jsuya
Reviewed By: Hermet
Subscribers: bu5hm4n, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D11979
2020-06-17 05:04:08 -07:00
|
|
|
|
|
|
|
/* check if previous path is same with new one.
|
|
|
|
and return true if they are same */
|
|
|
|
const char *cur_file_path = efl_file_get(obj);
|
|
|
|
if ((cur_file_path && file) && !strcmp(cur_file_path, file))
|
|
|
|
{
|
|
|
|
const char *cur_group = efl_file_key_get(obj);
|
|
|
|
if (!(cur_group && group && strcmp(cur_group, group)))
|
2020-06-17 05:17:23 -07:00
|
|
|
{
|
|
|
|
if (efl_file_loaded_get(obj)) return EINA_TRUE;
|
|
|
|
if (_efl_ui_image_is_remote(file)) return EINA_TRUE;
|
|
|
|
}
|
elm_image: keep backword compatibility for elm_image_file_set API when setting url file set twice
Summary:
when trying to set file using url path twice, the second api call's return value is EINA_FALSE
since image obj has already has same file path. After applying Efl.File interface, the behavior is changed compared to before.
both of the return values should be EINA_TRUE.
@fix
ex)
Eina_Bool ret1, ret2;
ret1 = elm_image_file_set(image, "http://sameurl/image.jpg", NULL);
ret2 = elm_image_file_set(image, "http://sameurl/image.jpg", NULL);
ret1 and ret2 should be EINA_TURE
Test Plan:
1. call elm_image_file_set api with same url path
2. see the return value
Reviewers: Hermet, kimcinoo, jsuya
Reviewed By: Hermet
Subscribers: bu5hm4n, cedric, #reviewers, #committers
Tags: #efl
Differential Revision: https://phab.enlightenment.org/D11979
2020-06-17 05:04:08 -07:00
|
|
|
}
|
|
|
|
|
2019-02-27 10:17:09 -08:00
|
|
|
ret = efl_file_simple_load(obj, file, group);
|
2019-08-21 09:31:35 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2016-03-22 07:14:04 -07:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_image_file_get(const Eo *obj, const char **file, const char **group)
|
|
|
|
{
|
2020-02-24 19:17:12 -08:00
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
|
|
|
efl_file_simple_get(sd->img, file, group);
|
2016-03-22 07:14:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_image_mmap_set(Evas_Object *obj, const Eina_File *file, const char *group)
|
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_CHECK(obj) EINA_FALSE;
|
2019-02-27 10:17:09 -08:00
|
|
|
return efl_file_simple_mmap_load(obj, file, group);
|
2016-03-22 07:14:04 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_image_memfile_set(Evas_Object *obj, const void *img, size_t size, const char *format, const char *key)
|
|
|
|
{
|
2018-05-04 03:55:59 -07:00
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(img, EINA_FALSE);
|
2018-05-03 04:36:16 -07:00
|
|
|
|
2016-03-22 07:14:04 -07:00
|
|
|
Evas_Load_Error err;
|
|
|
|
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_CHECK(obj) EINA_FALSE;
|
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
2016-03-22 07:14:04 -07:00
|
|
|
|
2020-04-27 03:29:47 -07:00
|
|
|
if (efl_file_loaded_get(obj))
|
|
|
|
efl_file_unload(obj);
|
|
|
|
else
|
|
|
|
_efl_ui_image_file_set_do(obj);
|
2016-03-22 07:14:04 -07:00
|
|
|
|
|
|
|
evas_object_image_memfile_set
|
|
|
|
(sd->img, (void *)img, size, (char *)format, (char *)key);
|
|
|
|
|
2017-04-20 02:29:26 -07:00
|
|
|
if (sd->preload_status == EFL_UI_IMAGE_PRELOAD_DISABLED)
|
2020-02-10 08:05:35 -08:00
|
|
|
{
|
|
|
|
_prev_img_del(sd);
|
|
|
|
if (sd->autoplay) efl_player_playing_set(sd->self, EINA_TRUE);
|
|
|
|
}
|
2017-04-20 02:29:26 -07:00
|
|
|
else
|
|
|
|
{
|
|
|
|
sd->preload_status = EFL_UI_IMAGE_PRELOADING;
|
|
|
|
evas_object_image_preload(sd->img, EINA_FALSE);
|
|
|
|
}
|
2016-03-22 07:14:04 -07:00
|
|
|
|
|
|
|
err = evas_object_image_load_error_get(sd->img);
|
|
|
|
if (err != EVAS_LOAD_ERROR_NONE)
|
|
|
|
{
|
|
|
|
if (img)
|
|
|
|
ERR("Failed to load image from memory block (" FMT_SIZE_T
|
|
|
|
" bytes): %s (%p)", size, evas_load_error_str(err), sd->img);
|
|
|
|
else
|
|
|
|
ERR("NULL image data passed (%p)", sd->img);
|
2017-05-31 03:01:03 -07:00
|
|
|
|
|
|
|
_prev_img_del(sd);
|
2016-03-22 07:14:04 -07:00
|
|
|
return EINA_FALSE;
|
|
|
|
}
|
|
|
|
|
2019-08-21 09:31:35 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2016-03-22 07:14:04 -07:00
|
|
|
|
|
|
|
return EINA_TRUE;
|
|
|
|
}
|
|
|
|
|
2016-03-31 22:44:21 -07:00
|
|
|
EAPI void
|
|
|
|
elm_image_fill_outside_set(Evas_Object *obj, Eina_Bool fill_outside)
|
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_CHECK(obj);
|
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
2016-05-11 21:25:13 -07:00
|
|
|
fill_outside = !!fill_outside;
|
|
|
|
|
|
|
|
if (sd->fill_inside == !fill_outside) return;
|
2016-03-31 22:44:21 -07:00
|
|
|
|
|
|
|
sd->fill_inside = !fill_outside;
|
|
|
|
|
2016-05-11 21:25:13 -07:00
|
|
|
if (sd->aspect_fixed)
|
|
|
|
{
|
2019-09-16 02:06:02 -07:00
|
|
|
if (sd->fill_inside) sd->scale_type = EFL_GFX_IMAGE_SCALE_METHOD_FIT;
|
|
|
|
else sd->scale_type = EFL_GFX_IMAGE_SCALE_METHOD_EXPAND;
|
2016-05-11 21:25:13 -07:00
|
|
|
}
|
|
|
|
else
|
2019-09-16 02:06:02 -07:00
|
|
|
sd->scale_type = EFL_GFX_IMAGE_SCALE_METHOD_FILL;
|
2016-05-11 21:25:13 -07:00
|
|
|
|
2019-08-21 09:31:35 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2016-03-31 22:44:21 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_image_fill_outside_get(const Evas_Object *obj)
|
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_CHECK(obj) EINA_FALSE;
|
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
2016-03-31 22:44:21 -07:00
|
|
|
|
|
|
|
return !sd->fill_inside;
|
|
|
|
}
|
|
|
|
|
2016-03-31 23:06:55 -07:00
|
|
|
// TODO: merge preload and async code
|
|
|
|
EAPI void
|
|
|
|
elm_image_preload_disabled_set(Evas_Object *obj, Eina_Bool disable)
|
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_CHECK(obj);
|
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
2016-03-31 23:06:55 -07:00
|
|
|
|
2020-06-12 00:14:56 -07:00
|
|
|
if (sd->edje) return;
|
|
|
|
if (!sd->img)
|
|
|
|
{
|
|
|
|
if (disable) sd->preload_status = EFL_UI_IMAGE_PRELOAD_DISABLED;
|
2020-06-12 00:33:21 -07:00
|
|
|
else sd->preload_status = EFL_UI_IMAGE_PRELOAD_ENABLED;
|
2020-06-12 00:14:56 -07:00
|
|
|
return;
|
|
|
|
}
|
2016-03-31 23:06:55 -07:00
|
|
|
|
|
|
|
if (disable)
|
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
if (sd->preload_status == EFL_UI_IMAGE_PRELOADING)
|
2016-03-31 23:06:55 -07:00
|
|
|
{
|
|
|
|
evas_object_image_preload(sd->img, disable);
|
|
|
|
if (sd->show) evas_object_show(sd->img);
|
2016-11-21 01:52:27 -08:00
|
|
|
_prev_img_del(sd);
|
2016-03-31 23:06:55 -07:00
|
|
|
}
|
2016-05-31 03:38:21 -07:00
|
|
|
sd->preload_status = EFL_UI_IMAGE_PRELOAD_DISABLED;
|
2016-03-31 23:06:55 -07:00
|
|
|
}
|
2016-05-31 03:38:21 -07:00
|
|
|
else if (sd->preload_status == EFL_UI_IMAGE_PRELOAD_DISABLED)
|
2016-03-31 23:06:55 -07:00
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
sd->preload_status = EFL_UI_IMAGE_PRELOADING;
|
2016-03-31 23:06:55 -07:00
|
|
|
evas_object_image_preload(sd->img, disable);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-31 23:12:01 -07:00
|
|
|
EAPI void
|
2019-05-20 08:51:56 -07:00
|
|
|
elm_image_orient_set(Evas_Object *obj, Elm_Image_Orient elm_orient)
|
|
|
|
{
|
2019-05-22 11:16:16 -07:00
|
|
|
// This array takes an Elm_Image_Orient and turns it into an Efl_Gfx_Image_Orientation
|
|
|
|
static const Efl_Gfx_Image_Orientation efl_orient[8] = {
|
|
|
|
EFL_GFX_IMAGE_ORIENTATION_NONE,
|
|
|
|
EFL_GFX_IMAGE_ORIENTATION_RIGHT,
|
|
|
|
EFL_GFX_IMAGE_ORIENTATION_DOWN,
|
|
|
|
EFL_GFX_IMAGE_ORIENTATION_LEFT,
|
|
|
|
EFL_GFX_IMAGE_ORIENTATION_FLIP_HORIZONTAL,
|
|
|
|
EFL_GFX_IMAGE_ORIENTATION_FLIP_VERTICAL,
|
|
|
|
EFL_GFX_IMAGE_ORIENTATION_LEFT | EFL_GFX_IMAGE_ORIENTATION_FLIP_VERTICAL,
|
|
|
|
EFL_GFX_IMAGE_ORIENTATION_RIGHT | EFL_GFX_IMAGE_ORIENTATION_FLIP_VERTICAL
|
2019-05-20 08:51:56 -07:00
|
|
|
};
|
2016-04-05 18:46:04 -07:00
|
|
|
|
2018-01-30 04:21:35 -08:00
|
|
|
EFL_UI_IMAGE_CHECK(obj);
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
2019-05-20 08:51:56 -07:00
|
|
|
EINA_SAFETY_ON_FALSE_RETURN(elm_orient >= 0 && elm_orient < 8);
|
|
|
|
sd->image_orient = elm_orient;
|
2019-05-22 11:16:16 -07:00
|
|
|
efl_gfx_image_orientation_set(obj, efl_orient[elm_orient]);
|
2020-08-27 22:54:11 -07:00
|
|
|
|
|
|
|
// to keep behavior compatibility, update inlined image orientation
|
|
|
|
if (sd->img) efl_gfx_image_orientation_set(sd->img, efl_orient[elm_orient]);
|
2016-03-31 23:12:01 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Elm_Image_Orient
|
|
|
|
elm_image_orient_get(const Evas_Object *obj)
|
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_CHECK(obj) ELM_IMAGE_ORIENT_NONE;
|
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
2016-04-05 18:46:04 -07:00
|
|
|
|
|
|
|
return sd->image_orient;
|
2016-03-31 23:12:01 -07:00
|
|
|
}
|
|
|
|
|
2016-04-01 01:49:14 -07:00
|
|
|
EAPI Evas_Object*
|
|
|
|
elm_image_object_get(const Evas_Object *obj)
|
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_CHECK(obj) NULL;
|
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
2018-08-16 07:01:37 -07:00
|
|
|
if (!sd->img)
|
|
|
|
sd->img = _img_new((Evas_Object *)obj);
|
|
|
|
|
2016-04-01 01:49:14 -07:00
|
|
|
return sd->img;
|
|
|
|
}
|
2016-03-31 23:12:01 -07:00
|
|
|
|
2016-04-01 01:49:14 -07:00
|
|
|
EAPI void
|
|
|
|
elm_image_object_size_get(const Evas_Object *obj, int *w, int *h)
|
|
|
|
{
|
2017-09-18 04:16:33 -07:00
|
|
|
Eina_Size2D sz;
|
|
|
|
sz = efl_gfx_view_size_get(obj);
|
|
|
|
if (w) *w = sz.w;
|
|
|
|
if (h) *h = sz.h;
|
2016-04-01 01:49:14 -07:00
|
|
|
}
|
2016-03-31 23:12:01 -07:00
|
|
|
|
2016-04-11 04:33:25 -07:00
|
|
|
EAPI void
|
|
|
|
elm_image_no_scale_set(Evas_Object *obj, Eina_Bool no_scale)
|
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_CHECK(obj);
|
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
2016-04-11 04:33:25 -07:00
|
|
|
sd->no_scale = no_scale;
|
|
|
|
|
2019-08-21 09:31:35 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2016-04-11 04:33:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_image_no_scale_get(const Evas_Object *obj)
|
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_CHECK(obj) EINA_FALSE;
|
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
2016-04-11 04:33:25 -07:00
|
|
|
return sd->no_scale;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_image_resizable_set(Evas_Object *obj, Eina_Bool up, Eina_Bool down)
|
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_CHECK(obj);
|
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
2016-05-11 21:25:13 -07:00
|
|
|
sd->scale_up = !!up;
|
|
|
|
sd->scale_down = !!down;
|
2016-04-11 04:33:25 -07:00
|
|
|
|
2019-08-21 09:31:35 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2016-04-11 04:33:25 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI void
|
|
|
|
elm_image_resizable_get(const Evas_Object *obj, Eina_Bool *size_up, Eina_Bool *size_down)
|
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_CHECK(obj);
|
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
2016-05-11 21:25:13 -07:00
|
|
|
if (size_up) *size_up = sd->scale_up;
|
|
|
|
if (size_down) *size_down = sd->scale_down;
|
2016-04-11 04:33:25 -07:00
|
|
|
}
|
|
|
|
|
2016-04-28 19:50:59 -07:00
|
|
|
EAPI void
|
|
|
|
elm_image_aspect_fixed_set(Evas_Object *obj, Eina_Bool fixed)
|
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_CHECK(obj);
|
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
2016-04-28 19:50:59 -07:00
|
|
|
fixed = !!fixed;
|
|
|
|
if (sd->aspect_fixed == fixed) return;
|
|
|
|
|
|
|
|
sd->aspect_fixed = fixed;
|
|
|
|
|
2016-05-11 21:25:13 -07:00
|
|
|
if (sd->aspect_fixed)
|
|
|
|
{
|
2019-09-16 02:06:02 -07:00
|
|
|
if (sd->fill_inside) sd->scale_type = EFL_GFX_IMAGE_SCALE_METHOD_FIT;
|
|
|
|
else sd->scale_type = EFL_GFX_IMAGE_SCALE_METHOD_EXPAND;
|
2016-05-11 21:25:13 -07:00
|
|
|
}
|
|
|
|
else
|
2019-09-16 02:06:02 -07:00
|
|
|
sd->scale_type = EFL_GFX_IMAGE_SCALE_METHOD_FILL;
|
2016-05-11 21:25:13 -07:00
|
|
|
|
2019-08-21 09:31:35 -07:00
|
|
|
efl_canvas_group_change(obj);
|
2016-04-28 19:50:59 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Eina_Bool
|
|
|
|
elm_image_aspect_fixed_get(const Evas_Object *obj)
|
|
|
|
{
|
2016-05-31 03:38:21 -07:00
|
|
|
EFL_UI_IMAGE_CHECK(obj) EINA_FALSE;
|
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, sd);
|
2016-04-28 19:50:59 -07:00
|
|
|
return sd->aspect_fixed;
|
|
|
|
}
|
|
|
|
|
2017-08-16 23:08:00 -07:00
|
|
|
/* Standard widget overrides */
|
|
|
|
|
|
|
|
ELM_WIDGET_KEY_DOWN_DEFAULT_IMPLEMENT(efl_ui_image, Efl_Ui_Image_Data)
|
|
|
|
|
2017-05-18 01:52:17 -07:00
|
|
|
/* Internal EO APIs and hidden overrides */
|
|
|
|
|
|
|
|
#define EFL_UI_IMAGE_EXTRA_OPS \
|
2019-08-21 09:31:35 -07:00
|
|
|
EFL_CANVAS_GROUP_ADD_DEL_OPS(efl_ui_image), \
|
|
|
|
EFL_CANVAS_GROUP_CALC_OPS(efl_ui_image)
|
2017-05-18 01:52:17 -07:00
|
|
|
|
2016-05-31 03:38:21 -07:00
|
|
|
#include "efl_ui_image.eo.c"
|
2018-01-23 22:50:58 -08:00
|
|
|
|
2019-03-05 14:00:37 -08:00
|
|
|
#include "efl_ui_image_legacy_eo.h"
|
2018-01-23 22:50:58 -08:00
|
|
|
|
|
|
|
#define MY_CLASS_NAME_LEGACY "elm_image"
|
|
|
|
|
|
|
|
static void
|
|
|
|
_efl_ui_image_legacy_class_constructor(Efl_Class *klass)
|
|
|
|
{
|
|
|
|
evas_smart_legacy_type_register(MY_CLASS_NAME_LEGACY, klass);
|
|
|
|
}
|
|
|
|
|
|
|
|
EOLIAN static Eo *
|
|
|
|
_efl_ui_image_legacy_efl_object_constructor(Eo *obj, void *pd EINA_UNUSED)
|
|
|
|
{
|
|
|
|
obj = efl_constructor(efl_super(obj, EFL_UI_IMAGE_LEGACY_CLASS));
|
|
|
|
efl_canvas_object_type_set(obj, MY_CLASS_NAME_LEGACY);
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
|
|
|
EAPI Evas_Object *
|
|
|
|
elm_image_add(Evas_Object *parent)
|
|
|
|
{
|
|
|
|
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
|
|
|
Evas_Object *obj = elm_legacy_add(EFL_UI_IMAGE_LEGACY_CLASS, parent);
|
|
|
|
EFL_UI_IMAGE_DATA_GET(obj, priv);
|
|
|
|
|
2019-02-21 09:46:36 -08:00
|
|
|
efl_event_callback_add(obj, EFL_GFX_ENTITY_EVENT_HINTS_CHANGED, _on_size_hints_changed, priv);
|
2018-01-23 22:50:58 -08:00
|
|
|
|
|
|
|
return obj;
|
|
|
|
}
|
|
|
|
|
2019-03-05 14:00:37 -08:00
|
|
|
#include "efl_ui_image_legacy_eo.c"
|