3
using System.Collections.Generic;
11
using Do.Interface.CairoUtils;
12
using Docky.Utilities;
14
namespace Docky.Interface
18
public class PoofWindow
20
TimeSpan run_length = new TimeSpan (0, 0, 0, 0, 300);
30
double AnimationState {
32
return Math.Max (0, Math.Min (1, (DateTime.UtcNow - run_time).TotalMilliseconds / run_length.TotalMilliseconds));
36
public PoofWindow (int size)
41
public void SetCenterPosition (Gdk.Point point)
43
x = point.X - (size / 2);
44
y = point.Y - (size / 2);
49
window = new Gtk.Window (Gtk.WindowType.Toplevel);
50
poof = new Pixbuf (GetType ().Assembly, "poof.png");
52
window.AppPaintable = true;
53
window.Resizable = false;
54
window.KeepAbove = true;
55
window.CanFocus = false;
56
window.TypeHint = WindowTypeHint.Splashscreen;
57
window.SetCompositeColormap ();
59
window.Realized += delegate { window.GdkWindow.SetBackPixmap (null, false); };
61
window.SetSizeRequest (size, size);
62
window.ExposeEvent += HandleExposeEvent;
64
GLib.Timeout.Add (30, delegate {
65
if (AnimationState == 1) {
78
run_time = DateTime.UtcNow;
81
void HandleExposeEvent (object o, ExposeEventArgs args)
83
using (Cairo.Context cr = CairoHelper.Create (window.GdkWindow)) {
84
cr.Scale ((double) size / 128, (double) size / 128);
87
switch ((int) Math.Floor (5 * AnimationState)) {
105
CairoHelper.SetSourcePixbuf (cr, poof, 0, -(offset));