X-Git-Url: https://www.fi.muni.cz/~kas/git//home/kas/public_html/git/?a=blobdiff_plain;f=shell%2Fev-transition-animation.c;h=148b4c7734eccaba3e576e1f1ec5ef060ce722e3;hb=5e55b6b5e74175b5638337616b84527fb8286908;hp=6a4006b27df5170ae5eae7db03b32235dab288ce;hpb=16e10a8f22b1c22f6770e8d9d62938b83b5c52f1;p=evince.git diff --git a/shell/ev-transition-animation.c b/shell/ev-transition-animation.c index 6a4006b2..148b4c77 100644 --- a/shell/ev-transition-animation.c +++ b/shell/ev-transition-animation.c @@ -370,6 +370,180 @@ ev_transition_animation_box (cairo_t *cr, } } +static void +ev_transition_animation_wipe (cairo_t *cr, + EvTransitionAnimation *animation, + EvTransitionEffect *effect, + gdouble progress, + GdkRectangle page_area) +{ + EvTransitionAnimationPriv *priv; + gint width, height; + gint angle; + + priv = EV_TRANSITION_ANIMATION_GET_PRIVATE (animation); + width = page_area.width; + height = page_area.height; + + g_object_get (effect, + "angle", &angle, + NULL); + + paint_surface (cr, priv->origin_surface, 0, 0, 0, page_area); + + if (angle == 0) { + /* left to right */ + cairo_rectangle (cr, + 0, 0, + width * progress, + height); + } else if (angle <= 90) { + /* bottom to top */ + cairo_rectangle (cr, + 0, + height * (1 - progress), + width, + height * progress); + } else if (angle <= 180) { + /* right to left */ + cairo_rectangle (cr, + width * (1 - progress), + 0, + width * progress, + height); + } else if (angle <= 270) { + /* top to bottom */ + cairo_rectangle (cr, + 0, 0, + width, + height * progress); + } + + cairo_clip (cr); + + paint_surface (cr, priv->dest_surface, 0, 0, 0, page_area); +} + +static void +ev_transition_animation_dissolve (cairo_t *cr, + EvTransitionAnimation *animation, + EvTransitionEffect *effect, + gdouble progress, + GdkRectangle page_area) +{ + EvTransitionAnimationPriv *priv; + + priv = EV_TRANSITION_ANIMATION_GET_PRIVATE (animation); + + paint_surface (cr, priv->dest_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->origin_surface, 0, 0, 1 - progress, page_area); +} + +static void +ev_transition_animation_push (cairo_t *cr, + EvTransitionAnimation *animation, + EvTransitionEffect *effect, + gdouble progress, + GdkRectangle page_area) +{ + EvTransitionAnimationPriv *priv; + gint width, height; + gint angle; + + priv = EV_TRANSITION_ANIMATION_GET_PRIVATE (animation); + width = page_area.width; + height = page_area.height; + + g_object_get (effect, + "angle", &angle, + NULL); + + if (angle == 0) { + /* left to right */ + paint_surface (cr, priv->origin_surface, - (width * progress), 0, 0, page_area); + paint_surface (cr, priv->dest_surface, width * (1 - progress), 0, 0, page_area); + } else { + /* top to bottom */ + paint_surface (cr, priv->origin_surface, 0, - (height * progress), 0, page_area); + paint_surface (cr, priv->dest_surface, 0, height * (1 - progress), 0, page_area); + } +} + +static void +ev_transition_animation_cover (cairo_t *cr, + EvTransitionAnimation *animation, + EvTransitionEffect *effect, + gdouble progress, + GdkRectangle page_area) +{ + EvTransitionAnimationPriv *priv; + gint width, height; + gint angle; + + priv = EV_TRANSITION_ANIMATION_GET_PRIVATE (animation); + width = page_area.width; + height = page_area.height; + + g_object_get (effect, + "angle", &angle, + NULL); + + paint_surface (cr, priv->origin_surface, 0, 0, 0, page_area); + + if (angle == 0) { + /* left to right */ + paint_surface (cr, priv->dest_surface, width * (1 - progress), 0, 0, page_area); + } else { + /* top to bottom */ + paint_surface (cr, priv->dest_surface, 0, height * (1 - progress), 0, page_area); + } +} + +static void +ev_transition_animation_uncover (cairo_t *cr, + EvTransitionAnimation *animation, + EvTransitionEffect *effect, + gdouble progress, + GdkRectangle page_area) +{ + EvTransitionAnimationPriv *priv; + gint width, height; + gint angle; + + priv = EV_TRANSITION_ANIMATION_GET_PRIVATE (animation); + width = page_area.width; + height = page_area.height; + + g_object_get (effect, + "angle", &angle, + NULL); + + paint_surface (cr, priv->dest_surface, 0, 0, 0, page_area); + + if (angle == 0) { + /* left to right */ + paint_surface (cr, priv->origin_surface, - (width * progress), 0, 0, page_area); + } else { + /* top to bottom */ + paint_surface (cr, priv->origin_surface, 0, - (height * progress), 0, page_area); + } +} + +static void +ev_transition_animation_fade (cairo_t *cr, + EvTransitionAnimation *animation, + EvTransitionEffect *effect, + gdouble progress, + GdkRectangle page_area) +{ + EvTransitionAnimationPriv *priv; + + priv = EV_TRANSITION_ANIMATION_GET_PRIVATE (animation); + + paint_surface (cr, priv->origin_surface, 0, 0, 0, page_area); + paint_surface (cr, priv->dest_surface, 0, 0, progress, page_area); +} + void ev_transition_animation_paint (EvTransitionAnimation *animation, cairo_t *cr, @@ -405,6 +579,24 @@ ev_transition_animation_paint (EvTransitionAnimation *animation, case EV_TRANSITION_EFFECT_BOX: ev_transition_animation_box (cr, animation, priv->effect, progress, page_area); break; + case EV_TRANSITION_EFFECT_WIPE: + ev_transition_animation_wipe (cr, animation, priv->effect, progress, page_area); + break; + case EV_TRANSITION_EFFECT_DISSOLVE: + ev_transition_animation_dissolve (cr, animation, priv->effect, progress, page_area); + break; + case EV_TRANSITION_EFFECT_PUSH: + ev_transition_animation_push (cr, animation, priv->effect, progress, page_area); + break; + case EV_TRANSITION_EFFECT_COVER: + ev_transition_animation_cover (cr, animation, priv->effect, progress, page_area); + break; + case EV_TRANSITION_EFFECT_UNCOVER: + ev_transition_animation_uncover (cr, animation, priv->effect, progress, page_area); + break; + case EV_TRANSITION_EFFECT_FADE: + ev_transition_animation_fade (cr, animation, priv->effect, progress, page_area); + break; default: { GEnumValue *enum_value; @@ -476,3 +668,15 @@ ev_transition_animation_set_dest_surface (EvTransitionAnimation *animation, if (priv->origin_surface && priv->dest_surface) ev_timeline_start (EV_TIMELINE (animation)); } + +gboolean +ev_transition_animation_ready (EvTransitionAnimation *animation) +{ + EvTransitionAnimationPriv *priv; + + g_return_val_if_fail (EV_IS_TRANSITION_ANIMATION (animation), FALSE); + + priv = EV_TRANSITION_ANIMATION_GET_PRIVATE (animation); + + return (priv->origin_surface && priv->dest_surface); +}