1/* 2* Copyright (c) 2011-2013 Yorba Foundation 3* 2013 Jens Bav 4* 5* This program is free software; you can redistribute it and/or 6* modify it under the terms of the GNU Lesser General Public 7* License as published by the Free Software Foundation; either 8* version 2.1 of the License, or (at your option) any later version. 9* 10* This program is distributed in the hope that it will be useful, 11* but WITHOUT ANY WARRANTY; without even the implied warranty of 12* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13* General Public License for more details. 14* 15* You should have received a copy of the GNU General Public 16* License along with this program; if not, write to the 17* Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, 18* Boston, MA 02110-1301 USA 19*/ 20 21using Spit; 22 23private class CircleEffectDescriptor : ShotwellTransitionDescriptor { 24 public CircleEffectDescriptor (GLib.File resource_directory) { 25 base (resource_directory); 26 } 27 28 public override unowned string get_id () { 29 return "io.elementary.photos.transitions.circle"; 30 } 31 32 public override unowned string get_pluggable_name () { 33 return _ ("Circle"); 34 } 35 36 public override Transitions.Effect create (HostInterface host) { 37 return new CircleEffect (); 38 } 39} 40 41private class CircleEffect : Object, Transitions.Effect { 42 private const int DESIRED_FPS = 25; 43 private const int MIN_FPS = 15; 44 45 public CircleEffect () { 46 } 47 48 public void get_fps (out int desired_fps, out int min_fps) { 49 desired_fps = CircleEffect.DESIRED_FPS; 50 min_fps = CircleEffect.MIN_FPS; 51 } 52 53 public void start (Transitions.Visuals visuals, Transitions.Motion motion) { 54 } 55 56 public bool needs_clear_background () { 57 return true; 58 } 59 60 public void paint (Transitions.Visuals visuals, Transitions.Motion motion, Cairo.Context ctx, 61 int width, int height, int frame_number) { 62 double alpha = motion.get_alpha (frame_number); 63 int radius = (int) (alpha * Math.fmax (width, height)); 64 65 if (visuals.from_pixbuf != null) { 66 Gdk.cairo_set_source_pixbuf (ctx, visuals.from_pixbuf, visuals.from_pos.x, 67 visuals.from_pos.y); 68 ctx.paint_with_alpha (1 - alpha); 69 } 70 71 if (visuals.to_pixbuf != null) { 72 Gdk.cairo_set_source_pixbuf (ctx, visuals.to_pixbuf, visuals.to_pos.x, visuals.to_pos.y); 73 ctx.arc ((int) width / 2, (int) height / 2, radius, 0, 2 * Math.PI); 74 ctx.clip (); 75 ctx.paint (); 76 } 77 } 78 79 public void advance (Transitions.Visuals visuals, Transitions.Motion motion, int frame_number) { 80 } 81 82 public void cancel () { 83 } 84} 85