Commit 569952f8 authored by Jens B's avatar Jens B Committed by Lucas Beeler

Adds four additional core slideshow transitions. Closes #6347.

parent 921e0bd9
......@@ -632,9 +632,33 @@
<key name="transitions-slide" type="b">
<default>true</default>
<summary>enable slideshow slide transision</summary>
<summary>enable slideshow slide transition</summary>
<description>True if the Slide slideshow transition plugin is enabled, false otherwise</description>
</key>
<key name="transitions-clock" type="b">
<default>true</default>
<summary>enable slideshow clock transition</summary>
<description>True if the Clock slideshow transition plugin is enabled, false otherwise</description>
</key>
<key name="transitions-circle" type="b">
<default>true</default>
<summary>enable slideshow circle transition</summary>
<description>True if the Circle slideshow transition plugin is enabled, false otherwise</description>
</key>
<key name="transitions-circles" type="b">
<default>true</default>
<summary>enable slideshow circle transition</summary>
<description>True if the Circles slideshow transition plugin is enabled, false otherwise</description>
</key>
<key name="transitions-blinds" type="b">
<default>true</default>
<summary>enable slideshow slide transition</summary>
<description>True if the Blinds slideshow transition plugin is enabled, false otherwise</description>
</key>
</schema>
</schemalist>
......
/* Copyright 2013 Jens Bav
* Copyright 2011-2013 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() {
}
}
/* Copyright 2013 Jens Bav
* Copyright 2011-2013 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() {
}
}
/* Copyright 2013 Jens Bav
* Copyright 2011-2013 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() {
}
}
/* Copyright 2013 Jens Bav
* Copyright 2011-2013 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() {
}
}
......@@ -5,7 +5,11 @@ SRC_FILES := \
shotwell-transitions.vala \
FadeEffect.vala \
SlideEffect.vala \
CrumbleEffect.vala
CrumbleEffect.vala \
BlindsEffect.vala \
CircleEffect.vala \
CirclesEffect.vala \
ClockEffect.vala
RC_FILES := \
slideshow-plugin.png
......
......@@ -15,6 +15,10 @@ private class ShotwellTransitions : Object, Spit.Module {
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);
}
public unowned string get_module_name() {
......
......@@ -11,6 +11,10 @@ public void init() throws Error {
core_ids += "org.yorba.shotwell.transitions.crumble";
core_ids += "org.yorba.shotwell.transitions.fade";
core_ids += "org.yorba.shotwell.transitions.slide";
core_ids += "org.yorba.shotwell.transitions.blinds";
core_ids += "org.yorba.shotwell.transitions.circle";
core_ids += "org.yorba.shotwell.transitions.circles";
core_ids += "org.yorba.shotwell.transitions.clock";
Plugins.register_extension_point(typeof(Spit.Transitions.Descriptor), _("Slideshow Transitions"),
Resources.ICON_SLIDESHOW_EXTENSION_POINT, core_ids);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment