2
// AnimatedVboxActor.cs
5
// Scott Peterson <lunchtimemama@gmail.com>
7
// Copyright (C) 2008 Scott Peterson
9
// Permission is hereby granted, free of charge, to any person obtaining
10
// a copy of this software and associated documentation files (the
11
// "Software"), to deal in the Software without restriction, including
12
// without limitation the rights to use, copy, modify, merge, publish,
13
// distribute, sublicense, and/or sell copies of the Software, and to
14
// permit persons to whom the Software is furnished to do so, subject to
15
// the following conditions:
17
// The above copyright notice and this permission notice shall be
18
// included in all copies or substantial portions of the Software.
20
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
21
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
22
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
23
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
24
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
25
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
26
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30
using System.Collections.Generic;
34
//using Hyena.Gui.Theatrics;
36
namespace Docky.Widgets
38
internal enum AnimationState
46
internal class AnimatedWidget : Container
48
public event EventHandler WidgetDestroyed;
52
public Blocking Blocking;
53
public AnimationState AnimationState;
55
public double Bias = 1.0;
58
public int StartPadding;
59
public int EndPadding;
60
public LinkedListNode <AnimatedWidget> Node;
62
private readonly bool horizontal;
63
private double percent;
64
private Rectangle widget_alloc;
65
private Pixmap canvas;
67
public AnimatedWidget (Widget widget, uint duration, Easing easing, Blocking blocking, bool horizontal)
69
this.horizontal = horizontal;
74
AnimationState = AnimationState.Coming;
77
Widget.Destroyed += OnWidgetDestroyed;
81
protected AnimatedWidget (IntPtr raw) : base (raw)
85
public double Percent {
86
get { return percent; }
88
percent = value * Bias;
89
QueueResizeNoRedraw ();
93
private void OnWidgetDestroyed (object sender, EventArgs args)
99
canvas = new Pixmap (GdkWindow, widget_alloc.Width, widget_alloc.Height);
100
canvas.DrawDrawable (Style.BackgroundGC (State), GdkWindow,
101
widget_alloc.X, widget_alloc.Y, 0, 0, widget_alloc.Width, widget_alloc.Height);
103
if (AnimationState != AnimationState.Going) {
104
WidgetDestroyed (this, args);
110
protected override void OnRemoved (Widget widget)
112
if (widget == Widget) {
118
protected override void OnRealized ()
120
WidgetFlags |= WidgetFlags.Realized;
122
Gdk.WindowAttr attributes = new Gdk.WindowAttr ();
123
attributes.WindowType = Gdk.WindowType.Child;
124
attributes.Wclass = Gdk.WindowClass.InputOutput;
125
attributes.EventMask = (int)Gdk.EventMask.ExposureMask;
127
GdkWindow = new Gdk.Window (Parent.GdkWindow, attributes, 0);
128
GdkWindow.UserData = Handle;
129
GdkWindow.Background = Style.Background (State);
130
Style.Attach (GdkWindow);
133
protected override void OnSizeRequested (ref Requisition requisition)
135
if (Widget != null) {
136
Requisition req = Widget.SizeRequest ();
137
widget_alloc.Width = req.Width;
138
widget_alloc.Height = req.Height;
142
Width = Choreographer.PixelCompose (percent, widget_alloc.Width + StartPadding + EndPadding, Easing);
143
Height = widget_alloc.Height;
145
Width = widget_alloc.Width;
146
Height = Choreographer.PixelCompose (percent, widget_alloc.Height + StartPadding + EndPadding, Easing);
149
requisition.Width = Width;
150
requisition.Height = Height;
153
protected override void OnSizeAllocated (Rectangle allocation)
155
base.OnSizeAllocated (allocation);
156
if (Widget != null) {
158
widget_alloc.Height = allocation.Height;
159
widget_alloc.X = StartPadding;
160
if (Blocking == Blocking.Downstage) {
161
widget_alloc.X += allocation.Width - widget_alloc.Width;
164
widget_alloc.Width = allocation.Width;
165
widget_alloc.Y = StartPadding;
166
if (Blocking == Blocking.Downstage) {
167
widget_alloc.Y = allocation.Height - widget_alloc.Height;
170
Widget.SizeAllocate (widget_alloc);
174
protected override bool OnExposeEvent (EventExpose evnt)
176
if (canvas != null) {
177
GdkWindow.DrawDrawable (Style.BackgroundGC (State), canvas,
178
0, 0, widget_alloc.X, widget_alloc.Y, widget_alloc.Width, widget_alloc.Height);
181
return base.OnExposeEvent (evnt);
185
protected override void ForAll (bool include_internals, Callback callback)
187
if (Widget != null) {
b'\\ No newline at end of file'