Fix a bug on resizing.

SVN revision: 42838
This commit is contained in:
titan 2009-10-01 17:45:35 +00:00 committed by titan
parent ca69fd3fe2
commit 9236d613b9
4 changed files with 54 additions and 100 deletions

View File

@ -62,7 +62,6 @@ void ephoto_table_pack(Evas_Object *obj, char *image);
void ephoto_table_viewport_set(Evas_Object *obj, int w, int h); void ephoto_table_viewport_set(Evas_Object *obj, int w, int h);
void ephoto_table_next_page(Evas_Object *obj); void ephoto_table_next_page(Evas_Object *obj);
void ephoto_table_prev_page(Evas_Object *obj); void ephoto_table_prev_page(Evas_Object *obj);
void reshow_table_items(Evas_Object *obj);
typedef struct _Ephoto Ephoto; typedef struct _Ephoto Ephoto;
struct _Ephoto struct _Ephoto
@ -72,7 +71,6 @@ struct _Ephoto
Ethumb_Client *thumb_cli; Ethumb_Client *thumb_cli;
Evas_Object *bg; Evas_Object *bg;
Evas_Object *image_browser; Evas_Object *image_browser;
Evas_Object *image_browser_tbl;
Evas_Object *flow; Evas_Object *flow;
Evas_Object *sel; Evas_Object *sel;
Eina_List *images; Eina_List *images;

View File

@ -1,7 +1,5 @@
#include "ephoto.h" #include "ephoto.h"
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 int get_thumbnails(void *data); static int get_thumbnails(void *data);
static Ecore_Idler *idler; static Ecore_Idler *idler;
static DIR *direc; static DIR *direc;
@ -10,54 +8,27 @@ static DIR *direc;
void add_image_browser(void) void add_image_browser(void)
{ {
Evas_Object *o; 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");
em->image_browser = o;
edje_object_part_geometry_get(em->bg, "ephoto.swallow.content", &x, &y, &w, &h);
o = ephoto_table_add(em->e); o = ephoto_table_add(em->e);
ephoto_table_padding_set(o, 20, 20); ephoto_table_padding_set(o, 20, 20);
edje_object_part_swallow(em->image_browser, "ephoto.swallow.content", o); em->image_browser = o;
em->image_browser_tbl = o;
edje_object_signal_callback_add(em->image_browser, "mouse,up,1", "move_left", move_left, NULL);
edje_object_signal_callback_add(em->image_browser, "mouse,up,1", "move_right", move_right, NULL);
} }
void show_image_browser(void) void show_image_browser(void)
{ {
int w, h; int w, h;
evas_object_show(em->image_browser); 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_swallow(em->bg, "ephoto.swallow.content", em->image_browser);
edje_object_part_geometry_get(em->bg, "ephoto.swallow.content", 0, 0, &w, &h); 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, w, h);
ephoto_table_viewport_set(em->image_browser_tbl, w, h);
} }
void hide_image_browser(void) void hide_image_browser(void)
{ {
evas_object_hide(em->image_browser); evas_object_hide(em->image_browser);
evas_object_hide(em->image_browser_tbl);
edje_object_part_unswallow(em->bg, em->image_browser); edje_object_part_unswallow(em->bg, em->image_browser);
} }
static void move_left(void *data, Evas_Object *obj, const char *emission, const char *source)
{
ephoto_table_prev_page(em->image_browser_tbl);
printf("Left\n");
}
static void move_right(void *data, Evas_Object *obj, const char *emission, const char *source)
{
ephoto_table_next_page(em->image_browser_tbl);
printf("Right\n");
}
/*Get a list of images and begin to thumbnail them*/ /*Get a list of images and begin to thumbnail them*/
/*They will be passed to create_thumbnail for creation*/ /*They will be passed to create_thumbnail for creation*/
void populate_thumbnails(void) void populate_thumbnails(void)
@ -99,7 +70,7 @@ static int get_thumbnails(void *data)
if (!strncmp(type, "image", 5)) if (!strncmp(type, "image", 5))
{ {
em->images = eina_list_append(em->images, strdup(path)); em->images = eina_list_append(em->images, strdup(path));
ephoto_table_pack(em->image_browser_tbl, strdup(path)); ephoto_table_pack(em->image_browser, strdup(path));
} }
} }
} }

