add a flow browser

SVN revision: 42827
This commit is contained in:
titan 2009-10-01 04:54:48 +00:00 committed by titan
parent f51a365753
commit ca69fd3fe2
7 changed files with 408 additions and 28 deletions

View File

@ -11,6 +11,8 @@ ephoto_SOURCES = \
ephoto_main.c \
ephoto_image.c \
ephoto_image_browser.c \
ephoto_flow.c \
ephoto_flow_browser.c \
ephoto_table.c
ephoto_CFLAGS = @EVAS_CFLAGS@ @EDJE_CFLAGS@ @EINA_CFLAGS@ @EFREET_MIME_CFLAGS@ @ETHUMB_CFLAGS@ -Wall -g

View File

@ -32,10 +32,21 @@
void create_main_window(void);
/*Ephoto Image Browser*/
void add_image_browser(void);
void show_image_browser(void);
void hide_image_browser(void);
void populate_thumbnails(void);
/*Ephoto Flow Browser*/
void add_flow_view(void);
void show_flow_view(Eina_List *node, Eina_List *list);
void hide_flow_view(void);
/*Ephoto Flow*/
Evas_Object *ephoto_flow_add(Evas *e);
void ephoto_flow_current_node_set(Evas_Object *obj, Eina_List *node);
void ephoto_flow_item_list_set(Evas_Object *obj, Eina_List *list);
/*Ephoto Image*/
Evas_Object *ephoto_image_add();
void ephoto_image_file_set(Evas_Object *obj, const char *file, int w, int h);
@ -51,6 +62,7 @@ void ephoto_table_pack(Evas_Object *obj, char *image);
void ephoto_table_viewport_set(Evas_Object *obj, int w, int h);
void ephoto_table_next_page(Evas_Object *obj);
void ephoto_table_prev_page(Evas_Object *obj);
void reshow_table_items(Evas_Object *obj);
typedef struct _Ephoto Ephoto;
struct _Ephoto
@ -61,6 +73,7 @@ struct _Ephoto
Evas_Object *bg;
Evas_Object *image_browser;
Evas_Object *image_browser_tbl;
Evas_Object *flow;
Evas_Object *sel;
Eina_List *images;
};

270
src/bin/ephoto_flow.c Normal file
View File

