[ease: 3/9] Builds again.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease: 3/9] Builds again.
- Date: Sun, 30 May 2010 23:28:17 +0000 (UTC)
commit a2bfbc9f2c631339ea90304aa760677c9e72719e
Author: Nate Stedman <natesm gmail com>
Date: Sun May 30 05:05:42 2010 -0400
Builds again.
src/JSONParser.vala | 12 ++-
src/SlideActor.vala | 8 +-
src/TransitionPane.vala | 46 +++++++-----
src/Transitions.vala | 179 ++++++++++++++++++++++++++++++++--------------
4 files changed, 164 insertions(+), 81 deletions(-)
---
diff --git a/src/JSONParser.vala b/src/JSONParser.vala
index f4ff5c9..de08aa1 100644
--- a/src/JSONParser.vala
+++ b/src/JSONParser.vala
@@ -59,8 +59,12 @@ public static class Ease.JSONParser
var slide = new Slide();
// read the slide's transition properties
- slide.transition = obj.get_string_member("transition");
- slide.variant = obj.get_string_member("variant");
+ slide.transition =
+ (TransitionType)obj.get_string_member("transition").to_int();
+
+ slide.variant =
+ (TransitionVariant)obj.get_string_member("variant").to_int();
+
slide.transition_time =
obj.get_string_member("transition_time").to_double();
@@ -148,8 +152,8 @@ public static class Ease.JSONParser
var obj = new Json.Object();
// write the slide's transition properties
- obj.set_string_member("transition", slide.transition);
- obj.set_string_member("variant", slide.variant);
+ obj.set_string_member("transition", slide.transition.to_string());
+ obj.set_string_member("variant", slide.variant.to_string());
obj.set_string_member("transition_time",
slide.transition_time.to_string());
diff --git a/src/SlideActor.vala b/src/SlideActor.vala
index e953b71..9ada8cd 100644
--- a/src/SlideActor.vala
+++ b/src/SlideActor.vala
@@ -204,10 +204,6 @@ public class Ease.SlideActor : Clutter.Group
switch (slide.transition)
{
- case TransitionType.FADE:
- fade_transition(new_slide, stack_container, length);
- break;
-
case TransitionType.SLIDE:
slide_transition(new_slide, stack_container, length);
break;
@@ -271,6 +267,10 @@ public class Ease.SlideActor : Clutter.Group
case TransitionType.PANEL:
panel_transition(new_slide, stack_container, length);
break;
+
+ default: // FADE, or something undefined
+ fade_transition(new_slide, stack_container, length);
+ break;
}
animation_time.start();
diff --git a/src/TransitionPane.vala b/src/TransitionPane.vala
index d588b0a..6435798 100644
--- a/src/TransitionPane.vala
+++ b/src/TransitionPane.vala
@@ -124,26 +124,40 @@ public class Ease.TransitionPane : InspectorPane
// signal handlers
- effect.changed.connect(() => {
- var variants = Transitions.get_variants(effect.active);
+ effect.changed.connect(() => {
+ // create a new ComboBox
variant_align.remove(variant);
variant = new Gtk.ComboBox.text();
variant_align.add(variant);
variant.show();
- variant.changed.connect(() => {
- slide.variant = Transitions.get_variants(effect.active)[variant.active];
- });
- var variant_count = Transitions.get_variant_count(effect.active);
- if (variant_count > 0)
+
+ // get the variants for the new transition
+ var variants = Transitions.variants_for_index(effect.active);
+
+ // add the transition's variants
+ for (var i = 0; i < variants.length; i++)
+ {
+ variant.append_text(Transitions.get_variant_name(variants[i]));
+ }
+
+ // if the slide has variants, make the appropriate one active
+ for (int i = 0; i < variants.length; i++)
{
- for (var i = 0; i < variant_count; i++)
+ if (variants[i] == slide.variant)
{
- variant.append_text(variants[i]);
+ variant.set_active(i);
+ break;
}
- variant.set_active(0);
- slide.variant = Transitions.get_variants(effect.active)[variant.active];
}
- slide.transition = Transitions.get_name(effect.active);
+
+ // set the transition
+ slide.transition = Transitions.transition_for_index(effect.active);
+
+ // allow the user to change the variant
+ variant.changed.connect(() => {
+ var v = Transitions.variants_for_transition(slide.transition);
+ slide.variant = v[variant.active];
+ });
});
start_transition.changed.connect(() => {
@@ -164,12 +178,8 @@ public class Ease.TransitionPane : InspectorPane
transition_time.set_value(slide.transition_time);
// set effect and variant combo boxes
- effect.set_active(Transitions.get_transition_id(slide.transition));
- if (slide.variant != "" && slide.variant != null)
- {
- variant.set_active(Transitions.get_variant_id(slide.transition,
- slide.variant));
- }
+ var index = Transitions.get_index(slide.transition);
+ effect.set_active(index);
}
}
diff --git a/src/Transitions.vala b/src/Transitions.vala
index 120a6d8..1577c17 100644
--- a/src/Transitions.vala
+++ b/src/Transitions.vala
@@ -23,10 +23,10 @@
*/
public static class Ease.Transitions : GLib.Object
{
- private const TransitionVariant[] directions = { TransitionVariant.UP,
- TransitionVariant.DOWN,
- TransitionVariant.LEFT,
- TransitionVariant.RIGHT };
+ private static TransitionVariant[] directions = { TransitionVariant.UP,
+ TransitionVariant.DOWN,
+ TransitionVariant.LEFT,
+ TransitionVariant.RIGHT };
private static Transition[] transitions = {
Transition() { type = TransitionType.NONE, variants = {} },
@@ -43,7 +43,8 @@ public static class Ease.Transitions : GLib.Object
TransitionVariant.BOTTOM_TO_TOP,
TransitionVariant.LEFT_TO_RIGHT,
TransitionVariant.RIGHT_TO_LEFT } },
- Transition() { type = TransitionType.REVOLVING_DOOR, variants = directions },
+ Transition() { type = TransitionType.REVOLVING_DOOR,
+ variants = directions },
Transition() { type = TransitionType.REVEAL, variants = directions },
Transition() { type = TransitionType.FALL, variants = {} },
Transition() { type = TransitionType.SLATS, variants = {} },
@@ -59,7 +60,8 @@ public static class Ease.Transitions : GLib.Object
variants = { TransitionVariant.LEFT,
TransitionVariant.RIGHT } },
Transition() { type = TransitionType.SWING_CONTENTS, variants = {} },
- Transition() { type = TransitionType.SLIDE_CONTENTS, variants = directions },
+ Transition() { type = TransitionType.SLIDE_CONTENTS,
+ variants = directions },
Transition() { type = TransitionType.SPRING_CONTENTS,
variants = { TransitionVariant.UP,
TransitionVariant.DOWN } },
@@ -73,7 +75,7 @@ public static class Ease.Transitions : GLib.Object
/**
* Returns the string name of a transition.
*
- * @param type The transition type.
+ * @param type The { link TransitionType} to find a name for..
*/
public static string get_name(TransitionType type)
{
@@ -81,118 +83,179 @@ public static class Ease.Transitions : GLib.Object
{
case TransitionType.NONE:
return _("None");
- break;
case TransitionType.FADE:
return _("Fade");
- break;
case TransitionType.SLIDE:
return _("Slide");
- break;
case TransitionType.DROP:
return _("Drop");
- break;
case TransitionType.PIVOT:
return _("Pivot");
- break;
case TransitionType.FLIP:
return _("Flip");
- break;
case TransitionType.REVOLVING_DOOR:
return _("Revolving Door");
- break;
case TransitionType.REVEAL:
return _("Reveal");
- break;
case TransitionType.FALL:
return _("Fall");
- break;
case TransitionType.SLATS:
return _("Slats");
- break;
case TransitionType.OPEN_DOOR:
return _("Open Door");
- break;
case TransitionType.ZOOM:
return _("Zoom");
- break;
case TransitionType.PANEL:
return _("Panel");
- break;
case TransitionType.SPIN_CONTENTS:
return _("Spin Contents");
- break;
case TransitionType.SPRING_CONTENTS:
return _("Spring Contents");
- break;
case TransitionType.SWING_CONTENTS:
return _("Swing Contents");
- break;
case TransitionType.SLIDE_CONTENTS:
return _("Slide Contents");
- break;
default: // ZOOM_CONTENTS
return _("Zoom Contents");
- break;
}
}
- public string[] names()
+ /**
+ * Returns the string name of a variant.
+ *
+ * @param variant The { link TransitionVariant} to find a name for.
+ */
+ public static string get_variant_name(TransitionVariant variant)
{
- var names = new string[transitions.length];
-
- for (int i = 0; i < transitions.length; i++)
+ switch (variant)
{
- names[i] = get_name(transitions[i].type);
+ case TransitionVariant.UP:
+ return _("Up");
+ case TransitionVariant.DOWN:
+ return _("Down");
+ case TransitionVariant.LEFT:
+ return _("Left");
+ case TransitionVariant.RIGHT:
+ return _("Right");
+ case TransitionVariant.BOTTOM:
+ return _("Bottom");
+ case TransitionVariant.TOP:
+ return _("Top");
+ case TransitionVariant.CENTER:
+ return _("Center");
+ case TransitionVariant.TOP_LEFT:
+ return _("Top Left");
+ case TransitionVariant.TOP_RIGHT:
+ return _("Top Right");
+ case TransitionVariant.BOTTOM_LEFT:
+ return _("Bottom Left");
+ case TransitionVariant.BOTTOM_RIGHT:
+ return _("Bottom Right");
+ case TransitionVariant.TOP_TO_BOTTOM:
+ return _("Top to Bottom");
+ case TransitionVariant.BOTTOM_TO_TOP:
+ return _("Bottom to Top");
+ case TransitionVariant.LEFT_TO_RIGHT:
+ return _("Left to Right");
+ case TransitionVariant.RIGHT_TO_LEFT:
+ return _("Right to Left");
+ case TransitionVariant.IN:
+ return _("In");
+ default: // OUT
+ return _("Out");
}
-
- return names;
}
/**
- * Given a name, returns the ID of a transition.
- *
- * @param name The name of the transition.
+ * Returns a { link Transition} struct for the given { link TransitionType}.
+ *
+ * @param type The { link TransitionType} to find the transition for.
*/
- /*public static int get_transition_id(string name)
+ public static Transition? get_transition(TransitionType type)
{
- for (var i = 0; i < transitions.length; i++)
+ for (int i = 0; i < transitions.length; i++)
{
- if (get_name(transitions[i].type) == name)
+ if (transitions[i].type == type)
{
- return i;
+ return transitions[i];
}
}
- return 0;
- }*/
+
+ return null;
+ }
/**
- * Returns the ID of a transition, given the names of both.
+ * Returns the index of the given { link TransitionType}.
*
- * @param transition The name of the transition.
- * @param variant The name of the variant.
+ * @param type The { link TransitionType} to find the index of.
*/
- /*public static int get_variant_id(string transition, string variant)
+ public static int? get_index(TransitionType type)
{
- var id = get_transition_id(transition);
- for (var i = 0; i < Transitions.get(id).count; i++)
+ for (int i = 0; i < transitions.length; i++)
{
- if (Transitions.get(id).variants[i] == variant)
+ if (transitions[i].type == type)
{
return i;
}
}
- return 0;
- }*/
+
+ return null;
+ }
/**
- * Returns an array of variants, given a transition ID.
+ * Returns the { link TransitionType} for a given index.
*
- * @param i A transition index.
+ * @param index The index to find the { link TransitionType} of.
*/
- /*public static string[] get_variants(int i)
+ public static TransitionType transition_for_index(int index)
{
- return Transitions.get(i).variants;
- }*/
+ return transitions[index].type;
+ }
+
+ /**
+ * Returns the variants for a given index.
+ *
+ * @param index The index to find the variants of.
+ */
+ public static TransitionVariant[] variants_for_index(int index)
+ {
+ return transitions[index].variants;
+ }
+
+ /**
+ * Returns the variants of a given { link TransitionType}.
+ *
+ * @param t The { link TransitionType} to find the variants of.
+ */
+ public static TransitionVariant[] variants_for_transition(TransitionType t)
+ {
+ return variants_for_index(get_index(t));
+ }
+
+ /**
+ * Returns the names of all transitions.
+ */
+ public static string[] names()
+ {
+ var names = new string[transitions.length];
+
+ for (int i = 0; i < transitions.length; i++)
+ {
+ names[i] = get_name(transitions[i].type);
+ }
+
+ return names;
+ }
+
+ /**
+ * Returns a specific transition name
+ *
+ * @param index The index of the transition to find the name of.
+ */
+ public static string name(int index)
+ {
+ return get_name(transitions[index].type);
+ }
}
public struct Ease.Transition
@@ -201,6 +264,9 @@ public struct Ease.Transition
public TransitionVariant[] variants;
}
+/**
+ * All transitions available in Ease
+ */
public enum Ease.TransitionType
{
NONE,
@@ -223,6 +289,9 @@ public enum Ease.TransitionType
ZOOM_CONTENTS
}
+/**
+ * All transition variants available in Ease. Each transition uses a subset.
+ */
public enum Ease.TransitionVariant
{
UP,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]