static void glw_slideshow_render(glw_t *w, const glw_rctx_t *rc) { glw_t *c, *p, *n; glw_rctx_t rc0; if((c = w->glw_focused) == NULL) return; p = glw_prev_widget(c); if(p == NULL) p = glw_last_widget(w); if(p != NULL && p != c) { if(p->glw_parent_alpha > 0.01) { rc0 = *rc; rc0.rc_alpha *= p->glw_parent_alpha; glw_render0(p, &rc0); } } rc0 = *rc; rc0.rc_alpha *= c->glw_parent_alpha; glw_render0(c, &rc0); n = glw_next_widget(c); if(n == NULL) n = glw_first_widget(w); if(n != NULL && n != c) { if(n->glw_parent_alpha > 0.01) { rc0 = *rc; rc0.rc_alpha *= n->glw_parent_alpha; glw_render0(n, &rc0); } } }
static int glw_slideshow_event(glw_t *w, event_t *e) { glw_root_t *gr = w->glw_root; glw_slideshow_t *s = (glw_slideshow_t *)w; glw_t *c; event_int_t *eu = (event_int_t *)e; if(event_is_action(e, ACTION_SKIP_FORWARD) || event_is_action(e, ACTION_RIGHT)) { c = w->glw_focused ? glw_next_widget(w->glw_focused) : NULL; if(c == NULL) c = glw_first_widget(w); w->glw_focused = c; s->deadline = 0; glw_need_refresh(gr, 0); } else if(event_is_action(e, ACTION_SKIP_BACKWARD) || event_is_action(e, ACTION_LEFT)) { c = w->glw_focused ? glw_prev_widget(w->glw_focused) : NULL; if(c == NULL) c = glw_last_widget(w, 0); w->glw_focused = c; s->deadline = 0; glw_need_refresh(gr, 0); } else if(event_is_type(e, EVENT_UNICODE) && eu->val == 32) { s->hold = !s->hold; glw_slideshow_update_playstatus(s); } else if(event_is_action(e, ACTION_PLAYPAUSE) || event_is_action(e, ACTION_PLAY) || event_is_action(e, ACTION_PAUSE)) { s->hold = action_update_hold_by_event(s->hold, e); glw_slideshow_update_playstatus(s); } else if(event_is_action(e, ACTION_STOP)) { prop_set_string(s->playstatus, "stop"); } else return 0; return 1; }
static int glw_nav_last(glw_t *parent) { glw_t *c = glw_last_widget(parent); while(c != NULL) { glw_t *to_focus = glw_get_focusable_child(c); if(to_focus != NULL && to_focus->glw_flags2 & GLW2_NAV_FOCUSABLE) { glw_focus_set(to_focus->glw_root, to_focus, GLW_FOCUS_SET_INTERACTIVE, "NavLast"); return 1; } c = glw_prev_widget(c); } return 0; }
static void glw_slideshow_render(glw_t *w, const glw_rctx_t *rc) { glw_t *c, *p, *n; glw_rctx_t rc0; float sa = w->glw_alpha; if((c = w->glw_focused) == NULL) return; p = glw_prev_widget(c); if(p == NULL) p = glw_last_widget(w); if(p != NULL && p != c) { float a = sa * glw_parent_data(p, glw_slideshow_item_t)->alpha; if(a > GLW_ALPHA_EPSILON) { rc0 = *rc; rc0.rc_alpha *= a; glw_render0(p, &rc0); } } rc0 = *rc; rc0.rc_alpha *= sa * glw_parent_data(c, glw_slideshow_item_t)->alpha; glw_render0(c, &rc0); n = glw_next_widget(c); if(n == NULL) n = glw_first_widget(w); if(n != NULL && n != c) { float a = sa * glw_parent_data(n, glw_slideshow_item_t)->alpha; if(a > GLW_ALPHA_EPSILON) { rc0 = *rc; rc0.rc_alpha *= a; glw_render0(n, &rc0); } } }
static void glw_slideshow_layout(glw_t *w, const glw_rctx_t *rc) { glw_slideshow_t *s = (glw_slideshow_t *)w; glw_t *c, *p, *n; float delta; glw_reset_screensaver(w->glw_root); delta = s->w.glw_root->gr_frameduration / (1000000.0 * s->transition_time); if(s->time == 0) { s->displaytime = INT32_MAX; } else { s->displaytime = 1000000 * s->time / s->w.glw_root->gr_frameduration; } if((c = s->w.glw_focused) == NULL) { c = s->w.glw_focused = glw_first_widget(&s->w); if(c) glw_copy_constraints(&s->w, c); } if(c == NULL) return; if(s->timer >= s->displaytime) { c = glw_next_widget(c); if(c == NULL) c = glw_first_widget(&s->w); s->timer = 0; if(c != NULL) { glw_focus_open_path_close_all_other(c); glw_copy_constraints(&s->w, c); } } if(!s->hold) s->timer++; glw_layout0(c, rc); c->glw_parent_alpha = GLW_MIN(c->glw_parent_alpha + delta, 1.0f); /** * Keep previous and next images 'hot' (ie, loaded into texture memory) */ p = glw_prev_widget(c); if(p == NULL) p = glw_last_widget(&s->w); if(p != NULL && p != c) { p->glw_parent_alpha = GLW_MAX(p->glw_parent_alpha - delta, 0.0f); glw_layout0(p, rc); } n = glw_next_widget(c); if(n == NULL) n = glw_first_widget(&s->w); if(n != NULL && n != c) { n->glw_parent_alpha = GLW_MAX(n->glw_parent_alpha - delta, 0.0f); glw_layout0(n, rc); } }
static void glw_slideshow_layout(glw_t *w, const glw_rctx_t *rc) { glw_root_t *gr = w->glw_root; glw_slideshow_t *s = (glw_slideshow_t *)w; glw_t *c, *p, *n; float delta; int r = 0; glw_reset_screensaver(w->glw_root); delta = s->w.glw_root->gr_frameduration / (float)s->transition_time; if((c = s->w.glw_focused) == NULL) { c = s->w.glw_focused = glw_first_widget(&s->w); if(c) glw_copy_constraints(&s->w, c); } if(c == NULL) return; glw_schedule_refresh(gr, s->deadline); if(s->deadline <= gr->gr_frame_start) { s->deadline = gr->gr_frame_start + s->display_time; c = glw_next_widget(c); if(c == NULL) c = glw_first_widget(&s->w); if(c != NULL) { glw_focus_open_path_close_all_other(c); glw_copy_constraints(&s->w, c); } } glw_layout0(c, rc); r |= update_parent_alpha(c, GLW_MIN(c->glw_parent_alpha + delta, 1.0f)); /** * Keep previous and next images 'hot' (ie, loaded into texture memory) */ p = glw_prev_widget(c); if(p == NULL) p = glw_last_widget(&s->w, 0); if(p != NULL && p != c) { r |= update_parent_alpha(p, GLW_MAX(p->glw_parent_alpha - delta, 0.0f)); glw_layout0(p, rc); } n = glw_next_widget(c); if(n == NULL) n = glw_first_widget(&s->w); if(n != NULL && n != c) { r |= update_parent_alpha(n, GLW_MAX(n->glw_parent_alpha - delta, 0.0f)); glw_layout0(n, rc); } if(r) glw_need_refresh(w->glw_root, 0); }