@ -0,0 +1,270 @@
#include "ephoto.h"
typedef struct _Smart_Data Smart_Data;
struct _Smart_Data
{
Evas_Object *obj;
int x;
int y;
int w;
int h;
Evas_Object *center_image;
Eina_List *current_node;
Eina_List *list;
};
static Evas_Smart *_smart = NULL;
static void _flow_smart_reconfigure(Smart_Data *sd);
static void _flow_smart_init(void);
static void _flow_smart_add(Evas_Object *obj);
static void _flow_smart_del(Evas_Object *obj);
static void _flow_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y);
static void _flow_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h);
static void _flow_smart_show(Evas_Object *obj);
static void _flow_smart_hide(Evas_Object *obj);
static void _flow_smart_color_set(Evas_Object *obj, int r, int g, int b, int a);
static void _flow_smart_clip_set(Evas_Object *obj, Evas_Object *clip);
static void _flow_smart_clip_unset(Evas_Object *obj);
static void move_left(void *data, Evas_Object *obj, const char *emission, const char *source);
static void move_right(void *data, Evas_Object *obj, const char *emission, const char *source);
static void go_back(void *data, Evas_Object *obj, const char *emission, const char *source);
static void move_left(void *data, Evas_Object *obj, const char *emission, const char *source)
{
Smart_Data *sd;
sd = data;
if (sd->current_node->prev)
sd->current_node = sd->current_node->prev;
else
sd->current_node = eina_list_last(sd->list);
_flow_smart_reconfigure(sd);
printf("Left\n");
}
static void move_right(void *data, Evas_Object *obj, const char *emission, const char *source)
{
Smart_Data *sd;
sd = data;
if (sd->current_node->next)
sd->current_node = sd->current_node->next;
else
sd->current_node = sd->list;
_flow_smart_reconfigure(sd);
printf("Right\n");
}
static void go_back(void *data, Evas_Object *obj, const char *emission, const char *source)
{
hide_flow_view();
show_image_browser();
}
Evas_Object *ephoto_flow_add(Evas *e)
{
_flow_smart_init();
return evas_object_smart_add(e, _smart);
}
void ephoto_flow_current_node_set(Evas_Object *obj, Eina_List *node)
{
Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
sd->current_node = node;
_flow_smart_reconfigure(sd);
return;
}
void ephoto_flow_item_list_set(Evas_Object *obj, Eina_List *list)
{
Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
sd->list = list;
return;
}
static void _flow_smart_reconfigure(Smart_Data *sd)
{
char *center;
int w, h, nw, nh;
center = sd->current_node->data;
evas_object_geometry_get(sd->obj, 0, 0, &w, &h);
nw = w/1.2;
nh = h/1.2;
edje_object_part_unswallow(sd->obj, sd->center_image);
ephoto_image_fill_inside_set(sd->center_image, 1);
ephoto_image_file_set(sd->center_image, center, nw, nh);
evas_object_resize(sd->center_image, nw, nh);
evas_object_size_hint_min_set(sd->center_image, nw, nh);
evas_object_size_hint_max_set(sd->center_image, nw, nh);
edje_object_part_swallow(sd->obj, "ephoto.swallow.content", sd->center_image);
return;
}
static void _flow_smart_init(void)
{
if (_smart)
return;
{
static const Evas_Smart_Class sc =
{
"ephoto_flow",
EVAS_SMART_CLASS_VERSION,
_flow_smart_add,
_flow_smart_del,
_flow_smart_move,
_flow_smart_resize,
_flow_smart_show,
_flow_smart_hide,
_flow_smart_color_set,
_flow_smart_clip_set,
_flow_smart_clip_unset,
NULL,
NULL
};
_smart = evas_smart_class_new(&sc);
}
}
static void _flow_smart_add(Evas_Object *obj)
{
Smart_Data *sd;
sd = calloc(1, sizeof(Smart_Data));
if (!sd)
return;
sd->w = 0;
sd->h = 0;
sd->x = 0;
sd->y = 0;
sd->obj = edje_object_add(em->e);
edje_object_file_set(sd->obj, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", "/ephoto/flow/view");
evas_object_smart_data_set(obj, sd);
edje_object_signal_callback_add(sd->obj, "mouse,up,1", "move_left", move_left, sd);
edje_object_signal_callback_add(sd->obj, "mouse,up,1", "move_right", move_right, sd);
edje_object_signal_callback_add(sd->obj, "mouse,up,1", "back", go_back, sd);
sd->center_image = ephoto_image_add();
edje_object_part_swallow(sd->obj, "ephoto.swallow.content", sd->center_image);
}
static void _flow_smart_del(Evas_Object *obj)
{
Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd)
return;
evas_object_del(sd->center_image);
evas_object_del(sd->obj);
free(sd);
}
static void _flow_smart_move(Evas_Object *obj, Evas_Coord x, Evas_Coord y)
{
Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd)
return;
if ((x == sd->x) && (y == sd->y))
return;
sd->x = x;
sd->y = y;
evas_object_move(sd->obj, x, y);
_flow_smart_reconfigure(sd);
}
static void _flow_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
{
Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd)
return;
if ((w == sd->w) && (h == sd->h))
return;
sd->w = w;
sd->h = h;
evas_object_resize(sd->obj, w, h);
_flow_smart_reconfigure(sd);
}
static void _flow_smart_show(Evas_Object *obj)
{
Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd)
return;
evas_object_show(sd->obj);
evas_object_show(sd->center_image);
}
static void _flow_smart_hide(Evas_Object *obj)
{
Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd)
return;
evas_object_hide(sd->obj);
evas_object_hide(sd->center_image);
}
static void _flow_smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
{
Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd)
return;
evas_object_color_set(sd->obj, r, g, b, a);
}
static void _flow_smart_clip_set(Evas_Object *obj, Evas_Object *clip)
{
Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd)
return;
evas_object_clip_set(sd->obj, clip);
return;
}
static void _flow_smart_clip_unset(Evas_Object *obj)
{
Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd)
return;
evas_object_clip_unset(sd->obj);
return;
}

View File

@ -0,0 +1,23 @@
#include "ephoto.h"
void add_flow_view(void)
{
Evas_Object *o;
o = ephoto_flow_add(em->e);
em->flow = o;
}
void show_flow_view(Eina_List *node, Eina_List *list)
{
ephoto_flow_current_node_set(em->flow, node);
ephoto_flow_item_list_set(em->flow, list);
evas_object_show(em->flow);
edje_object_part_swallow(em->bg, "ephoto.swallow.content", em->flow);
}
void hide_flow_view(void)
{
evas_object_hide(em->flow);
edje_object_part_unswallow(em->bg, em->flow);
}

