[f-spot/FSPOT_0_6_0_STABLE] new extendable SlideShow
- From: Stephane Delcroix <sdelcroix src gnome org>
- To: svn-commits-list gnome org
- Cc:
- Subject: [f-spot/FSPOT_0_6_0_STABLE] new extendable SlideShow
- Date: Wed, 19 Aug 2009 13:03:59 +0000 (UTC)
commit 573ef30a788d61871f50d649ba873232952fcd4e
Author: Stephane Delcroix <stephane delcroix org>
Date: Sun Aug 16 13:00:56 2009 +0200
new extendable SlideShow
as the current slideshow mode was broken and as we had to drop/update/fix Tao,
the Slideshow mode was changed to something modular using Mono.Addins.
the default Push transition is written in Cairo, you're free to write any new one
using Gl, clutter, cairo, gtk..
src/Extensions/TransitionNode.cs | 34 ++++++++
src/FSpot.addin.xml | 10 ++-
src/FullScreenView.cs | 27 +++++-
src/Makefile.am | 9 ++-
src/Widgets/CairoTransition.cs | 38 ++++++++
src/Widgets/PushTransition.cs | 80 +++++++++++++++++
src/Widgets/SlideShow.cs | 165 ++++++++++++++++++++++++++++++++++++
src/Widgets/SlideShowTransition.cs | 37 ++++++++
8 files changed, 395 insertions(+), 5 deletions(-)
---
diff --git a/src/Extensions/TransitionNode.cs b/src/Extensions/TransitionNode.cs
new file mode 100644
index 0000000..1738125
--- /dev/null
+++ b/src/Extensions/TransitionNode.cs
@@ -0,0 +1,34 @@
+/*
+ * FSpot.Extensions.TransitionNode.cs
+ *
+ * Author(s):
+ * Stephane Delcroix <stephane delcroix org>
+ *
+ * Copyright (c) 2009 Novell, Inc.
+ *
+ * This is open source software. See COPYING for details.
+ *
+ */
+
+using System;
+using Mono.Addins;
+using Gdk;
+using FSpot.Widgets;
+
+namespace FSpot.Extensions
+{
+ public class TransitionNode : ExtensionNode
+ {
+ [NodeAttribute ("transition_type", true)]
+ protected string class_name;
+
+ SlideShowTransition transition = null;
+ public SlideShowTransition Transition {
+ get {
+ if (transition == null)
+ transition = Addin.CreateInstance (class_name) as SlideShowTransition;
+ return transition;
+ }
+ }
+ }
+}
diff --git a/src/FSpot.addin.xml b/src/FSpot.addin.xml
index 3fd7420..649961e 100644
--- a/src/FSpot.addin.xml
+++ b/src/FSpot.addin.xml
@@ -1,6 +1,6 @@
<Addin namespace = "FSpot"
id = "Core"
- version = "0.6"
+ version = "0.6.0.1"
compatVersion = "0.6"
isroot="true">
@@ -25,6 +25,10 @@
<ExtensionNode name="Service" type="FSpot.Extensions.ServiceNode"/>
</ExtensionPoint>
+ <ExtensionPoint path = "/FSpot/SlideShow">
+ <ExtensionNode name="Transition" type="FSpot.Extensions.TransitionNode"/>
+ </ExtensionPoint>
+
<Extension path = "/FSpot/Menus">
<Menu id="Exports" _label="Export to" />
</Extension>
@@ -73,4 +77,8 @@
<Editor editor_type = "FSpot.Editors.AutoStretchEditor"/>
<Editor editor_type = "FSpot.Editors.ColorEditor"/>
</Extension>
+
+ <Extension path = "/FSpot/SlideShow">
+ <Transition transition_type = "FSpot.Widgets.PushTransition"/>
+ </Extension>
</Addin>
diff --git a/src/FullScreenView.cs b/src/FullScreenView.cs
index 983d9a3..bdfb8d3 100644
--- a/src/FullScreenView.cs
+++ b/src/FullScreenView.cs
@@ -22,7 +22,7 @@ namespace FSpot {
private Notebook notebook;
private ControlOverlay controls;
// private ImageDisplay display;
- private TextureDisplay display;
+ private SlideShow display;
private ToolButton play_pause_button;
private ToggleToolButton info_button;
private Delay hide_cursor_delay;
@@ -128,14 +128,19 @@ namespace FSpot {
t_item.Child = new Label (Catalog.GetString ("Slide transition:"));
tbar.Insert (t_item, -1);
- display = new TextureDisplay (view.Item);
+ display = new SlideShow (view.Item);
display.AddEvents ((int) (Gdk.EventMask.PointerMotionMask));
display.ModifyBg (Gtk.StateType.Normal, this.Style.Black);
display.MotionNotifyEvent += HandleViewMotion;
display.Show ();
t_item = new ToolItem ();
- t_item.Child = display.GetCombo ();
+ ComboBox combo = ComboBox.NewText ();
+ foreach (var transition in display.Transitions)
+ combo.AppendText (transition.Name);
+ combo.Active = 0;
+ combo.Changed += HandleTransitionChanged;
+ t_item.Child = combo;
tbar.Insert (t_item, -1);
action = new RotateLeftAction (view.Item);
@@ -200,6 +205,22 @@ namespace FSpot {
scroll.ShowControls ();
}
+ void HandleTransitionChanged (object sender, EventArgs e)
+ {
+ ComboBox combo = sender as ComboBox;
+ if (combo == null)
+ return;
+ TreeIter iter;
+ if (combo.GetActiveIter (out iter)) {
+ string name = combo.Model.GetValue (iter, 0) as string;
+ foreach (var transition in display.Transitions)
+ if (transition.Name == name)
+ display.Transition = transition;
+ }
+
+
+ }
+
protected override bool OnExposeEvent (Gdk.EventExpose args)
{
bool ret = base.OnExposeEvent (args);
diff --git a/src/Makefile.am b/src/Makefile.am
index 5bafde7..381aef2 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -97,7 +97,10 @@ WIDGETS_CSDISTFILES = \
$(srcdir)/Widgets/PointerMode.cs \
$(srcdir)/Widgets/Rating.cs \
$(srcdir)/Widgets/SaneTreeView.cs \
- $(srcdir)/Widgets/ScrolledView.cs
+ $(srcdir)/Widgets/ScrolledView.cs \
+ $(srcdir)/Widgets/PushTransition.cs \
+ $(srcdir)/Widgets/CairoTransition.cs \
+ $(srcdir)/Widgets/SlideShowTransition.cs
GNOME_PLATFORM_CSDISTFILES = \
$(srcdir)/Platform/Gnome/Desktop.cs \
@@ -152,6 +155,7 @@ F_SPOT_CSDISTFILES = \
$(srcdir)/Extensions/PhotoSelectionCondition.cs \
$(srcdir)/Extensions/PopupCommands.cs \
$(srcdir)/Extensions/ServiceNode.cs \
+ $(srcdir)/Extensions/TransitionNode.cs \
$(srcdir)/Extensions/ViewModeCondition.cs \
$(srcdir)/Fader.cs \
$(srcdir)/FileImportBackend.cs \
@@ -279,6 +283,7 @@ F_SPOT_CSDISTFILES = \
$(srcdir)/GPhotoCamera.cs \
$(srcdir)/CameraSelectionDialog.cs \
$(srcdir)/CameraFileSelectionDialog.cs \
+ $(srcdir)/Widgets/SlideShow.cs \
$(srcdir)/Widgets/CompositeUtils.cs \
$(srcdir)/Widgets/Dissolve.cs \
$(srcdir)/Widgets/EditorPage.cs \
@@ -345,6 +350,8 @@ JOBSCHEDULER_ASSEMBLIES = \
BLING_ASSEMBLIES = \
-pkg:gtk-sharp-2.0 \
+ -r:Mono.Cairo \
+ -r:FSpot.Utils.dll \
$(LINK_GTKSHARPBEANS)
WIDGETS_ASSEMBLIES = \
diff --git a/src/Widgets/CairoTransition.cs b/src/Widgets/CairoTransition.cs
new file mode 100644
index 0000000..08ffda8
--- /dev/null
+++ b/src/Widgets/CairoTransition.cs
@@ -0,0 +1,38 @@
+//
+// FSpot.Widgets.CairoTransition.cs
+//
+// Author(s):
+// Stephane Delcroix <stephane delcroix org>
+//
+// Copyright (c) 2009 Novell, Inc.
+//
+// This is open source software. See COPYING for details.
+//
+
+using System;
+
+using Cairo;
+using Gdk;
+
+using FSpot.Utils;
+
+using Color = Cairo.Color;
+
+namespace FSpot.Widgets
+{
+ public abstract class CairoTransition : SlideShowTransition
+ {
+ public CairoTransition (string name) : base (name)
+ {
+ }
+
+ public override void Draw (Drawable d, Pixbuf prev, Pixbuf next, int width, int height, double progress)
+ {
+ using (Cairo.Context cr = Gdk.CairoHelper.Create (d)) {
+ Draw (cr, prev, next, width, height, progress);
+ }
+ }
+
+ protected abstract void Draw (Context cr, Pixbuf prev, Pixbuf next, int width, int height, double progress);
+ }
+}
diff --git a/src/Widgets/PushTransition.cs b/src/Widgets/PushTransition.cs
new file mode 100644
index 0000000..2a54484
--- /dev/null
+++ b/src/Widgets/PushTransition.cs
@@ -0,0 +1,80 @@
+//
+// FSpot.Widgets.PushTransition.cs
+//
+// Author(s):
+// Stephane Delcroix <stephane delcroix org>
+//
+// Copyright (c) 2009 Novell, Inc.
+//
+// This is open source software. See COPYING for details.
+//
+
+using System;
+
+using Cairo;
+using Gdk;
+
+using FSpot.Utils;
+
+using Color = Cairo.Color;
+
+namespace FSpot.Widgets
+{
+ public class PushTransition : CairoTransition
+ {
+ public PushTransition () : base ("Push")
+ {
+ }
+
+ protected override void Draw (Context cr, Pixbuf prev, Pixbuf next, int width, int height, double progress)
+ {
+ cr.Color = new Color (0, 0, 0);
+ if (prev != null) {
+ double scale = Math.Min ((double)width/(double)prev.Width, (double)height/(double)prev.Height);
+ cr.Save ();
+ cr.Translate (-progress * width, 0);
+
+ cr.Rectangle (0, 0, width, .5 * (height - scale*prev.Height));
+ cr.Fill ();
+
+ cr.Rectangle (0, height - .5 * (height - scale*prev.Height), width, .5 * (height - scale*prev.Height));
+ cr.Fill ();
+
+ cr.Rectangle (0, 0, .5 * (width - scale*prev.Width), height);
+ cr.Fill ();
+
+ cr.Rectangle (width - .5 * (width - scale*prev.Width), 0, .5 * (width - scale*prev.Width), height);
+ cr.Fill ();
+
+ cr.Rectangle (0, 0, width, height);
+ cr.Scale (scale, scale);
+ CairoHelper.SetSourcePixbuf (cr, prev, .5 * ((double)width/scale - prev.Width), .5 * ((double)height/scale - prev.Height));
+ cr.Fill ();
+ cr.Restore ();
+ }
+ if (next != null) {
+ double scale = Math.Min ((double)width/(double)next.Width, (double)height/(double)next.Height);
+ cr.Save ();
+ cr.Translate (width * (1.0 - progress), 0);
+
+ cr.Rectangle (0, 0, width, .5 * (height - scale*next.Height));
+ cr.Fill ();
+
+ cr.Rectangle (0, height - .5 * (height - scale*next.Height), width, .5 * (height - scale*next.Height));
+ cr.Fill ();
+
+ cr.Rectangle (0, 0, .5 * (width - scale*next.Width), height);
+ cr.Fill ();
+
+ cr.Rectangle (width - .5 * (width - scale*next.Width), 0, .5 * (width - scale*next.Width), height);
+ cr.Fill ();
+
+ cr.Rectangle (0, 0, width, height);
+ cr.Scale (scale, scale);
+ CairoHelper.SetSourcePixbuf (cr, next, .5 * ((double)width/scale - next.Width), .5 * ((double)height/scale - next.Height));
+ cr.Fill ();
+ cr.Restore ();
+ }
+ }
+ }
+}
diff --git a/src/Widgets/SlideShow.cs b/src/Widgets/SlideShow.cs
new file mode 100644
index 0000000..4d2270c
--- /dev/null
+++ b/src/Widgets/SlideShow.cs
@@ -0,0 +1,165 @@
+//
+// FSpot.Widgets.SlideShow.cs
+//
+// Author(s):
+// Stephane Delcroix <stephane delcroix org>
+//
+// This is open source software. See COPYING for details.
+//
+
+using System;
+using System.Collections.Generic;
+
+using Gtk;
+using Gdk;
+using Mono.Addins;
+using FSpot.Bling;
+using FSpot.Extensions;
+
+namespace FSpot.Widgets
+{
+ public class SlideShow : DrawingArea
+ {
+ BrowsablePointer item;
+#region Public API
+ public SlideShow (BrowsablePointer item) : base ()
+ {
+ this.item = item;
+ DoubleBuffered = false;
+ AppPaintable = true;
+ CanFocus = true;
+ item.Changed += HandleItemChanged;
+
+ foreach (TransitionNode transition in AddinManager.GetExtensionNodes ("/FSpot/SlideShow")) {
+ if (this.transition == null)
+ this.transition = transition.Transition;
+ transitions.Add (transition.Transition);
+ }
+
+ flip = new Delay (6000, delegate {item.MoveNext (true); return true;});
+ animation = new DoubleAnimation (0, 1, new TimeSpan (0, 0, 2), HandleProgressChanged);
+ }
+
+ SlideShowTransition transition;
+ public SlideShowTransition Transition {
+ get { return transition; }
+ set {
+ if (value == transition)
+ return;
+ transition = value;
+ QueueDraw ();
+ }
+ }
+
+ List<SlideShowTransition> transitions = new List<SlideShowTransition> ();
+ public IEnumerable<SlideShowTransition> Transitions {
+ get { return transitions; }
+ }
+
+ DoubleAnimation animation;
+ Delay flip;
+ public void Start ()
+ {
+ flip.Start ();
+ }
+
+ public void Stop ()
+ {
+ flip.Stop ();
+ }
+
+ //DROP THIS
+ public ComboBox GetCombo ()
+ {
+ ComboBox combo = ComboBox.NewText ();
+ combo.HasFrame = false;
+
+// foreach (GlTransition t in transitions)
+// combo.AppendText (t.Name);
+//
+// combo.Active = current_transition;
+ // combo.Changed += HandleComboChanged;
+ combo.Show ();
+ return combo;
+ }
+
+#endregion
+
+#region Event Handlers
+ Pixbuf prev, next;
+ object sync_handle = new object ();
+ void HandleItemChanged (object sender, EventArgs e)
+ {
+ flip.Stop ();
+ flip.Start ();
+ lock (sync_handle) {
+ if (prev != null)
+ prev.Dispose ();
+ prev = next;
+ if (next != null) {
+ next = null;
+ }
+
+ using (ImageFile img = ImageFile.Create (item.Current.DefaultVersionUri)) {
+ try {
+ using (var pb = img.Load ()) {
+ double scale = Math.Min ((double)Allocation.Width/(double)pb.Width, (double)Allocation.Height/(double)pb.Height);
+ int w = (int)(pb.Width * scale);
+ int h = (int)(pb.Height * scale);
+
+ if (w > 0 && h > 0)
+ next = pb.ScaleSimple ((int)(pb.Width * scale), (int)(pb.Height * scale), InterpType.Nearest);
+ }
+ Cms.Profile screen_profile;
+ if (FSpot.ColorManagement.Profiles.TryGetValue (Preferences.Get<string> (Preferences.COLOR_MANAGEMENT_DISPLAY_PROFILE), out screen_profile))
+ FSpot.ColorManagement.ApplyProfile (next, img.GetProfile (), screen_profile);
+ } catch (Exception)
+ {}
+ }
+
+ if (animation.IsRunning)
+ animation.Stop ();
+ animation.Start ();
+ }
+ }
+
+ double progress = 0;
+ void HandleProgressChanged (double progress)
+ {
+ this.progress = progress;
+ QueueDraw ();
+ }
+#endregion
+
+#region Gtk Widgetry
+ protected override bool OnExposeEvent (Gdk.EventExpose args)
+ {
+ lock (sync_handle) {
+ transition.Draw (args.Window, prev, next, Allocation.Width, Allocation.Height, progress);
+ }
+ return true;
+ }
+ protected override void OnDestroyed ()
+ {
+ if (prev != null)
+ prev.Dispose ();
+ if (next != null)
+ next.Dispose ();
+
+ base.OnDestroyed ();
+ }
+
+ protected override void OnSizeAllocated (Rectangle allocation)
+ {
+ base.OnSizeAllocated (allocation);
+ QueueDraw ();
+ }
+
+ protected override void OnUnrealized ()
+ {
+ flip.Stop ();
+ base.OnUnrealized ();
+ }
+#endregion
+ }
+}
diff --git a/src/Widgets/SlideShowTransition.cs b/src/Widgets/SlideShowTransition.cs
new file mode 100644
index 0000000..ac98957
--- /dev/null
+++ b/src/Widgets/SlideShowTransition.cs
@@ -0,0 +1,37 @@
+//
+// FSpot.Widgets.SlideShowTransition.cs
+//
+// Author(s):
+// Stephane Delcroix <stephane delcroix org>
+//
+// Copyright (c) 2009 Novell, Inc.
+//
+// This is open source software. See COPYING for details.
+//
+
+using System;
+
+using Cairo;
+using Gdk;
+
+using FSpot.Utils;
+
+using Color = Cairo.Color;
+
+namespace FSpot.Widgets
+{
+ public abstract class SlideShowTransition
+ {
+ public SlideShowTransition (string name)
+ {
+ this.name = name;
+ }
+
+ string name;
+ public string Name {
+ get { return name; }
+ }
+
+ public abstract void Draw (Drawable d, Pixbuf prev, Pixbuf next, int width, int height, double progress);
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]