Skip to content

Commit 725177f

Browse files
committed
Some fixes and use in workspace clone
1 parent 445d730 commit 725177f

File tree

3 files changed

+24
-126
lines changed

3 files changed

+24
-126
lines changed

src/Gestures/PropertyGestureTransition.vala

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,25 @@ public class Gala.PropertyGestureTransition : Object {
55
public Value? from_value { get; construct; }
66
public Value to_value { get; construct; }
77
public bool with_gesture { get; construct; }
8+
public Value? intermediate_value { get; construct; }
89

910
public PropertyGestureTransition (
1011
Clutter.Actor actor,
1112
GestureTracker gesture_tracker,
1213
string property,
1314
Value? from_value,
1415
Value to_value,
15-
bool with_gesture
16+
bool with_gesture,
17+
Value? intermediate_value = null
1618
) {
1719
Object (
1820
actor: actor,
1921
gesture_tracker: gesture_tracker,
2022
property: property,
2123
from_value: from_value,
2224
to_value: to_value,
23-
with_gesture: with_gesture
25+
with_gesture: with_gesture,
26+
intermediate_value: intermediate_value
2427
);
2528
}
2629

@@ -38,18 +41,18 @@ public class Gala.PropertyGestureTransition : Object {
3841
};
3942

4043
GestureTracker.OnUpdate on_animation_update = (percentage) => {
41-
var animation_value = GestureTracker.animation_value (value_to_float (from_value), value_to_float (to_value), percentage);
44+
var animation_value = GestureTracker.animation_value (value_to_float (from_value), value_to_float (intermediate_value ?? to_value), percentage);
4245
actor.set_property (property, value_from_float (animation_value));
4346
};
4447

45-
GestureTracker.OnEnd on_animation_end = (percentage, cancel_action) => {
48+
GestureTracker.OnEnd on_animation_end = (percentage, cancel_action, calculated_duration) => {
4649
if (cancel_action) {
4750
return;
4851
}
4952

5053
actor.save_easing_state ();
5154
actor.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
52-
actor.set_easing_duration (500);
55+
actor.set_easing_duration (calculated_duration);
5356
actor.set_property (property, cancel_action ? from_value : to_value);
5457
actor.restore_easing_state ();
5558

@@ -60,7 +63,7 @@ public class Gala.PropertyGestureTransition : Object {
6063
gesture_tracker.connect_handlers (on_animation_begin, on_animation_update, on_animation_end);
6164
} else {
6265
on_animation_begin (0);
63-
on_animation_end (1, false, 0);
66+
on_animation_end (1, false, gesture_tracker.min_animation_duration);
6467
}
6568
}
6669

src/Widgets/MultitaskingView.vala

Lines changed: 8 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -383,60 +383,17 @@ namespace Gala {
383383
target_workspace.activate (display.get_current_time ());
384384
}
385385

386-
new PropertyGestureTransition (workspaces, workspace_gesture_tracker, "x", null, target_x, true);
387-
388-
GestureTracker.OnUpdate on_animation_update = (percentage) => {
389-
var x = GestureTracker.animation_value (initial_x, target_x, percentage, true);
390-
var icon_group_opacity = GestureTracker.animation_value (0.0f, 1.0f, percentage, false);
391-
392-
if (is_nudge_animation) {
393-
x = x.clamp (initial_x - nudge_gap, initial_x + nudge_gap);
394-
}
395-
396-
// workspaces.x = x;
397-
398-
if (!is_nudge_animation) {
399-
active_icon_group.backdrop_opacity = 1.0f - icon_group_opacity;
400-
target_icon_group.backdrop_opacity = icon_group_opacity;
401-
}
402-
};
386+
if (is_nudge_animation) {
387+
new PropertyGestureTransition (workspaces, workspace_gesture_tracker, "x", null, initial_x, true, initial_x + nudge_gap * -relative_dir);
388+
} else {
389+
new PropertyGestureTransition (workspaces, workspace_gesture_tracker, "x", null, target_x, true);
390+
new PropertyGestureTransition (active_icon_group, workspace_gesture_tracker, "backdrop-opacity", 1f, 0f, true);
391+
new PropertyGestureTransition (target_icon_group, workspace_gesture_tracker, "backdrop-opacity", 0f, 1f, true);
392+
}
403393

404394
GestureTracker.OnEnd on_animation_end = (percentage, cancel_action, calculated_duration) => {
405395
switching_workspace_with_gesture = false;
406396

407-
var duration = is_nudge_animation ?
408-
(uint) (AnimationDuration.NUDGE / 2) :
409-
(uint) calculated_duration;
410-
411-
// workspaces.save_easing_state ();
412-
// workspaces.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
413-
// workspaces.set_easing_duration (duration);
414-
// workspaces.x = (is_nudge_animation || cancel_action) ? initial_x : target_x;
415-
// workspaces.restore_easing_state ();
416-
417-
if (!is_nudge_animation) {
418-
if (wm.enable_animations) {
419-
var active_transition = new Clutter.PropertyTransition ("backdrop-opacity") {
420-
duration = duration,
421-
remove_on_complete = true
422-
};
423-
active_transition.set_from_value (active_icon_group.backdrop_opacity);
424-
active_transition.set_to_value (cancel_action ? 1.0f : 0.0f);
425-
active_icon_group.add_transition ("backdrop-opacity", active_transition);
426-
427-
var target_transition = new Clutter.PropertyTransition ("backdrop-opacity") {
428-
duration = duration,
429-
remove_on_complete = true
430-
};
431-
target_transition.set_from_value (target_icon_group.backdrop_opacity);
432-
target_transition.set_to_value (cancel_action ? 0.0f : 1.0f);
433-
target_icon_group.add_transition ("backdrop-opacity", target_transition);
434-
} else {
435-
active_icon_group.backdrop_opacity = cancel_action ? 1.0f : 0.0f;
436-
target_icon_group.backdrop_opacity = cancel_action ? 0.0f : 1.0f;
437-
}
438-
}
439-
440397
if (is_nudge_animation || cancel_action) {
441398
active_workspace.activate (display.get_current_time ());
442399
}
@@ -445,7 +402,7 @@ namespace Gala {
445402
if (!wm.enable_animations) {
446403
on_animation_end (1, false, 0);
447404
} else {
448-
workspace_gesture_tracker.connect_handlers (null, (owned) on_animation_update, (owned) on_animation_end);
405+
workspace_gesture_tracker.connect_handlers (null, null, (owned) on_animation_end);
449406
}
450407
}
451408

src/Widgets/WorkspaceClone.vala

Lines changed: 7 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -365,46 +365,13 @@ namespace Gala {
365365

366366
var scale = (float)(monitor.height - InternalUtils.scale_to_int (TOP_OFFSET + BOTTOM_OFFSET, scale_factor)) / monitor.height;
367367
var pivot_y = InternalUtils.scale_to_int (TOP_OFFSET, scale_factor) / (monitor.height - monitor.height * scale);
368+
background.set_pivot_point (0.5f, pivot_y);
368369

369370
update_size (monitor);
370371

371-
GestureTracker.OnBegin on_animation_begin = () => {
372-
x = initial_x;
373-
background.set_pivot_point (0.5f, pivot_y);
374-
};
375-
376-
GestureTracker.OnUpdate on_animation_update = (percentage) => {
377-
var x = GestureTracker.animation_value (initial_x, target_x, percentage);
378-
set_x (x);
379-
380-
var update_scale = (double) GestureTracker.animation_value (1.0f, (float)scale, percentage);
381-
background.set_scale (update_scale, update_scale);
382-
};
383-
384-
GestureTracker.OnEnd on_animation_end = (percentage, cancel_action) => {
385-
if (cancel_action) {
386-
return;
387-
}
388-
389-
save_easing_state ();
390-
set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
391-
set_easing_duration (wm.enable_animations ? MultitaskingView.ANIMATION_DURATION : 0);
392-
set_x (target_x);
393-
restore_easing_state ();
394-
395-
background.save_easing_state ();
396-
background.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
397-
background.set_easing_duration (wm.enable_animations ? MultitaskingView.ANIMATION_DURATION : 0);
398-
background.set_scale (scale, scale);
399-
background.restore_easing_state ();
400-
};
401-
402-
if (!with_gesture || !wm.enable_animations) {
403-
on_animation_begin (0);
404-
on_animation_end (1, false, 0);
405-
} else {
406-
gesture_tracker.connect_handlers ((owned) on_animation_begin, (owned) on_animation_update, (owned)on_animation_end);
407-
}
372+
new PropertyGestureTransition (this, gesture_tracker, "x", initial_x, target_x, with_gesture);
373+
new PropertyGestureTransition (background, gesture_tracker, "scale-x", 1.0f, (float) scale, with_gesture);
374+
new PropertyGestureTransition (background, gesture_tracker, "scale-y", 1.0f, (float) scale, with_gesture);
408375

409376
#if HAS_MUTTER45
410377
Mtk.Rectangle area = {
@@ -448,38 +415,9 @@ namespace Gala {
448415
double initial_scale_x, initial_scale_y;
449416
background.get_scale (out initial_scale_x, out initial_scale_y);
450417

451-
GestureTracker.OnUpdate on_animation_update = (percentage) => {
452-
var x = GestureTracker.animation_value (initial_x, target_x, percentage);
453-
set_x (x);
454-
455-
double scale_x = (double) GestureTracker.animation_value ((float) initial_scale_x, 1.0f, percentage);
456-
double scale_y = (double) GestureTracker.animation_value ((float) initial_scale_y, 1.0f, percentage);
457-
background.set_scale (scale_x, scale_y);
458-
};
459-
460-
GestureTracker.OnEnd on_animation_end = (percentage, cancel_action) => {
461-
if (cancel_action) {
462-
return;
463-
}
464-
465-
save_easing_state ();
466-
set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
467-
set_easing_duration (wm.enable_animations ? MultitaskingView.ANIMATION_DURATION : 0);
468-
set_x (target_x);
469-
restore_easing_state ();
470-
471-
background.save_easing_state ();
472-
background.set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
473-
background.set_easing_duration (wm.enable_animations ? MultitaskingView.ANIMATION_DURATION : 0);
474-
background.set_scale (1, 1);
475-
background.restore_easing_state ();
476-
};
477-
478-
if (!with_gesture || !wm.enable_animations) {
479-
on_animation_end (1, false, 0);
480-
} else {
481-
gesture_tracker.connect_handlers (null, (owned) on_animation_update, (owned) on_animation_end);
482-
}
418+
new PropertyGestureTransition (this, gesture_tracker, "x", initial_x, target_x, with_gesture);
419+
new PropertyGestureTransition (background, gesture_tracker, "scale-x", initial_scale_x, 1.0f, with_gesture);
420+
new PropertyGestureTransition (background, gesture_tracker, "scale-y", initial_scale_y, 1.0f, with_gesture);
483421

484422
window_container.close (with_gesture, is_cancel_animation);
485423
}

0 commit comments

Comments
 (0)