|
13 | 13 |
|
14 | 14 | public Launcher? added_launcher { get; set; default = null; } |
15 | 15 |
|
| 16 | + private Adw.TimedAnimation resize_animation; |
16 | 17 | private GLib.GenericArray<Launcher> launchers; // Only used to keep track of launcher indices |
17 | 18 | private BackgroundItem background_item; |
18 | 19 | private GLib.GenericArray<WorkspaceIconGroup> icon_groups; // Only used to keep track of icon group indices |
|
42 | 43 |
|
43 | 44 | overflow = VISIBLE; |
44 | 45 |
|
| 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 | + |
45 | 55 | settings.changed.connect ((key) => { |
46 | 56 | if (key == "icon-size") { |
47 | 57 | reposition_items (); |
|
221 | 231 | icon_groups.add ((WorkspaceIconGroup) item); |
222 | 232 | } |
223 | 233 |
|
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 | + }); |
225 | 240 |
|
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 (); |
227 | 246 | } |
228 | 247 |
|
229 | 248 | private void remove_item (BaseItem item) { |
|
239 | 258 | } |
240 | 259 |
|
241 | 260 | 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 | + |
242 | 264 | remove (item); |
243 | 265 | reposition_items (); |
244 | 266 |
|
| 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 | + |
245 | 273 | item.revealed_done.disconnect (remove_finish); |
246 | 274 | item.cleanup (); |
247 | 275 | } |
|
0 commit comments