super simple press button with click sound and background image
Simple Button that has two state "pressed" and "unpressed" with sound on touch released.
Evas_Object* button = elm_button_add(box);
evas_object_size_hint_weight_set(button, EVAS_HINT_EXPAND, EVAS_HINT_EXPAND);
char edj_path[512] = {0,};
char *resdir = app_get_resource_path();
strcat(edj_path, resdir);
strcat(edj_path, "style.edj");
elm_layout_file_set(button, edj_path, "main");
free(resdir);
elm_object_part_text_set(button, "text", "Test");
elm_box_pack_end(box, button);
evas_object_show(button);
/*
// style.edj
// be careful, png and wav files must be placed into directory written with -ID -SD options.
collections {
images {
image: "pause.png" COMP;
image: "play.png" COMP;
}
sounds {
sample { name: "sound" LOSSY 64;
source: "button.wav";
}
}
group { name: "main";
parts {
part { name: "bg";
type: IMAGE;
mouse_events: 1;
description { state: "default" 0.0;
min: 128 128;
image.normal: "play.png";
rel1.relative: 0.0 0.0;
rel2.relative: 1.0 1.0;
}
description { state: "pressed" 0.0;
inherit: "default" 0.0;
image.normal: "pause.png";
}
}
part { name: "text";
type: TEXT;
mouse_events: 0;
description { state : "default" 0.0;
align: 0.5 0.5;
text {
text: "BuTToN";
size: 35;
}
color: 0 0 0 255;
}
}
}
programs {
// for button pressed
program { name: "mouse_down";
signal: "mouse,down,1";
source: "bg";
action: SIGNAL_EMIT "elm,action,press" "";
after: "img_pressed";
}
// for button unpressed
program { name: "mouse_up";
signal: "mouse,up,1";
source: "bg";
action: SIGNAL_EMIT "elm,action,unpress" "";
after: "img_unpressed";
}
program { name: "img_pressed";
action: STATE_SET "pressed" 0.0;
target: "bg";
}
program { name: "img_unpressed";
action: STATE_SET "default" 0.0;
target: "bg";
after: "mouse_clicked";
}
program { name: "mouse_clicked";
action: SIGNAL_EMIT "elm,action,click" "";
after: "btn_sound";
}
program { name: "btn_sound";
action: PLAY_SAMPLE "sound" 1.0;
}
}
}
}
*/