~psybers/docky/stacks

« back to all changes in this revision

Viewing changes to Docky/Docky/Menus/MenuFileWidget.cs

  • Committer: Robert Dyer
  • Date: 2010-06-17 19:56:46 UTC
  • Revision ID: psybers@gmail.com-20100617195646-c2p2qfatoaoq6rvg
tweak the hover animation

Show diffs side-by-side

added added

removed removed

Lines of Context:
34
34
                const int iconSize = 48;
35
35
                const int padding = 4;
36
36
                const int textHeight = 12;
 
37
                const int AnimationTime = 250;
37
38
                
38
39
                public event EventHandler FolderSelected;
39
40
                
63
64
                {
64
65
                        QueueDraw ();
65
66
                        
66
 
                        if (SelectedOpacity < 1)
 
67
                        if ((DateTime.UtcNow - last_selected).TotalMilliseconds < AnimationTime)
67
68
                                return true;
68
69
                        
69
 
                        if (animation_timer > 0)
70
 
                                GLib.Source.Remove (animation_timer);
71
70
                        animation_timer = 0;
72
71
                        return false;
73
72
                }
74
73
                
75
74
                protected double SelectedOpacity {
76
 
                        get { return Math.Min (1, (DateTime.UtcNow - last_selected).TotalMilliseconds / 250); }
 
75
                        get {
 
76
                                double opacity = Math.Min (1, (DateTime.UtcNow - last_selected).TotalMilliseconds / AnimationTime);
 
77
                                if (IsSelected)
 
78
                                        return opacity;
 
79
                                return 1 - opacity;
 
80
                        }
77
81
                }
78
82
                
79
83
                Gdk.Rectangle VisibleRect;
170
174
                                        SetSizeRequest (2 * (iconSize + padding + lineWidth), VisibleRect.Height);
171
175
                                }
172
176
                                
173
 
                                if (IsSelected) {
 
177
                                if (SelectedOpacity > 0) {
174
178
                                        cr.RoundedRectangle (Allocation.X + lineWidth, Allocation.Y + lineWidth, Allocation.Width - 2 * lineWidth, VisibleRect.Height - 2 * lineWidth, 6.0);
175
179
                                        cr.Color = new Cairo.Color (1, 1, 1, SelectedOpacity * 0.2);
176
180
                                        cr.FillPreserve ();