Ephoto: Move common editing code to one place.

master
Stephen okra Houston 7 years ago
parent d5b7d24082
commit 4b8ea0492b
  1. 3
      src/bin/Makefile.am
  2. 6
      src/bin/ephoto.h
  3. 144
      src/bin/ephoto_bcg.c
  4. 129
      src/bin/ephoto_color.c
  5. 146
      src/bin/ephoto_cropper.c
  6. 141
      src/bin/ephoto_hsv.c
  7. 6
      src/bin/ephoto_main.c

@ -29,7 +29,8 @@ ephoto_SOURCES = \
ephoto_bcg.c \
ephoto_hsv.c \
ephoto_filters.c \
ephoto_color.c
ephoto_color.c \
ephoto_editor.c
noinst_HEADERS = ephoto.h
EXTRA_DIST = ephoto.h

@ -88,6 +88,9 @@ void ephoto_thumb_browser_update(Ephoto *ephoto, Ephoto_Entry *entry);
/* smart callbacks called: "selected" - an item in the thumb browser is
* selected. The selected Ephoto_Entry is passed as event_info argument. */
Evas_Object *ephoto_editor_add(Evas_Object *parent, const char *title,
const char *data_name, void *data);
void ephoto_editor_del(Evas_Object *obj);
void ephoto_cropper_add(Evas_Object *main, Evas_Object *parent,
Evas_Object *image_parent, Evas_Object *image);
void ephoto_bcg_add(Evas_Object *main, Evas_Object *parent,
@ -284,5 +287,8 @@ extern int EPHOTO_EVENT_ENTRY_CREATE;
extern int EPHOTO_EVENT_POPULATE_START;
extern int EPHOTO_EVENT_POPULATE_END;
extern int EPHOTO_EVENT_POPULATE_ERROR;
extern int EPHOTO_EVENT_EDITOR_RESET;
extern int EPHOTO_EVENT_EDITOR_APPLY;
extern int EPHOTO_EVENT_EDITOR_CANCEL;
#endif

@ -6,10 +6,11 @@ struct _Ephoto_BCG
Evas_Object *main;
Evas_Object *parent;
Evas_Object *image;
Evas_Object *frame;
Evas_Object *editor;
Evas_Object *bslider;
Evas_Object *cslider;
Evas_Object *gslider;
Eina_List *handlers;
int contrast;
int brightness;
double gamma;
@ -248,8 +249,8 @@ _gamma_slider_changed(void *data, Evas_Object *obj,
_ephoto_bcg_adjust_contrast(ebcg, ebcg->contrast, image_data_two);
}
static void
_bcg_reset(void *data, Evas_Object *obj EINA_UNUSED,
static Eina_Bool
_bcg_reset(void *data, int type EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ephoto_BCG *ebcg = data;
@ -261,10 +262,12 @@ _bcg_reset(void *data, Evas_Object *obj EINA_UNUSED,
ebcg->contrast = 0;
ebcg->gamma = 1;
_brightness_slider_changed(ebcg, ebcg->bslider, NULL);
return ECORE_CALLBACK_PASS_ON;
}
static void
_bcg_apply(void *data, Evas_Object *obj EINA_UNUSED,
static Eina_Bool
_bcg_apply(void *data, int type EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ephoto_BCG *ebcg = data;
@ -277,11 +280,13 @@ _bcg_apply(void *data, Evas_Object *obj EINA_UNUSED,
evas_object_image_size_get(elm_image_object_get(ebcg->image), &w, &h);
ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_TRUE,
image_data, w, h);
evas_object_del(ebcg->frame);
ephoto_editor_del(ebcg->editor);
return ECORE_CALLBACK_PASS_ON;
}
static void
_bcg_cancel(void *data, Evas_Object *obj EINA_UNUSED,
static Eina_Bool
_bcg_cancel(void *data, int type EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ephoto_BCG *ebcg = data;
@ -294,15 +299,20 @@ _bcg_cancel(void *data, Evas_Object *obj EINA_UNUSED,
ebcg->gamma = 1;
_brightness_slider_changed(ebcg, ebcg->bslider, NULL);
ephoto_single_browser_cancel_editing(ebcg->main, ebcg->image);
evas_object_del(ebcg->frame);
ephoto_editor_del(ebcg->editor);
return ECORE_CALLBACK_PASS_ON;
}
static void
_frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
_editor_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ephoto_BCG *ebcg = data;
Ecore_Event_Handler *handler;
EINA_LIST_FREE(ebcg->handlers, handler)
ecore_event_handler_del(handler);
free(ebcg->original_im_data);
free(ebcg);
}
@ -310,7 +320,7 @@ _frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void
ephoto_bcg_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
{
Evas_Object *box, *slider, *ic, *button;
Evas_Object *slider;
Ephoto_BCG *ebcg;
unsigned int *im_data;
@ -334,39 +344,26 @@ ephoto_bcg_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
memcpy(ebcg->original_im_data, im_data,
sizeof(unsigned int) * ebcg->w * ebcg->h);
ebcg->frame = elm_frame_add(parent);
elm_object_text_set(ebcg->frame, _("Brightness/Contrast/Gamma"));
evas_object_size_hint_weight_set(ebcg->frame, 0.3, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ebcg->frame,
EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(parent, ebcg->frame);
evas_object_data_set(ebcg->frame, "ebcg", ebcg);
evas_object_event_callback_add(ebcg->frame, EVAS_CALLBACK_DEL, _frame_del,
ebcg->editor = ephoto_editor_add(parent, _("Brightness/Contrast/Gamma"),
"ebcg", ebcg);
evas_object_event_callback_add(ebcg->editor, EVAS_CALLBACK_DEL, _editor_del,
ebcg);
evas_object_show(ebcg->frame);
box = elm_box_add(ebcg->frame);
elm_box_horizontal_set(box, EINA_FALSE);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_content_set(ebcg->frame, box);
evas_object_show(box);
slider = elm_slider_add(box);
elm_object_text_set(slider, _("Brightness"));
elm_slider_min_max_set(slider, -100, 100);
elm_slider_step_set(slider, 1);
elm_slider_value_set(slider, 0);
elm_slider_unit_format_set(slider, "%1.0f");
slider = elm_slider_add(ebcg->editor);
elm_object_text_set(slider, _("Gamma"));
elm_slider_min_max_set(slider, -0.1, 3);
elm_slider_step_set(slider, .1);
elm_slider_value_set(slider, 1);
elm_slider_unit_format_set(slider, "%1.2f");
evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
evas_object_smart_callback_add(slider, "delay,changed",
_brightness_slider_changed, ebcg);
elm_box_pack_end(box, slider);
_gamma_slider_changed, ebcg);
elm_box_pack_start(ebcg->editor, slider);
evas_object_show(slider);
ebcg->bslider = slider;
ebcg->gslider = slider;
slider = elm_slider_add(box);
slider = elm_slider_add(ebcg->editor);
elm_object_text_set(slider, _("Contrast"));
elm_slider_min_max_set(slider, -100, 100);
elm_slider_step_set(slider, 1);
@ -376,65 +373,36 @@ ephoto_bcg_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
evas_object_smart_callback_add(slider, "delay,changed",
_contrast_slider_changed, ebcg);
elm_box_pack_end(box, slider);
elm_box_pack_start(ebcg->editor, slider);
evas_object_show(slider);
ebcg->cslider = slider;
slider = elm_slider_add(box);
elm_object_text_set(slider, _("Gamma"));
elm_slider_min_max_set(slider, 0.1, 3);
elm_slider_step_set(slider, .1);
elm_slider_value_set(slider, 1);
elm_slider_unit_format_set(slider, "%1.2f");
slider = elm_slider_add(ebcg->editor);
elm_object_text_set(slider, _("Brightness"));
elm_slider_min_max_set(slider, -100, 100);
elm_slider_step_set(slider, 1);
elm_slider_value_set(slider, 0);
elm_slider_unit_format_set(slider, "%1.0f");
evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
evas_object_smart_callback_add(slider, "delay,changed",
_gamma_slider_changed, ebcg);
elm_box_pack_end(box, slider);
_brightness_slider_changed, ebcg);
elm_box_pack_start(ebcg->editor, slider);
evas_object_show(slider);
ebcg->gslider = slider;
ebcg->bslider = slider;
ic = elm_icon_add(box);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "edit-undo");
button = elm_button_add(box);
elm_object_text_set(button, _("Reset"));
elm_object_part_content_set(button, "icon", ic);
evas_object_smart_callback_add(button, "clicked", _bcg_reset, ebcg);
evas_object_size_hint_weight_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, button);
evas_object_show(button);
ic = elm_icon_add(box);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "document-save");
button = elm_button_add(box);
elm_object_text_set(button, _("Apply"));
elm_object_part_content_set(button, "icon", ic);
evas_object_smart_callback_add(button, "clicked", _bcg_apply, ebcg);
evas_object_size_hint_weight_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, button);
evas_object_show(button);
ic = elm_icon_add(box);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "window-close");
button = elm_button_add(box);
elm_object_text_set(button, _("Cancel"));
elm_object_part_content_set(button, "icon", ic);
evas_object_smart_callback_add(button, "clicked", _bcg_cancel, ebcg);
evas_object_size_hint_weight_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, button);
evas_object_show(button);
ebcg->handlers =
eina_list_append(ebcg->handlers,
ecore_event_handler_add(EPHOTO_EVENT_EDITOR_RESET,
_bcg_reset, ebcg));
ebcg->handlers =
eina_list_append(ebcg->handlers,
ecore_event_handler_add(EPHOTO_EVENT_EDITOR_APPLY,
_bcg_apply, ebcg));
ebcg->handlers =
eina_list_append(ebcg->handlers,
ecore_event_handler_add(EPHOTO_EVENT_EDITOR_CANCEL,
_bcg_cancel, ebcg));
return;

