[cheese/three-point-oh] Countdown animation sorta works. Burst mode broken



commit 4565bf279aa8f7416713fe5b4ed3587e0a0ea190
Author: Yuvaraj Pandian T <yuvipanda gmail com>
Date:   Sun Jun 13 18:21:28 2010 +0530

    Countdown animation sorta works. Burst mode broken

 data/cheese-viewport.json     |   17 ++++++++++++-
 valasrc/Makefile.am           |    3 +-
 valasrc/cheese-countdown.vala |   50 +++++++++++++++++++++++++++++++++++++++++
 valasrc/cheese-window.vala    |   13 ++++++++--
 4 files changed, 77 insertions(+), 6 deletions(-)
---
diff --git a/data/cheese-viewport.json b/data/cheese-viewport.json
index 02809b5..0d5cb3e 100644
--- a/data/cheese-viewport.json
+++ b/data/cheese-viewport.json
@@ -4,11 +4,24 @@
     "type": "ClutterTexture",
     "child::x-align": "CLUTTER_BIN_ALIGNMENT_FILL",
     "child::y-align": "CLUTTER_BIN_ALIGNMENT_FILL"
-  },
+},
+{
+    "id": "countdown_layer",
+    "type": "ClutterText",
+    "child::x-align": "CLUTTER_BIN_ALIGNMENT_CENTER",
+    "child::y-align": "CLUTTER_BIN_ALIGNMENT_CENTER",
+    "text": "1",
+    "font-name": "Serif 300px",
+    "opacity": 0
+},
 {
     "id": "viewport_layout",
     "type": "ClutterBox",
-    "children": ['video_preview'] 
+    "children":
+    [
+	'video_preview',
+	'countdown_layer'
+    ] 
 },
 {
     "id": "viewport_layout_manager",
diff --git a/valasrc/Makefile.am b/valasrc/Makefile.am
index d355087..cccf2ea 100644
--- a/valasrc/Makefile.am
+++ b/valasrc/Makefile.am
@@ -28,13 +28,14 @@ AM_CPPFLAGS = \
 	-I top_srcdir@/libcheese 
 
 AM_CFLAGS = \
-	-export-dynamic
+	-export-dynamic 
 
 bin_PROGRAMS = cheese
 
 cheese_SOURCES = \
 	cheese-main.vala \
 	cheese-window.vala \
+	cheese-countdown.vala \
 	thumbview/cheese-gconf.c \
 	thumbview/cheese-thumb-view.c \
 	thumbview/eog-thumb-nav.c \
diff --git a/valasrc/cheese-countdown.vala b/valasrc/cheese-countdown.vala
new file mode 100644
index 0000000..56796fe
--- /dev/null
+++ b/valasrc/cheese-countdown.vala
@@ -0,0 +1,50 @@
+using GLib;
+using Clutter;
+
+const int COUNTDOWN_TILL = 3;
+
+internal class Cheese.Countdown : GLib.Object{
+
+	public delegate void CountdownCallback();
+	
+	private Clutter.Text countdown_actor;
+	private CountdownCallback completed_callback;
+
+	private int current_value = 0;
+	
+	public Countdown(Clutter.Text countdown_actor) {
+		this.countdown_actor = countdown_actor;
+	}
+
+	private void fade_out() {
+		Clutter.Animation anim = this.countdown_actor.animate(Clutter.AnimationMode.LINEAR, 500,
+															  "opacity", 0);
+//		anim.completed.connect_after( () => {fade_in();});
+		GLib.Timeout.add(500,
+						 () => { fade_in();
+								 return false;
+						 });						 
+	}
+	
+	private void fade_in() {
+		this.current_value++;
+		this.countdown_actor.text = "%d".printf(this.current_value);
+		if (this.current_value > 3) {
+			this.completed_callback();
+			return;
+		}
+			
+		Clutter.Animation anim = this.countdown_actor.animate(Clutter.AnimationMode.LINEAR, 500,
+															  "opacity", 255);
+//		anim.completed.connect_after(() => {fade_out();});
+		GLib.Timeout.add(500,
+						 () => { fade_out();
+								 return false;
+						 });
+	}
+	
+	public void start_countdown (CountdownCallback completed_callback) {
+		this.completed_callback = completed_callback;
+		fade_in();
+	}
+}
\ No newline at end of file
diff --git a/valasrc/cheese-window.vala b/valasrc/cheese-window.vala
index f9d0226..f0fa7bb 100644
--- a/valasrc/cheese-window.vala
+++ b/valasrc/cheese-window.vala
@@ -37,6 +37,7 @@ public class Cheese.MainWindow : Gtk.Window {
 	private Clutter.Box viewport_layout;
 	private Clutter.Texture video_preview;
 	private Clutter.BinLayout viewport_layout_manager;
+	private Clutter.Text countdown_layer;
 	
 	private Gtk.Action take_photo_action;
 	private Gtk.Action take_video_action;
@@ -272,11 +273,16 @@ public class Cheese.MainWindow : Gtk.Window {
 		this.viewport_layout.set_size(viewport.width, viewport.height);
 	}
 
+
+	private void finish_countdown_callback() {
+		string file_name = fileutil.get_new_media_filename(this.current_mode);
+		this.flash.fire();
+		this.camera.take_photo(file_name);		
+	}
 	
 	internal void take_photo() {
-		string file_name = fileutil.get_new_media_filename(this.current_mode);
-		flash.fire();
-		camera.take_photo(file_name);
+		Countdown cd = new Countdown(this.countdown_layer);
+		cd.start_countdown(finish_countdown_callback);
 	}
 
 	[CCode (instance_pos = -1)]
@@ -379,6 +385,7 @@ public class Cheese.MainWindow : Gtk.Window {
 		video_preview = (Clutter.Texture) clutter_builder.get_object ("video_preview");
 		viewport_layout = (Clutter.Box) clutter_builder.get_object ("viewport_layout");
 		viewport_layout_manager = (Clutter.BinLayout) clutter_builder.get_object ("viewport_layout_manager");
+		countdown_layer = (Clutter.Text) clutter_builder.get_object ("countdown_layer");
 
 		viewport_layout.set_layout_manager(viewport_layout_manager);
 



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