simplify, move thumb count to theme, min limit to contents.

If we used such a large border with small item sizes, the content size
would be zero and thus icons did turn invisible. Limit that to 16x16.

"thumbs" in group will say how many thumbnails are desired, instead of
hardcoding it to 3.

countless code simplifications.



SVN revision: 53207
This commit is contained in:
Gustavo Sverzut Barbieri 2010-10-08 20:21:29 +00:00
parent 5637a4879f
commit 50c67f7ad6
2 changed files with 141 additions and 196 deletions

View File

@ -95,72 +95,29 @@ collections
} }
} }
} }
group
{ group { name: "/ephoto/thumb/no_border";
name: "/ephoto/thumb/no_border"; parts {
parts part { name: "ephoto.swallow.content";
{ type: SWALLOW;
part mouse_events: 0;
{ description { state: "default" 0.0;
name: "border"; min: 16 16;
type: RECT; rel1.offset: 8 8;
mouse_events: 0; rel2.offset: -9 -9;
description }
{ }
state: "default" 0.0;
color: 255 255 255 0; part {
rel1.offset: 18 18; name: "eventarea";
rel2.offset: -17 -17; type: RECT;
} description { state: "default" 0.0;
} color: 255 255 255 0;
part }
{ }
name: "clipper"; }
type: RECT; }
mouse_events: 0;
description
{
state: "default" 0.0;
visible: 1;
color: 255 255 255 255;
}
}
part
{
name: "ephoto.swallow.content";
type: SWALLOW;
mouse_events: 1;
clip_to: "clipper";
description
{
state: "default" 0.0;
visible: 1;
rel1.to: "border";
rel1.offset: 8 8;
rel2.to: "border";
rel2.offset: -9 -9;
color: 255 255 255 255;
}
}
part
{
name: "event_area";
type: RECT;
mouse_events: 1;
description
{
state: "default" 0.0;
color: 255 255 255 0;
rel1.to: "clipper";
rel1.relative: 0.0 0.0;
rel1.offset: 0 0;
rel2.to: "clipper";
rel2.relative: 1.0 1.0;
rel2.offset: -1 -1;
}
}
}
}
group group
{ {
name: "elm/gengrid/item/ephoto/default"; name: "elm/gengrid/item/ephoto/default";
@ -617,73 +574,58 @@ collections
} }
} }
} }
group
{ group { name: "/ephoto/directory/thumb/layout";
name: "/ephoto/directory/thumb/layout"; data.item: "thumbs" "3";
parts parts {
{ part { name: "ephoto.swallow.thumb1";
part {
name: "ephoto.swallow.thumb1";
type: SWALLOW; type: SWALLOW;
description { description {
state: "default" 0.0; state: "default" 0.0;
color: 255 0 0 255; map.on: 0;
map {
on: 0;
}
} }
} }
part { part { name: "ephoto.swallow.thumb2";
name: "ephoto.swallow.thumb2"; type: SWALLOW;
type: SWALLOW;
description { description {
state: "default" 0.0; state: "default" 0.0;
color: 255 0 0 255;
map { map {
on: 1; on: 1;
rotation { rotation.z: 20;
z: 20;
}
}
}
}
part {
name: "ephoto.swallow.thumb3";
type: SWALLOW;
description {
state: "default" 0.0;
color: 255 0 0 255;
map {
on: 1;
rotation {
z: -20;
}
}
}
}
}
programs {
program { name: "load";
signal: "load";
script {
new Float:val;
custom_state(PART:"ephoto.swallow.thumb3", "default", 0.0);
custom_state(PART:"ephoto.swallow.thumb2", "default", 0.0);
val = randf();
val = 40 * val - 20;
set_state_val(PART:"ephoto.swallow.thumb3", STATE_MAP_ROT_Z, val);
val = randf();
val = 40 * val - 20;
set_state_val(PART:"ephoto.swallow.thumb2", STATE_MAP_ROT_Z, val);
set_state(PART:"ephoto.swallow.thumb2", "custom", 0.0);
set_state(PART:"ephoto.swallow.thumb3", "custom", 0.0);
} }
} }
} }
part { name: "ephoto.swallow.thumb3";
type: SWALLOW;
description {
state: "default" 0.0;
map {
on: 1;
rotation.z: -20;
}
}
}
}
programs {
program { name: "load";
signal: "load";
script {
new Float:val;
custom_state(PART:"ephoto.swallow.thumb3", "default", 0.0);
custom_state(PART:"ephoto.swallow.thumb2", "default", 0.0);
val = randf();
val = 40 * val - 20;
set_state_val(PART:"ephoto.swallow.thumb3", STATE_MAP_ROT_Z, val);
val = randf();
val = 40 * val - 20;
set_state_val(PART:"ephoto.swallow.thumb2", STATE_MAP_ROT_Z, val);
set_state(PART:"ephoto.swallow.thumb2", "custom", 0.0);
set_state(PART:"ephoto.swallow.thumb3", "custom", 0.0);
}
}
}
} }
} }

