add image number indicator for bgselector

This commit is contained in:
zmike 2014-02-05 00:59:01 -05:00
parent 96c29bd051
commit 42e368c520
3 changed files with 76 additions and 16 deletions

View File

@ -120,17 +120,42 @@
rel2.relative: 0.9 0.9;
}
}
part { name: "empc.text.count"; type: TEXT; mouse_events: 0;
effect: GLOW;
scale: 1;
description { state: "default";
fixed: 1 1;
align: 0.0 0.5;
color: 255 255 255 0;
color2: 0 0 0 0;
color3: 0 0 0 0;
text { font: "Sans:style=Bold"; size: 12;
min: 1 1;
align: 0 0.5;
}
visible: 0;
}
description { state: "active";
inherit: "default";
visible: 1;
color: 255 255 255 255;
color2: 0 0 0 192;
color3: 0 0 0 128;
}
}
program { signal: "empc,state,active"; source: "empc";
action: STATE_SET "active" 0.0;
transition: LINEAR 0.2;
target: "empc.swallow.0";
target: "empc.swallow.1";
target: "empc.text.count";
}
program { signal: "empc,state,inactive"; source: "empc";
action: STATE_SET "default" 0.0;
transition: LINEAR 0.2;
target: "empc.swallow.0";
target: "empc.swallow.1";
target: "empc.text.count";
}
}
}

View File

