Ephoto: Add file operations, context menus, sorting, and more.
This commit is contained in:
parent
0b62428e24
commit
cf25f7c561
|
@ -6,6 +6,9 @@ ephoto_CPPFLAGS = \
|
|||
-I$(top_srcdir) \
|
||||
-I$(top_srcdir)/src/bin \
|
||||
-DPACKAGE_DATA_DIR=\"$(datadir)/$(PACKAGE)\" \
|
||||
-Wall \
|
||||
-Wextra \
|
||||
-Wshadow \
|
||||
@EFL_CFLAGS@
|
||||
ephoto_LDADD = @EFL_LIBS@
|
||||
if HAVE_PO
|
||||
|
|
|
@ -2,9 +2,6 @@
|
|||
|
||||
static void _ephoto_display_usage(void);
|
||||
|
||||
/* Global log domain pointer */
|
||||
int __log_domain = -1;
|
||||
|
||||
EAPI int
|
||||
elm_main(int argc, char **argv)
|
||||
{
|
||||
|
@ -23,79 +20,70 @@ elm_main(int argc, char **argv)
|
|||
textdomain(PACKAGE);
|
||||
#endif
|
||||
|
||||
__log_domain = eina_log_domain_register("ephoto", EINA_COLOR_ORANGE);
|
||||
if (!__log_domain)
|
||||
{
|
||||
EINA_LOG_ERR("Could not register log domain: Ephoto");
|
||||
r = 1;
|
||||
goto end_log_domain;
|
||||
}
|
||||
|
||||
if (!efreet_mime_init())
|
||||
ERR("Could not init efreet_mime!");
|
||||
printf("Could not initialize Efreet_Mime!\n");
|
||||
|
||||
elm_policy_set(ELM_POLICY_QUIT, ELM_POLICY_QUIT_LAST_WINDOW_CLOSED);
|
||||
|
||||
DBG("Logging initialized");
|
||||
if (argc > 2)
|
||||
{
|
||||
printf("Too Many Arguments!\n");
|
||||
_ephoto_display_usage();
|
||||
r = 1;
|
||||
goto end;
|
||||
printf("Too Many Arguments!\n");
|
||||
_ephoto_display_usage();
|
||||
r = 1;
|
||||
goto end;
|
||||
}
|
||||
else if (argc < 2)
|
||||
{
|
||||
Evas_Object *win = ephoto_window_add(NULL);
|
||||
if (!win)
|
||||
{
|
||||
r = 1;
|
||||
goto end;
|
||||
}
|
||||
Evas_Object *win = ephoto_window_add(NULL);
|
||||
|
||||
if (!win)
|
||||
{
|
||||
r = 1;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
else if (!strncmp(argv[1], "--help", 6))
|
||||
{
|
||||
_ephoto_display_usage();
|
||||
r = 0;
|
||||
goto end;
|
||||
_ephoto_display_usage();
|
||||
r = 0;
|
||||
goto end;
|
||||
}
|
||||
else
|
||||
{
|
||||
char *real = ecore_file_realpath(argv[1]);
|
||||
if (!real)
|
||||
{
|
||||
printf("invalid file or directory: '%s'\n", argv[1]);
|
||||
r = 1;
|
||||
goto end;
|
||||
}
|
||||
Evas_Object *win = ephoto_window_add(real);
|
||||
free(real);
|
||||
if (!win)
|
||||
{
|
||||
r = 1;
|
||||
goto end;
|
||||
}
|
||||
char *real = ecore_file_realpath(argv[1]);
|
||||
|
||||
if (!real)
|
||||
{
|
||||
printf("invalid file or directory: '%s'\n", argv[1]);
|
||||
r = 1;
|
||||
goto end;
|
||||
}
|
||||
Evas_Object *win = ephoto_window_add(real);
|
||||
|
||||
free(real);
|
||||
if (!win)
|
||||
{
|
||||
r = 1;
|
||||
goto end;
|
||||
}
|
||||
}
|
||||
|
||||
elm_run();
|
||||
|
||||
end:
|
||||
eina_log_domain_unregister(__log_domain);
|
||||
end:
|
||||
efreet_mime_shutdown();
|
||||
end_log_domain:
|
||||
eio_shutdown();
|
||||
|
||||
return r;
|
||||
}
|
||||
|
||||
/*Display useage commands for ephoto*/
|
||||
/* Display useage commands for ephoto */
|
||||
static void
|
||||
_ephoto_display_usage(void)
|
||||
{
|
||||
printf("Ephoto Usage: \n"
|
||||
"ephoto --help : This page\n"
|
||||
"ephoto filename : Specifies a file to open\n"
|
||||
"ephoto dirname : Specifies a directory to open\n");
|
||||
printf("Ephoto Usage: \n" "ephoto --help : This page\n"
|
||||
"ephoto filename : Specifies a file to open\n"
|
||||
"ephoto dirname : Specifies a directory to open\n");
|
||||
}
|
||||
|
||||
ELM_MAIN()
|
||||
|
|
239
src/bin/ephoto.h
239
src/bin/ephoto.h
|
@ -1,34 +1,38 @@
|
|||
#ifndef _EPHOTO_H_
|
||||
#define _EPHOTO_H_
|
||||
# define _EPHOTO_H_
|
||||
|
||||
#ifdef HAVE_CONFIG_H
|
||||
#include "config.h"
|
||||
#endif
|
||||
# ifdef HAVE_CONFIG_H
|
||||
# include "config.h"
|
||||
# endif
|
||||
|
||||
#include <Eet.h>
|
||||
#include <Ecore.h>
|
||||
#include <Ecore_Evas.h>
|
||||
#include <Ecore_File.h>
|
||||
#include <Efreet_Mime.h>
|
||||
#include <Elementary.h>
|
||||
#include <Eina.h>
|
||||
#include <Edje.h>
|
||||
#include <Evas.h>
|
||||
#include <Eio.h>
|
||||
#include <Ethumb_Client.h>
|
||||
#include <limits.h>
|
||||
#include <math.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <dirent.h>
|
||||
# include <Eet.h>
|
||||
# include <Ecore.h>
|
||||
# include <Ecore_Evas.h>
|
||||
# include <Ecore_File.h>
|
||||
# include <Efreet_Mime.h>
|
||||
# include <Elementary.h>
|
||||
# include <Elementary_Cursor.h>
|
||||
# include <Eina.h>
|
||||
# include <Edje.h>
|
||||
# include <Evas.h>
|
||||
# include <Eio.h>
|
||||
# include <Ethumb_Client.h>
|
||||
# include <limits.h>
|
||||
# include <math.h>
|
||||
# include <stdio.h>
|
||||
# include <stdlib.h>
|
||||
# include <string.h>
|
||||
# include <dirent.h>
|
||||
|
||||
#ifdef HAVE_PO
|
||||
#include <locale.h>
|
||||
#endif
|
||||
# ifdef HAVE_PO
|
||||
# include <locale.h>
|
||||
# endif
|
||||
|
||||
#ifdef HAVE_GETTEXT
|
||||
#include "gettext.h"
|
||||
#if HAVE_GETTEXT && ENABLE_NLS
|
||||
#define _(string) gettext (string)
|
||||
#else
|
||||
#define _(string) (string)
|
||||
#define ngettext(String1, String2, Var) Var == 1 ? String1 : String2
|
||||
#endif
|
||||
|
||||
typedef struct _Ephoto_Config Ephoto_Config;
|
||||
|
@ -38,77 +42,88 @@ typedef struct _Ephoto_Event_Entry_Create Ephoto_Event_Entry_Create;
|
|||
|
||||
typedef enum _Ephoto_State Ephoto_State;
|
||||
typedef enum _Ephoto_Orient Ephoto_Orient;
|
||||
typedef enum _Ephoto_Sort Ephoto_Sort;
|
||||
|
||||
Evas_Object *ephoto_window_add(const char *path);
|
||||
void ephoto_title_set(Ephoto *ephoto, const char *title);
|
||||
void ephoto_thumb_size_set(Ephoto *ephoto, int size);
|
||||
Evas_Object *ephoto_thumb_add(Ephoto *ephoto, Evas_Object *parent, const char *path);
|
||||
void ephoto_thumb_path_set(Evas_Object *obj, const char *path);
|
||||
void ephoto_directory_set(Ephoto *ephoto, const char *path);
|
||||
void ephoto_title_set(Ephoto *ephoto, const char *title);
|
||||
void ephoto_thumb_size_set(Ephoto *ephoto, int size);
|
||||
Evas_Object *ephoto_thumb_add(Ephoto *ephoto, Evas_Object *parent,
|
||||
const char *path);
|
||||
void ephoto_thumb_path_set(Evas_Object *obj, const char *path);
|
||||
void ephoto_directory_set(Ephoto *ephoto, const char *path,
|
||||
Elm_Widget_Item *expanded, Eina_Bool dirs_only);
|
||||
|
||||
Eina_Bool ephoto_config_init(Ephoto *em);
|
||||
void ephoto_config_save(Ephoto *em);
|
||||
void ephoto_config_free(Ephoto *em);
|
||||
void ephoto_config_general(Ephoto *em);
|
||||
void ephoto_config_slideshow(Ephoto *em);
|
||||
void ephoto_config_about(Ephoto *em);
|
||||
Eina_Bool ephoto_config_init(Ephoto *em);
|
||||
void ephoto_config_save(Ephoto *em);
|
||||
void ephoto_config_free(Ephoto *em);
|
||||
void ephoto_config_general(Ephoto *em);
|
||||
void ephoto_config_slideshow(Ephoto *em);
|
||||
void ephoto_config_about(Ephoto *em);
|
||||
|
||||
Evas_Object *ephoto_single_browser_add(Ephoto *ephoto, Evas_Object *parent);
|
||||
void ephoto_single_browser_entry_set(Evas_Object *obj, Ephoto_Entry *entry);
|
||||
void ephoto_single_browser_path_pending_set(Evas_Object *obj, const char *path);
|
||||
void ephoto_single_browser_image_data_update(Evas_Object *main, Evas_Object *image, Eina_Bool finished, unsigned int *image_data, int w, int h);
|
||||
void ephoto_single_browser_cancel_editing(Evas_Object *main, Evas_Object *image);
|
||||
/* smart callbacks called:
|
||||
* "back" - the user wants to go back to the previous screen.
|
||||
*/
|
||||
void ephoto_single_browser_entry_set(Evas_Object *obj, Ephoto_Entry *entry);
|
||||
void ephoto_single_browser_path_pending_set(Evas_Object *obj,
|
||||
const char *path);
|
||||
void ephoto_single_browser_image_data_update(Evas_Object *main,
|
||||
Evas_Object *image, Eina_Bool finished, unsigned int *image_data, int w,
|
||||
int h);
|
||||
void ephoto_single_browser_cancel_editing(Evas_Object *main,
|
||||
Evas_Object *image);
|
||||
/* smart callbacks called: "back" - the user wants to go back to the previous
|
||||
* screen. */
|
||||
Evas_Object *ephoto_slideshow_add(Ephoto *ephoto, Evas_Object *parent);
|
||||
void ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry);
|
||||
/* smart callbacks called:
|
||||
* "back" - the user wants to go back to the previous screen.
|
||||
*/
|
||||
void ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry);
|
||||
|
||||
/* smart callbacks called: "back" - the user wants to go back to the previous
|
||||
* screen. */
|
||||
|
||||
Evas_Object *ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent);
|
||||
void ephoto_thumb_browser_fsel_clear(Ephoto *ephoto);
|
||||
|
||||
/* smart callbacks called:
|
||||
* "selected" - an item in the thumb browser is selected. The selected Ephoto_Entry is passed as event_info argument.
|
||||
*/
|
||||
/* smart callbacks called: "selected" - an item in the thumb browser is
|
||||
* selected. The selected Ephoto_Entry is passed as event_info argument. */
|
||||
|
||||
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, Evas_Object *image);
|
||||
void ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image);
|
||||
void ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image);
|
||||
void ephoto_filter_blur(Evas_Object *main, Evas_Object *image);
|
||||
void ephoto_filter_sharpen(Evas_Object *main, Evas_Object *image);
|
||||
void ephoto_filter_black_and_white(Evas_Object *main, Evas_Object *image);
|
||||
void ephoto_filter_old_photo(Evas_Object *main, Evas_Object *image);
|
||||
void ephoto_filter_histogram_eq(Evas_Object *main, Evas_Object *image);
|
||||
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,
|
||||
Evas_Object *image);
|
||||
void ephoto_hsv_add(Evas_Object *main, Evas_Object *parent,
|
||||
Evas_Object *image);
|
||||
void ephoto_color_add(Evas_Object *main, Evas_Object *parent,
|
||||
Evas_Object *image);
|
||||
void ephoto_filter_blur(Evas_Object *main, Evas_Object *image);
|
||||
void ephoto_filter_sharpen(Evas_Object *main, Evas_Object *image);
|
||||
void ephoto_filter_black_and_white(Evas_Object *main, Evas_Object *image);
|
||||
void ephoto_filter_old_photo(Evas_Object *main, Evas_Object *image);
|
||||
void ephoto_filter_histogram_eq(Evas_Object *main, Evas_Object *image);
|
||||
|
||||
enum _Ephoto_State
|
||||
{
|
||||
EPHOTO_STATE_THUMB,
|
||||
EPHOTO_STATE_SINGLE,
|
||||
EPHOTO_STATE_SLIDESHOW
|
||||
EPHOTO_STATE_THUMB,
|
||||
EPHOTO_STATE_SINGLE,
|
||||
EPHOTO_STATE_SLIDESHOW
|
||||
};
|
||||
|
||||
enum _Ephoto_Orient /* matches with exif orientation tag */
|
||||
enum _Ephoto_Orient
|
||||
{
|
||||
EPHOTO_ORIENT_0 = 1,
|
||||
EPHOTO_ORIENT_FLIP_HORIZ = 2,
|
||||
EPHOTO_ORIENT_180 = 3,
|
||||
EPHOTO_ORIENT_FLIP_VERT = 4,
|
||||
EPHOTO_ORIENT_FLIP_VERT_90 = 5,
|
||||
EPHOTO_ORIENT_90 = 6,
|
||||
EPHOTO_ORIENT_FLIP_HORIZ_90 = 7,
|
||||
EPHOTO_ORIENT_270 = 8
|
||||
EPHOTO_ORIENT_0 = 1,
|
||||
EPHOTO_ORIENT_FLIP_HORIZ = 2,
|
||||
EPHOTO_ORIENT_180 = 3,
|
||||
EPHOTO_ORIENT_FLIP_VERT = 4,
|
||||
EPHOTO_ORIENT_FLIP_VERT_90 = 5,
|
||||
EPHOTO_ORIENT_90 = 6,
|
||||
EPHOTO_ORIENT_FLIP_HORIZ_90 = 7,
|
||||
EPHOTO_ORIENT_270 = 8
|
||||
};
|
||||
|
||||
enum _Ephoto_Sort
|
||||
{
|
||||
EPHOTO_SORT_ALPHABETICAL_ASCENDING,
|
||||
EPHOTO_SORT_ALPHABETICAL_DESCENDING,
|
||||
EPHOTO_SORT_MODTIME_ASCENDING,
|
||||
EPHOTO_SORT_MODTIME_DESCENDING
|
||||
};
|
||||
|
||||
/* TODO: split into window & global config, allow multi window
|
||||
*
|
||||
* This also requires single instance, as 2 instances changing the
|
||||
* same configuration will lead to problems.
|
||||
*
|
||||
* Single instance is better done as DBus, using FDO standard methods.
|
||||
*/
|
||||
struct _Ephoto_Config
|
||||
{
|
||||
int config_version;
|
||||
|
@ -122,11 +137,15 @@ struct _Ephoto_Config
|
|||
int fsel_hide;
|
||||
int tool_hide;
|
||||
const char *open;
|
||||
int prompts;
|
||||
int drop;
|
||||
Evas_Object *slide_time;
|
||||
Evas_Object *slide_trans;
|
||||
Evas_Object *hide_toolbar;
|
||||
Evas_Object *open_dir;
|
||||
Evas_Object *open_dir_custom;
|
||||
Evas_Object *show_prompts;
|
||||
Evas_Object *move_drop;
|
||||
};
|
||||
|
||||
struct _Ephoto
|
||||
|
@ -144,14 +163,16 @@ struct _Ephoto
|
|||
|
||||
Eina_List *entries;
|
||||
Eina_List *direntries;
|
||||
Eina_List *thumbs; /* live thumbs that need to be regenerated on changes */
|
||||
Eina_List *thumbs;
|
||||
|
||||
int thumb_gen_size; /* pending value for thumb_regen */
|
||||
Evas_Coord bottom_bar_size;
|
||||
struct {
|
||||
int thumb_gen_size;
|
||||
Evas_Coord bottom_bar_size;
|
||||
struct
|
||||
{
|
||||
Ecore_Timer *thumb_regen;
|
||||
} timer;
|
||||
struct {
|
||||
struct
|
||||
{
|
||||
Ecore_Job *change_dir;
|
||||
} job;
|
||||
|
||||
|
@ -166,10 +187,11 @@ struct _Ephoto
|
|||
struct _Ephoto_Entry
|
||||
{
|
||||
const char *path;
|
||||
const char *basename; /* pointer inside path */
|
||||
const char *basename;
|
||||
const char *label;
|
||||
Ephoto *ephoto;
|
||||
Elm_Object_Item *item;
|
||||
Elm_Object_Item *parent;
|
||||
Eina_List *free_listeners;
|
||||
Eina_Bool is_dir;
|
||||
};
|
||||
|
@ -179,17 +201,15 @@ struct _Ephoto_Event_Entry_Create
|
|||
Ephoto_Entry *entry;
|
||||
};
|
||||
|
||||
Ephoto_Entry *ephoto_entry_new(Ephoto *ephoto, const char *path, const char *label, Eina_File_Type type);
|
||||
void ephoto_entry_free(Ephoto_Entry *entry);
|
||||
void ephoto_entry_free_listener_add(Ephoto_Entry *entry, void (*cb)(void *data, const Ephoto_Entry *entry), const void *data);
|
||||
void ephoto_entry_free_listener_del(Ephoto_Entry *entry, void (*cb)(void *data, const Ephoto_Entry *entry), const void *data);
|
||||
void ephoto_entries_free(Ephoto *ephoto);
|
||||
int ephoto_entries_cmp(const void *pa, const void *pb);
|
||||
|
||||
extern int __log_domain;
|
||||
#define DBG(...) EINA_LOG_DOM_DBG(__log_domain, __VA_ARGS__)
|
||||
#define INF(...) EINA_LOG_DOM_INFO(__log_domain, __VA_ARGS__)
|
||||
#define ERR(...) EINA_LOG_DOM_ERR(__log_domain, __VA_ARGS__)
|
||||
Ephoto_Entry *ephoto_entry_new(Ephoto *ephoto, const char *path,
|
||||
const char *label, Eina_File_Type type);
|
||||
void ephoto_entry_free(Ephoto_Entry *entry);
|
||||
void ephoto_entry_free_listener_add(Ephoto_Entry *entry,
|
||||
void (*cb) (void *data, const Ephoto_Entry *entry), const void *data);
|
||||
void ephoto_entry_free_listener_del(Ephoto_Entry *entry,
|
||||
void (*cb) (void *data, const Ephoto_Entry *entry), const void *data);
|
||||
void ephoto_entries_free(Ephoto *ephoto);
|
||||
int ephoto_entries_cmp(const void *pa, const void *pb);
|
||||
|
||||
static inline Eina_Bool
|
||||
_ephoto_eina_file_direct_info_image_useful(const Eina_File_Direct_Info *info)
|
||||
|
@ -197,29 +217,28 @@ _ephoto_eina_file_direct_info_image_useful(const Eina_File_Direct_Info *info)
|
|||
const char *type, *bname;
|
||||
int i = 0;
|
||||
|
||||
const char *filters[] =
|
||||
{
|
||||
"png", "jpeg", "jpg", "eet", "xpm", "tiff", "gif", "svg", "webp", "pmaps",
|
||||
"bmp", "tga", "wbmp", "ico", "psd", "jp2k", "generic"
|
||||
const char *filters[] = {
|
||||
"png", "jpeg", "jpg", "eet", "xpm", "tiff", "gif", "svg", "webp", "pmaps",
|
||||
"bmp", "tga", "wbmp", "ico", "psd", "jp2k", "generic"
|
||||
};
|
||||
|
||||
bname = info->path + info->name_start;
|
||||
if (bname[0] == '.') return EINA_FALSE;
|
||||
if (bname[0] == '.')
|
||||
return EINA_FALSE;
|
||||
if ((info->type != EINA_FILE_REG) && (info->type != EINA_FILE_UNKNOWN))
|
||||
return EINA_FALSE;
|
||||
return EINA_FALSE;
|
||||
|
||||
type = strrchr(bname, '.');
|
||||
if(!type) return EINA_FALSE;
|
||||
int count = sizeof(filters)/sizeof(filters[0]);
|
||||
for (i=0; i < count; i++)
|
||||
if (!type)
|
||||
return EINA_FALSE;
|
||||
int count = sizeof(filters) / sizeof(filters[0]);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
{
|
||||
if (!strcasecmp(type+1, filters[i]))
|
||||
return evas_object_image_extension_can_load_get(bname);
|
||||
if (!strcasecmp(type + 1, filters[i]))
|
||||
return evas_object_image_extension_can_load_get(bname);
|
||||
}
|
||||
return EINA_FALSE;
|
||||
/* seems that this does not play nice with threads */
|
||||
//if (!(type = efreet_mime_type_get(info->path))) return EINA_FALSE;
|
||||
//return strncmp(type, "image/", sizeof("image/") - 1) == 0;
|
||||
}
|
||||
|
||||
extern int EPHOTO_EVENT_ENTRY_CREATE;
|
||||
|
|
|
@ -21,221 +21,236 @@ static int
|
|||
_normalize_color(int color)
|
||||
{
|
||||
if (color < 0)
|
||||
return 0;
|
||||
return 0;
|
||||
else if (color > 255)
|
||||
return 255;
|
||||
return 255;
|
||||
else
|
||||
return color;
|
||||
return color;
|
||||
}
|
||||
|
||||
static int
|
||||
_mul_color_alpha(int color, int alpha)
|
||||
{
|
||||
if (alpha > 0 && alpha < 255)
|
||||
return (color * (255 / alpha));
|
||||
return color * (255 / alpha);
|
||||
else
|
||||
return color;
|
||||
return color;
|
||||
}
|
||||
|
||||
static int
|
||||
_demul_color_alpha(int color, int alpha)
|
||||
{
|
||||
if (alpha > 0 && alpha < 255)
|
||||
return ((color * alpha) / 255);
|
||||
return (color * alpha) / 255;
|
||||
else
|
||||
return color;
|
||||
return color;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
_ephoto_bcg_adjust_brightness(Ephoto_BCG *ebcg, int brightness, unsigned int *image_data)
|
||||
_ephoto_bcg_adjust_brightness(Ephoto_BCG *ebcg, int brightness,
|
||||
unsigned int *image_data)
|
||||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int x, y, w, h;
|
||||
int x, y;
|
||||
int a, r, g, b, bb, gg, rr;
|
||||
|
||||
im_data = malloc(sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
if (image_data)
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
else
|
||||
memcpy(im_data, ebcg->original_im_data, sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
memcpy(im_data, ebcg->original_im_data,
|
||||
sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
|
||||
ebcg->brightness = brightness;
|
||||
im_data_new = malloc(sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
|
||||
for (y = 0; y < ebcg->h; y++)
|
||||
{
|
||||
p1 = im_data + (y * ebcg->w);
|
||||
p2 = im_data_new + (y * ebcg->w);
|
||||
for (x = 0; x < ebcg->w; x++)
|
||||
{
|
||||
b = (int)((*p1) & 0xff);
|
||||
g = (int)((*p1 >> 8) & 0xff);
|
||||
r = (int)((*p1 >> 16) & 0xff);
|
||||
a = (int)((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
bb = (int)b+ebcg->brightness;
|
||||
gg = (int)g+ebcg->brightness;
|
||||
rr = (int)r+ebcg->brightness;
|
||||
bb = _normalize_color(bb);
|
||||
gg = _normalize_color(gg);
|
||||
rr = _normalize_color(rr);
|
||||
bb = _demul_color_alpha(bb, a);
|
||||
gg = _demul_color_alpha(gg, a);
|
||||
rr = _demul_color_alpha(rr, a);
|
||||
*p2 = (a << 24) | (rr << 16) | (gg << 8) | bb;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
p1 = im_data + (y * ebcg->w);
|
||||
p2 = im_data_new + (y * ebcg->w);
|
||||
for (x = 0; x < ebcg->w; x++)
|
||||
{
|
||||
b = (int) ((*p1) & 0xff);
|
||||
g = (int) ((*p1 >> 8) & 0xff);
|
||||
r = (int) ((*p1 >> 16) & 0xff);
|
||||
a = (int) ((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
bb = (int) b + ebcg->brightness;
|
||||
gg = (int) g + ebcg->brightness;
|
||||
rr = (int) r + ebcg->brightness;
|
||||
bb = _normalize_color(bb);
|
||||
gg = _normalize_color(gg);
|
||||
rr = _normalize_color(rr);
|
||||
bb = _demul_color_alpha(bb, a);
|
||||
gg = _demul_color_alpha(gg, a);
|
||||
rr = _demul_color_alpha(rr, a);
|
||||
*p2 = (a << 24) | (rr << 16) | (gg << 8) | bb;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
}
|
||||
ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_FALSE, im_data_new, ebcg->w, ebcg->h);
|
||||
ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_FALSE,
|
||||
im_data_new, ebcg->w, ebcg->h);
|
||||
free(im_data);
|
||||
return im_data_new;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
_ephoto_bcg_adjust_contrast(Ephoto_BCG *ebcg, int contrast, unsigned int *image_data)
|
||||
_ephoto_bcg_adjust_contrast(Ephoto_BCG *ebcg, int contrast,
|
||||
unsigned int *image_data)
|
||||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int x, y, w, h, top, bottom;
|
||||
int x, y, top, bottom;
|
||||
int a, r, g, b, bb, gg, rr;
|
||||
float factor;
|
||||
|
||||
im_data = malloc(sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
if (image_data)
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
else
|
||||
memcpy(im_data, ebcg->original_im_data, sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
memcpy(im_data, ebcg->original_im_data,
|
||||
sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
|
||||
ebcg->contrast = contrast;
|
||||
top = ((255+(contrast))*259);
|
||||
bottom = ((259-(contrast))*255);
|
||||
factor = (float)top / (float)bottom;
|
||||
top = ((255 + (contrast)) * 259);
|
||||
bottom = ((259 - (contrast)) * 255);
|
||||
factor = (float) top / (float) bottom;
|
||||
im_data_new = malloc(sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
|
||||
for (y = 0; y < ebcg->h; y++)
|
||||
{
|
||||
p1 = im_data + (y * ebcg->w);
|
||||
p2 = im_data_new + (y * ebcg->w);
|
||||
for (x = 0; x < ebcg->w; x++)
|
||||
{
|
||||
b = (int)((*p1) & 0xff);
|
||||
g = (int)((*p1 >> 8) & 0xff);
|
||||
r = (int)((*p1 >> 16) & 0xff);
|
||||
a = (int)((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
bb = (int)((factor * (b - 128)) + 128);
|
||||
gg = (int)((factor * (g - 128)) + 128);
|
||||
rr = (int)((factor * (r - 128)) + 128);
|
||||
bb = _normalize_color(bb);
|
||||
gg = _normalize_color(gg);
|
||||
rr = _normalize_color(rr);
|
||||
bb = _demul_color_alpha(bb, a);
|
||||
gg = _demul_color_alpha(gg, a);
|
||||
rr = _demul_color_alpha(rr, a);
|
||||
*p2 = (a << 24) | (rr << 16) | (gg << 8) | bb;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
}
|
||||
ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_FALSE, im_data_new, ebcg->w, ebcg->h);
|
||||
p1 = im_data + (y * ebcg->w);
|
||||
p2 = im_data_new + (y * ebcg->w);
|
||||
for (x = 0; x < ebcg->w; x++)
|
||||
{
|
||||
b = (int) ((*p1) & 0xff);
|
||||
g = (int) ((*p1 >> 8) & 0xff);
|
||||
r = (int) ((*p1 >> 16) & 0xff);
|
||||
a = (int) ((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
bb = (int) ((factor * (b - 128)) + 128);
|
||||
gg = (int) ((factor * (g - 128)) + 128);
|
||||
rr = (int) ((factor * (r - 128)) + 128);
|
||||
bb = _normalize_color(bb);
|
||||
gg = _normalize_color(gg);
|
||||
rr = _normalize_color(rr);
|
||||
bb = _demul_color_alpha(bb, a);
|
||||
gg = _demul_color_alpha(gg, a);
|
||||
rr = _demul_color_alpha(rr, a);
|
||||
*p2 = (a << 24) | (rr << 16) | (gg << 8) | bb;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
}
|
||||
ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_FALSE,
|
||||
im_data_new, ebcg->w, ebcg->h);
|
||||
free(im_data);
|
||||
return im_data_new;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
_ephoto_bcg_adjust_gamma(Ephoto_BCG *ebcg, double gamma, unsigned int *image_data)
|
||||
_ephoto_bcg_adjust_gamma(Ephoto_BCG *ebcg, double gamma,
|
||||
unsigned int *image_data)
|
||||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int x, y, w, h;
|
||||
int x, y;
|
||||
int a, r, g, b, bb, gg, rr;
|
||||
|
||||
im_data = malloc(sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
if (image_data)
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
else
|
||||
memcpy(im_data, ebcg->original_im_data, sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
memcpy(im_data, ebcg->original_im_data,
|
||||
sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
|
||||
ebcg->gamma = 1/gamma;
|
||||
ebcg->gamma = 1 / gamma;
|
||||
im_data_new = malloc(sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
|
||||
for (y = 0; y < ebcg->h; y++)
|
||||
{
|
||||
p1 = im_data + (y * ebcg->w);
|
||||
p2 = im_data_new + (y * ebcg->w);
|
||||
for (x = 0; x < ebcg->w; x++)
|
||||
{
|
||||
b = (int)((*p1) & 0xff);
|
||||
g = (int)((*p1 >> 8) & 0xff);
|
||||
r = (int)((*p1 >> 16) & 0xff);
|
||||
a = (int)((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
bb = (int)(pow(((double)b/255), ebcg->gamma) * 255);
|
||||
gg = (int)(pow(((double)g/255), ebcg->gamma) * 255);
|
||||
rr = (int)(pow(((double)r/255), ebcg->gamma) * 255);
|
||||
bb = _normalize_color(bb);
|
||||
gg = _normalize_color(gg);
|
||||
rr = _normalize_color(rr);
|
||||
bb = _demul_color_alpha(bb, a);
|
||||
gg = _demul_color_alpha(gg, a);
|
||||
rr = _demul_color_alpha(rr, a);
|
||||
*p2 = (a << 24) | (rr << 16) | (gg << 8) | bb;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
p1 = im_data + (y * ebcg->w);
|
||||
p2 = im_data_new + (y * ebcg->w);
|
||||
for (x = 0; x < ebcg->w; x++)
|
||||
{
|
||||
b = (int) ((*p1) & 0xff);
|
||||
g = (int) ((*p1 >> 8) & 0xff);
|
||||
r = (int) ((*p1 >> 16) & 0xff);
|
||||
a = (int) ((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
bb = (int) (pow(((double) b / 255), ebcg->gamma) * 255);
|
||||
gg = (int) (pow(((double) g / 255), ebcg->gamma) * 255);
|
||||
rr = (int) (pow(((double) r / 255), ebcg->gamma) * 255);
|
||||
bb = _normalize_color(bb);
|
||||
gg = _normalize_color(gg);
|
||||
rr = _normalize_color(rr);
|
||||
bb = _demul_color_alpha(bb, a);
|
||||
gg = _demul_color_alpha(gg, a);
|
||||
rr = _demul_color_alpha(rr, a);
|
||||
*p2 = (a << 24) | (rr << 16) | (gg << 8) | bb;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
}
|
||||
ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_FALSE, im_data_new, ebcg->w, ebcg->h);
|
||||
ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_FALSE,
|
||||
im_data_new, ebcg->w, ebcg->h);
|
||||
free(im_data);
|
||||
return im_data_new;
|
||||
}
|
||||
|
||||
static void
|
||||
_brightness_slider_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
_brightness_slider_changed(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_BCG *ebcg = data;
|
||||
int brightness;
|
||||
unsigned int *image_data, *image_data_two, *image_data_three;
|
||||
unsigned int *image_data, *image_data_two;
|
||||
|
||||
brightness = elm_slider_value_get(obj);
|
||||
image_data = _ephoto_bcg_adjust_brightness(ebcg, brightness, NULL);
|
||||
image_data_two = _ephoto_bcg_adjust_contrast(ebcg, ebcg->contrast, image_data);
|
||||
image_data_three = _ephoto_bcg_adjust_gamma(ebcg, ebcg->gamma, image_data_two);
|
||||
image_data_two =
|
||||
_ephoto_bcg_adjust_contrast(ebcg, ebcg->contrast, image_data);
|
||||
_ephoto_bcg_adjust_gamma(ebcg, ebcg->gamma, image_data_two);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_contrast_slider_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
_contrast_slider_changed(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_BCG *ebcg = data;
|
||||
int contrast;
|
||||
unsigned int *image_data, *image_data_two, *image_data_three;
|
||||
unsigned int *image_data, *image_data_two;
|
||||
|
||||
contrast = elm_slider_value_get(obj);
|
||||
image_data = _ephoto_bcg_adjust_contrast(ebcg, contrast, NULL);
|
||||
image_data_two = _ephoto_bcg_adjust_brightness(ebcg, ebcg->brightness, image_data);
|
||||
image_data_three = _ephoto_bcg_adjust_gamma(ebcg, ebcg->gamma, image_data_two);
|
||||
image_data_two =
|
||||
_ephoto_bcg_adjust_brightness(ebcg, ebcg->brightness, image_data);
|
||||
_ephoto_bcg_adjust_gamma(ebcg, ebcg->gamma, image_data_two);
|
||||
}
|
||||
|
||||
static void
|
||||
_gamma_slider_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
_gamma_slider_changed(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_BCG *ebcg = data;
|
||||
double gamma;
|
||||
unsigned int *image_data, *image_data_two, *image_data_three;
|
||||
unsigned int *image_data, *image_data_two;
|
||||
|
||||
gamma = elm_slider_value_get(obj);
|
||||
image_data = _ephoto_bcg_adjust_gamma(ebcg, gamma, NULL);
|
||||
image_data_two = _ephoto_bcg_adjust_brightness(ebcg, ebcg->brightness, image_data);
|
||||
image_data_three = _ephoto_bcg_adjust_contrast(ebcg, ebcg->contrast, image_data_two);
|
||||
image_data_two =
|
||||
_ephoto_bcg_adjust_brightness(ebcg, ebcg->brightness, image_data);
|
||||
_ephoto_bcg_adjust_contrast(ebcg, ebcg->contrast, image_data_two);
|
||||
}
|
||||
|
||||
static void
|
||||
_bcg_reset(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_bcg_reset(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_BCG *ebcg = data;
|
||||
|
||||
|
@ -249,20 +264,25 @@ _bcg_reset(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSE
|
|||
}
|
||||
|
||||
static void
|
||||
_bcg_apply(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_bcg_apply(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_BCG *ebcg = data;
|
||||
unsigned int *image_data;
|
||||
int w, h;
|
||||
|
||||
image_data = evas_object_image_data_get(elm_image_object_get(ebcg->image), EINA_FALSE);
|
||||
image_data =
|
||||
evas_object_image_data_get(elm_image_object_get(ebcg->image),
|
||||
EINA_FALSE);
|
||||
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);
|
||||
ephoto_single_browser_image_data_update(ebcg->main, ebcg->image, EINA_TRUE,
|
||||
image_data, w, h);
|
||||
evas_object_del(ebcg->frame);
|
||||
}
|
||||
|
||||
static void
|
||||
_bcg_cancel(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_bcg_cancel(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_BCG *ebcg = data;
|
||||
|
||||
|
@ -278,16 +298,19 @@ _bcg_cancel(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUS
|
|||
}
|
||||
|
||||
static void
|
||||
_frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_BCG *ebcg = data;
|
||||
|
||||
free(ebcg->original_im_data);
|
||||
free(ebcg);
|
||||
}
|
||||
|
||||
void ephoto_bcg_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
||||
void
|
||||
ephoto_bcg_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
||||
{
|
||||
Evas_Object *win, *box, *slider, *ic, *button;
|
||||
Evas_Object *box, *slider, *ic, *button;
|
||||
Ephoto_BCG *ebcg;
|
||||
unsigned int *im_data;
|
||||
|
||||
|
@ -302,10 +325,14 @@ void ephoto_bcg_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
ebcg->main = main;
|
||||
ebcg->parent = parent;
|
||||
ebcg->image = image;
|
||||
im_data = evas_object_image_data_get(elm_image_object_get(ebcg->image), EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_get(ebcg->image), &ebcg->w, &ebcg->h);
|
||||
im_data =
|
||||
evas_object_image_data_get(elm_image_object_get(ebcg->image),
|
||||
EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_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, sizeof(unsigned int) * ebcg->w * ebcg->h);
|
||||
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"));
|
||||
|
@ -313,7 +340,8 @@ void ephoto_bcg_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
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);
|
||||
evas_object_event_callback_add(ebcg->frame, EVAS_CALLBACK_DEL, _frame_del,
|
||||
ebcg);
|
||||
evas_object_show(ebcg->frame);
|
||||
|
||||
box = elm_box_add(ebcg->frame);
|
||||
|
@ -331,7 +359,8 @@ void ephoto_bcg_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
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", _brightness_slider_changed, ebcg);
|
||||
evas_object_smart_callback_add(slider, "delay,changed",
|
||||
_brightness_slider_changed, ebcg);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
ebcg->bslider = slider;
|
||||
|
@ -344,7 +373,8 @@ void ephoto_bcg_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
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", _contrast_slider_changed, ebcg);
|
||||
evas_object_smart_callback_add(slider, "delay,changed",
|
||||
_contrast_slider_changed, ebcg);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
ebcg->cslider = slider;
|
||||
|
@ -357,7 +387,8 @@ void ephoto_bcg_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
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", _gamma_slider_changed, ebcg);
|
||||
evas_object_smart_callback_add(slider, "delay,changed",
|
||||
_gamma_slider_changed, ebcg);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
ebcg->gslider = slider;
|
||||
|
@ -406,6 +437,6 @@ void ephoto_bcg_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
|
||||
return;
|
||||
|
||||
error:
|
||||
return;
|
||||
error:
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -21,165 +21,173 @@ static int
|
|||
_normalize_color(int color)
|
||||
{
|
||||
if (color < 0)
|
||||
return 0;
|
||||
return 0;
|
||||
else if (color > 255)
|
||||
return 255;
|
||||
return 255;
|
||||
else
|
||||
return color;
|
||||
return color;
|
||||
}
|
||||
|
||||
static int
|
||||
_mul_color_alpha(int color, int alpha)
|
||||
{
|
||||
if (alpha > 0 && alpha < 255)
|
||||
return (color * (255 / alpha));
|
||||
return color * (255 / alpha);
|
||||
else
|
||||
return color;
|
||||
return color;
|
||||
}
|
||||
|
||||
static int
|
||||
_demul_color_alpha(int color, int alpha)
|
||||
{
|
||||
if (alpha > 0 && alpha < 255)
|
||||
return ((color * alpha) / 255);
|
||||
return (color * alpha) / 255;
|
||||
else
|
||||
return color;
|
||||
return color;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
_ephoto_color_adjust_red(Ephoto_Color *eco, int red, unsigned int *image_data)
|
||||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int x, y, w, h;
|
||||
int x, y;
|
||||
int a, r, g, b, rr;
|
||||
|
||||
im_data = malloc(sizeof(unsigned int) * eco->w * eco->h);
|
||||
if (image_data)
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * eco->w * eco->h);
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * eco->w * eco->h);
|
||||
else
|
||||
memcpy(im_data, eco->original_im_data, sizeof(unsigned int) * eco->w * eco->h);
|
||||
memcpy(im_data, eco->original_im_data,
|
||||
sizeof(unsigned int) * eco->w * eco->h);
|
||||
|
||||
eco->red = red;
|
||||
im_data_new = malloc(sizeof(unsigned int) * eco->w * eco->h);
|
||||
|
||||
for (y = 0; y < eco->h; y++)
|
||||
{
|
||||
p1 = im_data + (y * eco->w);
|
||||
p2 = im_data_new + (y * eco->w);
|
||||
for (x = 0; x < eco->w; x++)
|
||||
{
|
||||
b = (int)((*p1) & 0xff);
|
||||
g = (int)((*p1 >> 8) & 0xff);
|
||||
r = (int)((*p1 >> 16) & 0xff);
|
||||
a = (int)((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
rr = (int)r+eco->red;
|
||||
b = _normalize_color(b);
|
||||
g = _normalize_color(g);
|
||||
rr = _normalize_color(rr);
|
||||
b = _demul_color_alpha(b, a);
|
||||
g = _demul_color_alpha(g, a);
|
||||
rr = _demul_color_alpha(rr, a);
|
||||
*p2 = (a << 24) | (rr << 16) | (g << 8) | b;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
p1 = im_data + (y * eco->w);
|
||||
p2 = im_data_new + (y * eco->w);
|
||||
for (x = 0; x < eco->w; x++)
|
||||
{
|
||||
b = (int) ((*p1) & 0xff);
|
||||
g = (int) ((*p1 >> 8) & 0xff);
|
||||
r = (int) ((*p1 >> 16) & 0xff);
|
||||
a = (int) ((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
rr = (int) r + eco->red;
|
||||
b = _normalize_color(b);
|
||||
g = _normalize_color(g);
|
||||
rr = _normalize_color(rr);
|
||||
b = _demul_color_alpha(b, a);
|
||||
g = _demul_color_alpha(g, a);
|
||||
rr = _demul_color_alpha(rr, a);
|
||||
*p2 = (a << 24) | (rr << 16) | (g << 8) | b;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
}
|
||||
ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_FALSE, im_data_new, eco->w, eco->h);
|
||||
ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_FALSE,
|
||||
im_data_new, eco->w, eco->h);
|
||||
free(im_data);
|
||||
return im_data_new;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
_ephoto_color_adjust_green(Ephoto_Color *eco, int green, unsigned int *image_data)
|
||||
_ephoto_color_adjust_green(Ephoto_Color *eco, int green,
|
||||
unsigned int *image_data)
|
||||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int x, y, w, h;
|
||||
int x, y;
|
||||
int a, r, g, b, gg;
|
||||
|
||||
im_data = malloc(sizeof(unsigned int) * eco->w * eco->h);
|
||||
if (image_data)
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * eco->w * eco->h);
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * eco->w * eco->h);
|
||||
else
|
||||
memcpy(im_data, eco->original_im_data, sizeof(unsigned int) * eco->w * eco->h);
|
||||
memcpy(im_data, eco->original_im_data,
|
||||
sizeof(unsigned int) * eco->w * eco->h);
|
||||
|
||||
eco->green = green;
|
||||
im_data_new = malloc(sizeof(unsigned int) * eco->w * eco->h);
|
||||
|
||||
for (y = 0; y < eco->h; y++)
|
||||
{
|
||||
p1 = im_data + (y * eco->w);
|
||||
p2 = im_data_new + (y * eco->w);
|
||||
for (x = 0; x < eco->w; x++)
|
||||
{
|
||||
b = (int)((*p1) & 0xff);
|
||||
g = (int)((*p1 >> 8) & 0xff);
|
||||
r = (int)((*p1 >> 16) & 0xff);
|
||||
a = (int)((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
gg = (int)g+eco->green;
|
||||
b = _normalize_color(b);
|
||||
gg = _normalize_color(gg);
|
||||
r = _normalize_color(r);
|
||||
b = _demul_color_alpha(b, a);
|
||||
gg = _demul_color_alpha(gg, a);
|
||||
r = _demul_color_alpha(r, a);
|
||||
*p2 = (a << 24) | (r << 16) | (gg << 8) | b;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
p1 = im_data + (y * eco->w);
|
||||
p2 = im_data_new + (y * eco->w);
|
||||
for (x = 0; x < eco->w; x++)
|
||||
{
|
||||
b = (int) ((*p1) & 0xff);
|
||||
g = (int) ((*p1 >> 8) & 0xff);
|
||||
r = (int) ((*p1 >> 16) & 0xff);
|
||||
a = (int) ((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
gg = (int) g + eco->green;
|
||||
b = _normalize_color(b);
|
||||
gg = _normalize_color(gg);
|
||||
r = _normalize_color(r);
|
||||
b = _demul_color_alpha(b, a);
|
||||
gg = _demul_color_alpha(gg, a);
|
||||
r = _demul_color_alpha(r, a);
|
||||
*p2 = (a << 24) | (r << 16) | (gg << 8) | b;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
}
|
||||
ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_FALSE, im_data_new, eco->w, eco->h);
|
||||
ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_FALSE,
|
||||
im_data_new, eco->w, eco->h);
|
||||
free(im_data);
|
||||
return im_data_new;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
_ephoto_color_adjust_blue(Ephoto_Color *eco, int blue, unsigned int *image_data)
|
||||
_ephoto_color_adjust_blue(Ephoto_Color *eco, int blue,
|
||||
unsigned int *image_data)
|
||||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int x, y, w, h;
|
||||
int x, y;
|
||||
int a, r, g, b, bb;
|
||||
|
||||
im_data = malloc(sizeof(unsigned int) * eco->w * eco->h);
|
||||
if (image_data)
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * eco->w * eco->h);
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * eco->w * eco->h);
|
||||
else
|
||||
memcpy(im_data, eco->original_im_data, sizeof(unsigned int) * eco->w * eco->h);
|
||||
memcpy(im_data, eco->original_im_data,
|
||||
sizeof(unsigned int) * eco->w * eco->h);
|
||||
|
||||
eco->blue = blue;
|
||||
im_data_new = malloc(sizeof(unsigned int) * eco->w * eco->h);
|
||||
|
||||
for (y = 0; y < eco->h; y++)
|
||||
{
|
||||
p1 = im_data + (y * eco->w);
|
||||
p2 = im_data_new + (y * eco->w);
|
||||
for (x = 0; x < eco->w; x++)
|
||||
{
|
||||
b = (int)((*p1) & 0xff);
|
||||
g = (int)((*p1 >> 8) & 0xff);
|
||||
r = (int)((*p1 >> 16) & 0xff);
|
||||
a = (int)((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
bb = (int)b+eco->blue;
|
||||
bb = _normalize_color(bb);
|
||||
g = _normalize_color(g);
|
||||
r = _normalize_color(r);
|
||||
bb = _demul_color_alpha(bb, a);
|
||||
g = _demul_color_alpha(g, a);
|
||||
r = _demul_color_alpha(r, a);
|
||||
*p2 = (a << 24) | (r << 16) | (g << 8) | bb;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
p1 = im_data + (y * eco->w);
|
||||
p2 = im_data_new + (y * eco->w);
|
||||
for (x = 0; x < eco->w; x++)
|
||||
{
|
||||
b = (int) ((*p1) & 0xff);
|
||||
g = (int) ((*p1 >> 8) & 0xff);
|
||||
r = (int) ((*p1 >> 16) & 0xff);
|
||||
a = (int) ((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
bb = (int) b + eco->blue;
|
||||
bb = _normalize_color(bb);
|
||||
g = _normalize_color(g);
|
||||
r = _normalize_color(r);
|
||||
bb = _demul_color_alpha(bb, a);
|
||||
g = _demul_color_alpha(g, a);
|
||||
r = _demul_color_alpha(r, a);
|
||||
*p2 = (a << 24) | (r << 16) | (g << 8) | bb;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
}
|
||||
ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_FALSE, im_data_new, eco->w, eco->h);
|
||||
ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_FALSE,
|
||||
im_data_new, eco->w, eco->h);
|
||||
free(im_data);
|
||||
return im_data_new;
|
||||
}
|
||||
|
@ -189,43 +197,45 @@ _red_slider_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
|||
{
|
||||
Ephoto_Color *eco = data;
|
||||
int red;
|
||||
unsigned int *image_data, *image_data_two, *image_data_three;
|
||||
unsigned int *image_data, *image_data_two;
|
||||
|
||||
red = elm_slider_value_get(obj);
|
||||
image_data = _ephoto_color_adjust_red(eco, red, NULL);
|
||||
image_data_two = _ephoto_color_adjust_green(eco, eco->green, image_data);
|
||||
image_data_three = _ephoto_color_adjust_blue(eco, eco->blue, image_data_two);
|
||||
_ephoto_color_adjust_blue(eco, eco->blue, image_data_two);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_green_slider_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
_green_slider_changed(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Color *eco = data;
|
||||
int green;
|
||||
unsigned int *image_data, *image_data_two, *image_data_three;
|
||||
unsigned int *image_data, *image_data_two;
|
||||
|
||||
green = elm_slider_value_get(obj);
|
||||
image_data = _ephoto_color_adjust_green(eco, green, NULL);
|
||||
image_data_two = _ephoto_color_adjust_red(eco, eco->red, image_data);
|
||||
image_data_three = _ephoto_color_adjust_blue(eco, eco->blue, image_data_two);
|
||||
_ephoto_color_adjust_blue(eco, eco->blue, image_data_two);
|
||||
}
|
||||
|
||||
static void
|
||||
_blue_slider_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
_blue_slider_changed(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Color *eco = data;
|
||||
int blue;
|
||||
unsigned int *image_data, *image_data_two, *image_data_three;
|
||||
unsigned int *image_data, *image_data_two;
|
||||
|
||||
blue = elm_slider_value_get(obj);
|
||||
image_data = _ephoto_color_adjust_blue(eco, blue, NULL);
|
||||
image_data_two = _ephoto_color_adjust_red(eco, eco->red, image_data);
|
||||
image_data_three = _ephoto_color_adjust_green(eco, eco->green, image_data_two);
|
||||
_ephoto_color_adjust_green(eco, eco->green, image_data_two);
|
||||
}
|
||||
|
||||
static void
|
||||
_color_reset(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_color_reset(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Color *eco = data;
|
||||
|
||||
|
@ -239,20 +249,24 @@ _color_reset(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNU
|
|||
}
|
||||
|
||||
static void
|
||||
_color_apply(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_color_apply(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Color *eco = data;
|
||||
unsigned int *image_data;
|
||||
int w, h;
|
||||
|
||||
image_data = evas_object_image_data_get(elm_image_object_get(eco->image), EINA_FALSE);
|
||||
image_data =
|
||||
evas_object_image_data_get(elm_image_object_get(eco->image), EINA_FALSE);
|
||||
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);
|
||||
ephoto_single_browser_image_data_update(eco->main, eco->image, EINA_TRUE,
|
||||
image_data, w, h);
|
||||
evas_object_del(eco->frame);
|
||||
}
|
||||
|
||||
static void
|
||||
_color_cancel(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_color_cancel(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Color *eco = data;
|
||||
|
||||
|
@ -268,16 +282,19 @@ _color_cancel(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UN
|
|||
}
|
||||
|
||||
static void
|
||||
_frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Color *eco = data;
|
||||
|
||||
free(eco->original_im_data);
|
||||
free(eco);
|
||||
}
|
||||
|
||||
void ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
||||
void
|
||||
ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
||||
{
|
||||
Evas_Object *win, *box, *slider, *ic, *button;
|
||||
Evas_Object *box, *slider, *ic, *button;
|
||||
Ephoto_Color *eco;
|
||||
unsigned int *im_data;
|
||||
|
||||
|
@ -292,10 +309,13 @@ void ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image
|
|||
eco->main = main;
|
||||
eco->parent = parent;
|
||||
eco->image = image;
|
||||
im_data = evas_object_image_data_get(elm_image_object_get(eco->image), EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_get(eco->image), &eco->w, &eco->h);
|
||||
im_data =
|
||||
evas_object_image_data_get(elm_image_object_get(eco->image), EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_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, sizeof(unsigned int) * eco->w * eco->h);
|
||||
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"));
|
||||
|
@ -303,7 +323,8 @@ void ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image
|
|||
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);
|
||||
evas_object_event_callback_add(eco->frame, EVAS_CALLBACK_DEL, _frame_del,
|
||||
eco);
|
||||
evas_object_show(eco->frame);
|
||||
|
||||
box = elm_box_add(eco->frame);
|
||||
|
@ -321,7 +342,8 @@ void ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image
|
|||
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);
|
||||
evas_object_smart_callback_add(slider, "delay,changed", _red_slider_changed,
|
||||
eco);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
eco->rslider = slider;
|
||||
|
@ -334,7 +356,8 @@ void ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image
|
|||
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", _green_slider_changed, eco);
|
||||
evas_object_smart_callback_add(slider, "delay,changed",
|
||||
_green_slider_changed, eco);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
eco->gslider = slider;
|
||||
|
@ -347,7 +370,8 @@ void ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image
|
|||
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", _blue_slider_changed, eco);
|
||||
evas_object_smart_callback_add(slider, "delay,changed", _blue_slider_changed,
|
||||
eco);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
eco->bslider = slider;
|
||||
|
@ -396,6 +420,6 @@ void ephoto_color_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image
|
|||
|
||||
return;
|
||||
|
||||
error:
|
||||
return;
|
||||
error:
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "ephoto.h"
|
||||
|
||||
#define CONFIG_VERSION 11
|
||||
#define CONFIG_VERSION 13
|
||||
|
||||
static int _ephoto_config_load(Ephoto *ephoto);
|
||||
static Eina_Bool _ephoto_on_config_save(void *data);
|
||||
|
@ -12,22 +12,21 @@ ephoto_config_init(Ephoto *ephoto)
|
|||
{
|
||||
Eet_Data_Descriptor_Class eddc;
|
||||
|
||||
if (!eet_eina_stream_data_descriptor_class_set(&eddc, sizeof (eddc),
|
||||
"Ephoto_Config",
|
||||
sizeof(Ephoto_Config)))
|
||||
if (!eet_eina_stream_data_descriptor_class_set(&eddc, sizeof(eddc),
|
||||
"Ephoto_Config", sizeof(Ephoto_Config)))
|
||||
{
|
||||
ERR("Unable to create the config data descriptor!");
|
||||
return EINA_FALSE;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
if (!edd) edd = eet_data_descriptor_stream_new(&eddc);
|
||||
if (!edd)
|
||||
edd = eet_data_descriptor_stream_new(&eddc);
|
||||
|
||||
#undef T
|
||||
#undef D
|
||||
#define T Ephoto_Config
|
||||
#define D edd
|
||||
#define C_VAL(edd, type, member, dtype) \
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, type, #member, member, dtype)
|
||||
EET_DATA_DESCRIPTOR_ADD_BASIC(edd, type, #member, member, dtype)
|
||||
|
||||
C_VAL(D, T, config_version, EET_T_INT);
|
||||
C_VAL(D, T, thumb_size, EET_T_INT);
|
||||
|
@ -40,20 +39,26 @@ ephoto_config_init(Ephoto *ephoto)
|
|||
C_VAL(D, T, fsel_hide, EET_T_INT);
|
||||
C_VAL(D, T, tool_hide, EET_T_INT);
|
||||
C_VAL(D, T, open, EET_T_STRING);
|
||||
C_VAL(D, T, prompts, EET_T_INT);
|
||||
C_VAL(D, T, drop, EET_T_INT);
|
||||
switch (_ephoto_config_load(ephoto))
|
||||
{
|
||||
case 0:
|
||||
/* Start a new config */
|
||||
ephoto->config->config_version = CONFIG_VERSION;
|
||||
ephoto->config->slideshow_timeout = 4.0;
|
||||
ephoto->config->slideshow_transition = eina_stringshare_add("fade");
|
||||
ephoto->config->window_width = 900;
|
||||
ephoto->config->window_height = 600;
|
||||
ephoto->config->fsel_hide = 0;
|
||||
ephoto->config->tool_hide = 0;
|
||||
break;
|
||||
default:
|
||||
return EINA_TRUE;
|
||||
case 0:
|
||||
/* Start a new config */
|
||||
ephoto->config->config_version = CONFIG_VERSION;
|
||||
ephoto->config->slideshow_timeout = 4.0;
|
||||
ephoto->config->slideshow_transition = eina_stringshare_add("fade");
|
||||
ephoto->config->window_width = 900;
|
||||
ephoto->config->window_height = 600;
|
||||
ephoto->config->fsel_hide = 0;
|
||||
ephoto->config->tool_hide = 0;
|
||||
ephoto->config->open = eina_stringshare_add(getenv("HOME"));
|
||||
ephoto->config->prompts = 1;
|
||||
ephoto->config->drop = 0;
|
||||
break;
|
||||
|
||||
default:
|
||||
return EINA_TRUE;
|
||||
}
|
||||
|
||||
ephoto_config_save(ephoto);
|
||||
|
@ -82,7 +87,8 @@ _close(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|||
}
|
||||
|
||||
static void
|
||||
_save_general(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_save_general(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *popup = data;
|
||||
Ephoto *ephoto = evas_object_data_get(popup, "ephoto");
|
||||
|
@ -90,22 +96,23 @@ _save_general(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UN
|
|||
const char *text = elm_object_text_get(ephoto->config->open_dir);
|
||||
|
||||
if (!strcmp(text, _("Root Directory")))
|
||||
path = "/";
|
||||
path = "/";
|
||||
else if (!strcmp(text, _("Home Directory")))
|
||||
path = getenv("HOME");
|
||||
path = getenv("HOME");
|
||||
else if (!strcmp(text, _("Last Open Directory")))
|
||||
path = "Last";
|
||||
path = "Last";
|
||||
else
|
||||
path = elm_object_text_get(ephoto->config->open_dir_custom);
|
||||
path = elm_object_text_get(ephoto->config->open_dir_custom);
|
||||
|
||||
if (ecore_file_is_dir(path) || !strcmp(path, "Last"))
|
||||
eina_stringshare_replace(&ephoto->config->open, path);
|
||||
ephoto->config->tool_hide = elm_check_state_get(ephoto->config->hide_toolbar);
|
||||
|
||||
eina_stringshare_replace(&ephoto->config->open, path);
|
||||
ephoto->config->tool_hide =
|
||||
elm_check_state_get(ephoto->config->hide_toolbar);
|
||||
ephoto->config->prompts = elm_check_state_get(ephoto->config->show_prompts);
|
||||
ephoto->config->drop = elm_check_state_get(ephoto->config->move_drop);
|
||||
evas_object_del(popup);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_open_hv_select(void *data, Evas_Object *obj, void *event_info)
|
||||
{
|
||||
|
@ -114,15 +121,15 @@ _open_hv_select(void *data, Evas_Object *obj, void *event_info)
|
|||
elm_object_text_set(obj, elm_object_item_text_get(event_info));
|
||||
|
||||
if (!strcmp(elm_object_item_text_get(event_info), _("Custom Directory")))
|
||||
elm_object_disabled_set(ephoto->config->open_dir_custom, EINA_FALSE);
|
||||
elm_object_disabled_set(ephoto->config->open_dir_custom, EINA_FALSE);
|
||||
else
|
||||
elm_object_disabled_set(ephoto->config->open_dir_custom, EINA_TRUE);
|
||||
elm_object_disabled_set(ephoto->config->open_dir_custom, EINA_TRUE);
|
||||
}
|
||||
|
||||
void
|
||||
ephoto_config_general(Ephoto *ephoto)
|
||||
{
|
||||
Evas_Object *popup, *box, *table, *check, *label, *hoversel, *entry, *ic, *button;
|
||||
Evas_Object *popup, *box, *table, *check, *hoversel, *entry, *ic, *button;
|
||||
|
||||
popup = elm_popup_add(ephoto->win);
|
||||
elm_popup_scrollable_set(popup, EINA_TRUE);
|
||||
|
@ -148,17 +155,38 @@ ephoto_config_general(Ephoto *ephoto)
|
|||
evas_object_show(check);
|
||||
ephoto->config->hide_toolbar = check;
|
||||
|
||||
check = elm_check_add(table);
|
||||
elm_object_text_set(check, _("Prompt Before Changing The Filesystem"));
|
||||
evas_object_size_hint_align_set(check, 0.0, EVAS_HINT_FILL);
|
||||
elm_check_state_set(check, ephoto->config->prompts);
|
||||
elm_table_pack(table, check, 0, 2, 1, 1);
|
||||
evas_object_show(check);
|
||||
ephoto->config->show_prompts = check;
|
||||
|
||||
check = elm_check_add(table);
|
||||
elm_object_text_set(check, _("Move Files When Dropped"));
|
||||
evas_object_size_hint_align_set(check, 0.0, EVAS_HINT_FILL);
|
||||
elm_check_state_set(check, ephoto->config->drop);
|
||||
elm_table_pack(table, check, 0, 3, 1, 1);
|
||||
evas_object_show(check);
|
||||
ephoto->config->move_drop = check;
|
||||
|
||||
hoversel = elm_hoversel_add(table);
|
||||
elm_hoversel_hover_parent_set(hoversel, ephoto->win);
|
||||
elm_hoversel_item_add(hoversel, _("Root Directory"), NULL, 0, _open_hv_select, ephoto);
|
||||
elm_hoversel_item_add(hoversel, _("Home Directory"), NULL, 0, _open_hv_select, ephoto);
|
||||
elm_hoversel_item_add(hoversel, _("Last Open Directory"), NULL, 0, _open_hv_select, ephoto);
|
||||
elm_hoversel_item_add(hoversel, _("Custom Directory"), NULL, 0, _open_hv_select, ephoto);
|
||||
elm_hoversel_item_add(hoversel, _("Root Directory"), NULL, 0,
|
||||
_open_hv_select, ephoto);
|
||||
elm_hoversel_item_add(hoversel, _("Home Directory"), NULL, 0,
|
||||
_open_hv_select, ephoto);
|
||||
elm_hoversel_item_add(hoversel, _("Last Open Directory"), NULL, 0,
|
||||
_open_hv_select, ephoto);
|
||||
elm_hoversel_item_add(hoversel, _("Custom Directory"), NULL, 0,
|
||||
_open_hv_select, ephoto);
|
||||
elm_object_text_set(hoversel, _("Directory To Open Ephoto In"));
|
||||
evas_object_data_set(hoversel, "ephoto", ephoto);
|
||||
evas_object_size_hint_weight_set(hoversel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_weight_set(hoversel, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(hoversel, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_table_pack(table, hoversel, 0, 2, 1, 1);
|
||||
elm_table_pack(table, hoversel, 0, 4, 1, 1);
|
||||
evas_object_show(hoversel);
|
||||
ephoto->config->open_dir = hoversel;
|
||||
|
||||
|
@ -167,10 +195,11 @@ ephoto_config_general(Ephoto *ephoto)
|
|||
elm_entry_scrollable_set(entry, EINA_TRUE);
|
||||
elm_object_text_set(entry, _("Custom Directory"));
|
||||
elm_object_disabled_set(entry, EINA_TRUE);
|
||||
elm_scroller_policy_set(entry, ELM_SCROLLER_POLICY_OFF, ELM_SCROLLER_POLICY_OFF);
|
||||
elm_scroller_policy_set(entry, ELM_SCROLLER_POLICY_OFF,
|
||||
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, 3, 1, 1);
|
||||
elm_table_pack(table, entry, 0, 5, 1, 1);
|
||||
evas_object_show(entry);
|
||||
ephoto->config->open_dir_custom = entry;
|
||||
|
||||
|
@ -212,10 +241,11 @@ _save(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|||
Ephoto *ephoto = evas_object_data_get(popup, "ephoto");
|
||||
|
||||
if (elm_spinner_value_get(ephoto->config->slide_time) > 0)
|
||||
ephoto->config->slideshow_timeout = elm_spinner_value_get(ephoto->config->slide_time);
|
||||
ephoto->config->slideshow_timeout =
|
||||
elm_spinner_value_get(ephoto->config->slide_time);
|
||||
if (elm_object_text_get(ephoto->config->slide_trans))
|
||||
eina_stringshare_replace(&ephoto->config->slideshow_transition, elm_object_text_get(ephoto->config->slide_trans));
|
||||
|
||||
eina_stringshare_replace(&ephoto->config->slideshow_transition,
|
||||
elm_object_text_get(ephoto->config->slide_trans));
|
||||
evas_object_del(popup);
|
||||
}
|
||||
|
||||
|
@ -226,7 +256,8 @@ _hv_select(void *data EINA_UNUSED, Evas_Object *obj, void *event_info)
|
|||
}
|
||||
|
||||
static void
|
||||
_spinner_changed(void *data EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
_spinner_changed(void *data EINA_UNUSED, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
double val;
|
||||
char buf[PATH_MAX];
|
||||
|
@ -262,7 +293,7 @@ ephoto_config_slideshow(Ephoto *ephoto)
|
|||
|
||||
label = elm_label_add(table);
|
||||
memset(buf, 0, PATH_MAX);
|
||||
snprintf(buf, PATH_MAX, "<b>%s:</b>", _("Show Each Slide For"));
|
||||
snprintf(buf, PATH_MAX, "%s:", _("Show Each Slide For"));
|
||||
elm_object_text_set(label, buf);
|
||||
evas_object_size_hint_align_set(label, 0.0, EVAS_HINT_FILL);
|
||||
elm_table_pack(table, label, 0, 1, 1, 1);
|
||||
|
@ -283,7 +314,7 @@ ephoto_config_slideshow(Ephoto *ephoto)
|
|||
|
||||
label = elm_label_add(table);
|
||||
memset(buf, 0, PATH_MAX);
|
||||
snprintf(buf, PATH_MAX, "<b>%s:</b>", _("Slide Transition"));
|
||||
snprintf(buf, PATH_MAX, "%s:", _("Slide Transition"));
|
||||
elm_object_text_set(label, buf);
|
||||
evas_object_size_hint_align_set(label, 0.0, EVAS_HINT_FILL);
|
||||
elm_table_pack(table, label, 0, 2, 1, 1);
|
||||
|
@ -291,11 +322,13 @@ ephoto_config_slideshow(Ephoto *ephoto)
|
|||
|
||||
hoversel = elm_hoversel_add(table);
|
||||
elm_hoversel_hover_parent_set(hoversel, ephoto->win);
|
||||
EINA_LIST_FOREACH(elm_slideshow_transitions_get(ephoto->slideshow), l, transition)
|
||||
elm_hoversel_item_add(hoversel, transition, NULL, 0, _hv_select, transition);
|
||||
EINA_LIST_FOREACH(elm_slideshow_transitions_get(ephoto->slideshow), l,
|
||||
transition) elm_hoversel_item_add(hoversel, transition, NULL, 0,
|
||||
_hv_select, transition);
|
||||
elm_hoversel_item_add(hoversel, "None", NULL, 0, _hv_select, NULL);
|
||||
elm_object_text_set(hoversel, ephoto->config->slideshow_transition);
|
||||
evas_object_size_hint_weight_set(hoversel, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_weight_set(hoversel, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(hoversel, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_table_pack(table, hoversel, 1, 2, 1, 1);
|
||||
evas_object_show(hoversel);
|
||||
|
@ -354,52 +387,54 @@ ephoto_config_about(Ephoto *ephoto)
|
|||
evas_object_size_hint_weight_set(label, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(label, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
eina_strbuf_append_printf(sbuf,
|
||||
_("Ephoto is a comprehensive image viewer based on the EFL.<br/>"
|
||||
"For more information, please visit the Ephoto project page on the Enlightenment wiki:<br/>"
|
||||
"https://phab.enlightenment.org/w/projects/ephoto<br/>"
|
||||
"Ephoto's source can be found through Enlightenment's git:<br/>"
|
||||
"http://git.enlightenment.org/apps/ephoto.git<br/>"
|
||||
"<br/>"
|
||||
"<b>Authors:</b><br/>"));
|
||||
_("Ephoto is a comprehensive image viewer based on the EFL.<br/>"
|
||||
"For more information, please visit the Ephoto project page on the Enlightenment wiki:<br/>"
|
||||
"https://phab.enlightenment.org/w/projects/ephoto<br/>"
|
||||
"Ephoto's source can be found through Enlightenment's git:<br/>"
|
||||
"http://git.enlightenment.org/apps/ephoto.git<br/>" "<br/>"
|
||||
"<b>Authors:</b><br/>"));
|
||||
f = fopen(PACKAGE_DATA_DIR "/AUTHORS", "r");
|
||||
if (f)
|
||||
{
|
||||
char buf[PATH_MAX];
|
||||
while (fgets(buf, sizeof(buf), f))
|
||||
{
|
||||
int len;
|
||||
char buf[PATH_MAX];
|
||||
|
||||
len = strlen(buf);
|
||||
if (len > 0)
|
||||
{
|
||||
if (buf[len - 1] == '\n')
|
||||
{
|
||||
buf[len - 1] = 0;
|
||||
len--;
|
||||
}
|
||||
if (len > 0)
|
||||
{
|
||||
char *p;
|
||||
while (fgets(buf, sizeof(buf), f))
|
||||
{
|
||||
int len;
|
||||
|
||||
do
|
||||
{
|
||||
p = strchr(buf, '<');
|
||||
if (p) *p = 0;
|
||||
}
|
||||
while (p);
|
||||
do
|
||||
{
|
||||
p = strchr(buf, '>');
|
||||
if (p) *p = 0;
|
||||
}
|
||||
while (p);
|
||||
eina_strbuf_append_printf(sbuf, "%s<br>", buf);
|
||||
}
|
||||
if (len == 0)
|
||||
eina_strbuf_append_printf(sbuf, "<br>");
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
len = strlen(buf);
|
||||
if (len > 0)
|
||||
{
|
||||
if (buf[len - 1] == '\n')
|
||||
{
|
||||
buf[len - 1] = 0;
|
||||
len--;
|
||||
}
|
||||
if (len > 0)
|
||||
{
|
||||
char *p;
|
||||
|
||||
do
|
||||
{
|
||||
p = strchr(buf, '<');
|
||||
if (p)
|
||||
*p = 0;
|
||||
}
|
||||
while (p);
|
||||
do
|
||||
{
|
||||
p = strchr(buf, '>');
|
||||
if (p)
|
||||
*p = 0;
|
||||
}
|
||||
while (p);
|
||||
eina_strbuf_append_printf(sbuf, "%s<br>", buf);
|
||||
}
|
||||
if (len == 0)
|
||||
eina_strbuf_append_printf(sbuf, "<br>");
|
||||
}
|
||||
}
|
||||
fclose(f);
|
||||
}
|
||||
elm_object_text_set(label, eina_strbuf_string_get(sbuf));
|
||||
elm_box_pack_end(box, label);
|
||||
|
@ -435,9 +470,9 @@ _ephoto_config_load(Ephoto *ephoto)
|
|||
ef = eet_open(buf, EET_FILE_MODE_READ);
|
||||
if (!ef)
|
||||
{
|
||||
ephoto_config_free(ephoto);
|
||||
ephoto->config = calloc(1, sizeof(Ephoto_Config));
|
||||
return 0;
|
||||
ephoto_config_free(ephoto);
|
||||
ephoto->config = calloc(1, sizeof(Ephoto_Config));
|
||||
return 0;
|
||||
}
|
||||
|
||||
ephoto->config = eet_data_read(ef, edd, "config");
|
||||
|
@ -445,17 +480,17 @@ _ephoto_config_load(Ephoto *ephoto)
|
|||
|
||||
if (!ephoto->config || ephoto->config->config_version > CONFIG_VERSION)
|
||||
{
|
||||
ephoto_config_free(ephoto);
|
||||
ephoto->config = calloc(1, sizeof(Ephoto_Config));
|
||||
return 0;
|
||||
ephoto_config_free(ephoto);
|
||||
ephoto->config = calloc(1, sizeof(Ephoto_Config));
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (ephoto->config->config_version < CONFIG_VERSION)
|
||||
{
|
||||
ecore_file_unlink(buf);
|
||||
ephoto_config_free(ephoto);
|
||||
ephoto->config = calloc(1, sizeof(Ephoto_Config));
|
||||
return 0;
|
||||
ecore_file_unlink(buf);
|
||||
ephoto_config_free(ephoto);
|
||||
ephoto->config = calloc(1, sizeof(Ephoto_Config));
|
||||
return 0;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -471,16 +506,17 @@ _ephoto_on_config_save(void *data)
|
|||
snprintf(buf2, sizeof(buf2), "%s.tmp", buf);
|
||||
|
||||
ef = eet_open(buf2, EET_FILE_MODE_WRITE);
|
||||
if (!ef) goto save_end;
|
||||
if (!ef)
|
||||
goto save_end;
|
||||
|
||||
eet_data_write(ef, edd, "config", ephoto->config, 1);
|
||||
if (eet_close(ef)) goto save_end;
|
||||
if (eet_close(ef))
|
||||
goto save_end;
|
||||
|
||||
if (!ecore_file_mv(buf2, buf)) goto save_end;
|
||||
if (!ecore_file_mv(buf2, buf))
|
||||
goto save_end;
|
||||
|
||||
INF("Config saved");
|
||||
|
||||
save_end:
|
||||
save_end:
|
||||
ecore_file_unlink(buf2);
|
||||
|
||||
return ECORE_CALLBACK_CANCEL;
|
||||
|
|
|
@ -21,38 +21,40 @@ struct _Ephoto_Cropper
|
|||
};
|
||||
|
||||
static void
|
||||
_calculate_cropper_size(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
_calculate_cropper_size(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
Edje_Message_Int_Set *msg;
|
||||
char buf[PATH_MAX];
|
||||
int w, h, cw, ch, iw, ih, nw, nh;
|
||||
double scalew, scaleh;
|
||||
|
||||
evas_object_geometry_get(ec->layout, 0, 0, &w, &h);
|
||||
edje_object_part_geometry_get(elm_layout_edje_get(ec->layout),
|
||||
"ephoto.swallow.cropper", 0, 0, &cw, &ch);
|
||||
"ephoto.swallow.cropper", 0, 0, &cw, &ch);
|
||||
evas_object_image_size_get(elm_image_object_get(ec->image), &iw, &ih);
|
||||
|
||||
scalew = (double)cw/(double)w;
|
||||
scaleh = (double)ch/(double)h;
|
||||
scalew = (double) cw / (double) w;
|
||||
scaleh = (double) ch / (double) h;
|
||||
|
||||
nw = iw*scalew;
|
||||
nh = ih*scaleh;
|
||||
nw = iw * scalew;
|
||||
nh = ih * scaleh;
|
||||
|
||||
elm_slider_value_set(ec->cropw, nw);
|
||||
elm_slider_value_set(ec->croph, nh);
|
||||
|
||||
msg = alloca(sizeof(Edje_Message_Int_Set) + (3*sizeof(int)));
|
||||
msg = alloca(sizeof(Edje_Message_Int_Set) + (3 * sizeof(int)));
|
||||
msg->count = 3;
|
||||
msg->val[0] = 11;
|
||||
msg->val[1] = nw;
|
||||
msg->val[2] = nh;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_changed_width(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_cropper_changed_width(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
Edje_Message_Int_Set *msgl, *msgr;
|
||||
|
@ -65,45 +67,48 @@ _cropper_changed_width(void *data, Evas_Object *obj EINA_UNUSED, void *event_inf
|
|||
evas_object_geometry_get(ec->cropper, &cx, 0, &cw, 0);
|
||||
evas_object_image_size_get(elm_image_object_get(ec->image), &iw, 0);
|
||||
|
||||
scalew = (double)mw/(double)iw;
|
||||
scalew = (double) mw / (double) iw;
|
||||
|
||||
nw = lw*scalew;
|
||||
left = (nw-cw)/2;
|
||||
right = (nw-cw)/2;
|
||||
nw = lw * scalew;
|
||||
left = (nw - cw) / 2;
|
||||
right = (nw - cw) / 2;
|
||||
|
||||
if ((cx+cw+right) >= (lx+lw))
|
||||
if ((cx + cw + right) >= (lx + lw))
|
||||
{
|
||||
right = (lx+lw)-(cx+cw);
|
||||
left += left - right;
|
||||
right = (lx + lw) - (cx + cw);
|
||||
left += left - right;
|
||||
}
|
||||
else if ((cx-left) <= lx)
|
||||
else if ((cx - left) <= lx)
|
||||
{
|
||||
left = cx-lx;
|
||||
right += right - left;
|
||||
left = cx - lx;
|
||||
right += right - left;
|
||||
}
|
||||
left *= -1;
|
||||
|
||||
msgl = alloca(sizeof(Edje_Message_Int_Set) + (3*sizeof(int)));
|
||||
msgl = alloca(sizeof(Edje_Message_Int_Set) + (3 * sizeof(int)));
|
||||
msgl->count = 3;
|
||||
msgl->val[0] = 8;
|
||||
msgl->val[1] = left;
|
||||
msgl->val[2] = 0;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msgl);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msgl);
|
||||
|
||||
msgr = alloca(sizeof(Edje_Message_Int_Set) + (3*sizeof(int)));
|
||||
msgr = alloca(sizeof(Edje_Message_Int_Set) + (3 * sizeof(int)));
|
||||
msgr->count = 3;
|
||||
msgr->val[0] = 4;
|
||||
msgr->val[1] = right;
|
||||
msgr->val[2] = 0;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msgr);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msgr);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_changed_height(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_cropper_changed_height(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
Edje_Message_Int_Set *msgt, *msgb;
|
||||
int mh, ch, cy, nh, lh, ly, ih, left, top, bottom;
|
||||
int mh, ch, cy, nh, lh, ly, ih, top, bottom;
|
||||
double scaleh;
|
||||
|
||||
mh = elm_slider_value_get(ec->croph);
|
||||
|
@ -112,98 +117,105 @@ _cropper_changed_height(void *data, Evas_Object *obj EINA_UNUSED, void *event_in
|
|||
evas_object_geometry_get(ec->cropper, 0, &cy, 0, &ch);
|
||||
evas_object_image_size_get(elm_image_object_get(ec->image), 0, &ih);
|
||||
|
||||
scaleh = (double)mh/(double)ih;
|
||||
nh = lh*scaleh;
|
||||
top = (nh-ch)/2;
|
||||
bottom = (nh-ch)/2;
|
||||
scaleh = (double) mh / (double) ih;
|
||||
nh = lh * scaleh;
|
||||
top = (nh - ch) / 2;
|
||||
bottom = (nh - ch) / 2;
|
||||
|
||||
if ((cy+ch+bottom) >= (ly+lh))
|
||||
if ((cy + ch + bottom) >= (ly + lh))
|
||||
{
|
||||
bottom = (ly+lh)-(cy+ch);
|
||||
top += top - bottom;
|
||||
bottom = (ly + lh) - (cy + ch);
|
||||
top += top - bottom;
|
||||
}
|
||||
else if ((cy-top) <= ly)
|
||||
else if ((cy - top) <= ly)
|
||||
{
|
||||
top = cy-ly;
|
||||
bottom += bottom - top;
|
||||
top = cy - ly;
|
||||
bottom += bottom - top;
|
||||
}
|
||||
top *= -1;
|
||||
|
||||
msgt = alloca(sizeof(Edje_Message_Int_Set) + (3*sizeof(int)));
|
||||
msgt = alloca(sizeof(Edje_Message_Int_Set) + (3 * sizeof(int)));
|
||||
msgt->count = 3;
|
||||
msgt->val[0] = 2;
|
||||
msgt->val[1] = 0;
|
||||
msgt->val[2] = top;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msgt);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msgt);
|
||||
|
||||
msgb = alloca(sizeof(Edje_Message_Int_Set) + (3*sizeof(int)));
|
||||
msgb = alloca(sizeof(Edje_Message_Int_Set) + (3 * sizeof(int)));
|
||||
msgb->count = 3;
|
||||
msgb->val[0] = 6;
|
||||
msgb->val[1] = 0;
|
||||
msgb->val[2] = bottom;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msgb);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msgb);
|
||||
}
|
||||
|
||||
static void
|
||||
_reset_crop(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_reset_crop(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
Edje_Message_Int_Set *msg;
|
||||
|
||||
msg = alloca(sizeof(Edje_Message_Int_Set) + (3*sizeof(int)));
|
||||
msg = alloca(sizeof(Edje_Message_Int_Set) + (3 * sizeof(int)));
|
||||
msg->count = 3;
|
||||
msg->val[0] = 10;
|
||||
msg->val[1] = 0;
|
||||
msg->val[2] = 0;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
}
|
||||
|
||||
static void
|
||||
_apply_crop(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_apply_crop(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
Evas_Object *edje = elm_layout_edje_get(ec->layout);
|
||||
|
||||
const char *path, *key, *type;;
|
||||
int x, y, w, h, cx, cy, cw, ch, iw, ih;
|
||||
int nx, ny, nw, nh, i, j, tmpx, tmpy, ind, index;
|
||||
double scalex, scaley, scalew, scaleh;
|
||||
unsigned int *idata, *idata_new;
|
||||
|
||||
evas_object_geometry_get(ec->layout, &x, &y, &w, &h);
|
||||
edje_object_part_geometry_get(edje, "ephoto.swallow.cropper", &cx, &cy, &cw, &ch);
|
||||
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);
|
||||
|
||||
idata = evas_object_image_data_get(elm_image_object_get(ec->image), EINA_FALSE);
|
||||
idata =
|
||||
evas_object_image_data_get(elm_image_object_get(ec->image), EINA_FALSE);
|
||||
|
||||
scalex = (double)cx/(double)w;
|
||||
scaley = (double)cy/(double)h;
|
||||
scalew = (double)cw/(double)w;
|
||||
scaleh = (double)ch/(double)h;
|
||||
scalex = (double) cx / (double) w;
|
||||
scaley = (double) cy / (double) h;
|
||||
scalew = (double) cw / (double) w;
|
||||
scaleh = (double) ch / (double) h;
|
||||
|
||||
nx = iw*scalex;
|
||||
ny = ih*scaley;
|
||||
nw = iw*scalew;
|
||||
nh = ih*scaleh;
|
||||
nx = iw * scalex;
|
||||
ny = ih * scaley;
|
||||
nw = iw * scalew;
|
||||
nh = ih * scaleh;
|
||||
|
||||
index = 0;
|
||||
idata_new = malloc(sizeof(unsigned int)*nw*nh);
|
||||
idata_new = malloc(sizeof(unsigned int) * nw * nh);
|
||||
|
||||
for (i = 0; i < nh; i++)
|
||||
{
|
||||
tmpy = (i+ny)*iw;
|
||||
for (j = 0; j < nw; j++)
|
||||
{
|
||||
tmpx = j+nx;
|
||||
ind = tmpy+tmpx;
|
||||
idata_new[index] = idata[ind];
|
||||
index++;
|
||||
}
|
||||
tmpy = (i + ny) * iw;
|
||||
for (j = 0; j < nw; j++)
|
||||
{
|
||||
tmpx = j + nx;
|
||||
ind = tmpy + tmpx;
|
||||
idata_new[index] = idata[ind];
|
||||
index++;
|
||||
}
|
||||
}
|
||||
elm_table_unpack(ec->image_parent, ec->box);
|
||||
elm_layout_content_unset(ec->layout, "ephoto.swallow.image");
|
||||
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);
|
||||
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);
|
||||
|
@ -211,7 +223,8 @@ _apply_crop(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUS
|
|||
}
|
||||
|
||||
static void
|
||||
_cancel_crop(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_cancel_crop(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
|
||||
|
@ -226,7 +239,8 @@ _cancel_crop(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNU
|
|||
}
|
||||
|
||||
static void
|
||||
_cropper_both_mouse_move(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source)
|
||||
_cropper_both_mouse_move(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
Edje_Message_Int_Set *msg;
|
||||
|
@ -237,47 +251,52 @@ _cropper_both_mouse_move(void *data, Evas_Object *obj EINA_UNUSED, const char *e
|
|||
evas_object_geometry_get(ec->layout, &lx, &ly, &lw, &lh);
|
||||
|
||||
if (mx < lx)
|
||||
mx = lx;
|
||||
else if (mx > lx+lw)
|
||||
mx = lx+lw;
|
||||
mx = lx;
|
||||
else if (mx > lx + lw)
|
||||
mx = lx + lw;
|
||||
if (my < ly)
|
||||
my = ly;
|
||||
else if (my > ly+lh)
|
||||
my = ly+lh;
|
||||
my = ly;
|
||||
else if (my > ly + lh)
|
||||
my = ly + lh;
|
||||
|
||||
nx = mx-ec->startx;
|
||||
ny = my-ec->starty;
|
||||
nx = mx - ec->startx;
|
||||
ny = my - ec->starty;
|
||||
ec->startx = mx;
|
||||
ec->starty = my;
|
||||
|
||||
msg = alloca(sizeof(Edje_Message_Int_Set) + (3*sizeof(int)));
|
||||
msg = alloca(sizeof(Edje_Message_Int_Set) + (3 * sizeof(int)));
|
||||
msg->count = 3;
|
||||
if (!strcmp(source, "handle1"))
|
||||
msg->val[0] = 1;
|
||||
msg->val[0] = 1;
|
||||
else if (!strcmp(source, "handle3"))
|
||||
msg->val[0] = 3;
|
||||
msg->val[0] = 3;
|
||||
else if (!strcmp(source, "handle5"))
|
||||
msg->val[0] = 5;
|
||||
msg->val[0] = 5;
|
||||
else if (!strcmp(source, "handle7"))
|
||||
msg->val[0] = 7;
|
||||
msg->val[0] = 7;
|
||||
|
||||
msg->val[1] = nx;
|
||||
msg->val[2] = ny;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_both_mouse_up(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source)
|
||||
_cropper_both_mouse_up(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,move", source, _cropper_both_mouse_move, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,up,1", source, _cropper_both_mouse_up, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,move", source,
|
||||
_cropper_both_mouse_move, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,up,1", source,
|
||||
_cropper_both_mouse_up, ec);
|
||||
ec->resizing = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_resize_both(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source)
|
||||
_cropper_resize_both(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
int mx, my, cx, cy;
|
||||
|
@ -285,17 +304,20 @@ _cropper_resize_both(void *data, Evas_Object *obj EINA_UNUSED, const char *emiss
|
|||
ec->resizing = 1;
|
||||
evas_pointer_canvas_xy_get(evas_object_evas_get(ec->cropper), &mx, &my);
|
||||
evas_object_geometry_get(ec->cropper, &cx, &cy, 0, 0);
|
||||
ec->offsetx = mx-cx;
|
||||
ec->offsety = my-cy;
|
||||
ec->offsetx = mx - cx;
|
||||
ec->offsety = my - cy;
|
||||
ec->startx = mx;
|
||||
ec->starty = my;
|
||||
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,move", source, _cropper_both_mouse_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,up,1", source, _cropper_both_mouse_up, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,move", source,
|
||||
_cropper_both_mouse_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,up,1", source,
|
||||
_cropper_both_mouse_up, ec);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_horiz_mouse_move(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source)
|
||||
_cropper_horiz_mouse_move(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
Edje_Message_Int_Set *msg;
|
||||
|
@ -306,36 +328,41 @@ _cropper_horiz_mouse_move(void *data, Evas_Object *obj EINA_UNUSED, const char *
|
|||
evas_object_geometry_get(ec->layout, &lx, 0, &lw, 0);
|
||||
|
||||
if (mx < lx)
|
||||
mx = lx;
|
||||
else if (mx > lx+lw)
|
||||
mx = lx+lw;
|
||||
mx = lx;
|
||||
else if (mx > lx + lw)
|
||||
mx = lx + lw;
|
||||
|
||||
nx = mx-ec->startx;
|
||||
nx = mx - ec->startx;
|
||||
ec->startx = mx;
|
||||
|
||||
msg = alloca(sizeof(Edje_Message_Int_Set) + (3*sizeof(int)));
|
||||
msg = alloca(sizeof(Edje_Message_Int_Set) + (3 * sizeof(int)));
|
||||
msg->count = 3;
|
||||
if (!strcmp(source, "handle4"))
|
||||
msg->val[0] = 4;
|
||||
msg->val[0] = 4;
|
||||
else if (!strcmp(source, "handle8"))
|
||||
msg->val[0] = 8;
|
||||
msg->val[0] = 8;
|
||||
msg->val[1] = nx;
|
||||
msg->val[2] = 0;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_horiz_mouse_up(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source)
|
||||
_cropper_horiz_mouse_up(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,move", source, _cropper_horiz_mouse_move, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,up,1", source, _cropper_horiz_mouse_up, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,move", source,
|
||||
_cropper_horiz_mouse_move, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,up,1", source,
|
||||
_cropper_horiz_mouse_up, ec);
|
||||
ec->resizing = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_resize_horiz(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
_cropper_resize_horiz(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
int mx, my, cx, cy;
|
||||
|
@ -343,17 +370,20 @@ _cropper_resize_horiz(void *data, Evas_Object *obj EINA_UNUSED, const char *emis
|
|||
ec->resizing = 1;
|
||||
evas_pointer_canvas_xy_get(evas_object_evas_get(ec->cropper), &mx, &my);
|
||||
evas_object_geometry_get(ec->cropper, &cx, &cy, 0, 0);
|
||||
ec->offsetx = mx-cx;
|
||||
ec->offsety = my-cy;
|
||||
ec->offsetx = mx - cx;
|
||||
ec->offsety = my - cy;
|
||||
ec->startx = mx;
|
||||
ec->starty = my;
|
||||
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,move", source, _cropper_horiz_mouse_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,up,1", source, _cropper_horiz_mouse_up, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,move", source,
|
||||
_cropper_horiz_mouse_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,up,1", source,
|
||||
_cropper_horiz_mouse_up, ec);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_vert_mouse_move(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source)
|
||||
_cropper_vert_mouse_move(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
Edje_Message_Int_Set *msg;
|
||||
|
@ -364,36 +394,41 @@ _cropper_vert_mouse_move(void *data, Evas_Object *obj EINA_UNUSED, const char *e
|
|||
evas_object_geometry_get(ec->layout, 0, &ly, 0, &lh);
|
||||
|
||||
if (my < ly)
|
||||
my = ly;
|
||||
else if (my > ly+lh)
|
||||
my = ly+lh;
|
||||
my = ly;
|
||||
else if (my > ly + lh)
|
||||
my = ly + lh;
|
||||
|
||||
ny = my-ec->starty;
|
||||
ny = my - ec->starty;
|
||||
ec->starty = my;
|
||||
|
||||
msg = alloca(sizeof(Edje_Message_Int_Set) + (3*sizeof(int)));
|
||||
msg = alloca(sizeof(Edje_Message_Int_Set) + (3 * sizeof(int)));
|
||||
msg->count = 3;
|
||||
if (!strcmp(source, "handle2"))
|
||||
msg->val[0] = 2;
|
||||
msg->val[0] = 2;
|
||||
else if (!strcmp(source, "handle6"))
|
||||
msg->val[0] = 6;
|
||||
msg->val[0] = 6;
|
||||
msg->val[1] = 0;
|
||||
msg->val[2] = ny;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_vert_mouse_up(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source)
|
||||
_cropper_vert_mouse_up(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,move", source, _cropper_vert_mouse_move, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,up,1", source, _cropper_vert_mouse_up, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,move", source,
|
||||
_cropper_vert_mouse_move, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,up,1", source,
|
||||
_cropper_vert_mouse_up, ec);
|
||||
ec->resizing = 0;
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_resize_vert(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
_cropper_resize_vert(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
int mx, my, cx, cy;
|
||||
|
@ -401,63 +436,71 @@ _cropper_resize_vert(void *data, Evas_Object *obj EINA_UNUSED, const char *emiss
|
|||
ec->resizing = 1;
|
||||
evas_pointer_canvas_xy_get(evas_object_evas_get(ec->cropper), &mx, &my);
|
||||
evas_object_geometry_get(ec->cropper, &cx, &cy, 0, 0);
|
||||
ec->offsetx = mx-cx;
|
||||
ec->offsety = my-cy;
|
||||
ec->offsetx = mx - cx;
|
||||
ec->offsety = my - cy;
|
||||
ec->startx = mx;
|
||||
ec->starty = my;
|
||||
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,move", source, _cropper_vert_mouse_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,up,1", source, _cropper_vert_mouse_up, ec);
|
||||
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,move", source,
|
||||
_cropper_vert_mouse_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,up,1", source,
|
||||
_cropper_vert_mouse_up, ec);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_mouse_move(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
_cropper_mouse_move(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
|
||||
if (!ec->resizing)
|
||||
{
|
||||
Edje_Message_Int_Set *msg;
|
||||
int mx, my, cx, cy, cw, ch, nx, ny, lx, ly, lw, lh;
|
||||
Edje_Message_Int_Set *msg;
|
||||
int mx, my, cx, cy, cw, ch, nx, ny, lx, ly, lw, lh;
|
||||
|
||||
evas_pointer_canvas_xy_get(evas_object_evas_get(ec->cropper), &mx, &my);
|
||||
evas_object_geometry_get(ec->cropper, &cx, &cy, &cw, &ch);
|
||||
evas_object_geometry_get(ec->layout, &lx, &ly, &lw, &lh);
|
||||
evas_pointer_canvas_xy_get(evas_object_evas_get(ec->cropper), &mx, &my);
|
||||
evas_object_geometry_get(ec->cropper, &cx, &cy, &cw, &ch);
|
||||
evas_object_geometry_get(ec->layout, &lx, &ly, &lw, &lh);
|
||||
|
||||
if (mx < lx)
|
||||
mx = lx;
|
||||
else if (mx > lx+lw)
|
||||
mx = lx+lw;
|
||||
if (my < ly)
|
||||
my = ly;
|
||||
else if (my > ly+lh)
|
||||
my = ly+lh;
|
||||
if (mx < lx)
|
||||
mx = lx;
|
||||
else if (mx > lx + lw)
|
||||
mx = lx + lw;
|
||||
if (my < ly)
|
||||
my = ly;
|
||||
else if (my > ly + lh)
|
||||
my = ly + lh;
|
||||
|
||||
nx = mx-ec->startx;
|
||||
ny = my-ec->starty;
|
||||
ec->startx = mx;
|
||||
ec->starty = my;
|
||||
nx = mx - ec->startx;
|
||||
ny = my - ec->starty;
|
||||
ec->startx = mx;
|
||||
ec->starty = my;
|
||||
|
||||
msg = alloca(sizeof(Edje_Message_Int_Set) + (3*sizeof(int)));
|
||||
msg->count = 3;
|
||||
msg->val[0] = 0;
|
||||
msg->val[1] = nx;
|
||||
msg->val[2] = ny;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
msg = alloca(sizeof(Edje_Message_Int_Set) + (3 * sizeof(int)));
|
||||
msg->count = 3;
|
||||
msg->val[0] = 0;
|
||||
msg->val[1] = nx;
|
||||
msg->val[2] = ny;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_mouse_up(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
_cropper_mouse_up(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,move", "dragger", _cropper_mouse_move, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,up,1", "dragger", _cropper_mouse_up, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,move", "dragger",
|
||||
_cropper_mouse_move, ec);
|
||||
edje_object_signal_callback_del_full(ec->cropper, "mouse,up,1", "dragger",
|
||||
_cropper_mouse_up, ec);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_move(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
_cropper_move(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
const char *emission EINA_UNUSED, const char *source EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
int mx, my, cx, cy;
|
||||
|
@ -466,15 +509,18 @@ _cropper_move(void *data, Evas_Object *obj EINA_UNUSED, const char *emission EIN
|
|||
evas_object_geometry_get(ec->cropper, &cx, &cy, 0, 0);
|
||||
ec->startx = mx;
|
||||
ec->starty = my;
|
||||
ec->offsetx = mx-cx;
|
||||
ec->offsety = my-cy;
|
||||
ec->offsetx = mx - cx;
|
||||
ec->offsety = my - cy;
|
||||
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,move", "dragger", _cropper_mouse_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,up,1", "dragger", _cropper_mouse_up, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,move", "dragger",
|
||||
_cropper_mouse_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,up,1", "dragger",
|
||||
_cropper_mouse_up, ec);
|
||||
}
|
||||
|
||||
static void
|
||||
_image_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_image_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
Edje_Message_Int_Set *msg;
|
||||
|
@ -485,59 +531,66 @@ _image_resize(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, voi
|
|||
evas_object_image_size_get(elm_image_object_get(ec->image), &iw, &ih);
|
||||
|
||||
int nw, nh;
|
||||
|
||||
if (sw > sh)
|
||||
{
|
||||
nw = sw;
|
||||
nh = ih*((double)sw/(double)iw);
|
||||
if (nh > sh)
|
||||
{
|
||||
int onw, onh;
|
||||
onw = nw;
|
||||
onh = nh;
|
||||
nh = sh;
|
||||
nw = onw*((double)nh/(double)onh);
|
||||
}
|
||||
nw = sw;
|
||||
nh = ih * ((double) sw / (double) iw);
|
||||
if (nh > sh)
|
||||
{
|
||||
int onw, onh;
|
||||
|
||||
onw = nw;
|
||||
onh = nh;
|
||||
nh = sh;
|
||||
nw = onw * ((double) nh / (double) onh);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nh = sh;
|
||||
nw = iw*((double)sh/(double)ih);
|
||||
if (nw > sw)
|
||||
{
|
||||
int onw, onh;
|
||||
onw = nw;
|
||||
onh = nh;
|
||||
nw = sw;
|
||||
nh = onh*((double)nw/(double)onw);
|
||||
}
|
||||
nh = sh;
|
||||
nw = iw * ((double) sh / (double) ih);
|
||||
if (nw > sw)
|
||||
{
|
||||
int onw, onh;
|
||||
|
||||
onw = nw;
|
||||
onh = nh;
|
||||
nw = sw;
|
||||
nh = onh * ((double) nw / (double) onw);
|
||||
}
|
||||
}
|
||||
diffw = sw-nw;
|
||||
diffh = sh-nh;
|
||||
diffw = sw - nw;
|
||||
diffh = sh - nh;
|
||||
diffw /= 2;
|
||||
diffh /= 2;
|
||||
ix = sx+diffw;
|
||||
iy = sy+diffh;
|
||||
ix = sx + diffw;
|
||||
iy = sy + diffh;
|
||||
|
||||
evas_object_resize(ec->layout, nw, nh);
|
||||
evas_object_move(ec->layout, ix, iy);
|
||||
|
||||
msg = alloca(sizeof(Edje_Message_Int_Set) + (3*sizeof(int)));
|
||||
msg = alloca(sizeof(Edje_Message_Int_Set) + (3 * sizeof(int)));
|
||||
msg->count = 3;
|
||||
msg->val[0] = 9;
|
||||
msg->val[1] = 0;
|
||||
msg->val[2] = 0;
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout), EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
edje_object_message_send(elm_layout_edje_get(ec->layout),
|
||||
EDJE_MESSAGE_INT_SET, 1, msg);
|
||||
}
|
||||
|
||||
static void
|
||||
_cropper_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_cropper_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Cropper *ec = data;
|
||||
|
||||
free(ec);
|
||||
}
|
||||
|
||||
void
|
||||
ephoto_cropper_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image_parent, Evas_Object *image)
|
||||
ephoto_cropper_add(Evas_Object *main, Evas_Object *parent,
|
||||
Evas_Object *image_parent, Evas_Object *image)
|
||||
{
|
||||
Evas_Object *vbox, *ic, *button;
|
||||
Ephoto_Cropper *ec;
|
||||
|
@ -559,40 +612,57 @@ ephoto_cropper_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image_pa
|
|||
ec->box = elm_box_add(image_parent);
|
||||
elm_box_homogeneous_set(ec->box, EINA_TRUE);
|
||||
elm_box_horizontal_set(ec->box, EINA_TRUE);
|
||||
evas_object_size_hint_weight_set(ec->box, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_weight_set(ec->box, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(ec->box, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_table_pack(image_parent, ec->box, 0, 0, 1, 1);
|
||||
evas_object_show(ec->box);
|
||||
|
||||
ec->layout = elm_layout_add(ec->box);
|
||||
elm_layout_file_set(ec->layout, PACKAGE_DATA_DIR "/themes/crop.edj", "ephoto,image,cropper,base");
|
||||
evas_object_size_hint_weight_set(ec->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
elm_layout_file_set(ec->layout, PACKAGE_DATA_DIR "/themes/crop.edj",
|
||||
"ephoto,image,cropper,base");
|
||||
evas_object_size_hint_weight_set(ec->layout, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(ec->layout, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_box_pack_end(ec->box, ec->layout);
|
||||
evas_object_show(ec->layout);
|
||||
|
||||
evas_object_size_hint_weight_set(ec->image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_weight_set(ec->image, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(ec->image, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_layout_content_set(ec->layout, "ephoto.swallow.image", ec->image);
|
||||
evas_object_show(ec->image);
|
||||
|
||||
ec->cropper = edje_object_add(evas_object_evas_get(ec->layout));
|
||||
edje_object_file_set(ec->cropper, PACKAGE_DATA_DIR "/themes/crop.edj", "ephoto,image,cropper");
|
||||
edje_object_signal_callback_add(elm_layout_edje_get(ec->layout), "cropper,changed", "ephoto.swallow.cropper", _calculate_cropper_size, ec);
|
||||
edje_object_file_set(ec->cropper, PACKAGE_DATA_DIR "/themes/crop.edj",
|
||||
"ephoto,image,cropper");
|
||||
edje_object_signal_callback_add(elm_layout_edje_get(ec->layout),
|
||||
"cropper,changed", "ephoto.swallow.cropper", _calculate_cropper_size,
|
||||
ec);
|
||||
elm_layout_content_set(ec->layout, "ephoto.swallow.cropper", ec->cropper);
|
||||
evas_object_show(ec->cropper);
|
||||
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "dragger", _cropper_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle1", _cropper_resize_both, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle2", _cropper_resize_vert, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle3", _cropper_resize_both, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle4", _cropper_resize_horiz, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle5", _cropper_resize_both, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle6", _cropper_resize_vert, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle7", _cropper_resize_both, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle8", _cropper_resize_horiz, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "dragger",
|
||||
_cropper_move, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle1",
|
||||
_cropper_resize_both, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle2",
|
||||
_cropper_resize_vert, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle3",
|
||||
_cropper_resize_both, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle4",
|
||||
_cropper_resize_horiz, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle5",
|
||||
_cropper_resize_both, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle6",
|
||||
_cropper_resize_vert, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle7",
|
||||
_cropper_resize_both, ec);
|
||||
edje_object_signal_callback_add(ec->cropper, "mouse,down,1", "handle8",
|
||||
_cropper_resize_horiz, ec);
|
||||
|
||||
evas_object_event_callback_add(ec->layout, EVAS_CALLBACK_RESIZE, _image_resize, ec);
|
||||
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);
|
||||
|
@ -615,10 +685,12 @@ ephoto_cropper_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image_pa
|
|||
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_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_smart_callback_add(ec->cropw, "slider,drag,stop",
|
||||
_cropper_changed_width, ec);
|
||||
evas_object_show(ec->cropw);
|
||||
|
||||
ec->croph = elm_slider_add(vbox);
|
||||
|
@ -626,10 +698,12 @@ ephoto_cropper_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image_pa
|
|||
elm_slider_step_set(ec->croph, 1);
|
||||
elm_slider_unit_format_set(ec->croph, "%1.0f");
|
||||
elm_object_text_set(ec->croph, _("Height"));
|
||||
evas_object_size_hint_weight_set(ec->croph, EVAS_HINT_EXPAND, EVAS_HINT_FILL);
|
||||
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);
|
||||
evas_object_smart_callback_add(ec->croph, "slider,drag,stop", _cropper_changed_height, ec);
|
||||
evas_object_smart_callback_add(ec->croph, "slider,drag,stop",
|
||||
_cropper_changed_height, ec);
|
||||
evas_object_show(ec->croph);
|
||||
|
||||
ic = elm_icon_add(vbox);
|
||||
|
@ -676,6 +750,6 @@ ephoto_cropper_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image_pa
|
|||
|
||||
return;
|
||||
|
||||
error:
|
||||
return;
|
||||
error:
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -4,29 +4,29 @@ static int
|
|||
_normalize_color(int color)
|
||||
{
|
||||
if (color < 0)
|
||||
return 0;
|
||||
return 0;
|
||||
else if (color > 255)
|
||||
return 255;
|
||||
return 255;
|
||||
else
|
||||
return color;
|
||||
return color;
|
||||
}
|
||||
|
||||
static int
|
||||
_mul_color_alpha(int color, int alpha)
|
||||
{
|
||||
if (alpha > 0 && alpha < 255)
|
||||
return (color * (255 / alpha));
|
||||
return color * (255 / alpha);
|
||||
else
|
||||
return color;
|
||||
return color;
|
||||
}
|
||||
|
||||
static int
|
||||
_demul_color_alpha(int color, int alpha)
|
||||
{
|
||||
if (alpha > 0 && alpha < 255)
|
||||
return ((color * alpha) / 255);
|
||||
return (color * alpha) / 255;
|
||||
else
|
||||
return color;
|
||||
return color;
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -38,7 +38,8 @@ ephoto_filter_blur(Evas_Object *main, Evas_Object *image)
|
|||
int a, r, g, b;
|
||||
int *as, *rs, *gs, *bs;
|
||||
|
||||
im_data = evas_object_image_data_get(elm_image_object_get(image), EINA_FALSE);
|
||||
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);
|
||||
|
||||
im_data_new = malloc(sizeof(unsigned int) * w * h);
|
||||
|
@ -49,77 +50,78 @@ ephoto_filter_blur(Evas_Object *main, Evas_Object *image)
|
|||
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
my = y - rad;
|
||||
mh = (rad << 1) + 1;
|
||||
if (my < 0)
|
||||
{
|
||||
mh += my;
|
||||
my = 0;
|
||||
}
|
||||
if ((my + mh) > h)
|
||||
{
|
||||
mh = h - my;
|
||||
}
|
||||
p1 = im_data_new + (y * w);
|
||||
memset(as, 0, w * sizeof(int));
|
||||
memset(rs, 0, w * sizeof(int));
|
||||
memset(gs, 0, w * sizeof(int));
|
||||
memset(bs, 0, w * sizeof(int));
|
||||
my = y - rad;
|
||||
mh = (rad << 1) + 1;
|
||||
if (my < 0)
|
||||
{
|
||||
mh += my;
|
||||
my = 0;
|
||||
}
|
||||
if ((my + mh) > h)
|
||||
{
|
||||
mh = h - my;
|
||||
}
|
||||
p1 = im_data_new + (y * w);
|
||||
memset(as, 0, w * sizeof(int));
|
||||
memset(rs, 0, w * sizeof(int));
|
||||
memset(gs, 0, w * sizeof(int));
|
||||
memset(bs, 0, w * sizeof(int));
|
||||
|
||||
for (yy = 0; yy < mh; yy++)
|
||||
{
|
||||
p2 = im_data + ((yy + my) * w);
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
as[x] += (*p2 >> 24) & 0xff;
|
||||
rs[x] += (*p2 >> 16) & 0xff;
|
||||
gs[x] += (*p2 >> 8) & 0xff;
|
||||
bs[x] += *p2 & 0xff;
|
||||
p2++;
|
||||
}
|
||||
}
|
||||
if (w > ((rad << 1) + 1))
|
||||
{
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
a = 0;
|
||||
r = 0;
|
||||
g = 0;
|
||||
b = 0;
|
||||
mx = x - rad;
|
||||
mw = (rad << 1) + 1;
|
||||
if (mx < 0)
|
||||
{
|
||||
mw += mx;
|
||||
mx = 0;
|
||||
}
|
||||
if ((mx + mw) > w)
|
||||
{
|
||||
mw = w - mx;
|
||||
}
|
||||
mt = mw * mh;
|
||||
for (xx = mx; xx < (mw + mx); xx++)
|
||||
{
|
||||
a += as[xx];
|
||||
r += rs[xx];
|
||||
g += gs[xx];
|
||||
b += bs[xx];
|
||||
}
|
||||
a = a / mt;
|
||||
r = r / mt;
|
||||
g = g / mt;
|
||||
b = b / mt;
|
||||
*p1 = (a << 24) | (r << 16) | (g << 8) | b;
|
||||
p1 ++;
|
||||
}
|
||||
}
|
||||
for (yy = 0; yy < mh; yy++)
|
||||
{
|
||||
p2 = im_data + ((yy + my) * w);
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
as[x] += (*p2 >> 24) & 0xff;
|
||||
rs[x] += (*p2 >> 16) & 0xff;
|
||||
gs[x] += (*p2 >> 8) & 0xff;
|
||||
bs[x] += *p2 & 0xff;
|
||||
p2++;
|
||||
}
|
||||
}
|
||||
if (w > ((rad << 1) + 1))
|
||||
{
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
a = 0;
|
||||
r = 0;
|
||||
g = 0;
|
||||
b = 0;
|
||||
mx = x - rad;
|
||||
mw = (rad << 1) + 1;
|
||||
if (mx < 0)
|
||||
{
|
||||
mw += mx;
|
||||
mx = 0;
|
||||
}
|
||||
if ((mx + mw) > w)
|
||||
{
|
||||
mw = w - mx;
|
||||
}
|
||||
mt = mw * mh;
|
||||
for (xx = mx; xx < (mw + mx); xx++)
|
||||
{
|
||||
a += as[xx];
|
||||
r += rs[xx];
|
||||
g += gs[xx];
|
||||
b += bs[xx];
|
||||
}
|
||||
a = a / mt;
|
||||
r = r / mt;
|
||||
g = g / mt;
|
||||
b = b / mt;
|
||||
*p1 = (a << 24) | (r << 16) | (g << 8) | b;
|
||||
p1++;
|
||||
}
|
||||
}
|
||||
}
|
||||
free(as);
|
||||
free(rs);
|
||||
free(gs);
|
||||
free(bs);
|
||||
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new, w, h);
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new,
|
||||
w, h);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -127,57 +129,54 @@ ephoto_filter_sharpen(Evas_Object *main, Evas_Object *image)
|
|||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int a, r, g, b, x, y, w, h;
|
||||
int mul, mul2, tot;
|
||||
int rad = 3;
|
||||
|
||||
im_data = evas_object_image_data_get(elm_image_object_get(image), EINA_FALSE);
|
||||
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);
|
||||
|
||||
im_data_new = malloc(sizeof(unsigned int) * w * h);
|
||||
|
||||
mul = (rad * 4) + 1;
|
||||
mul2 = rad;
|
||||
tot = mul - (mul2 * 4);
|
||||
for (y = 1; y < (h - 1); y ++)
|
||||
for (y = 1; y < (h - 1); y++)
|
||||
{
|
||||
p1 = im_data + 1 + (y * w);
|
||||
p2 = im_data_new + 1 + (y * w);
|
||||
for (x = 1; x < (w - 1); x++)
|
||||
{
|
||||
b = (int)((p1[0]) & 0xff) * 5;
|
||||
g = (int)((p1[0] >> 8) & 0xff) * 5;
|
||||
r = (int)((p1[0] >> 16) & 0xff) * 5;
|
||||
a = (int)((p1[0] >> 24) & 0xff) * 5;
|
||||
b -= (int)((p1[-1]) & 0xff);
|
||||
g -= (int)((p1[-1] >> 8) & 0xff);
|
||||
r -= (int)((p1[-1] >> 16) & 0xff);
|
||||
a -= (int)((p1[-1] >> 24) & 0xff);
|
||||
b -= (int)((p1[1]) & 0xff);
|
||||
g -= (int)((p1[1] >> 8) & 0xff);
|
||||
r -= (int)((p1[1] >> 16) & 0xff);
|
||||
a -= (int)((p1[1] >> 24) & 0xff);
|
||||
b -= (int)((p1[-w]) & 0xff);
|
||||
g -= (int)((p1[-w] >> 8) & 0xff);
|
||||
r -= (int)((p1[-w] >> 16) & 0xff);
|
||||
a -= (int)((p1[-w] >> 24) & 0xff);
|
||||
b -= (int)((p1[-w]) & 0xff);
|
||||
g -= (int)((p1[-w] >> 8) & 0xff);
|
||||
r -= (int)((p1[-w] >> 16) & 0xff);
|
||||
a -= (int)((p1[-w] >> 24) & 0xff);
|
||||
a = (a & ((~a) >> 16));
|
||||
a = ((a | ((a & 256) - ((a & 256) >> 8))));
|
||||
r = (r & ((~r) >> 16));
|
||||
r = ((r | ((r & 256) - ((r & 256) >> 8))));
|
||||
g = (g & ((~g) >> 16));
|
||||
g = ((g | ((g & 256) - ((g & 256) >> 8))));
|
||||
b = (b & ((~b) >> 16));
|
||||
b = ((b | ((b & 256) - ((b & 256) >> 8))));
|
||||
*p2 = (a << 24) | (r << 16) | (g << 8) | b;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
p1 = im_data + 1 + (y * w);
|
||||
p2 = im_data_new + 1 + (y * w);
|
||||
for (x = 1; x < (w - 1); x++)
|
||||
{
|
||||
b = (int) ((p1[0]) & 0xff) * 5;
|
||||
g = (int) ((p1[0] >> 8) & 0xff) * 5;
|
||||
r = (int) ((p1[0] >> 16) & 0xff) * 5;
|
||||
a = (int) ((p1[0] >> 24) & 0xff) * 5;
|
||||
b -= (int) ((p1[-1]) & 0xff);
|
||||
g -= (int) ((p1[-1] >> 8) & 0xff);
|
||||
r -= (int) ((p1[-1] >> 16) & 0xff);
|
||||
a -= (int) ((p1[-1] >> 24) & 0xff);
|
||||
b -= (int) ((p1[1]) & 0xff);
|
||||
g -= (int) ((p1[1] >> 8) & 0xff);
|
||||
r -= (int) ((p1[1] >> 16) & 0xff);
|
||||
a -= (int) ((p1[1] >> 24) & 0xff);
|
||||
b -= (int) ((p1[-w]) & 0xff);
|
||||
g -= (int) ((p1[-w] >> 8) & 0xff);
|
||||
r -= (int) ((p1[-w] >> 16) & 0xff);
|
||||
a -= (int) ((p1[-w] >> 24) & 0xff);
|
||||
b -= (int) ((p1[-w]) & 0xff);
|
||||
g -= (int) ((p1[-w] >> 8) & 0xff);
|
||||
r -= (int) ((p1[-w] >> 16) & 0xff);
|
||||
a -= (int) ((p1[-w] >> 24) & 0xff);
|
||||
a = (a & ((~a) >> 16));
|
||||
a = ((a | ((a & 256) - ((a & 256) >> 8))));
|
||||
r = (r & ((~r) >> 16));
|
||||
r = ((r | ((r & 256) - ((r & 256) >> 8))));
|
||||
g = (g & ((~g) >> 16));
|
||||
g = ((g | ((g & 256) - ((g & 256) >> 8))));
|
||||
b = (b & ((~b) >> 16));
|
||||
b = ((b | ((b & 256) - ((b & 256) >> 8))));
|
||||
*p2 = (a << 24) | (r << 16) | (g << 8) | b;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
}
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new, w, h);
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new,
|
||||
w, h);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -186,26 +185,28 @@ ephoto_filter_black_and_white(Evas_Object *main, Evas_Object *image)
|
|||
unsigned int *im_data, *im_data_new;
|
||||
int gray, i, r, g, b, a, w, h;
|
||||
|
||||
im_data = evas_object_image_data_get(elm_image_object_get(image), EINA_FALSE);
|
||||
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);
|
||||
|
||||
im_data_new = malloc(sizeof(unsigned int) * w * h);
|
||||
|
||||
for (i = 0; i < (w * h); i++)
|
||||
{
|
||||
b = (int)((im_data[i]) & 0xff);
|
||||
g = (int)((im_data[i] >> 8) & 0xff);
|
||||
r = (int)((im_data[i] >> 16) & 0xff);
|
||||
a = (int)((im_data[i] >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
gray = (int)((0.3 * r) + (0.59 * g) + (0.11 * b));
|
||||
if (a >= 0 && a < 255)
|
||||
gray = (gray * a) / 255;
|
||||
im_data_new[i] = (a << 24) | (gray << 16) | (gray << 8) | gray;
|
||||
b = (int) ((im_data[i]) & 0xff);
|
||||
g = (int) ((im_data[i] >> 8) & 0xff);
|
||||
r = (int) ((im_data[i] >> 16) & 0xff);
|
||||
a = (int) ((im_data[i] >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
gray = (int) ((0.3 * r) + (0.59 * g) + (0.11 * b));
|
||||
if (a >= 0 && a < 255)
|
||||
gray = (gray * a) / 255;
|
||||
im_data_new[i] = (a << 24) | (gray << 16) | (gray << 8) | gray;
|
||||
}
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new, w, h);
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new,
|
||||
w, h);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -214,30 +215,32 @@ ephoto_filter_old_photo(Evas_Object *main, Evas_Object *image)
|
|||
unsigned int *im_data, *im_data_new;
|
||||
int i, r, rr, g, gg, b, bb, a, w, h;
|
||||
|
||||
im_data = evas_object_image_data_get(elm_image_object_get(image), EINA_FALSE);
|
||||
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);
|
||||
im_data_new = malloc(sizeof(unsigned int) * w * h);
|
||||
for (i = 0; i < (w * h); i++)
|
||||
{
|
||||
b = (int)((im_data[i]) & 0xff);
|
||||
g = (int)((im_data[i] >> 8) & 0xff);
|
||||
r = (int)((im_data[i] >> 16) & 0xff);
|
||||
a = (int)((im_data[i] >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
rr = (int)((r* .393) + (g*.769) + (b*.189));
|
||||
rr = _normalize_color(rr);
|
||||
gg = (int)((r* .349) + (g*.686) + (b*.168));
|
||||
gg = _normalize_color(gg);
|
||||
bb = (int)((r* .272) + (g*.534) + (b*.131));
|
||||
bb = _normalize_color(bb);
|
||||
bb = _demul_color_alpha(bb, a);
|
||||
gg = _demul_color_alpha(gg, a);
|
||||
rr = _demul_color_alpha(rr, a);
|
||||
im_data_new[i] = (a << 24) | (rr << 16) | (gg << 8) | bb;
|
||||
b = (int) ((im_data[i]) & 0xff);
|
||||
g = (int) ((im_data[i] >> 8) & 0xff);
|
||||
r = (int) ((im_data[i] >> 16) & 0xff);
|
||||
a = (int) ((im_data[i] >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
rr = (int) ((r * .393) + (g * .769) + (b * .189));
|
||||
rr = _normalize_color(rr);
|
||||
gg = (int) ((r * .349) + (g * .686) + (b * .168));
|
||||
gg = _normalize_color(gg);
|
||||
bb = (int) ((r * .272) + (g * .534) + (b * .131));
|
||||
bb = _normalize_color(bb);
|
||||
bb = _demul_color_alpha(bb, a);
|
||||
gg = _demul_color_alpha(gg, a);
|
||||
rr = _demul_color_alpha(rr, a);
|
||||
im_data_new[i] = (a << 24) | (rr << 16) | (gg << 8) | bb;
|
||||
}
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new, w, h);
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new,
|
||||
w, h);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -248,64 +251,65 @@ ephoto_filter_histogram_eq(Evas_Object *main, Evas_Object *image)
|
|||
int a, r, g, b, bb, gg, rr, norm, total;
|
||||
float hh, s, v, nv, sum;
|
||||
|
||||
im_data = evas_object_image_data_get(elm_image_object_get(image), EINA_FALSE);
|
||||
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);
|
||||
im_data_new = malloc(sizeof(unsigned int) * w * h);
|
||||
total = w * h;
|
||||
for (i = 0; i < 256; i++)
|
||||
hist[i] = 0;
|
||||
hist[i] = 0;
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
p1 = im_data + (y * w);
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
b = (int)((*p1) & 0xff);
|
||||
g = (int)((*p1 >> 8) & 0xff);
|
||||
r = (int)((*p1 >> 16) & 0xff);
|
||||
a = (int)((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
evas_color_rgb_to_hsv(r, g, b, &hh, &s, &v);
|
||||
norm = (int)round((double)v * (double)255);
|
||||
hist[norm] += 1;
|
||||
p1++;
|
||||
}
|
||||
p1 = im_data + (y * w);
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
b = (int) ((*p1) & 0xff);
|
||||
g = (int) ((*p1 >> 8) & 0xff);
|
||||
r = (int) ((*p1 >> 16) & 0xff);
|
||||
a = (int) ((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
evas_color_rgb_to_hsv(r, g, b, &hh, &s, &v);
|
||||
norm = (int) round((double) v * (double) 255);
|
||||
hist[norm] += 1;
|
||||
p1++;
|
||||
}
|
||||
}
|
||||
sum = 0;
|
||||
for (i = 0; i < 256; i++)
|
||||
{
|
||||
sum += ((double)hist[i] / (double)total);
|
||||
cdf[i] = (int)round(sum * 255);
|
||||
sum += ((double) hist[i] / (double) total);
|
||||
cdf[i] = (int) round(sum * 255);
|
||||
}
|
||||
for (y = 0; y < h; y++)
|
||||
{
|
||||
p1 = im_data + (y * w);
|
||||
p2 = im_data_new + (y * w);
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
b = (int)((*p1) & 0xff);
|
||||
g = (int)((*p1 >> 8) & 0xff);
|
||||
r = (int)((*p1 >> 16) & 0xff);
|
||||
a = (int)((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
evas_color_rgb_to_hsv(r, g, b, &hh, &s, &v);
|
||||
norm = (int)round((double)v * (double)255);
|
||||
nv = (float)cdf[norm] / (float)255;
|
||||
evas_color_hsv_to_rgb(hh, s, nv, &rr, &gg, &bb);
|
||||
bb = _normalize_color(bb);
|
||||
gg = _normalize_color(gg);
|
||||
rr = _normalize_color(rr);
|
||||
bb = _demul_color_alpha(bb, a);
|
||||
gg = _demul_color_alpha(gg, a);
|
||||
rr = _demul_color_alpha(rr, a);
|
||||
*p2 = (a << 24) | (rr << 16) | (gg << 8) | bb;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
p1 = im_data + (y * w);
|
||||
p2 = im_data_new + (y * w);
|
||||
for (x = 0; x < w; x++)
|
||||
{
|
||||
b = (int) ((*p1) & 0xff);
|
||||
g = (int) ((*p1 >> 8) & 0xff);
|
||||
r = (int) ((*p1 >> 16) & 0xff);
|
||||
a = (int) ((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
evas_color_rgb_to_hsv(r, g, b, &hh, &s, &v);
|
||||
norm = (int) round((double) v * (double) 255);
|
||||
nv = (float) cdf[norm] / (float) 255;
|
||||
evas_color_hsv_to_rgb(hh, s, nv, &rr, &gg, &bb);
|
||||
bb = _normalize_color(bb);
|
||||
gg = _normalize_color(gg);
|
||||
rr = _normalize_color(rr);
|
||||
bb = _demul_color_alpha(bb, a);
|
||||
gg = _demul_color_alpha(gg, a);
|
||||
rr = _demul_color_alpha(rr, a);
|
||||
*p2 = (a << 24) | (rr << 16) | (gg << 8) | bb;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
}
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new, w, h);
|
||||
ephoto_single_browser_image_data_update(main, image, EINA_TRUE, im_data_new,
|
||||
w, h);
|
||||
}
|
||||
|
||||
|
|
|
@ -21,186 +21,194 @@ static int
|
|||
_normalize_color(int color)
|
||||
{
|
||||
if (color < 0)
|
||||
return 0;
|
||||
return 0;
|
||||
else if (color > 255)
|
||||
return 255;
|
||||
return 255;
|
||||
else
|
||||
return color;
|
||||
return color;
|
||||
}
|
||||
|
||||
static int
|
||||
_mul_color_alpha(int color, int alpha)
|
||||
{
|
||||
if (alpha > 0 && alpha < 255)
|
||||
return (color * (255 / alpha));
|
||||
return color * (255 / alpha);
|
||||
else
|
||||
return color;
|
||||
return color;
|
||||
}
|
||||
|
||||
static int
|
||||
_demul_color_alpha(int color, int alpha)
|
||||
{
|
||||
if (alpha > 0 && alpha < 255)
|
||||
return ((color * alpha) / 255);
|
||||
return (color * alpha) / 255;
|
||||
else
|
||||
return color;
|
||||
return color;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
_ephoto_hsv_adjust_hue(Ephoto_HSV *ehsv, double hue, unsigned int *image_data)
|
||||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int x, y, w, h;
|
||||
int x, y;
|
||||
int a, r, g, b, bb, gg, rr;
|
||||
float hh, s, v;
|
||||
|
||||
im_data = malloc(sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
if (image_data)
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
else
|
||||
memcpy(im_data, ehsv->original_im_data, sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
memcpy(im_data, ehsv->original_im_data,
|
||||
sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
|
||||
im_data_new = malloc(sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
|
||||
for (y = 0; y < ehsv->h; y++)
|
||||
{
|
||||
p1 = im_data + (y * ehsv->w);
|
||||
p2 = im_data_new + (y * ehsv->w);
|
||||
for (x = 0; x < ehsv->w; x++)
|
||||
{
|
||||
b = (int)((*p1) & 0xff);
|
||||
g = (int)((*p1 >> 8) & 0xff);
|
||||
r = (int)((*p1 >> 16) & 0xff);
|
||||
a = (int)((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
evas_color_rgb_to_hsv(r, g, b, &hh, &s, &v);
|
||||
hh += hue;
|
||||
if (hh < 0)
|
||||
hh += 360;
|
||||
if (hh > 360)
|
||||
hh -= 360;
|
||||
evas_color_hsv_to_rgb(hh, s, v, &rr, &gg, &bb);
|
||||
bb = _normalize_color(bb);
|
||||
gg = _normalize_color(gg);
|
||||
rr = _normalize_color(rr);
|
||||
bb = _demul_color_alpha(bb, a);
|
||||
gg = _demul_color_alpha(gg, a);
|
||||
rr = _demul_color_alpha(rr, a);
|
||||
*p2 = (a << 24) | (rr << 16) | (gg << 8) | bb;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
p1 = im_data + (y * ehsv->w);
|
||||
p2 = im_data_new + (y * ehsv->w);
|
||||
for (x = 0; x < ehsv->w; x++)
|
||||
{
|
||||
b = (int) ((*p1) & 0xff);
|
||||
g = (int) ((*p1 >> 8) & 0xff);
|
||||
r = (int) ((*p1 >> 16) & 0xff);
|
||||
a = (int) ((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
evas_color_rgb_to_hsv(r, g, b, &hh, &s, &v);
|
||||
hh += hue;
|
||||
if (hh < 0)
|
||||
hh += 360;
|
||||
if (hh > 360)
|
||||
hh -= 360;
|
||||
evas_color_hsv_to_rgb(hh, s, v, &rr, &gg, &bb);
|
||||
bb = _normalize_color(bb);
|
||||
gg = _normalize_color(gg);
|
||||
rr = _normalize_color(rr);
|
||||
bb = _demul_color_alpha(bb, a);
|
||||
gg = _demul_color_alpha(gg, a);
|
||||
rr = _demul_color_alpha(rr, a);
|
||||
*p2 = (a << 24) | (rr << 16) | (gg << 8) | bb;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
}
|
||||
ehsv->hue = hue;
|
||||
ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_FALSE, im_data_new, ehsv->w, ehsv->h);
|
||||
ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_FALSE,
|
||||
im_data_new, ehsv->w, ehsv->h);
|
||||
free(im_data);
|
||||
return im_data_new;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
_ephoto_hsv_adjust_saturation(Ephoto_HSV *ehsv, double saturation, unsigned int *image_data)
|
||||
_ephoto_hsv_adjust_saturation(Ephoto_HSV *ehsv, double saturation,
|
||||
unsigned int *image_data)
|
||||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int x, y, w, h;
|
||||
int x, y;
|
||||
int a, r, g, b, bb, gg, rr;
|
||||
float hh, s, v;
|
||||
|
||||
im_data = malloc(sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
if (image_data)
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
else
|
||||
memcpy(im_data, ehsv->original_im_data, sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
memcpy(im_data, ehsv->original_im_data,
|
||||
sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
|
||||
im_data_new = malloc(sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
|
||||
for (y = 0; y < ehsv->h; y++)
|
||||
{
|
||||
p1 = im_data + (y * ehsv->w);
|
||||
p2 = im_data_new + (y * ehsv->w);
|
||||
for (x = 0; x < ehsv->w; x++)
|
||||
{
|
||||
b = (int)((*p1) & 0xff);
|
||||
g = (int)((*p1 >> 8) & 0xff);
|
||||
r = (int)((*p1 >> 16) & 0xff);
|
||||
a = (int)((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
evas_color_rgb_to_hsv(r, g, b, &hh, &s, &v);
|
||||
s += s*((float)saturation / 100);
|
||||
if (s < 0)
|
||||
s = 0;
|
||||
if (s > 1)
|
||||
s = 1;
|
||||
evas_color_hsv_to_rgb(hh, s, v, &rr, &gg, &bb);
|
||||
bb = _normalize_color(bb);
|
||||
gg = _normalize_color(gg);
|
||||
rr = _normalize_color(rr);
|
||||
bb = _demul_color_alpha(bb, a);
|
||||
gg = _demul_color_alpha(gg, a);
|
||||
rr = _demul_color_alpha(rr, a);
|
||||
*p2 = (a << 24) | (rr << 16) | (gg << 8) | bb;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
p1 = im_data + (y * ehsv->w);
|
||||
p2 = im_data_new + (y * ehsv->w);
|
||||
for (x = 0; x < ehsv->w; x++)
|
||||
{
|
||||
b = (int) ((*p1) & 0xff);
|
||||
g = (int) ((*p1 >> 8) & 0xff);
|
||||
r = (int) ((*p1 >> 16) & 0xff);
|
||||
a = (int) ((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
evas_color_rgb_to_hsv(r, g, b, &hh, &s, &v);
|
||||
s += s * ((float) saturation / 100);
|
||||
if (s < 0)
|
||||
s = 0;
|
||||
if (s > 1)
|
||||
s = 1;
|
||||
evas_color_hsv_to_rgb(hh, s, v, &rr, &gg, &bb);
|
||||
bb = _normalize_color(bb);
|
||||
gg = _normalize_color(gg);
|
||||
rr = _normalize_color(rr);
|
||||
bb = _demul_color_alpha(bb, a);
|
||||
gg = _demul_color_alpha(gg, a);
|
||||
rr = _demul_color_alpha(rr, a);
|
||||
*p2 = (a << 24) | (rr << 16) | (gg << 8) | bb;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
}
|
||||
ehsv->saturation = saturation;
|
||||
ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_FALSE, im_data_new, ehsv->w, ehsv->h);
|
||||
ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_FALSE,
|
||||
im_data_new, ehsv->w, ehsv->h);
|
||||
free(im_data);
|
||||
return im_data_new;
|
||||
}
|
||||
|
||||
unsigned int *
|
||||
_ephoto_hsv_adjust_value(Ephoto_HSV *ehsv, double value, unsigned int *image_data)
|
||||
_ephoto_hsv_adjust_value(Ephoto_HSV *ehsv, double value,
|
||||
unsigned int *image_data)
|
||||
{
|
||||
unsigned int *im_data, *im_data_new, *p1, *p2;
|
||||
int x, y, w, h;
|
||||
int x, y;
|
||||
int a, r, g, b, bb, gg, rr;
|
||||
float hh, s, v;
|
||||
|
||||
im_data = malloc(sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
if (image_data)
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
memcpy(im_data, image_data, sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
else
|
||||
memcpy(im_data, ehsv->original_im_data, sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
memcpy(im_data, ehsv->original_im_data,
|
||||
sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
|
||||
im_data_new = malloc(sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
|
||||
for (y = 0; y < ehsv->h; y++)
|
||||
{
|
||||
p1 = im_data + (y * ehsv->w);
|
||||
p2 = im_data_new + (y * ehsv->w);
|
||||
for (x = 0; x < ehsv->w; x++)
|
||||
{
|
||||
b = (int)((*p1) & 0xff);
|
||||
g = (int)((*p1 >> 8) & 0xff);
|
||||
r = (int)((*p1 >> 16) & 0xff);
|
||||
a = (int)((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
evas_color_rgb_to_hsv(r, g, b, &hh, &s, &v);
|
||||
v += (v*((float)value/100));
|
||||
if (v < 0)
|
||||
v = 0;
|
||||
if (v > 1)
|
||||
v = 1;
|
||||
evas_color_hsv_to_rgb(hh, s, v, &rr, &gg, &bb);
|
||||
bb = _normalize_color(bb);
|
||||
gg = _normalize_color(gg);
|
||||
rr = _normalize_color(rr);
|
||||
bb = _demul_color_alpha(bb, a);
|
||||
gg = _demul_color_alpha(gg, a);
|
||||
rr = _demul_color_alpha(rr, a);
|
||||
*p2 = (a << 24) | (rr << 16) | (gg << 8) | bb;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
p1 = im_data + (y * ehsv->w);
|
||||
p2 = im_data_new + (y * ehsv->w);
|
||||
for (x = 0; x < ehsv->w; x++)
|
||||
{
|
||||
b = (int) ((*p1) & 0xff);
|
||||
g = (int) ((*p1 >> 8) & 0xff);
|
||||
r = (int) ((*p1 >> 16) & 0xff);
|
||||
a = (int) ((*p1 >> 24) & 0xff);
|
||||
b = _mul_color_alpha(b, a);
|
||||
g = _mul_color_alpha(g, a);
|
||||
r = _mul_color_alpha(r, a);
|
||||
evas_color_rgb_to_hsv(r, g, b, &hh, &s, &v);
|
||||
v += (v * ((float) value / 100));
|
||||
if (v < 0)
|
||||
v = 0;
|
||||
if (v > 1)
|
||||
v = 1;
|
||||
evas_color_hsv_to_rgb(hh, s, v, &rr, &gg, &bb);
|
||||
bb = _normalize_color(bb);
|
||||
gg = _normalize_color(gg);
|
||||
rr = _normalize_color(rr);
|
||||
bb = _demul_color_alpha(bb, a);
|
||||
gg = _demul_color_alpha(gg, a);
|
||||
rr = _demul_color_alpha(rr, a);
|
||||
*p2 = (a << 24) | (rr << 16) | (gg << 8) | bb;
|
||||
p2++;
|
||||
p1++;
|
||||
}
|
||||
}
|
||||
ehsv->value = value;
|
||||
ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_FALSE, im_data_new, ehsv->w, ehsv->h);
|
||||
ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_FALSE,
|
||||
im_data_new, ehsv->w, ehsv->h);
|
||||
free(im_data);
|
||||
return im_data_new;
|
||||
}
|
||||
|
@ -210,43 +218,46 @@ _hue_slider_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
|||
{
|
||||
Ephoto_HSV *ehsv = data;
|
||||
double hue;
|
||||
unsigned int *image_data, *image_data_two, *image_data_three;
|
||||
unsigned int *image_data, *image_data_two;
|
||||
|
||||
hue = elm_slider_value_get(obj);
|
||||
image_data = _ephoto_hsv_adjust_hue(ehsv, hue, NULL);
|
||||
image_data_two = _ephoto_hsv_adjust_saturation(ehsv, ehsv->saturation, image_data);
|
||||
image_data_three = _ephoto_hsv_adjust_value(ehsv, ehsv->value, image_data_two);
|
||||
image_data_two =
|
||||
_ephoto_hsv_adjust_saturation(ehsv, ehsv->saturation, image_data);
|
||||
_ephoto_hsv_adjust_value(ehsv, ehsv->value, image_data_two);
|
||||
}
|
||||
|
||||
|
||||
static void
|
||||
_saturation_slider_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
_saturation_slider_changed(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_HSV *ehsv = data;
|
||||
double saturation;
|
||||
unsigned int *image_data, *image_data_two, *image_data_three;
|
||||
unsigned int *image_data, *image_data_two;
|
||||
|
||||
saturation = elm_slider_value_get(obj);
|
||||
image_data = _ephoto_hsv_adjust_saturation(ehsv, saturation, NULL);
|
||||
image_data_two = _ephoto_hsv_adjust_hue(ehsv, ehsv->hue, image_data);
|
||||
image_data_three = _ephoto_hsv_adjust_value(ehsv, ehsv->value, image_data_two);
|
||||
_ephoto_hsv_adjust_value(ehsv, ehsv->value, image_data_two);
|
||||
}
|
||||
|
||||
static void
|
||||
_value_slider_changed(void *data, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
_value_slider_changed(void *data, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_HSV *ehsv = data;
|
||||
double value;
|
||||
unsigned int *image_data, *image_data_two, *image_data_three;
|
||||
unsigned int *image_data, *image_data_two;
|
||||
|
||||
value = elm_slider_value_get(obj);
|
||||
image_data = _ephoto_hsv_adjust_value(ehsv, value, NULL);
|
||||
image_data_two = _ephoto_hsv_adjust_hue(ehsv, ehsv->hue, image_data);
|
||||
image_data_three = _ephoto_hsv_adjust_saturation(ehsv, ehsv->saturation, image_data_two);
|
||||
_ephoto_hsv_adjust_saturation(ehsv, ehsv->saturation, image_data_two);
|
||||
}
|
||||
|
||||
static void
|
||||
_hsv_reset(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_hsv_reset(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_HSV *ehsv = data;
|
||||
|
||||
|
@ -260,20 +271,25 @@ _hsv_reset(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSE
|
|||
}
|
||||
|
||||
static void
|
||||
_hsv_apply(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_hsv_apply(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_HSV *ehsv = data;
|
||||
unsigned int *image_data;
|
||||
int w, h;
|
||||
|
||||
image_data = evas_object_image_data_get(elm_image_object_get(ehsv->image), EINA_FALSE);
|
||||
image_data =
|
||||
evas_object_image_data_get(elm_image_object_get(ehsv->image),
|
||||
EINA_FALSE);
|
||||
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);
|
||||
ephoto_single_browser_image_data_update(ehsv->main, ehsv->image, EINA_TRUE,
|
||||
image_data, w, h);
|
||||
evas_object_del(ehsv->frame);
|
||||
}
|
||||
|
||||
static void
|
||||
_hsv_cancel(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_hsv_cancel(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_HSV *ehsv = data;
|
||||
|
||||
|
@ -289,16 +305,19 @@ _hsv_cancel(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUS
|
|||
}
|
||||
|
||||
static void
|
||||
_frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_frame_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_HSV *ehsv = data;
|
||||
|
||||
free(ehsv->original_im_data);
|
||||
free(ehsv);
|
||||
}
|
||||
|
||||
void ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
||||
void
|
||||
ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
||||
{
|
||||
Evas_Object *win, *box, *slider, *ic, *button;
|
||||
Evas_Object *box, *slider, *ic, *button;
|
||||
Ephoto_HSV *ehsv;
|
||||
unsigned int *im_data;
|
||||
|
||||
|
@ -313,10 +332,14 @@ void ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
ehsv->main = main;
|
||||
ehsv->parent = parent;
|
||||
ehsv->image = image;
|
||||
im_data = evas_object_image_data_get(elm_image_object_get(ehsv->image), EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_get(ehsv->image), &ehsv->w, &ehsv->h);
|
||||
im_data =
|
||||
evas_object_image_data_get(elm_image_object_get(ehsv->image),
|
||||
EINA_FALSE);
|
||||
evas_object_image_size_get(elm_image_object_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, sizeof(unsigned int) * ehsv->w * ehsv->h);
|
||||
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"));
|
||||
|
@ -324,7 +347,8 @@ void ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
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);
|
||||
evas_object_event_callback_add(ehsv->frame, EVAS_CALLBACK_DEL, _frame_del,
|
||||
ehsv);
|
||||
evas_object_show(ehsv->frame);
|
||||
|
||||
box = elm_box_add(ehsv->frame);
|
||||
|
@ -342,7 +366,8 @@ void ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
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", _hue_slider_changed, ehsv);
|
||||
evas_object_smart_callback_add(slider, "delay,changed", _hue_slider_changed,
|
||||
ehsv);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
ehsv->hslider = slider;
|
||||
|
@ -355,7 +380,8 @@ void ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
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", _saturation_slider_changed, ehsv);
|
||||
evas_object_smart_callback_add(slider, "delay,changed",
|
||||
_saturation_slider_changed, ehsv);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
ehsv->sslider = slider;
|
||||
|
@ -368,7 +394,8 @@ void ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
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", _value_slider_changed, ehsv);
|
||||
evas_object_smart_callback_add(slider, "delay,changed",
|
||||
_value_slider_changed, ehsv);
|
||||
elm_box_pack_end(box, slider);
|
||||
evas_object_show(slider);
|
||||
ehsv->vslider = slider;
|
||||
|
@ -417,6 +444,6 @@ void ephoto_hsv_add(Evas_Object *main, Evas_Object *parent, Evas_Object *image)
|
|||
|
||||
return;
|
||||
|
||||
error:
|
||||
return;
|
||||
error:
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -8,10 +8,18 @@ int EPHOTO_EVENT_POPULATE_ERROR = 0;
|
|||
typedef struct _Ephoto_Entry_Free_Listener Ephoto_Entry_Free_Listener;
|
||||
struct _Ephoto_Entry_Free_Listener
|
||||
{
|
||||
void (*cb)(void *data, const Ephoto_Entry *dead);
|
||||
void (*cb) (void *data, const Ephoto_Entry *dead);
|
||||
const void *data;
|
||||
};
|
||||
|
||||
typedef struct _Ephoto_Dir_Data Ephoto_Dir_Data;
|
||||
struct _Ephoto_Dir_Data
|
||||
{
|
||||
Ephoto *ephoto;
|
||||
Elm_Widget_Item *expanded;
|
||||
Eina_Bool dirs_only;
|
||||
};
|
||||
|
||||
static void
|
||||
_ephoto_state_set(Ephoto *ephoto, Ephoto_State state)
|
||||
{
|
||||
|
@ -22,8 +30,6 @@ _ephoto_state_set(Ephoto *ephoto, Ephoto_State state)
|
|||
static void
|
||||
_ephoto_thumb_browser_show(Ephoto *ephoto, Ephoto_Entry *entry)
|
||||
{
|
||||
DBG("entry '%s'", entry ? entry->path : "");
|
||||
|
||||
ephoto_single_browser_entry_set(ephoto->single_browser, NULL);
|
||||
ephoto_slideshow_entry_set(ephoto->slideshow, NULL);
|
||||
elm_naviframe_item_promote(ephoto->tb);
|
||||
|
@ -32,13 +38,12 @@ _ephoto_thumb_browser_show(Ephoto *ephoto, Ephoto_Entry *entry)
|
|||
ephoto_title_set(ephoto, ephoto->config->directory);
|
||||
|
||||
if ((entry) && (entry->item))
|
||||
elm_gengrid_item_bring_in(entry->item, ELM_GENGRID_ITEM_SCROLLTO_IN);
|
||||
elm_gengrid_item_bring_in(entry->item, ELM_GENGRID_ITEM_SCROLLTO_IN);
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_single_browser_show(Ephoto *ephoto, Ephoto_Entry *entry)
|
||||
{
|
||||
DBG("entry '%s'", entry->path);
|
||||
ephoto_single_browser_entry_set(ephoto->single_browser, entry);
|
||||
elm_naviframe_item_simple_promote(ephoto->pager, ephoto->single_browser);
|
||||
elm_object_focus_set(ephoto->single_browser, EINA_TRUE);
|
||||
|
@ -48,7 +53,6 @@ _ephoto_single_browser_show(Ephoto *ephoto, Ephoto_Entry *entry)
|
|||
static void
|
||||
_ephoto_slideshow_show(Ephoto *ephoto, Ephoto_Entry *entry)
|
||||
{
|
||||
DBG("entry '%s'", entry->path);
|
||||
ephoto_slideshow_entry_set(ephoto->slideshow, entry);
|
||||
elm_naviframe_item_simple_promote(ephoto->pager, ephoto->slideshow);
|
||||
elm_object_focus_set(ephoto->slideshow, EINA_TRUE);
|
||||
|
@ -56,74 +60,92 @@ _ephoto_slideshow_show(Ephoto *ephoto, Ephoto_Entry *entry)
|
|||
}
|
||||
|
||||
static void
|
||||
_ephoto_single_browser_back(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||
_ephoto_single_browser_back(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
Ephoto_Entry *entry = event_info;
|
||||
|
||||
_ephoto_thumb_browser_show(ephoto, entry);
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_slideshow_back(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||
_ephoto_slideshow_back(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
Ephoto_Entry *entry = event_info;
|
||||
|
||||
switch (ephoto->prev_state)
|
||||
{
|
||||
case EPHOTO_STATE_SINGLE:
|
||||
_ephoto_single_browser_show(ephoto, entry);
|
||||
break;
|
||||
case EPHOTO_STATE_THUMB:
|
||||
_ephoto_thumb_browser_show(ephoto, entry);
|
||||
break;
|
||||
default:
|
||||
ERR("unhandled previous state %d", ephoto->prev_state);
|
||||
case EPHOTO_STATE_SINGLE:
|
||||
_ephoto_single_browser_show(ephoto, entry);
|
||||
break;
|
||||
|
||||
case EPHOTO_STATE_THUMB:
|
||||
_ephoto_thumb_browser_show(ephoto, entry);
|
||||
break;
|
||||
|
||||
default:
|
||||
_ephoto_thumb_browser_show(ephoto, entry);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_thumb_browser_view(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||
_ephoto_thumb_browser_view(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
Ephoto_Entry *entry = event_info;
|
||||
|
||||
_ephoto_single_browser_show(ephoto, entry);
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_thumb_browser_changed_directory(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_ephoto_thumb_browser_changed_directory(void *data,
|
||||
Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
|
||||
ephoto_single_browser_entry_set(ephoto->single_browser, NULL);
|
||||
ephoto_slideshow_entry_set(ephoto->slideshow, NULL);
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_thumb_browser_slideshow(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||
_ephoto_thumb_browser_slideshow(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
Ephoto_Entry *entry = event_info;
|
||||
|
||||
_ephoto_slideshow_show(ephoto, entry);
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_single_browser_slideshow(void *data, Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||
_ephoto_single_browser_slideshow(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
Ephoto_Entry *entry = event_info;
|
||||
|
||||
_ephoto_slideshow_show(ephoto, entry);
|
||||
}
|
||||
|
||||
static void
|
||||
_win_free(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_win_free(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
if (ephoto->timer.thumb_regen) ecore_timer_del(ephoto->timer.thumb_regen);
|
||||
|
||||
if (ephoto->timer.thumb_regen)
|
||||
ecore_timer_del(ephoto->timer.thumb_regen);
|
||||
ephoto_config_save(ephoto);
|
||||
free(ephoto);
|
||||
}
|
||||
|
||||
static void
|
||||
_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
int w, h;
|
||||
|
@ -131,8 +153,8 @@ _resize_cb(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *
|
|||
evas_object_geometry_get(ephoto->win, 0, 0, &w, &h);
|
||||
if (w && h)
|
||||
{
|
||||
ephoto->config->window_width = w;
|
||||
ephoto->config->window_height = h;
|
||||
ephoto->config->window_width = w;
|
||||
ephoto->config->window_height = h;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -141,6 +163,7 @@ ephoto_window_add(const char *path)
|
|||
{
|
||||
Ephoto *ephoto = calloc(1, sizeof(Ephoto));
|
||||
char buf[PATH_MAX];
|
||||
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(ephoto, NULL);
|
||||
|
||||
EPHOTO_EVENT_ENTRY_CREATE = ecore_event_type_new();
|
||||
|
@ -151,121 +174,121 @@ ephoto_window_add(const char *path)
|
|||
ephoto->win = elm_win_util_standard_add("ephoto", "Ephoto");
|
||||
if (!ephoto->win)
|
||||
{
|
||||
free(ephoto);
|
||||
return NULL;
|
||||
free(ephoto);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
evas_object_event_callback_add
|
||||
(ephoto->win, EVAS_CALLBACK_FREE, _win_free, ephoto);
|
||||
evas_object_event_callback_add
|
||||
(ephoto->win, EVAS_CALLBACK_RESIZE, _resize_cb, ephoto);
|
||||
|
||||
evas_object_event_callback_add(ephoto->win, EVAS_CALLBACK_FREE, _win_free,
|
||||
ephoto);
|
||||
evas_object_event_callback_add(ephoto->win, EVAS_CALLBACK_RESIZE, _resize_cb,
|
||||
ephoto);
|
||||
elm_win_autodel_set(ephoto->win, EINA_TRUE);
|
||||
|
||||
if (!ephoto_config_init(ephoto))
|
||||
{
|
||||
evas_object_del(ephoto->win);
|
||||
return NULL;
|
||||
evas_object_del(ephoto->win);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if ((ephoto->config->thumb_gen_size != 128) &&
|
||||
(ephoto->config->thumb_gen_size != 256) &&
|
||||
(ephoto->config->thumb_gen_size != 512))
|
||||
ephoto_thumb_size_set(ephoto, ephoto->config->thumb_size);
|
||||
ephoto_thumb_size_set(ephoto, ephoto->config->thumb_size);
|
||||
|
||||
ephoto->pager = elm_naviframe_add(ephoto->win);
|
||||
elm_naviframe_prev_btn_auto_pushed_set(ephoto->pager, EINA_FALSE);
|
||||
evas_object_size_hint_weight_set
|
||||
(ephoto->pager, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_fill_set
|
||||
(ephoto->pager, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
evas_object_size_hint_weight_set(ephoto->pager, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_fill_set(ephoto->pager, EVAS_HINT_FILL,
|
||||
EVAS_HINT_FILL);
|
||||
elm_win_resize_object_add(ephoto->win, ephoto->pager);
|
||||
evas_object_show(ephoto->pager);
|
||||
|
||||
ephoto->thumb_browser = ephoto_thumb_browser_add(ephoto, ephoto->pager);
|
||||
if (!ephoto->thumb_browser)
|
||||
{
|
||||
ERR("could not add thumb browser");
|
||||
evas_object_del(ephoto->win);
|
||||
return NULL;
|
||||
evas_object_del(ephoto->win);
|
||||
return NULL;
|
||||
}
|
||||
ephoto->tb = elm_naviframe_item_push(ephoto->pager, NULL, NULL, NULL, ephoto->thumb_browser, "overlap");
|
||||
ephoto->tb =
|
||||
elm_naviframe_item_push(ephoto->pager, NULL, NULL, NULL,
|
||||
ephoto->thumb_browser, "overlap");
|
||||
elm_naviframe_item_title_enabled_set(ephoto->tb, EINA_FALSE, EINA_FALSE);
|
||||
evas_object_smart_callback_add
|
||||
(ephoto->thumb_browser, "view", _ephoto_thumb_browser_view, ephoto);
|
||||
evas_object_smart_callback_add
|
||||
(ephoto->thumb_browser, "changed,directory",
|
||||
_ephoto_thumb_browser_changed_directory, ephoto);
|
||||
evas_object_smart_callback_add
|
||||
(ephoto->thumb_browser, "slideshow",
|
||||
_ephoto_thumb_browser_slideshow, ephoto);
|
||||
evas_object_smart_callback_add(ephoto->thumb_browser, "view",
|
||||
_ephoto_thumb_browser_view, ephoto);
|
||||
evas_object_smart_callback_add(ephoto->thumb_browser, "changed,directory",
|
||||
_ephoto_thumb_browser_changed_directory, ephoto);
|
||||
evas_object_smart_callback_add(ephoto->thumb_browser, "slideshow",
|
||||
_ephoto_thumb_browser_slideshow, ephoto);
|
||||
|
||||
ephoto->single_browser = ephoto_single_browser_add(ephoto, ephoto->pager);
|
||||
if (!ephoto->single_browser)
|
||||
{
|
||||
ERR("could not add single browser");
|
||||
evas_object_del(ephoto->win);
|
||||
return NULL;
|
||||
evas_object_del(ephoto->win);
|
||||
return NULL;
|
||||
}
|
||||
ephoto->sb = elm_naviframe_item_insert_after(ephoto->pager, ephoto->tb,
|
||||
NULL, NULL, NULL, ephoto->single_browser, "overlap");
|
||||
ephoto->sb =
|
||||
elm_naviframe_item_insert_after(ephoto->pager, ephoto->tb, NULL, NULL,
|
||||
NULL, ephoto->single_browser, "overlap");
|
||||
elm_naviframe_item_title_enabled_set(ephoto->sb, EINA_FALSE, EINA_FALSE);
|
||||
evas_object_smart_callback_add
|
||||
(ephoto->single_browser, "back", _ephoto_single_browser_back, ephoto);
|
||||
evas_object_smart_callback_add
|
||||
(ephoto->single_browser, "slideshow",
|
||||
_ephoto_single_browser_slideshow, ephoto);
|
||||
evas_object_smart_callback_add(ephoto->single_browser, "back",
|
||||
_ephoto_single_browser_back, ephoto);
|
||||
evas_object_smart_callback_add(ephoto->single_browser, "slideshow",
|
||||
_ephoto_single_browser_slideshow, ephoto);
|
||||
|
||||
ephoto->slideshow = ephoto_slideshow_add(ephoto, ephoto->pager);
|
||||
if (!ephoto->slideshow)
|
||||
{
|
||||
ERR("could not add single browser");
|
||||
evas_object_del(ephoto->win);
|
||||
return NULL;
|
||||
evas_object_del(ephoto->win);
|
||||
return NULL;
|
||||
}
|
||||
ephoto->sl = elm_naviframe_item_insert_after(ephoto->pager, ephoto->sb,
|
||||
NULL, NULL, NULL, ephoto->slideshow, "overlap");
|
||||
ephoto->sl =
|
||||
elm_naviframe_item_insert_after(ephoto->pager, ephoto->sb, NULL, NULL,
|
||||
NULL, ephoto->slideshow, "overlap");
|
||||
elm_naviframe_item_title_enabled_set(ephoto->sl, EINA_FALSE, EINA_FALSE);
|
||||
evas_object_smart_callback_add
|
||||
(ephoto->slideshow, "back", _ephoto_slideshow_back, ephoto);
|
||||
evas_object_smart_callback_add(ephoto->slideshow, "back",
|
||||
_ephoto_slideshow_back, ephoto);
|
||||
|
||||
if ((!path) || (!ecore_file_exists(path)))
|
||||
{
|
||||
if (ephoto->config->open)
|
||||
{
|
||||
if (!strcmp(ephoto->config->open, "Last"))
|
||||
path = ephoto->config->directory;
|
||||
else
|
||||
path = ephoto->config->open;
|
||||
if ((path) && (!ecore_file_exists(path))) path = NULL;
|
||||
}
|
||||
if (ephoto->config->open)
|
||||
{
|
||||
if (!strcmp(ephoto->config->open, "Last"))
|
||||
path = ephoto->config->directory;
|
||||
else
|
||||
path = ephoto->config->open;
|
||||
if ((path) && (!ecore_file_exists(path)))
|
||||
path = NULL;
|
||||
}
|
||||
else if (!ephoto->config->open || path)
|
||||
{
|
||||
if (getcwd(buf, sizeof(buf)))
|
||||
path = buf;
|
||||
else
|
||||
path = getenv("HOME");
|
||||
}
|
||||
{
|
||||
if (getcwd(buf, sizeof(buf)))
|
||||
path = buf;
|
||||
else
|
||||
path = getenv("HOME");
|
||||
}
|
||||
}
|
||||
|
||||
if (ecore_file_is_dir(path))
|
||||
{
|
||||
ephoto_directory_set(ephoto, path);
|
||||
_ephoto_thumb_browser_show(ephoto, NULL);
|
||||
ephoto_directory_set(ephoto, path, NULL, EINA_FALSE);
|
||||
_ephoto_thumb_browser_show(ephoto, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
char *dir = ecore_file_dir_get(path);
|
||||
ephoto_directory_set(ephoto, dir);
|
||||
free(dir);
|
||||
ephoto_single_browser_path_pending_set(ephoto->single_browser, path);
|
||||
char *dir = ecore_file_dir_get(path);
|
||||
|
||||
elm_naviframe_item_simple_promote(ephoto->pager,
|
||||
ephoto->single_browser);
|
||||
ephoto->state = EPHOTO_STATE_SINGLE;
|
||||
ephoto_directory_set(ephoto, dir, NULL, EINA_FALSE);
|
||||
free(dir);
|
||||
ephoto_single_browser_path_pending_set(ephoto->single_browser, path);
|
||||
|
||||
elm_naviframe_item_simple_promote(ephoto->pager,
|
||||
ephoto->single_browser);
|
||||
ephoto->state = EPHOTO_STATE_SINGLE;
|
||||
}
|
||||
|
||||
evas_object_resize(ephoto->win, ephoto->config->window_width, ephoto->config->window_height);
|
||||
evas_object_resize(ephoto->win, ephoto->config->window_width,
|
||||
ephoto->config->window_height);
|
||||
evas_object_show(ephoto->win);
|
||||
|
||||
return ephoto->win;
|
||||
|
@ -278,62 +301,75 @@ ephoto_title_set(Ephoto *ephoto, const char *title)
|
|||
|
||||
if (title)
|
||||
{
|
||||
snprintf(buf, sizeof(buf), "Ephoto - %s", title);
|
||||
elm_win_title_set(ephoto->win, buf);
|
||||
snprintf(buf, sizeof(buf), "Ephoto - %s", title);
|
||||
elm_win_title_set(ephoto->win, buf);
|
||||
}
|
||||
else
|
||||
elm_win_title_set(ephoto->win, "Ephoto");
|
||||
elm_win_title_set(ephoto->win, "Ephoto");
|
||||
}
|
||||
|
||||
int
|
||||
ephoto_entries_cmp(const void *pa, const void *pb)
|
||||
{
|
||||
const Ephoto_Entry *a = pa, *b = pb;
|
||||
|
||||
return strcoll(a->basename, b->basename);
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_populate_main(void *data, Eio_File *handler EINA_UNUSED, const Eina_File_Direct_Info *info)
|
||||
_ephoto_populate_main(void *data, Eio_File *handler EINA_UNUSED,
|
||||
const Eina_File_Direct_Info *info)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
Ephoto_Dir_Data *ed = data;
|
||||
Ephoto_Entry *e;
|
||||
Ephoto_Event_Entry_Create *ev;
|
||||
|
||||
e = ephoto_entry_new(ephoto, info->path, info->path + info->name_start, info->type);
|
||||
e = ephoto_entry_new(ed->ephoto, info->path, info->path + info->name_start,
|
||||
info->type);
|
||||
|
||||
if (e->is_dir)
|
||||
{
|
||||
if (!ephoto->direntries)
|
||||
ephoto->direntries = eina_list_append(ephoto->direntries, e);
|
||||
else
|
||||
{
|
||||
int near_cmp;
|
||||
Eina_List *near_node = eina_list_search_sorted_near_list
|
||||
(ephoto->direntries, ephoto_entries_cmp, e, &near_cmp);
|
||||
if (near_cmp < 0)
|
||||
ephoto->direntries = eina_list_append_relative_list
|
||||
(ephoto->direntries, e, near_node);
|
||||
else
|
||||
ephoto->direntries = eina_list_prepend_relative_list
|
||||
(ephoto->direntries, e, near_node);
|
||||
}
|
||||
if (!ed->ephoto->direntries)
|
||||
ed->ephoto->direntries = eina_list_append(ed->ephoto->direntries, e);
|
||||
else
|
||||
{
|
||||
int near_cmp;
|
||||
Eina_List *near_node =
|
||||
eina_list_search_sorted_near_list(ed->ephoto->direntries,
|
||||
ephoto_entries_cmp, e, &near_cmp);
|
||||
|
||||
if (near_cmp < 0)
|
||||
ed->ephoto->direntries =
|
||||
eina_list_append_relative_list(ed->ephoto->direntries, e,
|
||||
near_node);
|
||||
else
|
||||
ed->ephoto->direntries =
|
||||
eina_list_prepend_relative_list(ed->ephoto->direntries, e,
|
||||
near_node);
|
||||
}
|
||||
e->parent = ed->expanded;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ephoto->entries)
|
||||
ephoto->entries = eina_list_append(ephoto->entries, e);
|
||||
else
|
||||
{
|
||||
int near_cmp;
|
||||
Eina_List *near_node = eina_list_search_sorted_near_list
|
||||
(ephoto->entries, ephoto_entries_cmp, e, &near_cmp);
|
||||
if (near_cmp < 0)
|
||||
ephoto->entries = eina_list_append_relative_list
|
||||
(ephoto->entries, e, near_node);
|
||||
else
|
||||
ephoto->entries = eina_list_prepend_relative_list
|
||||
(ephoto->entries, e, near_node);
|
||||
}
|
||||
if (!ed->ephoto->entries)
|
||||
ed->ephoto->entries = eina_list_append(ed->ephoto->entries, e);
|
||||
else
|
||||
{
|
||||
int near_cmp;
|
||||
Eina_List *near_node =
|
||||
eina_list_search_sorted_near_list(ed->ephoto->entries,
|
||||
ephoto_entries_cmp, e, &near_cmp);
|
||||
|
||||
if (near_cmp < 0)
|
||||
ed->ephoto->entries =
|
||||
eina_list_append_relative_list(ed->ephoto->entries, e,
|
||||
near_node);
|
||||
else
|
||||
ed->ephoto->entries =
|
||||
eina_list_prepend_relative_list(ed->ephoto->entries, e,
|
||||
near_node);
|
||||
}
|
||||
e->parent = NULL;
|
||||
}
|
||||
ev = calloc(1, sizeof(Ephoto_Event_Entry_Create));
|
||||
ev->entry = e;
|
||||
|
@ -342,48 +378,54 @@ _ephoto_populate_main(void *data, Eio_File *handler EINA_UNUSED, const Eina_File
|
|||
}
|
||||
|
||||
static Eina_Bool
|
||||
_ephoto_populate_filter(void *data EINA_UNUSED, Eio_File *handler EINA_UNUSED, const Eina_File_Direct_Info *info)
|
||||
_ephoto_populate_filter(void *data, Eio_File *handler EINA_UNUSED,
|
||||
const Eina_File_Direct_Info *info)
|
||||
{
|
||||
Ephoto_Dir_Data *ed = data;
|
||||
const char *bname = info->path + info->name_start;
|
||||
|
||||
if (bname[0] == '.') return EINA_FALSE;
|
||||
if (info->type == EINA_FILE_DIR) return EINA_TRUE;
|
||||
|
||||
return _ephoto_eina_file_direct_info_image_useful(info);
|
||||
if (bname[0] == '.')
|
||||
return EINA_FALSE;
|
||||
if (info->type == EINA_FILE_DIR)
|
||||
return EINA_TRUE;
|
||||
if (!ed->dirs_only)
|
||||
return _ephoto_eina_file_direct_info_image_useful(info);
|
||||
else
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_populate_end(void *data, Eio_File *handler EINA_UNUSED)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
ephoto->ls = NULL;
|
||||
Ephoto_Dir_Data *ed = data;
|
||||
|
||||
ed->ephoto->ls = NULL;
|
||||
|
||||
ecore_event_add(EPHOTO_EVENT_POPULATE_END, NULL, NULL, NULL);
|
||||
free(ed);
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_populate_error(void *data, Eio_File *handler, int error)
|
||||
_ephoto_populate_error(void *data, Eio_File *handler, int error EINA_UNUSED)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
if (error) ERR("could not populate: %s", strerror(error));
|
||||
Ephoto_Dir_Data *ed = data;
|
||||
|
||||
ecore_event_add(EPHOTO_EVENT_POPULATE_ERROR, NULL, NULL, NULL);
|
||||
_ephoto_populate_end(ephoto, handler);
|
||||
_ephoto_populate_end(ed->ephoto, handler);
|
||||
}
|
||||
|
||||
static void
|
||||
_ephoto_populate_entries(Ephoto *ephoto)
|
||||
_ephoto_populate_entries(Ephoto_Dir_Data *ed)
|
||||
{
|
||||
DBG("populate from '%s'", ephoto->config->directory);
|
||||
Ephoto_Entry *entry;
|
||||
|
||||
ephoto_entries_free(ephoto);
|
||||
|
||||
ephoto->ls = eio_file_stat_ls(ephoto->config->directory,
|
||||
_ephoto_populate_filter,
|
||||
_ephoto_populate_main,
|
||||
_ephoto_populate_end,
|
||||
_ephoto_populate_error,
|
||||
ephoto);
|
||||
if (!ed->dirs_only)
|
||||
ephoto_entries_free(ed->ephoto);
|
||||
else
|
||||
EINA_LIST_FREE(ed->ephoto->direntries, entry) ephoto_entry_free(entry);
|
||||
ed->ephoto->ls =
|
||||
eio_file_stat_ls(ed->ephoto->config->directory, _ephoto_populate_filter,
|
||||
_ephoto_populate_main, _ephoto_populate_end, _ephoto_populate_error, ed);
|
||||
|
||||
ecore_event_add(EPHOTO_EVENT_POPULATE_START, NULL, NULL, NULL);
|
||||
}
|
||||
|
@ -391,20 +433,29 @@ _ephoto_populate_entries(Ephoto *ephoto)
|
|||
static void
|
||||
_ephoto_change_dir(void *data)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
ephoto->job.change_dir = NULL;
|
||||
_ephoto_populate_entries(ephoto);
|
||||
Ephoto_Dir_Data *ed = data;
|
||||
|
||||
ed->ephoto->job.change_dir = NULL;
|
||||
_ephoto_populate_entries(ed);
|
||||
}
|
||||
|
||||
void
|
||||
ephoto_directory_set(Ephoto *ephoto, const char *path)
|
||||
ephoto_directory_set(Ephoto *ephoto, const char *path, Evas_Object *expanded,
|
||||
Eina_Bool dirs_only)
|
||||
{
|
||||
EINA_SAFETY_ON_NULL_RETURN(ephoto);
|
||||
Ephoto_Dir_Data *ed;
|
||||
|
||||
ed = malloc(sizeof(Ephoto_Dir_Data));
|
||||
ed->ephoto = ephoto;
|
||||
ed->expanded = expanded;
|
||||
ed->dirs_only = dirs_only;
|
||||
|
||||
ephoto_title_set(ephoto, NULL);
|
||||
eina_stringshare_replace(&ephoto->config->directory, path);
|
||||
if (ephoto->job.change_dir) ecore_job_del(ephoto->job.change_dir);
|
||||
ephoto->job.change_dir = ecore_job_add(_ephoto_change_dir, ephoto);
|
||||
|
||||
if (ed->ephoto->job.change_dir)
|
||||
ecore_job_del(ed->ephoto->job.change_dir);
|
||||
ed->ephoto->job.change_dir = ecore_job_add(_ephoto_change_dir, ed);
|
||||
}
|
||||
|
||||
static Eina_Bool
|
||||
|
@ -414,34 +465,33 @@ _thumb_gen_size_changed_timer_cb(void *data)
|
|||
const Eina_List *l;
|
||||
Evas_Object *o;
|
||||
|
||||
if (ephoto->config->thumb_gen_size == ephoto->thumb_gen_size) goto end;
|
||||
|
||||
INF("thumbnail generation size changed from %d to %d",
|
||||
ephoto->config->thumb_gen_size, ephoto->thumb_gen_size);
|
||||
if (ephoto->config->thumb_gen_size == ephoto->thumb_gen_size)
|
||||
goto end;
|
||||
|
||||
ephoto->config->thumb_gen_size = ephoto->thumb_gen_size;
|
||||
|
||||
EINA_LIST_FOREACH(ephoto->thumbs, l, o)
|
||||
{
|
||||
Ethumb_Thumb_Format format;
|
||||
format = (long)evas_object_data_get(o, "ephoto_format");
|
||||
if (format)
|
||||
{
|
||||
elm_thumb_format_set(o, format);
|
||||
if (format == ETHUMB_THUMB_FDO)
|
||||
{
|
||||
if (ephoto->config->thumb_gen_size < 256)
|
||||
elm_thumb_fdo_size_set(o, ETHUMB_THUMB_NORMAL);
|
||||
else
|
||||
elm_thumb_fdo_size_set(o, ETHUMB_THUMB_LARGE);
|
||||
}
|
||||
else
|
||||
elm_thumb_size_set(o, ephoto->thumb_gen_size, ephoto->thumb_gen_size);
|
||||
elm_thumb_reload(o);
|
||||
}
|
||||
}
|
||||
|
||||
end:
|
||||
format = (long) evas_object_data_get(o, "ephoto_format");
|
||||
if (format)
|
||||
{
|
||||
elm_thumb_format_set(o, format);
|
||||
if (format == ETHUMB_THUMB_FDO)
|
||||
{
|
||||
if (ephoto->config->thumb_gen_size < 256)
|
||||
elm_thumb_fdo_size_set(o, ETHUMB_THUMB_NORMAL);
|
||||
else
|
||||
elm_thumb_fdo_size_set(o, ETHUMB_THUMB_LARGE);
|
||||
}
|
||||
else
|
||||
elm_thumb_size_set(o, ephoto->thumb_gen_size,
|
||||
ephoto->thumb_gen_size);
|
||||
elm_thumb_reload(o);
|
||||
}
|
||||
}
|
||||
end:
|
||||
ephoto->timer.thumb_regen = NULL;
|
||||
return EINA_FALSE;
|
||||
}
|
||||
|
@ -451,63 +501,61 @@ ephoto_thumb_size_set(Ephoto *ephoto, int size)
|
|||
{
|
||||
if (ephoto->config->thumb_size != size)
|
||||
{
|
||||
INF("thumbnail display size changed from %d to %d",
|
||||
ephoto->config->thumb_size, size);
|
||||
ephoto->config->thumb_size = size;
|
||||
ephoto->config->thumb_size = size;
|
||||
}
|
||||
|
||||
if (size <= 128) ephoto->thumb_gen_size = 128;
|
||||
else if (size <= 256) ephoto->thumb_gen_size = 256;
|
||||
else ephoto->thumb_gen_size = 512;
|
||||
if (size <= 128)
|
||||
ephoto->thumb_gen_size = 128;
|
||||
else if (size <= 256)
|
||||
ephoto->thumb_gen_size = 256;
|
||||
else
|
||||
ephoto->thumb_gen_size = 512;
|
||||
|
||||
if (ephoto->timer.thumb_regen) ecore_timer_del(ephoto->timer.thumb_regen);
|
||||
ephoto->timer.thumb_regen = ecore_timer_add
|
||||
(0.1, _thumb_gen_size_changed_timer_cb, ephoto);
|
||||
if (ephoto->timer.thumb_regen)
|
||||
ecore_timer_del(ephoto->timer.thumb_regen);
|
||||
ephoto->timer.thumb_regen =
|
||||
ecore_timer_add(0.1, _thumb_gen_size_changed_timer_cb, ephoto);
|
||||
}
|
||||
|
||||
static void
|
||||
_thumb_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj, void *event_info EINA_UNUSED)
|
||||
_thumb_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto *ephoto = data;
|
||||
ephoto->thumbs = eina_list_remove(ephoto->thumbs, obj);
|
||||
}
|
||||
|
||||
static void
|
||||
_load_error(void *data , Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
const char *path = data;
|
||||
ERR("Error loading thumbnail: %s\n", path);
|
||||
ephoto->thumbs = eina_list_remove(ephoto->thumbs, obj);
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
ephoto_thumb_add(Ephoto *ephoto, Evas_Object *parent, const char *path)
|
||||
{
|
||||
Evas_Object *o;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(parent, NULL);
|
||||
|
||||
if (path)
|
||||
{
|
||||
const char *ext = strrchr(path, '.');
|
||||
if (ext)
|
||||
{
|
||||
ext++;
|
||||
if ((strcasecmp(ext, "edj") == 0))
|
||||
o = elm_icon_add(parent);
|
||||
else
|
||||
o = elm_thumb_add(parent);
|
||||
}
|
||||
const char *ext = strrchr(path, '.');
|
||||
|
||||
if (ext)
|
||||
{
|
||||
ext++;
|
||||
if ((strcasecmp(ext, "edj") == 0))
|
||||
o = elm_icon_add(parent);
|
||||
else
|
||||
o = elm_thumb_add(parent);
|
||||
}
|
||||
else
|
||||
o = elm_thumb_add(parent);
|
||||
o = elm_thumb_add(parent);
|
||||
ephoto_thumb_path_set(o, path);
|
||||
}
|
||||
else
|
||||
o = elm_thumb_add(parent);
|
||||
if (!o) return NULL;
|
||||
o = elm_thumb_add(parent);
|
||||
if (!o)
|
||||
return NULL;
|
||||
|
||||
if (path) ephoto_thumb_path_set(o, path);
|
||||
elm_object_style_set(o, "noframe");
|
||||
ephoto->thumbs = eina_list_append(ephoto->thumbs, o);
|
||||
evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, _thumb_del, ephoto);
|
||||
evas_object_smart_callback_add(o, "generate,error", _load_error, path);
|
||||
|
||||
return o;
|
||||
}
|
||||
|
||||
|
@ -517,29 +565,30 @@ ephoto_thumb_path_set(Evas_Object *obj, const char *path)
|
|||
Ethumb_Thumb_Format format = ETHUMB_THUMB_FDO;
|
||||
const char *group = NULL;
|
||||
const char *ext = strrchr(path, '.');
|
||||
|
||||
if (ext)
|
||||
{
|
||||
ext++;
|
||||
if ((strcasecmp(ext, "jpg") == 0) ||
|
||||
(strcasecmp(ext, "jpeg") == 0))
|
||||
format = ETHUMB_THUMB_JPEG; /* faster! */
|
||||
else if ((strcasecmp(ext, "edj") == 0))
|
||||
{
|
||||
if (edje_file_group_exists(path, "e/desktop/background"))
|
||||
group = "e/desktop/background";
|
||||
else
|
||||
{
|
||||
Eina_List *g = edje_file_collection_list(path);
|
||||
group = eina_list_data_get(g);
|
||||
edje_file_collection_list_free(g);
|
||||
}
|
||||
elm_image_file_set(obj, path, group);
|
||||
evas_object_data_set(obj, "ephoto_format", NULL);
|
||||
return;
|
||||
}
|
||||
ext++;
|
||||
if ((strcasecmp(ext, "jpg") == 0) || (strcasecmp(ext, "jpeg") == 0))
|
||||
format = ETHUMB_THUMB_JPEG;
|
||||
else if ((strcasecmp(ext, "edj") == 0))
|
||||
{
|
||||
if (edje_file_group_exists(path, "e/desktop/background"))
|
||||
group = "e/desktop/background";
|
||||
else
|
||||
{
|
||||
Eina_List *g = edje_file_collection_list(path);
|
||||
|
||||
group = eina_list_data_get(g);
|
||||
edje_file_collection_list_free(g);
|
||||
}
|
||||
elm_image_file_set(obj, path, group);
|
||||
evas_object_data_set(obj, "ephoto_format", NULL);
|
||||
return;
|
||||
}
|
||||
}
|
||||
elm_thumb_format_set(obj, format);
|
||||
evas_object_data_set(obj, "ephoto_format", (void*)(long)format);
|
||||
evas_object_data_set(obj, "ephoto_format", (void *) (long) format);
|
||||
elm_thumb_crop_align_set(obj, 0.5, 0.5);
|
||||
elm_thumb_aspect_set(obj, ETHUMB_THUMB_CROP);
|
||||
elm_thumb_orientation_set(obj, ETHUMB_THUMB_ORIENT_ORIGINAL);
|
||||
|
@ -547,20 +596,20 @@ ephoto_thumb_path_set(Evas_Object *obj, const char *path)
|
|||
}
|
||||
|
||||
Ephoto_Entry *
|
||||
ephoto_entry_new(Ephoto *ephoto, const char *path, const char *label, Eina_File_Type type)
|
||||
ephoto_entry_new(Ephoto *ephoto, const char *path, const char *label,
|
||||
Eina_File_Type type)
|
||||
{
|
||||
Ephoto_Entry *entry;
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(path, NULL);
|
||||
|
||||
entry = calloc(1, sizeof(Ephoto_Entry));
|
||||
EINA_SAFETY_ON_NULL_RETURN_VAL(entry, NULL);
|
||||
entry->ephoto = ephoto;
|
||||
entry->path = eina_stringshare_add(path);
|
||||
entry->basename = ecore_file_file_get(entry->path);
|
||||
entry->label = eina_stringshare_add(label);
|
||||
if (type == EINA_FILE_DIR)
|
||||
entry->is_dir = EINA_TRUE;
|
||||
entry->is_dir = EINA_TRUE;
|
||||
else
|
||||
entry->is_dir = EINA_FALSE;
|
||||
entry->is_dir = EINA_FALSE;
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
@ -571,42 +620,40 @@ ephoto_entry_free(Ephoto_Entry *entry)
|
|||
|
||||
EINA_LIST_FREE(entry->free_listeners, fl)
|
||||
{
|
||||
fl->cb((void *)fl->data, entry);
|
||||
fl->cb((void *) fl->data, entry);
|
||||
free(fl);
|
||||
}
|
||||
EINA_SAFETY_ON_NULL_RETURN(entry);
|
||||
eina_stringshare_del(entry->path);
|
||||
eina_stringshare_del(entry->label);
|
||||
free(entry);
|
||||
}
|
||||
|
||||
void
|
||||
ephoto_entry_free_listener_add(Ephoto_Entry *entry, void (*cb)(void *data, const Ephoto_Entry *entry), const void *data)
|
||||
ephoto_entry_free_listener_add(Ephoto_Entry *entry, void (*cb) (void *data,
|
||||
const Ephoto_Entry *entry), const void *data)
|
||||
{
|
||||
Ephoto_Entry_Free_Listener *fl;
|
||||
EINA_SAFETY_ON_NULL_RETURN(entry);
|
||||
EINA_SAFETY_ON_NULL_RETURN(cb);
|
||||
|
||||
fl = malloc(sizeof(Ephoto_Entry_Free_Listener));
|
||||
EINA_SAFETY_ON_NULL_RETURN(fl);
|
||||
fl->cb = cb;
|
||||
fl->data = data;
|
||||
entry->free_listeners = eina_list_append(entry->free_listeners, fl);
|
||||
}
|
||||
|
||||
void
|
||||
ephoto_entry_free_listener_del(Ephoto_Entry *entry, void (*cb)(void *data, const Ephoto_Entry *entry), const void *data)
|
||||
ephoto_entry_free_listener_del(Ephoto_Entry *entry, void (*cb) (void *data,
|
||||
const Ephoto_Entry *entry), const void *data)
|
||||
{
|
||||
Eina_List *l;
|
||||
Ephoto_Entry_Free_Listener *fl;
|
||||
EINA_SAFETY_ON_NULL_RETURN(entry);
|
||||
EINA_SAFETY_ON_NULL_RETURN(cb);
|
||||
|
||||
EINA_LIST_FOREACH(entry->free_listeners, l, fl)
|
||||
{
|
||||
if ((fl->cb == cb) && (fl->data == data))
|
||||
{
|
||||
entry->free_listeners = eina_list_remove_list
|
||||
(entry->free_listeners, l);
|
||||
break;
|
||||
{
|
||||
entry->free_listeners =
|
||||
eina_list_remove_list(entry->free_listeners, l);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -615,6 +662,7 @@ void
|
|||
ephoto_entries_free(Ephoto *ephoto)
|
||||
{
|
||||
Ephoto_Entry *entry;
|
||||
|
||||
EINA_LIST_FREE(ephoto->entries, entry) ephoto_entry_free(entry);
|
||||
EINA_LIST_FREE(ephoto->direntries, entry) ephoto_entry_free(entry);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -8,6 +8,7 @@ struct _Ephoto_Slideshow
|
|||
Evas_Object *slideshow;
|
||||
Evas_Object *notify;
|
||||
Evas_Object *bar;
|
||||
Evas_Object *event;
|
||||
Elm_Widget_Item *pause;
|
||||
Elm_Widget_Item *pause_after;
|
||||
Elm_Widget_Item *fullscreen;
|
||||
|
@ -17,44 +18,23 @@ struct _Ephoto_Slideshow
|
|||
};
|
||||
|
||||
static void
|
||||
_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
Evas_Event_Key_Down *ev = event_info;
|
||||
const char *k = ev->keyname;
|
||||
|
||||
if (!strcmp(k, "Escape"))
|
||||
{
|
||||
Evas_Object *win = ss->ephoto->win;
|
||||
Elm_Object_Item *slideshow_item;
|
||||
Ephoto_Entry *entry;
|
||||
|
||||
slideshow_item = elm_slideshow_item_current_get(ss->slideshow);
|
||||
if (slideshow_item) entry = elm_object_item_data_get(slideshow_item);
|
||||
else entry = ss->entry;
|
||||
evas_object_smart_callback_call(ss->slideshow, "back", entry);
|
||||
elm_slideshow_clear(ss->slideshow);
|
||||
evas_object_hide(ss->notify);
|
||||
ss->playing = 0;
|
||||
evas_object_freeze_events_set(ss->slideshow, EINA_TRUE);
|
||||
}
|
||||
else if (!strcmp(k, "F11"))
|
||||
{
|
||||
Evas_Object *win = ss->ephoto->win;
|
||||
elm_win_fullscreen_set(win, !elm_win_fullscreen_get(win));
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_mouse_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
Elm_Object_Item *slideshow_item;
|
||||
Ephoto_Entry *entry;
|
||||
|
||||
slideshow_item = elm_slideshow_item_current_get(ss->slideshow);
|
||||
if (slideshow_item) entry = elm_object_item_data_get(slideshow_item);
|
||||
else entry = ss->entry;
|
||||
if (slideshow_item)
|
||||
entry = elm_object_item_data_get(slideshow_item);
|
||||
else
|
||||
entry = ss->entry;
|
||||
if (ss->event)
|
||||
{
|
||||
evas_object_del(ss->event);
|
||||
ss->event = NULL;
|
||||
}
|
||||
evas_object_smart_callback_call(ss->slideshow, "back", entry);
|
||||
elm_slideshow_clear(ss->slideshow);
|
||||
evas_object_hide(ss->notify);
|
||||
|
@ -66,20 +46,24 @@ static void
|
|||
_entry_free(void *data, const Ephoto_Entry *entry EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
|
||||
ss->entry = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
_slideshow_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_slideshow_del(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
|
||||
if (ss->entry)
|
||||
ephoto_entry_free_listener_del(ss->entry, _entry_free, ss);
|
||||
ephoto_entry_free_listener_del(ss->entry, _entry_free, ss);
|
||||
free(ss);
|
||||
}
|
||||
|
||||
static void
|
||||
_notify_show(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_notify_show(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
evas_object_show(data);
|
||||
}
|
||||
|
@ -92,8 +76,15 @@ _back(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|||
Ephoto_Entry *entry;
|
||||
|
||||
slideshow_item = elm_slideshow_item_current_get(ss->slideshow);
|
||||
if (slideshow_item) entry = elm_object_item_data_get(slideshow_item);
|
||||
else entry = ss->entry;
|
||||
if (slideshow_item)
|
||||
entry = elm_object_item_data_get(slideshow_item);
|
||||
else
|
||||
entry = ss->entry;
|
||||
if (ss->event)
|
||||
{
|
||||
evas_object_del(ss->event);
|
||||
ss->event = NULL;
|
||||
}
|
||||
evas_object_smart_callback_call(ss->slideshow, "back", entry);
|
||||
elm_slideshow_clear(ss->slideshow);
|
||||
evas_object_hide(ss->notify);
|
||||
|
@ -114,7 +105,7 @@ _next(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|||
}
|
||||
|
||||
static void
|
||||
_pause(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_pause(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
|
||||
|
@ -122,22 +113,26 @@ _pause(void *data EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EI
|
|||
|
||||
if (ss->playing)
|
||||
{
|
||||
elm_slideshow_timeout_set(ss->slideshow, 0.0);
|
||||
ss->pause = elm_toolbar_item_insert_before(ss->bar, ss->pause_after,
|
||||
"media-playback-start", _("Play"), _pause, ss);
|
||||
ss->playing = 0;
|
||||
elm_slideshow_timeout_set(ss->slideshow, 0.0);
|
||||
ss->pause =
|
||||
elm_toolbar_item_insert_before(ss->bar, ss->pause_after,
|
||||
"media-playback-start", _("Play"), _pause, ss);
|
||||
ss->playing = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
elm_slideshow_timeout_set(ss->slideshow, ss->ephoto->config->slideshow_timeout);
|
||||
ss->pause = elm_toolbar_item_insert_before(ss->bar, ss->pause_after,
|
||||
"media-playback-pause", _("Pause"), _pause, ss);
|
||||
ss->playing = 1;
|
||||
elm_slideshow_timeout_set(ss->slideshow,
|
||||
ss->ephoto->config->slideshow_timeout);
|
||||
ss->pause =
|
||||
elm_toolbar_item_insert_before(ss->bar, ss->pause_after,
|
||||
"media-playback-pause", _("Pause"), _pause, ss);
|
||||
ss->playing = 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_previous(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_previous(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
elm_slideshow_previous(data);
|
||||
}
|
||||
|
@ -147,11 +142,12 @@ _last(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
|||
{
|
||||
unsigned int count = elm_slideshow_count_get(data);
|
||||
|
||||
elm_slideshow_item_show(elm_slideshow_item_nth_get(data, count-1));
|
||||
elm_slideshow_item_show(elm_slideshow_item_nth_get(data, count - 1));
|
||||
}
|
||||
|
||||
static void
|
||||
_fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_fullscreen(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
|
||||
|
@ -159,39 +155,200 @@ _fullscreen(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUS
|
|||
|
||||
if (elm_win_fullscreen_get(ss->ephoto->win))
|
||||
{
|
||||
ss->fullscreen = elm_toolbar_item_insert_before(ss->bar, ss->fullscreen_after,
|
||||
"view-fullscreen", _("Fullscreen"), _fullscreen, ss);
|
||||
elm_win_fullscreen_set(ss->ephoto->win, EINA_FALSE);
|
||||
ss->fullscreen =
|
||||
elm_toolbar_item_insert_before(ss->bar, ss->fullscreen_after,
|
||||
"view-fullscreen", _("Fullscreen"), _fullscreen, ss);
|
||||
elm_win_fullscreen_set(ss->ephoto->win, EINA_FALSE);
|
||||
}
|
||||
else
|
||||
{
|
||||
ss->fullscreen = elm_toolbar_item_insert_before(ss->bar, ss->fullscreen_after,
|
||||
"view-restore", _("Normal"), _fullscreen, ss);
|
||||
elm_win_fullscreen_set(ss->ephoto->win, EINA_TRUE);
|
||||
ss->fullscreen =
|
||||
elm_toolbar_item_insert_before(ss->bar, ss->fullscreen_after,
|
||||
"view-restore", _("Normal"), _fullscreen, ss);
|
||||
elm_win_fullscreen_set(ss->ephoto->win, EINA_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_settings(void *data, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_general_settings(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
Evas_Object *popup = data;
|
||||
Ephoto_Slideshow *ss = evas_object_data_get(popup, "slideshow");
|
||||
|
||||
ephoto_config_general(ss->ephoto);
|
||||
}
|
||||
|
||||
static void
|
||||
_slideshow_settings(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *popup = data;
|
||||
Ephoto_Slideshow *ss = evas_object_data_get(popup, "slideshow");
|
||||
|
||||
ephoto_config_slideshow(ss->ephoto);
|
||||
}
|
||||
|
||||
static void
|
||||
_mouse_in(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_about_settings(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *popup = data;
|
||||
Ephoto_Slideshow *ss = evas_object_data_get(popup, "slideshow");
|
||||
|
||||
ephoto_config_about(ss->ephoto);
|
||||
}
|
||||
|
||||
static void
|
||||
_close_settings(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Evas_Object *popup = data;
|
||||
Ephoto_Slideshow *ss = evas_object_data_get(popup, "slideshow");
|
||||
|
||||
evas_object_del(popup);
|
||||
if (ss->event)
|
||||
{
|
||||
evas_object_freeze_events_set(ss->event, EINA_FALSE);
|
||||
elm_object_focus_set(ss->event, EINA_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_settings(void *data, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
Evas_Object *popup, *list, *button, *ic;
|
||||
|
||||
if (ss->event)
|
||||
evas_object_freeze_events_set(ss->event, EINA_TRUE);
|
||||
|
||||
popup = elm_popup_add(ss->ephoto->win);
|
||||
elm_popup_scrollable_set(popup, EINA_TRUE);
|
||||
elm_object_part_text_set(popup, "title,text", _("Settings Panel"));
|
||||
elm_popup_orient_set(popup, ELM_POPUP_ORIENT_CENTER);
|
||||
|
||||
list = elm_list_add(popup);
|
||||
evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_list_mode_set(list, ELM_LIST_EXPAND);
|
||||
|
||||
ic = elm_icon_add(list);
|
||||
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, "preferences-system");
|
||||
evas_object_show(ic);
|
||||
elm_list_item_append(list, _("General Settings"), ic, NULL,
|
||||
_general_settings, popup);
|
||||
|
||||
ic = elm_icon_add(list);
|
||||
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, "media-playback-start");
|
||||
evas_object_show(ic);
|
||||
elm_list_item_append(list, _("Slideshow Settings"), ic, NULL,
|
||||
_slideshow_settings, popup);
|
||||
ic = elm_icon_add(list);
|
||||
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, "help-about");
|
||||
evas_object_show(ic);
|
||||
elm_list_item_append(list, _("About Ephoto"), ic, NULL, _about_settings,
|
||||
popup);
|
||||
|
||||
ic = elm_icon_add(popup);
|
||||
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(popup);
|
||||
elm_object_text_set(button, _("Close"));
|
||||
elm_object_part_content_set(button, "icon", ic);
|
||||
evas_object_smart_callback_add(button, "clicked", _close_settings, popup);
|
||||
elm_object_part_content_set(popup, "button1", button);
|
||||
evas_object_show(button);
|
||||
|
||||
elm_list_go(list);
|
||||
evas_object_show(list);
|
||||
|
||||
evas_object_data_set(popup, "slideshow", ss);
|
||||
elm_object_content_set(popup, list);
|
||||
evas_object_show(popup);
|
||||
}
|
||||
|
||||
static void
|
||||
_mouse_in(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
elm_notify_timeout_set(data, 0.0);
|
||||
evas_object_show(data);
|
||||
}
|
||||
|
||||
static void
|
||||
_mouse_out(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_info EINA_UNUSED)
|
||||
_mouse_out(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info EINA_UNUSED)
|
||||
{
|
||||
elm_notify_timeout_set(data, 3.0);
|
||||
}
|
||||
|
||||
static void
|
||||
_key_down(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_info)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
Evas_Event_Key_Down *ev = event_info;
|
||||
const char *k = ev->keyname;
|
||||
|
||||
if (!strcmp(k, "Escape") || !strcmp(k, "F5"))
|
||||
{
|
||||
_back(ss, NULL, NULL);
|
||||
}
|
||||
else if (!strcmp(k, "F1"))
|
||||
{
|
||||
_settings(ss, NULL, NULL);
|
||||
}
|
||||
else if (!strcmp(k, "F11"))
|
||||
{
|
||||
Evas_Object *win = ss->ephoto->win;
|
||||
|
||||
elm_win_fullscreen_set(win, !elm_win_fullscreen_get(win));
|
||||
}
|
||||
else if (!strcmp(k, "space"))
|
||||
{
|
||||
_pause(ss, NULL, NULL);
|
||||
}
|
||||
else if (!strcmp(k, "Home"))
|
||||
{
|
||||
_first(ss->slideshow, NULL, NULL);
|
||||
}
|
||||
else if (!strcmp(k, "End"))
|
||||
{
|
||||
_last(ss->slideshow, NULL, NULL);
|
||||
}
|
||||
else if (!strcmp(k, "Left"))
|
||||
{
|
||||
_previous(ss->slideshow, NULL, NULL);
|
||||
}
|
||||
else if (!strcmp(k, "Right"))
|
||||
{
|
||||
_next(ss->slideshow, NULL, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
_main_focused(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_data EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Slideshow *ss = data;
|
||||
|
||||
if (ss->ephoto->state == EPHOTO_STATE_SLIDESHOW)
|
||||
{
|
||||
if (ss->event)
|
||||
elm_object_focus_set(ss->event, EINA_TRUE);
|
||||
}
|
||||
}
|
||||
|
||||
Evas_Object *
|
||||
ephoto_slideshow_add(Ephoto *ephoto, Evas_Object *parent)
|
||||
{
|
||||
|
@ -205,26 +362,30 @@ ephoto_slideshow_add(Ephoto *ephoto, Evas_Object *parent)
|
|||
ss->ephoto = ephoto;
|
||||
ss->slideshow = slideshow;
|
||||
ss->playing = 0;
|
||||
evas_object_event_callback_add
|
||||
(slideshow, EVAS_CALLBACK_DEL, _slideshow_del, ss);
|
||||
evas_object_event_callback_add
|
||||
(slideshow, EVAS_CALLBACK_KEY_DOWN, _key_down, ss);
|
||||
evas_object_event_callback_add
|
||||
(slideshow, EVAS_CALLBACK_MOUSE_DOWN, _mouse_down, ss);
|
||||
evas_object_data_set(slideshow, "slideshow", ss);
|
||||
ss->event = NULL;
|
||||
|
||||
evas_object_event_callback_add(slideshow, EVAS_CALLBACK_DEL, _slideshow_del,
|
||||
ss);
|
||||
evas_object_event_callback_add(slideshow, EVAS_CALLBACK_MOUSE_DOWN,
|
||||
_mouse_down, ss);
|
||||
evas_object_event_callback_add(ss->ephoto->win, EVAS_CALLBACK_FOCUS_IN,
|
||||
_main_focused, ss);
|
||||
evas_object_data_set(slideshow, "slideshow", ss);
|
||||
elm_object_tree_focus_allow_set(slideshow, EINA_FALSE);
|
||||
elm_slideshow_loop_set(slideshow, EINA_TRUE);
|
||||
elm_slideshow_layout_set(slideshow, "fullscreen");
|
||||
evas_object_size_hint_weight_set
|
||||
(slideshow, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_weight_set(slideshow, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_align_set(slideshow, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
|
||||
ss->notify = elm_notify_add(ephoto->win);
|
||||
elm_notify_align_set(ss->notify, 0.5, 1.0);
|
||||
evas_object_size_hint_weight_set(ss->notify, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
|
||||
evas_object_size_hint_weight_set(ss->notify, EVAS_HINT_EXPAND,
|
||||
EVAS_HINT_EXPAND);
|
||||
elm_notify_timeout_set(ss->notify, 3.0);
|
||||
elm_win_resize_object_add(ephoto->win, ss->notify);
|
||||
evas_object_event_callback_add(slideshow, EVAS_CALLBACK_MOUSE_MOVE, _notify_show, ss->notify);
|
||||
evas_object_event_callback_add(slideshow, EVAS_CALLBACK_MOUSE_MOVE,
|
||||
_notify_show, ss->notify);
|
||||
elm_object_tree_focus_allow_set(ss->notify, EINA_FALSE);
|
||||
|
||||
ss->bar = elm_toolbar_add(ss->notify);
|
||||
elm_toolbar_horizontal_set(ss->bar, EINA_TRUE);
|
||||
|
@ -235,17 +396,30 @@ ephoto_slideshow_add(Ephoto *ephoto, Evas_Object *parent)
|
|||
evas_object_size_hint_weight_set(ss->bar, EVAS_HINT_EXPAND, 0.0);
|
||||
evas_object_size_hint_align_set(ss->bar, EVAS_HINT_FILL, EVAS_HINT_FILL);
|
||||
elm_object_content_set(ss->notify, ss->bar);
|
||||
evas_object_event_callback_add(ss->bar, EVAS_CALLBACK_MOUSE_IN, _mouse_in, ss->notify);
|
||||
evas_object_event_callback_add(ss->bar, EVAS_CALLBACK_MOUSE_OUT, _mouse_out, ss->notify);
|
||||
elm_object_tree_focus_allow_set(ss->bar, EINA_FALSE);
|
||||
evas_object_event_callback_add(ss->bar, EVAS_CALLBACK_MOUSE_IN, _mouse_in,
|
||||
ss->notify);
|
||||
evas_object_event_callback_add(ss->bar, EVAS_CALLBACK_MOUSE_OUT, _mouse_out,
|
||||
ss->notify);
|
||||
|
||||
elm_toolbar_item_append(ss->bar, "window-close", _("Back"), _back, ss);
|
||||
elm_toolbar_item_append(ss->bar, "go-first", _("First"), _first, ss->slideshow);
|
||||
elm_toolbar_item_append(ss->bar, "go-previous", _("Previous"), _previous, ss->slideshow);
|
||||
ss->pause = elm_toolbar_item_append(ss->bar, "media-playback-start", _("Play"), _pause, ss);
|
||||
ss->pause_after = elm_toolbar_item_append(ss->bar, "go-next", _("Next"), _next, ss->slideshow);
|
||||
elm_toolbar_item_append(ss->bar, "go-first", _("First"), _first,
|
||||
ss->slideshow);
|
||||
elm_toolbar_item_append(ss->bar, "go-previous", _("Previous"), _previous,
|
||||
ss->slideshow);
|
||||
ss->pause =
|
||||
elm_toolbar_item_append(ss->bar, "media-playback-start", _("Play"),
|
||||
_pause, ss);
|
||||
ss->pause_after =
|
||||
elm_toolbar_item_append(ss->bar, "go-next", _("Next"), _next,
|
||||
ss->slideshow);
|
||||
elm_toolbar_item_append(ss->bar, "go-last", _("Last"), _last, ss->slideshow);
|
||||
ss->fullscreen = elm_toolbar_item_append(ss->bar, "view-fullscreen", _("Fullscreen"), _fullscreen, ss);
|
||||
ss->fullscreen_after = elm_toolbar_item_append(ss->bar, "preferences-system", _("Settings"), _settings, ss);
|
||||
ss->fullscreen =
|
||||
elm_toolbar_item_append(ss->bar, "view-fullscreen", _("Fullscreen"),
|
||||
_fullscreen, ss);
|
||||
ss->fullscreen_after =
|
||||
elm_toolbar_item_append(ss->bar, "preferences-system", _("Settings"),
|
||||
_settings, ss);
|
||||
|
||||
evas_object_show(ss->bar);
|
||||
|
||||
|
@ -253,14 +427,17 @@ ephoto_slideshow_add(Ephoto *ephoto, Evas_Object *parent)
|
|||
|
||||
return ss->slideshow;
|
||||
|
||||
error:
|
||||
error:
|
||||
evas_object_del(slideshow);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void _image_shown(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED, void *event_data EINA_UNUSED)
|
||||
static void
|
||||
_image_shown(void *data, Evas *e EINA_UNUSED, Evas_Object *obj EINA_UNUSED,
|
||||
void *event_data EINA_UNUSED)
|
||||
{
|
||||
Ephoto_Entry *entry = data;
|
||||
|
||||
ephoto_title_set(entry->ephoto, entry->basename);
|
||||
}
|
||||
|
||||
|
@ -271,30 +448,35 @@ _slideshow_item_get(void *data, Evas_Object *obj)
|
|||
|
||||
const char *group = NULL;
|
||||
const char *ext = strrchr(entry->path, '.');
|
||||
|
||||
if (ext)
|
||||
{
|
||||
ext++;
|
||||
if ((strcasecmp(ext, "edj") == 0))
|
||||
{
|
||||
if (edje_file_group_exists(entry->path, "e/desktop/background"))
|
||||
group = "e/desktop/background";
|
||||
else
|
||||
{
|
||||
Eina_List *g = edje_file_collection_list(entry->path);
|
||||
group = eina_list_data_get(g);
|
||||
edje_file_collection_list_free(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
ext++;
|
||||
if ((strcasecmp(ext, "edj") == 0))
|
||||
{
|
||||
if (edje_file_group_exists(entry->path, "e/desktop/background"))
|
||||
group = "e/desktop/background";
|
||||
else
|
||||
{
|
||||
Eina_List *g = edje_file_collection_list(entry->path);
|
||||
|
||||
group = eina_list_data_get(g);
|
||||
edje_file_collection_list_free(g);
|
||||
}
|
||||
}
|
||||
}
|
||||
Evas_Object *image = elm_image_add(obj);
|
||||
|
||||
elm_image_file_set(image, entry->path, group);
|
||||
elm_object_style_set(image, "shadow");
|
||||
evas_object_event_callback_add(image, EVAS_CALLBACK_SHOW, _image_shown, entry);
|
||||
evas_object_event_callback_add(image, EVAS_CALLBACK_SHOW, _image_shown,
|
||||
entry);
|
||||
|
||||
return image;
|
||||
}
|
||||
|
||||
static const Elm_Slideshow_Item_Class _item_cls = {{_slideshow_item_get, NULL}};
|
||||
static const Elm_Slideshow_Item_Class _item_cls =
|
||||
{ {_slideshow_item_get, NULL} };
|
||||
|
||||
void
|
||||
ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry)
|
||||
|
@ -302,50 +484,71 @@ ephoto_slideshow_entry_set(Evas_Object *obj, Ephoto_Entry *entry)
|
|||
Ephoto_Slideshow *ss = evas_object_data_get(obj, "slideshow");
|
||||
Ephoto_Entry *itr;
|
||||
const Eina_List *l;
|
||||
EINA_SAFETY_ON_NULL_RETURN(ss);
|
||||
|
||||
if (ss->entry)
|
||||
ephoto_entry_free_listener_del(ss->entry, _entry_free, ss);
|
||||
ephoto_entry_free_listener_del(ss->entry, _entry_free, ss);
|
||||
|
||||
ss->entry = entry;
|
||||
|
||||
if (entry)
|
||||
ephoto_entry_free_listener_add(entry, _entry_free, ss);
|
||||
ephoto_entry_free_listener_add(entry, _entry_free, ss);
|
||||
|
||||
elm_slideshow_loop_set(ss->slideshow, EINA_TRUE);
|
||||
elm_slideshow_transition_set(ss->slideshow, ss->ephoto->config->slideshow_transition);
|
||||
elm_slideshow_timeout_set(ss->slideshow, ss->ephoto->config->slideshow_timeout);
|
||||
elm_slideshow_transition_set(ss->slideshow,
|
||||
ss->ephoto->config->slideshow_transition);
|
||||
elm_slideshow_timeout_set(ss->slideshow,
|
||||
ss->ephoto->config->slideshow_timeout);
|
||||
elm_slideshow_clear(ss->slideshow);
|
||||
if (!entry) return;
|
||||
if (!entry)
|
||||
return;
|
||||
|
||||
evas_object_freeze_events_set(ss->slideshow, EINA_FALSE);
|
||||
|
||||
if (ss->pause)
|
||||
{
|
||||
elm_object_item_del(ss->pause);
|
||||
ss->pause = elm_toolbar_item_insert_before(ss->bar, ss->pause_after,
|
||||
"media-playback-pause", _("Pause"), _pause, ss);
|
||||
ss->playing = 1;
|
||||
elm_object_item_del(ss->pause);
|
||||
ss->pause =
|
||||
elm_toolbar_item_insert_before(ss->bar, ss->pause_after,
|
||||
"media-playback-pause", _("Pause"), _pause, ss);
|
||||
ss->playing = 1;
|
||||
}
|
||||
if (ss->fullscreen)
|
||||
{
|
||||
elm_object_item_del(ss->fullscreen);
|
||||
if (elm_win_fullscreen_get(ss->ephoto->win))
|
||||
{
|
||||
ss->fullscreen = elm_toolbar_item_insert_before(ss->bar, ss->fullscreen_after,
|
||||
"view-restore", _("Normal"), _fullscreen, ss);
|
||||
}
|
||||
elm_object_item_del(ss->fullscreen);
|
||||
if (elm_win_fullscreen_get(ss->ephoto->win))
|
||||
{
|
||||
ss->fullscreen =
|
||||
elm_toolbar_item_insert_before(ss->bar, ss->fullscreen_after,
|
||||
"view-restore", _("Normal"), _fullscreen, ss);
|
||||
}
|
||||
else
|
||||
{
|
||||
ss->fullscreen = elm_toolbar_item_insert_before(ss->bar, ss->fullscreen_after,
|
||||
"view-fullscreen", _("Fullscreen"), _fullscreen, ss);
|
||||
}
|
||||
{
|
||||
ss->fullscreen =
|
||||
elm_toolbar_item_insert_before(ss->bar, ss->fullscreen_after,
|
||||
"view-fullscreen", _("Fullscreen"), _fullscreen, ss);
|
||||
}
|
||||
}
|
||||
|
||||
EINA_LIST_FOREACH(ss->ephoto->entries, l, itr)
|
||||
{
|
||||
Elm_Object_Item *slideshow_item;
|
||||
|
||||
slideshow_item = elm_slideshow_item_add(ss->slideshow, &_item_cls, itr);
|
||||
if (itr == entry) elm_slideshow_item_show(slideshow_item);
|
||||
if (itr == entry)
|
||||
elm_slideshow_item_show(slideshow_item);
|
||||
}
|
||||
if (ss->event)
|
||||
{
|
||||
evas_object_del(ss->event);
|
||||
ss->event = NULL;
|
||||
}
|
||||
ss->event = evas_object_rectangle_add(ss->ephoto->win);
|
||||
evas_object_smart_member_add(ss->event, ss->ephoto->win);
|
||||
evas_object_color_set(ss->event, 0, 0, 0, 0);
|
||||
evas_object_repeat_events_set(ss->event, EINA_TRUE);
|
||||
evas_object_show(ss->event);
|
||||
evas_object_event_callback_add(ss->event, EVAS_CALLBACK_KEY_DOWN, _key_down,
|
||||
ss);
|
||||
evas_object_raise(ss->event);
|
||||
elm_object_focus_set(ss->event, EINA_TRUE);
|
||||
}
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue