Skip to content

Commit 03553b7

Browse files
committed
Readd size animation
1 parent d1d9da3 commit 03553b7

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

src/ItemManager.vala

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
public Launcher? added_launcher { get; set; default = null; }
1515

16+
private Adw.TimedAnimation resize_animation;
1617
private GLib.GenericArray<Launcher> launchers; // Only used to keep track of launcher indices
1718
private BackgroundItem background_item;
1819
private GLib.GenericArray<WorkspaceIconGroup> icon_groups; // Only used to keep track of icon group indices
@@ -42,6 +43,15 @@
4243

4344
overflow = VISIBLE;
4445

46+
resize_animation = new Adw.TimedAnimation (
47+
this, 0, 0, 0,
48+
new Adw.CallbackAnimationTarget ((val) => {
49+
width_request = (int) val;
50+
})
51+
);
52+
53+
resize_animation.done.connect (() => width_request = -1); //Reset otherwise we stay to big when the launcher icon size changes
54+
4555
settings.changed.connect ((key) => {
4656
if (key == "icon-size") {
4757
reposition_items ();
@@ -221,9 +231,18 @@
221231
icon_groups.add ((WorkspaceIconGroup) item);
222232
}
223233

224-
reposition_items ();
234+
ulong reveal_cb = 0;
235+
reveal_cb = resize_animation.done.connect (() => {
236+
resize_animation.disconnect (reveal_cb);
237+
reposition_items ();
238+
item.set_revealed (true);
239+
});
225240

226-
item.set_revealed (true);
241+
resize_animation.easing = EASE_OUT_BACK;
242+
resize_animation.duration = Granite.TRANSITION_DURATION_OPEN;
243+
resize_animation.value_from = get_width ();
244+
resize_animation.value_to = launchers.length * get_launcher_size ();
245+
resize_animation.play ();
227246
}
228247

229248
private void remove_item (BaseItem item) {
@@ -239,9 +258,18 @@
239258
}
240259

241260
private void remove_finish (BaseItem item) {
261+
// Temporarily set the width request to avoid flicker until the animation calls the callback for the first time
262+
width_request = get_width ();
263+
242264
remove (item);
243265
reposition_items ();
244266

267+
resize_animation.easing = EASE_IN_OUT_QUAD;
268+
resize_animation.duration = Granite.TRANSITION_DURATION_CLOSE;
269+
resize_animation.value_from = get_width ();
270+
resize_animation.value_to = launchers.length * get_launcher_size ();
271+
resize_animation.play ();
272+
245273
item.revealed_done.disconnect (remove_finish);
246274
item.cleanup ();
247275
}

0 commit comments

Comments
 (0)