file_tab: use customed list for file tab.

This commit is contained in:
Hermet Park 2016-06-29 23:29:37 +09:00
parent 5140ab5c64
commit 247c1e67ae
10 changed files with 482 additions and 42 deletions

View File

@ -96,4 +96,7 @@ EXTRA_DIST = \
template.png \
left.png \
right.png \
filetab.png
filetab.png \
bevel_curved_vert_out.png \
vgrad_med_dark.png \
shadow_rounded_vert.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 148 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 693 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

View File

@ -2349,7 +2349,7 @@ group { "main_layout";
rel1 { to: "elm.swallow.statusbar"; relative: 0 0; }
rel2 { to: "elm.swallow.statusbar"; relative: 1 0; }
align: 0.5 0;
min: 0 22;
min: 0 25;
fixed: 0 1;
}
desc { "visible";
@ -2357,17 +2357,6 @@ group { "main_layout";
align: 0.5 1;
}
}
rect { "separator";
scale: 1;
desc { "default";
rel1 { to: "elm.swallow.file_tab"; relative: 0 1; offset: 0 -2; }
rel2 { to: "elm.swallow.file_tab"; relative: 1 1; offset: -1 -3; }
align: 0.5 0;
min: 0 1;
fixed: 0 1;
color: 50 50 50 100;
}
}
swallow { "elm.swallow.statusbar";
scale: 1;
desc { "default";

View File

@ -19,6 +19,403 @@
tag: "hilight" "+ style=glow glow_color=#3399ff20"; \
tag: "error" "+ underline=single underline_color=#ff0000 underline2_color=#ff0000"; \
//List
#define ODD(_NAME, _SRC) \
group { name: _NAME; \
inherit: _SRC; \
parts { \
part { name: "base"; \
description { state: "default" 0.0; \
color: 56 56 56 255; \
color_class: "list_item_base_odd"; \
} \
} \
} \
}
#define COMPRESS(_NAME, _SRC) \
group { name: _NAME; \
inherit: _SRC; \
parts { \
part { name: "elm.text"; \
description { state: "default" 0.0; \
text.min: 0 1; \
text.ellipsis: 0.0; \
} \
description { state: "selected" 0.0; \
text.min: 0 1; \
text.ellipsis: 0.0; \
} \
description { state: "disabled" 0.0; \
text.min: 0 1; \
text.ellipsis: 0.0; \
} \
} \
part { name: "label2"; \
description { state: "default" 0.0; \
text.min: 0 1; \
text.ellipsis: 0.0; \
} \
description { state: "selected" 0.0; \
text.min: 0 1; \
text.ellipsis: 0.0; \
} \
description { state: "disabled" 0.0; \
text.min: 0 1; \
text.ellipsis: 0.0; \
} \
} \
part { name: "label3"; \
description { state: "default" 0.0; \
text.min: 0 1; \
text.ellipsis: 0.0; \
} \
description { state: "selected" 0.0; \
text.min: 0 1; \
text.ellipsis: 0.0; \
} \
description { state: "disabled" 0.0; \
text.min: 0 1; \
text.ellipsis: 0.0; \
} \
} \
} \
}
#define COMPRESS_ODD(_NAME, _SRC) \
group { name: _NAME; \
inherit: _SRC; \
parts { \
part { name: "elm.text"; \
description { state: "default" 0.0; \
text.min: 0 1; \
text.ellipsis: 0.0; \
} \
description { state: "selected" 0.0; \
text.min: 0 1; \
text.ellipsis: 0.0; \
} \
description { state: "disabled" 0.0; \
text.min: 0 1; \
text.ellipsis: 0.0; \
} \
} \
part { name: "label2"; \
description { state: "default" 0.0; \
text.min: 0 1; \
text.ellipsis: 0.0; \
} \
description { state: "selected" 0.0; \
text.min: 0 1; \
text.ellipsis: 0.0; \
} \
description { state: "disabled" 0.0; \
text.min: 0 1; \
text.ellipsis: 0.0; \
} \
} \
part { name: "label3"; \
description { state: "default" 0.0; \
text.min: 0 1; \
text.ellipsis: 0.0; \
} \
description { state: "selected" 0.0; \
text.min: 0 1; \
text.ellipsis: 0.0; \
} \
description { state: "disabled" 0.0; \
text.min: 0 1; \
text.ellipsis: 0.0; \
} \
} \
part { name: "base"; \
description { state: "default" 0.0; \
color: 56 56 56 255; \
color_class: "list_item_base_odd"; \
} \
} \
} \
}
group { name: "elm/list/h_item/enventor";
data.item: "selectraise" "on";
data.item: "focusraise" "on";
images.image: "bevel_curved_vert_out.png" COMP;
images.image: "shadow_rounded_vert.png" COMP;
images.image: "vgrad_med_dark.png" COMP;
images.image: "bevel_out.png" COMP;
images.image: "shine.png" COMP;
parts {
part { name: "event"; type: RECT;
description { state: "default" 0.0;
color: 0 0 0 0;
}
description { state: "disabled" 0.0;
inherit: "default" 0.0;
visible: 0;
}
}
part { name: "base"; type: RECT; mouse_events: 0;
description { state: "default" 0.0;
color: 64 64 64 255;
color_class: "list_item_base";
}
description { state: "odd" 0.0;
color: 56 56 56 255;
color_class: "list_item_base_odd";
}
}
program {
signal: "elm,state,odd"; source: "elm";
action: STATE_SET "odd" 1.0;
target: "base";
}
program {
signal: "elm,state,even"; source: "elm";
action: STATE_SET "default" 0.0;
target: "base";
}
part { name: "bevel"; mouse_events: 0;
description { state: "default" 0.0;
image.normal: "bevel_curved_vert_out.png";
image.border: 2 2 0 0;
image.middle: 0;
fill.smooth: 0;
}
}
part { name: "sel_shadow"; mouse_events: 0;
description { state: "default" 0.0;
image.normal: "shadow_rounded_vert.png";
image.border: 9 9 0 0;
rel1.offset: -6 0;
rel2.offset: 5 -1;
fill.smooth: 0;
visible: 0;
}
description { state: "selected" 0.0;
inherit: "default" 0.0;
visible: 1;
}
}
part { name: "sel_base"; mouse_events: 0;
description { state: "default" 0.0;
image.normal: "vgrad_med_dark.png";
fill.smooth: 0;
visible: 0;
TILED_HORIZ(120)
}
description { state: "selected" 0.0;
inherit: "default" 0.0;
visible: 1;
}
}
part { name: "sel_bevel"; mouse_events: 0;
description { state: "default" 0.0;
image.normal: "bevel_out.png";
image.border: 2 2 2 2;
image.middle: 0;
fill.smooth: 0;
visible: 0;
}
description { state: "selected" 0.0;
inherit: "default" 0.0;
visible: 1;
}
}
program {
signal: "elm,state,selected"; source: "elm";
action: STATE_SET "selected" 0.0;
target: "sel_shadow";
target: "sel_base";
target: "sel_bevel";
}
program {
signal: "elm,state,unselected"; source: "elm";
action: STATE_SET "default" 0.0;
target: "sel_shadow";
target: "sel_base";
target: "sel_bevel";
}
program {
signal: "elm,state,disabled"; source: "elm";
action: STATE_SET "disabled" 0.0;
target: "event";
}
program {
signal: "elm,state,enabled"; source: "elm";
action: STATE_SET "default" 0.0;
target: "event";
}
text { "elm.text";
nomouse;
effect: SHADOW BOTTOM;
scale: 1;
desc { "default";
rel1.offset: 5 2;
rel1.relative: 1.0 0;
rel1.to_x: "elm.swallow.icon";
rel2.offset: -11 -3;
color3: 0 0 0 128;
color_class: "list_item";
text { font: FN; size: 10;
min: 1 1;
ellipsis: -1;
align: 0.5 0;
text_class: "list_item";
}
}
desc { "selected";
inherit: "default";
visible: 0;
}
desc { "disabled";
inherit: "default";
visible: 0;
}
}
part { name: "label2"; type: TEXT; mouse_events: 0;
effect: SHADOW BOTTOM;
scale: 1;
description { state: "default" 0.0;
rel1.to: "elm.text";
rel2.to: "elm.text";
color: 21 21 21 255;
color3: 255 255 255 25;
color_class: "list_item_disabled";
text { font: FN; size: 10;
text_source: "elm.text";
align: 0.5 0.5;
text_class: "list_item";
}
visible: 0;
}
description { state: "selected" 0.0;
inherit: "default" 0.0;
visible: 0;
}
description { state: "disabled" 0.0;
inherit: "default" 0.0;
visible: 1;
}
}
part { name: "label3"; type: TEXT; mouse_events: 0;
effect: GLOW;
scale: 1;
description { state: "default" 0.0;
rel1.offset: -2 -3;
rel1.to: "elm.text";
rel2.offset: 1 1;
rel2.to: "elm.text";
color: COL_HI;
color_class: "list_item_selected";
text { font: FN; size: 10;
text_source: "elm.text";
align: 0.5 0.5;
text_class: "list_item";
}
visible: 0;
}
description { state: "selected" 0.0;
inherit: "default" 0.0;
visible: 1;
}
description { state: "disabled" 0.0;
inherit: "default" 0.0;
visible: 0;
}
}
program {
signal: "elm,state,selected"; source: "elm";
action: STATE_SET "selected" 0.0;
target: "elm.text";
target: "label2";
target: "label3";
}
program {
signal: "elm,state,unselected"; source: "elm";
action: STATE_SET "default" 0.0;
target: "elm.text";
target: "label2";
target: "label3";
}
program {
signal: "elm,state,disabled"; source: "elm";
action: STATE_SET "disabled" 0.0;
target: "elm.text";
target: "label2";
target: "label3";
}
program {
signal: "elm,state,enabled"; source: "elm";
action: STATE_SET "default" 0.0;
target: "elm.text";
target: "label2";
target: "label3";
}
rect {"elm.swallow.icon";
scale: 1;
desc { "default";
fixed: 1 1;
align: 0 0.5;
rel1.relative: 0.0 0.5;
rel1.offset: 5 0;
rel2.relative: 0.0 0.5;
min: 12 12;
}
}
part { name: "sel_shine"; mouse_events: 0;
description { state: "default" 0.0;
image.normal: "shine.png";
rel1.offset: 0 -2;
rel1.to: "sel_base";
rel2.relative: 1.0 0.0;
rel2.offset: -1 2;
rel2.to: "sel_base";
visible: 0;
FIXED_SIZE(69, 5)
}
description { state: "selected" 0.0;
inherit: "default" 0.0;
visible: 1;
}
}
part { name: "event_block"; type: RECT;
description { state: "default" 0.0;
color: 0 0 0 0;
visible: 0;
}
description { state: "disabled" 0.0;
inherit: "default" 0.0;
visible: 1;
}
}
program {
signal: "elm,state,selected"; source: "elm";
action: STATE_SET "selected" 0.0;
target: "sel_shine";
}
program {
signal: "elm,state,unselected"; source: "elm";
action: STATE_SET "default" 0.0;
target: "sel_shine";
}
program {
signal: "elm,state,disabled"; source: "elm";
action: STATE_SET "disabled" 0.0;
target: "event_block";
}
program {
signal: "elm,state,enabled"; source: "elm";
action: STATE_SET "default" 0.0;
target: "event_block";
}
}
}
ODD("elm/list/h_item_odd/enventor", "elm/list/h_item/enventor")
COMPRESS("elm/list/h_item_compress/enventor", "elm/list/h_item/enventor")
COMPRESS_ODD("elm/list/h_item_compress_odd/enventor", "elm/list/h_item/enventor")
group { name: "elm/scroller/base/enventor";
images.image: "inset_shadow.png" COMP;
images.image: "bevel_in.png" COMP;

View File

@ -2,8 +2,7 @@
typedef struct file_tab_s
{
Evas_Object *in_box;
Evas_Object *scroller;
Evas_Object *list;
Evas_Object *out_box;
} file_data;
@ -19,10 +18,55 @@ file_data *g_fd = NULL;
/*****************************************************************************/
/* Internal method implementation */
/*****************************************************************************/
static void
left_btn_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
file_data *fd = data;
Elm_Object_Item *it = elm_list_selected_item_get(fd->list);
//just in case
if (!it) it = elm_list_last_item_get(fd->list);
if (!it) return;
it = elm_list_item_prev(it);
if (!it) return;
elm_list_item_selected_set(it, EINA_TRUE);
}
static void
right_btn_clicked_cb(void *data, Evas_Object *obj EINA_UNUSED,
void *event_info EINA_UNUSED)
{
file_data *fd = data;
Elm_Object_Item *it = elm_list_selected_item_get(fd->list);
//just in case
if (!it) it = elm_list_first_item_get(fd->list);
if (!it) return;
it = elm_list_item_next(it);
if (!it) return;
elm_list_item_selected_set(it, EINA_TRUE);
}
/*****************************************************************************/
/* Externally accessible calls */
/*****************************************************************************/
Eina_Bool file_tab_it_selected_set(Enventor_Item *enventor_it)
{
file_data *fd = g_fd;
if (!fd) return EINA_FALSE;
Eina_List *list = (Eina_List*) elm_list_items_get(fd->list);
Eina_List *l;
Elm_Object_Item *it;
EINA_LIST_FOREACH(list, l, it)
{
file_tab_it *fti = elm_object_item_data_get(it);
if (fti->it != enventor_it) continue;
elm_list_item_selected_set(it, EINA_TRUE);
}
}
Eina_Bool file_tab_it_add(Enventor_Item *enventor_it)
{
@ -58,14 +102,10 @@ Eina_Bool file_tab_it_add(Enventor_Item *enventor_it)
goto err;
}
Evas_Object *btn = elm_button_add(fd->in_box);
elm_object_text_set(btn, filename);
elm_object_style_set(btn, "enventor");
evas_object_size_hint_weight_set(btn, 0, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(btn, 0, 0.5);
evas_object_show(btn);
fti->it = enventor_it;
elm_box_pack_end(fd->in_box, btn);
elm_list_item_append(fd->list, filename, NULL, NULL, NULL, fti);
elm_list_go(fd->list);
free(filename);
@ -89,14 +129,16 @@ file_tab_init(Evas_Object *parent)
//Outer Box
Evas_Object *out_box = elm_box_add(parent);
elm_box_padding_set(out_box, ELM_SCALE_SIZE(5), 0);
elm_box_padding_set(out_box, ELM_SCALE_SIZE(3), 0);
elm_box_horizontal_set(out_box, EINA_TRUE);
//Left Button
Evas_Object *left_btn = elm_button_add(out_box);
elm_object_style_set(left_btn, ENVENTOR_NAME);
elm_object_focus_allow_set(left_btn, EINA_FALSE);
evas_object_size_hint_weight_set(left_btn, 0, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(left_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_smart_callback_add(left_btn, "clicked", left_btn_clicked_cb, fd);
evas_object_show(left_btn);
elm_box_pack_end(out_box, left_btn);
@ -107,9 +149,12 @@ file_tab_init(Evas_Object *parent)
//Right Button
Evas_Object *right_btn = elm_button_add(out_box);
elm_object_style_set(right_btn, ENVENTOR_NAME);
elm_object_focus_allow_set(left_btn, EINA_FALSE);
evas_object_size_hint_weight_set(right_btn, 0, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(right_btn, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_style_set(right_btn, ENVENTOR_NAME);
evas_object_smart_callback_add(right_btn, "clicked",
right_btn_clicked_cb, fd);
evas_object_show(right_btn);
elm_box_pack_end(out_box, right_btn);
@ -118,27 +163,20 @@ file_tab_init(Evas_Object *parent)
elm_image_file_set(img2, EDJE_PATH, "right_arrow");
elm_object_content_set(right_btn, img2);
//Scroller
Evas_Object *scroller = elm_scroller_add(out_box);
elm_object_style_set(scroller, ENVENTOR_NAME);
elm_scroller_policy_set(scroller, ELM_SCROLLER_POLICY_OFF,
//List
Evas_Object *list = elm_list_add(out_box);
elm_object_style_set(list, ENVENTOR_NAME);
elm_list_horizontal_set(list, EINA_TRUE);
elm_scroller_policy_set(list, ELM_SCROLLER_POLICY_OFF,
ELM_SCROLLER_POLICY_OFF);
evas_object_size_hint_weight_set(scroller, EVAS_HINT_EXPAND,
evas_object_size_hint_weight_set(list, EVAS_HINT_EXPAND,
EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(scroller, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(scroller);
elm_box_pack_end(out_box, scroller);
//Inner Box
Evas_Object *in_box = elm_box_add(scroller);
elm_box_horizontal_set(in_box, EINA_TRUE);
evas_object_size_hint_weight_set(in_box, 0, EVAS_HINT_EXPAND);
evas_object_size_hint_align_set(in_box, EVAS_HINT_FILL, EVAS_HINT_FILL);
elm_object_content_set(scroller, in_box);
evas_object_size_hint_align_set(list, EVAS_HINT_FILL, EVAS_HINT_FILL);
evas_object_show(list);
elm_box_pack_end(out_box, list);
fd->out_box = out_box;
fd->in_box = in_box;
fd->scroller = scroller;
fd->list = list;
return out_box;
}

View File

@ -595,6 +595,7 @@ enventor_setup(app_data *ad)
ad->main_it =
enventor_object_main_file_set(enventor, config_input_path_get());
file_tab_it_add(ad->main_it);
file_tab_it_selected_set(ad->main_it);
base_enventor_set(enventor);
base_text_editor_set(ad->main_it);

View File

@ -1,3 +1,4 @@
Evas_Object *file_tab_init(Evas_Object *parent);
void file_tab_term(void);
Eina_Bool file_tab_it_add(Enventor_Item *it);
Eina_Bool file_tab_it_selected_set(Enventor_Item *enventor_it);

11
src/lib/util.c Normal file
View File

@ -0,0 +1,11 @@
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include <Enventor.h>
#include "enventor_private.h"
void mem_fail_msg(void)
{
EINA_LOG_ERR("Failed to allocate Memory!");
}