-
-
Notifications
You must be signed in to change notification settings - Fork 76
/
WorkspaceInsertThumb.vala
112 lines (90 loc) · 3.54 KB
/
WorkspaceInsertThumb.vala
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
/*
* Copyright 2014 Tom Beckmann
* Copyright 2023 elementary, Inc. (https://elementary.io)
* SPDX-License-Identifier: GPL-3.0-or-later
*/
public class Gala.WorkspaceInsertThumb : Clutter.Actor {
public const int EXPAND_DELAY = 300;
public int workspace_index { get; construct set; }
public bool expanded { get; set; default = false; }
public int delay { get; set; default = EXPAND_DELAY; }
uint expand_timeout = 0;
public WorkspaceInsertThumb (int workspace_index) {
Object (workspace_index: workspace_index);
var scale = InternalUtils.get_ui_scaling_factor ();
width = IconGroupContainer.SPACING * scale;
height = IconGroupContainer.GROUP_WIDTH * scale;
y = (IconGroupContainer.GROUP_WIDTH * scale - IconGroupContainer.SPACING * scale) / 2;
opacity = 0;
set_pivot_point (0.5f, 0.5f);
reactive = true;
x_align = Clutter.ActorAlign.CENTER;
var drop = new DragDropAction (DragDropActionType.DESTINATION, "multitaskingview-window");
drop.crossed.connect ((target, hovered) => {
if (!Meta.Prefs.get_dynamic_workspaces () && (target != null && target is WindowClone)) {
return;
}
if (!hovered) {
if (expand_timeout != 0) {
Source.remove (expand_timeout);
expand_timeout = 0;
}
transform (false);
} else {
expand_timeout = Timeout.add (delay, expand);
}
});
add_action (drop);
}
public void set_window_thumb (Meta.Window window) {
destroy_all_children ();
var scale = InternalUtils.get_ui_scaling_factor ();
var icon = new WindowIcon (window, IconGroupContainer.GROUP_WIDTH, scale) {
x = IconGroupContainer.SPACING,
x_align = Clutter.ActorAlign.CENTER
};
add_child (icon);
}
private bool expand () {
expand_timeout = 0;
transform (true);
return Source.REMOVE;
}
private new void transform (bool expand) {
save_easing_state ();
set_easing_mode (Clutter.AnimationMode.EASE_OUT_QUAD);
set_easing_duration (200);
var scale = InternalUtils.get_ui_scaling_factor ();
if (!expand) {
remove_transition ("pulse");
opacity = 0;
width = IconGroupContainer.SPACING * scale;
expanded = false;
} else {
add_pulse_animation ();
opacity = 200;
width = IconGroupContainer.GROUP_WIDTH * scale + IconGroupContainer.SPACING * 2;
expanded = true;
}
restore_easing_state ();
}
private void add_pulse_animation () {
var transition = new Clutter.TransitionGroup () {
duration = 800,
auto_reverse = true,
repeat_count = -1,
progress_mode = Clutter.AnimationMode.LINEAR
};
var scale_x_transition = new Clutter.PropertyTransition ("scale-x");
scale_x_transition.set_from_value (0.8);
scale_x_transition.set_to_value (1.1);
scale_x_transition.auto_reverse = true;
var scale_y_transition = new Clutter.PropertyTransition ("scale-y");
scale_y_transition.set_from_value (0.8);
scale_y_transition.set_to_value (1.1);
scale_y_transition.auto_reverse = true;
transition.add_transition (scale_x_transition);
transition.add_transition (scale_y_transition);
add_transition ("pulse", transition);
}
}