Skip to content

Commit 5ae0b70

Browse files
committed
MultitaskingView: Add overshoot animation
1 parent 81a3a00 commit 5ae0b70

File tree

3 files changed

+27
-7
lines changed

3 files changed

+27
-7
lines changed

lib/Gestures/PropertyTarget.vala

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,24 @@ public class Gala.PropertyTarget : Object, GestureTarget {
1010
// Don't take a reference since we are most of the time owned by the target
1111
public weak Object? target { get; private set; }
1212
public string property { get; construct; }
13-
13+
public bool allow_overshoot { get; construct; }
1414
public Clutter.Interval interval { get; construct; }
1515

16-
public PropertyTarget (GestureAction action, Object target, string property, Type value_type, Value from_value, Value to_value) {
17-
Object (action: action, property: property, interval: new Clutter.Interval.with_values (value_type, from_value, to_value));
16+
public PropertyTarget (
17+
GestureAction action,
18+
Object target,
19+
string property,
20+
Type value_type,
21+
Value from_value,
22+
Value to_value,
23+
bool allow_overshoot = false
24+
) {
25+
Object (
26+
action: action,
27+
property: property,
28+
interval: new Clutter.Interval.with_values (value_type, from_value, to_value),
29+
allow_overshoot: allow_overshoot
30+
);
1831

1932
this.target = target;
2033
this.target.weak_ref (on_target_disposed);
@@ -35,6 +48,10 @@ public class Gala.PropertyTarget : Object, GestureTarget {
3548
return;
3649
}
3750

51+
if (!allow_overshoot) {
52+
progress = progress.clamp (0.0, 1.0);
53+
}
54+
3855
target.set_property (property, interval.compute (progress));
3956
}
4057
}

src/Widgets/MultitaskingView/MultitaskingView.vala

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,10 @@ public class Gala.MultitaskingView : ActorTarget, RootTarget, ActivatableCompone
6161
opened = false;
6262
display = wm.get_display ();
6363

64-
multitasking_gesture_controller = new GestureController (MULTITASKING_VIEW, wm, MULTITASKING_VIEW);
64+
multitasking_gesture_controller = new GestureController (MULTITASKING_VIEW, wm, MULTITASKING_VIEW) {
65+
overshoot_upper_clamp = 1.1,
66+
overshoot_lower_clamp = -0.1
67+
};
6568
multitasking_gesture_controller.enable_touchpad (wm.stage);
6669
add_gesture_controller (multitasking_gesture_controller);
6770

src/Widgets/MultitaskingView/WorkspaceClone.vala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ public class Gala.WorkspaceClone : ActorTarget {
239239
var initial_width = monitor.width;
240240
var target_width = monitor.width * scale + WorkspaceRow.WORKSPACE_GAP * 2;
241241

242-
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "width", typeof (float), (float) initial_width, (float) target_width));
243-
add_target (new PropertyTarget (MULTITASKING_VIEW, background, "scale-x", typeof (double), 1d, (double) scale));
244-
add_target (new PropertyTarget (MULTITASKING_VIEW, background, "scale-y", typeof (double), 1d, (double) scale));
242+
add_target (new PropertyTarget (MULTITASKING_VIEW, this, "width", typeof (float), (float) initial_width, (float) target_width, true));
243+
add_target (new PropertyTarget (MULTITASKING_VIEW, background, "scale-x", typeof (double), 1d, (double) scale, true));
244+
add_target (new PropertyTarget (MULTITASKING_VIEW, background, "scale-y", typeof (double), 1d, (double) scale, true));
245245

246246
window_container.padding_top = Utils.scale_to_int (TOP_OFFSET, monitor_scale);
247247
window_container.padding_left = window_container.padding_right = (int) (monitor.width - monitor.width * scale) / 2;

0 commit comments

Comments
 (0)