Ephoto: Use evas_object_image rather than elm_image to avoid casting. Add config option to turn off smooth scaling.

This commit is contained in:
Stephen okra Houston 2016-08-04 16:36:58 -05:00
parent 9f28098156
commit 1c01b4f315
11 changed files with 104 additions and 60 deletions

View File

@ -225,6 +225,7 @@ struct _Ephoto_Config
Eina_Bool prompts;
Eina_Bool drop;
Eina_Bool movess;
Eina_Bool smooth;
Eina_Bool firstrun;
Evas_Object *slide_time;
Evas_Object *slide_trans;
@ -232,6 +233,7 @@ struct _Ephoto_Config
Evas_Object *open_dir_custom;
Evas_Object *show_prompts;
Evas_Object *move_drop;
Evas_Object *smooth_scale;
Evas_Object *slide_move;
};

View File

@ -275,9 +275,9 @@ _bcg_apply(void *data, int type EINA_UNUSED,
Evas_Coord w, h;
image_data =
evas_object_image_data_get(elm_image_object_get(ebcg->image),
evas_object_image_data_get(ebcg->image,
EINA_FALSE);
evas_object_image_size_get(elm_image_object_get(ebcg->image), &w, &h);
evas_object_image_size_get(ebcg->image, &w, &h);
ephoto_single_browser_image_data_done(ebcg->main, image_data, w, h);
ephoto_editor_del(ebcg->editor);
@ -335,9 +335,9 @@ ephoto_bcg_add(Ephoto *ephoto, Evas_Object *main, Evas_Object *parent, Evas_Obje
ebcg->parent = parent;
ebcg->image = image;
im_data =
evas_object_image_data_get(elm_image_object_get(ebcg->image),
evas_object_image_data_get(ebcg->image,
EINA_FALSE);
evas_object_image_size_get(elm_image_object_get(ebcg->image), &ebcg->w,
evas_object_image_size_get(ebcg->image, &ebcg->w,
&ebcg->h);
ebcg->original_im_data = malloc(sizeof(unsigned int) * ebcg->w * ebcg->h);
memcpy(ebcg->original_im_data, im_data,

View File

@ -260,9 +260,9 @@ _color_apply(void *data, int type EINA_UNUSED,
Evas_Coord w, h;
image_data =
evas_object_image_data_get(elm_image_object_get(eco->image),
evas_object_image_data_get(eco->image,
EINA_FALSE);
evas_object_image_size_get(elm_image_object_get(eco->image), &w, &h);
evas_object_image_size_get(eco->image, &w, &h);
ephoto_single_browser_image_data_done(eco->main, image_data, w, h);
ephoto_editor_del(eco->editor);
@ -320,9 +320,9 @@ ephoto_color_add(Ephoto *ephoto, Evas_Object *main, Evas_Object *parent, Evas_Ob
eco->parent = parent;
eco->image = image;
im_data =
evas_object_image_data_get(elm_image_object_get(eco->image),
evas_object_image_data_get(eco->image,
EINA_FALSE);
evas_object_image_size_get(elm_image_object_get(eco->image), &eco->w,
evas_object_image_size_get(eco->image, &eco->w,
&eco->h);
eco->original_im_data = malloc(sizeof(unsigned int) * eco->w * eco->h);
memcpy(eco->original_im_data, im_data,

View File

@ -1,6 +1,6 @@
#include "ephoto.h"
#define CONFIG_VERSION 18
#define CONFIG_VERSION 19
static int _ephoto_config_load(Ephoto *ephoto);
static Eina_Bool _ephoto_on_config_save(void *data);
@ -50,6 +50,7 @@ _config_save_cb(void *data, Evas_Object *obj EINA_UNUSED,
ephoto->config->prompts = elm_check_state_get(ephoto->config->show_prompts);
ephoto->config->drop = elm_check_state_get(ephoto->config->move_drop);
ephoto->config->movess = elm_check_state_get(ephoto->config->slide_move);
ephoto->config->smooth = elm_check_state_get(ephoto->config->smooth_scale);
if (elm_spinner_value_get(ephoto->config->slide_time) > 0)
ephoto->config->slideshow_timeout =
elm_spinner_value_get(ephoto->config->slide_time);
@ -108,6 +109,14 @@ _config_general(Ephoto *ephoto, Evas_Object *parent)
evas_object_show(check);
ephoto->config->move_drop = check;
check = elm_check_add(table);
elm_object_text_set(check, _("Smooth Scale Images"));
evas_object_size_hint_align_set(check, 0.0, EVAS_HINT_FILL);
elm_check_state_set(check, ephoto->config->smooth);
elm_table_pack(table, check, 0, 3, 1, 1);
evas_object_show(check);
ephoto->config->smooth_scale = check;
hoversel = elm_hoversel_add(table);
elm_hoversel_hover_parent_set(hoversel, ephoto->win);
elm_hoversel_item_add(hoversel, _("Root Directory"), NULL, 0,
@ -123,7 +132,7 @@ _config_general(Ephoto *ephoto, Evas_Object *parent)
evas_object_size_hint_weight_set(hoversel, EVAS_HINT_EXPAND,
EVAS_HINT_FILL);
evas_object_size_hint_align_set(hoversel, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_table_pack(table, hoversel, 0, 3, 1, 1);
elm_table_pack(table, hoversel, 0, 4, 1, 1);
evas_object_show(hoversel);
ephoto->config->open_dir = hoversel;
@ -136,7 +145,7 @@ _config_general(Ephoto *ephoto, Evas_Object *parent)
ELM_SCROLLER_POLICY_OFF);
evas_object_size_hint_weight_set(entry, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(entry, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_table_pack(table, entry, 0, 4, 1, 1);
elm_table_pack(table, entry, 0, 5, 1, 1);
evas_object_show(entry);
ephoto->config->open_dir_custom = entry;
}
@ -797,6 +806,7 @@ ephoto_config_init(Ephoto *ephoto)
ephoto->config->prompts = 1;
ephoto->config->drop = 0;
ephoto->config->movess = 1;
ephoto->config->smooth = 1;
ephoto->config->firstrun = 1;
break;

View File

@ -34,7 +34,7 @@ _calculate_cropper_size(void *data, Evas_Object *obj EINA_UNUSED,
"ephoto.swallow.image", 0, 0, &w, &h);
edje_object_part_geometry_get(elm_layout_edje_get(ec->layout),
"ephoto.swallow.cropper", 0, 0, &cw, &ch);
evas_object_image_size_get(elm_image_object_get(ec->image), &iw, &ih);
evas_object_image_size_get(ec->image, &iw, &ih);
scalew = (double) cw / (double) w;
scaleh = (double) ch / (double) h;
@ -69,8 +69,7 @@ _cropper_changed_width(void *data, Evas_Object *obj EINA_UNUSED,
"ephoto.swallow.image", &lx, 0, &lw, 0);
edje_object_part_geometry_get(elm_layout_edje_get(ec->layout),
"ephoto.swallow.cropper", &cx, 0, &cw, 0);
evas_object_image_size_get(elm_image_object_get(ec->image), &iw, 0);
evas_object_image_size_get(ec->image, &iw, 0);
scalew = (double) mw / (double) iw;
nw = lw * scalew;
@ -121,7 +120,7 @@ _cropper_changed_height(void *data, Evas_Object *obj EINA_UNUSED,
"ephoto.swallow.image", 0, &ly, 0, &lh);
edje_object_part_geometry_get(elm_layout_edje_get(ec->layout),
"ephoto.swallow.cropper", 0, &cy, 0, &ch);
evas_object_image_size_get(elm_image_object_get(ec->image), 0, &ih);
evas_object_image_size_get(ec->image, 0, &ih);
scaleh = (double) mh / (double) ih;
nh = lh * scaleh;
@ -188,10 +187,10 @@ _apply_crop(void *data, Evas_Object *obj EINA_UNUSED,
edje_object_part_geometry_get(edje, "ephoto.swallow.image", &x, &y, &w, &h);
edje_object_part_geometry_get(edje, "ephoto.swallow.cropper", &cx, &cy, &cw,
&ch);
evas_object_image_size_get(elm_image_object_get(ec->image), &iw, &ih);
evas_object_image_size_get(ec->image, &iw, &ih);
idata =
evas_object_image_data_get(elm_image_object_get(ec->image), EINA_FALSE);
evas_object_image_data_get(ec->image, EINA_FALSE);
scalex = (double) (cx-x) / (double) w;
scaley = (double) (cy-y) / (double) h;
@ -535,7 +534,7 @@ _image_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
Evas_Coord sx, sy, sw, sh, ix, iy, iw, ih, diffw, diffh;
evas_object_geometry_get(ec->layout, &sx, &sy, &sw, &sh);
evas_object_image_size_get(elm_image_object_get(ec->image), &iw, &ih);
evas_object_image_size_get(ec->image, &iw, &ih);
Evas_Coord nw, nh;
@ -644,7 +643,7 @@ ephoto_cropper_add(Ephoto *ephoto, Evas_Object *main, Evas_Object *parent,
ec->image_parent = image_parent;
ec->image = image;
evas_object_image_size_get(elm_image_object_get(image), &w, &h);
evas_object_image_size_get(image, &w, &h);
ec->box = elm_box_add(image_parent);
elm_box_homogeneous_set(ec->box, EINA_TRUE);

View File

@ -115,7 +115,7 @@ _save_image_as_overwrite(void *data, Evas_Object *obj EINA_UNUSED,
}
ephoto_single_browser_path_pending_set(ephoto->single_browser, file);
success =
evas_object_image_save(elm_image_object_get(image), file,
evas_object_image_save(image, file,
NULL, NULL);
if (!success)
{
@ -1005,7 +1005,7 @@ _prompt_save_image_apply(void *data, Evas_Object *obj EINA_UNUSED,
}
}
success =
evas_object_image_save(elm_image_object_get(image), entry->path,
evas_object_image_save(image, entry->path,
NULL, NULL);
if (!success)
_complete(ephoto, _("Save Failed"),
@ -1097,7 +1097,7 @@ _prompt_save_image_as_apply(void *data, Evas_Object *obj EINA_UNUSED, void *even
ephoto_single_browser_path_pending_set
(ephoto->single_browser, buf);
success =
evas_object_image_save(elm_image_object_get(image), buf,
evas_object_image_save(image, buf,
NULL, NULL);
if (!success)
{

View File

@ -63,8 +63,8 @@ _initialize_filter(Ephoto_Image_Filter filter,
unsigned int *im_data;
im_data =
evas_object_image_data_get(elm_image_object_get(image), EINA_FALSE);
evas_object_image_size_get(elm_image_object_get(image), &w, &h);
evas_object_image_data_get(image, EINA_FALSE);
evas_object_image_size_get(image, &w, &h);
ef->filter = filter;
ef->main = main;

View File

@ -282,9 +282,9 @@ _hsv_apply(void *data, int type EINA_UNUSED,
Evas_Coord w, h;
image_data =
evas_object_image_data_get(elm_image_object_get(ehsv->image),
evas_object_image_data_get(ehsv->image,
EINA_FALSE);
evas_object_image_size_get(elm_image_object_get(ehsv->image), &w, &h);
evas_object_image_size_get(ehsv->image, &w, &h);
ephoto_single_browser_image_data_done(ehsv->main, image_data, w, h);
ephoto_editor_del(ehsv->editor);
@ -342,9 +342,9 @@ ephoto_hsv_add(Ephoto *ephoto, Evas_Object *main, Evas_Object *parent, Evas_Obje
ehsv->parent = parent;
ehsv->image = image;
im_data =
evas_object_image_data_get(elm_image_object_get(ehsv->image),
evas_object_image_data_get(ehsv->image,
EINA_FALSE);
evas_object_image_size_get(elm_image_object_get(ehsv->image), &ehsv->w,
evas_object_image_size_get(ehsv->image, &ehsv->w,
&ehsv->h);
ehsv->original_im_data = malloc(sizeof(unsigned int) * ehsv->w * ehsv->h);
memcpy(ehsv->original_im_data, im_data,

View File

@ -151,9 +151,9 @@ _reye_apply(void *data, int type EINA_UNUSED,
Evas_Coord w, h;
image_data =
evas_object_image_data_get(elm_image_object_get(er->image),
evas_object_image_data_get(er->image,
EINA_FALSE);
evas_object_image_size_get(elm_image_object_get(er->image), &w, &h);
evas_object_image_size_get(er->image, &w, &h);
ephoto_single_browser_image_data_done(er->main, image_data, w, h);
ephoto_editor_del(er->editor);
@ -211,9 +211,9 @@ ephoto_red_eye_add(Ephoto *ephoto, Evas_Object *main, Evas_Object *parent, Evas_
er->parent = parent;
er->image = image;
im_data =
evas_object_image_data_get(elm_image_object_get(er->image),
evas_object_image_data_get(er->image,
EINA_FALSE);
evas_object_image_size_get(elm_image_object_get(er->image), &er->w,
evas_object_image_size_get(er->image, &er->w,
&er->h);
er->original_im_data = malloc(sizeof(unsigned int) * er->w * er->h);
memcpy(er->original_im_data, im_data,

View File

@ -107,7 +107,7 @@ _es_apply(void *data, int type EINA_UNUSED,
w = round(elm_spinner_value_get(es->scalew));
h = round(elm_spinner_value_get(es->scaleh));
evas_object_image_file_get(elm_image_object_get(es->image),
evas_object_image_file_get(es->image,
NULL, &key);
ee = ecore_evas_buffer_new(1, 1);
@ -192,13 +192,13 @@ ephoto_scale_add(Ephoto *ephoto, Evas_Object *main, Evas_Object *parent,
es->tmp_file = eina_stringshare_add(buf);
if (ecore_file_exists(es->tmp_file))
ecore_file_unlink(es->tmp_file);
evas_object_image_save(elm_image_object_get(es->image), es->tmp_file,
evas_object_image_save(es->image, es->tmp_file,
NULL, NULL);
im_data =
evas_object_image_data_get(elm_image_object_get(es->image),
evas_object_image_data_get(es->image,
EINA_FALSE);
evas_object_image_size_get(elm_image_object_get(es->image), &es->w,
evas_object_image_size_get(es->image, &es->w,
&es->h);
es->original_im_data = malloc(sizeof(unsigned int) * es->w * es->h);
memcpy(es->original_im_data, im_data,

View File

@ -40,6 +40,10 @@ struct _Ephoto_Viewer
double zoom;
Eina_Bool fit:1;
Eina_Bool zoom_first:1;
double duration;
int frame_count;
int cur_frame;
Ecore_Timer *anim_timer;
};
/*Common Callbacks*/
@ -94,7 +98,7 @@ _ephoto_update_bottom_bar(Ephoto_Single_Browser *sb)
if (sb->editing)
return;
evas_object_image_size_get(elm_image_object_get(v->image),
evas_object_image_size_get(v->image,
&w, &h);
tmp = _ephoto_get_file_size(sb->entry->path);
snprintf(image_info, PATH_MAX,
@ -265,6 +269,8 @@ _viewer_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
EINA_LIST_FREE(v->monitor_handlers, handler)
ecore_event_handler_del(handler);
}
if (v->anim_timer)
ecore_timer_del(v->anim_timer);
free(v);
}
@ -312,7 +318,7 @@ _viewer_zoom_apply(Ephoto_Viewer *v, double zoom)
Evas_Object *image;
image = v->image;
evas_object_image_size_get(elm_image_object_get(image), &w, &h);
evas_object_image_size_get(image, &w, &h);
w *= zoom;
h *= zoom;
evas_object_size_hint_min_set(v->image, w, h);
@ -328,7 +334,7 @@ _viewer_zoom_fit_apply(Ephoto_Viewer *v)
image = v->image;
evas_object_geometry_get(v->scroller, NULL, NULL, &cw, &ch);
evas_object_image_size_get(elm_image_object_get(image), &iw, &ih);
evas_object_image_size_get(image, &iw, &ih);
if ((cw <= 0) || (ch <= 0))
return;
@ -355,7 +361,7 @@ _viewer_resized(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
image = v->image;
evas_object_geometry_get(v->scroller, NULL, NULL, &cw, &ch);
evas_object_image_size_get(elm_image_object_get(image), &iw, &ih);
evas_object_image_size_get(image, &iw, &ih);
if ((cw <= 0) || (ch <= 0))
return;
@ -453,9 +459,9 @@ _orient_apply(Ephoto_Single_Browser *sb)
}
elm_table_unpack(v->table, v->image);
elm_object_content_unset(v->scroller);
elm_image_object_size_get(v->image, &w, &h);
evas_object_image_size_get(v->image, &w, &h);
sb->edited_image_data =
evas_object_image_data_get(elm_image_object_get(v->image), EINA_FALSE);
evas_object_image_data_get(v->image, EINA_FALSE);
sb->ew = w;
sb->eh = h;
evas_object_size_hint_min_set(v->image, w, h);
@ -1312,16 +1318,37 @@ _image_changed(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
}
/*Image Viewer Function*/
static Eina_Bool
_animate_cb(void *data)
{
Ephoto_Viewer *v = data;
v->cur_frame++;
if (v->cur_frame > v->frame_count)
v->cur_frame = 1;
evas_object_image_animated_frame_set(v->image, v->cur_frame);
v->duration = evas_object_image_animated_frame_duration_get(v->image,
v->cur_frame, 0);
if (v->duration > 0)
ecore_timer_interval_set(v->anim_timer, v->duration);
return ECORE_CALLBACK_RENEW;
}
static Evas_Object *
_viewer_add(Evas_Object *parent, const char *path, Ephoto_Single_Browser *sb)
{
Ephoto_Viewer *v = calloc(1, sizeof(Ephoto_Viewer));
int err;
v->zoom_first = EINA_TRUE;
Evas_Coord w, h;
const char *group = _ephoto_get_edje_group(path);
v->zoom_first = EINA_TRUE;
v->cur_frame = 0;
v->anim_timer = NULL;
v->duration = 0;
v->frame_count = 0;
v->scroller = elm_scroller_add(parent);
evas_object_size_hint_weight_set(v->scroller, EVAS_HINT_EXPAND,
EVAS_HINT_EXPAND);
@ -1341,13 +1368,15 @@ _viewer_add(Evas_Object *parent, const char *path, Ephoto_Single_Browser *sb)
elm_object_content_set(v->scroller, v->table);
evas_object_show(v->table);
v->image = elm_image_add(v->table);
elm_image_preload_disabled_set(v->image, EINA_TRUE);
elm_image_file_set(v->image, path, group);
err = evas_object_image_load_error_get(elm_image_object_get(v->image));
v->image = evas_object_image_add(evas_object_evas_get(v->table));
evas_object_image_filled_set(v->image, EINA_TRUE);
evas_object_image_smooth_scale_set(v->image, sb->ephoto->config->smooth);
evas_object_image_preload(v->image, EINA_FALSE);
evas_object_image_file_set(v->image, path, group);
err = evas_object_image_load_error_get(v->image);
if (err != EVAS_LOAD_ERROR_NONE)
goto error;
evas_object_image_size_get(elm_image_object_get(v->image), &w, &h);
evas_object_image_size_get(v->image, &w, &h);
elm_drop_target_add(v->image, ELM_SEL_FORMAT_IMAGE, NULL, NULL, NULL, NULL,
NULL, NULL, NULL, NULL);
evas_object_size_hint_min_set(v->image, w, h);
@ -1359,10 +1388,14 @@ _viewer_add(Evas_Object *parent, const char *path, Ephoto_Single_Browser *sb)
evas_object_event_callback_add(v->image, EVAS_CALLBACK_RESIZE, _image_changed, sb);
elm_table_pack(v->table, v->image, 0, 0, 1, 1);
evas_object_show(v->image);
if (elm_image_animated_available_get(v->image))
if (evas_object_image_animated_get(v->image))
{
elm_image_animated_set(v->image, EINA_TRUE);
elm_image_animated_play_set(v->image, EINA_TRUE);
v->frame_count = evas_object_image_animated_frame_count_get(v->image);
v->cur_frame = 1;
evas_object_image_animated_frame_set(v->image, v->cur_frame);
v->duration = evas_object_image_animated_frame_duration_get(v->image,
v->cur_frame, 0);
v->anim_timer = ecore_timer_add(v->duration, _animate_cb, v);
}
@ -1894,8 +1927,8 @@ ephoto_single_browser_image_data_update(Evas_Object *main, Evas_Object *image,
if (sb->editing)
{
evas_object_image_data_set(elm_image_object_get(image), image_data);
evas_object_image_data_update_add(elm_image_object_get(image), 0, 0, w,
evas_object_image_data_set(image, image_data);
evas_object_image_data_update_add(image, 0, 0, w,
h);
}
}
@ -1912,9 +1945,9 @@ ephoto_single_browser_image_data_done(Evas_Object *main,
Ephoto_Viewer *v = evas_object_data_get(sb->viewer, "viewer");
if (sb->cropping)
sb->cropping = EINA_FALSE;
evas_object_image_size_set(elm_image_object_get(v->image), w, h);
evas_object_image_data_set(elm_image_object_get(v->image), image_data);
evas_object_image_data_update_add(elm_image_object_get(v->image), 0, 0, w,
evas_object_image_size_set(v->image, w, h);
evas_object_image_data_set(v->image, image_data);
evas_object_image_data_update_add(v->image, 0, 0, w,
h);
sb->edited_image_data = image_data;
sb->ew = w;
@ -1938,11 +1971,11 @@ ephoto_single_browser_cancel_editing(Evas_Object *main)
sb->cropping = EINA_FALSE;
if (sb->edited_image_data)
{
evas_object_image_size_set(elm_image_object_get(v->image), sb->ew,
evas_object_image_size_set(v->image, sb->ew,
sb->eh);
evas_object_image_data_set(elm_image_object_get(v->image),
evas_object_image_data_set(v->image,
sb->edited_image_data);
evas_object_image_data_update_add(elm_image_object_get(v->image), 0,
evas_object_image_data_update_add(v->image, 0,
0, sb->ew, sb->eh);
}
sb->editing = EINA_FALSE;