View File

@ -44,7 +44,8 @@ window_shown(void *data, Evas *e, Evas_Object *obj, void *event_info)
/*The window has been closed, free and quit*/ /*The window has been closed, free and quit*/
static void window_close(Ecore_Evas *ee) static void window_close(Ecore_Evas *ee)
{ {
evas_object_del(em->image_browser_tbl); evas_object_del(em->image_browser);
evas_object_del(em->flow);
if (em->images) if (em->images)
eina_list_free(em->images); eina_list_free(em->images);
free(em); free(em);

View File

@ -42,11 +42,25 @@ static void _table_smart_color_set(Evas_Object *obj, int r, int g, int b, int a)
static void _table_smart_clip_set(Evas_Object *obj, Evas_Object *clip); static void _table_smart_clip_set(Evas_Object *obj, Evas_Object *clip);
static void _table_smart_clip_unset(Evas_Object *obj); static void _table_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 connect_callback(void *data, Ethumb_Client *client, Eina_Bool success); static void connect_callback(void *data, Ethumb_Client *client, Eina_Bool success);
static void thumb_generated(void *data, Ethumb_Client *client, int id, const char *file, const char *key, static void thumb_generated(void *data, Ethumb_Client *client, int id, const char *file, const char *key,
const char *thumb_path, const char *thumb_key, const char *thumb_path, const char *thumb_key,
Eina_Bool success); Eina_Bool success);
static void move_left(void *data, Evas_Object *obj, const char *emission, const char *source)
{
ephoto_table_prev_page(em->image_browser);
printf("Left\n");
}
static void move_right(void *data, Evas_Object *obj, const char *emission, const char *source)
{
ephoto_table_next_page(em->image_browser);
printf("Right\n");
}
static void connect_callback(void *data, Ethumb_Client *client, Eina_Bool success) static void connect_callback(void *data, Ethumb_Client *client, Eina_Bool success)
{ {
printf("Connected to ethumb client: %d\n", success); printf("Connected to ethumb client: %d\n", success);
@ -118,28 +132,12 @@ static void image_clicked(void *data, Evas *e, Evas_Object *obj, void *event_inf
Smart_Data *sd; Smart_Data *sd;
ev = event_info; ev = event_info;
sd = evas_object_smart_data_get(em->image_browser_tbl); sd = evas_object_smart_data_get(em->image_browser);
if (ev->flags == EVAS_BUTTON_DOUBLE_CLICK) if (ev->flags == EVAS_BUTTON_DOUBLE_CLICK)
{ {
edje_object_signal_emit(em->image_browser, "ephoto.browser.hidden", "ephoto"); edje_object_signal_emit(em->image_browser, "ephoto.browser.hidden", "ephoto");
node = evas_object_data_get(obj, "image"); 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(); hide_image_browser();
show_flow_view(node, sd->images); show_flow_view(node, sd->images);
return; return;
@ -153,32 +151,6 @@ static void image_clicked(void *data, Evas *e, Evas_Object *obj, void *event_inf
em->sel = obj; 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) Evas_Object *ephoto_table_add(Evas *e)
{ {
_table_smart_init(); _table_smart_init();
@ -194,6 +166,7 @@ void ephoto_table_padding_set(Evas_Object *obj, int paddingw, int paddingh)
return; return;
sd->paddingw = paddingw; sd->paddingw = paddingw;
sd->paddingh = paddingh; sd->paddingh = paddingh;
sd->items_per_page = (sd->visiblew / (sd->item_w+sd->paddingw)) * (sd->visibleh / (sd->item_h+sd->paddingh));
} }
void ephoto_table_pack(Evas_Object *obj, char *image) void ephoto_table_pack(Evas_Object *obj, char *image)
@ -205,7 +178,6 @@ void ephoto_table_pack(Evas_Object *obj, char *image)
const char *thumb; const char *thumb;
sd = evas_object_smart_data_get(obj); sd = evas_object_smart_data_get(obj);
sd->images = eina_list_append(sd->images, strdup(image)); sd->images = eina_list_append(sd->images, strdup(image));
@ -220,15 +192,15 @@ void ephoto_table_pack(Evas_Object *obj, char *image)
pages++; pages++;
sd->total_pages = pages; sd->total_pages = pages;
snprintf(text, PATH_MAX, "Page: %d of %d", sd->current_page, sd->total_pages); snprintf(text, PATH_MAX, "Page: %d of %d", sd->current_page, sd->total_pages);
edje_object_part_text_set(em->image_browser, "ephoto.text.object", text); edje_object_part_text_set(sd->obj, "ephoto.text.object", text);
return; return;
} }
img = edje_object_add(em->e); img = edje_object_add(em->e);
edje_object_file_set(img, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", "/ephoto/thumb/shadow"); edje_object_file_set(img, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", "/ephoto/thumb/shadow");
evas_object_move(img, sd->tw, sd->th);
evas_object_show(img); evas_object_show(img);
evas_object_move(img, sd->tw, sd->th);
edje_object_signal_emit(img, "ephoto.thumb.visible", "ephoto"); 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_data_set(img, "image", eina_list_nth_list(sd->images, eina_list_count(sd->images)-1));
@ -276,11 +248,10 @@ void ephoto_table_viewport_set(Evas_Object *obj, int w, int h)
if ((sd->visiblew == w) && (sd->visibleh == h)) if ((sd->visiblew == w) && (sd->visibleh == h))
return; return;
sd->visiblew = w; sd->visiblew = w;
sd->visibleh = h; sd->visibleh = h;
evas_object_resize(sd->obj, w, h); sd->items_per_page = (sd->visiblew / (sd->item_w+sd->paddingw)) * (sd->visibleh / (sd->item_h+sd->paddingh));
evas_object_resize(em->image_browser, w, h); evas_object_resize(sd->obj, sd->visiblew, sd->visibleh);
sd->items_per_page = (sd->visiblew / sd->item_w) * (sd->visibleh / sd->item_h); if (!eina_list_count(sd->images))
if (!eina_list_count(sd->items))
return; return;
pages = eina_list_count(sd->images)/sd->items_per_page; pages = eina_list_count(sd->images)/sd->items_per_page;
@ -292,7 +263,7 @@ void ephoto_table_viewport_set(Evas_Object *obj, int w, int h)
else else
sd->total_pages = pages; sd->total_pages = pages;
snprintf(text, PATH_MAX, "Page: %d of %d", sd->current_page, sd->total_pages); snprintf(text, PATH_MAX, "Page: %d of %d", sd->current_page, sd->total_pages);
edje_object_part_text_set(em->image_browser, "ephoto.text.object", text); edje_object_part_text_set(sd->obj, "ephoto.text.object", text);
_table_smart_reconfigure(sd); _table_smart_reconfigure(sd);
} }
@ -367,7 +338,7 @@ static void _table_smart_change_page(Smart_Data *sd, int direction)
return; return;
snprintf(text, PATH_MAX, "Page: %d of %d", sd->current_page, sd->total_pages); snprintf(text, PATH_MAX, "Page: %d of %d", sd->current_page, sd->total_pages);
edje_object_part_text_set(em->image_browser, "ephoto.text.object", text); edje_object_part_text_set(sd->obj, "ephoto.text.object", text);
for (j = 0; j <= sd->items_per_page; j++) for (j = 0; j <= sd->items_per_page; j++)
{ {
@ -595,7 +566,6 @@ static void _table_smart_reconfigure(Smart_Data *sd)
iteratorb = eina_list_next(iteratorb); iteratorb = eina_list_next(iteratorb);
} }
} }
return; return;
} }
@ -620,7 +590,6 @@ static void _table_smart_init(void)
NULL, NULL,
NULL NULL
}; };
em->thumb_cli = ethumb_client_connect(connect_callback, NULL, NULL);
_smart = evas_smart_class_new(&sc); _smart = evas_smart_class_new(&sc);
} }
} }
@ -635,8 +604,8 @@ static void _table_smart_add(Evas_Object *obj)
if (!sd) if (!sd)
return; return;
evas_object_geometry_get(em->image_browser, 0, 0, &w, &h); edje_object_part_geometry_get(em->bg, "ephoto.swallow.content", 0, 0, &w, &h);
sd->visiblew = w; sd->visiblew = w;
sd->visibleh = h; sd->visibleh = h;
sd->tw = 60; sd->tw = 60;
@ -652,16 +621,21 @@ static void _table_smart_add(Evas_Object *obj)
sd->visible_items = 0; sd->visible_items = 0;
sd->total_pages = 1; sd->total_pages = 1;
sd->obj = evas_object_rectangle_add(em->e); sd->obj = edje_object_add(em->e);
evas_object_color_set(sd->obj, 255, 255, 255, 0); edje_object_file_set(sd->obj, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", "/ephoto/image/browser");
evas_object_smart_data_set(obj, sd); evas_object_smart_data_set(obj, sd);
edje_object_signal_callback_add(sd->obj, "mouse,up,1", "move_left", move_left, NULL);
edje_object_signal_callback_add(sd->obj, "mouse,up,1", "move_right", move_right, NULL);
img = edje_object_add(em->e); img = edje_object_add(em->e);
edje_object_file_set(img, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", "/ephoto/thumb/shadow"); edje_object_file_set(img, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", "/ephoto/thumb/shadow");
edje_object_size_min_get(img, &sd->item_w, &sd->item_h); edje_object_size_min_get(img, &sd->item_w, &sd->item_h);
evas_object_del(img); evas_object_del(img);
sd->items_per_page = (sd->visiblew / sd->item_w) * (sd->visibleh / sd->item_h); sd->items_per_page = (sd->visiblew / sd->item_w+sd->paddingw) * (sd->visibleh / sd->item_h+sd->paddingh);
em->thumb_cli = ethumb_client_connect(connect_callback, NULL, NULL);
} }
static void _table_smart_del(Evas_Object *obj) static void _table_smart_del(Evas_Object *obj)
@ -709,19 +683,19 @@ static void _table_smart_resize(Evas_Object *obj, Evas_Coord w, Evas_Coord h)
if (!sd) if (!sd)
return; return;
evas_object_geometry_get(em->image_browser, 0, 0, &ibw, &ibh); evas_object_geometry_get(sd->obj, 0, 0, &ibw, &ibh);
if ((w == sd->w) && (h == sd->h)) if ((w == sd->w) && (h == sd->h))
return; return;
sd->w = w; sd->w = w;
sd->h = h; sd->h = h;
evas_object_resize(sd->obj, w, h); evas_object_resize(sd->obj, w, h);
if (!eina_list_count(sd->items)) if (!eina_list_count(sd->images))
return; return;
if ((ibw == sd->visiblew) && (ibh == sd->visibleh)) if ((ibw == sd->visiblew) && (ibh == sd->visibleh))
return; return;
else else
ephoto_table_viewport_set(obj, ibw, ibh); ephoto_table_viewport_set(obj, w, h);
} }
static void _table_smart_show(Evas_Object *obj) static void _table_smart_show(Evas_Object *obj)
@ -731,18 +705,28 @@ static void _table_smart_show(Evas_Object *obj)
sd = evas_object_smart_data_get(obj); sd = evas_object_smart_data_get(obj);
if (!sd) if (!sd)
return; return;
evas_object_show(sd->obj); evas_object_show(sd->obj);
_table_smart_reconfigure(sd);
} }
static void _table_smart_hide(Evas_Object *obj) static void _table_smart_hide(Evas_Object *obj)
{ {
Eina_List *iterator;
Evas_Object *o;
Smart_Data *sd; Smart_Data *sd;
sd = evas_object_smart_data_get(obj); sd = evas_object_smart_data_get(obj);
if (!sd) if (!sd)
return; return;
iterator = sd->items;
while (eina_list_data_get(iterator))
{
o = eina_list_data_get(iterator);
edje_object_signal_emit(o, "ephoto.thumb.hidden", "ephoto");
evas_object_hide(o);
iterator = eina_list_next(iterator);
}
evas_object_hide(sd->obj); evas_object_hide(sd->obj);
} }