@ -6,10 +6,11 @@ struct _Ephoto_Color
Evas_Object *main;
Evas_Object *parent;
Evas_Object *image;
Evas_Object *frame;
Evas_Object *editor;
Evas_Object *bslider;
Evas_Object *gslider;
Evas_Object *rslider;
Eina_List *handlers;
int blue;
int green;
int red;
@ -233,8 +234,8 @@ _blue_slider_changed(void *data, Evas_Object *obj,
_ephoto_color_adjust_green(eco, eco->green, image_data_two);
}
static void
_color_reset(void *data, Evas_Object *obj EINA_UNUSED,
static Eina_Bool
_color_reset(void *data, int type EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ephoto_Color *eco = data;
@ -246,10 +247,12 @@ _color_reset(void *data, Evas_Object *obj EINA_UNUSED,
eco->green = 0;
eco->blue = 0;
_red_slider_changed(eco, eco->rslider, NULL);
return ECORE_CALLBACK_PASS_ON;
}
static void
_color_apply(void *data, Evas_Object *obj EINA_UNUSED,
static Eina_Bool
_color_apply(void *data, int type EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ephoto_Color *eco = data;
@ -262,11 +265,13 @@ _color_apply(void *data, Evas_Object *obj EINA_UNUSED,
evas_object_image_size_get(elm_image_object_get(eco->image), &w, &h);
ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_TRUE,
image_data, w, h);
evas_object_del(eco->frame);
ephoto_editor_del(eco->editor);
return ECORE_CALLBACK_PASS_ON;
}
static void
_color_cancel(void *data, Evas_Object *obj EINA_UNUSED,
static Eina_Bool
_color_cancel(void *data, int type EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ephoto_Color *eco = data;
@ -279,15 +284,20 @@ _color_cancel(void *data, Evas_Object *obj EINA_UNUSED,
eco->blue = 0;
_red_slider_changed(eco, eco->rslider, NULL);
ephoto_single_browser_cancel_editing(eco->main, eco->image);
evas_object_del(eco->frame);
ephoto_editor_del(eco->editor);
return ECORE_CALLBACK_PASS_ON;
}
static void
_frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
_editor_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ephoto_Color *eco = data;
Ecore_Event_Handler *handler;
EINA_LIST_FREE(eco->handlers, handler)
ecore_event_handler_del(handler);
free(eco->original_im_data);
free(eco);
}
@ -295,7 +305,7 @@ _frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void
ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
{
Evas_Object *box, *slider, *ic, *button;
Evas_Object *slider;
Ephoto_Color *eco;
unsigned int *im_data;
@ -319,38 +329,26 @@ ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
memcpy(eco->original_im_data, im_data,
sizeof(unsigned int) * eco->w * eco->h);
eco->frame = elm_frame_add(parent);
elm_object_text_set(eco->frame, _("Adjust Color Levels"));
evas_object_size_hint_weight_set(eco->frame, 0.3, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(eco->frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(parent, eco->frame);
evas_object_data_set(eco->frame, "eco", eco);
evas_object_event_callback_add(eco->frame, EVAS_CALLBACK_DEL, _frame_del,
eco->editor = ephoto_editor_add(parent, _("Adjust Color Levels"),
"eco", eco);
evas_object_event_callback_add(eco->editor, EVAS_CALLBACK_DEL, _editor_del,
eco);
evas_object_show(eco->frame);
box = elm_box_add(eco->frame);
elm_box_horizontal_set(box, EINA_FALSE);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_content_set(eco->frame, box);
evas_object_show(box);
slider = elm_slider_add(box);
elm_object_text_set(slider, _("Red"));
slider = elm_slider_add(eco->editor);
elm_object_text_set(slider, _("Blue"));
elm_slider_min_max_set(slider, -100, 100);
elm_slider_step_set(slider, 1);
elm_slider_value_set(slider, 0);
elm_slider_unit_format_set(slider, "%1.0f");
evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
evas_object_smart_callback_add(slider, "delay,changed", _red_slider_changed,
eco);
elm_box_pack_end(box, slider);
evas_object_smart_callback_add(slider, "delay,changed",
_blue_slider_changed, eco);
elm_box_pack_start(eco->editor, slider);
evas_object_show(slider);
eco->rslider = slider;
eco->bslider = slider;
slider = elm_slider_add(box);
slider = elm_slider_add(eco->editor);
elm_object_text_set(slider, _("Green"));
elm_slider_min_max_set(slider, -100, 100);
elm_slider_step_set(slider, 1);
@ -360,12 +358,12 @@ ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
evas_object_smart_callback_add(slider, "delay,changed",
_green_slider_changed, eco);
elm_box_pack_end(box, slider);
elm_box_pack_start(eco->editor, slider);
evas_object_show(slider);
eco->gslider = slider;
slider = elm_slider_add(box);
elm_object_text_set(slider, _("Blue"));
slider = elm_slider_add(eco->editor);
elm_object_text_set(slider, _("Red"));
elm_slider_min_max_set(slider, -100, 100);
elm_slider_step_set(slider, 1);
elm_slider_value_set(slider, 0);
@ -373,52 +371,23 @@ ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
evas_object_smart_callback_add(slider, "delay,changed",
_blue_slider_changed, eco);
elm_box_pack_end(box, slider);
_red_slider_changed, eco);
elm_box_pack_start(eco->editor, slider);
evas_object_show(slider);
eco->bslider = slider;
eco->rslider = slider;
ic = elm_icon_add(box);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "edit-undo");
button = elm_button_add(box);
elm_object_text_set(button, _("Reset"));
elm_object_part_content_set(button, "icon", ic);
evas_object_smart_callback_add(button, "clicked", _color_reset, eco);
evas_object_size_hint_weight_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, button);
evas_object_show(button);
ic = elm_icon_add(box);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "document-save");
button = elm_button_add(box);
elm_object_text_set(button, _("Apply"));
elm_object_part_content_set(button, "icon", ic);
evas_object_smart_callback_add(button, "clicked", _color_apply, eco);
evas_object_size_hint_weight_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, button);
evas_object_show(button);
ic = elm_icon_add(box);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "window-close");
button = elm_button_add(box);
elm_object_text_set(button, _("Cancel"));
elm_object_part_content_set(button, "icon", ic);
evas_object_smart_callback_add(button, "clicked", _color_cancel, eco);
evas_object_size_hint_weight_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, button);
evas_object_show(button);
eco->handlers =
eina_list_append(eco->handlers,
ecore_event_handler_add(EPHOTO_EVENT_EDITOR_RESET,
_color_reset, eco));
eco->handlers =
eina_list_append(eco->handlers,
ecore_event_handler_add(EPHOTO_EVENT_EDITOR_APPLY,
_color_apply, eco));
eco->handlers =
eina_list_append(eco->handlers,
ecore_event_handler_add(EPHOTO_EVENT_EDITOR_CANCEL,
_color_cancel, eco));
return;

@ -7,12 +7,13 @@ struct _Ephoto_Cropper
Evas_Object *parent;
Evas_Object *image_parent;
Evas_Object *box;
Evas_Object *frame;
Evas_Object *editor;
Evas_Object *image;
Evas_Object *cropper;
Evas_Object *layout;
Evas_Object *cropw;
Evas_Object *croph;
Eina_List *handlers;
int startx;
int starty;
int offsetx;
@ -221,10 +222,10 @@ _apply_crop(void *data, Evas_Object *obj EINA_UNUSED,
elm_table_pack(ec->image_parent, ec->image, 0, 0, 1, 1);
ephoto_single_browser_image_data_update(ec->main, ec->image, EINA_TRUE,
idata_new, nw, nh);
evas_object_del(ec->frame);
evas_object_del(ec->cropper);
evas_object_del(ec->layout);
evas_object_del(ec->box);
ephoto_editor_del(ec->editor);
}
static void
@ -237,10 +238,10 @@ _cancel_crop(void *data, Evas_Object *obj EINA_UNUSED,
elm_layout_content_unset(ec->layout, "ephoto.swallow.image");
elm_table_pack(ec->image_parent, ec->image, 0, 0, 1, 1);
ephoto_single_browser_cancel_editing(ec->main, ec->image);
evas_object_del(ec->frame);
evas_object_del(ec->cropper);
evas_object_del(ec->layout);
evas_object_del(ec->box);
ephoto_editor_del(ec->editor);
}
static void
@ -585,11 +586,42 @@ _image_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
EDJE_MESSAGE_INT_SET, 1, msg);
}
static Eina_Bool
_crop_reset(void *data, int type EINA_UNUSED,
void *event_info EINA_UNUSED)
{
_reset_crop(data, NULL, NULL);
return ECORE_CALLBACK_PASS_ON;
}
static Eina_Bool
_crop_apply(void *data, int type EINA_UNUSED,
void *event_info EINA_UNUSED)
{
_apply_crop(data, NULL, NULL);
return ECORE_CALLBACK_PASS_ON;
}
static Eina_Bool
_crop_cancel(void *data, int type EINA_UNUSED,
void *event_info EINA_UNUSED)
{
_cancel_crop(data, NULL, NULL);
return ECORE_CALLBACK_PASS_ON;
}
static void
_cropper_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
_editor_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ephoto_Cropper *ec = data;
Ecore_Event_Handler *handler;
EINA_LIST_FREE(ec->handlers, handler)
ecore_event_handler_del(handler);
free(ec);
}
@ -598,7 +630,6 @@ void
ephoto_cropper_add(Evas_Object *main, Evas_Object *parent,
Evas_Object *image_parent, Evas_Object *image)
{
Evas_Object *vbox, *ic, *button;
Ephoto_Cropper *ec;
int w, h;
@ -669,38 +700,13 @@ ephoto_cropper_add(Evas_Object *main, Evas_Object *parent,
evas_object_event_callback_add(ec->layout, EVAS_CALLBACK_RESIZE,
_image_resize, ec);
evas_object_event_callback_add(ec->box, EVAS_CALLBACK_DEL,
_cropper_del, ec);
ec->frame = elm_frame_add(parent);
elm_object_text_set(ec->frame, _("Crop Image"));
evas_object_size_hint_weight_set(ec->frame, 0.3, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ec->frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(parent, ec->frame);
evas_object_data_set(ec->frame, "ec", ec);
evas_object_show(ec->frame);
vbox = elm_box_add(ec->frame);
elm_box_horizontal_set(vbox, EINA_FALSE);
evas_object_size_hint_weight_set(vbox, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(vbox, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_content_set(ec->frame, vbox);
evas_object_show(vbox);
ec->cropw = elm_slider_add(vbox);
elm_slider_min_max_set(ec->cropw, 1, w);
elm_slider_step_set(ec->cropw, 1);
elm_slider_unit_format_set(ec->cropw, "%1.0f");
elm_object_text_set(ec->cropw, _("Width"));
evas_object_size_hint_weight_set(ec->cropw, EVAS_HINT_EXPAND,
EVAS_HINT_FILL);
evas_object_size_hint_align_set(ec->cropw, EVAS_HINT_FILL, 0.5);
elm_box_pack_end(vbox, ec->cropw);
evas_object_smart_callback_add(ec->cropw, "slider,drag,stop",
_cropper_changed_width, ec);
evas_object_show(ec->cropw);
ec->croph = elm_slider_add(vbox);
ec->editor = ephoto_editor_add(parent, _("Crop Image"),
"ec", ec);
evas_object_event_callback_add(ec->editor, EVAS_CALLBACK_DEL,
_editor_del, ec);
ec->croph = elm_slider_add(ec->editor);
elm_slider_min_max_set(ec->croph, 1, h);
elm_slider_step_set(ec->croph, 1);
elm_slider_unit_format_set(ec->croph, "%1.0f");
@ -708,52 +714,36 @@ ephoto_cropper_add(Evas_Object *main, Evas_Object *parent,
evas_object_size_hint_weight_set(ec->croph, EVAS_HINT_EXPAND,
EVAS_HINT_FILL);
evas_object_size_hint_align_set(ec->croph, EVAS_HINT_FILL, 0.5);
elm_box_pack_end(vbox, ec->croph);
elm_box_pack_start(ec->editor, ec->croph);
evas_object_smart_callback_add(ec->croph, "slider,drag,stop",
_cropper_changed_height, ec);
evas_object_show(ec->croph);
ic = elm_icon_add(vbox);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "edit-undo");
button = elm_button_add(vbox);
elm_object_text_set(button, _("Reset"));
elm_object_part_content_set(button, "icon", ic);
evas_object_smart_callback_add(button, "clicked", _reset_crop, ec);
evas_object_size_hint_weight_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(vbox, button);
evas_object_show(button);
ic = elm_icon_add(vbox);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "document-save");
button = elm_button_add(vbox);
elm_object_text_set(button, _("Apply"));
elm_object_part_content_set(button, "icon", ic);
evas_object_smart_callback_add(button, "clicked", _apply_crop, ec);
evas_object_size_hint_weight_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(vbox, button);
evas_object_show(button);
ic = elm_icon_add(vbox);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "window-close");
button = elm_button_add(vbox);
elm_object_text_set(button, _("Cancel"));
elm_object_part_content_set(button, "icon", ic);
evas_object_smart_callback_add(button, "clicked", _cancel_crop, ec);
evas_object_size_hint_weight_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(vbox, button);
evas_object_show(button);
ec->cropw = elm_slider_add(ec->editor);
elm_slider_min_max_set(ec->cropw, 1, w);
elm_slider_step_set(ec->cropw, 1);
elm_slider_unit_format_set(ec->cropw, "%1.0f");
elm_object_text_set(ec->cropw, _("Width"));
evas_object_size_hint_weight_set(ec->cropw, EVAS_HINT_EXPAND,
EVAS_HINT_FILL);
evas_object_size_hint_align_set(ec->cropw, EVAS_HINT_FILL, 0.5);
elm_box_pack_start(ec->editor, ec->cropw);
evas_object_smart_callback_add(ec->cropw, "slider,drag,stop",
_cropper_changed_width, ec);
evas_object_show(ec->cropw);
ec->handlers =
eina_list_append(ec->handlers,
ecore_event_handler_add(EPHOTO_EVENT_EDITOR_RESET,
_crop_reset, ec));
ec->handlers =
eina_list_append(ec->handlers,
ecore_event_handler_add(EPHOTO_EVENT_EDITOR_APPLY,
_crop_apply, ec));
ec->handlers =
eina_list_append(ec->handlers,
ecore_event_handler_add(EPHOTO_EVENT_EDITOR_CANCEL,
_crop_cancel, ec));
return;

@ -6,10 +6,11 @@ struct _Ephoto_HSV
Evas_Object *main;
Evas_Object *parent;
Evas_Object *image;
Evas_Object *frame;
Evas_Object *editor;
Evas_Object *hslider;
Evas_Object *sslider;
Evas_Object *vslider;
Eina_List *handlers;
double hue;
double saturation;
double value;
@ -255,8 +256,8 @@ _value_slider_changed(void *data, Evas_Object *obj,
_ephoto_hsv_adjust_saturation(ehsv, ehsv->saturation, image_data_two);
}
static void
_hsv_reset(void *data, Evas_Object *obj EINA_UNUSED,
static Eina_Bool
_hsv_reset(void *data, int type EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ephoto_HSV *ehsv = data;
@ -268,10 +269,12 @@ _hsv_reset(void *data, Evas_Object *obj EINA_UNUSED,
ehsv->saturation = 0;
ehsv->value = 0;
_hue_slider_changed(ehsv, ehsv->hslider, NULL);
return ECORE_CALLBACK_PASS_ON;
}
static void
_hsv_apply(void *data, Evas_Object *obj EINA_UNUSED,
static Eina_Bool
_hsv_apply(void *data, int type EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ephoto_HSV *ehsv = data;
@ -284,11 +287,13 @@ _hsv_apply(void *data, Evas_Object *obj EINA_UNUSED,
evas_object_image_size_get(elm_image_object_get(ehsv->image), &w, &h);
ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_TRUE,
image_data, w, h);
evas_object_del(ehsv->frame);
ephoto_editor_del(ehsv->editor);
return ECORE_CALLBACK_PASS_ON;
}
static void
_hsv_cancel(void *data, Evas_Object *obj EINA_UNUSED,
static Eina_Bool
_hsv_cancel(void *data, int type EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ephoto_HSV *ehsv = data;
@ -301,15 +306,20 @@ _hsv_cancel(void *data, Evas_Object *obj EINA_UNUSED,
ehsv->value = 0;
_hue_slider_changed(ehsv, ehsv->hslider, NULL);
ephoto_single_browser_cancel_editing(ehsv->main, ehsv->image);
evas_object_del(ehsv->frame);
ephoto_editor_del(ehsv->editor);
return ECORE_CALLBACK_PASS_ON;
}
static void
_frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
_editor_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
Ephoto_HSV *ehsv = data;
Ecore_Event_Handler *handler;
EINA_LIST_FREE(ehsv->handlers, handler)
ecore_event_handler_del(handler);
free(ehsv->original_im_data);
free(ehsv);
}
@ -317,7 +327,7 @@ _frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
void
ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
{
Evas_Object *box, *slider, *ic, *button;
Evas_Object *slider;
Ephoto_HSV *ehsv;
unsigned int *im_data;
@ -341,39 +351,26 @@ ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
memcpy(ehsv->original_im_data, im_data,
sizeof(unsigned int) * ehsv->w * ehsv->h);
ehsv->frame = elm_frame_add(parent);
elm_object_text_set(ehsv->frame, _("Hue/Saturation/Value"));
evas_object_size_hint_weight_set(ehsv->frame, 0.3, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(ehsv->frame,
EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(parent, ehsv->frame);
evas_object_data_set(ehsv->frame, "ehsv", ehsv);
evas_object_event_callback_add(ehsv->frame, EVAS_CALLBACK_DEL, _frame_del,
ehsv->editor = ephoto_editor_add(parent, _("Hue/Saturation/Value"),
"ehsv", ehsv);
evas_object_event_callback_add(ehsv->editor, EVAS_CALLBACK_DEL, _editor_del,
ehsv);
evas_object_show(ehsv->frame);
box = elm_box_add(ehsv->frame);
elm_box_horizontal_set(box, EINA_FALSE);
evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_content_set(ehsv->frame, box);
evas_object_show(box);
slider = elm_slider_add(box);
elm_object_text_set(slider, _("Hue"));
elm_slider_min_max_set(slider, -180, 180);
elm_slider_step_set(slider, 1);
slider = elm_slider_add(ehsv->editor);
elm_object_text_set(slider, _("Value"));
elm_slider_min_max_set(slider, -100, 100);
elm_slider_step_set(slider, 1.20);
elm_slider_value_set(slider, 0);
elm_slider_unit_format_set(slider, "%1.0f");
elm_slider_unit_format_set(slider, "%1.2f");
evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
evas_object_smart_callback_add(slider, "delay,changed", _hue_slider_changed,
evas_object_smart_callback_add(slider, "delay,changed", _value_slider_changed,
ehsv);
elm_box_pack_end(box, slider);
elm_box_pack_start(ehsv->editor, slider);
evas_object_show(slider);
ehsv->hslider = slider;
ehsv->vslider = slider;
slider = elm_slider_add(box);
slider = elm_slider_add(ehsv->editor);
elm_object_text_set(slider, _("Saturation"));
elm_slider_min_max_set(slider, -100, 100);
elm_slider_step_set(slider, 1.20);
@ -383,66 +380,36 @@ ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
evas_object_smart_callback_add(slider, "delay,changed",
_saturation_slider_changed, ehsv);
elm_box_pack_end(box, slider);
elm_box_pack_start(ehsv->editor, slider);
evas_object_show(slider);
ehsv->sslider = slider;
slider = elm_slider_add(box);
elm_object_text_set(slider, _("Value"));
elm_slider_min_max_set(slider, -100, 100);
elm_slider_step_set(slider, 1.20);
slider = elm_slider_add(ehsv->editor);
elm_object_text_set(slider, _("Hue"));
elm_slider_min_max_set(slider, -180, 180);
elm_slider_step_set(slider, 1);
elm_slider_value_set(slider, 0);
elm_slider_unit_format_set(slider, "%1.2f");
elm_slider_unit_format_set(slider, "%1.0f");
evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
evas_object_smart_callback_add(slider, "delay,changed",
_value_slider_changed, ehsv);
elm_box_pack_end(box, slider);
_hue_slider_changed, ehsv);
elm_box_pack_start(ehsv->editor, slider);
evas_object_show(slider);
ehsv->vslider = slider;
ic = elm_icon_add(box);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "edit-undo");
button = elm_button_add(box);
elm_object_text_set(button, _("Reset"));
elm_object_part_content_set(button, "icon", ic);
evas_object_smart_callback_add(button, "clicked", _hsv_reset, ehsv);
evas_object_size_hint_weight_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, button);
evas_object_show(button);
ic = elm_icon_add(box);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "document-save");
button = elm_button_add(box);
elm_object_text_set(button, _("Apply"));
elm_object_part_content_set(button, "icon", ic);
evas_object_smart_callback_add(button, "clicked", _hsv_apply, ehsv);
evas_object_size_hint_weight_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, button);
evas_object_show(button);
ic = elm_icon_add(box);
elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
elm_icon_standard_set(ic, "window-close");
button = elm_button_add(box);
elm_object_text_set(button, _("Cancel"));
elm_object_part_content_set(button, "icon", ic);
evas_object_smart_callback_add(button, "clicked", _hsv_cancel, ehsv);
evas_object_size_hint_weight_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_box_pack_end(box, button);
evas_object_show(button);
ehsv->hslider = slider;
ehsv->handlers =
eina_list_append(ehsv->handlers,
ecore_event_handler_add(EPHOTO_EVENT_EDITOR_RESET,
_hsv_reset, ehsv));
ehsv->handlers =
eina_list_append(ehsv->handlers,
ecore_event_handler_add(EPHOTO_EVENT_EDITOR_APPLY,
_hsv_apply, ehsv));
ehsv->handlers =
eina_list_append(ehsv->handlers,
ecore_event_handler_add(EPHOTO_EVENT_EDITOR_CANCEL,
_hsv_cancel, ehsv));
return;
error:

@ -4,6 +4,9 @@ int EPHOTO_EVENT_ENTRY_CREATE = 0;
int EPHOTO_EVENT_POPULATE_START = 0;
int EPHOTO_EVENT_POPULATE_END = 0;
int EPHOTO_EVENT_POPULATE_ERROR = 0;
int EPHOTO_EVENT_EDITOR_RESET = 0;
int EPHOTO_EVENT_EDITOR_APPLY = 0;
int EPHOTO_EVENT_EDITOR_CANCEL = 0;
typedef struct _Ephoto_Entry_Free_Listener Ephoto_Entry_Free_Listener;
struct _Ephoto_Entry_Free_Listener
@ -198,6 +201,9 @@ ephoto_window_add(const char *path)
EPHOTO_EVENT_POPULATE_START = ecore_event_type_new();
EPHOTO_EVENT_POPULATE_END = ecore_event_type_new();
EPHOTO_EVENT_POPULATE_ERROR = ecore_event_type_new();
EPHOTO_EVENT_EDITOR_RESET = ecore_event_type_new();
EPHOTO_EVENT_EDITOR_APPLY = ecore_event_type_new();
EPHOTO_EVENT_EDITOR_CANCEL = ecore_event_type_new();
ephoto->selentries = NULL;
ephoto->win = elm_win_util_standard_add("ephoto", "Ephoto");

Loading…
Cancel
Save