Skip to content

Commit 6acf811

Browse files
committed
Remove done signal
1 parent 2e7af0b commit 6acf811

File tree

1 file changed

+27
-37
lines changed

1 file changed

+27
-37
lines changed

src/Gestures/GesturePropertyTransition.vala

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@
1212
public class Gala.GesturePropertyTransition : Object {
1313
public delegate void DoneCallback ();
1414

15-
/**
16-
* Emitted when all animations are finished that is when the property has reached the target value
17-
* either via gesture or via easing or combined.
18-
*/
19-
public signal void done ();
20-
2115
/**
2216
* The actor whose property will be animated.
2317
*/
@@ -49,6 +43,10 @@ public class Gala.GesturePropertyTransition : Object {
4943
*/
5044
public Value? intermediate_value { get; construct; }
5145

46+
private Value actual_from_value;
47+
48+
private DoneCallback? done_callback;
49+
5250
public GesturePropertyTransition (
5351
Clutter.Actor actor,
5452
GestureTracker gesture_tracker,
@@ -67,10 +65,6 @@ public class Gala.GesturePropertyTransition : Object {
6765
);
6866
}
6967

70-
construct {
71-
done.connect (unref);
72-
}
73-
7468
/**
7569
* Starts animating the property from {@link from_value} to {@link to_value}. If with_gesture is true
7670
* it will connect to the gesture trackers signals and animate according to the input finishing with an easing
@@ -82,43 +76,31 @@ public class Gala.GesturePropertyTransition : Object {
8276
public void start (bool with_gesture, owned DoneCallback? done_callback = null) {
8377
ref ();
8478

85-
if (done_callback != null) {
86-
ulong done_callback_handler = 0;
87-
done_callback_handler = done.connect (() => {
88-
done_callback ();
89-
disconnect (done_callback_handler);
90-
});
91-
}
79+
this.done_callback = (owned) done_callback;
9280

9381
Value current_value = {};
9482
actor.get_property (property, ref current_value);
9583

96-
if (from_value == null) {
97-
from_value = current_value;
84+
actual_from_value = from_value ?? current_value;
9885

99-
ulong done_handler = 0;
100-
done_handler = done.connect (() => {
101-
from_value = null;
102-
disconnect (done_handler);
103-
});
104-
} else if (from_value.type () != current_value.type ()) {
86+
if (actual_from_value.type () != current_value.type ()) {
10587
warning ("from_value of type %s is not of the same type as the property %s which is %s. Can't animate.", from_value.type_name (), property, current_value.type_name ());
106-
done ();
88+
finish ();
10789
return;
10890
}
10991

11092
if (current_value.type () != to_value.type ()) {
11193
warning ("to_value of type %s is not of the same type as the property %s which is %s. Can't animate.", to_value.type_name (), property, current_value.type_name ());
112-
done ();
94+
finish ();
11395
return;
11496
}
11597

11698
GestureTracker.OnBegin on_animation_begin = () => {
117-
actor.set_property (property, from_value);
99+
actor.set_property (property, actual_from_value);
118100
};
119101

120102
GestureTracker.OnUpdate on_animation_update = (percentage) => {
121-
var animation_value = GestureTracker.animation_value (value_to_float (from_value), value_to_float (intermediate_value ?? to_value), percentage);
103+
var animation_value = GestureTracker.animation_value (value_to_float (actual_from_value), value_to_float (intermediate_value ?? to_value), percentage);
122104
actor.set_property (property, value_from_float (animation_value));
123105
};
124106

@@ -128,16 +110,16 @@ public class Gala.GesturePropertyTransition : Object {
128110
}
129111

130112
actor.save_easing_state ();
131-
actor.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
132-
actor.set_easing_duration (AnimationsSettings.get_enable_animations () ? calculated_duration : 0);
133-
actor.set_property (property, cancel_action ? from_value : to_value);
113+
actor.set_easing_mode (EASE_OUT_QUAD);
114+
actor.set_easing_duration (AnimationsSettings.get_animation_duration (calculated_duration));
115+
actor.set_property (property, cancel_action ? actual_from_value : to_value);
134116
actor.restore_easing_state ();
135117

136118
unowned var transition = actor.get_transition (property);
137119
if (transition == null) {
138-
done ();
120+
finish ();
139121
} else {
140-
transition.stopped.connect (() => done ());
122+
transition.stopped.connect (finish);
141123
}
142124
};
143125

@@ -147,8 +129,8 @@ public class Gala.GesturePropertyTransition : Object {
147129
on_animation_begin (0);
148130
if (intermediate_value != null) {
149131
actor.save_easing_state ();
150-
actor.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
151-
actor.set_easing_duration (AnimationsSettings.get_enable_animations () ? gesture_tracker.min_animation_duration : 0);
132+
actor.set_easing_mode (EASE_OUT_QUAD);
133+
actor.set_easing_duration (AnimationsSettings.get_animation_duration (gesture_tracker.min_animation_duration));
152134
actor.set_property (property, intermediate_value);
153135
actor.restore_easing_state ();
154136

@@ -164,6 +146,14 @@ public class Gala.GesturePropertyTransition : Object {
164146
}
165147
}
166148

149+
private void finish () {
150+
if (done_callback != null) {
151+
done_callback ();
152+
}
153+
154+
unref ();
155+
}
156+
167157
private float value_to_float (Value val) {
168158
Value float_val = Value (typeof (float));
169159
if (val.transform (ref float_val)) {
@@ -178,7 +168,7 @@ public class Gala.GesturePropertyTransition : Object {
178168
var float_val = Value (typeof (float));
179169
float_val.set_float (f);
180170

181-
var val = Value (from_value.type ());
171+
var val = Value (actual_from_value.type ());
182172

183173
if (!float_val.transform (ref val)) {
184174
warning ("Failed to transform float to give type");

0 commit comments

Comments
 (0)