From 4ea2cc3bd4a7d9b1c54a9d33e6a1cf82e7c8c21d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Frings-F=C3=BCrst?= Date: Wed, 23 Jul 2014 09:06:59 +0200 Subject: Imported Upstream version 0.18.1 --- plugins/shotwell-transitions/BlindsEffect.vala | 96 +++++++++++++++++++ plugins/shotwell-transitions/ChessEffect.vala | 88 ++++++++++++++++++ plugins/shotwell-transitions/CircleEffect.vala | 71 ++++++++++++++ plugins/shotwell-transitions/CirclesEffect.vala | 86 +++++++++++++++++ plugins/shotwell-transitions/ClockEffect.vala | 83 +++++++++++++++++ plugins/shotwell-transitions/CrumbleEffect.vala | 103 +++++++++++++++++++++ plugins/shotwell-transitions/FadeEffect.vala | 70 ++++++++++++++ plugins/shotwell-transitions/Makefile | 21 +++++ plugins/shotwell-transitions/SlideEffect.vala | 75 +++++++++++++++ plugins/shotwell-transitions/SquaresEffect.vala | 86 +++++++++++++++++ plugins/shotwell-transitions/StripesEffect.vala | 84 +++++++++++++++++ .../shotwell-transitions/shotwell-transitions.vala | 90 ++++++++++++++++++ plugins/shotwell-transitions/slideshow-plugin.png | Bin 0 -> 3520 bytes 13 files changed, 953 insertions(+) create mode 100644 plugins/shotwell-transitions/BlindsEffect.vala create mode 100644 plugins/shotwell-transitions/ChessEffect.vala create mode 100644 plugins/shotwell-transitions/CircleEffect.vala create mode 100644 plugins/shotwell-transitions/CirclesEffect.vala create mode 100644 plugins/shotwell-transitions/ClockEffect.vala create mode 100644 plugins/shotwell-transitions/CrumbleEffect.vala create mode 100644 plugins/shotwell-transitions/FadeEffect.vala create mode 100644 plugins/shotwell-transitions/Makefile create mode 100644 plugins/shotwell-transitions/SlideEffect.vala create mode 100644 plugins/shotwell-transitions/SquaresEffect.vala create mode 100644 plugins/shotwell-transitions/StripesEffect.vala create mode 100644 plugins/shotwell-transitions/shotwell-transitions.vala create mode 100755 plugins/shotwell-transitions/slideshow-plugin.png (limited to 'plugins/shotwell-transitions') diff --git a/plugins/shotwell-transitions/BlindsEffect.vala b/plugins/shotwell-transitions/BlindsEffect.vala new file mode 100644 index 0000000..6fdcf18 --- /dev/null +++ b/plugins/shotwell-transitions/BlindsEffect.vala @@ -0,0 +1,96 @@ +/* Copyright 2013 Jens Bav + * Copyright 2011-2014 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +using Spit; + +private class BlindsEffectDescriptor : ShotwellTransitionDescriptor { + public BlindsEffectDescriptor(GLib.File resource_directory) { + base(resource_directory); + } + + public override unowned string get_id() { + return "org.yorba.shotwell.transitions.blinds"; + } + + public override unowned string get_pluggable_name() { + return _("Blinds"); + } + + public override Transitions.Effect create(HostInterface host) { + return new BlindsEffect(); + } +} + +private class BlindsEffect : Object, Transitions.Effect { + private const int DESIRED_FPS = 30; + private const int MIN_FPS = 15; + + private const int BLIND_WIDTH = 50; + private int current_blind_width; + + private Cairo.ImageSurface[] to_blinds; + private int blind_count; + + public BlindsEffect() { + } + + public void get_fps(out int desired_fps, out int min_fps) { + desired_fps = BlindsEffect.DESIRED_FPS; + min_fps = BlindsEffect.MIN_FPS; + } + + public bool needs_clear_background() { + return true; + } + + public void start(Transitions.Visuals visuals, Transitions.Motion motion) { + if (visuals.from_pixbuf != null) { + blind_count = visuals.to_pixbuf.width / BLIND_WIDTH; + current_blind_width = + (int) Math.ceil((double) visuals.to_pixbuf.width / (double) blind_count); + + to_blinds = new Cairo.ImageSurface[blind_count]; + + for (int i = 0; i < blind_count; ++i) { + to_blinds[i] = new Cairo.ImageSurface(Cairo.Format.RGB24, current_blind_width, + visuals.to_pixbuf.height); + Cairo.Context ctx = new Cairo.Context(to_blinds[i]); + Gdk.cairo_set_source_pixbuf(ctx, visuals.to_pixbuf, -i * current_blind_width, 0); + ctx.paint(); + } + } + } + + public void paint(Transitions.Visuals visuals, Transitions.Motion motion, Cairo.Context ctx, + int width, int height, int frame_number) { + double alpha = motion.get_alpha(frame_number); + int y = visuals.to_pos.y; + int x = visuals.to_pos.x; + + if (visuals.from_pixbuf != null){ + Gdk.cairo_set_source_pixbuf(ctx, visuals.from_pixbuf, visuals.from_pos.x, + visuals.from_pos.y); + ctx.paint_with_alpha(1 - alpha * 2); + } + + for (int i = 0; i < blind_count; ++i) { + ctx.set_source_surface(to_blinds[i], x + i * current_blind_width, y); + ctx.rectangle(x + i * current_blind_width, y, current_blind_width * (alpha + 0.5), + visuals.to_pixbuf.height); + ctx.fill(); + } + + ctx.clip(); + ctx.paint(); + } + + public void advance(Transitions.Visuals visuals, Transitions.Motion motion, int frame_number) { + } + + public void cancel() { + } +} diff --git a/plugins/shotwell-transitions/ChessEffect.vala b/plugins/shotwell-transitions/ChessEffect.vala new file mode 100644 index 0000000..37c9fd2 --- /dev/null +++ b/plugins/shotwell-transitions/ChessEffect.vala @@ -0,0 +1,88 @@ +/* Copyright 2013 Jens Bav + * Copyright 2011-2014 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +using Spit; + +private class ChessEffectDescriptor : ShotwellTransitionDescriptor { + public ChessEffectDescriptor(GLib.File resource_directory) { + base(resource_directory); + } + + public override unowned string get_id() { + return "org.yorba.shotwell.transitions.chess"; + } + + public override unowned string get_pluggable_name() { + return _("Chess"); + } + + public override Transitions.Effect create(HostInterface host) { + return new ChessEffect(); + } +} + +private class ChessEffect : Object, Transitions.Effect { + private const int DESIRED_FPS = 25; + private const int MIN_FPS = 10; + private const int SQUARE_SIZE = 100; + private double square_count_x; + private double square_count_y; + + public ChessEffect() { + } + + public void get_fps(out int desired_fps, out int min_fps) { + desired_fps = ChessEffect.DESIRED_FPS; + min_fps = ChessEffect.MIN_FPS; + } + + public void start(Transitions.Visuals visuals, Transitions.Motion motion) { + square_count_y = visuals.to_pos.height / SQUARE_SIZE + 2; + square_count_x = visuals.to_pos.width / SQUARE_SIZE + 2; + } + + public bool needs_clear_background() { + return true; + } + + public void paint(Transitions.Visuals visuals, Transitions.Motion motion, Cairo.Context ctx, + int width, int height, int frame_number) { + double alpha = motion.get_alpha(frame_number); + double size = 2 * alpha * SQUARE_SIZE; + if (visuals.from_pixbuf != null) { + Gdk.cairo_set_source_pixbuf(ctx, visuals.from_pixbuf, visuals.from_pos.x, + visuals.from_pos.y); + ctx.paint_with_alpha(1 - alpha); + } + + if (visuals.to_pixbuf != null) { + Gdk.cairo_set_source_pixbuf(ctx, visuals.to_pixbuf,visuals.to_pos.x, visuals.to_pos.y); + for (double y = 0; y <= square_count_y; y++) { + for (double x = 0; x <= square_count_x; x++) { + double translation = (x+y) % 2 == 0 ? -1.5 * SQUARE_SIZE : 1.5 * SQUARE_SIZE; + if (motion.direction == Transitions.Direction.FORWARD) { + ctx.rectangle(visuals.to_pos.x + translation + x * SQUARE_SIZE, + visuals.to_pos.y + y * SQUARE_SIZE, size, SQUARE_SIZE); + } else { + ctx.rectangle(visuals.to_pos.x + visuals.to_pos.width + translation - x + * SQUARE_SIZE - size, visuals.to_pos.y + y * SQUARE_SIZE, size, + SQUARE_SIZE); + } + } + } + + ctx.clip(); + ctx.paint_with_alpha(alpha); + } + } + + public void advance(Transitions.Visuals visuals, Transitions.Motion motion, int frame_number) { + } + + public void cancel() { + } +} diff --git a/plugins/shotwell-transitions/CircleEffect.vala b/plugins/shotwell-transitions/CircleEffect.vala new file mode 100644 index 0000000..11e7631 --- /dev/null +++ b/plugins/shotwell-transitions/CircleEffect.vala @@ -0,0 +1,71 @@ +/* Copyright 2013 Jens Bav + * Copyright 2011-2014 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +using Spit; + +private class CircleEffectDescriptor : ShotwellTransitionDescriptor { + public CircleEffectDescriptor(GLib.File resource_directory) { + base(resource_directory); + } + + public override unowned string get_id() { + return "org.yorba.shotwell.transitions.circle"; + } + + public override unowned string get_pluggable_name() { + return _("Circle"); + } + + public override Transitions.Effect create(HostInterface host) { + return new CircleEffect(); + } +} + +private class CircleEffect : Object, Transitions.Effect { + private const int DESIRED_FPS = 25; + private const int MIN_FPS = 15; + + public CircleEffect() { + } + + public void get_fps(out int desired_fps, out int min_fps) { + desired_fps = CircleEffect.DESIRED_FPS; + min_fps = CircleEffect.MIN_FPS; + } + + public void start(Transitions.Visuals visuals, Transitions.Motion motion) { + } + + public bool needs_clear_background() { + return true; + } + + public void paint(Transitions.Visuals visuals, Transitions.Motion motion, Cairo.Context ctx, + int width, int height, int frame_number) { + double alpha = motion.get_alpha(frame_number); + int radius = (int)((alpha) * Math.fmax(width,height)); + + if (visuals.from_pixbuf != null) { + Gdk.cairo_set_source_pixbuf(ctx, visuals.from_pixbuf, visuals.from_pos.x, + visuals.from_pos.y); + ctx.paint_with_alpha(1 - alpha); + } + + if (visuals.to_pixbuf != null) { + Gdk.cairo_set_source_pixbuf(ctx, visuals.to_pixbuf,visuals.to_pos.x, visuals.to_pos.y); + ctx.arc ((int) width / 2, (int) height / 2, radius, 0, 2 * Math.PI); + ctx.clip(); + ctx.paint(); + } + } + + public void advance(Transitions.Visuals visuals, Transitions.Motion motion, int frame_number) { + } + + public void cancel() { + } +} diff --git a/plugins/shotwell-transitions/CirclesEffect.vala b/plugins/shotwell-transitions/CirclesEffect.vala new file mode 100644 index 0000000..b01e06f --- /dev/null +++ b/plugins/shotwell-transitions/CirclesEffect.vala @@ -0,0 +1,86 @@ +/* Copyright 2013 Jens Bav + * Copyright 2011-2014 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +using Spit; + +private class CirclesEffectDescriptor : ShotwellTransitionDescriptor { + public CirclesEffectDescriptor(GLib.File resource_directory) { + base(resource_directory); + } + + public override unowned string get_id() { + return "org.yorba.shotwell.transitions.circles"; + } + + public override unowned string get_pluggable_name() { + return _("Circles"); + } + + public override Transitions.Effect create(HostInterface host) { + return new CirclesEffect(); + } +} + +private class CirclesEffect : Object, Transitions.Effect { + private const int DESIRED_FPS = 25; + private const int MIN_FPS = 15; + private const double SPEED = 2.5; + + public CirclesEffect() { + } + + public void get_fps(out int desired_fps, out int min_fps) { + desired_fps = CirclesEffect.DESIRED_FPS; + min_fps = CirclesEffect.MIN_FPS; + } + + public void start(Transitions.Visuals visuals, Transitions.Motion motion) { + } + + public bool needs_clear_background() { + return true; + } + + public void paint(Transitions.Visuals visuals, Transitions.Motion motion, Cairo.Context ctx, + int width, int height, int frame_number) { + double alpha = motion.get_alpha(frame_number); + int distance = 60, radius; + int circleCountX = width / (2 * distance); + int circleCountY = height / distance; + double maxRadius = SPEED * distance; + + if (visuals.from_pixbuf != null) { + Gdk.cairo_set_source_pixbuf(ctx, visuals.from_pixbuf, visuals.from_pos.x, + visuals.from_pos.y); + ctx.paint_with_alpha(1 - alpha); + } + + if (visuals.to_pixbuf != null) { + Gdk.cairo_set_source_pixbuf(ctx, visuals.to_pixbuf,visuals.to_pos.x, visuals.to_pos.y); + + for(int y = 0; y <= circleCountY; y++){ + for(int x = 0; x <= circleCountX; x++){ + radius = (int) (Math.fmax(0,Math.fmin(1, alpha-((double) (x + y)/(double) + ((circleCountY + circleCountX) * SPEED)))) * maxRadius); + ctx.arc(2 * distance * x, 2 * distance * y, radius, 0, 2 * Math.PI); + ctx.fill(); + } + } + + ctx.clip(); + ctx.paint_with_alpha(alpha); + } + + + } + + public void advance(Transitions.Visuals visuals, Transitions.Motion motion, int frame_number) { + } + + public void cancel() { + } +} diff --git a/plugins/shotwell-transitions/ClockEffect.vala b/plugins/shotwell-transitions/ClockEffect.vala new file mode 100644 index 0000000..78b39a6 --- /dev/null +++ b/plugins/shotwell-transitions/ClockEffect.vala @@ -0,0 +1,83 @@ +/* Copyright 2013 Jens Bav + * Copyright 2011-2014 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +using Spit; + +private class ClockEffectDescriptor : ShotwellTransitionDescriptor { + public ClockEffectDescriptor(GLib.File resource_directory) { + base(resource_directory); + } + + public override unowned string get_id() { + return "org.yorba.shotwell.transitions.clock"; + } + + public override unowned string get_pluggable_name() { + return _("Clock"); + } + + public override Transitions.Effect create(HostInterface host) { + return new ClockEffect(); + } +} + +private class ClockEffect : Object, Transitions.Effect { + private const int DESIRED_FPS = 25; + private const int MIN_FPS = 15; + private const double TOP_RADIANT = 0.5 * Math.PI; + + public ClockEffect() { + } + + public void get_fps(out int desired_fps, out int min_fps) { + desired_fps = ClockEffect.DESIRED_FPS; + min_fps = ClockEffect.MIN_FPS; + } + + public void start(Transitions.Visuals visuals, Transitions.Motion motion) { + } + + public bool needs_clear_background() { + return true; + } + + public void paint(Transitions.Visuals visuals, Transitions.Motion motion, Cairo.Context ctx, + int width, int height, int frame_number) { + double alpha = motion.get_alpha(frame_number); + double start_angle = -TOP_RADIANT, stop_angle = -TOP_RADIANT; + + if (motion.direction == Transitions.Direction.FORWARD) + stop_angle = alpha*Math.PI * 2 - TOP_RADIANT; + else + start_angle = (2 * (1-alpha)) * Math.PI - TOP_RADIANT; + + int radius = (int) Math.fmax(visuals.to_pos.width, visuals.to_pos.height); + + if (visuals.from_pixbuf != null) { + Gdk.cairo_set_source_pixbuf(ctx, visuals.from_pixbuf, visuals.from_pos.x, + visuals.from_pos.y); + ctx.paint_with_alpha(1 - alpha); + } + + if (visuals.to_pixbuf != null) { + Gdk.cairo_set_source_pixbuf(ctx, visuals.to_pixbuf,visuals.to_pos.x, visuals.to_pos.y); + + int x = visuals.to_pos.x + (int) visuals.to_pos.width / 2; + int y = visuals.to_pos.y + (int) visuals.to_pos.height / 2; + + ctx.move_to(x, y); + ctx.arc (x, y, radius, start_angle, stop_angle); + ctx.fill_preserve(); + } + } + + public void advance(Transitions.Visuals visuals, Transitions.Motion motion, int frame_number) { + } + + public void cancel() { + } +} diff --git a/plugins/shotwell-transitions/CrumbleEffect.vala b/plugins/shotwell-transitions/CrumbleEffect.vala new file mode 100644 index 0000000..a458811 --- /dev/null +++ b/plugins/shotwell-transitions/CrumbleEffect.vala @@ -0,0 +1,103 @@ +/* Copyright 2010 Maxim Kartashev + * Copyright 2011-2014 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +using Spit; + +private class CrumbleEffectDescriptor : ShotwellTransitionDescriptor { + public CrumbleEffectDescriptor(GLib.File resource_directory) { + base(resource_directory); + } + + public override unowned string get_id() { + return "org.yorba.shotwell.transitions.crumble"; + } + + public override unowned string get_pluggable_name() { + return _("Crumble"); + } + + public override Transitions.Effect create(Spit.HostInterface host) { + return new CrumbleEffect(); + } +} + +private class CrumbleEffect : Object, Transitions.Effect { + private const int DESIRED_FPS = 25; + private const int MIN_FPS = 15; + + private const int STRIPE_WIDTH = 10; + + private Cairo.ImageSurface[] from_stripes; + private double[] accelerations; + private int stripes_count; + + public CrumbleEffect() { + } + + public void get_fps(out int desired_fps, out int min_fps) { + desired_fps = CrumbleEffect.DESIRED_FPS; + min_fps = CrumbleEffect.MIN_FPS; + } + + public bool needs_clear_background() { + return true; + } + + public void start(Transitions.Visuals visuals, Transitions.Motion motion) { + Rand rand = new Rand(); + + // Cut original image into stripes of STRIPE_WIDTH width; also prepare + // acceleration for each stripe. + if (visuals.from_pixbuf != null) { + stripes_count = visuals.from_pixbuf.width / STRIPE_WIDTH; + from_stripes = new Cairo.ImageSurface[stripes_count]; + accelerations = new double[stripes_count]; + for (int i = 0; i < stripes_count; ++i) { + from_stripes[i] = new Cairo.ImageSurface(Cairo.Format.RGB24, STRIPE_WIDTH, + visuals.from_pixbuf.height); + Cairo.Context ctx = new Cairo.Context(from_stripes[i]); + Gdk.cairo_set_source_pixbuf(ctx, visuals.from_pixbuf, - i * STRIPE_WIDTH, 0); + ctx.paint(); + accelerations[i] = rand.next_double(); + } + } + } + + public void paint(Transitions.Visuals visuals, Transitions.Motion motion, Cairo.Context ctx, + int width, int height, int frame_number) { + double alpha = motion.get_alpha(frame_number); + + if (alpha < 0.5) { + // First part: draw stripes that go down with pre-calculated acceleration + alpha = alpha * 2; // stretch alpha to [0, 1] + + // tear down from_pixbuf first + for (int i = 0; i < stripes_count; ++i) { + int x = visuals.from_pos.x + i * STRIPE_WIDTH; + double a = alpha + alpha * accelerations[i]; + int y = visuals.from_pos.y + (int) (visuals.from_pixbuf.height * a * a); + + ctx.set_source_surface(from_stripes[i], x, y); + ctx.paint(); + } + } else if (visuals.to_pixbuf != null) { + // Second part: fade in next image ("to_pixbuf") + alpha = (alpha - 0.5) * 2; // stretch alpha to [0, 1] + Gdk.cairo_set_source_pixbuf(ctx, visuals.to_pixbuf, visuals.to_pos.x, visuals.to_pos.y); + ctx.paint_with_alpha(alpha); + } else { + // TODO: fade in background color + } + } + + public void advance(Transitions.Visuals visuals, Transitions.Motion motion, int frame_number) { + } + + public void cancel() { + } +} + diff --git a/plugins/shotwell-transitions/FadeEffect.vala b/plugins/shotwell-transitions/FadeEffect.vala new file mode 100644 index 0000000..efe1d74 --- /dev/null +++ b/plugins/shotwell-transitions/FadeEffect.vala @@ -0,0 +1,70 @@ +/* Copyright 2010 Maxim Kartashev + * Copyright 2011-2014 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +using Spit; + +private class FadeEffectDescriptor : ShotwellTransitionDescriptor { + public FadeEffectDescriptor(GLib.File resource_directory) { + base(resource_directory); + } + + public override unowned string get_id() { + return "org.yorba.shotwell.transitions.fade"; + } + + public override unowned string get_pluggable_name() { + return _("Fade"); + } + + public override Transitions.Effect create(Spit.HostInterface host) { + return new FadeEffect(); + } +} + +private class FadeEffect : Object, Transitions.Effect { + private const int DESIRED_FPS = 30; + private const int MIN_FPS = 20; + + public FadeEffect() { + } + + public void get_fps(out int desired_fps, out int min_fps) { + desired_fps = FadeEffect.DESIRED_FPS; + min_fps = FadeEffect.MIN_FPS; + } + + public void start(Transitions.Visuals visuals, Transitions.Motion motion) { + } + + public bool needs_clear_background() { + return true; + } + + public void paint(Transitions.Visuals visuals, Transitions.Motion motion, Cairo.Context ctx, + int width, int height, int frame_number) { + double alpha = motion.get_alpha(frame_number); + + // blend the two pixbufs using an alpha of the appropriate level depending on how far + // the cycle has progressed + if (visuals.from_pixbuf != null) { + Gdk.cairo_set_source_pixbuf(ctx, visuals.from_pixbuf, visuals.from_pos.x, visuals.from_pos.y); + ctx.paint_with_alpha(1.0 - alpha); + } + + if (visuals.to_pixbuf != null) { + Gdk.cairo_set_source_pixbuf(ctx, visuals.to_pixbuf, visuals.to_pos.x, visuals.to_pos.y); + ctx.paint_with_alpha(alpha); + } + } + + public void advance(Transitions.Visuals visuals, Transitions.Motion motion, int frame_number) { + } + + public void cancel() { + } +} + diff --git a/plugins/shotwell-transitions/Makefile b/plugins/shotwell-transitions/Makefile new file mode 100644 index 0000000..043891c --- /dev/null +++ b/plugins/shotwell-transitions/Makefile @@ -0,0 +1,21 @@ + +PLUGIN := shotwell-transitions + +SRC_FILES := \ + shotwell-transitions.vala \ + FadeEffect.vala \ + SlideEffect.vala \ + CrumbleEffect.vala \ + BlindsEffect.vala \ + CircleEffect.vala \ + CirclesEffect.vala \ + SquaresEffect.vala \ + StripesEffect.vala \ + ChessEffect.vala \ + ClockEffect.vala + +RC_FILES := \ + slideshow-plugin.png + +include ../Makefile.plugin.mk + diff --git a/plugins/shotwell-transitions/SlideEffect.vala b/plugins/shotwell-transitions/SlideEffect.vala new file mode 100644 index 0000000..1019f62 --- /dev/null +++ b/plugins/shotwell-transitions/SlideEffect.vala @@ -0,0 +1,75 @@ +/* Copyright 2010 Maxim Kartashev + * Copyright 2011-2014 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +using Spit; + +private class SlideEffectDescriptor : ShotwellTransitionDescriptor { + public SlideEffectDescriptor(GLib.File resource_directory) { + base(resource_directory); + } + + public override unowned string get_id() { + return "org.yorba.shotwell.transitions.slide"; + } + + public override unowned string get_pluggable_name() { + return _("Slide"); + } + + public override Transitions.Effect create(Spit.HostInterface host) { + return new SlideEffect(); + } +} + +private class SlideEffect : Object, Transitions.Effect { + private const int DESIRED_FPS = 25; + private const int MIN_FPS = 15; + + public SlideEffect() { + } + + public void get_fps(out int desired_fps, out int min_fps) { + desired_fps = SlideEffect.DESIRED_FPS; + min_fps = SlideEffect.MIN_FPS; + } + + public void start(Transitions.Visuals visuals, Transitions.Motion motion) { + } + + public bool needs_clear_background() { + return true; + } + + public void paint(Transitions.Visuals visuals, Transitions.Motion motion, Cairo.Context ctx, + int width, int height, int frame_number) { + double alpha = motion.get_alpha(frame_number); + + if (visuals.from_pixbuf != null) { + int from_target_x = (motion.direction == Transitions.Direction.FORWARD) + ? -visuals.from_pixbuf.width : width; + int from_current_x = (int) (visuals.from_pos.x * (1 - alpha) + from_target_x * alpha); + Gdk.cairo_set_source_pixbuf(ctx, visuals.from_pixbuf, from_current_x, visuals.from_pos.y); + ctx.paint(); + } + + if (visuals.to_pixbuf != null) { + int to_target_x = (width - visuals.to_pixbuf.width) / 2; + int from_x = (motion.direction == Transitions.Direction.FORWARD) + ? width : -visuals.to_pixbuf.width; + int to_current_x = (int) (from_x * (1 - alpha) + to_target_x * alpha); + Gdk.cairo_set_source_pixbuf(ctx, visuals.to_pixbuf, to_current_x, visuals.to_pos.y); + ctx.paint(); + } + } + + public void advance(Transitions.Visuals visuals, Transitions.Motion motion, int frame_number) { + } + + public void cancel() { + } +} + diff --git a/plugins/shotwell-transitions/SquaresEffect.vala b/plugins/shotwell-transitions/SquaresEffect.vala new file mode 100644 index 0000000..c5a0163 --- /dev/null +++ b/plugins/shotwell-transitions/SquaresEffect.vala @@ -0,0 +1,86 @@ +/* Copyright 2013 Jens Bav + * Copyright 2011-2014 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +using Spit; + +private class SquaresEffectDescriptor : ShotwellTransitionDescriptor { + public SquaresEffectDescriptor(GLib.File resource_directory) { + base(resource_directory); + } + + public override unowned string get_id() { + return "org.yorba.shotwell.transitions.squares"; + } + + public override unowned string get_pluggable_name() { + return _("Squares"); + } + + public override Transitions.Effect create(HostInterface host) { + return new SquaresEffect(); + } +} + +private class SquaresEffect : Object, Transitions.Effect { + private const int DESIRED_FPS = 25; + private const int MIN_FPS = 10; + private const int SQUARE_SIZE = 100; + private double square_count_x; + private double square_count_y; + + public SquaresEffect() { + } + + public void get_fps(out int desired_fps, out int min_fps) { + desired_fps = SquaresEffect.DESIRED_FPS; + min_fps = SquaresEffect.MIN_FPS; + } + + public void start(Transitions.Visuals visuals, Transitions.Motion motion) { + square_count_x = visuals.to_pos.width/SQUARE_SIZE + 1; + square_count_y = visuals.to_pos.height/SQUARE_SIZE + 1; + } + + public bool needs_clear_background() { + return true; + } + + public void paint(Transitions.Visuals visuals, Transitions.Motion motion, Cairo.Context ctx, + int width, int height, int frame_number) { + double alpha = motion.get_alpha(frame_number); + if (visuals.from_pixbuf != null) { + Gdk.cairo_set_source_pixbuf(ctx, visuals.from_pixbuf, visuals.from_pos.x, + visuals.from_pos.y); + ctx.paint_with_alpha(1 - alpha); + } + + if (visuals.to_pixbuf != null) { + Gdk.cairo_set_source_pixbuf(ctx, visuals.to_pixbuf,visuals.to_pos.x, visuals.to_pos.y); + for (double y = 0; y<=square_count_y; y++) { + for (double x = 0; x <=square_count_x; x++) { + double size = SQUARE_SIZE * (Math.fmin(1, alpha + ((square_count_x - x) + / square_count_x + (square_count_y - y)/square_count_y)/2.5)); + + ctx.rectangle(visuals.to_pos.x + x * SQUARE_SIZE, visuals.to_pos.y + y + * SQUARE_SIZE, size, size); + + ctx.fill(); + } + } + + ctx.clip(); + ctx.paint_with_alpha(alpha); + } + } + + public void advance(Transitions.Visuals visuals, Transitions.Motion motion, int frame_number) { + } + + public void cancel() { + } +} + diff --git a/plugins/shotwell-transitions/StripesEffect.vala b/plugins/shotwell-transitions/StripesEffect.vala new file mode 100644 index 0000000..2edbdfe --- /dev/null +++ b/plugins/shotwell-transitions/StripesEffect.vala @@ -0,0 +1,84 @@ +/* Copyright 2013 Jens Bav + * Copyright 2011-2014 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +using Spit; + +private class StripesEffectDescriptor : ShotwellTransitionDescriptor { + public StripesEffectDescriptor(GLib.File resource_directory) { + base(resource_directory); + } + + public override unowned string get_id() { + return "org.yorba.shotwell.transitions.stripes"; + } + + public override unowned string get_pluggable_name() { + return _("Stripes"); + } + + public override Transitions.Effect create(HostInterface host) { + return new StripesEffect(); + } +} + +private class StripesEffect : Object, Transitions.Effect { + private const int DESIRED_FPS = 25; + private const int MIN_FPS = 10; + private const int STRIPE_HEIGHT = 100; + private int stripe_count; + + public StripesEffect() { + } + + public void get_fps(out int desired_fps, out int min_fps) { + desired_fps = StripesEffect.DESIRED_FPS; + min_fps = StripesEffect.MIN_FPS; + } + + public void start(Transitions.Visuals visuals, Transitions.Motion motion) { + stripe_count = visuals.to_pos.height / STRIPE_HEIGHT + 1; + } + + public bool needs_clear_background() { + return true; + } + + public void paint(Transitions.Visuals visuals, Transitions.Motion motion, Cairo.Context ctx, + int width, int height, int frame_number) { + double alpha = motion.get_alpha(frame_number); + if (visuals.from_pixbuf != null) { + Gdk.cairo_set_source_pixbuf(ctx, visuals.from_pixbuf, visuals.from_pos.x, + visuals.from_pos.y); + ctx.paint_with_alpha(1 - Math.fmin(1, alpha * 2)); + } + + if (visuals.to_pixbuf != null) { + Gdk.cairo_set_source_pixbuf(ctx, visuals.to_pixbuf,visuals.to_pos.x, visuals.to_pos.y); + int x = visuals.to_pos.x; + int y = visuals.to_pos.y; + for (int i = 0; i <= stripe_count; i++) { + if (i % 2 == motion.direction) { + ctx.rectangle(x + visuals.to_pos.width - alpha * visuals.to_pos.width, + y + i * STRIPE_HEIGHT, x + visuals.to_pos.width, STRIPE_HEIGHT); + } else { + ctx.rectangle(x, y + STRIPE_HEIGHT * i, visuals.to_pos.width * alpha, + STRIPE_HEIGHT); + } + } + + ctx.clip(); + ctx.paint_with_alpha(alpha); + } + } + + public void advance(Transitions.Visuals visuals, Transitions.Motion motion, int frame_number) { + } + + public void cancel() { + } +} + diff --git a/plugins/shotwell-transitions/shotwell-transitions.vala b/plugins/shotwell-transitions/shotwell-transitions.vala new file mode 100644 index 0000000..bd358c3 --- /dev/null +++ b/plugins/shotwell-transitions/shotwell-transitions.vala @@ -0,0 +1,90 @@ +/* Copyright 2011-2014 Yorba Foundation + * + * This software is licensed under the GNU Lesser General Public License + * (version 2.1 or later). See the COPYING file in this distribution. + */ + +extern const string _VERSION; + +private class ShotwellTransitions : Object, Spit.Module { + private Spit.Pluggable[] pluggables = new Spit.Pluggable[0]; + + public ShotwellTransitions(GLib.File module_file) { + GLib.File resource_directory = module_file.get_parent(); + + pluggables += new FadeEffectDescriptor(resource_directory); + pluggables += new SlideEffectDescriptor(resource_directory); + pluggables += new CrumbleEffectDescriptor(resource_directory); + pluggables += new BlindsEffectDescriptor(resource_directory); + pluggables += new CircleEffectDescriptor(resource_directory); + pluggables += new CirclesEffectDescriptor(resource_directory); + pluggables += new ClockEffectDescriptor(resource_directory); + pluggables += new SquaresEffectDescriptor(resource_directory); + pluggables += new ChessEffectDescriptor(resource_directory); + pluggables += new StripesEffectDescriptor(resource_directory); + } + + public unowned string get_module_name() { + return _("Core Slideshow Transitions"); + } + + public unowned string get_version() { + return _VERSION; + } + + public unowned string get_id() { + return "org.yorba.shotwell.transitions"; + } + + public unowned Spit.Pluggable[]? get_pluggables() { + return pluggables; + } +} + +// This entry point is required for all SPIT modules. +public Spit.Module? spit_entry_point(Spit.EntryPointParams *params) { + params->module_spit_interface = Spit.negotiate_interfaces(params->host_min_spit_interface, + params->host_max_spit_interface, Spit.CURRENT_INTERFACE); + + return (params->module_spit_interface != Spit.UNSUPPORTED_INTERFACE) + ? new ShotwellTransitions(params->module_file) : null; +} + +// Base class for all transition descriptors in this module +public abstract class ShotwellTransitionDescriptor : Object, Spit.Pluggable, Spit.Transitions.Descriptor { + private const string ICON_FILENAME = "slideshow-plugin.png"; + + private static Gdk.Pixbuf[] icon_pixbuf_set = null; + + public ShotwellTransitionDescriptor(GLib.File resource_directory) { + if (icon_pixbuf_set == null) + icon_pixbuf_set = Resources.load_icon_set(resource_directory.get_child(ICON_FILENAME)); + } + + public int get_pluggable_interface(int min_host_interface, int max_host_interface) { + return Spit.negotiate_interfaces(min_host_interface, max_host_interface, + Spit.Transitions.CURRENT_INTERFACE); + } + + public abstract unowned string get_id(); + + public abstract unowned string get_pluggable_name(); + + public void get_info(ref Spit.PluggableInfo info) { + info.authors = "Maxim Kartashev"; + info.copyright = _("Copyright 2010 Maxim Kartashev, Copyright 2011-2014 Yorba Foundation"); + info.translators = Resources.TRANSLATORS; + info.version = _VERSION; + info.website_name = Resources.WEBSITE_NAME; + info.website_url = Resources.WEBSITE_URL; + info.is_license_wordwrapped = false; + info.license = Resources.LICENSE; + info.icons = icon_pixbuf_set; + } + + public void activation(bool enabled) { + } + + public abstract Spit.Transitions.Effect create(Spit.HostInterface host); +} + diff --git a/plugins/shotwell-transitions/slideshow-plugin.png b/plugins/shotwell-transitions/slideshow-plugin.png new file mode 100755 index 0000000..cb4a497 Binary files /dev/null and b/plugins/shotwell-transitions/slideshow-plugin.png differ -- cgit v1.2.3