1 /*
2 * This file is part of d-dazzle.
3 *
4 * d-dazzle is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License
6 * as published by the Free Software Foundation; either version 3
7 * of the License, or (at your option) any later version, with
8 * some exceptions, please read the COPYING file.
9 *
10 * d-dazzle 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
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with d-dazzle; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18 */19 moduledazzle.Animation;
20 21 privateimportdazzle.c.functions;
22 publicimportdazzle.c.types;
23 privateimportgdk.MonitorG;
24 privateimportgobject.ObjectG;
25 privateimportgobject.ParamSpec;
26 privateimportgobject.Signals;
27 privateimportgobject.Value;
28 privateimportstd.algorithm;
29 30 31 /** */32 publicclassAnimation : ObjectG33 {
34 /** the main Gtk struct */35 protectedDzlAnimation* dzlAnimation;
36 37 /** Get the main Gtk struct */38 publicDzlAnimation* getAnimationStruct(booltransferOwnership = false)
39 {
40 if (transferOwnership)
41 ownedRef = false;
42 returndzlAnimation;
43 }
44 45 /** the main Gtk struct as a void* */46 protectedoverridevoid* getStruct()
47 {
48 returncast(void*)dzlAnimation;
49 }
50 51 /**
52 * Sets our main struct and passes it to the parent class.
53 */54 publicthis (DzlAnimation* dzlAnimation, boolownedRef = false)
55 {
56 this.dzlAnimation = dzlAnimation;
57 super(cast(GObject*)dzlAnimation, ownedRef);
58 }
59 60 61 /** */62 publicstaticGTypegetType()
63 {
64 returndzl_animation_get_type();
65 }
66 67 /** */68 publicstaticuintcalculateDuration(MonitorGmonitor, doublefromValue, doubletoValue)
69 {
70 returndzl_animation_calculate_duration((monitorisnull) ? null : monitor.getMonitorGStruct(), fromValue, toValue);
71 }
72 73 /**
74 * Adds a new property to the set of properties to be animated during the
75 * lifetime of the animation.
76 *
77 * Side effects: None.
78 *
79 * Params:
80 * pspec = A #ParamSpec of @target or a #GtkWidget<!-- -->'s parent.
81 * value = The new value for the property at the end of the animation.
82 */83 publicvoidaddProperty(ParamSpecpspec, Valuevalue)
84 {
85 dzl_animation_add_property(dzlAnimation, (pspecisnull) ? null : pspec.getParamSpecStruct(), (valueisnull) ? null : value.getValueStruct());
86 }
87 88 /**
89 * Start the animation. When the animation stops, the internal reference will
90 * be dropped and the animation may be finalized.
91 *
92 * Side effects: None.
93 */94 publicvoidstart()
95 {
96 dzl_animation_start(dzlAnimation);
97 }
98 99 /**
100 * Stops a running animation. The internal reference to the animation is
101 * dropped and therefore may cause the object to finalize.
102 *
103 * As a convenience, this function accepts %NULL for @animation but
104 * does nothing if that should occur.
105 */106 publicvoidstop()
107 {
108 dzl_animation_stop(dzlAnimation);
109 }
110 111 /**
112 * The "tick" signal is emitted on each frame in the animation.
113 */114 gulongaddOnTick(voiddelegate(Animation) dlg, ConnectFlagsconnectFlags=cast(ConnectFlags)0)
115 {
116 returnSignals.connect(this, "tick", dlg, connectFlags ^ ConnectFlags.SWAPPED);
117 }
118 }