[ease/video: 5/5] [video] Add VideoActor play/pause controls.



commit 999bc79a7a733019783b0fe8beb28687ccdcdffa
Author: Nate Stedman <natesm gmail com>
Date:   Thu Jul 29 08:55:41 2010 -0400

    [video] Add VideoActor play/pause controls.

 data/svg-sources/video-play-button-inkscape.svg |  257 +++++++++++++++++++++++
 data/svg/video-play-button.svg                  |  256 ++++++++++++++++++++++
 ease-core/ease-actor.vala                       |   16 ++
 ease-core/ease-video-actor.vala                 |  161 ++++++++++++++-
 ease-core/ease-video-element.vala               |    4 +
 5 files changed, 691 insertions(+), 3 deletions(-)
---
diff --git a/data/svg-sources/video-play-button-inkscape.svg b/data/svg-sources/video-play-button-inkscape.svg
new file mode 100644
index 0000000..3f9765d
--- /dev/null
+++ b/data/svg-sources/video-play-button-inkscape.svg
@@ -0,0 +1,257 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:xlink="http://www.w3.org/1999/xlink";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   version="1.1"
+   width="200"
+   height="200"
+   id="svg2"
+   inkscape:version="0.47 r22583"
+   sodipodi:docname="video-play-button.svg">
+  <metadata
+     id="metadata2829">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="1680"
+     inkscape:window-height="1000"
+     id="namedview2827"
+     showgrid="false"
+     inkscape:zoom="1.3417336"
+     inkscape:cx="99.736496"
+     inkscape:cy="99.999997"
+     inkscape:window-x="0"
+     inkscape:window-y="25"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="layer1" />
+  <defs
+     id="defs4">
+    <linearGradient
+       id="linearGradient3771">
+      <stop
+         id="stop3773"
+         offset="0"
+         style="stop-color:#dddddd;stop-opacity:1;" />
+      <stop
+         id="stop3775"
+         offset="1"
+         style="stop-color:#ffffff;stop-opacity:1;" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient3747">
+      <stop
+         style="stop-color:#ffffff;stop-opacity:1;"
+         offset="0"
+         id="stop3749" />
+      <stop
+         style="stop-color:#727272;stop-opacity:1;"
+         offset="1"
+         id="stop3751" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient3643">
+      <stop
+         style="stop-color:#b5b5b5;stop-opacity:1;"
+         offset="0"
+         id="stop3645" />
+      <stop
+         style="stop-color:#ffffff;stop-opacity:1;"
+         offset="1"
+         id="stop3647" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient3605">
+      <stop
+         style="stop-color:#000000;stop-opacity:1;"
+         offset="0"
+         id="stop3607" />
+      <stop
+         style="stop-color:#474747;stop-opacity:1;"
+         offset="1"
+         id="stop3609" />
+    </linearGradient>
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 100 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="200 : 100 : 1"
+       inkscape:persp3d-origin="100 : 66.666667 : 1"
+       id="perspective2831" />
+    <linearGradient
+       id="linearGradient3608">
+      <stop
+         id="stop3610"
+         style="stop-color:#ffffff;stop-opacity:1"
+         offset="0" />
+      <stop
+         id="stop3612"
+         style="stop-color:#b7b7b7;stop-opacity:1"
+         offset="1" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient3592">
+      <stop
+         id="stop3594"
+         style="stop-color:#4e4e4e;stop-opacity:1"
+         offset="0" />
+      <stop
+         id="stop3596"
+         style="stop-color:#4a4a4a;stop-opacity:1"
+         offset="1" />
+    </linearGradient>
+    <radialGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3605"
+       id="radialGradient3617"
+       cx="-73.968117"
+       cy="187.73848"
+       fx="-73.968117"
+       fy="187.73848"
+       r="238.9817"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0.31918131,2.1331936,-2.3265057,0.34810583,473.29743,205.2387)" />
+    <inkscape:perspective
+       id="perspective3629"
+       inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+       inkscape:vp_z="1 : 0.5 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_x="0 : 0.5 : 1"
+       sodipodi:type="inkscape:persp3d" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3643"
+       id="linearGradient3649"
+       x1="86.016953"
+       y1="950.66724"
+       x2="86.016953"
+       y2="1011.8754"
+       gradientUnits="userSpaceOnUse" />
+    <inkscape:perspective
+       id="perspective3667"
+       inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+       inkscape:vp_z="1 : 0.5 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_x="0 : 0.5 : 1"
+       sodipodi:type="inkscape:persp3d" />
+    <filter
+       inkscape:collect="always"
+       id="filter3693"
+       x="-0.17237611"
+       width="1.3447522"
+       y="-0.14928198"
+       height="1.298564"
+       color-interpolation-filters="sRGB">
+      <feGaussianBlur
+         inkscape:collect="always"
+         stdDeviation="7.53851"
+         id="feGaussianBlur3695" />
+    </filter>
+    <inkscape:perspective
+       id="perspective3705"
+       inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+       inkscape:vp_z="1 : 0.5 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_x="0 : 0.5 : 1"
+       sodipodi:type="inkscape:persp3d" />
+    <radialGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3605-9"
+       id="radialGradient3617-5"
+       cx="-73.968117"
+       cy="187.73848"
+       fx="-73.968117"
+       fy="187.73848"
+       r="238.9817"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0.31918131,2.1331936,-2.3265057,0.34810583,473.29743,205.2387)" />
+    <linearGradient
+       id="linearGradient3605-9">
+      <stop
+         style="stop-color:#000000;stop-opacity:1;"
+         offset="0"
+         id="stop3607-3" />
+      <stop
+         style="stop-color:#474747;stop-opacity:1;"
+         offset="1"
+         id="stop3609-9" />
+    </linearGradient>
+    <filter
+       inkscape:collect="always"
+       id="filter3743"
+       color-interpolation-filters="sRGB">
+      <feGaussianBlur
+         inkscape:collect="always"
+         stdDeviation="7.0025082"
+         id="feGaussianBlur3745" />
+    </filter>
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3747"
+       id="linearGradient3753"
+       x1="100"
+       y1="170.52333"
+       x2="100"
+       y2="648.48676"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3771"
+       id="linearGradient3769"
+       x1="197.54715"
+       y1="-24.622486"
+       x2="198.33766"
+       y2="36.071426"
+       gradientUnits="userSpaceOnUse" />
+  </defs>
+  <g
+     transform="matrix(0.85611942,0,0,0.85611942,14.387959,-715.33566)"
+     id="layer1">
+    <path
+       d="m 198.03523,952.36907 a 98.035115,98.035115 0 0 1 -196.0702295,0 98.035115,98.035115 0 1 1 196.0702295,0 z"
+       id="path2816-9"
+       style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3.93000007;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;filter:url(#filter3743)" />
+    <path
+       d="m 334.28572,409.50504 a 234.28572,234.28572 0 1 1 -468.57144,0 234.28572,234.28572 0 1 1 468.57144,0 z"
+       transform="matrix(0.41844255,0,0,0.41844255,58.155746,781.00785)"
+       id="path2816"
+       style="fill:url(#radialGradient3617);fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient3753);stroke-width:9.39197063;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+    <path
+       d="M 159.959,951.264 107.4795,981.56306 55,1011.8622 l 0,-60.5982 0,-60.5981 52.4795,30.29905 52.4795,30.29905 z"
+       id="path2818-4"
+       style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;filter:url(#filter3693)" />
+    <path
+       d="m 289.25837,36.071426 -52.4795,30.299053 -52.4795,30.299052 0,-60.598106 0,-60.598103 52.4795,30.299053 52.4795,30.299051 z"
+       transform="translate(-129.29937,915.19265)"
+       id="path2818"
+       style="fill:url(#linearGradient3769);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-opacity:1;stroke-width:2.16792184999999993;stroke-miterlimit:4;stroke-dasharray:none" />
+    <path
+       d="M 159.959,951.26398 107.4795,981.56304 55,1011.8622 l 0,-60.59822 104.959,0 z"
+       id="path2818-1"
+       style="fill:url(#linearGradient3649);fill-opacity:1;fill-rule:evenodd;stroke:none"
+       sodipodi:nodetypes="ccccc" />
+  </g>
+</svg>
diff --git a/data/svg/video-play-button.svg b/data/svg/video-play-button.svg
new file mode 100644
index 0000000..b49e418
--- /dev/null
+++ b/data/svg/video-play-button.svg
@@ -0,0 +1,256 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<!-- Created with Inkscape (http://www.inkscape.org/) -->
+
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:xlink="http://www.w3.org/1999/xlink";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   version="1.1"
+   width="200"
+   height="200"
+   id="svg2"
+   inkscape:version="0.47 r22583"
+   sodipodi:docname="video-play-button.svg">
+  <metadata
+     id="metadata2829">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="1680"
+     inkscape:window-height="1000"
+     id="namedview2827"
+     showgrid="false"
+     inkscape:zoom="1.3417336"
+     inkscape:cx="99.736496"
+     inkscape:cy="99.999997"
+     inkscape:window-x="0"
+     inkscape:window-y="25"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="layer1" />
+  <defs
+     id="defs4">
+    <linearGradient
+       id="linearGradient3771">
+      <stop
+         id="stop3773"
+         offset="0"
+         style="stop-color:#dddddd;stop-opacity:1;" />
+      <stop
+         id="stop3775"
+         offset="1"
+         style="stop-color:#ffffff;stop-opacity:1;" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient3747">
+      <stop
+         style="stop-color:#ffffff;stop-opacity:1;"
+         offset="0"
+         id="stop3749" />
+      <stop
+         style="stop-color:#727272;stop-opacity:1;"
+         offset="1"
+         id="stop3751" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient3643">
+      <stop
+         style="stop-color:#b5b5b5;stop-opacity:1;"
+         offset="0"
+         id="stop3645" />
+      <stop
+         style="stop-color:#ffffff;stop-opacity:1;"
+         offset="1"
+         id="stop3647" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient3605">
+      <stop
+         style="stop-color:#000000;stop-opacity:1;"
+         offset="0"
+         id="stop3607" />
+      <stop
+         style="stop-color:#474747;stop-opacity:1;"
+         offset="1"
+         id="stop3609" />
+    </linearGradient>
+    <inkscape:perspective
+       sodipodi:type="inkscape:persp3d"
+       inkscape:vp_x="0 : 100 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_z="200 : 100 : 1"
+       inkscape:persp3d-origin="100 : 66.666667 : 1"
+       id="perspective2831" />
+    <linearGradient
+       id="linearGradient3608">
+      <stop
+         id="stop3610"
+         style="stop-color:#ffffff;stop-opacity:1"
+         offset="0" />
+      <stop
+         id="stop3612"
+         style="stop-color:#b7b7b7;stop-opacity:1"
+         offset="1" />
+    </linearGradient>
+    <linearGradient
+       id="linearGradient3592">
+      <stop
+         id="stop3594"
+         style="stop-color:#4e4e4e;stop-opacity:1"
+         offset="0" />
+      <stop
+         id="stop3596"
+         style="stop-color:#4a4a4a;stop-opacity:1"
+         offset="1" />
+    </linearGradient>
+    <radialGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3605"
+       id="radialGradient3617"
+       cx="-73.968117"
+       cy="187.73848"
+       fx="-73.968117"
+       fy="187.73848"
+       r="238.9817"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0.31918131,2.1331936,-2.3265057,0.34810583,473.29743,205.2387)" />
+    <inkscape:perspective
+       id="perspective3629"
+       inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+       inkscape:vp_z="1 : 0.5 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_x="0 : 0.5 : 1"
+       sodipodi:type="inkscape:persp3d" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3643"
+       id="linearGradient3649"
+       x1="86.016953"
+       y1="950.66724"
+       x2="86.016953"
+       y2="1011.8754"
+       gradientUnits="userSpaceOnUse" />
+    <inkscape:perspective
+       id="perspective3667"
+       inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+       inkscape:vp_z="1 : 0.5 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_x="0 : 0.5 : 1"
+       sodipodi:type="inkscape:persp3d" />
+    <filter
+       inkscape:collect="always"
+       id="filter3693"
+       x="-0.17237611"
+       width="1.3447522"
+       y="-0.14928198"
+       height="1.298564"
+       color-interpolation-filters="sRGB">
+      <feGaussianBlur
+         inkscape:collect="always"
+         stdDeviation="7.53851"
+         id="feGaussianBlur3695" />
+    </filter>
+    <inkscape:perspective
+       id="perspective3705"
+       inkscape:persp3d-origin="0.5 : 0.33333333 : 1"
+       inkscape:vp_z="1 : 0.5 : 1"
+       inkscape:vp_y="0 : 1000 : 0"
+       inkscape:vp_x="0 : 0.5 : 1"
+       sodipodi:type="inkscape:persp3d" />
+    <radialGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3605-9"
+       id="radialGradient3617-5"
+       cx="-73.968117"
+       cy="187.73848"
+       fx="-73.968117"
+       fy="187.73848"
+       r="238.9817"
+       gradientUnits="userSpaceOnUse"
+       gradientTransform="matrix(0.31918131,2.1331936,-2.3265057,0.34810583,473.29743,205.2387)" />
+    <linearGradient
+       id="linearGradient3605-9">
+      <stop
+         style="stop-color:#000000;stop-opacity:1;"
+         offset="0"
+         id="stop3607-3" />
+      <stop
+         style="stop-color:#474747;stop-opacity:1;"
+         offset="1"
+         id="stop3609-9" />
+    </linearGradient>
+    <filter
+       inkscape:collect="always"
+       id="filter3743"
+       color-interpolation-filters="sRGB">
+      <feGaussianBlur
+         inkscape:collect="always"
+         stdDeviation="7.0025082"
+         id="feGaussianBlur3745" />
+    </filter>
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3747"
+       id="linearGradient3753"
+       x1="100"
+       y1="170.52333"
+       x2="100"
+       y2="648.48676"
+       gradientUnits="userSpaceOnUse" />
+    <linearGradient
+       inkscape:collect="always"
+       xlink:href="#linearGradient3771"
+       id="linearGradient3769"
+       x1="197.54715"
+       y1="-24.622486"
+       x2="198.33766"
+       y2="36.071426"
+       gradientUnits="userSpaceOnUse" />
+  </defs>
+  <g
+     transform="matrix(0.85611942,0,0,0.85611942,14.387959,-715.33566)"
+     id="layer1">
+    <path
+       d="m 198.03523,952.36907 a 98.035115,98.035115 0 0 1 -196.0702295,0 98.035115,98.035115 0 1 1 196.0702295,0 z"
+       id="path2816-9"
+       style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:#000000;stroke-width:3.93000007;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none;filter:url(#filter3743)" />
+    <path
+       d="m 334.28572,409.50504 a 234.28572,234.28572 0 1 1 -468.57144,0 234.28572,234.28572 0 1 1 468.57144,0 z"
+       transform="matrix(0.41844255,0,0,0.41844255,58.155746,781.00785)"
+       id="path2816"
+       style="fill:url(#radialGradient3617);fill-opacity:1;fill-rule:evenodd;stroke:url(#linearGradient3753);stroke-width:9.39197063;stroke-linecap:butt;stroke-linejoin:miter;stroke-miterlimit:4;stroke-opacity:1;stroke-dasharray:none" />
+    <path
+       d="M 159.959,951.264 107.4795,981.56306 55,1011.8622 l 0,-60.5982 0,-60.5981 52.4795,30.29905 52.4795,30.29905 z"
+       id="path2818-4"
+       style="fill:#000000;fill-opacity:1;fill-rule:evenodd;stroke:none;filter:url(#filter3693)" />
+    <path
+       d="m 289.25837,36.071426 -52.4795,30.299053 -52.4795,30.299052 0,-60.598106 0,-60.598103 52.4795,30.299053 52.4795,30.299051 z"
+       transform="translate(-129.29937,915.19265)"
+       id="path2818"
+       style="fill:url(#linearGradient3769);fill-opacity:1;fill-rule:evenodd;stroke:none;stroke-opacity:1;stroke-width:2.16792184999999993;stroke-miterlimit:4;stroke-dasharray:none" />
+    <path
+       d="M 159.959,951.26398 107.4795,981.56304 55,1011.8622 l 0,-60.59822 104.959,0 z"
+       id="path2818-1"
+       style="fill:url(#linearGradient3649);fill-opacity:1;fill-rule:evenodd;stroke:none"
+       sodipodi:nodetypes="ccccc" />
+  </g>
+</svg>
diff --git a/ease-core/ease-actor.vala b/ease-core/ease-actor.vala
index 7b9a068..a7311e4 100644
--- a/ease-core/ease-actor.vala
+++ b/ease-core/ease-actor.vala
@@ -91,6 +91,22 @@ public abstract class Ease.Actor : Clutter.Group
 	}
 	
 	/**
+	 * Automatically resizes an actor to fit within this Actor's bounds.
+	 *
+	 * @param actor The actor to automatically scale.
+	 */
+	public void autosize(Clutter.Actor actor)
+	{
+		contents.notify["width"].connect(() => {
+			actor.width = width;
+		});
+		
+		contents.notify["height"].connect(() => {
+			actor.height = height;
+		});
+	}
+	
+	/**
 	 * Rereads the Actor's { link Element} to position it properly.
 	 *
 	 * Used after reverting an action.
diff --git a/ease-core/ease-video-actor.vala b/ease-core/ease-video-actor.vala
index 344764c..6582831 100644
--- a/ease-core/ease-video-actor.vala
+++ b/ease-core/ease-video-actor.vala
@@ -34,7 +34,53 @@ public class Ease.VideoActor : Actor, Clutter.Media
 	/**
 	 * The "play" button in a presentation.
 	 */
-	private Clutter.CairoTexture play_button;
+	private Clutter.Texture action_button;
+	
+	/**
+	 * The textured overlayed on the video when it is not playing.
+	 */
+	private Clutter.CairoTexture gloss;
+	
+	/**
+	 * The path to the "play" button svg.
+	 */
+	private const string PLAY_PATH =
+		Path.build_filename("svg", "video-play-button.svg");
+	
+	/**
+	 * A group to contain the video actor and the play button.
+	 */
+	private Clutter.Group group;
+	
+	/**
+	 * The amount of time it takes for the button to fade out.
+	 */
+	private const int BUTTON_TIME = 500;
+	
+	/**
+	 * Easing for the button fadeout.
+	 */
+	private const int ALPHA_OPACITY = Clutter.AnimationMode.LINEAR;
+	
+	/**
+	 * Easing for the button scale out.
+	 */
+	private const int ALPHA_SCALE = Clutter.AnimationMode.EASE_IN_BACK;
+	
+	/**
+	 * Easing for the button scale in.
+	 */
+	private const int ALPHA_SCALE_IN = Clutter.AnimationMode.EASE_OUT_BACK;
+	
+	/**
+	 * Start alarm.
+	 */
+	private Clutter.Timeline timeline;
+	
+	/**
+	 * Fade in alarm.
+	 */
+	private Clutter.Timeline timeline_in;
 
 	/**
 	 * Instantiates a new VideoActor from an Element.
@@ -53,11 +99,48 @@ public class Ease.VideoActor : Actor, Clutter.Media
 		video = new ClutterGst.VideoTexture();
 		video.set_filename(Path.build_filename(e.parent.parent.path,
 		                                       e.filename));
+		group = new Clutter.Group();
+		group.add_actor(video);
 
 		// play the video if it's in the presentation
 		if (c == ActorContext.PRESENTATION)
 		{
-			video.set_playing(true);
+			if (e.play_auto)
+			{
+				video.set_playing(true);
+				video.reactive = true;
+				create_paused_ui(e, false);
+			}
+			else
+			{
+				// get a video frame to display (dimmed maybe?)
+				video.set_playing(true);
+				video.set_playing(false);
+				create_paused_ui(e, true);
+			}
+			
+			// show the pause ui when the video is paused
+			video.button_press_event.connect((a, event) => {
+				video.reactive = false;
+				video.set_playing(false);
+				
+				// set overlay scale and alpha to 0
+				action_button.scale_x = 1;
+				action_button.scale_y = 1;
+			
+				// create an alarm
+				timeline_in = new Clutter.Timeline(BUTTON_TIME);
+				timeline_in.completed.connect(() => {
+					action_button.reactive = true;
+				});
+				timeline_in.start();
+			
+				// do the animations
+				gloss.animate(ALPHA_OPACITY, BUTTON_TIME, "opacity", 255);
+				action_button.animate(ALPHA_OPACITY, BUTTON_TIME,
+					                  "opacity", 255);
+				return true;
+			});
 		}
 		else
 		{
@@ -66,13 +149,85 @@ public class Ease.VideoActor : Actor, Clutter.Media
 			video.set_playing(false);
 		}
 		
-		contents = video;
+		contents = group;
 
 		add_actor(contents);
 		contents.width = e.width;
 		contents.height = e.height;
 		x = e.x;
 		y = e.y;
+		
+		autosize(video);
+	}
+	
+	private void create_paused_ui(VideoElement e, bool active)
+	{
+		// create the glossy overlay
+		gloss = new Clutter.CairoTexture((int)e.width, (int)e.height);
+		gloss.set_surface_size((int)e.width, (int)e.height);
+		gloss.opacity = 100;
+		var cr = gloss.create();
+	
+		// draw the upper, light triangle
+		cr.save();
+		cr.move_to(0, 0);
+		cr.line_to(e.width, 0);
+		cr.line_to(0, e.height);
+		cr.close_path();
+		cr.set_source_rgba(0, 0, 0, 0.5);
+		cr.fill();
+		cr.restore();
+	
+		// draw the lower, dark triangle
+		cr.move_to(e.width, e.height);
+		cr.line_to(e.width, 0);
+		cr.line_to(0, e.height);
+		cr.close_path();
+		cr.set_source_rgba(0, 0, 0, 0.8);
+		cr.fill();
+		
+		// create the action button
+		action_button = new Clutter.Texture.from_file(data_path(PLAY_PATH));
+		
+		// set the position of the button
+		action_button.anchor_gravity = Clutter.Gravity.CENTER;
+		action_button.x = e.width / 2;
+		action_button.y = e.height / 2;
+
+		// add the actors
+		group.add_actor(gloss);
+		group.add_actor(action_button);
+		
+		// allow the button to be clicked
+		action_button.button_press_event.connect((a, event) => {
+			action_button.reactive = false;
+			video.reactive = true;
+			timeline = new Clutter.Timeline(BUTTON_TIME);
+			timeline.completed.connect(() => {
+				video.set_playing(true);
+				video.reactive = true;
+			});
+			timeline.start();
+			gloss.animate(ALPHA_OPACITY, BUTTON_TIME / 2, "opacity", 0);
+			action_button.animate(ALPHA_OPACITY, BUTTON_TIME,
+			                      "opacity", 0);
+			action_button.animate(ALPHA_SCALE, BUTTON_TIME,
+			                      "scale-x", 0);
+			action_button.animate(ALPHA_SCALE, BUTTON_TIME,
+			                      "scale-y", 0);
+			return true;
+		});
+		
+		// if requested, show the new actors
+		if (!active)
+		{
+			action_button.opacity = 0;
+			gloss.opacity = 0;
+		}
+		else
+		{
+			action_button.reactive = true;
+		}
 	}
 	
 	public double get_audio_volume()
diff --git a/ease-core/ease-video-element.vala b/ease-core/ease-video-element.vala
index b6c5dbb..465b85f 100644
--- a/ease-core/ease-video-element.vala
+++ b/ease-core/ease-video-element.vala
@@ -21,6 +21,10 @@
  */
 public class Ease.VideoElement : MediaElement
 {
+	/**
+	 * If the video should begin playing automatically, or display a play
+	 * button.
+	 */
 	public bool play_auto { get; set; default = false; }
 	
 	public VideoElement()



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]