summaryrefslogtreecommitdiff
path: root/src/bin/ephoto_color.c
diff options
context:
space:
mode:
authorStephen okra Houston <smhouston88@gmail.com>2016-03-23 15:14:21 -0500
committerStephen okra Houston <smhouston88@gmail.com>2016-03-23 15:14:21 -0500
commit4b8ea0492b9492a7946b486eae8beee95343a581 (patch)
tree1bb480316176e49ad05934fc69ea26eead4b8406 /src/bin/ephoto_color.c
parentd5b7d2408273a99623a5a957fc52267099de4c26 (diff)
Ephoto: Move common editing code to one place.
Diffstat (limited to 'src/bin/ephoto_color.c')
-rw-r--r--src/bin/ephoto_color.c129
1 files changed, 49 insertions, 80 deletions
diff --git a/src/bin/ephoto_color.c b/src/bin/ephoto_color.c
index c8a2ab9..73ddc70 100644
--- a/src/bin/ephoto_color.c
+++ b/src/bin/ephoto_color.c
@@ -6,10 +6,11 @@ struct _Ephoto_Color
6 Evas_Object *main; 6 Evas_Object *main;
7 Evas_Object *parent; 7 Evas_Object *parent;
8 Evas_Object *image; 8 Evas_Object *image;
9 Evas_Object *frame; 9 Evas_Object *editor;
10 Evas_Object *bslider; 10 Evas_Object *bslider;
11 Evas_Object *gslider; 11 Evas_Object *gslider;
12 Evas_Object *rslider; 12 Evas_Object *rslider;
13 Eina_List *handlers;
13 int blue; 14 int blue;
14 int green; 15 int green;
15 int red; 16 int red;
@@ -233,8 +234,8 @@ _blue_slider_changed(void *data, Evas_Object *obj,
233 _ephoto_color_adjust_green(eco, eco->green, image_data_two); 234 _ephoto_color_adjust_green(eco, eco->green, image_data_two);
234} 235}
235 236
236static void 237static Eina_Bool
237_color_reset(void *data, Evas_Object *obj EINA_UNUSED, 238_color_reset(void *data, int type EINA_UNUSED,
238 void *event_info EINA_UNUSED) 239 void *event_info EINA_UNUSED)
239{ 240{
240 Ephoto_Color *eco = data; 241 Ephoto_Color *eco = data;
@@ -246,10 +247,12 @@ _color_reset(void *data, Evas_Object *obj EINA_UNUSED,
246 eco->green = 0; 247 eco->green = 0;
247 eco->blue = 0; 248 eco->blue = 0;
248 _red_slider_changed(eco, eco->rslider, NULL); 249 _red_slider_changed(eco, eco->rslider, NULL);
250
251 return ECORE_CALLBACK_PASS_ON;
249} 252}
250 253
251static void 254static Eina_Bool
252_color_apply(void *data, Evas_Object *obj EINA_UNUSED, 255_color_apply(void *data, int type EINA_UNUSED,
253 void *event_info EINA_UNUSED) 256 void *event_info EINA_UNUSED)
254{ 257{
255 Ephoto_Color *eco = data; 258 Ephoto_Color *eco = data;
@@ -262,11 +265,13 @@ _color_apply(void *data, Evas_Object *obj EINA_UNUSED,
262 evas_object_image_size_get(elm_image_object_get(eco->image), &w, &h); 265 evas_object_image_size_get(elm_image_object_get(eco->image), &w, &h);
263 ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_TRUE, 266 ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_TRUE,
264 image_data, w, h); 267 image_data, w, h);
265 evas_object_del(eco->frame); 268 ephoto_editor_del(eco->editor);
269
270 return ECORE_CALLBACK_PASS_ON;
266} 271}
267 272
268static void 273static Eina_Bool
269_color_cancel(void *data, Evas_Object *obj EINA_UNUSED, 274_color_cancel(void *data, int type EINA_UNUSED,
270 void *event_info EINA_UNUSED) 275 void *event_info EINA_UNUSED)
271{ 276{
272 Ephoto_Color *eco = data; 277 Ephoto_Color *eco = data;
@@ -279,15 +284,20 @@ _color_cancel(void *data, Evas_Object *obj EINA_UNUSED,
279 eco->blue = 0; 284 eco->blue = 0;
280 _red_slider_changed(eco, eco->rslider, NULL); 285 _red_slider_changed(eco, eco->rslider, NULL);
281 ephoto_single_browser_cancel_editing(eco->main, eco->image); 286 ephoto_single_browser_cancel_editing(eco->main, eco->image);
282 evas_object_del(eco->frame); 287 ephoto_editor_del(eco->editor);
288
289 return ECORE_CALLBACK_PASS_ON;
283} 290}
284 291
285static void 292static void
286_frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, 293_editor_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
287 void *event_info EINA_UNUSED) 294 void *event_info EINA_UNUSED)
288{ 295{
289 Ephoto_Color *eco = data; 296 Ephoto_Color *eco = data;
297 Ecore_Event_Handler *handler;
290 298
299 EINA_LIST_FREE(eco->handlers, handler)
300 ecore_event_handler_del(handler);
291 free(eco->original_im_data); 301 free(eco->original_im_data);
292 free(eco); 302 free(eco);
293} 303}
@@ -295,7 +305,7 @@ _frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
295void 305void
296ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image) 306ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
297{ 307{
298 Evas_Object *box, *slider, *ic, *button; 308 Evas_Object *slider;
299 Ephoto_Color *eco; 309 Ephoto_Color *eco;
300 unsigned int *im_data; 310 unsigned int *im_data;
301 311
@@ -319,38 +329,26 @@ ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
319 memcpy(eco->original_im_data, im_data, 329 memcpy(eco->original_im_data, im_data,
320 sizeof(unsigned int) * eco->w * eco->h); 330 sizeof(unsigned int) * eco->w * eco->h);
321 331
322 eco->frame = elm_frame_add(parent); 332 eco->editor = ephoto_editor_add(parent, _("Adjust Color Levels"),
323 elm_object_text_set(eco->frame, _("Adjust Color Levels")); 333 "eco", eco);
324 evas_object_size_hint_weight_set(eco->frame, 0.3, EVAS_HINT_EXPAND); 334 evas_object_event_callback_add(eco->editor, EVAS_CALLBACK_DEL, _editor_del,
325 evas_object_size_hint_align_set(eco->frame, EVAS_HINT_FILL, EVAS_HINT_FILL);
326 elm_box_pack_end(parent, eco->frame);
327 evas_object_data_set(eco->frame, "eco", eco);
328 evas_object_event_callback_add(eco->frame, EVAS_CALLBACK_DEL, _frame_del,
329 eco); 335 eco);
330 evas_object_show(eco->frame);
331
332 box = elm_box_add(eco->frame);
333 elm_box_horizontal_set(box, EINA_FALSE);
334 evas_object_size_hint_weight_set(box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
335 evas_object_size_hint_align_set(box, EVAS_HINT_FILL, EVAS_HINT_FILL);
336 elm_object_content_set(eco->frame, box);
337 evas_object_show(box);
338 336
339 slider = elm_slider_add(box); 337 slider = elm_slider_add(eco->editor);
340 elm_object_text_set(slider, _("Red")); 338 elm_object_text_set(slider, _("Blue"));
341 elm_slider_min_max_set(slider, -100, 100); 339 elm_slider_min_max_set(slider, -100, 100);
342 elm_slider_step_set(slider, 1); 340 elm_slider_step_set(slider, 1);
343 elm_slider_value_set(slider, 0); 341 elm_slider_value_set(slider, 0);
344 elm_slider_unit_format_set(slider, "%1.0f"); 342 elm_slider_unit_format_set(slider, "%1.0f");
345 evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL); 343 evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
346 evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5); 344 evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
347 evas_object_smart_callback_add(slider, "delay,changed", _red_slider_changed, 345 evas_object_smart_callback_add(slider, "delay,changed",
348 eco); 346 _blue_slider_changed, eco);
349 elm_box_pack_end(box, slider); 347 elm_box_pack_start(eco->editor, slider);
350 evas_object_show(slider); 348 evas_object_show(slider);
351 eco->rslider = slider; 349 eco->bslider = slider;
352 350
353 slider = elm_slider_add(box); 351 slider = elm_slider_add(eco->editor);
354 elm_object_text_set(slider, _("Green")); 352 elm_object_text_set(slider, _("Green"));
355 elm_slider_min_max_set(slider, -100, 100); 353 elm_slider_min_max_set(slider, -100, 100);
356 elm_slider_step_set(slider, 1); 354 elm_slider_step_set(slider, 1);
@@ -360,12 +358,12 @@ ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
360 evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5); 358 evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
361 evas_object_smart_callback_add(slider, "delay,changed", 359 evas_object_smart_callback_add(slider, "delay,changed",
362 _green_slider_changed, eco); 360 _green_slider_changed, eco);
363 elm_box_pack_end(box, slider); 361 elm_box_pack_start(eco->editor, slider);
364 evas_object_show(slider); 362 evas_object_show(slider);
365 eco->gslider = slider; 363 eco->gslider = slider;
366 364
367 slider = elm_slider_add(box); 365 slider = elm_slider_add(eco->editor);
368 elm_object_text_set(slider, _("Blue")); 366 elm_object_text_set(slider, _("Red"));
369 elm_slider_min_max_set(slider, -100, 100); 367 elm_slider_min_max_set(slider, -100, 100);
370 elm_slider_step_set(slider, 1); 368 elm_slider_step_set(slider, 1);
371 elm_slider_value_set(slider, 0); 369 elm_slider_value_set(slider, 0);
@@ -373,52 +371,23 @@ ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
373 evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL); 371 evas_object_size_hint_weight_set(slider, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
374 evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5); 372 evas_object_size_hint_align_set(slider, EVAS_HINT_FILL, 0.5);
375 evas_object_smart_callback_add(slider, "delay,changed", 373 evas_object_smart_callback_add(slider, "delay,changed",
376 _blue_slider_changed, eco); 374 _red_slider_changed, eco);
377 elm_box_pack_end(box, slider); 375 elm_box_pack_start(eco->editor, slider);
378 evas_object_show(slider); 376 evas_object_show(slider);
379 eco->bslider = slider; 377 eco->rslider = slider;
380 378
381 ic = elm_icon_add(box); 379 eco->handlers =
382 elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME); 380 eina_list_append(eco->handlers,
383 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1); 381 ecore_event_handler_add(EPHOTO_EVENT_EDITOR_RESET,
384 elm_icon_standard_set(ic, "edit-undo"); 382 _color_reset, eco));
385 383 eco->handlers =
386 button = elm_button_add(box); 384 eina_list_append(eco->handlers,
387 elm_object_text_set(button, _("Reset")); 385 ecore_event_handler_add(EPHOTO_EVENT_EDITOR_APPLY,
388 elm_object_part_content_set(button, "icon", ic); 386 _color_apply, eco));
389 evas_object_smart_callback_add(button, "clicked", _color_reset, eco); 387 eco->handlers =
390 evas_object_size_hint_weight_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL); 388 eina_list_append(eco->handlers,
391 evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL); 389 ecore_event_handler_add(EPHOTO_EVENT_EDITOR_CANCEL,
392 elm_box_pack_end(box, button); 390 _color_cancel, eco));
393 evas_object_show(button);
394
395 ic = elm_icon_add(box);
396 elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
397 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
398 elm_icon_standard_set(ic, "document-save");
399
400 button = elm_button_add(box);
401 elm_object_text_set(button, _("Apply"));
402 elm_object_part_content_set(button, "icon", ic);
403 evas_object_smart_callback_add(button, "clicked", _color_apply, eco);
404 evas_object_size_hint_weight_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
405 evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
406 elm_box_pack_end(box, button);
407 evas_object_show(button);
408
409 ic = elm_icon_add(box);
410 elm_icon_order_lookup_set(ic, ELM_ICON_LOOKUP_FDO_THEME);
411 evas_object_size_hint_aspect_set(ic, EVAS_ASPECT_CONTROL_VERTICAL, 1, 1);
412 elm_icon_standard_set(ic, "window-close");
413
414 button = elm_button_add(box);
415 elm_object_text_set(button, _("Cancel"));
416 elm_object_part_content_set(button, "icon", ic);
417 evas_object_smart_callback_add(button, "clicked", _color_cancel, eco);
418 evas_object_size_hint_weight_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
419 evas_object_size_hint_align_set(button, EVAS_HINT_FILL, EVAS_HINT_FILL);
420 elm_box_pack_end(box, button);
421 evas_object_show(button);
422 391
423 return; 392 return;
424 393