View File

@ -7,23 +7,19 @@ static Ecore_Idler *idler;
static DIR *direc;
/*Show the Image Browser*/
void show_image_browser(void)
void add_image_browser(void)
{
Evas_Object *o;
int x, y, w, h;
o = edje_object_add(em->e);
edje_object_file_set(o, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", "/ephoto/image/browser");
edje_object_part_swallow(em->bg, "ephoto.swallow.content", o);
evas_object_show(o);
em->image_browser = o;
edje_object_part_geometry_get(em->bg, "ephoto.swallow.content", &x, &y, &w, &h);
o = ephoto_table_add(em->e);
ephoto_table_padding_set(o, 20, 20);
ephoto_table_viewport_set(o, w, h);
evas_object_show(o);
edje_object_part_swallow(em->image_browser, "ephoto.swallow.content", o);
em->image_browser_tbl = o;
@ -32,9 +28,22 @@ void show_image_browser(void)
edje_object_signal_callback_add(em->image_browser, "mouse,up,1", "move_right", move_right, NULL);
}
void show_image_browser(void)
{
int w, h;
evas_object_show(em->image_browser);
evas_object_show(em->image_browser_tbl);
edje_object_part_swallow(em->bg, "ephoto.swallow.content", em->image_browser);
edje_object_part_geometry_get(em->bg, "ephoto.swallow.content", 0, 0, &w, &h);
reshow_table_items(em->image_browser_tbl);
ephoto_table_viewport_set(em->image_browser_tbl, w, h);
}
void hide_image_browser(void)
{
evas_object_hide(em->image_browser);
evas_object_hide(em->image_browser_tbl);
edje_object_part_unswallow(em->bg, em->image_browser);
}
static void move_left(void *data, Evas_Object *obj, const char *emission, const char *source)

View File

@ -35,6 +35,8 @@ void create_main_window(void)
static void
window_shown(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
add_image_browser();
add_flow_view();
show_image_browser();
evas_object_event_callback_del(em->bg, EVAS_CALLBACK_SHOW, window_shown);
}

View File

@ -47,23 +47,6 @@ static void thumb_generated(void *data, Ethumb_Client *client, int id, const cha
const char *thumb_path, const char *thumb_key,
Eina_Bool success);
Evas_Object *ephoto_table_add(Evas *e)
{
_table_smart_init();
return evas_object_smart_add(e, _smart);
}
void ephoto_table_padding_set(Evas_Object *obj, int paddingw, int paddingh)
{
Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd)
return;
sd->paddingw = paddingw;
sd->paddingh = paddingh;
}
static void connect_callback(void *data, Ethumb_Client *client, Eina_Bool success)
{
printf("Connected to ethumb client: %d\n", success);
@ -85,6 +68,7 @@ static void thumb_generated(void *data, Ethumb_Client *client, int id, const cha
if (success)
{
img = data;
evas_object_event_callback_add(img, EVAS_CALLBACK_MOUSE_DOWN, image_clicked, NULL);
edje = edje_object_add(em->e);
edje_object_file_set(edje, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", "/ephoto/thumb/image");
@ -92,7 +76,6 @@ static void thumb_generated(void *data, Ethumb_Client *client, int id, const cha
evas_object_show(edje);
o = ephoto_image_add();
evas_object_event_callback_add(o, EVAS_CALLBACK_MOUSE_UP, image_clicked, img);
evas_object_show(o);
edje_object_part_swallow(edje, "ephoto.swallow.content", o);
edje_object_part_swallow(img, "ephoto.swallow.content", edje);
@ -130,16 +113,87 @@ static void thumb_generated(void *data, Ethumb_Client *client, int id, const cha
static void image_clicked(void *data, Evas *e, Evas_Object *obj, void *event_info)
{
Evas_Object *img;
Eina_List *node;
Evas_Event_Mouse_Down *ev;
Smart_Data *sd;
img = data;
ev = event_info;
sd = evas_object_smart_data_get(em->image_browser_tbl);
if (img == em->sel)
if (ev->flags == EVAS_BUTTON_DOUBLE_CLICK)
{
edje_object_signal_emit(em->image_browser, "ephoto.browser.hidden", "ephoto");
node = evas_object_data_get(obj, "image");
if (sd->items)
{
Eina_List *iterator;
Evas_Object *o, *i;;
iterator = sd->items;
while(eina_list_data_get(iterator))
{
o = eina_list_data_get(iterator);
i = edje_object_part_swallow_get(o, "ephoto.swallow.content");
edje_object_signal_emit(i, "ephoto.thumb.hidden", "ephoto");
edje_object_signal_emit(o, "ephoto.thumb.hidden", "ephoto");
iterator = eina_list_next(iterator);
}
}
hide_image_browser();
show_flow_view(node, sd->images);
return;
}
if (obj == em->sel)
return;
if (em->sel)
edje_object_signal_emit(em->sel, "ephoto.thumb.deselected", "ephoto");
edje_object_signal_emit(img, "ephoto.thumb.selected", "ephoto");
em->sel = img;
edje_object_signal_emit(obj, "ephoto.thumb.selected", "ephoto");
em->sel = obj;
}
void reshow_table_items(Evas_Object *obj)
{
Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd)
return;
if (sd->items)
{
Eina_List *iterator;
Evas_Object *o, *i;;
iterator = sd->items;
while(eina_list_data_get(iterator))
{
o = eina_list_data_get(iterator);
i = edje_object_part_swallow_get(o, "ephoto.swallow.content");
edje_object_signal_emit(i, "ephoto.thumb.visible", "ephoto");
edje_object_signal_emit(o, "ephoto.thumb.visible", "ephoto");
iterator = eina_list_next(iterator);
}
}
}
Evas_Object *ephoto_table_add(Evas *e)
{
_table_smart_init();
return evas_object_smart_add(e, _smart);
}
void ephoto_table_padding_set(Evas_Object *obj, int paddingw, int paddingh)
{
Smart_Data *sd;
sd = evas_object_smart_data_get(obj);
if (!sd)
return;
sd->paddingw = paddingw;
sd->paddingh = paddingh;
}
void ephoto_table_pack(Evas_Object *obj, char *image)
@ -151,6 +205,7 @@ void ephoto_table_pack(Evas_Object *obj, char *image)
const char *thumb;
sd = evas_object_smart_data_get(obj);
sd->images = eina_list_append(sd->images, strdup(image));
@ -175,6 +230,7 @@ void ephoto_table_pack(Evas_Object *obj, char *image)
evas_object_move(img, sd->tw, sd->th);
evas_object_show(img);
edje_object_signal_emit(img, "ephoto.thumb.visible", "ephoto");
evas_object_data_set(img, "image", eina_list_nth_list(sd->images, eina_list_count(sd->images)-1));
evas_object_resize(img, sd->item_w, sd->item_h);
evas_object_size_hint_min_set(img, sd->item_w, sd->item_h);
@ -392,6 +448,7 @@ static void _table_smart_change_page(Smart_Data *sd, int direction)
evas_object_show(img);
evas_object_event_callback_add(img, EVAS_CALLBACK_MOUSE_UP, image_clicked, NULL);
edje_object_signal_emit(img, "ephoto.thumb.visible", "ephoto");
evas_object_data_set(img, "image", iteratorb);
evas_object_resize(img, sd->item_w, sd->item_h);
evas_object_size_hint_min_set(img, sd->item_w, sd->item_h);
@ -469,6 +526,7 @@ static void _table_smart_reconfigure(Smart_Data *sd)
else
{
evas_object_show(i);
edje_object_signal_emit(i, "ephoto.thumb.visible", "ephoto");
evas_object_move(i, sd->tw, sd->th);
edje_object_signal_emit(i, "ephoto.thumb.visible", "ephoto");
@ -500,6 +558,7 @@ static void _table_smart_reconfigure(Smart_Data *sd)
evas_object_show(img);
evas_object_event_callback_add(img, EVAS_CALLBACK_MOUSE_UP, image_clicked, NULL);
edje_object_signal_emit(img, "ephoto.thumb.visible", "ephoto");
evas_object_data_set(img, "image", iteratorb);
evas_object_resize(img, sd->item_w, sd->item_h);
evas_object_size_hint_min_set(img, sd->item_w, sd->item_h);
@ -672,6 +731,7 @@ static void _table_smart_show(Evas_Object *obj)
sd = evas_object_smart_data_get(obj);
if (!sd)
return;
evas_object_show(sd->obj);
}
@ -682,6 +742,7 @@ static void _table_smart_hide(Evas_Object *obj)
sd = evas_object_smart_data_get(obj);
if (!sd)
return;
evas_object_hide(sd->obj);
}