Commit 886689c4 authored by Jens B's avatar Jens B Committed by Lucas Beeler

Adds three additional slideshow transition effects. Closes #6411.

parent c10d3d84
...@@ -659,6 +659,24 @@ ...@@ -659,6 +659,24 @@
<summary>enable slideshow slide transition</summary> <summary>enable slideshow slide transition</summary>
<description>True if the Blinds slideshow transition plugin is enabled, false otherwise</description> <description>True if the Blinds slideshow transition plugin is enabled, false otherwise</description>
</key> </key>
<key name="transitions-squares" type="b">
<default>true</default>
<summary>enable slideshow squares transition</summary>
<description>True if the Squares slideshow transition plugin is enabled, false otherwise</description>
</key>
<key name="transitions-stripes" type="b">
<default>true</default>
<summary>enable slideshow stripes transition</summary>
<description>True if the Stripes slideshow transition plugin is enabled, false otherwise</description>
</key>
<key name="transitions-chess" type="b">
<default>true</default>
<summary>enable slideshow chess transition</summary>
<description>True if the Chess-Board slideshow transition plugin is enabled, false otherwise</description>
</key>
</schema> </schema>
</schemalist> </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 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() {
}
}
...@@ -9,6 +9,9 @@ SRC_FILES := \ ...@@ -9,6 +9,9 @@ SRC_FILES := \
BlindsEffect.vala \ BlindsEffect.vala \
CircleEffect.vala \ CircleEffect.vala \
CirclesEffect.vala \ CirclesEffect.vala \
SquaresEffect.vala \
StripesEffect.vala \
ChessEffect.vala \
ClockEffect.vala ClockEffect.vala
RC_FILES := \ RC_FILES := \
......
/* 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 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() {
}
}
/* 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 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() {
}
}
...@@ -19,6 +19,9 @@ private class ShotwellTransitions : Object, Spit.Module { ...@@ -19,6 +19,9 @@ private class ShotwellTransitions : Object, Spit.Module {
pluggables += new CircleEffectDescriptor(resource_directory); pluggables += new CircleEffectDescriptor(resource_directory);
pluggables += new CirclesEffectDescriptor(resource_directory); pluggables += new CirclesEffectDescriptor(resource_directory);
pluggables += new ClockEffectDescriptor(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() { public unowned string get_module_name() {
......
...@@ -15,6 +15,9 @@ public void init() throws Error { ...@@ -15,6 +15,9 @@ public void init() throws Error {
core_ids += "org.yorba.shotwell.transitions.circle"; core_ids += "org.yorba.shotwell.transitions.circle";
core_ids += "org.yorba.shotwell.transitions.circles"; core_ids += "org.yorba.shotwell.transitions.circles";
core_ids += "org.yorba.shotwell.transitions.clock"; core_ids += "org.yorba.shotwell.transitions.clock";
core_ids += "org.yorba.shotwell.transitions.stripes";
core_ids += "org.yorba.shotwell.transitions.squares";
core_ids += "org.yorba.shotwell.transitions.chess";
Plugins.register_extension_point(typeof(Spit.Transitions.Descriptor), _("Slideshow Transitions"), Plugins.register_extension_point(typeof(Spit.Transitions.Descriptor), _("Slideshow Transitions"),
Resources.ICON_SLIDESHOW_EXTENSION_POINT, core_ids); 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