@ -31,6 +31,24 @@ collections {
aspect: 1.0 1.0; aspect_preference: BOTH;
}
}
part { name: "text_clip"; type: RECT; mouse_events: 0;
description { state: "default";
}
description { state: "hidden";
color: 255 255 255 0;
visible: 0;
}
}
program { name: "text_show";
action: STATE_SET "default" 0.0;
transition: LINEAR 0.2 CURRENT;
target: "text_clip";
}
program { name: "text_hide";
action: STATE_SET "hidden" 0.0;
transition: LINEAR 0.2 CURRENT;
target: "text_clip";
}
part { name: EMPC_BASE_SWALLOW_BACKGROUND; type: SWALLOW;
description { state: "default";
}
@ -45,31 +63,32 @@ collections {
rel2.relative: 2 1;
}
}
program { signal: "empc,bg_chooser,stop"; source: "empc";
script {
if (get_int(bg_chooser)) {
emit("empc,bg_chooser,inactive", "empc");
set_int(bg_chooser, 0);
}
}
}
program { signal: "empc,bg_chooser,start"; source: "empc";
program { name: "bg_chooser_active";
signal: "empc,bg_chooser,start"; source: "empc";
script {
if (!get_int(bg_chooser)) {
emit("empc,bg_chooser,active", "empc");
set_int(bg_chooser, 1);
run_program(get_program_id("text_hide"));
}
}
}
program { name: "bg_chooser_inactive";
signal: "empc,bg_chooser,stop"; source: "empc";
script {
if (get_int(bg_chooser)) {
emit("empc,bg_chooser,inactive", "empc");
set_int(bg_chooser, 0);
run_program(get_program_id("text_show"));
}
}
}
program { signal: "mouse,down,1,double"; source: EMPC_BASE_SWALLOW_BACKGROUND;
script {
if (!get_int(bg_chooser)) {
emit("empc,bg_chooser,active", "empc");
set_int(bg_chooser, 1);
} else {
emit("empc,bg_chooser,inactive", "empc");
set_int(bg_chooser, 0);
}
if (!get_int(bg_chooser))
run_program(get_program_id("bg_chooser_active"));
else
run_program(get_program_id("bg_chooser_inactive"));
}
}
program { signal: "mouse,wheel,0,-1"; source: EMPC_BASE_SWALLOW_BACKGROUND;
@ -117,6 +136,7 @@ collections {
after: "empc_bg_done";
}
part { name: EMPC_BASE_TEXT_ARTIST; type: TEXT; mouse_events: 0;
clip_to: "text_clip";
effect: GLOW;
scale: 1;
description { state: "default";
@ -133,6 +153,7 @@ collections {
}
}
part { name: EMPC_BASE_TEXT_ALBUM; type: TEXT; mouse_events: 0;
clip_to: "text_clip";
effect: GLOW;
scale: 1;
description { state: "default";
@ -171,6 +192,7 @@ collections {
}
}
part { name: "title_clip"; type: RECT; mouse_events: 0;
clip_to: "text_clip";
description { state: "default";
}
description { state: "left";
@ -181,6 +203,7 @@ collections {
}
}
part { name: "title_animator"; type: TEXT; mouse_events: 0;
clip_to: "text_clip";
effect: GLOW;
scale: 1;
description { state: "default";

View File

@ -5,6 +5,7 @@ typedef struct Bgselector
Evas_Object *layout;
Eina_List *current;
Eina_List *images;
unsigned int current_num;
Eina_Bool state : 1;
Eina_Bool animating : 1;
Eina_Bool active : 1;
@ -36,9 +37,12 @@ _bgs_switch(void *data, Evas_Object *obj EINA_UNUSED, const char *sig, const cha
{
Bgselector *bgs = data;
const char *num = sig + sizeof("empc,state,visible,") - 1;
char buf[64];
bgs->state = atoi(num);
bgs->animating = 0;
snprintf(buf, sizeof(buf), "%d/%d", bgs->current_num + 1, eina_list_count(bgs->images));
elm_object_part_text_set(obj, "empc.text.count", buf);
}
Evas_Object *
@ -53,6 +57,7 @@ bgselector_add(Evas_Object *parent)
elm_layout_theme_set(o, "layout", "empc", "bgselector");
elm_object_signal_callback_add(o, "empc,state,visible,*", "empc", _bgs_switch, bgs);
evas_object_event_callback_add(o, EVAS_CALLBACK_DEL, _bgs_del, bgs);
elm_object_part_text_set(o, "empc.text.count", "0");
return o;
}
@ -61,6 +66,7 @@ void
bgselector_image_add(Evas_Object *obj, Evas_Object *img)
{
Bgselector *bgs;
char buf[64];
EINA_SAFETY_ON_NULL_RETURN(img);
bgs = evas_object_data_get(obj, "__bgselector");
@ -68,6 +74,8 @@ bgselector_image_add(Evas_Object *obj, Evas_Object *img)
//unsigned int c = eina_list_count(bgs->images) + 1;
//evas_object_data_set(img, "__bgselector_num", (uintptr_t*)c);
bgs->images = eina_list_append(bgs->images, img);
snprintf(buf, sizeof(buf), "%d/%d", bgs->current_num + 1, eina_list_count(bgs->images));
elm_object_part_text_set(obj, "empc.text.count", buf);
if (bgs->current)
{
evas_object_hide(img);
@ -92,6 +100,7 @@ bgselector_next(Evas_Object *obj)
it = eina_list_data_get(bgs->current->next);
if (!it) return;
bgs->current = bgs->current->next;
bgs->current_num++;
evas_object_show(it);
//INF("IMG NEXT: %u", (unsigned int)evas_object_data_get(it, "__bgselector_num"));
elm_object_part_content_unset(bgs->layout, part_name[_bg_next_get(bgs->state)]);
@ -114,6 +123,7 @@ bgselector_prev(Evas_Object *obj)
it = eina_list_data_get(bgs->current->prev);
if (!it) return;
bgs->current = bgs->current->prev;
bgs->current_num--;
evas_object_show(it);
//INF("IMG PREV: %u", (unsigned int)evas_object_data_get(it, "__bgselector_num"));
elm_object_part_content_unset(bgs->layout, part_name[_bg_next_get(bgs->state)]);
@ -143,6 +153,7 @@ bgselector_clear(Evas_Object *obj)
elm_object_signal_emit(bgs->layout, "empc,bg,prev", "empc");
bgs->state = 0;
bgs->current = NULL;
bgs->current_num = 0;
}
void
@ -157,6 +168,7 @@ bgselector_prune(Evas_Object *obj)
bgs->images = eina_list_remove_list(bgs->images, bgs->current);
E_FREE_LIST(bgs->images, evas_object_del);
bgs->current = bgs->images = eina_list_append(bgs->images, img);
bgs->current_num = 0;
}
void