[ease] Implemented automatic advance of slides.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] Implemented automatic advance of slides.
- Date: Tue, 1 Jun 2010 19:10:30 +0000 (UTC)
commit e2bf79948ac432d68e4153fa38618c4b8b3b34ae
Author: Nate Stedman <natesm gmail com>
Date: Tue Jun 1 15:08:46 2010 -0400
Implemented automatic advance of slides.
This includes functionality in the player, the transition inspector pane, and
additions to the file format.
Examples/Example.ease/Document.json | 14 ++-
Examples/Transitions.ease/Document.json | 146 +++++++++++++++++++------------
src/Document.vala | 5 +
src/JSONParser.vala | 10 ++
src/Player.vala | 44 +++++++++-
src/Slide.vala | 10 ++
src/TransitionPane.vala | 43 +++++++---
7 files changed, 198 insertions(+), 74 deletions(-)
---
diff --git a/Examples/Example.ease/Document.json b/Examples/Example.ease/Document.json
index 7f81aaa..abf877b 100644
--- a/Examples/Example.ease/Document.json
+++ b/Examples/Example.ease/Document.json
@@ -24,11 +24,18 @@ See Ease Run.",
}
],
"background_image" : "Media/Themes/Pink/Background.svg",
+ "automatically_advance" : "true",
"variant" : "2",
+ "advance_delay" : "0.75",
"transition" : "3",
"transition_time" : "1"
},
{
+ "transition" : "10",
+ "green" : "0",
+ "variant" : "0",
+ "automatically_advance" : "false",
+ "advance_delay" : "0",
"elements" : [
{
"element_type" : "image",
@@ -44,10 +51,7 @@ See Ease Run.",
}
],
"blue" : "0",
- "green" : "0",
- "variant" : "0",
"red" : "0",
- "transition" : "10",
"transition_time" : "1"
},
{
@@ -102,10 +106,12 @@ See Ease Run.",
}
],
"background_image" : "Media/Themes/Pink/Background.svg",
+ "automatically_advance" : "false",
"variant" : "7",
+ "advance_delay" : "0",
"transition" : "4",
"transition_time" : "1"
}
],
"width" : "640"
-}
\ No newline at end of file
+}
diff --git a/Examples/Transitions.ease/Document.json b/Examples/Transitions.ease/Document.json
index 3c4b335..a202181 100644
--- a/Examples/Transitions.ease/Document.json
+++ b/Examples/Transitions.ease/Document.json
@@ -2,6 +2,11 @@
"height" : "768",
"slides" : [
{
+ "transition" : "1",
+ "automatically_advance" : "true",
+ "green" : "34",
+ "variant" : "0",
+ "advance_delay" : "0.5",
"elements" : [
{
"font_variant" : "Normal",
@@ -41,13 +46,15 @@
}
],
"blue" : "34",
- "green" : "34",
- "variant" : "0",
"red" : "34",
- "transition" : "1",
"transition_time" : "1"
},
{
+ "transition" : "2",
+ "automatically_advance" : "true",
+ "green" : "255",
+ "variant" : "2",
+ "advance_delay" : "0.5",
"elements" : [
{
"font_variant" : "Normal",
@@ -87,13 +94,15 @@
}
],
"blue" : "255",
- "green" : "255",
- "variant" : "2",
"red" : "255",
- "transition" : "2",
"transition_time" : "1"
},
{
+ "transition" : "3",
+ "automatically_advance" : "true",
+ "green" : "34",
+ "variant" : "0",
+ "advance_delay" : "0.5",
"elements" : [
{
"font_variant" : "Normal",
@@ -133,13 +142,15 @@
}
],
"blue" : "34",
- "green" : "34",
- "variant" : "0",
"red" : "34",
- "transition" : "3",
"transition_time" : "1"
},
{
+ "transition" : "4",
+ "automatically_advance" : "true",
+ "green" : "255",
+ "variant" : "7",
+ "advance_delay" : "0.5",
"elements" : [
{
"font_variant" : "Normal",
@@ -179,13 +190,15 @@
}
],
"blue" : "255",
- "green" : "255",
- "variant" : "7",
"red" : "255",
- "transition" : "4",
"transition_time" : "1"
},
{
+ "transition" : "5",
+ "automatically_advance" : "true",
+ "green" : "34",
+ "variant" : "13",
+ "advance_delay" : "0.5",
"elements" : [
{
"font_variant" : "Normal",
@@ -225,13 +238,15 @@
}
],
"blue" : "34",
- "green" : "34",
- "variant" : "13",
"red" : "34",
- "transition" : "5",
"transition_time" : "1"
},
{
+ "transition" : "6",
+ "automatically_advance" : "true",
+ "green" : "255",
+ "variant" : "2",
+ "advance_delay" : "0.5",
"elements" : [
{
"font_variant" : "Normal",
@@ -271,13 +286,15 @@
}
],
"blue" : "255",
- "green" : "255",
- "variant" : "2",
"red" : "255",
- "transition" : "6",
"transition_time" : "1"
},
{
+ "transition" : "7",
+ "automatically_advance" : "true",
+ "green" : "34",
+ "variant" : "0",
+ "advance_delay" : "0.5",
"elements" : [
{
"font_variant" : "Normal",
@@ -317,13 +334,15 @@
}
],
"blue" : "34",
- "green" : "34",
- "variant" : "0",
"red" : "34",
- "transition" : "7",
"transition_time" : "1"
},
{
+ "transition" : "8",
+ "automatically_advance" : "true",
+ "green" : "255",
+ "variant" : "0",
+ "advance_delay" : "0.5",
"elements" : [
{
"font_variant" : "Normal",
@@ -363,13 +382,15 @@
}
],
"blue" : "255",
- "green" : "255",
- "variant" : "0",
"red" : "255",
- "transition" : "8",
"transition_time" : "1"
},
{
+ "transition" : "10",
+ "automatically_advance" : "true",
+ "green" : "34",
+ "variant" : "0",
+ "advance_delay" : "0.5",
"elements" : [
{
"font_variant" : "Normal",
@@ -409,13 +430,15 @@
}
],
"blue" : "34",
- "green" : "34",
- "variant" : "0",
"red" : "34",
- "transition" : "10",
"transition_time" : "1"
},
{
+ "transition" : "11",
+ "automatically_advance" : "true",
+ "green" : "255",
+ "variant" : "6",
+ "advance_delay" : "0.5",
"elements" : [
{
"font_variant" : "Normal",
@@ -455,13 +478,15 @@
}
],
"blue" : "255",
- "green" : "255",
- "variant" : "6",
"red" : "255",
- "transition" : "11",
"transition_time" : "1"
},
{
+ "transition" : "12",
+ "automatically_advance" : "true",
+ "green" : "34",
+ "variant" : "0",
+ "advance_delay" : "0.5",
"elements" : [
{
"font_variant" : "Normal",
@@ -501,13 +526,15 @@
}
],
"blue" : "34",
- "green" : "34",
- "variant" : "0",
"red" : "34",
- "transition" : "12",
"transition_time" : "1"
},
{
+ "transition" : "13",
+ "automatically_advance" : "true",
+ "green" : "255",
+ "variant" : "2",
+ "advance_delay" : "0.5",
"elements" : [
{
"font_variant" : "Normal",
@@ -547,13 +574,15 @@
}
],
"blue" : "255",
- "green" : "255",
- "variant" : "2",
"red" : "255",
- "transition" : "13",
"transition_time" : "1"
},
{
+ "transition" : "15",
+ "automatically_advance" : "true",
+ "green" : "34",
+ "variant" : "0",
+ "advance_delay" : "0.5",
"elements" : [
{
"font_variant" : "Normal",
@@ -593,13 +622,15 @@
}
],
"blue" : "34",
- "green" : "34",
- "variant" : "0",
"red" : "34",
- "transition" : "15",
"transition_time" : "1"
},
{
+ "transition" : "16",
+ "automatically_advance" : "true",
+ "green" : "255",
+ "variant" : "0",
+ "advance_delay" : "0.5",
"elements" : [
{
"font_variant" : "Normal",
@@ -639,13 +670,15 @@
}
],
"blue" : "255",
- "green" : "255",
- "variant" : "0",
"red" : "255",
- "transition" : "16",
"transition_time" : "1"
},
{
+ "transition" : "14",
+ "automatically_advance" : "true",
+ "green" : "34",
+ "variant" : "0",
+ "advance_delay" : "0.5",
"elements" : [
{
"font_variant" : "Normal",
@@ -685,13 +718,15 @@
}
],
"blue" : "34",
- "green" : "34",
- "variant" : "0",
"red" : "34",
- "transition" : "14",
"transition_time" : "1"
},
{
+ "transition" : "17",
+ "automatically_advance" : "true",
+ "green" : "255",
+ "variant" : "15",
+ "advance_delay" : "0.5",
"elements" : [
{
"font_variant" : "Normal",
@@ -731,13 +766,15 @@
}
],
"blue" : "255",
- "green" : "255",
- "variant" : "15",
"red" : "255",
- "transition" : "17",
"transition_time" : "1"
},
{
+ "transition" : "0",
+ "automatically_advance" : "true",
+ "green" : "34",
+ "variant" : "0",
+ "advance_delay" : "0.5",
"elements" : [
{
"font_variant" : "Normal",
@@ -777,13 +814,15 @@
}
],
"blue" : "34",
- "green" : "34",
- "variant" : "0",
"red" : "34",
- "transition" : "0",
"transition_time" : "1"
},
{
+ "transition" : "0",
+ "automatically_advance" : "true",
+ "green" : "255",
+ "variant" : "0",
+ "advance_delay" : "0.5",
"elements" : [
{
"font_variant" : "Normal",
@@ -823,12 +862,9 @@
}
],
"blue" : "255",
- "green" : "255",
- "variant" : "0",
"red" : "255",
- "transition" : "0",
"transition_time" : "1"
}
],
"width" : "1024"
-}
\ No newline at end of file
+}
diff --git a/src/Document.vala b/src/Document.vala
index d4e42d6..87eaec9 100644
--- a/src/Document.vala
+++ b/src/Document.vala
@@ -37,6 +37,11 @@ public class Ease.Document : GLib.Object
public int height { get; set; }
/**
+ * The aspect ratio of the Document.
+ */
+ public float aspect { get { return (float)width / (float)height; } }
+
+ /**
* The file path of the Document.
*/
public string path { get; set; }
diff --git a/src/JSONParser.vala b/src/JSONParser.vala
index a5ec5e4..a197da1 100644
--- a/src/JSONParser.vala
+++ b/src/JSONParser.vala
@@ -67,6 +67,12 @@ public static class Ease.JSONParser
slide.transition_time =
obj.get_string_member("transition_time").to_double();
+
+ slide.automatically_advance =
+ obj.get_string_member("automatically_advance").to_bool();
+
+ slide.advance_delay =
+ obj.get_string_member("advance_delay").to_double();
// read the slide's background properties
if (obj.has_member("background_image"))
@@ -158,6 +164,10 @@ public static class Ease.JSONParser
((int)slide.variant).to_string());
obj.set_string_member("transition_time",
slide.transition_time.to_string());
+ obj.set_string_member("automatically_advance",
+ slide.automatically_advance.to_string());
+ obj.set_string_member("advance_delay",
+ slide.advance_delay.to_string());
// write the slide's background properties
if (slide.background_image != null)
diff --git a/src/Player.vala b/src/Player.vala
index 5f671e7..a854483 100644
--- a/src/Player.vala
+++ b/src/Player.vala
@@ -34,8 +34,12 @@ public class Ease.Player : GLib.Object
private SlideActor old_slide;
private Clutter.Group stack_container;
+ // automatic advance alarm
+ private Clutter.Timeline advance_alarm;
+
// constants
- public const bool PRESENTATION_FULLSCREEN = false;
+ private const bool PRESENTATION_FULLSCREEN = false;
+ private const uint FADE_IN_TIME = 1000;
public Player(Document doc)
{
@@ -98,6 +102,13 @@ public class Ease.Player : GLib.Object
{
return;
}
+
+ // stop the advance alarm
+ if (advance_alarm != null)
+ {
+ advance_alarm.stop();
+ advance_alarm = null;
+ }
slide_index++;
if (slide_index == document.slides.size) // slideshow complete
@@ -115,8 +126,16 @@ public class Ease.Player : GLib.Object
current_slide.stack(stack_container);
current_slide.opacity = 0;
current_slide.animate(Clutter.AnimationMode.EASE_IN_SINE,
- 1000, "opacity", 255);
+ FADE_IN_TIME, "opacity", 255);
stage.add_actor(current_slide);
+
+ advance_alarm = new Clutter.Timeline(FADE_IN_TIME);
+ advance_alarm.completed.connect(animation_complete);
+ advance_alarm.start();
+
+ can_animate = false;
+
+
}
else
{
@@ -167,9 +186,28 @@ public class Ease.Player : GLib.Object
private void animation_complete()
{
- stage.remove_actor(old_slide);
+ if (old_slide != null)
+ {
+ if (old_slide.get_parent() == stage)
+ {
+ stage.remove_actor(old_slide);
+ }
+ }
+
can_animate = true;
current_slide.stack(stack_container);
+
+ // prepare to automatically advance if necessary
+ if (current_slide.slide.automatically_advance)
+ {
+ uint time = (uint)(1000 * current_slide.slide.advance_delay);
+
+ advance_alarm = new Clutter.Timeline(time);
+ advance_alarm.completed.connect(() => {
+ advance();
+ });
+ advance_alarm.start();
+ }
}
private bool key_press(Gtk.Widget sender, Gdk.EventKey event)
diff --git a/src/Slide.vala b/src/Slide.vala
index 8ca68a0..5a3350a 100644
--- a/src/Slide.vala
+++ b/src/Slide.vala
@@ -45,6 +45,16 @@ public class Ease.Slide
public double transition_time { get; set; }
/**
+ * If the slide advances automatically or on key press
+ */
+ public bool automatically_advance { get; set; }
+
+ /**
+ * If the slide advances automatically, the amount of delay
+ */
+ public double advance_delay { get; set; }
+
+ /**
* The background color, if there is no background image
*/
public Clutter.Color background_color;
diff --git a/src/TransitionPane.vala b/src/TransitionPane.vala
index ed79d61..ad2e9b4 100644
--- a/src/TransitionPane.vala
+++ b/src/TransitionPane.vala
@@ -27,7 +27,14 @@ public class Ease.TransitionPane : InspectorPane
private Gtk.Alignment variant_align;
private Gtk.ComboBox start_transition;
private Gtk.SpinButton delay;
+
+ // transition preview
+ private Gtk.AspectFrame aspect;
private GtkClutter.Embed preview;
+ private SlideActor current_slide;
+ private SlideActor new_slide;
+ private const int PREVIEW_HEIGHT = 150;
+
public TransitionPane()
{
@@ -38,17 +45,16 @@ public class Ease.TransitionPane : InspectorPane
// preview
preview = new GtkClutter.Embed();
- preview.set_size_request(0, 100);
+ preview.set_size_request(0, PREVIEW_HEIGHT);
((Clutter.Stage)(preview.get_stage())).color = {0, 0, 0, 255};
- var frame = new Gtk.Frame(null);
- frame.add(preview);
- var hbox = new Gtk.HBox(false, 0);
- hbox.pack_start(frame, true, true, 5);
- pack_start(hbox, false, false, 5);
+ aspect = new Gtk.AspectFrame("", 0.5f, 0.5f, 0.5f, false);
+ aspect.add(preview);
+ aspect.shadow_type = Gtk.ShadowType.IN;
+ pack_start(aspect, false, false, 5);
// transition selection
var vbox = new Gtk.VBox(false, 0);
- hbox = new Gtk.HBox(false, 0);
+ var hbox = new Gtk.HBox(false, 0);
var align = new Gtk.Alignment(0, 0, 0, 0);
align.add(new Gtk.Label(_("Effect")));
vbox.pack_start(align, false, false, 0);
@@ -76,10 +82,6 @@ public class Ease.TransitionPane : InspectorPane
hbox.pack_start(vbox, false, false, 5);
pack_start(hbox, false, false, 5);
- transition_time.value_changed.connect(() => {
- slide.transition_time = transition_time.get_value();
- });
-
// transition variant
hbox = new Gtk.HBox(false, 0);
vbox = new Gtk.VBox(false, 0);
@@ -121,7 +123,6 @@ public class Ease.TransitionPane : InspectorPane
hbox.pack_start(vbox, false, false, 5);
pack_start(hbox, false, false, 5);
-
// signal handlers
effect.changed.connect(() => {
// create a new ComboBox
@@ -163,22 +164,40 @@ public class Ease.TransitionPane : InspectorPane
if (start_transition.active == 0)
{
delay.sensitive = false;
+ slide.automatically_advance = false;
}
else
{
delay.sensitive = true;
+ slide.automatically_advance = true;
}
});
+
+ transition_time.value_changed.connect(() => {
+ slide.transition_time = transition_time.get_value();
+ });
+
+ delay.value_changed.connect(() => {
+ slide.advance_delay = delay.get_value();
+ });
}
protected override void slide_updated()
{
+ // set preview aspect ratio
+ aspect.ratio = (float)slide.parent.width / (float)slide.parent.height;
+
// set transition time box
transition_time.set_value(slide.transition_time);
// set effect and variant combo boxes
var index = Transitions.get_index(slide.transition);
effect.set_active(index);
+
+ // set the automatic advance boxes
+ start_transition.set_active(slide.automatically_advance ? 1 : 0);
+ delay.set_value(slide.advance_delay);
+ delay.sensitive = slide.automatically_advance;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]