View File

@ -1,8 +1,4 @@
#include "ephoto.h"
#include <Elementary.h>
#include <Eio.h>
#include "config.h"
typedef struct _Directory_Thumb Directory_Thumb; typedef struct _Directory_Thumb Directory_Thumb;
@ -10,10 +6,21 @@ struct _Directory_Thumb
{ {
Evas_Object *layout; Evas_Object *layout;
Eio_File *file; Eio_File *file;
Eina_List *thumbs; Eina_List *frames;
const char *path; const char *path;
int theme_thumb_count;
}; };
static void
_layout_del(void *data, Evas *e, Evas_Object *layout, void *event_info)
{
Directory_Thumb *dt = data;
if (dt->file) eio_file_cancel(dt->file);
eina_list_free(dt->frames);
eina_stringshare_del(dt->path);
free(dt);
}
static Eina_Bool static Eina_Bool
_populate_filter(void *data, const char *file) _populate_filter(void *data, const char *file)
{ {
@ -37,113 +44,109 @@ static void
_populate_end(void *data) _populate_end(void *data)
{ {
Directory_Thumb *dt = (Directory_Thumb*) data; Directory_Thumb *dt = (Directory_Thumb*) data;
dt->file = NULL; dt->file = NULL;
} }
static void static void
_populate_error(int error, void *data) _populate_error(int error, void *data)
{ {
Directory_Thumb *dt = (Directory_Thumb*)data; Directory_Thumb *dt = (Directory_Thumb*)data;
dt->file = NULL; dt->file = NULL;
} }
static void static void
_populate_main(void *data, const char *file) _populate_main(void *data, const char *file)
{ {
Evas_Object *thumb, *o; Evas_Object *frame, *image;
int position; int position;
Directory_Thumb *dt = data; Directory_Thumb *dt = data;
char buf[4096]; char buf[4096];
position = eina_list_count(dt->thumbs); position = eina_list_count(dt->frames);
if (position > 3 ) if (position > dt->theme_thumb_count)
{ {
eio_file_cancel(dt->file); if (dt->file)
return; {
eio_file_cancel(dt->file);
dt->file = NULL;
}
return;
} }
thumb = elm_layout_add(dt->layout); frame = elm_layout_add(dt->layout);
elm_layout_file_set(thumb, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", if (!elm_layout_file_set
"/ephoto/thumb/no_border"); (frame, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", "/ephoto/thumb"))
ERR("could not load group '/ephoto/thumb' from file '%s'",
evas_object_size_hint_weight_set(thumb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); PACKAGE_DATA_DIR "/themes/default/ephoto.edj");
evas_object_show(thumb); evas_object_size_hint_weight_set(frame, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(frame);
thumb = elm_layout_add(dt->layout); image = elm_thumb_add(frame);
elm_layout_file_set(thumb, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", elm_thumb_file_set(image, file, NULL);
"/ephoto/thumb"); elm_object_style_set(image, "ephoto");
evas_object_size_hint_weight_set(image, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_weight_set(thumb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); evas_object_size_hint_align_set(image, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(thumb); elm_layout_content_set(frame, "ephoto.swallow.content", image);
o = elm_thumb_add(thumb);
elm_thumb_file_set(o, file, NULL);
elm_object_style_set(o, "ephoto");
evas_object_size_hint_weight_set(o, EVAS_HINT_EXPAND,
EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(o, EVAS_HINT_FILL,
EVAS_HINT_FILL);
evas_object_show(o);
elm_layout_content_set(thumb, "ephoto.swallow.content", o);
snprintf(buf, sizeof(buf), "ephoto.swallow.thumb%d", position); snprintf(buf, sizeof(buf), "ephoto.swallow.thumb%d", position);
elm_layout_content_set(dt->layout, buf, thumb); elm_layout_content_set(dt->layout, buf, frame);
evas_object_show(thumb);
dt->thumbs = eina_list_append(dt->thumbs, thumb);
dt->frames = eina_list_append(dt->frames, frame);
} }
Evas_Object *ephoto_directory_thumb_add(Evas_Object *parent, const char *path) Evas_Object *
ephoto_directory_thumb_add(Evas_Object *parent, const char *path)
{ {
Directory_Thumb *dt; Directory_Thumb *dt;
Evas_Object *thumb, *o; Evas_Object *thumb, *placeholder;
const char *s;
dt = calloc(1, sizeof( Directory_Thumb)); dt = calloc(1, sizeof( Directory_Thumb));
dt->path = eina_stringshare_add(path); dt->path = eina_stringshare_add(path);
dt->layout = elm_layout_add(parent); dt->layout = elm_layout_add(parent);
if (!elm_layout_file_set(dt->layout, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", if (!elm_layout_file_set
"/ephoto/directory/thumb/layout")) (dt->layout, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
printf(" Error loading group /ephoto/directory/thumb/layout in %s\n", PACKAGE_DATA_DIR "/themes/default/ephoto.edj"); "/ephoto/directory/thumb/layout"))
evas_object_size_hint_weight_set(dt->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); ERR("could not load group '/ephoto/directory/thumb/layout' from file '%s'",
PACKAGE_DATA_DIR "/themes/default/ephoto.edj");
evas_object_size_hint_weight_set
(dt->layout, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(dt->layout); evas_object_show(dt->layout);
evas_object_data_set(dt->layout, "dt", dt);
evas_object_event_callback_add
(dt->layout, EVAS_CALLBACK_DEL, _layout_del, dt);
thumb = elm_layout_add(dt->layout); thumb = elm_layout_add(dt->layout);
if (!elm_layout_file_set(thumb, PACKAGE_DATA_DIR "/themes/default/ephoto.edj", if (!elm_layout_file_set
"/ephoto/thumb/no_border")) (thumb, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
printf(" Error loading group /ephoto/thumb/no_border in %s\n", PACKAGE_DATA_DIR "/themes/default/ephoto.edj"); "/ephoto/thumb/no_border"))
ERR("could not load group '/ephoto/thumb/no_border' from file '%s'",
PACKAGE_DATA_DIR "/themes/default/ephoto.edj");
//evas_object_size_hint_weight_set(thumb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND); //evas_object_size_hint_weight_set(thumb, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_show(thumb);
o = elm_image_add(thumb);
elm_image_file_set(o, PACKAGE_DATA_DIR "/images/change_directory.png", NULL);
evas_object_show(o);
elm_layout_content_set(thumb, "ephoto.swallow.content", o);
elm_layout_content_set(dt->layout, "ephoto.swallow.thumb1", thumb); elm_layout_content_set(dt->layout, "ephoto.swallow.thumb1", thumb);
evas_object_show(dt->layout); placeholder = elm_image_add(thumb);
elm_image_file_set
evas_object_data_set(dt->layout, "dt", dt); (placeholder, PACKAGE_DATA_DIR "/images/change_directory.png", NULL);
elm_layout_content_set(thumb, "ephoto.swallow.content", placeholder);
dt->file = eio_file_ls(path, s = edje_object_data_get(elm_layout_edje_get(dt->layout), "thumbs");
_populate_filter, if (s)
_populate_main, {
_populate_end, dt->theme_thumb_count = atoi(s);
_populate_error,
dt); /* TODO: fix "Up" to be another type of directory and do not need
* to check for existence here */
if ((dt->theme_thumb_count > 0) && (ecore_file_exists(path)))
dt->file = eio_file_ls(path,
_populate_filter,
_populate_main,
_populate_end,
_populate_error,
dt);
}
/* TODO add del callback to free dt and its member */
return dt->layout; return dt->layout;
} }