#define COVER_ALPHA_SPEED 10 #define COVER_UPDATE_INTERVAL 0.05 public cover_alpha = 0; public previous_cover_alpha = 0; public cover_timer = 0; public cover_is_set = 0; public cover_set() { custom_state(PART:"cover_clip", "default"); set_state(PART:"cover_clip", "custom", 0.0); custom_state(PART:"previous_cover_clip", "default"); set_state(PART:"previous_cover_clip", "custom", 0.0); set_int(previous_cover_alpha, get_int(cover_alpha)); run_program(PROGRAM:"open_left_side"); cover_change_cb(1); } public cover_unset() { custom_state(PART:"cover_clip", "default"); set_state(PART:"cover_clip", "custom", 0.0); custom_state(PART:"previous_cover_clip", "default"); set_state(PART:"previous_cover_clip", "custom", 0.0); set_int(previous_cover_alpha, get_int(cover_alpha)); run_program(PROGRAM:"close_left_side"); cover_change_cb(0); } public cover_change_cb(set) { new ca, pca, id; if ((id = get_int(cover_timer)) && (set != get_int(cover_is_set))) { cancel_timer(id); set_int(cover_timer, 0); set_int(cover_is_set, set); } ca = get_int(cover_alpha); pca = get_int(previous_cover_alpha); if (set == 0) ca = 0; else { if (ca < 255) { ca += COVER_ALPHA_SPEED; if (ca > 255) ca = 255; } } if (pca > 0) { pca -= COVER_ALPHA_SPEED; if (pca < 0) pca = 0; } if (set == 0) { if (pca != 0) set_int(cover_timer, timer(COVER_UPDATE_INTERVAL, "cover_change_cb", set)); else set_int(cover_timer, 0); } else { if (ca != 255 || pca != 0) set_int(cover_timer, timer(COVER_UPDATE_INTERVAL, "cover_change_cb", set)); else set_int(cover_timer, 0); } set_state_val(PART:"cover_clip", STATE_COLOR, 255, 255, 255, ca); set_state_val(PART:"previous_cover_clip", STATE_COLOR, 255, 255, 255, pca); set_int(cover_alpha, ca); set_int(previous_cover_alpha, pca); //TODO: edje bug: the edje object is not updated after the set_state_val call //run_program(PROGRAM:"update"); }