[ease] Switched to Namespace.Class style declarations, saving a level of indentation.
- From: Nate Stedman <natesm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [ease] Switched to Namespace.Class style declarations, saving a level of indentation.
- Date: Wed, 19 May 2010 04:50:09 +0000 (UTC)
commit 3ff536cbb980e22fb14e8da495341155f4e272bc
Author: Nate Stedman <natesm gmail com>
Date: Wed May 19 00:46:34 2010 -0400
Switched to Namespace.Class style declarations, saving a level of indentation.
src/libease/Actor.vala | 98 ++--
src/libease/Document.vala | 451 ++++++++--------
src/libease/EditorEmbed.vala | 560 ++++++++++----------
src/libease/EditorWindow.vala | 644 ++++++++++++------------
src/libease/Element.vala | 654 ++++++++++++------------
src/libease/ElementMap.vala | 144 +++---
src/libease/ElementMapValue.vala | 14 +-
src/libease/HTMLExporter.vala | 226 ++++----
src/libease/Handle.vala | 154 +++---
src/libease/ImageActor.vala | 64 ++--
src/libease/Main.vala | 294 ++++++------
src/libease/MainToolbar.vala | 106 ++--
src/libease/OpenDialog.vala | 71 ++--
src/libease/Player.vala | 292 ++++++------
src/libease/ScrollableEmbed.vala | 217 ++++----
src/libease/Slide.vala | 181 ++++----
src/libease/SlideActor.vala | 1036 ++++++++++++++++++-------------------
src/libease/SlideButton.vala | 210 ++++----
src/libease/SlideButtonPanel.vala | 76 ++--
src/libease/SlidePane.vala | 86 ++--
src/libease/TextActor.vala | 73 ++--
src/libease/Theme.vala | 12 +-
src/libease/TransitionPane.vala | 203 ++++----
src/libease/Transitions.vala | 212 ++++----
src/libease/VideoActor.vala | 76 ++--
src/libease/WelcomeActor.vala | 138 +++---
src/libease/WelcomeWindow.vala | 490 +++++++++---------
27 files changed, 3362 insertions(+), 3420 deletions(-)
---
diff --git a/src/libease/Actor.vala b/src/libease/Actor.vala
index a278d65..59ed449 100644
--- a/src/libease/Actor.vala
+++ b/src/libease/Actor.vala
@@ -15,61 +15,59 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * The basic Ease actor, subclassed for different types of
+ * { link Element}.
+ *
+ * The Actor class should never be instantiated - instead,
+ * subclasses such as { link TextActor} and { link ImageActor}
+ * are placed on a { link SlideActor} to form Ease presentations.
+ */
+public class Ease.Actor : Clutter.Group
{
+ // the contents of the actor
+ protected Clutter.Actor contents;
+
+ // the element this actor represents
+ public Element element;
+
+ // where this actor is (editor, player, sidebar)
+ public ActorContext context;
+
+ // if the actor is a slide background
+ public bool is_background;
+
/**
- * The basic Ease actor, subclassed for different types of
- * { link Element}.
+ * Instantiate a new Actor
+ *
+ * Instantiates the Actor base class. In general, this should only be
+ * called by subclasses.
*
- * The Actor class should never be instantiated - instead,
- * subclasses such as { link TextActor} and { link ImageActor}
- * are placed on a { link SlideActor} to form Ease presentations.
+ * @param e The { link Element} this Actor represents.
+ * @param c The context of this Actor - sidebar, presentation, editor.
*/
- public class Actor : Clutter.Group
+ public Actor(Element e, ActorContext c)
{
- // the contents of the actor
- protected Clutter.Actor contents;
-
- // the element this actor represents
- public Element element;
-
- // where this actor is (editor, player, sidebar)
- public ActorContext context;
-
- // if the actor is a slide background
- public bool is_background;
-
- /**
- * Instantiate a new Actor
- *
- * Instantiates the Actor base class. In general, this should only be
- * called by subclasses.
- *
- * @param e The { link Element} this Actor represents.
- * @param c The context of this Actor - sidebar, presentation, editor.
- */
- public Actor(Element e, ActorContext c)
- {
- element = e;
- context = c;
- is_background = false;
- }
+ element = e;
+ context = c;
+ is_background = false;
+ }
+
+ /**
+ * Move this Actor and update its { link Element}
+ *
+ * Used in the editor and tied to Clutter MotionEvents.
+ *
+ * @param x_change The amount of X motion.
+ * @param y_change The amount of Y motion.
+ */
+ public void translate(float x_change, float y_change)
+ {
+ x += x_change;
+ y += y_change;
- /**
- * Move this Actor and update its { link Element}
- *
- * Used in the editor and tied to Clutter MotionEvents.
- *
- * @param x_change The amount of X motion.
- * @param y_change The amount of Y motion.
- */
- public void translate(float x_change, float y_change)
- {
- x += x_change;
- y += y_change;
-
- element.x = x;
- element.y = y;
- }
+ element.x = x;
+ element.y = y;
}
}
+
diff --git a/src/libease/Document.vala b/src/libease/Document.vala
index e82c4d1..5de2fef 100644
--- a/src/libease/Document.vala
+++ b/src/libease/Document.vala
@@ -17,273 +17,270 @@
using Xml;
-namespace Ease
+/**
+ * The internal representation of Ease documents. Contains { link Slide}s.
+ *
+ * The Ease Document class is generated from XML and writes back to XML
+ * when saved.
+ */
+public class Ease.Document : GLib.Object
{
+ public Gee.ArrayList<Slide> slides { get; set; }
+ public Theme theme { get; set; }
+ public int width { get; set; }
+ public int height { get; set; }
+ public string path { get; set; }
+
/**
- * The internal representation of Ease documents. Contains { link Slide}s.
- *
- * The Ease Document class is generated from XML and writes back to XML
- * when saved.
+ * Default constructor, used for new documents.
+ *
+ * Creates a new, empty document with no slides. Used for creating new
+ * documents (which can then add a default slide).
*/
- public class Document : GLib.Object
+ public Document()
{
- public Gee.ArrayList<Slide> slides { get; set; }
- public Theme theme { get; set; }
- public int width { get; set; }
- public int height { get; set; }
- public string path { get; set; }
+ slides = new Gee.ArrayList<Slide>();
+ }
- /**
- * Default constructor, used for new documents.
- *
- * Creates a new, empty document with no slides. Used for creating new
- * documents (which can then add a default slide).
- */
- public Document()
+ /**
+ * Create a document from a file that already exists.
+ *
+ * Used for loading previously saved files.
+ *
+ * @param filename The path to the filename.
+ */
+ public Document.from_file(string filename)
+ {
+ this();
+
+ path = filename;
+
+ var doc = Parser.parse_file(filename + "Document.xml");
+ if (doc == null)
{
- slides = new Gee.ArrayList<Slide>();
+ stdout.printf("No Document");
}
-
- /**
- * Create a document from a file that already exists.
- *
- * Used for loading previously saved files.
- *
- * @param filename The path to the filename.
- */
- public Document.from_file(string filename)
+
+ var root = doc->get_root_element();
+ if (root == null)
{
- this();
-
- path = filename;
-
- var doc = Parser.parse_file(filename + "Document.xml");
- if (doc == null)
- {
- stdout.printf("No Document");
- }
-
- var root = doc->get_root_element();
- if (root == null)
- {
- stdout.printf("No root node");
- }
- else
+ stdout.printf("No root node");
+ }
+ else
+ {
+ for (Xml.Attr* i = root -> properties; i != null; i = i->next)
{
- for (Xml.Attr* i = root -> properties; i != null; i = i->next)
+ switch (i->name)
{
- switch (i->name)
- {
- case "width":
- width = (i->children->content).to_int();
- break;
- case "height":
- height = (i->children->content).to_int();
- break;
- }
+ case "width":
+ width = (i->children->content).to_int();
+ break;
+ case "height":
+ height = (i->children->content).to_int();
+ break;
}
- parse_xml(root);
}
-
- delete doc;
+ parse_xml(root);
}
+
+ delete doc;
+ }
- /**
- * Writes the document to a file (currently, a folder).
- *
- * to_file() uses the Document's "path" property to determine where the
- * file should be written. Currently, if writing fails, a dialog box
- * is displayed with the exception.
- *
- */
- public void to_file()
+ /**
+ * Writes the document to a file (currently, a folder).
+ *
+ * to_file() uses the Document's "path" property to determine where the
+ * file should be written. Currently, if writing fails, a dialog box
+ * is displayed with the exception.
+ *
+ */
+ public void to_file()
+ {
+ string output = "<?xml version=\"1.0\" ?>\n" +
+ "<document width=\"" + @"$width" + "\" height=\"" + @"$height" + "\">\n" +
+ "\t<slides>\n";
+ foreach (var s in slides)
{
- string output = "<?xml version=\"1.0\" ?>\n" +
- "<document width=\"" + @"$width" + "\" height=\"" + @"$height" + "\">\n" +
- "\t<slides>\n";
- foreach (var s in slides)
- {
- output += s.to_xml();
- }
- output += "\t</slides>\n</document>\n";
+ output += s.to_xml();
+ }
+ output += "\t</slides>\n</document>\n";
- try
- {
- var file = File.new_for_path(path + "Document.xml");
- var stream = file.replace(null, true, FileCreateFlags.NONE, null);
- var data_stream = new DataOutputStream(stream);
- data_stream.put_string(output, null);
- }
- catch (GLib.Error e)
+ try
+ {
+ var file = File.new_for_path(path + "Document.xml");
+ var stream = file.replace(null, true, FileCreateFlags.NONE, null);
+ var data_stream = new DataOutputStream(stream);
+ data_stream.put_string(output, null);
+ }
+ catch (GLib.Error e)
+ {
+ var dialog = new Gtk.MessageDialog(null,
+ Gtk.DialogFlags.NO_SEPARATOR,
+ Gtk.MessageType.ERROR,
+ Gtk.ButtonsType.CLOSE,
+ "Error saving: %s", e. message);
+ dialog.title = "Error Saving";
+ dialog.border_width = 5;
+ dialog.run();
+ }
+ }
+
+ /**
+ * Begins the parsing of an XML document.
+ *
+ * This will be replaced with a JSON file format.
+ *
+ * @param node The initial XML node to begin with.
+ */
+ private void parse_xml(Xml.Node* node)
+ {
+ for (Xml.Node* iter = node->children; iter != null; iter = iter ->next)
+ {
+ switch (iter->name)
{
- var dialog = new Gtk.MessageDialog(null,
- Gtk.DialogFlags.NO_SEPARATOR,
- Gtk.MessageType.ERROR,
- Gtk.ButtonsType.CLOSE,
- "Error saving: %s", e. message);
- dialog.title = "Error Saving";
- dialog.border_width = 5;
- dialog.run();
+ case "slides":
+ parse_slides(iter);
+ break;
}
}
+ }
- /**
- * Begins the parsing of an XML document.
- *
- * This will be replaced with a JSON file format.
- *
- * @param node The initial XML node to begin with.
- */
- private void parse_xml(Xml.Node* node)
+ /**
+ * Parses the slides from an XML document.
+ *
+ * This will be replaced with a JSON file format.
+ *
+ * @param node The slides XML node.
+ */
+ private void parse_slides(Xml.Node* node)
+ {
+ for (Xml.Node* i = node->children; i != null; i = i->next)
{
- for (Xml.Node* iter = node->children; iter != null; iter = iter ->next)
+ // skip ahead if this isn't a node
+ if (i->type != ElementType.ELEMENT_NODE)
+ {
+ continue;
+ }
+
+ // create a new slide to be added
+ var slide = new Slide(this);
+ slide.elements = new Gee.ArrayList<Element>();
+
+ // scan the slide's properties
+ for (Xml.Attr* j = i->properties; j != null; j = j->next)
{
- switch (iter->name)
+ switch (j->name)
{
- case "slides":
- parse_slides(iter);
+ case "transition":
+ slide.transition = j->children->content;
+ break;
+ case "variant":
+ slide.variant = j->children->content;
+ break;
+ case "background_color":
+ slide.background_color.from_string(j->children->content);
+ break;
+ case "background_image":
+ slide.background_image = j->children->content;
+ break;
+ case "time":
+ slide.transition_time = j->children->content.to_double();
break;
}
}
- }
-
- /**
- * Parses the slides from an XML document.
- *
- * This will be replaced with a JSON file format.
- *
- * @param node The slides XML node.
- */
- private void parse_slides(Xml.Node* node)
- {
- for (Xml.Node* i = node->children; i != null; i = i->next)
- {
- // skip ahead if this isn't a node
- if (i->type != ElementType.ELEMENT_NODE)
+
+ // scan the slide's elements
+ for (Xml.Node* j = i->children; j != null; j = j->next)
+ {
+ if (j->type != ElementType.ELEMENT_NODE)
{
continue;
}
-
- // create a new slide to be added
- var slide = new Slide(this);
- slide.elements = new Gee.ArrayList<Element>();
-
- // scan the slide's properties
- for (Xml.Attr* j = i->properties; j != null; j = j->next)
+
+ // build a list of the element's properties
+ var list = new Gee.ArrayList<string>();
+ for (Xml.Attr* k = j->properties; k != null; k = k->next)
{
- switch (j->name)
- {
- case "transition":
- slide.transition = j->children->content;
- break;
- case "variant":
- slide.variant = j->children->content;
- break;
- case "background_color":
- slide.background_color.from_string(j->children->content);
- break;
- case "background_image":
- slide.background_image = j->children->content;
- break;
- case "time":
- slide.transition_time = j->children->content.to_double();
- break;
- }
+ list.add(k->name);
+ list.add(k->children->content);
}
-
- // scan the slide's elements
- for (Xml.Node* j = i->children; j != null; j = j->next)
- {
- if (j->type != ElementType.ELEMENT_NODE)
- {
- continue;
- }
- // build a list of the element's properties
- var list = new Gee.ArrayList<string>();
- for (Xml.Attr* k = j->properties; k != null; k = k->next)
- {
- list.add(k->name);
- list.add(k->children->content);
- }
-
- // if the element has text, add that as well
- if (j->get_content() != null)
- {
- list.add("text");
- list.add(j-> get_content());
- }
-
- // create an appropriate element
- var element = new Element(slide);
- for (var index = 0; index < list.size; index += 2)
- {
- element.data.set(list[index], list[index + 1]);
- }
-
- slide.elements.add(element);
+ // if the element has text, add that as well
+ if (j->get_content() != null)
+ {
+ list.add("text");
+ list.add(j-> get_content());
}
- slides.add(slide);
+ // create an appropriate element
+ var element = new Element(slide);
+ for (var index = 0; index < list.size; index += 2)
+ {
+ element.data.set(list[index], list[index + 1]);
+ }
+
+ slide.elements.add(element);
}
+
+ slides.add(slide);
}
+ }
+
+ public void export_to_html(Gtk.Window window)
+ {
+ // make an HTMLExporter
+ var exporter = new HTMLExporter();
- public void export_to_html(Gtk.Window window)
+ if (!exporter.request_path(window))
{
- // make an HTMLExporter
- var exporter = new HTMLExporter();
-
- if (!exporter.request_path(window))
- {
- return;
- }
+ return;
+ }
+
+ // intialize the html string
+ var html = "<!DOCTYPE html>\n<html>\n";
- // intialize the html string
- var html = "<!DOCTYPE html>\n<html>\n";
-
- // make the header
- html += "<head>\n<title>Presentation</title>\n";
- html += "<style>\n.slide {\nwidth:" + width.to_string() +
- "px;\nheight:" + height.to_string() +
- "px; position: relative;margin: 20px auto 20px auto}\n" +
- "html { padding: 0px; margin: 0px; background-color:" +
- "black;}\n</style>\n</head>\n";
-
- // make the body
- html += "<body>\n";
-
- // add each slide
- for (var i = 0; i < slides.size; i++)
- {
- slides.get(i).to_html(ref html, exporter, 1.0 / slides.size, i);
- }
-
- // finish the document
- html += "</body>\n</html>\n";
-
- // write the document to file
- try
- {
- var file = File.new_for_path(exporter.path);
- var stream = file.replace(null, true, FileCreateFlags.NONE, null);
- var data_stream = new DataOutputStream(stream);
- data_stream.put_string(html, null);
- }
- catch (GLib.Error e)
- {
- var dialog = new Gtk.MessageDialog(null,
- Gtk.DialogFlags.NO_SEPARATOR,
- Gtk.MessageType.ERROR,
- Gtk.ButtonsType.CLOSE,
- "Error exporting: %s",
- e. message);
- dialog.title = "Error Exporting";
- dialog.border_width = 5;
- dialog.run();
- }
-
- exporter.finish();
+ // make the header
+ html += "<head>\n<title>Presentation</title>\n";
+ html += "<style>\n.slide {\nwidth:" + width.to_string() +
+ "px;\nheight:" + height.to_string() +
+ "px; position: relative;margin: 20px auto 20px auto}\n" +
+ "html { padding: 0px; margin: 0px; background-color:" +
+ "black;}\n</style>\n</head>\n";
+
+ // make the body
+ html += "<body>\n";
+
+ // add each slide
+ for (var i = 0; i < slides.size; i++)
+ {
+ slides.get(i).to_html(ref html, exporter, 1.0 / slides.size, i);
+ }
+
+ // finish the document
+ html += "</body>\n</html>\n";
+
+ // write the document to file
+ try
+ {
+ var file = File.new_for_path(exporter.path);
+ var stream = file.replace(null, true, FileCreateFlags.NONE, null);
+ var data_stream = new DataOutputStream(stream);
+ data_stream.put_string(html, null);
}
+ catch (GLib.Error e)
+ {
+ var dialog = new Gtk.MessageDialog(null,
+ Gtk.DialogFlags.NO_SEPARATOR,
+ Gtk.MessageType.ERROR,
+ Gtk.ButtonsType.CLOSE,
+ "Error exporting: %s",
+ e. message);
+ dialog.title = "Error Exporting";
+ dialog.border_width = 5;
+ dialog.run();
+ }
+
+ exporter.finish();
}
}
diff --git a/src/libease/EditorEmbed.vala b/src/libease/EditorEmbed.vala
index 0bb7516..977397b 100644
--- a/src/libease/EditorEmbed.vala
+++ b/src/libease/EditorEmbed.vala
@@ -15,335 +15,333 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * The main editing widget.
+ *
+ * EditorEmbed is the outermost part of the editing canvas in an Ease
+ * window. Each EditorEmbed is linked to a { link Document}, and
+ * changes in the editor are immediately reflected in the Document, but
+ * are not saved to disk until the user clicks on a save button or
+ * menu item.
+ *
+ * EditorEmbed is a subclass of { link ScrollableEmbed}, and has both
+ * horizontal and vertical scrollbars.
+ */
+public class Ease.EditorEmbed : ScrollableEmbed
{
+ // overall display
+ private Clutter.Rectangle view_background;
+
+ // selection rectangle
+ private Clutter.Rectangle selection_rectangle;
+
+ // handles
+ private Handle[] handles;
+
+ // the current slide's actor
+ private SlideActor slide_actor;
+
+ // the currently selected Actor
+ private Actor selected;
+
+ // if the selected Actor is being dragged
+ private bool is_dragging;
+ private bool is_drag_ready;
+ private float mouse_x;
+ private float mouse_y;
+
+ private Document document;
+ public float zoom;
+ public bool zoom_fit;
+
/**
- * The main editing widget.
- *
+ * Create an EditorEmbed representing a { link Document}.
+ *
* EditorEmbed is the outermost part of the editing canvas in an Ease
* window. Each EditorEmbed is linked to a { link Document}, and
* changes in the editor are immediately reflected in the Document, but
* are not saved to disk until the user clicks on a save button or
- * menu item.
- *
- * EditorEmbed is a subclass of { link ScrollableEmbed}, and has both
- * horizontal and vertical scrollbars.
+ * menu item.
+ *
+ * @param d The { link Document} this EditorEmbed represents.
*/
- public class EditorEmbed : ScrollableEmbed
+ public EditorEmbed(Document d)
{
- // overall display
- private Clutter.Rectangle view_background;
-
- // selection rectangle
- private Clutter.Rectangle selection_rectangle;
-
- // handles
- private Handle[] handles;
+ base(true);
- // the current slide's actor
- private SlideActor slide_actor;
+ // set up the background
+ view_background = new Clutter.Rectangle();
+ var color = Clutter.Color();
+ color.from_string("Gray");
+ view_background.color = color;
+ contents.add_actor(view_background);
- // the currently selected Actor
- private Actor selected;
-
- // if the selected Actor is being dragged
- private bool is_dragging;
- private bool is_drag_ready;
- private float mouse_x;
- private float mouse_y;
-
- private Document document;
- public float zoom;
- public bool zoom_fit;
+ document = d;
+ set_size_request(320, 240);
- /**
- * Create an EditorEmbed representing a { link Document}.
- *
- * EditorEmbed is the outermost part of the editing canvas in an Ease
- * window. Each EditorEmbed is linked to a { link Document}, and
- * changes in the editor are immediately reflected in the Document, but
- * are not saved to disk until the user clicks on a save button or
- * menu item.
- *
- * @param d The { link Document} this EditorEmbed represents.
- */
- public EditorEmbed(Document d)
- {
- base(true);
+ zoom = 1;
+ zoom_fit = false;
- // set up the background
- view_background = new Clutter.Rectangle();
- var color = Clutter.Color();
- color.from_string("Gray");
- view_background.color = color;
- contents.add_actor(view_background);
-
- document = d;
- set_size_request(320, 240);
-
- zoom = 1;
- zoom_fit = false;
+ // reposition everything when resized
+ size_allocate.connect(() => {
+ if (zoom_fit)
+ {
+ zoom = width / height > (float)document.width / document.height
+ ? height / document.height
+ : width / document.width;
+ reposition_group();
+ }
+ else
+ {
+ reposition_group();
+ }
- // reposition everything when resized
- size_allocate.connect(() => {
- if (zoom_fit)
- {
- zoom = width / height > (float)document.width / document.height
- ? height / document.height
- : width / document.width;
- reposition_group();
- }
- else
- {
- reposition_group();
- }
+ // set the size of the background
+ view_background.width = (float)Math.fmax(width, slide_actor.width);
+ view_background.height = height;
+ });
+ }
- // set the size of the background
- view_background.width = (float)Math.fmax(width, slide_actor.width);
- view_background.height = height;
- });
- }
+ /**
+ * Sets the zoom level of the slide displayed by this EditorEmbed.
+ *
+ * When this function is called, only the EditorEmbed's zoom level is
+ * set. Therefore, any other relevant parts of the interface should
+ * also be updated by the caller.
+ *
+ * @param z The zoom level, on a 0-100 scale (higher values, are, of
+ * course, possible, but values below 10 or so are unlikely to produce
+ * desirable results.
+ */
+ public void set_zoom(float z)
+ {
+ zoom = z / 100;
+ reposition_group();
+ }
- /**
- * Sets the zoom level of the slide displayed by this EditorEmbed.
- *
- * When this function is called, only the EditorEmbed's zoom level is
- * set. Therefore, any other relevant parts of the interface should
- * also be updated by the caller.
- *
- * @param z The zoom level, on a 0-100 scale (higher values, are, of
- * course, possible, but values below 10 or so are unlikely to produce
- * desirable results.
- */
- public void set_zoom(float z)
+ /**
+ * Sets the current { link Slide} that the EditorEmbed is displaying.
+ *
+ * The current slide is displayed in the center of the EditorEmbed.
+ * Components of it should also be editable via interface elements such
+ * as the Inspector.
+ *
+ * This function will work with a { link Slide} that is not in the
+ * displayed { link Document}. For obvious reasons, this is not a
+ * particularly good idea.
+ *
+ * @param node The initial XML node to begin with.
+ */
+ public void set_slide(Slide slide)
+ {
+ if (slide == null)
{
- zoom = z / 100;
- reposition_group();
+ return;
}
-
- /**
- * Sets the current { link Slide} that the EditorEmbed is displaying.
- *
- * The current slide is displayed in the center of the EditorEmbed.
- * Components of it should also be editable via interface elements such
- * as the Inspector.
- *
- * This function will work with a { link Slide} that is not in the
- * displayed { link Document}. For obvious reasons, this is not a
- * particularly good idea.
- *
- * @param node The initial XML node to begin with.
- */
- public void set_slide(Slide slide)
+
+ // clean up the previous slide
+ if (slide_actor != null)
{
- if (slide == null)
- {
- return;
- }
-
- // clean up the previous slide
- if (slide_actor != null)
- {
- contents.remove_actor(slide_actor);
- for (unowned List<Clutter.Actor>* itr = slide_actor.contents.get_children();
- itr != null;
- itr = itr->next)
- {
- ((Actor*)(itr->data))->button_press_event.disconnect(actor_clicked);
- ((Actor*)(itr->data))->button_release_event.disconnect(actor_released);
- ((Actor*)(itr->data))->motion_event.disconnect(actor_motion);
- ((Actor*)(itr->data))->set_reactive(false);
- }
- }
-
- // remove the selection rectangle
- if (selection_rectangle != null)
- {
- contents.remove_actor(selection_rectangle);
- foreach (var h in handles)
- {
- contents.remove_actor(h);
- }
- }
-
- // create a new SlideActor
- slide_actor = new SlideActor.from_slide(document,
- slide,
- false,
- ActorContext.EDITOR);
-
- // make the elements clickable
+ contents.remove_actor(slide_actor);
for (unowned List<Clutter.Actor>* itr = slide_actor.contents.get_children();
itr != null;
itr = itr->next)
{
-
- ((Actor*)(itr->data))->button_press_event.connect(actor_clicked);
- ((Actor*)(itr->data))->button_release_event.connect(actor_released);
- ((Actor*)(itr->data))->motion_event.connect(actor_motion);
- ((Actor*)(itr->data))->set_reactive(true);
+ ((Actor*)(itr->data))->button_press_event.disconnect(actor_clicked);
+ ((Actor*)(itr->data))->button_release_event.disconnect(actor_released);
+ ((Actor*)(itr->data))->motion_event.disconnect(actor_motion);
+ ((Actor*)(itr->data))->set_reactive(false);
}
-
- contents.add_actor(slide_actor);
- reposition_group();
}
-
- /**
- * Repositions the EditorEmbed's { link SlideActor}.
- *
- * Call this function after changing the zoom level, document size, or
- * any other properties that could place the slide off center.
- */
- public void reposition_group()
+
+ // remove the selection rectangle
+ if (selection_rectangle != null)
{
- var w = zoom * document.width;
- var h = zoom * document.height;
-
- slide_actor.set_scale_full(zoom, zoom, 0, 0);
-
- slide_actor.x = w < width
- ? width / 2 - w / 2
- : 0;
-
- slide_actor.y = h < height
- ? height / 2 - h / 2
- : 0;
-
- if (selection_rectangle != null)
+ contents.remove_actor(selection_rectangle);
+ foreach (var h in handles)
{
- position_selection();
+ contents.remove_actor(h);
}
}
- /**
- * Repositions the EditorEmbed's selection rectangle
- *
- * Call this function after changing the zoom level, document size, or
- * any other properties that could place the slide off center.
- */
- private void position_selection()
+ // create a new SlideActor
+ slide_actor = new SlideActor.from_slide(document,
+ slide,
+ false,
+ ActorContext.EDITOR);
+
+ // make the elements clickable
+ for (unowned List<Clutter.Actor>* itr = slide_actor.contents.get_children();
+ itr != null;
+ itr = itr->next)
{
- selection_rectangle.set_position(zoom * selected.x + slide_actor.x,
- zoom * selected.y + slide_actor.y);
- selection_rectangle.set_size(zoom * selected.width,
- zoom * selected.height);
- foreach (var h in handles)
- {
- h.reposition(selection_rectangle);
- }
+ ((Actor*)(itr->data))->button_press_event.connect(actor_clicked);
+ ((Actor*)(itr->data))->button_release_event.connect(actor_released);
+ ((Actor*)(itr->data))->motion_event.connect(actor_motion);
+ ((Actor*)(itr->data))->set_reactive(true);
}
- /**
- * Signal handler for clicking on { link Actor}s.
- *
- * This handler is attached to the button_press_event of all
- * { link Actor}s in the currently displayed { link SlideActor}.
- *
- * @param sender The { link Actor} that was clicked
- * @param event The corresponding Clutter.Event
- */
- public bool actor_clicked(Clutter.Actor sender, Clutter.Event event)
- {
- Actor act = (Actor)sender;
- stdout.printf("Name: %s\n", act.element.data.get("ease_name"));
+ contents.add_actor(slide_actor);
+ reposition_group();
+ }
+
+ /**
+ * Repositions the EditorEmbed's { link SlideActor}.
+ *
+ * Call this function after changing the zoom level, document size, or
+ * any other properties that could place the slide off center.
+ */
+ public void reposition_group()
+ {
+ var w = zoom * document.width;
+ var h = zoom * document.height;
- // if the sender is already selected, drag it
- if (sender == selected)
- {
- is_dragging = true;
- is_drag_ready = false;
- Clutter.grab_pointer(sender);
- return true;
- }
-
- // remove the selection rectangle
- if (selection_rectangle != null)
- {
- foreach (var h in handles)
- {
- contents.remove_actor(h);
- }
- contents.remove_actor(selection_rectangle);
- }
-
- selected = (Actor)sender;
-
- // make a new selection rectangle
- selection_rectangle = new Clutter.Rectangle();
- selection_rectangle.border_color = {0, 0, 0, 255};
- selection_rectangle.color = {0, 0, 0, 0};
- selection_rectangle.set_border_width(2);
+ slide_actor.set_scale_full(zoom, zoom, 0, 0);
+
+ slide_actor.x = w < width
+ ? width / 2 - w / 2
+ : 0;
+
+ slide_actor.y = h < height
+ ? height / 2 - h / 2
+ : 0;
+
+ if (selection_rectangle != null)
+ {
position_selection();
- contents.add_actor(selection_rectangle);
-
- handles = new Handle[8];
- for (int i = 0; i < 8; i++)
- {
- handles[i] = new Handle((HandlePosition)i);
- handles[i].reposition(selection_rectangle);
- contents.add_actor(handles[i]);
- }
-
+ }
+ }
+
+ /**
+ * Repositions the EditorEmbed's selection rectangle
+ *
+ * Call this function after changing the zoom level, document size, or
+ * any other properties that could place the slide off center.
+ */
+ private void position_selection()
+ {
+ selection_rectangle.set_position(zoom * selected.x + slide_actor.x,
+ zoom * selected.y + slide_actor.y);
+ selection_rectangle.set_size(zoom * selected.width,
+ zoom * selected.height);
+
+ foreach (var h in handles)
+ {
+ h.reposition(selection_rectangle);
+ }
+ }
+
+ /**
+ * Signal handler for clicking on { link Actor}s.
+ *
+ * This handler is attached to the button_press_event of all
+ * { link Actor}s in the currently displayed { link SlideActor}.
+ *
+ * @param sender The { link Actor} that was clicked
+ * @param event The corresponding Clutter.Event
+ */
+ public bool actor_clicked(Clutter.Actor sender, Clutter.Event event)
+ {
+ Actor act = (Actor)sender;
+ stdout.printf("Name: %s\n", act.element.data.get("ease_name"));
+
+ // if the sender is already selected, drag it
+ if (sender == selected)
+ {
+ is_dragging = true;
+ is_drag_ready = false;
+ Clutter.grab_pointer(sender);
return true;
}
- /**
- * Signal handler for releasing an { link Actor}.
- *
- * This handler is attached to the button_release_event of all
- * { link Actor}s in the currently displayed { link SlideActor}.
- *
- * When the { link Actor} is being dragged, this ends the drag action.
- *
- * @param sender The { link Actor} that was released
- * @param event The corresponding Clutter.Event
- */
- public bool actor_released(Clutter.Actor sender, Clutter.Event event)
+ // remove the selection rectangle
+ if (selection_rectangle != null)
{
- if (sender == selected && is_dragging)
+ foreach (var h in handles)
{
- is_dragging = false;
- Clutter.ungrab_pointer();
+ contents.remove_actor(h);
}
- return true;
+ contents.remove_actor(selection_rectangle);
}
- /**
- * Signal handler for dragging an { link Actor}.
- *
- * This handler is attached to the motion_event of all
- * { link Actor}s in the currently displayed { link SlideActor}.
- * It will only have an effect if a drag is active.
- *
- * @param sender The { link Actor} that was dragged
- * @param event The corresponding Clutter.Event
- */
- public bool actor_motion(Clutter.Actor sender, Clutter.Event event)
+ selected = (Actor)sender;
+
+ // make a new selection rectangle
+ selection_rectangle = new Clutter.Rectangle();
+ selection_rectangle.border_color = {0, 0, 0, 255};
+ selection_rectangle.color = {0, 0, 0, 0};
+ selection_rectangle.set_border_width(2);
+ position_selection();
+ contents.add_actor(selection_rectangle);
+
+ handles = new Handle[8];
+ for (int i = 0; i < 8; i++)
{
- Actor actor = (Actor)sender;
-
- if (sender == selected && is_dragging)
+ handles[i] = new Handle((HandlePosition)i);
+ handles[i].reposition(selection_rectangle);
+ contents.add_actor(handles[i]);
+ }
+
+ return true;
+ }
+
+ /**
+ * Signal handler for releasing an { link Actor}.
+ *
+ * This handler is attached to the button_release_event of all
+ * { link Actor}s in the currently displayed { link SlideActor}.
+ *
+ * When the { link Actor} is being dragged, this ends the drag action.
+ *
+ * @param sender The { link Actor} that was released
+ * @param event The corresponding Clutter.Event
+ */
+ public bool actor_released(Clutter.Actor sender, Clutter.Event event)
+ {
+ if (sender == selected && is_dragging)
+ {
+ is_dragging = false;
+ Clutter.ungrab_pointer();
+ }
+ return true;
+ }
+
+ /**
+ * Signal handler for dragging an { link Actor}.
+ *
+ * This handler is attached to the motion_event of all
+ * { link Actor}s in the currently displayed { link SlideActor}.
+ * It will only have an effect if a drag is active.
+ *
+ * @param sender The { link Actor} that was dragged
+ * @param event The corresponding Clutter.Event
+ */
+ public bool actor_motion(Clutter.Actor sender, Clutter.Event event)
+ {
+ Actor actor = (Actor)sender;
+
+ if (sender == selected && is_dragging)
+ {
+ if (!is_drag_ready)
{
- if (!is_drag_ready)
- {
- is_drag_ready = true;
- mouse_x = event.motion.x;
- mouse_y = event.motion.y;
- return true;
- }
-
- float factor = 1 / zoom;
-
- actor.translate(factor * (event.motion.x - mouse_x),
- factor * (event.motion.y - mouse_y));
-
+ is_drag_ready = true;
mouse_x = event.motion.x;
mouse_y = event.motion.y;
-
- position_selection();
+ return true;
}
- return true;
+
+ float factor = 1 / zoom;
+
+ actor.translate(factor * (event.motion.x - mouse_x),
+ factor * (event.motion.y - mouse_y));
+
+ mouse_x = event.motion.x;
+ mouse_y = event.motion.y;
+
+ position_selection();
}
+ return true;
}
}
+
diff --git a/src/libease/EditorWindow.vala b/src/libease/EditorWindow.vala
index 3d6d407..e215ff7 100644
--- a/src/libease/EditorWindow.vala
+++ b/src/libease/EditorWindow.vala
@@ -15,355 +15,353 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * A window for editing an Ease { link Document}
+ *
+ * An EditorWindow contains several widgets: a { link MainToolbar}, an
+ * { link EditorEmbed}, a { link SlideButtonPanel}, and assorted other
+ * controls. The window is linked to a { link Document}, and all changes
+ * are made directly to that object.
+ */
+public class Ease.EditorWindow : Gtk.Window
{
+ // interface elements
+ public EditorEmbed embed;
+ public MainToolbar main_toolbar;
+ public Gtk.HBox inspector;
+ public Gtk.HBox slides;
+ public TransitionPane pane_transition;
+ public SlidePane pane_slide;
+ public Gtk.HScale zoom_slider;
+ private Gtk.Button zoom_in;
+ private Gtk.Button zoom_out;
+ private int zoom_previous = 0;
+
+ // the player for this window
+ private Player player;
+
+ public Document document;
+ public Slide slide;
+
+ // interface variables
+ public bool inspector_shown { get; set; }
+ public bool slides_shown { get; set; }
+
+ // constants
+ private const int[] ZOOM_LEVELS = {10, 25, 33, 50, 66, 75, 100, 125, 150, 200, 250, 300, 400};
+ private const int ZOOM_COUNT = 13;
+
/**
- * A window for editing an Ease { link Document}
+ * Creates a new EditorWindow.
+ *
+ * An EditorWindow includes a { link MainToolbar}, an
+ * { link EditorEmbed}, a { link SlidePane}, a menu bar, and other
+ * interface elements.
*
- * An EditorWindow contains several widgets: a { link MainToolbar}, an
- * { link EditorEmbed}, a { link SlideButtonPanel}, and assorted other
- * controls. The window is linked to a { link Document}, and all changes
- * are made directly to that object.
+ * @param node The initial XML node to begin with.
*/
- public class EditorWindow : Gtk.Window
+ public EditorWindow(string filename)
{
- // interface elements
- public EditorEmbed embed;
- public MainToolbar main_toolbar;
- public Gtk.HBox inspector;
- public Gtk.HBox slides;
- public TransitionPane pane_transition;
- public SlidePane pane_slide;
- public Gtk.HScale zoom_slider;
- private Gtk.Button zoom_in;
- private Gtk.Button zoom_out;
- private int zoom_previous = 0;
-
- // the player for this window
- private Player player;
+ title = "Ease - " + filename;
+ set_default_size(1024, 768);
- public Document document;
- public Slide slide;
+ document = new Document.from_file(filename);
- // interface variables
- public bool inspector_shown { get; set; }
- public bool slides_shown { get; set; }
+ // slide display
+ var slides_win = new SlideButtonPanel(document, this);
- // constants
- private const int[] ZOOM_LEVELS = {10, 25, 33, 50, 66, 75, 100, 125, 150, 200, 250, 300, 400};
- private const int ZOOM_COUNT = 13;
-
- /**
- * Creates a new EditorWindow.
- *
- * An EditorWindow includes a { link MainToolbar}, an
- * { link EditorEmbed}, a { link SlidePane}, a menu bar, and other
- * interface elements.
- *
- * @param node The initial XML node to begin with.
- */
- public EditorWindow(string filename)
- {
- title = "Ease - " + filename;
- set_default_size(1024, 768);
-
- document = new Document.from_file(filename);
-
- // slide display
- var slides_win = new SlideButtonPanel(document, this);
-
- // the inspector
- inspector = new Gtk.HBox(false, 0);
- var notebook = new Gtk.Notebook();
- notebook.scrollable = true;
- pane_transition = new TransitionPane();
- pane_slide = new SlidePane();
- notebook.append_page(pane_slide,
- new Gtk.Image.from_stock("gtk-page-setup",
- Gtk.IconSize.SMALL_TOOLBAR));
- notebook.append_page(pane_transition,
- new Gtk.Image.from_stock("gtk-media-forward",
- Gtk.IconSize.SMALL_TOOLBAR));
- inspector.pack_start(notebook, false, false, 0);
-
- // main editor
- embed = new EditorEmbed(document);
-
- // assemble middle contents
- var hbox = new Gtk.HBox(false, 0);
- var hpaned = new Gtk.HPaned();
- hpaned.pack1(slides_win, false, false);
- hpaned.pack2(embed, true, true);
- hbox.pack_start(hpaned, true, true, 0);
- hbox.pack_start(inspector, false, false, 0);
-
- // assemble window contents
- var vbox = new Gtk.VBox(false, 0);
- vbox.pack_start(create_menu_bar(), false, false, 0);
- main_toolbar = new MainToolbar();
- vbox.pack_start(main_toolbar, false, false, 0);
- vbox.pack_start(new Gtk.HSeparator(), false, false, 0);
- vbox.pack_start(hbox, true, true, 0);
- vbox.pack_end(create_bottom_bar(), false, false, 0);
-
- // final window setup
- add(vbox);
- show_all();
- embed.show();
- inspector.hide();
- inspector_shown = false;
- slides_shown = true;
-
- // USER INTERFACE SIGNALS
-
- // toolbar
-
- // show and hide inspector
- main_toolbar.inspector.clicked.connect(() => {
- if (inspector_shown)
- {
- inspector.hide();
- }
- else
- {
- inspector.show();
- }
- inspector_shown = !inspector_shown;
- });
-
- // show and hide slides
- main_toolbar.slides.clicked.connect(() => {
- if (slides_shown)
- {
- slides.hide();
- }
- else
- {
- slides.show();
- }
- slides_shown = !slides_shown;
- });
+ // the inspector
+ inspector = new Gtk.HBox(false, 0);
+ var notebook = new Gtk.Notebook();
+ notebook.scrollable = true;
+ pane_transition = new TransitionPane();
+ pane_slide = new SlidePane();
+ notebook.append_page(pane_slide,
+ new Gtk.Image.from_stock("gtk-page-setup",
+ Gtk.IconSize.SMALL_TOOLBAR));
+ notebook.append_page(pane_transition,
+ new Gtk.Image.from_stock("gtk-media-forward",
+ Gtk.IconSize.SMALL_TOOLBAR));
+ inspector.pack_start(notebook, false, false, 0);
+
+ // main editor
+ embed = new EditorEmbed(document);
+
+ // assemble middle contents
+ var hbox = new Gtk.HBox(false, 0);
+ var hpaned = new Gtk.HPaned();
+ hpaned.pack1(slides_win, false, false);
+ hpaned.pack2(embed, true, true);
+ hbox.pack_start(hpaned, true, true, 0);
+ hbox.pack_start(inspector, false, false, 0);
+
+ // assemble window contents
+ var vbox = new Gtk.VBox(false, 0);
+ vbox.pack_start(create_menu_bar(), false, false, 0);
+ main_toolbar = new MainToolbar();
+ vbox.pack_start(main_toolbar, false, false, 0);
+ vbox.pack_start(new Gtk.HSeparator(), false, false, 0);
+ vbox.pack_start(hbox, true, true, 0);
+ vbox.pack_end(create_bottom_bar(), false, false, 0);
+
+ // final window setup
+ add(vbox);
+ show_all();
+ embed.show();
+ inspector.hide();
+ inspector_shown = false;
+ slides_shown = true;
+
+ // USER INTERFACE SIGNALS
+
+ // toolbar
+
+ // show and hide inspector
+ main_toolbar.inspector.clicked.connect(() => {
+ if (inspector_shown)
+ {
+ inspector.hide();
+ }
+ else
+ {
+ inspector.show();
+ }
+ inspector_shown = !inspector_shown;
+ });
+
+ // show and hide slides
+ main_toolbar.slides.clicked.connect(() => {
+ if (slides_shown)
+ {
+ slides.hide();
+ }
+ else
+ {
+ slides.show();
+ }
+ slides_shown = !slides_shown;
+ });
- // make a new presentation
- main_toolbar.new_presentation.clicked.connect(Main.show_welcome);
+ // make a new presentation
+ main_toolbar.new_presentation.clicked.connect(Main.show_welcome);
- // open a file
- main_toolbar.open.clicked.connect(() => OpenDialog.run());
-
- // save file
- main_toolbar.save.clicked.connect(() => {
- document.to_file();
- });
-
- // play presentation
- main_toolbar.play.clicked.connect(() => {
- player = new Player(document);
- });
-
- // TODO: export HTML in a proper place
- main_toolbar.fonts.clicked.connect(() => {
- document.export_to_html(this);
- });
-
- // inspector
-
- // transition pane
- pane_transition.effect.changed.connect(() => {
- var variants = Transitions.get_variants(pane_transition.effect.active);
- pane_transition.variant_align.remove(pane_transition.variant);
- pane_transition.variant = new Gtk.ComboBox.text();
- pane_transition.variant_align.add(pane_transition.variant);
- pane_transition.variant.show();
- pane_transition.variant.changed.connect(() => {
- slide.variant = Transitions.get_variants(pane_transition.effect.active)[pane_transition.variant.active];
- });
- var variant_count = Transitions.get_variant_count(pane_transition.effect.active);
- if (variant_count > 0)
- {
- for (var i = 0; i < variant_count; i++)
- {
- pane_transition.variant.append_text(variants[i]);
- }
- pane_transition.variant.set_active(0);
- slide.variant = Transitions.get_variants(pane_transition.effect.active)[pane_transition.variant.active];
- }
- slide.transition = Transitions.get_name(pane_transition.effect.active);
- });
-
- pane_transition.start_transition.changed.connect(() => {
- if (pane_transition.start_transition.active == 0)
- {
- pane_transition.delay.sensitive = false;
- }
- else
- {
- pane_transition.delay.sensitive = true;
- }
+ // open a file
+ main_toolbar.open.clicked.connect(() => OpenDialog.run());
+
+ // save file
+ main_toolbar.save.clicked.connect(() => {
+ document.to_file();
+ });
+
+ // play presentation
+ main_toolbar.play.clicked.connect(() => {
+ player = new Player(document);
+ });
+
+ // TODO: export HTML in a proper place
+ main_toolbar.fonts.clicked.connect(() => {
+ document.export_to_html(this);
+ });
+
+ // inspector
+
+ // transition pane
+ pane_transition.effect.changed.connect(() => {
+ var variants = Transitions.get_variants(pane_transition.effect.active);
+ pane_transition.variant_align.remove(pane_transition.variant);
+ pane_transition.variant = new Gtk.ComboBox.text();
+ pane_transition.variant_align.add(pane_transition.variant);
+ pane_transition.variant.show();
+ pane_transition.variant.changed.connect(() => {
+ slide.variant = Transitions.get_variants(pane_transition.effect.active)[pane_transition.variant.active];
});
-
- // change the embed's zoom when the zoom slider is moved
- zoom_slider.change_value.connect((scroll, zoom, user_data) => {
- if (zoom_previous != (float)zoom_slider.get_value())
+ var variant_count = Transitions.get_variant_count(pane_transition.effect.active);
+ if (variant_count > 0)
+ {
+ for (var i = 0; i < variant_count; i++)
{
- embed.set_zoom((float)zoom_slider.get_value());
+ pane_transition.variant.append_text(variants[i]);
}
- zoom_previous = zoom;
- return false;
- });
-
- // zoom in and out with the buttons
- zoom_in.clicked.connect(() => {
- for (var i = 0; i < ZOOM_COUNT; i++)
+ pane_transition.variant.set_active(0);
+ slide.variant = Transitions.get_variants(pane_transition.effect.active)[pane_transition.variant.active];
+ }
+ slide.transition = Transitions.get_name(pane_transition.effect.active);
+ });
+
+ pane_transition.start_transition.changed.connect(() => {
+ if (pane_transition.start_transition.active == 0)
+ {
+ pane_transition.delay.sensitive = false;
+ }
+ else
+ {
+ pane_transition.delay.sensitive = true;
+ }
+ });
+
+ // change the embed's zoom when the zoom slider is moved
+ zoom_slider.change_value.connect((scroll, zoom, user_data) => {
+ if (zoom_previous != (float)zoom_slider.get_value())
+ {
+ embed.set_zoom((float)zoom_slider.get_value());
+ }
+ zoom_previous = zoom;
+ return false;
+ });
+
+ // zoom in and out with the buttons
+ zoom_in.clicked.connect(() => {
+ for (var i = 0; i < ZOOM_COUNT; i++)
+ {
+ if (zoom_slider.get_value() < ZOOM_LEVELS[i])
{
- if (zoom_slider.get_value() < ZOOM_LEVELS[i])
- {
- zoom_slider.set_value(ZOOM_LEVELS[i]);
- embed.set_zoom(ZOOM_LEVELS[i]);
- zoom_previous = ZOOM_LEVELS[i];
- break;
- }
+ zoom_slider.set_value(ZOOM_LEVELS[i]);
+ embed.set_zoom(ZOOM_LEVELS[i]);
+ zoom_previous = ZOOM_LEVELS[i];
+ break;
}
- });
-
- zoom_out.clicked.connect(() => {
- for (var i = ZOOM_COUNT - 1; i > -1; i--)
+ }
+ });
+
+ zoom_out.clicked.connect(() => {
+ for (var i = ZOOM_COUNT - 1; i > -1; i--)
+ {
+ if (zoom_slider.get_value() > ZOOM_LEVELS[i])
{
- if (zoom_slider.get_value() > ZOOM_LEVELS[i])
- {
- zoom_slider.set_value(ZOOM_LEVELS[i]);
- embed.set_zoom(ZOOM_LEVELS[i]);
- zoom_previous = ZOOM_LEVELS[i];
- break;
- }
+ zoom_slider.set_value(ZOOM_LEVELS[i]);
+ embed.set_zoom(ZOOM_LEVELS[i]);
+ zoom_previous = ZOOM_LEVELS[i];
+ break;
}
- });
+ }
+ });
- hide.connect(() => Main.remove_window(this));
-
- load_slide(0);
- }
+ hide.connect(() => Main.remove_window(this));
- /**
- * Load a slide into the main { link EditorEmbed}.
- *
- * @param filename The index of the slide.
- */
- public void load_slide(int index)
- {
- slide = document.slides.get(index);
-
- // update ui elements for this new slide
- pane_transition.effect.set_active(Transitions.get_transition_id(slide.transition));
- if (slide.variant != "" && slide.variant != null)
- {
- pane_transition.variant.set_active(Transitions.get_variant_id(slide.transition, slide.variant));
- }
-
- embed.set_slide(slide);
- }
+ load_slide(0);
+ }
+
+ /**
+ * Load a slide into the main { link EditorEmbed}.
+ *
+ * @param filename The index of the slide.
+ */
+ public void load_slide(int index)
+ {
+ slide = document.slides.get(index);
- // signal handlers
- private void show_open_dialog()
+ // update ui elements for this new slide
+ pane_transition.effect.set_active(Transitions.get_transition_id(slide.transition));
+ if (slide.variant != "" && slide.variant != null)
{
- var dialog = new Gtk.FileChooserDialog("Open File",
- this,
- Gtk.FileChooserAction.OPEN,
- null);
- dialog.run();
+ pane_transition.variant.set_active(Transitions.get_variant_id(slide.transition, slide.variant));
}
- private void new_presentation()
- {
- //var window = new EditorWindow("../../../../Examples/Example.ease/");
- }
+ embed.set_slide(slide);
+ }
+
+ // signal handlers
+ private void show_open_dialog()
+ {
+ var dialog = new Gtk.FileChooserDialog("Open File",
+ this,
+ Gtk.FileChooserAction.OPEN,
+ null);
+ dialog.run();
+ }
+
+ private void new_presentation()
+ {
+ //var window = new EditorWindow("../../../../Examples/Example.ease/");
+ }
+
+ // menu bar creation
+ private Gtk.MenuBar create_menu_bar()
+ {
+ var menubar = new Gtk.MenuBar();
- // menu bar creation
- private Gtk.MenuBar create_menu_bar()
- {
- var menubar = new Gtk.MenuBar();
-
- menubar.append(create_file_menu());
-
- return menubar;
- }
+ menubar.append(create_file_menu());
- private Gtk.MenuItem create_file_menu()
- {
- /* TODO : use mnemonics */
- var menuItem = new Gtk.MenuItem.with_label("File");
- var menu = new Gtk.Menu();
-
- var newItem = new Gtk.MenuItem.with_label("New");
- var newMenu = new Gtk.Menu();
- var newPres = new Gtk.MenuItem.with_label("Presentation");
- newPres.activate.connect(new_presentation);
- var newTheme = new Gtk.MenuItem.with_label("Theme");
- var Quit = new Gtk.MenuItem.with_label("Quit");
- Quit.activate.connect( Gtk.main_quit );
+ return menubar;
+ }
+
+ private Gtk.MenuItem create_file_menu()
+ {
+ /* TODO : use mnemonics */
+ var menuItem = new Gtk.MenuItem.with_label("File");
+ var menu = new Gtk.Menu();
+
+ var newItem = new Gtk.MenuItem.with_label("New");
+ var newMenu = new Gtk.Menu();
+ var newPres = new Gtk.MenuItem.with_label("Presentation");
+ newPres.activate.connect(new_presentation);
+ var newTheme = new Gtk.MenuItem.with_label("Theme");
+ var Quit = new Gtk.MenuItem.with_label("Quit");
+ Quit.activate.connect( Gtk.main_quit );
- newMenu.append(newPres);
- newMenu.append(newTheme);
- newItem.set_submenu(newMenu);
- menu.append(newItem);
-
- var openItem = new Gtk.MenuItem.with_label("Open");
- openItem.activate.connect(show_open_dialog);
- openItem.set_accel_path("<-Document>/File/Open");
- Gtk.AccelMap.add_entry("<-Document>/File/Open",
- Gdk.keyval_from_name("o"),
- Gdk.ModifierType.CONTROL_MASK);
- menu.append(openItem);
- menu.append(Quit);
- menuItem.set_submenu(menu);
-
- return menuItem;
- }
+ newMenu.append(newPres);
+ newMenu.append(newTheme);
+ newItem.set_submenu(newMenu);
+ menu.append(newItem);
- private Gtk.Alignment create_bottom_bar()
- {
- var hbox = new Gtk.HBox(false, 5);
-
- // create zoom slider
- zoom_slider = new Gtk.HScale(new Gtk.Adjustment(100, 10, 400, 10, 50, 50));
- zoom_slider.width_request = 200;
- zoom_slider.value_pos = Gtk.PositionType.RIGHT;
- zoom_slider.digits = 0;
-
- // format the slider text
- zoom_slider.format_value.connect(val => {
- return "%i%%".printf((int)val);
- });
-
- // zoom in button
- zoom_in = new Gtk.Button();
- zoom_in.add(new Gtk.Image.from_stock("gtk-zoom-in", Gtk.IconSize.MENU));
- zoom_in.relief = Gtk.ReliefStyle.NONE;
-
- // zoom out button
- zoom_out = new Gtk.Button();
- zoom_out.add(new Gtk.Image.from_stock("gtk-zoom-out", Gtk.IconSize.MENU));
- zoom_out.relief = Gtk.ReliefStyle.NONE;
-
- // put it all together
- var align = new Gtk.Alignment(0, 0.5f, 1, 0);
- align.add(zoom_out);
- hbox.pack_start(align, false, false, 0);
-
- align = new Gtk.Alignment(0, 0.5f, 1, 0);
- align.add(zoom_slider);
- hbox.pack_start(align, false, false, 0);
-
- align = new Gtk.Alignment(0, 0.5f, 1, 0);
- align.add(zoom_in);
- hbox.pack_start(align, false, false, 0);
-
- var vbox = new Gtk.VBox(false, 0);
- vbox.pack_start(new Gtk.HSeparator(), false, false, 0);
- vbox.pack_start(hbox, true, true, 2);
-
- align = new Gtk.Alignment(1, 1, 1, 1);
- align.add(vbox);
- return align;
- }
+ var openItem = new Gtk.MenuItem.with_label("Open");
+ openItem.activate.connect(show_open_dialog);
+ openItem.set_accel_path("<-Document>/File/Open");
+ Gtk.AccelMap.add_entry("<-Document>/File/Open",
+ Gdk.keyval_from_name("o"),
+ Gdk.ModifierType.CONTROL_MASK);
+ menu.append(openItem);
+ menu.append(Quit);
+ menuItem.set_submenu(menu);
+
+ return menuItem;
+ }
+
+ private Gtk.Alignment create_bottom_bar()
+ {
+ var hbox = new Gtk.HBox(false, 5);
+
+ // create zoom slider
+ zoom_slider = new Gtk.HScale(new Gtk.Adjustment(100, 10, 400, 10, 50, 50));
+ zoom_slider.width_request = 200;
+ zoom_slider.value_pos = Gtk.PositionType.RIGHT;
+ zoom_slider.digits = 0;
+
+ // format the slider text
+ zoom_slider.format_value.connect(val => {
+ return "%i%%".printf((int)val);
+ });
+
+ // zoom in button
+ zoom_in = new Gtk.Button();
+ zoom_in.add(new Gtk.Image.from_stock("gtk-zoom-in", Gtk.IconSize.MENU));
+ zoom_in.relief = Gtk.ReliefStyle.NONE;
+
+ // zoom out button
+ zoom_out = new Gtk.Button();
+ zoom_out.add(new Gtk.Image.from_stock("gtk-zoom-out", Gtk.IconSize.MENU));
+ zoom_out.relief = Gtk.ReliefStyle.NONE;
+
+ // put it all together
+ var align = new Gtk.Alignment(0, 0.5f, 1, 0);
+ align.add(zoom_out);
+ hbox.pack_start(align, false, false, 0);
+
+ align = new Gtk.Alignment(0, 0.5f, 1, 0);
+ align.add(zoom_slider);
+ hbox.pack_start(align, false, false, 0);
+
+ align = new Gtk.Alignment(0, 0.5f, 1, 0);
+ align.add(zoom_in);
+ hbox.pack_start(align, false, false, 0);
+
+ var vbox = new Gtk.VBox(false, 0);
+ vbox.pack_start(new Gtk.HSeparator(), false, false, 0);
+ vbox.pack_start(hbox, true, true, 2);
+
+ align = new Gtk.Alignment(1, 1, 1, 1);
+ align.add(vbox);
+ return align;
}
}
+
diff --git a/src/libease/Element.vala b/src/libease/Element.vala
index e57ed64..092ca97 100644
--- a/src/libease/Element.vala
+++ b/src/libease/Element.vala
@@ -15,390 +15,388 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * An object on a { link Slide}
+ *
+ * While there are several subclasses of { link Actor} for different types
+ * of presentation objects, there is a single Element class. The Element
+ * class uses an { link ElementMap} to store data. The "type" key
+ * specifies the type of Element ("text", "image", "video", etc.)
+ *
+ * For accessing data stored in the { link ElementMap}, Element provides
+ * several convenience properties. Many of these are specific to a single
+ * type of Element, such as the font_name property for text elements.
+ * Accessing these properties in the wrong type of Element will cause
+ * bad things to happen, including the heat death of the universe.
+ */
+public class Ease.Element : GLib.Object
{
+ public Slide parent { get; set; }
+
+ public ElementMap data = new ElementMap();
+
/**
- * An object on a { link Slide}
+ * Create a new element.
*
- * While there are several subclasses of { link Actor} for different types
- * of presentation objects, there is a single Element class. The Element
- * class uses an { link ElementMap} to store data. The "type" key
- * specifies the type of Element ("text", "image", "video", etc.)
+ * @param owner The slide that this Element belongs to.
+ */
+ public Element(Slide owner)
+ {
+ parent = owner;
+ }
+
+ /**
+ * Create a document from a file that already exists.
*
- * For accessing data stored in the { link ElementMap}, Element provides
- * several convenience properties. Many of these are specific to a single
- * type of Element, such as the font_name property for text elements.
- * Accessing these properties in the wrong type of Element will cause
- * bad things to happen, including the heat death of the universe.
+ * Currently, this simply invokes to_xml() on the Element's
+ * { link ElementMap}. Although the { link ElementMap} is a public
+ * field, this could change in the future, so always use to_xml()
+ * on the Element itself.
*/
- public class Element : GLib.Object
+ public string to_xml()
{
- public Slide parent { get; set; }
-
- public ElementMap data = new ElementMap();
-
- /**
- * Create a new element.
- *
- * @param owner The slide that this Element belongs to.
- */
- public Element(Slide owner)
+ return data.to_xml();
+ }
+
+ /**
+ * Creates HTML markup for this Element.
+ *
+ * The <div> tag for this Element is appended to the "HTML" parameter.
+ * This should be inside a <div> tag for the Element's { link Slide}.
+ *
+ * @param html The HTML string in its current state.
+ * @param exporter The { link HTMLExporter}, for the path and progress.
+ * @param amount The amount progress should increase by when done.
+ */
+ public void to_html(ref string html,
+ HTMLExporter exporter,
+ double amount)
+ {
+ switch (data.get("element_type"))
{
- parent = owner;
+ case "image":
+ // open the img tag
+ html += "<img class=\"image element\" ";
+
+ // set the image's style
+ html += "style=\"";
+ html += "left:" + data.get("x") + "px;";
+ html += " top:" + data.get("y") + "px;";
+ html += " width:" + data.get("width") + "px;";
+ html += " height:" + data.get("height") + "px;";
+ html += " position: absolute;\" ";
+
+ // add the image
+ html += "src=\"" + exporter.path + " " +
+ data.get("filename") + "\" alt=\"Image\" />";
+
+ // copy the image file
+ exporter.copy_file(data.get("filename"),
+ parent.parent.path);
+
+ break;
+
+ case "text":
+ // open the tag
+ html += "<div class=\"text element\" ";
+
+ // set the size and position of the element
+ html += "style=\"";
+ html += "left:" + data.get("x") + "px;";
+ html += " top:" + data.get("y") + "px;";
+ html += " width:" + data.get("width") + "px;";
+ html += " height:" + data.get("height") + "px;";
+ html += " position: absolute;";
+
+ // set the text-specific properties of the element
+ html += " color:" + data.get("color").substring(0, 7) +
+ ";";
+
+ html += " font-family:'" + data.get("font_name") +
+ "', sans-serif;";
+
+ html += " font-size:" + data.get("font_size") + "pt;";
+
+ html += " font-weight:" + data.get("font_name").to_int().to_string() +
+ ";";
+ html += " font-style:" + data.get("font_style").down() +
+ ";";
+
+ html += " text-align:" + data.get("align") + ";\"";
+
+ // write the actual content
+ html += ">" + data.get("text").replace("\n", "<br />") +
+ "</div>";
+
+ break;
+
+ case "video":
+ // open the tag
+ html += "<video class=\"video element\" ";
+
+ // set the video's style
+ html += "style=\"";
+ html += "left:" + data.get("x") + "px;";
+ html += " top:" + data.get("y") + "px;";
+ html += " position: absolute;\" ";
+
+ // set the video's size
+ html += " width=\"" + data.get("width") + "\" ";
+ html += " height=\"" + data.get("height") + "\" ";
+
+ // set the video's source and controls
+ html += "src=\"" + exporter.path + " " +
+ data.get("filename") + "\" " +
+ "controls=\"yes\">" +
+ "Your browser does not support the video tag" +
+ "</video>";
+
+ // copy the video file
+ exporter.copy_file(data.get("filename"),
+ parent.parent.path);
+
+ break;
}
- /**
- * Create a document from a file that already exists.
- *
- * Currently, this simply invokes to_xml() on the Element's
- * { link ElementMap}. Although the { link ElementMap} is a public
- * field, this could change in the future, so always use to_xml()
- * on the Element itself.
- */
- public string to_xml()
+ // advance the progress bar
+ exporter.add_progress(amount);
+ }
+
+ // convenience properties
+
+ // base element
+ public string ease_name
+ {
+ set
{
- return data.to_xml();
+ data.set("ease_name", value);
}
-
- /**
- * Creates HTML markup for this Element.
- *
- * The <div> tag for this Element is appended to the "HTML" parameter.
- * This should be inside a <div> tag for the Element's { link Slide}.
- *
- * @param html The HTML string in its current state.
- * @param exporter The { link HTMLExporter}, for the path and progress.
- * @param amount The amount progress should increase by when done.
- */
- public void to_html(ref string html,
- HTMLExporter exporter,
- double amount)
+ }
+
+ public string element_type
+ {
+ set
{
- switch (data.get("element_type"))
- {
- case "image":
- // open the img tag
- html += "<img class=\"image element\" ";
-
- // set the image's style
- html += "style=\"";
- html += "left:" + data.get("x") + "px;";
- html += " top:" + data.get("y") + "px;";
- html += " width:" + data.get("width") + "px;";
- html += " height:" + data.get("height") + "px;";
- html += " position: absolute;\" ";
-
- // add the image
- html += "src=\"" + exporter.path + " " +
- data.get("filename") + "\" alt=\"Image\" />";
-
- // copy the image file
- exporter.copy_file(data.get("filename"),
- parent.parent.path);
-
- break;
-
- case "text":
- // open the tag
- html += "<div class=\"text element\" ";
-
- // set the size and position of the element
- html += "style=\"";
- html += "left:" + data.get("x") + "px;";
- html += " top:" + data.get("y") + "px;";
- html += " width:" + data.get("width") + "px;";
- html += " height:" + data.get("height") + "px;";
- html += " position: absolute;";
-
- // set the text-specific properties of the element
- html += " color:" + data.get("color").substring(0, 7) +
- ";";
-
- html += " font-family:'" + data.get("font_name") +
- "', sans-serif;";
-
- html += " font-size:" + data.get("font_size") + "pt;";
-
- html += " font-weight:" + data.get("font_name").to_int().to_string() +
- ";";
- html += " font-style:" + data.get("font_style").down() +
- ";";
-
- html += " text-align:" + data.get("align") + ";\"";
-
- // write the actual content
- html += ">" + data.get("text").replace("\n", "<br />") +
- "</div>";
-
- break;
-
- case "video":
- // open the tag
- html += "<video class=\"video element\" ";
-
- // set the video's style
- html += "style=\"";
- html += "left:" + data.get("x") + "px;";
- html += " top:" + data.get("y") + "px;";
- html += " position: absolute;\" ";
-
- // set the video's size
- html += " width=\"" + data.get("width") + "\" ";
- html += " height=\"" + data.get("height") + "\" ";
-
- // set the video's source and controls
- html += "src=\"" + exporter.path + " " +
- data.get("filename") + "\" " +
- "controls=\"yes\">" +
- "Your browser does not support the video tag" +
- "</video>";
-
- // copy the video file
- exporter.copy_file(data.get("filename"),
- parent.parent.path);
-
- break;
- }
-
- // advance the progress bar
- exporter.add_progress(amount);
+ data.set("element_type", value);
}
-
- // convenience properties
-
- // base element
- public string ease_name
+ }
+
+ /**
+ * The X position of this Element.
+ */
+ public float x
+ {
+ get
{
- set
- {
- data.set("ease_name", value);
- }
+ return (float)(data.get("x").to_double());
}
-
- public string element_type
+ set
{
- set
- {
- data.set("element_type", value);
- }
+ data.set("x", @"$value");
}
-
- /**
- * The X position of this Element.
- */
- public float x
+ }
+
+ public float y
+ {
+ get
{
- get
- {
- return (float)(data.get("x").to_double());
- }
- set
- {
- data.set("x", @"$value");
- }
+ return (float)(data.get("y").to_double());
}
-
- public float y
+ set
{
- get
- {
- return (float)(data.get("y").to_double());
- }
- set
- {
- data.set("y", @"$value");
- }
+ data.set("y", @"$value");
}
-
- public float width
+ }
+
+ public float width
+ {
+ get
{
- get
- {
- return (float)(data.get("width").to_double());
- }
- set
- {
- data.set("width", @"$value");
- }
+ return (float)(data.get("width").to_double());
}
-
- public float height
+ set
{
- get
- {
- return (float)(data.get("height").to_double());
- }
- set
- {
- data.set("height", @"$value");
- }
+ data.set("width", @"$value");
+ }
+ }
+
+ public float height
+ {
+ get
+ {
+ return (float)(data.get("height").to_double());
+ }
+ set
+ {
+ data.set("height", @"$value");
}
+ }
- // text elements
- public string text
+ // text elements
+ public string text
+ {
+ set
{
- set
- {
- data.set("text", value);
- }
+ data.set("text", value);
}
-
- public Clutter.Color color
+ }
+
+ public Clutter.Color color
+ {
+ get
{
- get
- {
- Clutter.Color c = Clutter.Color();
- c.from_string(data.get("color"));
- return c;
- }
- set
- {
- data.set("color", value.to_string());
- }
+ Clutter.Color c = Clutter.Color();
+ c.from_string(data.get("color"));
+ return c;
+ }
+ set
+ {
+ data.set("color", value.to_string());
}
-
- public string font_name
+ }
+
+ public string font_name
+ {
+ set
{
- set
- {
- data.set("font_name", value);
- }
+ data.set("font_name", value);
}
-
- public Pango.Style font_style
+ }
+
+ public Pango.Style font_style
+ {
+ get
{
- get
- {
- switch (data.get("font_style"))
- {
- case "Oblique":
- return Pango.Style.OBLIQUE;
- case "Italic":
- return Pango.Style.ITALIC;
- default:
- return Pango.Style.NORMAL;
- }
- }
- set
+ switch (data.get("font_style"))
{
- switch (value)
- {
- case Pango.Style.OBLIQUE:
- data.set("font_style", "Oblique");
- break;
- case Pango.Style.ITALIC:
- data.set("font_style", "Italic");
- break;
- case Pango.Style.NORMAL:
- data.set("font_style", "Normal");
- break;
- }
+ case "Oblique":
+ return Pango.Style.OBLIQUE;
+ case "Italic":
+ return Pango.Style.ITALIC;
+ default:
+ return Pango.Style.NORMAL;
}
}
-
- public Pango.Variant font_variant
+ set
{
- get
+ switch (value)
{
- return data.get("font_variant") == "Normal"
- ? Pango.Variant.NORMAL
- : Pango.Variant.SMALL_CAPS;
- }
- set
- {
- data.set("font_name",
- value == Pango.Variant.NORMAL ?
- "Normal" : "Small Caps");
+ case Pango.Style.OBLIQUE:
+ data.set("font_style", "Oblique");
+ break;
+ case Pango.Style.ITALIC:
+ data.set("font_style", "Italic");
+ break;
+ case Pango.Style.NORMAL:
+ data.set("font_style", "Normal");
+ break;
}
}
-
- public Pango.Weight font_weight
+ }
+
+ public Pango.Variant font_variant
+ {
+ get
{
- get
- {
- var str = "font_name";
- return (Pango.Weight)(data.get(str).to_int());
- }
- set
- {
- data.set("font_weight", ((int)value).to_string());
- }
+ return data.get("font_variant") == "Normal"
+ ? Pango.Variant.NORMAL
+ : Pango.Variant.SMALL_CAPS;
}
-
- public Pango.Alignment text_align
+ set
{
- get
- {
- switch (data.get("align"))
- {
- case "right":
- return Pango.Alignment.RIGHT;
- case "center":
- return Pango.Alignment.CENTER;
- default:
- return Pango.Alignment.LEFT;
- }
- }
- set
- {
- switch (value)
- {
- case Pango.Alignment.RIGHT:
- data.set("font_style", "right");
- break;
- case Pango.Alignment.CENTER:
- data.set("font_style", "center");
- break;
- case Pango.Alignment.LEFT:
- data.set("font_style", "left");
- break;
- }
- }
+ data.set("font_name",
+ value == Pango.Variant.NORMAL ?
+ "Normal" : "Small Caps");
}
-
- public int font_size
+ }
+
+ public Pango.Weight font_weight
+ {
+ get
+ {
+ var str = "font_name";
+ return (Pango.Weight)(data.get(str).to_int());
+ }
+ set
+ {
+ data.set("font_weight", ((int)value).to_string());
+ }
+ }
+
+ public Pango.Alignment text_align
+ {
+ get
{
- get
+ switch (data.get("align"))
{
- return data.get("font_size").to_int();
+ case "right":
+ return Pango.Alignment.RIGHT;
+ case "center":
+ return Pango.Alignment.CENTER;
+ default:
+ return Pango.Alignment.LEFT;
}
- set
+ }
+ set
+ {
+ switch (value)
{
- data.set("font_size", @"$value");
+ case Pango.Alignment.RIGHT:
+ data.set("font_style", "right");
+ break;
+ case Pango.Alignment.CENTER:
+ data.set("font_style", "center");
+ break;
+ case Pango.Alignment.LEFT:
+ data.set("font_style", "left");
+ break;
}
}
+ }
+
+ public int font_size
+ {
+ get
+ {
+ return data.get("font_size").to_int();
+ }
+ set
+ {
+ data.set("font_size", @"$value");
+ }
+ }
- // image elements
- public string filename
+ // image elements
+ public string filename
+ {
+ set
{
- set
- {
- data.set("filename", value);
- }
+ data.set("filename", value);
}
-
- public float scale_x
+ }
+
+ public float scale_x
+ {
+ get
{
- get
- {
- return (float)(data.get("scale_x").to_double());
- }
- set
- {
- data.set("scale_x", @"$value");
- }
+ return (float)(data.get("scale_x").to_double());
}
-
- public float scale_y
+ set
{
- get
- {
- return (float)(data.get("scale_y").to_double());
- }
- set
- {
- data.set("scale_y", @"$value");
- }
+ data.set("scale_x", @"$value");
+ }
+ }
+
+ public float scale_y
+ {
+ get
+ {
+ return (float)(data.get("scale_y").to_double());
+ }
+ set
+ {
+ data.set("scale_y", @"$value");
}
}
}
+
diff --git a/src/libease/ElementMap.vala b/src/libease/ElementMap.vala
index c7cff0d..de1d2f9 100644
--- a/src/libease/ElementMap.vala
+++ b/src/libease/ElementMap.vala
@@ -15,94 +15,92 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * Contains data about an { link Element}
+ *
+ * ElementMap contains a Gee.Map with string keys and
+ * { link ElementMapValue} values. Each { link Element} has exactly one
+ * ElementMap, which stores all data about its owner.
+ *
+ * The vast majority of XML conversion of { link Element}s is done by
+ * ElementMap.
+ */
+public class Ease.ElementMap
{
+ private Gee.Map<string, ElementMapValue> map;
+
/**
- * Contains data about an { link Element}
+ * Creates an ElementMap.
+ *
+ * The ElementMap class stores data about an { link Element}, allowing
+ * for a single class to represent every type of { link Element}, with
+ * less type checking.
*
- * ElementMap contains a Gee.Map with string keys and
- * { link ElementMapValue} values. Each { link Element} has exactly one
- * ElementMap, which stores all data about its owner.
- *
- * The vast majority of XML conversion of { link Element}s is done by
- * ElementMap.
+ * @param filename The path to the filename.
*/
- public class ElementMap
+ public ElementMap()
{
- private Gee.Map<string, ElementMapValue> map;
-
- /**
- * Creates an ElementMap.
- *
- * The ElementMap class stores data about an { link Element}, allowing
- * for a single class to represent every type of { link Element}, with
- * less type checking.
- *
- * @param filename The path to the filename.
- */
- public ElementMap()
- {
- map = new Gee.HashMap<string, ElementMapValue>();
- }
+ map = new Gee.HashMap<string, ElementMapValue>();
+ }
+
+ /**
+ * Output this ElementData as XML.
+ *
+ * Returns an XML string of the represented { link Element}'s
+ * data. Called by the represented { link Element} when that
+ * object's to_xml() method is called.
+ */
+ public string to_xml()
+ {
+ string xml = "", text = "";
- /**
- * Output this ElementData as XML.
- *
- * Returns an XML string of the represented { link Element}'s
- * data. Called by the represented { link Element} when that
- * object's to_xml() method is called.
- */
- public string to_xml()
+ foreach (var key in map.keys)
{
- string xml = "", text = "";
-
- foreach (var key in map.keys)
+ if (key != "text")
{
- if (key != "text")
- {
- xml += key + "=\"" + get(key) + "\" ";
- }
- else
- {
- text = get(key);
- }
- }
- return text == ""
- ? "\t\t\t<element " + xml + "/>\n"
- : "\t\t\t<element " + xml + ">" + text + "</element>\n";
- }
-
- /**
- * Set a value.
- *
- * ElementMap uses a key/value system to make exporting XML and adding
- * new types of Elements easy.
- *
- * @param key The map key.
- * @param val A string to be stored as the key's value.
- */
- public void set(string key, string val)
- {
- if (map.has_key(key))
- {
- map.get(key).str_val = val;
+ xml += key + "=\"" + get(key) + "\" ";
}
else
{
- var value = new ElementMapValue();
- value.str_val = val;
- map.set(key, value);
+ text = get(key);
}
}
+ return text == ""
+ ? "\t\t\t<element " + xml + "/>\n"
+ : "\t\t\t<element " + xml + ">" + text + "</element>\n";
+ }
- /**
- * Get a value, given a key.
- *
- * @param key The key to get a value for.
- */
- public string get(string key)
+ /**
+ * Set a value.
+ *
+ * ElementMap uses a key/value system to make exporting XML and adding
+ * new types of Elements easy.
+ *
+ * @param key The map key.
+ * @param val A string to be stored as the key's value.
+ */
+ public void set(string key, string val)
+ {
+ if (map.has_key(key))
{
- return map.get(key).str_val;
+ map.get(key).str_val = val;
+ }
+ else
+ {
+ var value = new ElementMapValue();
+ value.str_val = val;
+ map.set(key, value);
}
}
+
+ /**
+ * Get a value, given a key.
+ *
+ * @param key The key to get a value for.
+ */
+ public string get(string key)
+ {
+ return map.get(key).str_val;
+ }
}
+
diff --git a/src/libease/ElementMapValue.vala b/src/libease/ElementMapValue.vala
index 02a55b3..bb352c4 100644
--- a/src/libease/ElementMapValue.vala
+++ b/src/libease/ElementMapValue.vala
@@ -15,13 +15,11 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * Stores data in an { link ElementMap}
+ */
+public class Ease.ElementMapValue
{
- /**
- * Stores data in an { link ElementMap}
- */
- public class ElementMapValue
- {
- public string str_val { get; set; }
- }
+ public string str_val { get; set; }
}
+
diff --git a/src/libease/HTMLExporter.vala b/src/libease/HTMLExporter.vala
index d5755f8..61137d0 100644
--- a/src/libease/HTMLExporter.vala
+++ b/src/libease/HTMLExporter.vala
@@ -15,134 +15,132 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * Exports Ease { link Document}s as HTML5 files
+ *
+ * HTMLExporter creates a save dialog and a progress dialog. The actual
+ * exporting is done with the { link Document}, { link Slide}, and
+ * { link Element} classes. The exported { link Document} reports back to
+ * HTMLExported when the export is complete, allowing the dialog to close.
+ *
+ * HTMLExporter also handles copying media files to the output directory.
+ */
+public class Ease.HTMLExporter : GLib.Object
{
+ private Gtk.Dialog window;
+ private Gtk.ProgressBar progress;
+
+ public string path { get; private set; }
+
+ public HTMLExporter()
+ {
+ progress = new Gtk.ProgressBar();
+ }
+
/**
- * Exports Ease { link Document}s as HTML5 files
- *
- * HTMLExporter creates a save dialog and a progress dialog. The actual
- * exporting is done with the { link Document}, { link Slide}, and
- * { link Element} classes. The exported { link Document} reports back to
- * HTMLExported when the export is complete, allowing the dialog to close.
+ * Asks the user for an output path
*
- * HTMLExporter also handles copying media files to the output directory.
+ * Shows a file chooser dialog. If the user does not cancel the export,
+ * creates a the progress dialog. Returns false if the user cancels,
+ * otherwise returns true.
+ *
+ * @param win The window that the dialog should be modal for
*/
- public class HTMLExporter : GLib.Object
+ public bool request_path(Gtk.Window win)
{
- private Gtk.Dialog window;
- private Gtk.ProgressBar progress;
-
- public string path { get; private set; }
-
- public HTMLExporter()
- {
- progress = new Gtk.ProgressBar();
- }
+ var dialog = new Gtk.FileChooserDialog("Export to HTML",
+ win,
+ Gtk.FileChooserAction.SAVE,
+ "gtk-save",
+ Gtk.ResponseType.ACCEPT,
+ "gtk-cancel",
+ Gtk.ResponseType.CANCEL,
+ null);
- /**
- * Asks the user for an output path
- *
- * Shows a file chooser dialog. If the user does not cancel the export,
- * creates a the progress dialog. Returns false if the user cancels,
- * otherwise returns true.
- *
- * @param win The window that the dialog should be modal for
- */
- public bool request_path(Gtk.Window win)
+ if (dialog.run() == Gtk.ResponseType.ACCEPT)
{
- var dialog = new Gtk.FileChooserDialog("Export to HTML",
- win,
- Gtk.FileChooserAction.SAVE,
- "gtk-save",
- Gtk.ResponseType.ACCEPT,
- "gtk-cancel",
- Gtk.ResponseType.CANCEL,
- null);
+ // clean up the file dialog
+ path = dialog.get_filename();
+ dialog.destroy();
- if (dialog.run() == Gtk.ResponseType.ACCEPT)
- {
- // clean up the file dialog
- path = dialog.get_filename();
- dialog.destroy();
-
- // create the progress dialog
- window = new Gtk.Dialog();
- window.width_request = 400;
- window.set_title("Exporting as HTML");
- Gtk.VBox vbox = (Gtk.VBox)(window.get_content_area());
- vbox.pack_start(progress, true, true, 5);
- window.show_all();
-
- return true;
- }
- else
- {
- dialog.destroy();
- return false;
- }
- }
-
- /**
- * Adds to the progress dialog's progress bar, which ranges from 0 to 1
- *
- * @param amount The amount of progress to add
- */
- public void add_progress(double amount)
- {
- progress.set_fraction(progress.get_fraction() + amount);
+ // create the progress dialog
+ window = new Gtk.Dialog();
+ window.width_request = 400;
+ window.set_title("Exporting as HTML");
+ Gtk.VBox vbox = (Gtk.VBox)(window.get_content_area());
+ vbox.pack_start(progress, true, true, 5);
+ window.show_all();
+
+ return true;
}
-
- /**
- * Finishes exporting and hides the progress dialog
- */
- public void finish()
+ else
{
- window.hide_all();
- window.destroy();
+ dialog.destroy();
+ return false;
}
-
- /**
- * Copies a file to the output path
- *
- * To show images or videos in an HTML presentation, they must be
- * copied to a path relative to the HTML document.
- *
- * @param end_path The file's path relative to the Ease file
- * @param base_path The output directory and filename
- */
- public void copy_file(string end_path, string base_path)
- {
- var source = File.new_for_path(base_path + "/" + end_path);
- var destination = File.new_for_path(path + " " + end_path);
+ }
+
+ /**
+ * Adds to the progress dialog's progress bar, which ranges from 0 to 1
+ *
+ * @param amount The amount of progress to add
+ */
+ public void add_progress(double amount)
+ {
+ progress.set_fraction(progress.get_fraction() + amount);
+ }
+
+ /**
+ * Finishes exporting and hides the progress dialog
+ */
+ public void finish()
+ {
+ window.hide_all();
+ window.destroy();
+ }
+
+ /**
+ * Copies a file to the output path
+ *
+ * To show images or videos in an HTML presentation, they must be
+ * copied to a path relative to the HTML document.
+ *
+ * @param end_path The file's path relative to the Ease file
+ * @param base_path The output directory and filename
+ */
+ public void copy_file(string end_path, string base_path)
+ {
+ var source = File.new_for_path(base_path + "/" + end_path);
+ var destination = File.new_for_path(path + " " + end_path);
- try
- {
- // if the destination directory doesn't exist, make it
- var parent = destination.get_parent();
- if (!parent.query_exists(null))
- {
- parent.make_directory_with_parents(null);
- }
-
- // copy the image
- source.copy(destination,
- FileCopyFlags.OVERWRITE,
- null,
- null);
- }
- catch (GLib.Error e)
+ try
+ {
+ // if the destination directory doesn't exist, make it
+ var parent = destination.get_parent();
+ if (!parent.query_exists(null))
{
- var dialog = new Gtk.MessageDialog(null,
- Gtk.DialogFlags.NO_SEPARATOR,
- Gtk.MessageType.ERROR,
- Gtk.ButtonsType.CLOSE,
- "Error copying: %s",
- e. message);
- dialog.title = "Error Copying File";
- dialog.border_width = 5;
- dialog.run();
- dialog.destroy();
+ parent.make_directory_with_parents(null);
}
+
+ // copy the image
+ source.copy(destination,
+ FileCopyFlags.OVERWRITE,
+ null,
+ null);
+ }
+ catch (GLib.Error e)
+ {
+ var dialog = new Gtk.MessageDialog(null,
+ Gtk.DialogFlags.NO_SEPARATOR,
+ Gtk.MessageType.ERROR,
+ Gtk.ButtonsType.CLOSE,
+ "Error copying: %s",
+ e. message);
+ dialog.title = "Error Copying File";
+ dialog.border_width = 5;
+ dialog.run();
+ dialog.destroy();
}
}
}
+
diff --git a/src/libease/Handle.vala b/src/libease/Handle.vala
index 452c4ce..daa3314 100644
--- a/src/libease/Handle.vala
+++ b/src/libease/Handle.vala
@@ -15,93 +15,91 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+public class Ease.Handle : Clutter.Group
{
- public class Handle : Clutter.Group
- {
- // the graphical element of the rectangle
- private Clutter.Rectangle rectangle;
-
- // the position of this rectangle
- private HandlePosition position;
+ // the graphical element of the rectangle
+ private Clutter.Rectangle rectangle;
+
+ // the position of this rectangle
+ private HandlePosition position;
- // the offset of the pointer, so things don't jump
- private int pointer_offset_x;
- private int pointer_offset_y;
-
- // constants
- public static const float SIZE = 10;
-
- public Handle(HandlePosition pos)
- {
- // set the rectangle's position
- position = pos;
+ // the offset of the pointer, so things don't jump
+ private int pointer_offset_x;
+ private int pointer_offset_y;
+
+ // constants
+ public static const float SIZE = 10;
+
+ public Handle(HandlePosition pos)
+ {
+ // set the rectangle's position
+ position = pos;
- // make the actual rectangle
- rectangle = new Clutter.Rectangle();
+ // make the actual rectangle
+ rectangle = new Clutter.Rectangle();
- // set the rectangle's color
- rectangle.color = {0, 0, 0, 255};
+ // set the rectangle's color
+ rectangle.color = {0, 0, 0, 255};
- // set the rectangle's border
- rectangle.border_width = 2;
- rectangle.border_color = {255, 255, 255, 255};
+ // set the rectangle's border
+ rectangle.border_width = 2;
+ rectangle.border_color = {255, 255, 255, 255};
- // set the rectangle's size
- rectangle.width = SIZE;
- rectangle.height = SIZE;
- set_anchor_point(SIZE / 2, SIZE / 2);
+ // set the rectangle's size
+ rectangle.width = SIZE;
+ rectangle.height = SIZE;
+ set_anchor_point(SIZE / 2, SIZE / 2);
- // add the rectangle
- add_actor(rectangle);
-
- reactive = true;
- }
+ // add the rectangle
+ add_actor(rectangle);
- public void reposition(Clutter.Actor selection)
+ reactive = true;
+ }
+
+ public void reposition(Clutter.Actor selection)
+ {
+ switch (position)
{
- switch (position)
- {
- case HandlePosition.TOP_LEFT:
- x = selection.x;
- y = selection.y;
- break;
-
- case HandlePosition.TOP_RIGHT:
- x = selection.x + selection.width;
- y = selection.y;
- break;
-
- case HandlePosition.TOP:
- x = selection.x + selection.width / 2;
- y = selection.y;
- break;
-
- case HandlePosition.LEFT:
- x = selection.x;
- y = selection.y + selection.height / 2;
- break;
-
- case HandlePosition.RIGHT:
- x = selection.x + selection.width;
- y = selection.y + selection.height / 2;
- break;
-
- case HandlePosition.BOTTOM_LEFT:
- x = selection.x;
- y = selection.y + selection.height;
- break;
-
- case HandlePosition.BOTTOM_RIGHT:
- x = selection.x + selection.width;
- y = selection.y + selection.height;
- break;
-
- case HandlePosition.BOTTOM:
- x = selection.x + selection.width / 2;
- y = selection.y + selection.height;
- break;
- }
+ case HandlePosition.TOP_LEFT:
+ x = selection.x;
+ y = selection.y;
+ break;
+
+ case HandlePosition.TOP_RIGHT:
+ x = selection.x + selection.width;
+ y = selection.y;
+ break;
+
+ case HandlePosition.TOP:
+ x = selection.x + selection.width / 2;
+ y = selection.y;
+ break;
+
+ case HandlePosition.LEFT:
+ x = selection.x;
+ y = selection.y + selection.height / 2;
+ break;
+
+ case HandlePosition.RIGHT:
+ x = selection.x + selection.width;
+ y = selection.y + selection.height / 2;
+ break;
+
+ case HandlePosition.BOTTOM_LEFT:
+ x = selection.x;
+ y = selection.y + selection.height;
+ break;
+
+ case HandlePosition.BOTTOM_RIGHT:
+ x = selection.x + selection.width;
+ y = selection.y + selection.height;
+ break;
+
+ case HandlePosition.BOTTOM:
+ x = selection.x + selection.width / 2;
+ y = selection.y + selection.height;
+ break;
}
}
}
+
diff --git a/src/libease/ImageActor.vala b/src/libease/ImageActor.vala
index c98cda3..6a5c916 100644
--- a/src/libease/ImageActor.vala
+++ b/src/libease/ImageActor.vala
@@ -15,47 +15,45 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * { link Actor} for images
+ *
+ * ImageActor can represent either a bitmap or vector image, as it is
+ * backed by { link Clutter.Texture}. This should be automatically
+ * handled by the represented { link Element} and Clutter.
+ */
+public class Ease.ImageActor : Actor
{
/**
- * { link Actor} for images
- *
+ * Instantiates a new ImageActor from an Element.
+ *
* ImageActor can represent either a bitmap or vector image, as it is
* backed by { link Clutter.Texture}. This should be automatically
* handled by the represented { link Element} and Clutter.
+ *
+ * @param e The represented element.
+ * @param c The context of this Actor (Presentation, Sidebar, Editor)
*/
- public class ImageActor : Actor
+ public ImageActor(Element e, ActorContext c)
{
- /**
- * Instantiates a new ImageActor from an Element.
- *
- * ImageActor can represent either a bitmap or vector image, as it is
- * backed by { link Clutter.Texture}. This should be automatically
- * handled by the represented { link Element} and Clutter.
- *
- * @param e The represented element.
- * @param c The context of this Actor (Presentation, Sidebar, Editor)
- */
- public ImageActor(Element e, ActorContext c)
+ base(e, c);
+
+ try
+ {
+ contents = new Clutter.Texture.from_file(e.parent.parent.path + e.data.get("filename"));
+ }
+ catch (GLib.Error e)
{
- base(e, c);
-
- try
- {
- contents = new Clutter.Texture.from_file(e.parent.parent.path + e.data.get("filename"));
- }
- catch (GLib.Error e)
- {
- stdout.printf("Error loading ImageActor: %s", e.message);
- }
- finally
- {
- add_actor(contents);
- contents.width = e.width;
- contents.height = e.height;
- x = e.x;
- y = e.y;
- }
+ stdout.printf("Error loading ImageActor: %s", e.message);
+ }
+ finally
+ {
+ add_actor(contents);
+ contents.width = e.width;
+ contents.height = e.height;
+ x = e.x;
+ y = e.y;
}
}
}
+
diff --git a/src/libease/Main.vala b/src/libease/Main.vala
index 784f966..65eb422 100644
--- a/src/libease/Main.vala
+++ b/src/libease/Main.vala
@@ -15,176 +15,174 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * Handles core actions in Ease
+ *
+ * When Ease starts, the simple C main function calls a function in this
+ * class. Main then initializes GTK, Clutter, and anything else.
+ *
+ * Main keeps track of { link EditorWindow}s, as well as the status of the
+ * single { link WelcomeWindow}. Main will end Ease if none of these are
+ * shown on the screen.
+ */
+public static class Ease.Main : GLib.Object
{
+ private static Gee.ArrayList<EditorWindow> windows;
+ private static WelcomeWindow welcome;
+
/**
- * Handles core actions in Ease
- *
- * When Ease starts, the simple C main function calls a function in this
- * class. Main then initializes GTK, Clutter, and anything else.
+ * Start Ease to edit files.
*
- * Main keeps track of { link EditorWindow}s, as well as the status of the
- * single { link WelcomeWindow}. Main will end Ease if none of these are
- * shown on the screen.
+ * If the user runs Ease with a filename as a parameter, this function
+ * will open an { link EditorWindow}. Otherwise, a { link WelcomeWindow}
+ * will be opened.
+ *
+ * @param argc Standard argc, passed through from C.
+ * @param argv Standard argv, passed through from C.
*/
- public static class Main : GLib.Object
+ public static int main_editor(int argc, char** argv)
{
- private static Gee.ArrayList<EditorWindow> windows;
- private static WelcomeWindow welcome;
-
- /**
- * Start Ease to edit files.
- *
- * If the user runs Ease with a filename as a parameter, this function
- * will open an { link EditorWindow}. Otherwise, a { link WelcomeWindow}
- * will be opened.
- *
- * @param argc Standard argc, passed through from C.
- * @param argv Standard argv, passed through from C.
- */
- public static int main_editor(int argc, char** argv)
+ string[] args = new string[argc];
+ for (var i = 0; i < argc; i++)
{
- string[] args = new string[argc];
- for (var i = 0; i < argc; i++)
- {
- args[i] = (string)argv[i];
- }
-
- GtkClutter.init(ref args);
- Gst.init(ref args);
- ClutterGst.init(ref args);
-
- // initalize static classes
- Transitions.init();
- OpenDialog.init();
- windows = new Gee.ArrayList<EditorWindow>();
-
- if (args.length == 2)
- {
- test_editor(args[1]);
- }
- else
- {
- show_welcome();
- }
-
- Gtk.main();
-
- return 0;
+ args[i] = (string)argv[i];
}
- /**
- * Starts Ease to play back a file.
- *
- * This function is primarily used by the ease-player executable. It runs
- * the slideshow, then exits. If no filename is given, it immediately
- * returns.
- *
- * @param argc Standard argc, passed through from C.
- * @param argv Standard argv, passed through from C.
- */
- public static int main_player(int argc, char** argv)
+ GtkClutter.init(ref args);
+ Gst.init(ref args);
+ ClutterGst.init(ref args);
+
+ // initalize static classes
+ Transitions.init();
+ OpenDialog.init();
+ windows = new Gee.ArrayList<EditorWindow>();
+
+ if (args.length == 2)
{
- string[] args = new string[argc];
- for (var i = 0; i < argc; i++)
- {
- args[i] = (string)argv[i];
- }
-
- if (args.length < 2)
- {
- return 0;
- }
-
- GtkClutter.init(ref args);
- Gst.init(ref args);
- ClutterGst.init(ref args);
-
- var doc = new Document.from_file(args[1]);
- var player = new Player(doc);
- player.stage.hide.connect(() => {
- Gtk.main_quit();
- });
-
- Gtk.main();
-
- return 0;
+ test_editor(args[1]);
}
-
- public static void test_editor(string path)
+ else
{
- add_window(new EditorWindow(path));
+ show_welcome();
}
- /**
- * Removes an { link EditorWindow} from Ease's internal store of windows.
- *
- * Ease tracks the current windows in order to properly quit when there
- * are no { link EditorWindow}s on screen and the { link WelcomeWindow} is
- * hidden. This function will quit Ease if the removed window is the final
- * window and the { link WelcomeWindow} is hidden.
- *
- * @param win The { link EditorWindow}.
- */
- public static void remove_window(EditorWindow win)
+ Gtk.main();
+
+ return 0;
+ }
+
+ /**
+ * Starts Ease to play back a file.
+ *
+ * This function is primarily used by the ease-player executable. It runs
+ * the slideshow, then exits. If no filename is given, it immediately
+ * returns.
+ *
+ * @param argc Standard argc, passed through from C.
+ * @param argv Standard argv, passed through from C.
+ */
+ public static int main_player(int argc, char** argv)
+ {
+ string[] args = new string[argc];
+ for (var i = 0; i < argc; i++)
{
- windows.remove(win);
- if (windows.size == 0 && welcome == null)
- {
- Gtk.main_quit();
- }
+ args[i] = (string)argv[i];
}
- /**
- * Adds an { link EditorWindow} to Ease's internal store of windows.
- *
- * Ease tracks the current windows in order to properly quit when there
- * are no { link EditorWindow}s on screen and the { link WelcomeWindow} is
- * hidden.
- *
- * @param win The { link EditorWindow}.
- */
- public static void add_window(EditorWindow win)
+ if (args.length < 2)
{
- windows.add(win);
+ return 0;
}
- /**
- * Shows the { link WelcomeWindow}
- *
- * Shows the { link WelcomeWindow}, or raises it to the top if it is not
- * already displayed.
- *
- */
- public static void show_welcome()
+ GtkClutter.init(ref args);
+ Gst.init(ref args);
+ ClutterGst.init(ref args);
+
+ var doc = new Document.from_file(args[1]);
+ var player = new Player(doc);
+ player.stage.hide.connect(() => {
+ Gtk.main_quit();
+ });
+
+ Gtk.main();
+
+ return 0;
+ }
+
+ public static void test_editor(string path)
+ {
+ add_window(new EditorWindow(path));
+ }
+
+ /**
+ * Removes an { link EditorWindow} from Ease's internal store of windows.
+ *
+ * Ease tracks the current windows in order to properly quit when there
+ * are no { link EditorWindow}s on screen and the { link WelcomeWindow} is
+ * hidden. This function will quit Ease if the removed window is the final
+ * window and the { link WelcomeWindow} is hidden.
+ *
+ * @param win The { link EditorWindow}.
+ */
+ public static void remove_window(EditorWindow win)
+ {
+ windows.remove(win);
+ if (windows.size == 0 && welcome == null)
{
- if (welcome == null)
- {
- welcome = new WelcomeWindow();
- welcome.hide.connect(() => remove_welcome());
- }
- else
- {
- welcome.present();
- }
+ Gtk.main_quit();
}
-
- /**
- * Hides the { link WelcomeWindow}.
- *
- * It's important to call this function when the { link WelcomeWindow} is
- * hidden, so that Ease can properly exit when all windows are closed.
- * When the { link WelcomeWindow} is shown via show_welcome, this function
- * is automatically added in that window's hide signal handler.
- */
- public static void remove_welcome()
+ }
+
+ /**
+ * Adds an { link EditorWindow} to Ease's internal store of windows.
+ *
+ * Ease tracks the current windows in order to properly quit when there
+ * are no { link EditorWindow}s on screen and the { link WelcomeWindow} is
+ * hidden.
+ *
+ * @param win The { link EditorWindow}.
+ */
+ public static void add_window(EditorWindow win)
+ {
+ windows.add(win);
+ }
+
+ /**
+ * Shows the { link WelcomeWindow}
+ *
+ * Shows the { link WelcomeWindow}, or raises it to the top if it is not
+ * already displayed.
+ *
+ */
+ public static void show_welcome()
+ {
+ if (welcome == null)
+ {
+ welcome = new WelcomeWindow();
+ welcome.hide.connect(() => remove_welcome());
+ }
+ else
+ {
+ welcome.present();
+ }
+ }
+
+ /**
+ * Hides the { link WelcomeWindow}.
+ *
+ * It's important to call this function when the { link WelcomeWindow} is
+ * hidden, so that Ease can properly exit when all windows are closed.
+ * When the { link WelcomeWindow} is shown via show_welcome, this function
+ * is automatically added in that window's hide signal handler.
+ */
+ public static void remove_welcome()
+ {
+ welcome.hide_all();
+ welcome = null;
+ if (windows.size == 0)
{
- welcome.hide_all();
- welcome = null;
- if (windows.size == 0)
- {
- Gtk.main_quit();
- }
+ Gtk.main_quit();
}
}
}
+
diff --git a/src/libease/MainToolbar.vala b/src/libease/MainToolbar.vala
index f0f8f0d..20aab06 100644
--- a/src/libease/MainToolbar.vala
+++ b/src/libease/MainToolbar.vala
@@ -15,64 +15,62 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * The main toolbar of an { link EditorWindow}
+ *
+ * MainToolbar exists solely to be added to the top of an
+ * { link EditorWindow}. Creating a subclass of Gtk.Toolbar keeps the
+ * { link EditorWindow} source somewhat cleaner, and allows for easy
+ * changes to the toolbar.
+ */
+public class MainToolbar : Gtk.Toolbar
{
+ public Gtk.ToolButton new_slide;
+ public Gtk.ToolButton play;
+ public Gtk.ToolButton save;
+ public Gtk.ToolButton new_presentation;
+ public Gtk.ToolButton open;
+ public Gtk.ToolButton inspector;
+ public Gtk.ToolButton slides;
+ public Gtk.ToolButton fonts;
+ public Gtk.ToolButton colors;
+
/**
- * The main toolbar of an { link EditorWindow}
- *
- * MainToolbar exists solely to be added to the top of an
- * { link EditorWindow}. Creating a subclass of Gtk.Toolbar keeps the
- * { link EditorWindow} source somewhat cleaner, and allows for easy
- * changes to the toolbar.
+ * Builds the main toolbar of an { link EditorWindow}.
+ *
+ * All fields are public, allowing the { link EditorWindow} to attach
+ * signal handlers.
+ *
*/
- public class MainToolbar : Gtk.Toolbar
+ public MainToolbar()
{
- public Gtk.ToolButton new_slide;
- public Gtk.ToolButton play;
- public Gtk.ToolButton save;
- public Gtk.ToolButton new_presentation;
- public Gtk.ToolButton open;
- public Gtk.ToolButton inspector;
- public Gtk.ToolButton slides;
- public Gtk.ToolButton fonts;
- public Gtk.ToolButton colors;
+ // tool buttons
+ new_slide = new Gtk.ToolButton.from_stock("gtk-add");
+ play = new Gtk.ToolButton.from_stock("gtk-media-play");
+ new_presentation = new Gtk.ToolButton.from_stock("gtk-new");
+ save = new Gtk.ToolButton.from_stock("gtk-save");
+ open = new Gtk.ToolButton.from_stock("gtk-open");
+ slides = new Gtk.ToolButton.from_stock("gtk-dnd-multiple");
+ inspector = new Gtk.ToolButton.from_stock("gtk-info");
+ colors = new Gtk.ToolButton.from_stock("gtk-select-color");
+ fonts = new Gtk.ToolButton.from_stock("gtk-select-font");
- /**
- * Builds the main toolbar of an { link EditorWindow}.
- *
- * All fields are public, allowing the { link EditorWindow} to attach
- * signal handlers.
- *
- */
- public MainToolbar()
- {
- // tool buttons
- new_slide = new Gtk.ToolButton.from_stock("gtk-add");
- play = new Gtk.ToolButton.from_stock("gtk-media-play");
- new_presentation = new Gtk.ToolButton.from_stock("gtk-new");
- save = new Gtk.ToolButton.from_stock("gtk-save");
- open = new Gtk.ToolButton.from_stock("gtk-open");
- slides = new Gtk.ToolButton.from_stock("gtk-dnd-multiple");
- inspector = new Gtk.ToolButton.from_stock("gtk-info");
- colors = new Gtk.ToolButton.from_stock("gtk-select-color");
- fonts = new Gtk.ToolButton.from_stock("gtk-select-font");
-
- // add buttons
- insert(new_slide, -1);
- insert(play, -1);
- insert(new Gtk.SeparatorToolItem(), -1);
- insert(new_presentation, -1);
- insert(open, -1);
- insert(save, -1);
- insert(new Gtk.SeparatorToolItem(), -1);
- insert(slides, -1);
- insert(inspector, -1);
- insert(new Gtk.SeparatorToolItem(), -1);
- insert(fonts, -1);
- insert(colors, -1);
-
- // format toolbar
- toolbar_style = Gtk.ToolbarStyle.ICONS;
- }
+ // add buttons
+ insert(new_slide, -1);
+ insert(play, -1);
+ insert(new Gtk.SeparatorToolItem(), -1);
+ insert(new_presentation, -1);
+ insert(open, -1);
+ insert(save, -1);
+ insert(new Gtk.SeparatorToolItem(), -1);
+ insert(slides, -1);
+ insert(inspector, -1);
+ insert(new Gtk.SeparatorToolItem(), -1);
+ insert(fonts, -1);
+ insert(colors, -1);
+
+ // format toolbar
+ toolbar_style = Gtk.ToolbarStyle.ICONS;
}
}
+
diff --git a/src/libease/OpenDialog.vala b/src/libease/OpenDialog.vala
index 869679f..3be0b0e 100644
--- a/src/libease/OpenDialog.vala
+++ b/src/libease/OpenDialog.vala
@@ -15,50 +15,47 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * Manages "open file" windows
+ *
+ * OpenDialog is a singleton. Before it can be used, init() must be
+ * called. After that, a dialog can be opened by calling the static
+ * method run().
+ */
+public class Ease.OpenDialog : GLib.Object
{
+ private static OpenDialog instance;
+
/**
- * Manages "open file" windows
+ * Initializes OpenDialog. Called when Ease starts.
+ */
+ public static void init()
+ {
+ instance = new OpenDialog();
+ }
+
+ /**
+ * Displays an "Open" dialog.
*
- * OpenDialog is a singleton. Before it can be used, init() must be
- * called. After that, a dialog can be opened by calling the static
- * method run().
+ * Used for loading previously saved files. This is a static method.
*/
- public class OpenDialog : GLib.Object
+ public static void run()
{
- private static OpenDialog instance;
-
- /**
- * Initializes OpenDialog. Called when Ease starts.
- */
- public static void init()
- {
- instance = new OpenDialog();
- }
-
- /**
- * Displays an "Open" dialog.
- *
- * Used for loading previously saved files. This is a static method.
- */
- public static void run()
- {
- instance.instance_run();
- }
+ instance.instance_run();
+ }
- private void instance_run()
- {
- var dialog = new Gtk.FileChooserDialog("Open File",
- null,
- Gtk.FileChooserAction.SELECT_FOLDER,
- "gtk-cancel", Gtk.ResponseType.CANCEL,
- "gtk-open", Gtk.ResponseType.ACCEPT, null);
+ private void instance_run()
+ {
+ var dialog = new Gtk.FileChooserDialog("Open File",
+ null,
+ Gtk.FileChooserAction.SELECT_FOLDER,
+ "gtk-cancel", Gtk.ResponseType.CANCEL,
+ "gtk-open", Gtk.ResponseType.ACCEPT, null);
- if (dialog.run() == Gtk.ResponseType.ACCEPT)
- {
- Main.test_editor(dialog.get_filename() + "/");
- }
- dialog.destroy();
+ if (dialog.run() == Gtk.ResponseType.ACCEPT)
+ {
+ Main.test_editor(dialog.get_filename() + "/");
}
+ dialog.destroy();
}
}
diff --git a/src/libease/Player.vala b/src/libease/Player.vala
index 72fe2fc..6ec4d3e 100644
--- a/src/libease/Player.vala
+++ b/src/libease/Player.vala
@@ -15,175 +15,173 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * Presents a { link Document}
+ *
+ * The Ease Player uses ClutterGtk to create a stage floated in the center
+ * of a fullscreen Gtk.Window.
+ */
+public class Ease.Player : GLib.Object
{
- /**
- * Presents a { link Document}
- *
- * The Ease Player uses ClutterGtk to create a stage floated in the center
- * of a fullscreen Gtk.Window.
- */
- public class Player : GLib.Object
+ public Document document { get; set; }
+ public int slide_index { get; set; }
+ public Clutter.Stage stage { get; set; }
+ private bool can_animate { get; set; }
+ private Gtk.Window window;
+
+ // current and transitioning out slide
+ private SlideActor current_slide;
+ private SlideActor old_slide;
+ private Clutter.Group stack_container;
+
+ // constants
+ public const bool PRESENTATION_FULLSCREEN = false;
+
+ public Player(Document doc)
{
- public Document document { get; set; }
- public int slide_index { get; set; }
- public Clutter.Stage stage { get; set; }
- private bool can_animate { get; set; }
- private Gtk.Window window;
+ document = doc;
+ slide_index = -1;
- // current and transitioning out slide
- private SlideActor current_slide;
- private SlideActor old_slide;
- private Clutter.Group stack_container;
+ var embed = new GtkClutter.Embed();
+ embed.set_size_request(document.width, document.height);
- // constants
- public const bool PRESENTATION_FULLSCREEN = false;
-
- public Player(Document doc)
- {
- document = doc;
- slide_index = -1;
-
- var embed = new GtkClutter.Embed();
- embed.set_size_request(document.width, document.height);
-
- stage = (Clutter.Stage)embed.get_stage();
- stage.width = document.width;
- stage.height = document.height;
- stage.title = "Ease Presentation";
-
- stage.set_fullscreen(PRESENTATION_FULLSCREEN);
- stage.hide_cursor();
-
- stage.show_all();
- Clutter.Color color = Clutter.Color();
- color.from_string("Black");
- stage.color = color;
- Clutter.grab_keyboard(stage);
+ stage = (Clutter.Stage)embed.get_stage();
+ stage.width = document.width;
+ stage.height = document.height;
+ stage.title = "Ease Presentation";
+
+ stage.set_fullscreen(PRESENTATION_FULLSCREEN);
+ stage.hide_cursor();
+
+ stage.show_all();
+ Clutter.Color color = Clutter.Color();
+ color.from_string("Black");
+ stage.color = color;
+ Clutter.grab_keyboard(stage);
- // make the stacking container
- stack_container = new Clutter.Group();
- stage.add_actor(stack_container);
-
- // make the window that everything will be displayed in
- window = new Gtk.Window(Gtk.WindowType.TOPLEVEL);
- Gdk.Color color2 = Gdk.Color();
- color2.red = 0;
- color2.green = 0;
- color2.blue = 0;
- window.modify_bg(Gtk.StateType.NORMAL, color2);
-
- // center the stage in the window
- var align = new Gtk.Alignment(0.5f, 0.5f, 0, 0);
- align.add(embed);
+ // make the stacking container
+ stack_container = new Clutter.Group();
+ stage.add_actor(stack_container);
+
+ // make the window that everything will be displayed in
+ window = new Gtk.Window(Gtk.WindowType.TOPLEVEL);
+ Gdk.Color color2 = Gdk.Color();
+ color2.red = 0;
+ color2.green = 0;
+ color2.blue = 0;
+ window.modify_bg(Gtk.StateType.NORMAL, color2);
+
+ // center the stage in the window
+ var align = new Gtk.Alignment(0.5f, 0.5f, 0, 0);
+ align.add(embed);
- // show the window
- if (PRESENTATION_FULLSCREEN)
- {
- window.fullscreen();
- }
- window.add(align);
- window.show_all();
+ // show the window
+ if (PRESENTATION_FULLSCREEN)
+ {
+ window.fullscreen();
+ }
+ window.add(align);
+ window.show_all();
- // register key presses and react
- align.get_parent_window().set_events(Gdk.EventMask.KEY_PRESS_MASK);
- align.key_press_event.connect(key_press);
+ // register key presses and react
+ align.get_parent_window().set_events(Gdk.EventMask.KEY_PRESS_MASK);
+ align.key_press_event.connect(key_press);
- // start the presentation
- can_animate = true;
- advance();
+ // start the presentation
+ can_animate = true;
+ advance();
+ }
+
+ public void advance()
+ {
+ // only advance when transitions are complete
+ if (!can_animate)
+ {
+ return;
}
-
- public void advance()
+
+ slide_index++;
+ if (slide_index == document.slides.size) // slideshow complete
{
- // only advance when transitions are complete
- if (!can_animate)
- {
- return;
- }
-
- slide_index++;
- if (slide_index == document.slides.size) // slideshow complete
- {
- window.hide_all();
- return;
- }
-
- var slide = document.slides.get(slide_index);
-
- // the first slide simply fades in
- if (slide_index == 0)
- {
- create_current_slide(slide);
- current_slide.stack(stack_container);
- current_slide.opacity = 0;
- current_slide.animate(Clutter.AnimationMode.EASE_IN_SINE,
- 1000, "opacity", 255);
- }
- else
- {
- old_slide = current_slide;
- create_current_slide(slide);
- old_slide.transition(current_slide, stack_container);
- old_slide.animation_time.completed.connect(animation_complete);
- can_animate = false;
- }
- stage.add_actor(current_slide);
+ window.hide_all();
+ return;
}
- private void retreat()
+ var slide = document.slides.get(slide_index);
+
+ // the first slide simply fades in
+ if (slide_index == 0)
{
- if (slide_index == 0)
- {
- return;
- }
-
- if (old_slide.animation_time != null)
- {
- old_slide.animation_time.stop();
- }
-
- slide_index--;
- can_animate = true;
- stage.remove_all();
-
- create_current_slide(document.slides.get(slide_index));
+ create_current_slide(slide);
current_slide.stack(stack_container);
- stage.add_actor(current_slide);
+ current_slide.opacity = 0;
+ current_slide.animate(Clutter.AnimationMode.EASE_IN_SINE,
+ 1000, "opacity", 255);
}
-
- private void create_current_slide(Slide slide)
+ else
+ {
+ old_slide = current_slide;
+ create_current_slide(slide);
+ old_slide.transition(current_slide, stack_container);
+ old_slide.animation_time.completed.connect(animation_complete);
+ can_animate = false;
+ }
+ stage.add_actor(current_slide);
+ }
+
+ private void retreat()
+ {
+ if (slide_index == 0)
{
- current_slide = new SlideActor.from_slide(document, slide, true,
- ActorContext.PRESENTATION);
+ return;
}
- private void animation_complete()
+ if (old_slide.animation_time != null)
{
- stage.remove_actor(old_slide);
- can_animate = true;
- current_slide.stack(stack_container);
+ old_slide.animation_time.stop();
}
- private bool key_press(Gtk.Widget sender, Gdk.EventKey event)
+ slide_index--;
+ can_animate = true;
+ stage.remove_all();
+
+ create_current_slide(document.slides.get(slide_index));
+ current_slide.stack(stack_container);
+ stage.add_actor(current_slide);
+ }
+
+ private void create_current_slide(Slide slide)
+ {
+ current_slide = new SlideActor.from_slide(document, slide, true,
+ ActorContext.PRESENTATION);
+ }
+
+ private void animation_complete()
+ {
+ stage.remove_actor(old_slide);
+ can_animate = true;
+ current_slide.stack(stack_container);
+ }
+
+ private bool key_press(Gtk.Widget sender, Gdk.EventKey event)
+ {
+ switch (event.keyval)
{
- switch (event.keyval)
- {
- case 65307: // escape
- stage.hide();
- break;
- case 65293: // enter
- case 65363: // right arrow
- case 65364: // up arrow
- advance();
- break;
- case 65288: // backspace
- case 65362: // up arrow
- case 65361: // left arrow
- retreat();
- break;
- }
- return false;
+ case 65307: // escape
+ stage.hide();
+ break;
+ case 65293: // enter
+ case 65363: // right arrow
+ case 65364: // up arrow
+ advance();
+ break;
+ case 65288: // backspace
+ case 65362: // up arrow
+ case 65361: // left arrow
+ retreat();
+ break;
}
+ return false;
}
}
+
diff --git a/src/libease/ScrollableEmbed.vala b/src/libease/ScrollableEmbed.vala
index bcf5e47..f9f29f5 100644
--- a/src/libease/ScrollableEmbed.vala
+++ b/src/libease/ScrollableEmbed.vala
@@ -15,131 +15,128 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * A GtkClutter.Embed with scrollbars
+ *
+ * A ScollableEmbed contains a { link GtkClutter.Viewport} within a
+ * { link GtkClutter.Embed}. The horizontal scrollbar is optional.
+ */
+public class Ease.ScrollableEmbed : Gtk.HBox
{
+ // actors
+ private GtkClutter.Embed embed;
+ private GtkClutter.Viewport viewport;
+ private Clutter.Stage stage;
+ public Clutter.Group contents { get; private set; }
+
+ // scrolling
+ private Gtk.HScrollbar h_scrollbar;
+ private Gtk.VScrollbar v_scrollbar;
+ private Gtk.Adjustment h_adjust;
+ private Gtk.Adjustment v_adjust;
+ private Gtk.Adjustment z_adjust;
+
+ public bool has_horizontal { get; private set; }
+
+ public float width
+ {
+ get
+ {
+ return stage.width;
+ }
+ }
+
+ public float height
+ {
+ get
+ {
+ return stage.height;
+ }
+ }
+
/**
- * A GtkClutter.Embed with scrollbars
- *
+ * Instantiate a ScollableEmbed with an optional vertical sidebar.
+ *
* A ScollableEmbed contains a { link GtkClutter.Viewport} within a
- * { link GtkClutter.Embed}. The horizontal scrollbar is optional.
+ * { link GtkClutter.Embed}.
+ *
+ * @param horizontal If true, the ScrollableEmbed has a horizontal
+ * scrollbar in addition to the vertical scrollbar.
*/
- public class ScrollableEmbed : Gtk.HBox
+ public ScrollableEmbed(bool horizontal)
{
- // actors
- private GtkClutter.Embed embed;
- private GtkClutter.Viewport viewport;
- private Clutter.Stage stage;
- public Clutter.Group contents { get; private set; }
+ has_horizontal = horizontal;
+
+ // create children
+ embed = new GtkClutter.Embed();
+ h_adjust = new Gtk.Adjustment(0, 0, 1, 0.1, 0.1, 0.1);
+ h_scrollbar = new Gtk.HScrollbar(h_adjust);
+ v_adjust = new Gtk.Adjustment(0, 0, 1, 0.1, 0.1, 0.1);
+ v_scrollbar = new Gtk.VScrollbar(v_adjust);
+ z_adjust = new Gtk.Adjustment(0, 0, 1, 0.1, 0.1, 0.1);
- // scrolling
- private Gtk.HScrollbar h_scrollbar;
- private Gtk.VScrollbar v_scrollbar;
- private Gtk.Adjustment h_adjust;
- private Gtk.Adjustment v_adjust;
- private Gtk.Adjustment z_adjust;
+ // set up clutter actors
+ viewport = new GtkClutter.Viewport(h_adjust, v_adjust, z_adjust);
+ contents = new Clutter.Group();
- public bool has_horizontal { get; private set; }
+ stage = (Clutter.Stage)(embed.get_stage());
+ stage.add_actor(viewport);
+ viewport.child = contents;
- public float width
+ var vbox = new Gtk.VBox(false, 0);
+ vbox.pack_start(embed, true, true, 0);
+
+ if (has_horizontal)
{
- get
- {
- return stage.width;
- }
+ vbox.pack_start(h_scrollbar, false, false, 0);
}
- public float height
- {
- get
- {
- return stage.height;
- }
- }
+ pack_start(vbox, true, true, 0);
+ pack_start(v_scrollbar, false, false, 0);
- /**
- * Instantiate a ScollableEmbed with an optional vertical sidebar.
- *
- * A ScollableEmbed contains a { link GtkClutter.Viewport} within a
- * { link GtkClutter.Embed}.
- *
- * @param horizontal If true, the ScrollableEmbed has a horizontal
- * scrollbar in addition to the vertical scrollbar.
- */
- public ScrollableEmbed(bool horizontal)
- {
- has_horizontal = horizontal;
-
- // create children
- embed = new GtkClutter.Embed();
- h_adjust = new Gtk.Adjustment(0, 0, 1, 0.1, 0.1, 0.1);
- h_scrollbar = new Gtk.HScrollbar(h_adjust);
- v_adjust = new Gtk.Adjustment(0, 0, 1, 0.1, 0.1, 0.1);
- v_scrollbar = new Gtk.VScrollbar(v_adjust);
- z_adjust = new Gtk.Adjustment(0, 0, 1, 0.1, 0.1, 0.1);
-
- // set up clutter actors
- viewport = new GtkClutter.Viewport(h_adjust, v_adjust, z_adjust);
- contents = new Clutter.Group();
-
- stage = (Clutter.Stage)(embed.get_stage());
- stage.add_actor(viewport);
- viewport.child = contents;
-
- var vbox = new Gtk.VBox(false, 0);
- vbox.pack_start(embed, true, true, 0);
-
- if (has_horizontal)
+ stage.show_all();
+
+ // scroll the view as is appropriate (with the mouse wheel)
+ realize.connect(() => {
+ get_window().set_events(Gdk.EventMask.ALL_EVENTS_MASK);
+ });
+
+ button_press_event.connect((event) => {
+ return false;
+ });
+
+ scroll_event.connect((event) => {
+ switch (event.direction)
{
- vbox.pack_start(h_scrollbar, false, false, 0);
+ case Gdk.ScrollDirection.UP:
+ v_adjust.value = Math.fmin(v_adjust.upper,
+ Math.fmax(v_adjust.lower,
+ v_adjust.value - v_adjust.step_increment));
+ break;
+ case Gdk.ScrollDirection.DOWN:
+ v_adjust.value = Math.fmin(v_adjust.upper,
+ Math.fmax(v_adjust.lower,
+ v_adjust.value + v_adjust.step_increment));
+ break;
}
+ return false;
+ });
- pack_start(vbox, true, true, 0);
- pack_start(v_scrollbar, false, false, 0);
-
- stage.show_all();
-
- // scroll the view as is appropriate (with the mouse wheel)
- realize.connect(() => {
- get_window().set_events(Gdk.EventMask.ALL_EVENTS_MASK);
- });
-
- button_press_event.connect((event) => {
- return false;
- });
-
- scroll_event.connect((event) => {
- switch (event.direction)
- {
- case Gdk.ScrollDirection.UP:
- v_adjust.value = Math.fmin(v_adjust.upper,
- Math.fmax(v_adjust.lower,
- v_adjust.value - v_adjust.step_increment));
- break;
- case Gdk.ScrollDirection.DOWN:
- v_adjust.value = Math.fmin(v_adjust.upper,
- Math.fmax(v_adjust.lower,
- v_adjust.value + v_adjust.step_increment));
- break;
- }
- return false;
- });
-
- // react when the view is resized
- embed.size_allocate.connect(embed_allocate);
- }
-
- public Clutter.Stage get_stage()
- {
- return (Clutter.Stage)(embed.get_stage());
- }
+ // react when the view is resized
+ embed.size_allocate.connect(embed_allocate);
+ }
+
+ public Clutter.Stage get_stage()
+ {
+ return (Clutter.Stage)(embed.get_stage());
+ }
- private void embed_allocate(Gtk.Widget sender, Gdk.Rectangle rect)
- {
- // pass on to Clutter actors
- stage.width = allocation.width;
- stage.height = allocation.height;
- viewport.width = allocation.width;
- viewport.height = allocation.height;
- }
+ private void embed_allocate(Gtk.Widget sender, Gdk.Rectangle rect)
+ {
+ // pass on to Clutter actors
+ stage.width = allocation.width;
+ stage.height = allocation.height;
+ viewport.width = allocation.width;
+ viewport.height = allocation.height;
}
}
diff --git a/src/libease/Slide.vala b/src/libease/Slide.vala
index 48a6b0e..db62544 100644
--- a/src/libease/Slide.vala
+++ b/src/libease/Slide.vala
@@ -15,112 +15,109 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * The internal representation of a slide
+ *
+ * A Slide is owned by a { link Document} and has { link Element}
+ * children. The currently selected Slide is often acted upon by an
+ * { link EditorWindow}.
+ */
+public class Ease.Slide
{
+ public Gee.ArrayList<Element> elements { get; set; }
+ public string transition { get; set; }
+ public string variant { get; set; }
+ public Clutter.Color background_color;
+ public string background_image { get; set; }
+ public Document parent { get; set; }
+ public double transition_time { get; set; }
+
/**
- * The internal representation of a slide
+ * Create a new Slide.
+ *
+ * Used for loading previously saved files.
*
- * A Slide is owned by a { link Document} and has { link Element}
- * children. The currently selected Slide is often acted upon by an
- * { link EditorWindow}.
+ * @param owner The { link Document} this slide is a part of.
*/
- public class Slide
+ public Slide(Document owner)
{
- public Gee.ArrayList<Element> elements { get; set; }
- public string transition { get; set; }
- public string variant { get; set; }
- public Clutter.Color background_color;
- public string background_image { get; set; }
- public Document parent { get; set; }
- public double transition_time { get; set; }
+ parent = owner;
+ }
+
+ /**
+ * Outputs this Slide to XML.
+ *
+ * This returns a <slide> tag containing information soecific to the
+ * Slide and a tag for each { link Element}.
+ */
+ public string to_xml()
+ {
+ string output = "\t\t<slide " +
+ "transition=\"" + transition + "\" " +
+ "variant=\"" + variant + "\" " +
+ "time=\"" + transition_time.to_string() + "\" " +
+ (background_image != null ?
+ ("background_image=\"" +
+ background_image + "\" ") :
+ ("background_color=\"" +
+ background_color.to_string()
+ + "\" ")) + ">\n";
- /**
- * Create a new Slide.
- *
- * Used for loading previously saved files.
- *
- * @param owner The { link Document} this slide is a part of.
- */
- public Slide(Document owner)
+ foreach (var e in elements)
{
- parent = owner;
+ output += e.to_xml();
}
- /**
- * Outputs this Slide to XML.
- *
- * This returns a <slide> tag containing information soecific to the
- * Slide and a tag for each { link Element}.
- */
- public string to_xml()
+ output += "</slide>\n";
+ return output;
+ }
+
+ /**
+ * Creates HTML markup for this Slide.
+ *
+ * The <div> tag for this Slide is appended to the "HTML" parameter.
+ *
+ * @param html The HTML string in its current state.
+ * @param exporter The { link HTMLExporter}, for the path and progress.
+ * @param amount The amount progress should increase by when done.
+ * @param index The index of this slide.
+ */
+ public void to_html(ref string html,
+ HTMLExporter exporter,
+ double amount,
+ int index)
+ {
+ // create the slide opening tag
+ html += "<div class=\"slide\" id=\"slide" +
+ index.to_string() + "\" ";
+
+ if (background_image == null)
{
- string output = "\t\t<slide " +
- "transition=\"" + transition + "\" " +
- "variant=\"" + variant + "\" " +
- "time=\"" + transition_time.to_string() + "\" " +
- (background_image != null ?
- ("background_image=\"" +
- background_image + "\" ") :
- ("background_color=\"" +
- background_color.to_string()
- + "\" ")) + ">\n";
-
- foreach (var e in elements)
- {
- output += e.to_xml();
- }
-
- output += "</slide>\n";
- return output;
+ // give the slide a background color
+ html += "style=\"background-color: " +
+ background_color.to_string().substring(0, 7) + "\">";
}
-
- /**
- * Creates HTML markup for this Slide.
- *
- * The <div> tag for this Slide is appended to the "HTML" parameter.
- *
- * @param html The HTML string in its current state.
- * @param exporter The { link HTMLExporter}, for the path and progress.
- * @param amount The amount progress should increase by when done.
- * @param index The index of this slide.
- */
- public void to_html(ref string html,
- HTMLExporter exporter,
- double amount,
- int index)
+ else
{
- // create the slide opening tag
- html += "<div class=\"slide\" id=\"slide" +
- index.to_string() + "\" ";
+ // close the tag
+ html += ">";
- if (background_image == null)
- {
- // give the slide a background color
- html += "style=\"background-color: " +
- background_color.to_string().substring(0, 7) + "\">";
- }
- else
- {
- // close the tag
- html += ">";
-
- // add the background image
- html += "<img src=\"" + exporter.path + " " + background_image +
- "\" alt=\"Background\" width=\"" +
- parent.width.to_string() + "\" height=\"" +
- parent.height.to_string() + "\"/>";
+ // add the background image
+ html += "<img src=\"" + exporter.path + " " + background_image +
+ "\" alt=\"Background\" width=\"" +
+ parent.width.to_string() + "\" height=\"" +
+ parent.height.to_string() + "\"/>";
- // copy the image file
- exporter.copy_file(background_image, parent.path);
- }
-
- // add tags for each Element
- foreach (var e in elements)
- {
- e.to_html(ref html, exporter, amount / elements.size);
- }
-
- html += "</div>\n";
+ // copy the image file
+ exporter.copy_file(background_image, parent.path);
}
+
+ // add tags for each Element
+ foreach (var e in elements)
+ {
+ e.to_html(ref html, exporter, amount / elements.size);
+ }
+
+ html += "</div>\n";
}
}
diff --git a/src/libease/SlideActor.vala b/src/libease/SlideActor.vala
index 41ba301..11cf220 100644
--- a/src/libease/SlideActor.vala
+++ b/src/libease/SlideActor.vala
@@ -15,565 +15,563 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+
+/**
+ * A Clutter actor for a Slide
+ *
+ * SlideActor is a subclass of Clutter.Group. It is used in both the
+ * editor and player, as well as assorted other preview screens.
+ */
+public class Ease.SlideActor : Clutter.Group
{
- /**
- * A Clutter actor for a Slide
- *
- * SlideActor is a subclass of Clutter.Group. It is used in both the
- * editor and player, as well as assorted other preview screens.
- */
- public class SlideActor : Clutter.Group
- {
- // the represented slide
- private Slide slide;
+ // the represented slide
+ private Slide slide;
- // the slide's background
- public Clutter.Actor background;
+ // the slide's background
+ public Clutter.Actor background;
- // the slide's contents
- //public Gee.ArrayList<Actor> contents_list;
+ // the slide's contents
+ //public Gee.ArrayList<Actor> contents_list;
- // the group of the slide's contents
- public Clutter.Group contents;
+ // the group of the slide's contents
+ public Clutter.Group contents;
+
+ // the context of the actor (presentation, etc.)
+ public ActorContext context;
+
+ // timelines
+ public Clutter.Timeline animation_time { get; set; }
+ private Clutter.Alpha animation_alpha { get; set; }
+ private Clutter.Timeline time1;
+ private Clutter.Timeline time2;
+ private Clutter.Alpha alpha1;
+ private Clutter.Alpha alpha2;
+
+ // constants
+ public const Clutter.AnimationMode EASE_SLIDE =
+ Clutter.AnimationMode.EASE_IN_OUT_SINE;
- // the context of the actor (presentation, etc.)
- public ActorContext context;
+ public const Clutter.AnimationMode EASE_DROP =
+ Clutter.AnimationMode.EASE_OUT_BOUNCE;
+
+ public const Clutter.AnimationMode EASE_PIVOT =
+ Clutter.AnimationMode.EASE_OUT_SINE;
- // timelines
- public Clutter.Timeline animation_time { get; set; }
- private Clutter.Alpha animation_alpha { get; set; }
- private Clutter.Timeline time1;
- private Clutter.Timeline time2;
- private Clutter.Alpha alpha1;
- private Clutter.Alpha alpha2;
-
- // constants
- public const Clutter.AnimationMode EASE_SLIDE =
- Clutter.AnimationMode.EASE_IN_OUT_SINE;
-
- public const Clutter.AnimationMode EASE_DROP =
- Clutter.AnimationMode.EASE_OUT_BOUNCE;
-
- public const Clutter.AnimationMode EASE_PIVOT =
- Clutter.AnimationMode.EASE_OUT_SINE;
-
- public const float FLIP_DEPTH = -400;
- public const float ZOOM_OUT_SCALE = 0.75f;
+ public const float FLIP_DEPTH = -400;
+ public const float ZOOM_OUT_SCALE = 0.75f;
+
+ public SlideActor.from_slide(Document document, Slide s, bool clip,
+ ActorContext ctx)
+ {
+ slide = s;
+ context = ctx;
- public SlideActor.from_slide(Document document, Slide s, bool clip,
- ActorContext ctx)
+ // clip the actor's bounds
+ if (clip)
{
- slide = s;
- context = ctx;
-
- // clip the actor's bounds
- if (clip)
- {
- set_clip(0, 0, document.width, document.height);
- }
+ set_clip(0, 0, document.width, document.height);
+ }
- // set the background
- if (slide.background_image != null)
- {
- try
- {
- background = new Clutter.Texture.from_file(document.path +
- slide.background_image);
- background.width = document.width;
- background.height = document.height;
- }
- catch (GLib.Error e)
- {
- stdout.printf("Error loading background: %s", e.message);
- }
- }
- else // the background is a solid color
+ // set the background
+ if (slide.background_image != null)
+ {
+ try
{
- background = new Clutter.Rectangle();
- ((Clutter.Rectangle)background).set_color(slide.background_color);
+ background = new Clutter.Texture.from_file(document.path +
+ slide.background_image);
background.width = document.width;
background.height = document.height;
}
-
- add_actor(background);
-
- contents = new Clutter.Group();
-
- foreach (var e in slide.elements)
+ catch (GLib.Error e)
{
- // load the proper type of actor
- switch (e.data.get("element_type"))
- {
- case "image":
- contents.add_actor(new ImageActor(e, context));
- break;
- case "text":
- contents.add_actor(new TextActor(e, context));
- break;
- case "video":
- contents.add_actor(new VideoActor(e, context));
- break;
- }
+ stdout.printf("Error loading background: %s", e.message);
}
-
- add_actor(contents);
+ }
+ else // the background is a solid color
+ {
+ background = new Clutter.Rectangle();
+ ((Clutter.Rectangle)background).set_color(slide.background_color);
+ background.width = document.width;
+ background.height = document.height;
}
- // stack the actor, removing children from container if needed
- public void stack(Clutter.Actor container)
+ add_actor(background);
+
+ contents = new Clutter.Group();
+
+ foreach (var e in slide.elements)
{
- if (background.get_parent() != this)
+ // load the proper type of actor
+ switch (e.data.get("element_type"))
{
- background.reparent(this);
- }
- if (contents.get_parent() != this)
- {
- contents.reparent(this);
+ case "image":
+ contents.add_actor(new ImageActor(e, context));
+ break;
+ case "text":
+ contents.add_actor(new TextActor(e, context));
+ break;
+ case "video":
+ contents.add_actor(new VideoActor(e, context));
+ break;
}
}
- // unstack the actor, layering it with another actor
- public void unstack(SlideActor other, Clutter.Actor container)
+ add_actor(contents);
+ }
+
+ // stack the actor, removing children from container if needed
+ public void stack(Clutter.Actor container)
+ {
+ if (background.get_parent() != this)
{
- if (other.background.get_parent() != container)
- {
- other.background.reparent(container);
- }
- if (background.get_parent() != container)
- {
- background.reparent(container);
- }
- if (contents.get_parent() != container)
- {
- contents.reparent(container);
- }
- if (other.contents.get_parent() != container)
- {
- other.contents.reparent(container);
- }
+ background.reparent(this);
}
-
- private void prepare_slide_transition(SlideActor new_slide,
- Clutter.Group stack_container)
+ if (contents.get_parent() != this)
{
- new_slide.stack(stack_container);
- stack(stack_container);
+ contents.reparent(this);
}
-
- private void prepare_stack_transition(bool current_on_top,
- SlideActor new_slide,
- Clutter.Group stack_container)
+ }
+
+ // unstack the actor, layering it with another actor
+ public void unstack(SlideActor other, Clutter.Actor container)
+ {
+ if (other.background.get_parent() != container)
+ {
+ other.background.reparent(container);
+ }
+ if (background.get_parent() != container)
{
- unstack(new_slide, stack_container);
+ background.reparent(container);
}
+ if (contents.get_parent() != container)
+ {
+ contents.reparent(container);
+ }
+ if (other.contents.get_parent() != container)
+ {
+ other.contents.reparent(container);
+ }
+ }
+
+ private void prepare_slide_transition(SlideActor new_slide,
+ Clutter.Group stack_container)
+ {
+ new_slide.stack(stack_container);
+ stack(stack_container);
+ }
+
+ private void prepare_stack_transition(bool current_on_top,
+ SlideActor new_slide,
+ Clutter.Group stack_container)
+ {
+ unstack(new_slide, stack_container);
+ }
+
+ public void transition(SlideActor new_slide,
+ Clutter.Group stack_container)
+ {
+ uint length = (uint)max(10, slide.transition_time * 1000);
+ float xpos = 0, ypos = 0, angle = 90;
+ var property = "";
- public void transition(SlideActor new_slide,
- Clutter.Group stack_container)
+ animation_time = new Clutter.Timeline(length);
+ animation_time.start();
+
+ switch (slide.transition)
{
- uint length = (uint)max(10, slide.transition_time * 1000);
- float xpos = 0, ypos = 0, angle = 90;
- var property = "";
+ case "Fade":
+ prepare_slide_transition(new_slide, stack_container);
+ new_slide.opacity = 0;
+ new_slide.animate(Clutter.AnimationMode.LINEAR,
+ length, "opacity", 255);
+ break;
- animation_time = new Clutter.Timeline(length);
- animation_time.start();
-
- switch (slide.transition)
- {
- case "Fade":
- prepare_slide_transition(new_slide, stack_container);
- new_slide.opacity = 0;
- new_slide.animate(Clutter.AnimationMode.LINEAR,
- length, "opacity", 255);
- break;
-
- case "Slide":
- switch (slide.variant)
- {
- case "Up":
- new_slide.y = slide.parent.height;
- new_slide.animate(EASE_SLIDE, length, "y", 0);
- animate(EASE_SLIDE, length, "y", -new_slide.y);
- break;
- case "Down":
- new_slide.y = -slide.parent.height;
- new_slide.animate(EASE_SLIDE, length, "y", 0);
- animate(EASE_SLIDE, length, "y", -new_slide.y);
- break;
- case "Left":
- new_slide.x = slide.parent.width;
- new_slide.animate(EASE_SLIDE, length, "x", 0);
- this.animate(EASE_SLIDE, length, "x", -new_slide.x);
- break;
- case "Right":
- new_slide.x = -slide.parent.width;
- new_slide.animate(EASE_SLIDE, length, "x", 0);
- animate(EASE_SLIDE, length, "x", -new_slide.x);
- break;
- }
- break;
-
- case "Drop":
- new_slide.y = -slide.parent.height;
- new_slide.animate(EASE_DROP, length, "y", 0);
- break;
-
- case "Pivot":
- switch (slide.variant)
- {
- case "Top Right":
- xpos = slide.parent.width;
- angle = -90;
- break;
- case "Bottom Left":
- ypos = slide.parent.height;
- angle = -90;
- break;
- case "Bottom Right":
- xpos = slide.parent.width;
- ypos = slide.parent.height;
- break;
- }
+ case "Slide":
+ switch (slide.variant)
+ {
+ case "Up":
+ new_slide.y = slide.parent.height;
+ new_slide.animate(EASE_SLIDE, length, "y", 0);
+ animate(EASE_SLIDE, length, "y", -new_slide.y);
+ break;
+ case "Down":
+ new_slide.y = -slide.parent.height;
+ new_slide.animate(EASE_SLIDE, length, "y", 0);
+ animate(EASE_SLIDE, length, "y", -new_slide.y);
+ break;
+ case "Left":
+ new_slide.x = slide.parent.width;
+ new_slide.animate(EASE_SLIDE, length, "x", 0);
+ this.animate(EASE_SLIDE, length, "x", -new_slide.x);
+ break;
+ case "Right":
+ new_slide.x = -slide.parent.width;
+ new_slide.animate(EASE_SLIDE, length, "x", 0);
+ animate(EASE_SLIDE, length, "x", -new_slide.x);
+ break;
+ }
+ break;
+
+ case "Drop":
+ new_slide.y = -slide.parent.height;
+ new_slide.animate(EASE_DROP, length, "y", 0);
+ break;
+
+ case "Pivot":
+ switch (slide.variant)
+ {
+ case "Top Right":
+ xpos = slide.parent.width;
+ angle = -90;
+ break;
+ case "Bottom Left":
+ ypos = slide.parent.height;
+ angle = -90;
+ break;
+ case "Bottom Right":
+ xpos = slide.parent.width;
+ ypos = slide.parent.height;
+ break;
+ }
+ new_slide.set_rotation(Clutter.RotateAxis.Z_AXIS,
+ angle, xpos, ypos, 0);
+ animation_alpha = new Clutter.Alpha.full(animation_time,
+ EASE_PIVOT);
+ animation_time.new_frame.connect((m) => {
new_slide.set_rotation(Clutter.RotateAxis.Z_AXIS,
- angle, xpos, ypos, 0);
- animation_alpha = new Clutter.Alpha.full(animation_time,
- EASE_PIVOT);
- animation_time.new_frame.connect((m) => {
- new_slide.set_rotation(Clutter.RotateAxis.Z_AXIS,
- angle * (1 - animation_alpha.get_alpha()),
- xpos, ypos, 0);
- });
- break;
-
- case "Flip":
- new_slide.opacity = 0;
- time1 = new Clutter.Timeline(length / 2);
- time2 = new Clutter.Timeline(length / 2);
- alpha1 = new Clutter.Alpha.full(time1,
- Clutter.AnimationMode.EASE_IN_SINE);
- alpha2 = new Clutter.Alpha.full(time2,
- Clutter.AnimationMode.EASE_OUT_SINE);
- switch (slide.variant)
- {
- case "Bottom to Top":
- time1.new_frame.connect((m) => {
- set_rotation(Clutter.RotateAxis.X_AXIS, 90 * alpha1.get_alpha(), 0, slide.parent.height / 2, 0);
- depth = (float)(FLIP_DEPTH * alpha1.get_alpha());
- });
- time2.new_frame.connect((m) => {
- new_slide.opacity = 255;
- new_slide.depth = FLIP_DEPTH * (float)(1 - alpha2.get_alpha());
- new_slide.set_rotation(Clutter.RotateAxis.X_AXIS, -90 * (1 - alpha2.get_alpha()), 0, slide.parent.height / 2, 0);
- });
- break;
- case "Top to Bottom":
- time1.new_frame.connect((m) => {
- set_rotation(Clutter.RotateAxis.X_AXIS, -90 * alpha1.get_alpha(), 0, slide.parent.height / 2, 0);
- depth = (float)(FLIP_DEPTH * alpha1.get_alpha());
- });
- time2.new_frame.connect((m) => {
- new_slide.opacity = 255;
- new_slide.depth = FLIP_DEPTH * (float)(1 - alpha2.get_alpha());
- new_slide.set_rotation(Clutter.RotateAxis.X_AXIS, 90 * (1 - alpha2.get_alpha()), 0, slide.parent.height / 2, 0);
- });
- break;
- case "Left to Right":
- time1.new_frame.connect((m) => {
- set_rotation(Clutter.RotateAxis.Y_AXIS, 90 * alpha1.get_alpha(), slide.parent.width / 2, 0, 0);
- depth = (float)(FLIP_DEPTH * alpha1.get_alpha());
- });
- time2.new_frame.connect((m) => {
- new_slide.opacity = 255;
- new_slide.depth = FLIP_DEPTH * (float)(1 - alpha2.get_alpha());
- new_slide.set_rotation(Clutter.RotateAxis.Y_AXIS, -90 * (1 - alpha2.get_alpha()), slide.parent.width / 2, 0, 0);
- });
- break;
- case "Right to Left":
- time1.new_frame.connect((m) => {
- set_rotation(Clutter.RotateAxis.Y_AXIS, -90 * alpha1.get_alpha(), slide.parent.width / 2, 0, 0);
- depth = (float)(FLIP_DEPTH * alpha1.get_alpha());
- });
- time2.new_frame.connect((m) => {
- new_slide.opacity = 255;
- new_slide.depth = FLIP_DEPTH * (float)(1 - alpha2.get_alpha());
- new_slide.set_rotation(Clutter.RotateAxis.Y_AXIS, 90 * (1 - alpha2.get_alpha()), slide.parent.width / 2, 0, 0);
- });
- break;
- }
- time1.completed.connect(() => {
- opacity = 0;
- new_slide.depth = FLIP_DEPTH;
- time2.start();
- });
- time1.start();
- break;
-
- case "Revolving Door":
- depth = 1; //ugly, but works
- animation_alpha = new Clutter.Alpha.full(animation_time, Clutter.AnimationMode.EASE_IN_OUT_SINE);
- switch (slide.variant)
- {
- case "Left":
- new_slide.set_rotation(Clutter.RotateAxis.Y_AXIS, 90, 0, 0, 0);
- animation_time.new_frame.connect((m) => {
- new_slide.set_rotation(Clutter.RotateAxis.Y_AXIS, 90 * (1 - animation_alpha.get_alpha()), 0, 0, 0);
- set_rotation(Clutter.RotateAxis.Y_AXIS, -110 * animation_alpha.get_alpha(), 0, 0, 0);
- });
- break;
- case "Right":
- new_slide.set_rotation(Clutter.RotateAxis.Y_AXIS, 90, slide.parent.width, 0, 0);
- animation_time.new_frame.connect((m) => {
- new_slide.set_rotation(Clutter.RotateAxis.Y_AXIS, -90 * (1 - animation_alpha.get_alpha()), slide.parent.width, 0, 0);
- set_rotation(Clutter.RotateAxis.Y_AXIS, 110 * animation_alpha.get_alpha(), slide.parent.width, 0, 0);
- });
- break;
- case "Top":
- new_slide.set_rotation(Clutter.RotateAxis.X_AXIS, -90, 0, 0, 0);
- animation_time.new_frame.connect((m) => {
- new_slide.set_rotation(Clutter.RotateAxis.X_AXIS, -90 * (1 - animation_alpha.get_alpha()), 0, 0, 0);
- set_rotation(Clutter.RotateAxis.X_AXIS, 110 * animation_alpha.get_alpha(), 0, 0, 0);
- });
- break;
- case "Bottom":
- new_slide.set_rotation(Clutter.RotateAxis.X_AXIS, 90, 0, slide.parent.height, 0);
- animation_time.new_frame.connect((m) => {
- new_slide.set_rotation(Clutter.RotateAxis.X_AXIS, 90 * (1 - animation_alpha.get_alpha()), 0, slide.parent.height, 0);
- set_rotation(Clutter.RotateAxis.X_AXIS, -110 * animation_alpha.get_alpha(), 0, slide.parent.height, 0);
- });
- break;
- }
- break;
-
- case "Fall":
- depth = 1; //ugly, but works
- animation_alpha = new Clutter.Alpha.full(animation_time, Clutter.AnimationMode.EASE_IN_QUART);
- animation_time.new_frame.connect((m) => {
- set_rotation(Clutter.RotateAxis.X_AXIS, -90 * animation_alpha.get_alpha(), 0, slide.parent.height, 0);
- });
- break;
-
- case "Spin Contents":
- prepare_stack_transition(false, new_slide, stack_container);
-
- new_slide.contents.opacity = 0;
- background.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "opacity", 0);
- time1 = new Clutter.Timeline(length / 2);
- time2 = new Clutter.Timeline(length / 2);
- alpha1 = new Clutter.Alpha.full(time1, Clutter.AnimationMode.EASE_IN_SINE);
- alpha2 = new Clutter.Alpha.full(time2, Clutter.AnimationMode.EASE_OUT_SINE);
- angle = slide.variant == "Left" ? -90 : 90;
- time1.completed.connect(() => {
- contents.opacity = 0;
- time2.start();
- });
- time1.new_frame.connect((m) => {
- contents.set_rotation(Clutter.RotateAxis.Y_AXIS, angle * alpha1.get_alpha(), slide.parent.width / 2, 0, 0);
- });
- time2.new_frame.connect((m) => {
- new_slide.contents.opacity = 255;
- new_slide.contents.set_rotation(Clutter.RotateAxis.Y_AXIS, -angle * (1 - alpha2.get_alpha()), slide.parent.width / 2, 0, 0);
- });
- time1.start();
- break;
-
- case "Swing Contents":
- prepare_stack_transition(false, new_slide, stack_container);
-
- new_slide.contents.opacity = 0;
- background.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "opacity", 0);
- alpha1 = new Clutter.Alpha.full(animation_time, Clutter.AnimationMode.EASE_IN_SINE);
- alpha2 = new Clutter.Alpha.full(animation_time, Clutter.AnimationMode.EASE_OUT_SINE);
- animation_alpha = new Clutter.Alpha.full(animation_time, Clutter.AnimationMode.LINEAR);
- animation_time.new_frame.connect((m) => {
- unowned GLib.List<Clutter.Actor>* itr;
- contents.opacity = clamp_opacity(455 - 555 * alpha1.get_alpha());
- new_slide.contents.opacity = clamp_opacity(-100 + 400 * alpha2.get_alpha());
- for (itr = contents.get_children(); itr != null; itr = itr->next)
- {
- ((Clutter.Actor*)itr->data)->set_rotation(Clutter.RotateAxis.X_AXIS, 540 * alpha1.get_alpha(), 0, 0, 0);
- }
- for (itr = new_slide.contents.get_children(); itr != null; itr = itr->next)
- {
- ((Clutter.Actor*)itr->data)->set_rotation(Clutter.RotateAxis.X_AXIS, -540 * (1 - alpha2.get_alpha()), 0, 0, 0);
- }
- });
- break;
-
- case "Zoom":
- switch (slide.variant)
- {
- case "Center":
- new_slide.set_scale_full(0, 0, slide.parent.width / 2, slide.parent.height / 2);
- break;
- case "Top Left":
- new_slide.set_scale_full(0, 0, 0, 0);
- break;
- case "Top Right":
- new_slide.set_scale_full(0, 0, slide.parent.width, 0);
- break;
- case "Bottom Left":
- new_slide.set_scale_full(0, 0, 0, slide.parent.height);
- break;
- case "Bottom Right":
- new_slide.set_scale_full(0, 0, slide.parent.width, slide.parent.height);
- break;
- }
- animation_alpha = new Clutter.Alpha.full(animation_time, Clutter.AnimationMode.EASE_OUT_SINE);
- animation_time.new_frame.connect((m) => {
- new_slide.set_scale(animation_alpha.get_alpha(), animation_alpha.get_alpha());
- });
- //new_slide.animate(Clutter.AnimationMode.EASE_OUT_SINE, length, "scale_x", 1);
- //new_slide.animate(Clutter.AnimationMode.EASE_OUT_SINE, length, "scale_y", 1);
- break;
-
- case "Slide Contents":
- prepare_stack_transition(false, new_slide, stack_container);
-
- background.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "opacity", 0);
- switch (slide.variant)
- {
- case "Right":
- new_slide.contents.x = -slide.parent.width;
- new_slide.contents.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "x", 0);
- contents.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "x", -new_slide.contents.x);
- break;
- case "Left":
- new_slide.contents.x = slide.parent.width;
- new_slide.contents.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "x", 0);
- contents.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "x", -new_slide.contents.x);
- break;
- case "Up":
- new_slide.contents.y = slide.parent.height;
- new_slide.contents.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "y", 0);
- contents.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "y", -new_slide.contents.y);
- break;
- case "Down":
- new_slide.contents.y = -slide.parent.height;
- new_slide.contents.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "y", 0);
- contents.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "y", -new_slide.contents.y);
- break;
- }
- break;
-
- case "Spring Contents":
- prepare_stack_transition(false, new_slide, stack_container);
-
- background.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "opacity", 0);
- switch (slide.variant)
- {
- case "Up":
- new_slide.contents.y = slide.parent.height * 1.2f;
- new_slide.contents.animate(Clutter.AnimationMode.EASE_IN_OUT_ELASTIC, length, "y", 0);
- contents.animate(Clutter.AnimationMode.EASE_IN_OUT_ELASTIC, length, "y", -slide.parent.height * 1.2);
- break;
- case "Down":
- new_slide.contents.y = -slide.parent.height * 1.2f;
- new_slide.contents.animate(Clutter.AnimationMode.EASE_IN_OUT_ELASTIC, length, "y", 0);
- contents.animate(Clutter.AnimationMode.EASE_IN_OUT_ELASTIC, length, "y", slide.parent.height * 1.2);
- break;
- }
- break;
-
- case "Zoom Contents":
- prepare_stack_transition(slide.variant == "Out",
- new_slide, stack_container);
-
- animation_alpha = new Clutter.Alpha.full(animation_time, Clutter.AnimationMode.EASE_IN_OUT_SINE);
- background.animate(Clutter.AnimationMode.LINEAR, length, "opacity", 0);
- switch (slide.variant)
+ angle * (1 - animation_alpha.get_alpha()),
+ xpos, ypos, 0);
+ });
+ break;
+
+ case "Flip":
+ new_slide.opacity = 0;
+ time1 = new Clutter.Timeline(length / 2);
+ time2 = new Clutter.Timeline(length / 2);
+ alpha1 = new Clutter.Alpha.full(time1,
+ Clutter.AnimationMode.EASE_IN_SINE);
+ alpha2 = new Clutter.Alpha.full(time2,
+ Clutter.AnimationMode.EASE_OUT_SINE);
+ switch (slide.variant)
+ {
+ case "Bottom to Top":
+ time1.new_frame.connect((m) => {
+ set_rotation(Clutter.RotateAxis.X_AXIS, 90 * alpha1.get_alpha(), 0, slide.parent.height / 2, 0);
+ depth = (float)(FLIP_DEPTH * alpha1.get_alpha());
+ });
+ time2.new_frame.connect((m) => {
+ new_slide.opacity = 255;
+ new_slide.depth = FLIP_DEPTH * (float)(1 - alpha2.get_alpha());
+ new_slide.set_rotation(Clutter.RotateAxis.X_AXIS, -90 * (1 - alpha2.get_alpha()), 0, slide.parent.height / 2, 0);
+ });
+ break;
+ case "Top to Bottom":
+ time1.new_frame.connect((m) => {
+ set_rotation(Clutter.RotateAxis.X_AXIS, -90 * alpha1.get_alpha(), 0, slide.parent.height / 2, 0);
+ depth = (float)(FLIP_DEPTH * alpha1.get_alpha());
+ });
+ time2.new_frame.connect((m) => {
+ new_slide.opacity = 255;
+ new_slide.depth = FLIP_DEPTH * (float)(1 - alpha2.get_alpha());
+ new_slide.set_rotation(Clutter.RotateAxis.X_AXIS, 90 * (1 - alpha2.get_alpha()), 0, slide.parent.height / 2, 0);
+ });
+ break;
+ case "Left to Right":
+ time1.new_frame.connect((m) => {
+ set_rotation(Clutter.RotateAxis.Y_AXIS, 90 * alpha1.get_alpha(), slide.parent.width / 2, 0, 0);
+ depth = (float)(FLIP_DEPTH * alpha1.get_alpha());
+ });
+ time2.new_frame.connect((m) => {
+ new_slide.opacity = 255;
+ new_slide.depth = FLIP_DEPTH * (float)(1 - alpha2.get_alpha());
+ new_slide.set_rotation(Clutter.RotateAxis.Y_AXIS, -90 * (1 - alpha2.get_alpha()), slide.parent.width / 2, 0, 0);
+ });
+ break;
+ case "Right to Left":
+ time1.new_frame.connect((m) => {
+ set_rotation(Clutter.RotateAxis.Y_AXIS, -90 * alpha1.get_alpha(), slide.parent.width / 2, 0, 0);
+ depth = (float)(FLIP_DEPTH * alpha1.get_alpha());
+ });
+ time2.new_frame.connect((m) => {
+ new_slide.opacity = 255;
+ new_slide.depth = FLIP_DEPTH * (float)(1 - alpha2.get_alpha());
+ new_slide.set_rotation(Clutter.RotateAxis.Y_AXIS, 90 * (1 - alpha2.get_alpha()), slide.parent.width / 2, 0, 0);
+ });
+ break;
+ }
+ time1.completed.connect(() => {
+ opacity = 0;
+ new_slide.depth = FLIP_DEPTH;
+ time2.start();
+ });
+ time1.start();
+ break;
+
+ case "Revolving Door":
+ depth = 1; //ugly, but works
+ animation_alpha = new Clutter.Alpha.full(animation_time, Clutter.AnimationMode.EASE_IN_OUT_SINE);
+ switch (slide.variant)
+ {
+ case "Left":
+ new_slide.set_rotation(Clutter.RotateAxis.Y_AXIS, 90, 0, 0, 0);
+ animation_time.new_frame.connect((m) => {
+ new_slide.set_rotation(Clutter.RotateAxis.Y_AXIS, 90 * (1 - animation_alpha.get_alpha()), 0, 0, 0);
+ set_rotation(Clutter.RotateAxis.Y_AXIS, -110 * animation_alpha.get_alpha(), 0, 0, 0);
+ });
+ break;
+ case "Right":
+ new_slide.set_rotation(Clutter.RotateAxis.Y_AXIS, 90, slide.parent.width, 0, 0);
+ animation_time.new_frame.connect((m) => {
+ new_slide.set_rotation(Clutter.RotateAxis.Y_AXIS, -90 * (1 - animation_alpha.get_alpha()), slide.parent.width, 0, 0);
+ set_rotation(Clutter.RotateAxis.Y_AXIS, 110 * animation_alpha.get_alpha(), slide.parent.width, 0, 0);
+ });
+ break;
+ case "Top":
+ new_slide.set_rotation(Clutter.RotateAxis.X_AXIS, -90, 0, 0, 0);
+ animation_time.new_frame.connect((m) => {
+ new_slide.set_rotation(Clutter.RotateAxis.X_AXIS, -90 * (1 - animation_alpha.get_alpha()), 0, 0, 0);
+ set_rotation(Clutter.RotateAxis.X_AXIS, 110 * animation_alpha.get_alpha(), 0, 0, 0);
+ });
+ break;
+ case "Bottom":
+ new_slide.set_rotation(Clutter.RotateAxis.X_AXIS, 90, 0, slide.parent.height, 0);
+ animation_time.new_frame.connect((m) => {
+ new_slide.set_rotation(Clutter.RotateAxis.X_AXIS, 90 * (1 - animation_alpha.get_alpha()), 0, slide.parent.height, 0);
+ set_rotation(Clutter.RotateAxis.X_AXIS, -110 * animation_alpha.get_alpha(), 0, slide.parent.height, 0);
+ });
+ break;
+ }
+ break;
+
+ case "Fall":
+ depth = 1; //ugly, but works
+ animation_alpha = new Clutter.Alpha.full(animation_time, Clutter.AnimationMode.EASE_IN_QUART);
+ animation_time.new_frame.connect((m) => {
+ set_rotation(Clutter.RotateAxis.X_AXIS, -90 * animation_alpha.get_alpha(), 0, slide.parent.height, 0);
+ });
+ break;
+
+ case "Spin Contents":
+ prepare_stack_transition(false, new_slide, stack_container);
+
+ new_slide.contents.opacity = 0;
+ background.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "opacity", 0);
+ time1 = new Clutter.Timeline(length / 2);
+ time2 = new Clutter.Timeline(length / 2);
+ alpha1 = new Clutter.Alpha.full(time1, Clutter.AnimationMode.EASE_IN_SINE);
+ alpha2 = new Clutter.Alpha.full(time2, Clutter.AnimationMode.EASE_OUT_SINE);
+ angle = slide.variant == "Left" ? -90 : 90;
+ time1.completed.connect(() => {
+ contents.opacity = 0;
+ time2.start();
+ });
+ time1.new_frame.connect((m) => {
+ contents.set_rotation(Clutter.RotateAxis.Y_AXIS, angle * alpha1.get_alpha(), slide.parent.width / 2, 0, 0);
+ });
+ time2.new_frame.connect((m) => {
+ new_slide.contents.opacity = 255;
+ new_slide.contents.set_rotation(Clutter.RotateAxis.Y_AXIS, -angle * (1 - alpha2.get_alpha()), slide.parent.width / 2, 0, 0);
+ });
+ time1.start();
+ break;
+
+ case "Swing Contents":
+ prepare_stack_transition(false, new_slide, stack_container);
+
+ new_slide.contents.opacity = 0;
+ background.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "opacity", 0);
+ alpha1 = new Clutter.Alpha.full(animation_time, Clutter.AnimationMode.EASE_IN_SINE);
+ alpha2 = new Clutter.Alpha.full(animation_time, Clutter.AnimationMode.EASE_OUT_SINE);
+ animation_alpha = new Clutter.Alpha.full(animation_time, Clutter.AnimationMode.LINEAR);
+ animation_time.new_frame.connect((m) => {
+ unowned GLib.List<Clutter.Actor>* itr;
+ contents.opacity = clamp_opacity(455 - 555 * alpha1.get_alpha());
+ new_slide.contents.opacity = clamp_opacity(-100 + 400 * alpha2.get_alpha());
+ for (itr = contents.get_children(); itr != null; itr = itr->next)
{
- case "In":
- new_slide.contents.set_scale_full(0, 0, slide.parent.width / 2, slide.parent.height / 2);
- contents.set_scale_full(1, 1, slide.parent.width / 2, slide.parent.height / 2);
- contents.animate(Clutter.AnimationMode.LINEAR, length / 2, "opacity", 0);
- animation_time.new_frame.connect((m) => {
- new_slide.contents.set_scale(animation_alpha.get_alpha(),
- animation_alpha.get_alpha());
- contents.set_scale(1.0 + 2 * animation_alpha.get_alpha(),
- 1.0 + 2 * animation_alpha.get_alpha());
- });
- break;
- case "Out":
- new_slide.contents.set_scale_full(0, 0, slide.parent.width / 2, slide.parent.height / 2);
- contents.set_scale_full(1, 1, slide.parent.width / 2, slide.parent.height / 2);
- new_slide.contents.opacity = 0;
- new_slide.contents.animate(Clutter.AnimationMode.EASE_IN_SINE, length / 2, "opacity", 255);
- animation_time.new_frame.connect((m) => {
- new_slide.contents.set_scale(1.0 + 2 * (1 - animation_alpha.get_alpha()),
- 1.0 + 2 * (1 - animation_alpha.get_alpha()));
- contents.set_scale(1 - animation_alpha.get_alpha(),
- 1 - animation_alpha.get_alpha());
- });
- break;
+ ((Clutter.Actor*)itr->data)->set_rotation(Clutter.RotateAxis.X_AXIS, 540 * alpha1.get_alpha(), 0, 0, 0);
}
- break;
-
- case "Panel":
- switch (slide.variant)
+ for (itr = new_slide.contents.get_children(); itr != null; itr = itr->next)
{
- case "Up":
- xpos = slide.parent.height;
- property = "y";
- break;
- case "Down":
- xpos = -slide.parent.height;
- property = "y";
- break;
- case "Left":
- xpos = slide.parent.width;
- property = "x";
- break;
- case "Right":
- xpos = -slide.parent.width;
- property = "x";
- break;
+ ((Clutter.Actor*)itr->data)->set_rotation(Clutter.RotateAxis.X_AXIS, -540 * (1 - alpha2.get_alpha()), 0, 0, 0);
}
-
- time1 = new Clutter.Timeline(length / 4);
- time2 = new Clutter.Timeline(3 * length / 4);
- new_slide.set_scale_full(ZOOM_OUT_SCALE, ZOOM_OUT_SCALE, slide.parent.width / 2, slide.parent.height / 2);
- new_slide.set_property(property, xpos);
- alpha1 = new Clutter.Alpha.full(time1, Clutter.AnimationMode.EASE_IN_OUT_SINE);
-
- time1.new_frame.connect((m) => {
- set_scale_full(ZOOM_OUT_SCALE + (1 - ZOOM_OUT_SCALE) * (1 - alpha1.get_alpha()),
- ZOOM_OUT_SCALE + (1 - ZOOM_OUT_SCALE) * (1 - alpha1.get_alpha()),
- slide.parent.width / 2,
- slide.parent.height / 2);
- });
- time1.completed.connect(() => {
- animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length / 2, property, -xpos);
- new_slide.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length / 2, property, 0.0f);
- });
- time2.completed.connect(() => {
- time1.new_frame.connect((m) => {
- new_slide.set_scale_full(ZOOM_OUT_SCALE + (1 - ZOOM_OUT_SCALE) * alpha1.get_alpha(),
- ZOOM_OUT_SCALE + (1 - ZOOM_OUT_SCALE) * alpha1.get_alpha(),
- slide.parent.width / 2,
- slide.parent.height / 2);
+ });
+ break;
+
+ case "Zoom":
+ switch (slide.variant)
+ {
+ case "Center":
+ new_slide.set_scale_full(0, 0, slide.parent.width / 2, slide.parent.height / 2);
+ break;
+ case "Top Left":
+ new_slide.set_scale_full(0, 0, 0, 0);
+ break;
+ case "Top Right":
+ new_slide.set_scale_full(0, 0, slide.parent.width, 0);
+ break;
+ case "Bottom Left":
+ new_slide.set_scale_full(0, 0, 0, slide.parent.height);
+ break;
+ case "Bottom Right":
+ new_slide.set_scale_full(0, 0, slide.parent.width, slide.parent.height);
+ break;
+ }
+ animation_alpha = new Clutter.Alpha.full(animation_time, Clutter.AnimationMode.EASE_OUT_SINE);
+ animation_time.new_frame.connect((m) => {
+ new_slide.set_scale(animation_alpha.get_alpha(), animation_alpha.get_alpha());
+ });
+ //new_slide.animate(Clutter.AnimationMode.EASE_OUT_SINE, length, "scale_x", 1);
+ //new_slide.animate(Clutter.AnimationMode.EASE_OUT_SINE, length, "scale_y", 1);
+ break;
+
+ case "Slide Contents":
+ prepare_stack_transition(false, new_slide, stack_container);
+
+ background.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "opacity", 0);
+ switch (slide.variant)
+ {
+ case "Right":
+ new_slide.contents.x = -slide.parent.width;
+ new_slide.contents.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "x", 0);
+ contents.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "x", -new_slide.contents.x);
+ break;
+ case "Left":
+ new_slide.contents.x = slide.parent.width;
+ new_slide.contents.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "x", 0);
+ contents.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "x", -new_slide.contents.x);
+ break;
+ case "Up":
+ new_slide.contents.y = slide.parent.height;
+ new_slide.contents.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "y", 0);
+ contents.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "y", -new_slide.contents.y);
+ break;
+ case "Down":
+ new_slide.contents.y = -slide.parent.height;
+ new_slide.contents.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "y", 0);
+ contents.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "y", -new_slide.contents.y);
+ break;
+ }
+ break;
+
+ case "Spring Contents":
+ prepare_stack_transition(false, new_slide, stack_container);
+
+ background.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length, "opacity", 0);
+ switch (slide.variant)
+ {
+ case "Up":
+ new_slide.contents.y = slide.parent.height * 1.2f;
+ new_slide.contents.animate(Clutter.AnimationMode.EASE_IN_OUT_ELASTIC, length, "y", 0);
+ contents.animate(Clutter.AnimationMode.EASE_IN_OUT_ELASTIC, length, "y", -slide.parent.height * 1.2);
+ break;
+ case "Down":
+ new_slide.contents.y = -slide.parent.height * 1.2f;
+ new_slide.contents.animate(Clutter.AnimationMode.EASE_IN_OUT_ELASTIC, length, "y", 0);
+ contents.animate(Clutter.AnimationMode.EASE_IN_OUT_ELASTIC, length, "y", slide.parent.height * 1.2);
+ break;
+ }
+ break;
+
+ case "Zoom Contents":
+ prepare_stack_transition(slide.variant == "Out",
+ new_slide, stack_container);
+
+ animation_alpha = new Clutter.Alpha.full(animation_time, Clutter.AnimationMode.EASE_IN_OUT_SINE);
+ background.animate(Clutter.AnimationMode.LINEAR, length, "opacity", 0);
+ switch (slide.variant)
+ {
+ case "In":
+ new_slide.contents.set_scale_full(0, 0, slide.parent.width / 2, slide.parent.height / 2);
+ contents.set_scale_full(1, 1, slide.parent.width / 2, slide.parent.height / 2);
+ contents.animate(Clutter.AnimationMode.LINEAR, length / 2, "opacity", 0);
+ animation_time.new_frame.connect((m) => {
+ new_slide.contents.set_scale(animation_alpha.get_alpha(),
+ animation_alpha.get_alpha());
+ contents.set_scale(1.0 + 2 * animation_alpha.get_alpha(),
+ 1.0 + 2 * animation_alpha.get_alpha());
});
- time1.start();
+ break;
+ case "Out":
+ new_slide.contents.set_scale_full(0, 0, slide.parent.width / 2, slide.parent.height / 2);
+ contents.set_scale_full(1, 1, slide.parent.width / 2, slide.parent.height / 2);
+ new_slide.contents.opacity = 0;
+ new_slide.contents.animate(Clutter.AnimationMode.EASE_IN_SINE, length / 2, "opacity", 255);
+ animation_time.new_frame.connect((m) => {
+ new_slide.contents.set_scale(1.0 + 2 * (1 - animation_alpha.get_alpha()),
+ 1.0 + 2 * (1 - animation_alpha.get_alpha()));
+ contents.set_scale(1 - animation_alpha.get_alpha(),
+ 1 - animation_alpha.get_alpha());
+ });
+ break;
+ }
+ break;
+
+ case "Panel":
+ switch (slide.variant)
+ {
+ case "Up":
+ xpos = slide.parent.height;
+ property = "y";
+ break;
+ case "Down":
+ xpos = -slide.parent.height;
+ property = "y";
+ break;
+ case "Left":
+ xpos = slide.parent.width;
+ property = "x";
+ break;
+ case "Right":
+ xpos = -slide.parent.width;
+ property = "x";
+ break;
+ }
+
+ time1 = new Clutter.Timeline(length / 4);
+ time2 = new Clutter.Timeline(3 * length / 4);
+ new_slide.set_scale_full(ZOOM_OUT_SCALE, ZOOM_OUT_SCALE, slide.parent.width / 2, slide.parent.height / 2);
+ new_slide.set_property(property, xpos);
+ alpha1 = new Clutter.Alpha.full(time1, Clutter.AnimationMode.EASE_IN_OUT_SINE);
+
+ time1.new_frame.connect((m) => {
+ set_scale_full(ZOOM_OUT_SCALE + (1 - ZOOM_OUT_SCALE) * (1 - alpha1.get_alpha()),
+ ZOOM_OUT_SCALE + (1 - ZOOM_OUT_SCALE) * (1 - alpha1.get_alpha()),
+ slide.parent.width / 2,
+ slide.parent.height / 2);
+ });
+ time1.completed.connect(() => {
+ animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length / 2, property, -xpos);
+ new_slide.animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, length / 2, property, 0.0f);
+ });
+ time2.completed.connect(() => {
+ time1.new_frame.connect((m) => {
+ new_slide.set_scale_full(ZOOM_OUT_SCALE + (1 - ZOOM_OUT_SCALE) * alpha1.get_alpha(),
+ ZOOM_OUT_SCALE + (1 - ZOOM_OUT_SCALE) * alpha1.get_alpha(),
+ slide.parent.width / 2,
+ slide.parent.height / 2);
});
time1.start();
- time2.start();
- break;
- }
- }
-
- private double min(double a, double b)
- {
- return a > b ? b : a;
- }
-
- private double max(double a, double b)
- {
- return a > b ? a : b;
- }
-
- private uint8 clamp_opacity(double o)
- {
- return (uint8)(max(0, min(255, o)));
+ });
+ time1.start();
+ time2.start();
+ break;
}
}
+
+ private double min(double a, double b)
+ {
+ return a > b ? b : a;
+ }
+
+ private double max(double a, double b)
+ {
+ return a > b ? a : b;
+ }
+
+ private uint8 clamp_opacity(double o)
+ {
+ return (uint8)(max(0, min(255, o)));
+ }
}
diff --git a/src/libease/SlideButton.vala b/src/libease/SlideButton.vala
index 9c7f104..e0adfbd 100644
--- a/src/libease/SlideButton.vala
+++ b/src/libease/SlideButton.vala
@@ -15,116 +15,114 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * Buttons for switching between slides in an { link EditorWindow}
+ *
+ * The SlideButtons for a { link Document} are displayed in a
+ * { link SlideButtonPanel} at the left of an{ link EditorWindow}.
+ */
+public class Ease.SlideButton : Gtk.Button
{
+ public int slide_id { get; set; }
+ public Slide slide { get; set; }
+
+ private Gtk.Alignment align;
+
+ // the clutter view
+ private GtkClutter.Embed slide_image;
+
+ // the clutter actor
+ private SlideActor actor;
+
+ // the frame to maintain the aspect ratio
+ private Gtk.AspectFrame aspect;
+
+ // the editor window this button is in
+ private EditorWindow owner;
+
+ // the panel the button is in
+ private SlideButtonPanel panel;
+
+ bool dont_loop = false;
+
/**
- * Buttons for switching between slides in an { link EditorWindow}
+ * Creates a new SlideButton.
*
- * The SlideButtons for a { link Document} are displayed in a
- * { link SlideButtonPanel} at the left of an{ link EditorWindow}.
+ * The SlideButtons are displayed in a column at the left of an
+ * { link EditorWindow}.
+ *
+ * @param id The ID number of this SlideButton, from 1 up.
+ * @param s The { link Slide} that this SlideButton displays.
+ * @param win The { link EditorWindow} that this SlideButton is
+ * displayed in.
+ * @param pan The { link SlideButtonPanel} that this SlideButton is
+ * displayed in.
*/
- public class SlideButton : Gtk.Button
+ public SlideButton(int id, Slide s, EditorWindow win, SlideButtonPanel pan)
{
- public int slide_id { get; set; }
- public Slide slide { get; set; }
-
- private Gtk.Alignment align;
-
- // the clutter view
- private GtkClutter.Embed slide_image;
-
- // the clutter actor
- private SlideActor actor;
-
- // the frame to maintain the aspect ratio
- private Gtk.AspectFrame aspect;
-
- // the editor window this button is in
- private EditorWindow owner;
-
- // the panel the button is in
- private SlideButtonPanel panel;
-
- bool dont_loop = false;
-
- /**
- * Creates a new SlideButton.
- *
- * The SlideButtons are displayed in a column at the left of an
- * { link EditorWindow}.
- *
- * @param id The ID number of this SlideButton, from 1 up.
- * @param s The { link Slide} that this SlideButton displays.
- * @param win The { link EditorWindow} that this SlideButton is
- * displayed in.
- * @param pan The { link SlideButtonPanel} that this SlideButton is
- * displayed in.
- */
- public SlideButton(int id, Slide s, EditorWindow win, SlideButtonPanel pan)
- {
- slide = s;
- slide_id = id;
- owner = win;
- panel = pan;
-
- // make the embed
- slide_image = new GtkClutter.Embed();
- var color = Clutter.Color();
- color.from_string("Black");
- ((Clutter.Stage)(slide_image.get_stage())).set_color(color);
-
- // make the slide actor
- actor = new SlideActor.from_slide(s.parent, s, true, ActorContext.SIDEBAR);
- actor.width = s.parent.width;
- actor.height = s.parent.height;
- ((Clutter.Stage)(slide_image.get_stage())).add_actor(actor);
-
- // make the aspect frame
- aspect = new Gtk.AspectFrame("Slide", 0, 0,
- (float)slide.parent.width /
- slide.parent.height,
- false);
- aspect.set_size_request(75, 50);
- aspect.label = null;
- aspect.add(slide_image);
-
- // place things together
- align = new Gtk.Alignment(0.5f, 0.5f, 0, 0);
- align.set_padding(0, 0, 0, 0);
- align.add(aspect);
-
- // set the style of the button
- aspect.shadow_type = Gtk.ShadowType.IN;
- relief = Gtk.ReliefStyle.NONE;
- focus_on_click = false;
- show_all();
- add(align);
-
- // resize the slide actor appropriately
- slide_image.size_allocate.connect((rect) => {
- actor.set_scale_full(rect.width / actor.width, rect.height / actor.height, 0, 0);
- });
-
- align.size_allocate.connect((rect) => {
- if (dont_loop)
- {
- dont_loop = false;
- return;
- }
- aspect.set_size_request(rect.width, (int)(rect.width * (float)slide.parent.height / slide.parent.width));
- dont_loop = true;
- });
-
- clicked.connect(() => {
- for (unowned GLib.List<Gtk.Widget>* itr = panel.slides_box.get_children();
- itr != null; itr = itr->next)
- {
- ((SlideButton*)(itr->data))->set_relief(Gtk.ReliefStyle.NONE);
- }
-
- relief = Gtk.ReliefStyle.NORMAL;
- owner.load_slide(slide_id);
- });
- }
+ slide = s;
+ slide_id = id;
+ owner = win;
+ panel = pan;
+
+ // make the embed
+ slide_image = new GtkClutter.Embed();
+ var color = Clutter.Color();
+ color.from_string("Black");
+ ((Clutter.Stage)(slide_image.get_stage())).set_color(color);
+
+ // make the slide actor
+ actor = new SlideActor.from_slide(s.parent, s, true, ActorContext.SIDEBAR);
+ actor.width = s.parent.width;
+ actor.height = s.parent.height;
+ ((Clutter.Stage)(slide_image.get_stage())).add_actor(actor);
+
+ // make the aspect frame
+ aspect = new Gtk.AspectFrame("Slide", 0, 0,
+ (float)slide.parent.width /
+ slide.parent.height,
+ false);
+ aspect.set_size_request(75, 50);
+ aspect.label = null;
+ aspect.add(slide_image);
+
+ // place things together
+ align = new Gtk.Alignment(0.5f, 0.5f, 0, 0);
+ align.set_padding(0, 0, 0, 0);
+ align.add(aspect);
+
+ // set the style of the button
+ aspect.shadow_type = Gtk.ShadowType.IN;
+ relief = Gtk.ReliefStyle.NONE;
+ focus_on_click = false;
+ show_all();
+ add(align);
+
+ // resize the slide actor appropriately
+ slide_image.size_allocate.connect((rect) => {
+ actor.set_scale_full(rect.width / actor.width, rect.height / actor.height, 0, 0);
+ });
+
+ align.size_allocate.connect((rect) => {
+ if (dont_loop)
+ {
+ dont_loop = false;
+ return;
+ }
+ aspect.set_size_request(rect.width, (int)(rect.width * (float)slide.parent.height / slide.parent.width));
+ dont_loop = true;
+ });
+
+ clicked.connect(() => {
+ for (unowned GLib.List<Gtk.Widget>* itr = panel.slides_box.get_children();
+ itr != null; itr = itr->next)
+ {
+ ((SlideButton*)(itr->data))->set_relief(Gtk.ReliefStyle.NONE);
+ }
+
+ relief = Gtk.ReliefStyle.NORMAL;
+ owner.load_slide(slide_id);
+ });
}
}
+
diff --git a/src/libease/SlideButtonPanel.vala b/src/libease/SlideButtonPanel.vala
index f58b57a..f733812 100644
--- a/src/libease/SlideButtonPanel.vala
+++ b/src/libease/SlideButtonPanel.vala
@@ -15,50 +15,48 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * Panel on the left side of an { link EditorWindow}
+ *
+ * A SlideButtonPanel contains a { link SlideButton} for each
+ * { link Slide} in the current { link Document}.
+ */
+public class Ease.SlideButtonPanel : Gtk.ScrolledWindow
{
+ private Document document;
+ private EditorWindow owner;
+ public Gtk.VBox slides_box;
+
/**
- * Panel on the left side of an { link EditorWindow}
+ * Creates a SlideButtonPanel
*
- * A SlideButtonPanel contains a { link SlideButton} for each
- * { link Slide} in the current { link Document}.
+ * A SlideButtonPanel forms the left edge of an { link EditorWindow}.
+ *
+ * @param d The Document that the { link EditorWindow} displays.
+ * @param win The { link EditorWindow} that this SlideButtonPanel is
+ * part of.
*/
- public class SlideButtonPanel : Gtk.ScrolledWindow
- {
- private Document document;
- private EditorWindow owner;
- public Gtk.VBox slides_box;
-
- /**
- * Creates a SlideButtonPanel
- *
- * A SlideButtonPanel forms the left edge of an { link EditorWindow}.
- *
- * @param d The Document that the { link EditorWindow} displays.
- * @param win The { link EditorWindow} that this SlideButtonPanel is
- * part of.
- */
- public SlideButtonPanel(Document d, EditorWindow win)
- {
- document = d;
- owner = win;
+ public SlideButtonPanel(Document d, EditorWindow win)
+ {
+ document = d;
+ owner = win;
- // set the scrollbar policy
- vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
- hscrollbar_policy = Gtk.PolicyType.NEVER;
-
- slides_box = new Gtk.VBox(true, 1);
- for (int i = 0; i < document.slides.size; i++)
- {
- var button = new SlideButton(i, document.slides.get(i), owner, this);
- slides_box.pack_start(button, false, false, 0);
- }
- var align = new Gtk.Alignment(0, 0, 1, 0);
- align.add(slides_box);
- var viewport = new Gtk.Viewport(null, null);
- viewport.set_shadow_type(Gtk.ShadowType.NONE);
- viewport.add(align);
- add(viewport);
+ // set the scrollbar policy
+ vscrollbar_policy = Gtk.PolicyType.AUTOMATIC;
+ hscrollbar_policy = Gtk.PolicyType.NEVER;
+
+ slides_box = new Gtk.VBox(true, 1);
+ for (int i = 0; i < document.slides.size; i++)
+ {
+ var button = new SlideButton(i, document.slides.get(i), owner, this);
+ slides_box.pack_start(button, false, false, 0);
}
+ var align = new Gtk.Alignment(0, 0, 1, 0);
+ align.add(slides_box);
+ var viewport = new Gtk.Viewport(null, null);
+ viewport.set_shadow_type(Gtk.ShadowType.NONE);
+ viewport.add(align);
+ add(viewport);
}
}
+
diff --git a/src/libease/SlidePane.vala b/src/libease/SlidePane.vala
index ab600dd..b551217 100644
--- a/src/libease/SlidePane.vala
+++ b/src/libease/SlidePane.vala
@@ -15,51 +15,49 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * The inspector pane concerning slides
+ */
+public class Ease.SlidePane : Gtk.VBox
{
- /**
- * The inspector pane concerning slides
- */
- public class SlidePane : Gtk.VBox
+ public Gtk.ComboBox effect { get; set; }
+ public Gtk.SpinButton duration { get; set; }
+ public Gtk.ComboBox variant { get; set; }
+ public Gtk.Label variant_label { get; set; }
+ public Gtk.ComboBox start_transition { get; set; }
+ public Gtk.SpinButton delay { get; set; }
+
+ public SlidePane()
{
- public Gtk.ComboBox effect { get; set; }
- public Gtk.SpinButton duration { get; set; }
- public Gtk.ComboBox variant { get; set; }
- public Gtk.Label variant_label { get; set; }
- public Gtk.ComboBox start_transition { get; set; }
- public Gtk.SpinButton delay { get; set; }
-
- public SlidePane()
- {
- homogeneous = false;
- spacing = 0;
-
- set_size_request(200, 0);
-
- // effect selection
- var vbox = new Gtk.VBox(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);
- effect = new Gtk.ComboBox();
- align = new Gtk.Alignment(0, 0, 1, 1);
- align.add(effect);
- vbox.pack_start(align, false, false, 0);
- hbox.pack_start(vbox, true, true, 5);
-
- // effect duration
- vbox = new Gtk.VBox(false, 0);
- align = new Gtk.Alignment(0, 0, 0, 0);
- align.add(new Gtk.Label("Duration"));
- vbox.pack_start(align, false, false, 0);
- duration = new Gtk.SpinButton.with_range(0, 10, 0.25);
- duration.digits = 2;
- align = new Gtk.Alignment(0, 0.5f, 1, 1);
- align.add(duration);
- vbox.pack_start(align, true, true, 0);
- hbox.pack_start(vbox, false, false, 5);
- pack_start(hbox, false, false, 5);
- }
+ homogeneous = false;
+ spacing = 0;
+
+ set_size_request(200, 0);
+
+ // effect selection
+ var vbox = new Gtk.VBox(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);
+ effect = new Gtk.ComboBox();
+ align = new Gtk.Alignment(0, 0, 1, 1);
+ align.add(effect);
+ vbox.pack_start(align, false, false, 0);
+ hbox.pack_start(vbox, true, true, 5);
+
+ // effect duration
+ vbox = new Gtk.VBox(false, 0);
+ align = new Gtk.Alignment(0, 0, 0, 0);
+ align.add(new Gtk.Label("Duration"));
+ vbox.pack_start(align, false, false, 0);
+ duration = new Gtk.SpinButton.with_range(0, 10, 0.25);
+ duration.digits = 2;
+ align = new Gtk.Alignment(0, 0.5f, 1, 1);
+ align.add(duration);
+ vbox.pack_start(align, true, true, 0);
+ hbox.pack_start(vbox, false, false, 5);
+ pack_start(hbox, false, false, 5);
}
}
+
diff --git a/src/libease/TextActor.vala b/src/libease/TextActor.vala
index c23ca36..f9666a9 100644
--- a/src/libease/TextActor.vala
+++ b/src/libease/TextActor.vala
@@ -15,51 +15,48 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * { link Actor} for blocks of text
+ *
+ * TextActor uses { link Clutter.Text} for rendering.
+ */
+public class Ease.TextActor : Actor
{
/**
- * { link Actor} for blocks of text
+ * Instantiates a new TextActor from an Element.
*
* TextActor uses { link Clutter.Text} for rendering.
+ *
+ * @param e The represented element.
+ * @param c The context of this Actor (Presentation, Sidebar, Editor)
*/
- public class TextActor : Actor
+ public TextActor(Element e, ActorContext c)
{
- /**
- * Instantiates a new TextActor from an Element.
- *
- * TextActor uses { link Clutter.Text} for rendering.
- *
- * @param e The represented element.
- * @param c The context of this Actor (Presentation, Sidebar, Editor)
- */
- public TextActor(Element e, ActorContext c)
- {
- base(e, c);
-
- contents = new Clutter.Text();
+ base(e, c);
+
+ contents = new Clutter.Text();
- // set basic actor properties
- ((Clutter.Text)contents).use_markup = true;
- ((Clutter.Text)contents).line_wrap = true;
- ((Clutter.Text)contents).line_wrap_mode = Pango.WrapMode.WORD_CHAR;
- ((Clutter.Text)contents).color = e.color;
- ((Clutter.Text)contents).set_markup(e.data.get("text"));
-
- // create the font description
- var desc = new Pango.FontDescription();
- desc.set_family(e.data.get("font_name"));
- desc.set_weight(e.font_weight);
- desc.set_variant(e.font_variant);
- desc.set_size(e.font_size * Pango.SCALE);
- ((Clutter.Text)contents).font_name = desc.to_string();
- ((Clutter.Text)contents).set_line_alignment(e.text_align);
-
- add_actor(contents);
- contents.width = e.width;
- contents.height = e.height;
- x = e.x;
- y = e.y;
- }
+ // set basic actor properties
+ ((Clutter.Text)contents).use_markup = true;
+ ((Clutter.Text)contents).line_wrap = true;
+ ((Clutter.Text)contents).line_wrap_mode = Pango.WrapMode.WORD_CHAR;
+ ((Clutter.Text)contents).color = e.color;
+ ((Clutter.Text)contents).set_markup(e.data.get("text"));
+
+ // create the font description
+ var desc = new Pango.FontDescription();
+ desc.set_family(e.data.get("font_name"));
+ desc.set_weight(e.font_weight);
+ desc.set_variant(e.font_variant);
+ desc.set_size(e.font_size * Pango.SCALE);
+ ((Clutter.Text)contents).font_name = desc.to_string();
+ ((Clutter.Text)contents).set_line_alignment(e.text_align);
+
+ add_actor(contents);
+ contents.width = e.width;
+ contents.height = e.height;
+ x = e.x;
+ y = e.y;
}
}
diff --git a/src/libease/Theme.vala b/src/libease/Theme.vala
index 436c321..16eef27 100644
--- a/src/libease/Theme.vala
+++ b/src/libease/Theme.vala
@@ -15,12 +15,10 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * Internal representation of Ease themes
+ */
+public class Ease.Theme : GLib.Object
{
- /**
- * Internal representation of Ease themes
- */
- public class Theme : GLib.Object
- {
- }
}
+
diff --git a/src/libease/TransitionPane.vala b/src/libease/TransitionPane.vala
index 24f4186..be9fa0b 100644
--- a/src/libease/TransitionPane.vala
+++ b/src/libease/TransitionPane.vala
@@ -15,111 +15,110 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+
+/**
+ * The inspector pane for changing transitions
+ */
+public class Ease.TransitionPane : Gtk.VBox
{
- /**
- * The inspector pane for changing transitions
- */
- public class TransitionPane : Gtk.VBox
+ public Gtk.ComboBox effect { get; set; }
+ public Gtk.SpinButton duration { get; set; }
+ public Gtk.ComboBox variant { get; set; }
+ public Gtk.Alignment variant_align { get; set; }
+ public Gtk.Label variant_label { get; set; }
+ public Gtk.ComboBox start_transition { get; set; }
+ public Gtk.SpinButton delay { get; set; }
+ public GtkClutter.Embed preview;
+
+ public TransitionPane()
{
- public Gtk.ComboBox effect { get; set; }
- public Gtk.SpinButton duration { get; set; }
- public Gtk.ComboBox variant { get; set; }
- public Gtk.Alignment variant_align { get; set; }
- public Gtk.Label variant_label { get; set; }
- public Gtk.ComboBox start_transition { get; set; }
- public Gtk.SpinButton delay { get; set; }
- public GtkClutter.Embed preview;
-
- public TransitionPane()
+ homogeneous = false;
+ spacing = 0;
+
+ set_size_request(200, 0);
+
+ // preview
+ preview = new GtkClutter.Embed();
+ preview.set_size_request(0, 100);
+ var color = Clutter.Color();
+ color.from_string("Black");
+ ((Clutter.Stage)(preview.get_stage())).set_color(color);
+ 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);
+
+ // transition selection
+ var vbox = new Gtk.VBox(false, 0);
+ 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);
+ effect = new Gtk.ComboBox.text();
+ for (var i = 0; i < Transitions.size; i++)
{
- homogeneous = false;
- spacing = 0;
-
- set_size_request(200, 0);
-
- // preview
- preview = new GtkClutter.Embed();
- preview.set_size_request(0, 100);
- var color = Clutter.Color();
- color.from_string("Black");
- ((Clutter.Stage)(preview.get_stage())).set_color(color);
- 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);
-
- // transition selection
- var vbox = new Gtk.VBox(false, 0);
- 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);
- effect = new Gtk.ComboBox.text();
- for (var i = 0; i < Transitions.size; i++)
- {
- effect.append_text(Transitions.get_name(i));
- }
- effect.set_active(0);
- align = new Gtk.Alignment(0, 0, 1, 1);
- align.add(effect);
- vbox.pack_start(align, false, false, 0);
- hbox.pack_start(vbox, true, true, 5);
-
- // transition duration
- vbox = new Gtk.VBox(false, 0);
- align = new Gtk.Alignment(0, 0, 0, 0);
- align.add(new Gtk.Label("Duration"));
- vbox.pack_start(align, false, false, 0);
- duration = new Gtk.SpinButton.with_range(0, 10, 0.25);
- duration.digits = 2;
- align = new Gtk.Alignment(0, 0.5f, 1, 1);
- align.add(duration);
- vbox.pack_start(align, true, true, 0);
- hbox.pack_start(vbox, false, false, 5);
- pack_start(hbox, false, false, 5);
-
- // transition variant
- hbox = new Gtk.HBox(false, 0);
- vbox = new Gtk.VBox(false, 0);
- align = new Gtk.Alignment(0, 0, 0, 0);
- align.add(new Gtk.Label("Direction"));
- vbox.pack_start(align, false, false, 0);
- variant = new Gtk.ComboBox.text();
- variant_align = new Gtk.Alignment(0, 0, 1, 1);
- variant_align.add(variant);
- vbox.pack_start(variant_align, false, false, 0);
- hbox.pack_start(vbox, true, true, 5);
- pack_start(hbox, false, false, 5);
-
- // start transition
- vbox = new Gtk.VBox(false, 0);
- hbox = new Gtk.HBox(false, 0);
- align = new Gtk.Alignment(0, 0, 0, 0);
- align.add(new Gtk.Label("Start Transition"));
- vbox.pack_start(align, false, false, 0);
- start_transition = new Gtk.ComboBox.text();
- start_transition.append_text("Manually");
- start_transition.append_text("Automatically");
- start_transition.set_active(0);
- align = new Gtk.Alignment(0, 0, 1, 1);
- align.add(start_transition);
- vbox.pack_start(align, false, false, 0);
- hbox.pack_start(vbox, true, true, 5);
-
- // start transition delay
- vbox = new Gtk.VBox(false, 0);
- align = new Gtk.Alignment(0, 0, 0, 0);
- align.add(new Gtk.Label("Delay"));
- vbox.pack_start(align, false, false, 0);
- delay = new Gtk.SpinButton.with_range(0, 10, 0.25);
- delay.digits = 2;
- align = new Gtk.Alignment(0, 0.5f, 1, 1);
- align.add(delay);
- vbox.pack_start(align, true, true, 0);
- hbox.pack_start(vbox, false, false, 5);
- pack_start(hbox, false, false, 5);
+ effect.append_text(Transitions.get_name(i));
}
+ effect.set_active(0);
+ align = new Gtk.Alignment(0, 0, 1, 1);
+ align.add(effect);
+ vbox.pack_start(align, false, false, 0);
+ hbox.pack_start(vbox, true, true, 5);
+
+ // transition duration
+ vbox = new Gtk.VBox(false, 0);
+ align = new Gtk.Alignment(0, 0, 0, 0);
+ align.add(new Gtk.Label("Duration"));
+ vbox.pack_start(align, false, false, 0);
+ duration = new Gtk.SpinButton.with_range(0, 10, 0.25);
+ duration.digits = 2;
+ align = new Gtk.Alignment(0, 0.5f, 1, 1);
+ align.add(duration);
+ vbox.pack_start(align, true, true, 0);
+ hbox.pack_start(vbox, false, false, 5);
+ pack_start(hbox, false, false, 5);
+
+ // transition variant
+ hbox = new Gtk.HBox(false, 0);
+ vbox = new Gtk.VBox(false, 0);
+ align = new Gtk.Alignment(0, 0, 0, 0);
+ align.add(new Gtk.Label("Direction"));
+ vbox.pack_start(align, false, false, 0);
+ variant = new Gtk.ComboBox.text();
+ variant_align = new Gtk.Alignment(0, 0, 1, 1);
+ variant_align.add(variant);
+ vbox.pack_start(variant_align, false, false, 0);
+ hbox.pack_start(vbox, true, true, 5);
+ pack_start(hbox, false, false, 5);
+
+ // start transition
+ vbox = new Gtk.VBox(false, 0);
+ hbox = new Gtk.HBox(false, 0);
+ align = new Gtk.Alignment(0, 0, 0, 0);
+ align.add(new Gtk.Label("Start Transition"));
+ vbox.pack_start(align, false, false, 0);
+ start_transition = new Gtk.ComboBox.text();
+ start_transition.append_text("Manually");
+ start_transition.append_text("Automatically");
+ start_transition.set_active(0);
+ align = new Gtk.Alignment(0, 0, 1, 1);
+ align.add(start_transition);
+ vbox.pack_start(align, false, false, 0);
+ hbox.pack_start(vbox, true, true, 5);
+
+ // start transition delay
+ vbox = new Gtk.VBox(false, 0);
+ align = new Gtk.Alignment(0, 0, 0, 0);
+ align.add(new Gtk.Label("Delay"));
+ vbox.pack_start(align, false, false, 0);
+ delay = new Gtk.SpinButton.with_range(0, 10, 0.25);
+ delay.digits = 2;
+ align = new Gtk.Alignment(0, 0.5f, 1, 1);
+ align.add(delay);
+ vbox.pack_start(align, true, true, 0);
+ hbox.pack_start(vbox, false, false, 5);
+ pack_start(hbox, false, false, 5);
}
}
+
diff --git a/src/libease/Transitions.vala b/src/libease/Transitions.vala
index 4c34e2b..481b87b 100644
--- a/src/libease/Transitions.vala
+++ b/src/libease/Transitions.vala
@@ -15,125 +15,123 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * A static class containing all Ease transitions
+ *
+ * The transition class is initialized at program start. It contains
+ * information about each transition and each transition's variants.
+ */
+public static class Ease.Transitions : GLib.Object
{
+ private static Gee.ArrayList<Transition> Transitions;
+
+ public static int size { get { return Transitions.size; } }
+
/**
- * A static class containing all Ease transitions
+ * Initialize the Transitions class.
+ *
+ * Called when Ease starts.
+ */
+ public static void init()
+ {
+ Transitions = new Gee.ArrayList<Transition>();
+ add_transition("None", {}, 0);
+ add_transition("Fade", {}, 0);
+ add_transition("Slide", { "Up", "Down", "Left", "Right" }, 4);
+ add_transition("Drop", {}, 0);
+ add_transition("Pivot", { "Top Left", "Top Right", "Bottom Left", "Bottom Right" }, 4);
+ add_transition("Flip", { "Top to Bottom", "Bottom to Top", "Left to Right", "Right to Left" }, 4);
+ add_transition("Revolving Door", { "Top", "Bottom", "Left", "Right" }, 4);
+ add_transition("Fall", {}, 0);
+ add_transition("Zoom", { "Center", "Top Left", "Top Right", "Bottom Left", "Bottom Right" }, 5);
+ add_transition("Panel", { "Up", "Down", "Left", "Right" }, 4);
+ add_transition("Spin Contents", { "Left", "Right" }, 2);
+ add_transition("Swing Contents", {}, 0);
+ add_transition("Slide Contents", { "Up", "Down", "Left", "Right" }, 4);
+ add_transition("Spring Contents", { "Up", "Down" }, 2);
+ add_transition("Zoom Contents", { "In", "Out" }, 2);
+ }
+
+ /**
+ * Returns the string name of a transition.
+ *
+ * @param i The transition index.
+ */
+ public static string get_name(int i)
+ {
+ return Transitions.get(i).name;
+ }
+
+ /**
+ * Given a name, returns the ID of a transition.
*
- * The transition class is initialized at program start. It contains
- * information about each transition and each transition's variants.
+ * @param name The name of the transition.
*/
- public static class Transitions : GLib.Object
+ public static int get_transition_id(string name)
{
- private static Gee.ArrayList<Transition> Transitions;
-
- public static int size { get { return Transitions.size; } }
-
- /**
- * Initialize the Transitions class.
- *
- * Called when Ease starts.
- */
- public static void init()
- {
- Transitions = new Gee.ArrayList<Transition>();
- add_transition("None", {}, 0);
- add_transition("Fade", {}, 0);
- add_transition("Slide", { "Up", "Down", "Left", "Right" }, 4);
- add_transition("Drop", {}, 0);
- add_transition("Pivot", { "Top Left", "Top Right", "Bottom Left", "Bottom Right" }, 4);
- add_transition("Flip", { "Top to Bottom", "Bottom to Top", "Left to Right", "Right to Left" }, 4);
- add_transition("Revolving Door", { "Top", "Bottom", "Left", "Right" }, 4);
- add_transition("Fall", {}, 0);
- add_transition("Zoom", { "Center", "Top Left", "Top Right", "Bottom Left", "Bottom Right" }, 5);
- add_transition("Panel", { "Up", "Down", "Left", "Right" }, 4);
- add_transition("Spin Contents", { "Left", "Right" }, 2);
- add_transition("Swing Contents", {}, 0);
- add_transition("Slide Contents", { "Up", "Down", "Left", "Right" }, 4);
- add_transition("Spring Contents", { "Up", "Down" }, 2);
- add_transition("Zoom Contents", { "In", "Out" }, 2);
- }
-
- /**
- * Returns the string name of a transition.
- *
- * @param i The transition index.
- */
- public static string get_name(int i)
+ for (var i = 0; i < Transitions.size; i++)
{
- return Transitions.get(i).name;
- }
-
- /**
- * Given a name, returns the ID of a transition.
- *
- * @param name The name of the transition.
- */
- public static int get_transition_id(string name)
- {
- for (var i = 0; i < Transitions.size; i++)
+ if (Transitions.get(i).name == name)
{
- if (Transitions.get(i).name == name)
- {
- return i;
- }
+ return i;
}
- return 0;
}
-
- /**
- * Returns the ID of a transition, given the names of both.
- *
- * @param transition The name of the transition.
- * @param variant The name of the variant.
- */
- public static int get_variant_id(string transition, string variant)
+ return 0;
+ }
+
+ /**
+ * Returns the ID of a transition, given the names of both.
+ *
+ * @param transition The name of the transition.
+ * @param variant The name of the variant.
+ */
+ public static int get_variant_id(string transition, string variant)
+ {
+ var id = get_transition_id(transition);
+ for (var i = 0; i < Transitions.get(id).count; i++)
{
- var id = get_transition_id(transition);
- for (var i = 0; i < Transitions.get(id).count; i++)
+ if (Transitions.get(id).variants[i] == variant)
{
- if (Transitions.get(id).variants[i] == variant)
- {
- return i;
- }
+ return i;
}
- return 0;
- }
-
- /**
- * Returns an array of variants, given a transition ID.
- *
- * @param i A transition index.
- */
- public static string[] get_variants(int i)
- {
- return Transitions.get(i).variants;
- }
-
- /**
- * Returns the size of the variant array, give a transition ID.
- *
- * @param i A transition index.
- */
- public static int get_variant_count(int i)
- {
- return Transitions.get(i).count;
- }
-
- private static void add_transition(string n, string[] v, int c)
- {
- Transition t = new Transition();
- t.name = n;
- t.variants = v;
- t.count = c;
- Transitions.add(t);
- }
-
- private class Transition : GLib.Object
- {
- public string name { get; set; }
- public int count { get; set; }
- public string[] variants;
}
+ return 0;
+ }
+
+ /**
+ * Returns an array of variants, given a transition ID.
+ *
+ * @param i A transition index.
+ */
+ public static string[] get_variants(int i)
+ {
+ return Transitions.get(i).variants;
+ }
+
+ /**
+ * Returns the size of the variant array, give a transition ID.
+ *
+ * @param i A transition index.
+ */
+ public static int get_variant_count(int i)
+ {
+ return Transitions.get(i).count;
+ }
+
+ private static void add_transition(string n, string[] v, int c)
+ {
+ Transition t = new Transition();
+ t.name = n;
+ t.variants = v;
+ t.count = c;
+ Transitions.add(t);
+ }
+
+ private class Transition : GLib.Object
+ {
+ public string name { get; set; }
+ public int count { get; set; }
+ public string[] variants;
}
}
+
diff --git a/src/libease/VideoActor.vala b/src/libease/VideoActor.vala
index dedc9ce..895d368 100644
--- a/src/libease/VideoActor.vala
+++ b/src/libease/VideoActor.vala
@@ -15,52 +15,50 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * { link Actor} for videos
+ *
+ * VideoActor uses Clutter-GStreamer, and therefore supports any video
+ * format supported by the GStreamer plugins on the user's system.
+ */
+public class Ease.VideoActor : Actor
{
/**
- * { link Actor} for videos
+ * Instantiates a new VideoActor from an Element.
+ *
+ * The VideoActor's context is particularly important due to playback.
+ * Playing back automatically in the editor would, of course, not be
+ * desired.
*
- * VideoActor uses Clutter-GStreamer, and therefore supports any video
- * format supported by the GStreamer plugins on the user's system.
+ * @param e The represented element.
+ * @param c The context of this Actor (Presentation, Sidebar, Editor)
*/
- public class VideoActor : Actor
+ public VideoActor(Element e, ActorContext c)
{
- /**
- * Instantiates a new VideoActor from an Element.
- *
- * The VideoActor's context is particularly important due to playback.
- * Playing back automatically in the editor would, of course, not be
- * desired.
- *
- * @param e The represented element.
- * @param c The context of this Actor (Presentation, Sidebar, Editor)
- */
- public VideoActor(Element e, ActorContext c)
- {
- base(e, c);
-
- var video = new ClutterGst.VideoTexture();
- video.set_filename(e.parent.parent.path + e.data.get("filename"));
+ base(e, c);
- // play the video if it's in the presentation
- if (c == ActorContext.PRESENTATION)
- {
- video.set_playing(true);
- }
- else
- {
- // FIXME: toggle playback to get a frame
- video.set_playing(true);
- video.set_playing(false);
- }
-
- contents = video;
+ var video = new ClutterGst.VideoTexture();
+ video.set_filename(e.parent.parent.path + e.data.get("filename"));
- add_actor(contents);
- contents.width = e.width;
- contents.height = e.height;
- x = e.x;
- y = e.y;
+ // play the video if it's in the presentation
+ if (c == ActorContext.PRESENTATION)
+ {
+ video.set_playing(true);
}
+ else
+ {
+ // FIXME: toggle playback to get a frame
+ video.set_playing(true);
+ video.set_playing(false);
+ }
+
+ contents = video;
+
+ add_actor(contents);
+ contents.width = e.width;
+ contents.height = e.height;
+ x = e.x;
+ y = e.y;
}
}
+
diff --git a/src/libease/WelcomeActor.vala b/src/libease/WelcomeActor.vala
index 1749dc5..d03a5d9 100644
--- a/src/libease/WelcomeActor.vala
+++ b/src/libease/WelcomeActor.vala
@@ -15,83 +15,81 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * { link Theme} tiles on the { link WelcomeWindow}
+ *
+ * Each WelcomeActor is a preview of a { link Theme}. The user can
+ * click on these to create a new { link Document} with that { link Theme}.
+ */
+public class Ease.WelcomeActor : Clutter.Rectangle
{
- /**
- * { link Theme} tiles on the { link WelcomeWindow}
- *
- * Each WelcomeActor is a preview of a { link Theme}. The user can
- * click on these to create a new { link Document} with that { link Theme}.
- */
- public class WelcomeActor : Clutter.Rectangle
+ private Gee.ArrayList<WelcomeActor> others;
+ private bool selected = false;
+ private bool faded = false;
+
+ public WelcomeActor(int w, ref Gee.ArrayList<WelcomeActor> o)
{
- private Gee.ArrayList<WelcomeActor> others;
- private bool selected = false;
- private bool faded = false;
+ width = w;
+ others = o;
+ height = w * 3 / 4; // 4:3
+
+ // TODO: make this an actual preview
+ var color = Clutter.Color();
+ color.from_hls((float)Random.next_double() * 360, 0.5f, 0.5f);
+ color.from_string("Pink");
+ set_color(color);
- public WelcomeActor(int w, ref Gee.ArrayList<WelcomeActor> o)
+ color = Clutter.Color();
+ color.from_string("White");
+ set_border_color(color);
+ set_border_width(2);
+ }
+
+ public void clicked()
+ {
+ stdout.printf("clicked!\n");
+ if (selected)
{
- width = w;
- others = o;
- height = w * 3 / 4; // 4:3
-
- // TODO: make this an actual preview
- var color = Clutter.Color();
- color.from_hls((float)Random.next_double() * 360, 0.5f, 0.5f);
- color.from_string("Pink");
- set_color(color);
+ // unfade the others
+ foreach (var a in others)
+ if (a != this)
+ a.unfade();
- color = Clutter.Color();
- color.from_string("White");
- set_border_color(color);
- set_border_width(2);
- }
-
- public void clicked()
- {
- stdout.printf("clicked!\n");
- if (selected)
- {
- // unfade the others
- foreach (var a in others)
- if (a != this)
- a.unfade();
-
- deselect();
- }
- else
- {
- // fade the others
- foreach (var a in others)
- if (a != this)
- a.fade();
-
- select();
- }
- }
-
- private void fade()
- {
- faded = true;
- animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, 250, "alpha", 0.5f);
- }
-
- private void unfade()
- {
- faded = false;
- animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, 250, "alpha", 1);
- }
-
- private void select()
- {
- selected = true;
- //animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, 250, "alpha", 0.5f);
+ deselect();
}
-
- private void deselect()
+ else
{
- selected = false;
- //animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, 250, "alpha", 1);
+ // fade the others
+ foreach (var a in others)
+ if (a != this)
+ a.fade();
+
+ select();
}
}
+
+ private void fade()
+ {
+ faded = true;
+ animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, 250, "alpha", 0.5f);
+ }
+
+ private void unfade()
+ {
+ faded = false;
+ animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, 250, "alpha", 1);
+ }
+
+ private void select()
+ {
+ selected = true;
+ //animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, 250, "alpha", 0.5f);
+ }
+
+ private void deselect()
+ {
+ selected = false;
+ //animate(Clutter.AnimationMode.EASE_IN_OUT_SINE, 250, "alpha", 1);
+ }
}
+
diff --git a/src/libease/WelcomeWindow.vala b/src/libease/WelcomeWindow.vala
index 2e417ec..733219f 100644
--- a/src/libease/WelcomeWindow.vala
+++ b/src/libease/WelcomeWindow.vala
@@ -15,280 +15,278 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-namespace Ease
+/**
+ * The window shown when Ease starts
+ *
+ * The WelcomeWindow contains a { link ScrollableEmbed} with
+ * { link WelcomeActor}s for each { link Theme} installed. From this
+ * window, the user can either create a new { link Document} or open
+ * an existing one.
+ */
+public class Ease.WelcomeWindow : Gtk.Window
{
- /**
- * The window shown when Ease starts
- *
- * The WelcomeWindow contains a { link ScrollableEmbed} with
- * { link WelcomeActor}s for each { link Theme} installed. From this
- * window, the user can either create a new { link Document} or open
- * an existing one.
- */
- public class WelcomeWindow : Gtk.Window
- {
- // main buttons
- private Gtk.Button new_button;
- private Gtk.Button open_button;
- private Gtk.ComboBox resolution;
- private Gtk.SpinButton x_res;
- private Gtk.SpinButton y_res;
+ // main buttons
+ private Gtk.Button new_button;
+ private Gtk.Button open_button;
+ private Gtk.ComboBox resolution;
+ private Gtk.SpinButton x_res;
+ private Gtk.SpinButton y_res;
- // clutter view
- private ScrollableEmbed embed;
+ // clutter view
+ private ScrollableEmbed embed;
- // previews
- private Clutter.Group preview_container;
- private Clutter.Rectangle preview_background;
- private Gee.ArrayList<WelcomeActor> previews = new Gee.ArrayList<WelcomeActor>();
- private int preview_width = 100;
- private float preview_aspect;
+ // previews
+ private Clutter.Group preview_container;
+ private Clutter.Rectangle preview_background;
+ private Gee.ArrayList<WelcomeActor> previews = new Gee.ArrayList<WelcomeActor>();
+ private int preview_width = 100;
+ private float preview_aspect;
- // zoom widgets
- private Gtk.HScale zoom_slider;
- private Gtk.Button zoom_in;
- private Gtk.Button zoom_out;
-
- // constants
- private const int[] RESOLUTIONS_X = {800,
- 1024,
- 1280,
- 1280,
- 1920};
- private const int[] RESOLUTIONS_Y = {600,
- 768,
- 1024,
- 720,
- 1080};
- private const int RESOLUTION_COUNT = 5;
- private const int PREVIEW_PADDING = 20;
+ // zoom widgets
+ private Gtk.HScale zoom_slider;
+ private Gtk.Button zoom_in;
+ private Gtk.Button zoom_out;
+
+ // constants
+ private const int[] RESOLUTIONS_X = {800,
+ 1024,
+ 1280,
+ 1280,
+ 1920};
+ private const int[] RESOLUTIONS_Y = {600,
+ 768,
+ 1024,
+ 720,
+ 1080};
+ private const int RESOLUTION_COUNT = 5;
+ private const int PREVIEW_PADDING = 20;
+
+ public WelcomeWindow()
+ {
+ title = "New Presentation";
+ set_default_size(640, 480);
- public WelcomeWindow()
+ // build the bottom UI
+ var hbox = new Gtk.HBox(false, 5);
+ resolution = new Gtk.ComboBox.text();
+ resolution.append_text("Custom");
+ for (var i = 0; i < RESOLUTION_COUNT; i++)
{
- title = "New Presentation";
- set_default_size(640, 480);
-
- // build the bottom UI
- var hbox = new Gtk.HBox(false, 5);
- resolution = new Gtk.ComboBox.text();
- resolution.append_text("Custom");
- for (var i = 0; i < RESOLUTION_COUNT; i++)
- {
- resolution.append_text("%i by %i".printf(RESOLUTIONS_X[i], RESOLUTIONS_Y[i]));
- }
- resolution.set_active(2);
-
- var align = new Gtk.Alignment(0, 0.5f, 0, 0);
- align.add(resolution);
- hbox.pack_start(align, false, false, 0);
-
- x_res = new Gtk.SpinButton.with_range(320, 1920, 1);
- x_res.set_value(1024);
- align = new Gtk.Alignment(0, 0.5f, 0, 0);
- align.add(x_res);
- hbox.pack_start(align, false, false, 0);
-
- y_res = new Gtk.SpinButton.with_range(240, 1920, 1);
- y_res.set_value(768);
- align = new Gtk.Alignment(0, 0.5f, 0, 0);
- align.add(y_res);
- hbox.pack_start(align, false, false, 0);
-
- new_button = new Gtk.Button.with_label("New Presentation");
- new_button.image = new Gtk.Image.from_stock("gtk-new", Gtk.IconSize.BUTTON);
- align = new Gtk.Alignment(0, 0.5f, 0, 0);
- align.add(new_button);
- hbox.pack_start(align, false, false, 0);
-
- hbox.pack_start(create_zoom_bar(), false, false, 0);
-
- open_button = new Gtk.Button.from_stock("gtk-open");
- align = new Gtk.Alignment(0, 0.5f, 0, 0);
- align.add(open_button);
- hbox.pack_end(align, false, false, 0);
-
- // create the upper UI - the embed
- embed = new ScrollableEmbed(false);
+ resolution.append_text("%i by %i".printf(RESOLUTIONS_X[i], RESOLUTIONS_Y[i]));
+ }
+ resolution.set_active(2);
+
+ var align = new Gtk.Alignment(0, 0.5f, 0, 0);
+ align.add(resolution);
+ hbox.pack_start(align, false, false, 0);
+
+ x_res = new Gtk.SpinButton.with_range(320, 1920, 1);
+ x_res.set_value(1024);
+ align = new Gtk.Alignment(0, 0.5f, 0, 0);
+ align.add(x_res);
+ hbox.pack_start(align, false, false, 0);
+
+ y_res = new Gtk.SpinButton.with_range(240, 1920, 1);
+ y_res.set_value(768);
+ align = new Gtk.Alignment(0, 0.5f, 0, 0);
+ align.add(y_res);
+ hbox.pack_start(align, false, false, 0);
+
+ new_button = new Gtk.Button.with_label("New Presentation");
+ new_button.image = new Gtk.Image.from_stock("gtk-new", Gtk.IconSize.BUTTON);
+ align = new Gtk.Alignment(0, 0.5f, 0, 0);
+ align.add(new_button);
+ hbox.pack_start(align, false, false, 0);
+
+ hbox.pack_start(create_zoom_bar(), false, false, 0);
+
+ open_button = new Gtk.Button.from_stock("gtk-open");
+ align = new Gtk.Alignment(0, 0.5f, 0, 0);
+ align.add(open_button);
+ hbox.pack_end(align, false, false, 0);
+
+ // create the upper UI - the embed
+ embed = new ScrollableEmbed(false);
- // create the preview container
- preview_container = new Clutter.Group();
+ // create the preview container
+ preview_container = new Clutter.Group();
- // the background for the previews
- preview_background = new Clutter.Rectangle();
- var color = Clutter.Color();
- color.from_string("Black");
- preview_background.color = color;
- preview_container.add_actor(preview_background);
-
- // create the previews
- for (var i = 0; i < 10; i++)
+ // the background for the previews
+ preview_background = new Clutter.Rectangle();
+ var color = Clutter.Color();
+ color.from_string("Black");
+ preview_background.color = color;
+ preview_container.add_actor(preview_background);
+
+ // create the previews
+ for (var i = 0; i < 10; i++)
+ {
+ var act = new WelcomeActor(preview_width, ref previews);
+ previews.add(act);
+ preview_container.add_actor(act);
+ }
+ embed.contents.add_actor(preview_container);
+ embed.contents.show_all();
+
+ // put it all together
+ var vbox = new Gtk.VBox(false, 0);
+ align = new Gtk.Alignment(0, 1, 1, 0);
+ align.add(hbox);
+ align.set_padding(5, 5, 5, 5);
+ vbox.pack_end(align, false, false, 0);
+ vbox.pack_end(new Gtk.HSeparator(), false, false, 0);
+ vbox.pack_start(embed, true, true, 0);
+
+ add(vbox);
+ show_all();
+ reflow_previews();
+
+ // ui signals
+ // changing resolution values
+ x_res.value_changed.connect(() => {
+ set_resolution_box((int)(x_res.get_value()), (int)(y_res.get_value()));
+ });
+
+ y_res.value_changed.connect(() => {
+ set_resolution_box((int)(x_res.get_value()), (int)(y_res.get_value()));
+ });
+
+ resolution.changed.connect(() => {
+ var val = resolution.get_active();
+ if (val > 0)
{
- var act = new WelcomeActor(preview_width, ref previews);
- previews.add(act);
- preview_container.add_actor(act);
+ x_res.set_value(RESOLUTIONS_X[val - 1]);
+ y_res.set_value(RESOLUTIONS_Y[val - 1]);
}
- embed.contents.add_actor(preview_container);
- embed.contents.show_all();
-
- // put it all together
- var vbox = new Gtk.VBox(false, 0);
- align = new Gtk.Alignment(0, 1, 1, 0);
- align.add(hbox);
- align.set_padding(5, 5, 5, 5);
- vbox.pack_end(align, false, false, 0);
- vbox.pack_end(new Gtk.HSeparator(), false, false, 0);
- vbox.pack_start(embed, true, true, 0);
-
- add(vbox);
- show_all();
reflow_previews();
-
- // ui signals
- // changing resolution values
- x_res.value_changed.connect(() => {
- set_resolution_box((int)(x_res.get_value()), (int)(y_res.get_value()));
- });
-
- y_res.value_changed.connect(() => {
- set_resolution_box((int)(x_res.get_value()), (int)(y_res.get_value()));
- });
-
- resolution.changed.connect(() => {
- var val = resolution.get_active();
- if (val > 0)
- {
- x_res.set_value(RESOLUTIONS_X[val - 1]);
- y_res.set_value(RESOLUTIONS_Y[val - 1]);
- }
- reflow_previews();
- });
-
- // reflow the stage
- embed.size_allocate.connect(() => {
- reflow_previews();
- });
-
- // click on previews
- foreach (var a in previews)
- {
- a.button_press_event.connect(e => {
- ((WelcomeActor)(e.button.source)).clicked();
- return false;
- });
- }
-
- // change the zoom of the previews when the zoom slider is moved
- zoom_slider.value_changed.connect(() => {
- preview_width = (int)zoom_slider.get_value();
- reflow_previews();
+ });
+
+ // reflow the stage
+ embed.size_allocate.connect(() => {
+ reflow_previews();
+ });
+
+ // click on previews
+ foreach (var a in previews)
+ {
+ a.button_press_event.connect(e => {
+ ((WelcomeActor)(e.button.source)).clicked();
+ return false;
});
-
- open_button.clicked.connect((sender) => OpenDialog.run());
}
- private void set_resolution_box(int width, int height)
+ // change the zoom of the previews when the zoom slider is moved
+ zoom_slider.value_changed.connect(() => {
+ preview_width = (int)zoom_slider.get_value();
+ reflow_previews();
+ });
+
+ open_button.clicked.connect((sender) => OpenDialog.run());
+ }
+
+ private void set_resolution_box(int width, int height)
+ {
+ for (var i = 0; i < RESOLUTION_COUNT; i++)
{
- for (var i = 0; i < RESOLUTION_COUNT; i++)
+ if (width == RESOLUTIONS_X[i] && height == RESOLUTIONS_Y[i])
{
- if (width == RESOLUTIONS_X[i] && height == RESOLUTIONS_Y[i])
- {
- resolution.set_active(i + 1);
- return;
- }
+ resolution.set_active(i + 1);
+ return;
}
- resolution.set_active(0);
- reflow_previews();
}
+ resolution.set_active(0);
+ reflow_previews();
+ }
+
+ private void reflow_previews()
+ {
+ // calculate the preview aspect ratio
+ preview_aspect = (float)(y_res.get_value() / x_res.get_value());
- private void reflow_previews()
- {
- // calculate the preview aspect ratio
- preview_aspect = (float)(y_res.get_value() / x_res.get_value());
-
- // calculate the number of previews per line
- var per_line = 2;
- for (; per_line * (preview_width + PREVIEW_PADDING) + PREVIEW_PADDING < embed.width;
- per_line++);
- per_line--; // FIXME: the math is not strong in me at 2 AM
+ // calculate the number of previews per line
+ var per_line = 2;
+ for (; per_line * (preview_width + PREVIEW_PADDING) + PREVIEW_PADDING < embed.width;
+ per_line++);
+ per_line--; // FIXME: the math is not strong in me at 2 AM
- // find the initial x position of previews
- var x_origin = embed.width / 2 -
- (preview_width * per_line + PREVIEW_PADDING * (per_line - 1)) / 2;
+ // find the initial x position of previews
+ var x_origin = embed.width / 2 -
+ (preview_width * per_line + PREVIEW_PADDING * (per_line - 1)) / 2;
- // the y position in pixels
- float y_pixels = PREVIEW_PADDING;
+ // the y position in pixels
+ float y_pixels = PREVIEW_PADDING;
- // the x position in previews
- int x_position = 0;
+ // the x position in previews
+ int x_position = 0;
- // place the previews
- for (var i = 0; i < previews.size; i++)
- {
- // set the position of the preview
- previews.get(i).x = x_origin + x_position * (PREVIEW_PADDING + preview_width);
- previews.get(i).y = y_pixels;
-
- // set the size of the preview
- previews.get(i).width = preview_width;
- previews.get(i).height = preview_width * preview_aspect;
-
- // go to the next line
- if (++x_position >= per_line)
- {
- x_position = 0;
- y_pixels += PREVIEW_PADDING + preview_width * preview_aspect;
- }
- }
-
- // set the size of the background
- preview_background.width = embed.width;
- preview_background.height = x_position != 0
- ? y_pixels + preview_width * preview_aspect + PREVIEW_PADDING
- : y_pixels + PREVIEW_PADDING;
+ // place the previews
+ for (var i = 0; i < previews.size; i++)
+ {
+ // set the position of the preview
+ previews.get(i).x = x_origin + x_position * (PREVIEW_PADDING + preview_width);
+ previews.get(i).y = y_pixels;
- // always fill the background
- if (preview_background.height < embed.height)
+ // set the size of the preview
+ previews.get(i).width = preview_width;
+ previews.get(i).height = preview_width * preview_aspect;
+
+ // go to the next line
+ if (++x_position >= per_line)
{
- preview_background.height = embed.height;
+ x_position = 0;
+ y_pixels += PREVIEW_PADDING + preview_width * preview_aspect;
}
}
-
- private Gtk.Alignment create_zoom_bar()
+
+ // set the size of the background
+ preview_background.width = embed.width;
+ preview_background.height = x_position != 0
+ ? y_pixels + preview_width * preview_aspect + PREVIEW_PADDING
+ : y_pixels + PREVIEW_PADDING;
+
+ // always fill the background
+ if (preview_background.height < embed.height)
{
- var hbox = new Gtk.HBox(false, 5);
-
- // create zoom slider
- zoom_slider = new Gtk.HScale(new Gtk.Adjustment(100, 100, 400, 10, 50, 50));
- zoom_slider.width_request = 200;
- zoom_slider.draw_value = false;
- zoom_slider.digits = 0;
-
- // zoom in button
- zoom_in = new Gtk.Button();
- zoom_in.add(new Gtk.Image.from_stock("gtk-zoom-in", Gtk.IconSize.MENU));
- zoom_in.relief = Gtk.ReliefStyle.NONE;
-
- // zoom out button
- zoom_out = new Gtk.Button();
- zoom_out.add(new Gtk.Image.from_stock("gtk-zoom-out", Gtk.IconSize.MENU));
- zoom_out.relief = Gtk.ReliefStyle.NONE;
-
- // put it all together
- var align = new Gtk.Alignment(0, 0.5f, 1, 0);
- align.add(zoom_out);
- hbox.pack_start(align, false, false, 0);
-
- align = new Gtk.Alignment(0, 0.5f, 1, 0);
- align.add(zoom_slider);
- hbox.pack_start(align, false, false, 0);
-
- align = new Gtk.Alignment(0, 0.5f, 1, 0);
- align.add(zoom_in);
- hbox.pack_start(align, false, false, 0);
-
- align = new Gtk.Alignment(1, 1, 1, 1);
- align.add(hbox);
- return align;
+ preview_background.height = embed.height;
}
}
+
+ private Gtk.Alignment create_zoom_bar()
+ {
+ var hbox = new Gtk.HBox(false, 5);
+
+ // create zoom slider
+ zoom_slider = new Gtk.HScale(new Gtk.Adjustment(100, 100, 400, 10, 50, 50));
+ zoom_slider.width_request = 200;
+ zoom_slider.draw_value = false;
+ zoom_slider.digits = 0;
+
+ // zoom in button
+ zoom_in = new Gtk.Button();
+ zoom_in.add(new Gtk.Image.from_stock("gtk-zoom-in", Gtk.IconSize.MENU));
+ zoom_in.relief = Gtk.ReliefStyle.NONE;
+
+ // zoom out button
+ zoom_out = new Gtk.Button();
+ zoom_out.add(new Gtk.Image.from_stock("gtk-zoom-out", Gtk.IconSize.MENU));
+ zoom_out.relief = Gtk.ReliefStyle.NONE;
+
+ // put it all together
+ var align = new Gtk.Alignment(0, 0.5f, 1, 0);
+ align.add(zoom_out);
+ hbox.pack_start(align, false, false, 0);
+
+ align = new Gtk.Alignment(0, 0.5f, 1, 0);
+ align.add(zoom_slider);
+ hbox.pack_start(align, false, false, 0);
+
+ align = new Gtk.Alignment(0, 0.5f, 1, 0);
+ align.add(zoom_in);
+ hbox.pack_start(align, false, false, 0);
+
+ align = new Gtk.Alignment(1, 1, 1, 1);
+ align.add(hbox);
+ return align;
+ }
}
+
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]