This is what I feel like is a middle ground for how directory browsing is handled in ephoto. Please give me useful feedback. Yes I know the directories/font of the directory labels need work, but you get the general idea, and that will be fixed soon.

SVN revision: 55098
This commit is contained in:
titan 2010-11-30 21:52:49 +00:00 committed by titan
parent 51f36d538b
commit cb528acc67
4 changed files with 274 additions and 59 deletions

View File

@ -3,6 +3,11 @@ externals {
}
collections {
images {
image: "up-128.png" COMP;
image: "directory-128.png" COMP;
image: "raise.png" COMP;
}
group { name: "elm/layout/ephoto/orient";
parts {
part { name: "elm.swallow.content";
@ -124,4 +129,185 @@ collections {
}
}
}
group { name: "ephoto,thumb,grid";
parts {
part { name: "ephoto.swallow.content.thumb";
type: SWALLOW;
mouse_events: 1;
description {
state: "default" 0.0;
rel1.relative: 0.0 0.0;
rel1.offset: 0 0;
rel2.relative: 1.0 1.0;
rel2.offset: -1 -1;
}
}
part { name: "overlay";
type: RECT;
mouse_events: 1;
description {
min: 1 40;
max: 9999 40;
fixed: 0 1;
state: "default" 0.0;
rel1.to: "ephoto.swallow.content.thumb";
rel1.relative: 0.0 0.0;
rel1.offset: 5 45;
rel2.to: "ephoto.swallow.content.thumb";
rel2.relative: 1.0 0.0;
rel2.offset: -5 0;
color: 0 0 0 120;
}
description {
state: "lowered" 0.0;
rel1.to: "ephoto.swallow.content.thumb";
rel1.relative: 0.0 0.0;
rel1.offset: 5 5;
rel2.to: "ephoto.swallow.content.thumb";
rel2.relative: 1.0 1.0;
rel2.offset: -5 -5;
color: 0 0 0 120;
}
}
part { name: "ephoto.swallow.content.dir";
type: SWALLOW;
mouse_events: 1;
description {
state: "default" 0.0;
visible: 0;
rel1.to: "ephoto.swallow.content.thumb";
rel1.relative: 0.0 0.0;
rel1.offset: 0 0;
rel1.to: "ephoto.swallow.content.thumb";
rel2.relative: 1.0 1.0;
rel2.offset: -1 -1;
}
description {
state: "lowered" 0.0;
inherit: "default" 0.0;
visible: 1;
}
}
part { name: "up";
type: IMAGE;
mouse_events: 1;
description
{
min: 32 32;
max: 32 32;
fixed: 1 1;
state: "default" 0.0;
rel1.to: "overlay";
rel1.relative: 0.0 0.0;
rel1.offset: 20 20;
rel2.to: "overlay";
rel2.relative: 0.0 0.0;
rel2.offset: 20 20;
image.normal: "up-128.png";
}
description {
state: "lowered" 0.0;
inherit: "default" 0.0;
visible: 0;
}
}
part { name: "directory";
type: IMAGE;
mouse_events: 1;
description
{
min: 32 32;
max: 32 32;
fixed: 1 1;
state: "default" 0.0;
visible: 1;
rel1.to: "overlay";
rel1.relative: 1.0 0.0;
rel1.offset: -20 20;
rel2.to: "overlay";
rel2.relative: 1.0 0.0;
rel2.offset: -20 20;
image.normal: "directory-128.png";
}
description
{
state: "lowered" 0.0;
inherit: "default" 0.0;
visible: 0;
}
}
part { name: "raise";
type: IMAGE;
mouse_events: 1;
description
{
min: 32 32;
max: 32 32;
fixed: 1 1;
visible: 0;
state: "default" 0.0;
rel1.to: "overlay";
rel1.relative: 1.0 0.0;
rel1.offset: -20 20;
rel2.to: "overlay";
rel2.relative: 1.0 0.0;
rel2.offset: -20 20;
image.normal: "raise.png";
}
description
{
state: "lowered" 0.0;
inherit: "default" 0.0;
visible: 1;
}
}
}
programs {
program { name: "up_clicked";
source: "up";
signal: "mouse,up,*";
action: SIGNAL_EMIT "ephoto.signal.up" "ephoto";
}
program { name: "dir_clicked";
source: "directory";
signal: "mouse,up,*";
action: SIGNAL_EMIT "ephoto.signal.dir" "ephoto";
after: "lower2";
}
program { name: "raise_clicked";
source: "raise";
signal: "mouse,up,*";
action: SIGNAL_EMIT "ephoto.signal.raise" "ephoto";
after: "raise2";
}
program { name: "lower";
action: STATE_SET "lowered" 0.0;
transition: ACCELERATE 0.6;
target: "overlay";
after: "lower3";
}
program { name: "lower2";
action: STATE_SET "lowered" 0.0;
target: "directory";
target: "raise";
after: "lower";
}
program { name: "lower3";
action: STATE_SET "lowered" 0.0;
target: "ephoto.swallow.content.dir";
}
program { name: "raise";
action: STATE_SET "default" 0.0;
transition: ACCELERATE 0.6;
target: "overlay";
}
program { name: "raise2";
action: STATE_SET "default" 0.0;
target: "directory";
target: "raise";
target: "ephoto.swallow.content.dir";
after: "raise";
}
}
}
}

View File

@ -10,5 +10,6 @@ up-256.png \
up-512.png \
directory-128.png \
directory-256.png \
directory-512.png
directory-512.png \
raise.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

View File

@ -17,10 +17,13 @@ struct _Ephoto_Thumb_Browser
Evas_Object *edje;
Evas_Object *fsel;
Evas_Object *grid;
Evas_Object *dir_grid;
Evas_Object *toolbar;
Evas_Object *overlay;
Eio_File *ls;
Eina_List *todo_items;
Eina_List *grid_items;
Eina_List *dir_grid_items;
Eina_List *handlers;
struct {
Elm_Toolbar_Item *zoom_in;
@ -46,6 +49,8 @@ _grid_items_free(Ephoto_Thumb_Browser *tb)
{
eina_list_free(tb->grid_items);
tb->grid_items = NULL;
eina_list_free(tb->dir_grid_items);
tb->dir_grid_items = NULL;
}
static Ephoto_Entry *
@ -136,16 +141,6 @@ static const Elm_Gengrid_Item_Class _ephoto_thumb_dir_class = {
}
};
static const Elm_Gengrid_Item_Class _ephoto_thumb_up_class = {
"up",
{
_ephoto_thumb_item_label_get,
NULL,
NULL,
_ephoto_thumb_item_del
}
};
static const Elm_Gengrid_Item_Class _ephoto_thumb_file_class = {
"thumb",
{
@ -177,38 +172,50 @@ _entry_item_add(Ephoto_Thumb_Browser *tb, Ephoto_Entry *e)
{
const Elm_Gengrid_Item_Class *ic;
int near_cmp;
Evas_Object *grid_of_choice;
Elm_Gengrid_Item *near_item = NULL;
Eina_List *near_node = NULL;
Eina_List *near_node = NULL, *list_of_choice = NULL;
if (e->is_dir)
{
ic = &_ephoto_thumb_dir_class;
grid_of_choice = tb->dir_grid;
list_of_choice = tb->dir_grid_items;
}
else
{
ic = &_ephoto_thumb_file_class;
grid_of_choice = tb->grid;
list_of_choice = tb->grid_items;
}
near_node = eina_list_search_sorted_near_list
(tb->grid_items, _entry_cmp, e, &near_cmp);
(list_of_choice, _entry_cmp, e, &near_cmp);
if (near_node)
near_item = near_node->data;
if (e->is_dir) ic = &_ephoto_thumb_dir_class;
else ic = &_ephoto_thumb_file_class;
if (!near_item)
{
e->item = elm_gengrid_item_append(tb->grid, ic, e, NULL, NULL);
tb->grid_items = eina_list_append(tb->grid_items, e->item);
e->item = elm_gengrid_item_append(grid_of_choice, ic, e, NULL, NULL);
list_of_choice = eina_list_append(list_of_choice, e->item);
}
else
{
if (near_cmp < 0)
{
e->item = elm_gengrid_item_insert_after
(tb->grid, ic, e, near_item, NULL, NULL);
tb->grid_items = eina_list_append_relative
(tb->grid_items, e->item, near_item);
(grid_of_choice, ic, e, near_item, NULL, NULL);
list_of_choice = eina_list_append_relative
(list_of_choice, e->item, near_item);
}
else
{
e->item = elm_gengrid_item_insert_before
(tb->grid, ic, e, near_item, NULL, NULL);
tb->grid_items = eina_list_prepend_relative
(tb->grid_items, e->item, near_item);
(grid_of_choice, ic, e, near_item, NULL, NULL);
list_of_choice = eina_list_prepend_relative
(list_of_choice, e->item, near_item);
}
}
@ -222,29 +229,6 @@ _entry_item_add(Ephoto_Thumb_Browser *tb, Ephoto_Entry *e)
}
}
static void
_up_item_add_if_required(Ephoto_Thumb_Browser *tb)
{
Ephoto_Entry *entry;
char *parent_dir;
if ((elm_gengrid_first_item_get(tb->grid)) ||
(strcmp(tb->ephoto->config->directory, "/") == 0))
return;
parent_dir = ecore_file_dir_get(tb->ephoto->config->directory);
if (!parent_dir) return;
entry = ephoto_entry_new(tb->ephoto, parent_dir, PARENT_DIR);
free(parent_dir);
EINA_SAFETY_ON_NULL_RETURN(entry);
entry->is_up = EINA_TRUE;
entry->is_dir = EINA_TRUE;
entry->item = elm_gengrid_item_append
(tb->grid, &_ephoto_thumb_up_class, entry, NULL, NULL);
/* does not go into entries as it is always the first - no sort! */
}
static Eina_Bool
_todo_items_process(void *data)
{
@ -255,8 +239,6 @@ _todo_items_process(void *data)
if ((tb->ls) && (eina_list_count(tb->todo_items) < TODO_ITEM_MIN_BATCH))
return EINA_TRUE;
_up_item_add_if_required(tb);
tb->animator.todo_items = NULL;
EINA_LIST_FREE(tb->todo_items, entry)
@ -309,6 +291,7 @@ _zoom_set(Ephoto_Thumb_Browser *tb, int zoom)
ephoto_thumb_size_set(tb->ephoto, zoom);
elm_gengrid_item_size_set(tb->grid, zoom, zoom);
elm_gengrid_item_size_set(tb->dir_grid, zoom, zoom);
elm_toolbar_item_disabled_set(tb->action.zoom_out, zoom == ZOOM_MIN);
elm_toolbar_item_disabled_set(tb->action.zoom_in, zoom == ZOOM_MAX);
@ -447,6 +430,7 @@ _ephoto_thumb_populate_start(void *data, int type __UNUSED__, void *event __UNUS
_todo_items_free(tb);
_grid_items_free(tb);
elm_gengrid_clear(tb->grid);
elm_gengrid_clear(tb->dir_grid);
elm_fileselector_entry_path_set(tb->fsel, tb->ephoto->config->directory);
edje_object_signal_emit(tb->edje, "populate,start", "ephoto");
@ -466,8 +450,6 @@ _ephoto_thumb_populate_end(void *data, int type __UNUSED__, void *event __UNUSED
return ECORE_CALLBACK_PASS_ON;
}
if (!tb->animator.todo_items) _up_item_add_if_required(tb);
edje_object_signal_emit(tb->edje, "populate,stop", "ephoto");
return ECORE_CALLBACK_PASS_ON;
@ -499,6 +481,26 @@ _ephoto_thumb_entry_create(void *data, int type __UNUSED__, void *event)
return ECORE_CALLBACK_PASS_ON;
}
static void
_ephoto_up_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
{
Ephoto_Thumb_Browser *tb = data;
char *parent_dir;
parent_dir = ecore_file_dir_get(tb->ephoto->config->directory);
if (!parent_dir)
return;
ephoto_directory_set(tb->ephoto, parent_dir);
}
static void
_ephoto_dir_clicked(void *data, Evas_Object *obj, const char *emission, const char *source)
{
Ephoto_Thumb_Browser *tb = data;
evas_object_show(tb->dir_grid);
}
Evas_Object *
ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent)
{
@ -558,26 +560,52 @@ ephoto_thumb_browser_add(Ephoto *ephoto, Evas_Object *parent)
evas_object_show(tb->fsel);
elm_layout_box_append(layout, "elm.box.content", tb->fsel);
tb->grid = elm_gengrid_add(layout);
EINA_SAFETY_ON_NULL_GOTO(tb->grid, error);
tb->overlay = elm_layout_add(layout);
elm_layout_file_set
(tb->overlay, PACKAGE_DATA_DIR "/themes/default/ephoto.edj",
"ephoto,thumb,grid");
evas_object_size_hint_weight_set
(tb->grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(tb->grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
(tb->overlay, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set
(tb->overlay, EVAS_HINT_FILL, EVAS_HINT_FILL);
edje_object_signal_callback_add
(elm_layout_edje_get(tb->overlay), "ephoto.signal.up", "ephoto",
_ephoto_up_clicked, tb);
edje_object_signal_callback_add
(elm_layout_edje_get(tb->overlay), "ephoto.signal.dir", "ephoto",
_ephoto_dir_clicked, tb);
evas_object_show(tb->overlay);
elm_layout_box_append(tb->layout, "elm.box.content", tb->overlay);
tb->grid = elm_gengrid_add(tb->overlay);
EINA_SAFETY_ON_NULL_GOTO(tb->grid, error);
elm_gengrid_align_set(tb->grid, 0.5, 0.5);
elm_gengrid_bounce_set(tb->grid, EINA_FALSE, EINA_TRUE);
evas_object_size_hint_align_set
(tb->grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set
(tb->grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_smart_callback_add
(tb->grid, "selected", _ephoto_thumb_selected, tb);
_zoom_set(tb, tb->ephoto->config->thumb_size);
evas_object_show(tb->grid);
elm_layout_box_append(tb->layout, "elm.box.content", tb->grid);
elm_layout_content_set
(tb->overlay, "ephoto.swallow.content.thumb", tb->grid);
tb->dir_grid = elm_gengrid_add(tb->overlay);
EINA_SAFETY_ON_NULL_GOTO(tb->dir_grid, error);
elm_gengrid_align_set(tb->dir_grid, 0.5, 0.5);
elm_gengrid_bounce_set(tb->dir_grid, EINA_FALSE, EINA_TRUE);
evas_object_size_hint_align_set
(tb->dir_grid, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_size_hint_weight_set
(tb->dir_grid, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
evas_object_smart_callback_add
(tb->dir_grid, "selected", _ephoto_thumb_selected, tb);
_zoom_set(tb, tb->ephoto->config->thumb_size);
evas_object_show(tb->dir_grid);
elm_layout_content_set
(tb->overlay, "ephoto.swallow.content.dir", tb->dir_grid);
tb->handlers = eina_list_append
(tb->handlers, ecore_event_handler_add