Merge lp:~unity-team/unity/unity.sprint-fixes into lp:unity
- unity.sprint-fixes
- Merge into trunk
Proposed by
Gord Allott
Status: | Merged |
---|---|
Merged at revision: | 392 |
Proposed branch: | lp:~unity-team/unity/unity.sprint-fixes |
Merge into: | lp:unity |
Diff against target: |
2485 lines (+955/-886) 17 files modified
targets/mutter/expose-manager.vala (+37/-79) targets/mutter/plugin.vala (+10/-33) targets/mutter/spaces-manager.vala (+68/-2) tests/unit/test-launcher.vala (+0/-3) unity-private/Makefile.am (+0/-1) unity-private/launcher/application-controller.vala (+46/-128) unity-private/launcher/launcher-child.vala (+0/-571) unity-private/launcher/launcher.vala (+2/-1) unity-private/launcher/quicklist-controller.vala (+8/-1) unity-private/launcher/scroller-controller.vala (+73/-40) unity-private/launcher/scroller-model.vala (+1/-0) unity-private/launcher/scroller-view.vala (+40/-10) unity-private/launcher/scrollerchild-controller.vala (+109/-7) unity-private/launcher/scrollerchild.vala (+548/-7) unity/drag-controller.vala (+3/-1) unity/drag-view.vala (+2/-1) unity/icon-postprocessor.vala (+8/-1) |
To merge this branch: | bzr merge lp:~unity-team/unity/unity.sprint-fixes |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Jason Smith (community) | Approve | ||
Review via email: mp+30669@code.launchpad.net |
This proposal supersedes a proposal from 2010-07-22.
Commit message
Description of the change
bunch of fixes from the sprint
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | === modified file 'targets/mutter/expose-manager.vala' | |||
2 | --- targets/mutter/expose-manager.vala 2010-07-19 09:12:30 +0000 | |||
3 | +++ targets/mutter/expose-manager.vala 2010-07-22 16:19:42 +0000 | |||
4 | @@ -25,6 +25,8 @@ | |||
5 | 25 | private Clutter.Clone clone; | 25 | private Clutter.Clone clone; |
6 | 26 | private Clutter.Actor darken_box; | 26 | private Clutter.Actor darken_box; |
7 | 27 | private bool hovered; | 27 | private bool hovered; |
8 | 28 | |||
9 | 29 | public bool fade_on_close { get; set; } | ||
10 | 28 | 30 | ||
11 | 29 | public unowned Clutter.Actor source { get; private set; } | 31 | public unowned Clutter.Actor source { get; private set; } |
12 | 30 | 32 | ||
13 | @@ -48,7 +50,7 @@ | |||
14 | 48 | unhovered_opacity = 255; | 50 | unhovered_opacity = 255; |
15 | 49 | 51 | ||
16 | 50 | this.source = source; | 52 | this.source = source; |
18 | 51 | 53 | ||
19 | 52 | if (source is Mutter.Window) | 54 | if (source is Mutter.Window) |
20 | 53 | clone = new Clutter.Clone ((source as Mutter.Window).get_texture ()); | 55 | clone = new Clutter.Clone ((source as Mutter.Window).get_texture ()); |
21 | 54 | else | 56 | else |
22 | @@ -90,6 +92,33 @@ | |||
23 | 90 | darken_box.opacity = darken; | 92 | darken_box.opacity = darken; |
24 | 91 | return false; | 93 | return false; |
25 | 92 | } | 94 | } |
26 | 95 | |||
27 | 96 | public void restore_window_position (int active_workspace) | ||
28 | 97 | { | ||
29 | 98 | set_anchor_point_from_gravity (Clutter.Gravity.NORTH_WEST); | ||
30 | 99 | Clutter.Actor window = source; | ||
31 | 100 | |||
32 | 101 | uint8 opacity = 0; | ||
33 | 102 | if (!fade_on_close || (window is Mutter.Window && (window as Mutter.Window).showing_on_its_workspace () && | ||
34 | 103 | (window as Mutter.Window).get_workspace () == active_workspace)) | ||
35 | 104 | opacity = 255; | ||
36 | 105 | |||
37 | 106 | |||
38 | 107 | set ("scale-gravity", Clutter.Gravity.CENTER); | ||
39 | 108 | Clutter.Animation anim = animate (Clutter.AnimationMode.EASE_IN_OUT_SINE, 250, | ||
40 | 109 | "scale-x", 1f, | ||
41 | 110 | "scale-y", 1f, | ||
42 | 111 | "opacity", opacity, | ||
43 | 112 | "x", window.x, | ||
44 | 113 | "y", window.y); | ||
45 | 114 | |||
46 | 115 | window.opacity = 0; | ||
47 | 116 | |||
48 | 117 | anim.completed.connect (() => { | ||
49 | 118 | destroy (); | ||
50 | 119 | window.opacity = 255; | ||
51 | 120 | }); | ||
52 | 121 | } | ||
53 | 93 | } | 122 | } |
54 | 94 | 123 | ||
55 | 95 | public class ExposeManager : Object | 124 | public class ExposeManager : Object |
56 | @@ -117,7 +146,6 @@ | |||
57 | 117 | 146 | ||
58 | 118 | private ExposeClone? last_selected_clone = null; | 147 | private ExposeClone? last_selected_clone = null; |
59 | 119 | 148 | ||
60 | 120 | private bool menu_in_hover_close_state = false; | ||
61 | 121 | 149 | ||
62 | 122 | public ExposeManager (Plugin plugin, Launcher.Launcher launcher) | 150 | public ExposeManager (Plugin plugin, Launcher.Launcher launcher) |
63 | 123 | { | 151 | { |
64 | @@ -137,12 +165,6 @@ | |||
65 | 137 | 165 | ||
66 | 138 | public void start_expose (SList<Clutter.Actor> windows) | 166 | public void start_expose (SList<Clutter.Actor> windows) |
67 | 139 | { | 167 | { |
68 | 140 | var controller = Launcher.QuicklistController.get_current_menu (); | ||
69 | 141 | if (controller.is_menu_open ()) | ||
70 | 142 | { | ||
71 | 143 | controller.get_view ().destroy.connect (this.end_expose); | ||
72 | 144 | this.menu_in_hover_close_state = controller.get_view ().get_close_on_leave (); | ||
73 | 145 | } | ||
74 | 146 | exposed_windows = new List<ExposeClone> (); | 168 | exposed_windows = new List<ExposeClone> (); |
75 | 147 | 169 | ||
76 | 148 | if (expose_group != null) | 170 | if (expose_group != null) |
77 | @@ -164,6 +186,7 @@ | |||
78 | 164 | continue; | 186 | continue; |
79 | 165 | 187 | ||
80 | 166 | ExposeClone clone = new ExposeClone (actor); | 188 | ExposeClone clone = new ExposeClone (actor); |
81 | 189 | clone.fade_on_close = true; | ||
82 | 167 | clone.set_position (actor.x, actor.y); | 190 | clone.set_position (actor.x, actor.y); |
83 | 168 | clone.set_size (actor.width, actor.height); | 191 | clone.set_size (actor.width, actor.height); |
84 | 169 | exposed_windows.append (clone); | 192 | exposed_windows.append (clone); |
85 | @@ -175,26 +198,6 @@ | |||
86 | 175 | clone.unhovered_opacity = unhovered_opacity; | 198 | clone.unhovered_opacity = unhovered_opacity; |
87 | 176 | clone.opacity = unhovered_opacity; | 199 | clone.opacity = unhovered_opacity; |
88 | 177 | clone.darken = darken; | 200 | clone.darken = darken; |
89 | 178 | |||
90 | 179 | clone.enter_event.connect (() => { | ||
91 | 180 | var ql_controller = Launcher.QuicklistController.get_current_menu (); | ||
92 | 181 | if (ql_controller.state == Launcher.QuicklistControllerState.MENU | ||
93 | 182 | && this.menu_in_hover_close_state) | ||
94 | 183 | { | ||
95 | 184 | ql_controller.get_view ().set_close_on_leave (false); | ||
96 | 185 | } | ||
97 | 186 | return false; | ||
98 | 187 | }); | ||
99 | 188 | |||
100 | 189 | clone.leave_event.connect (() => { | ||
101 | 190 | var ql_controller = Launcher.QuicklistController.get_current_menu (); | ||
102 | 191 | if (ql_controller.state == Launcher.QuicklistControllerState.MENU | ||
103 | 192 | && this.menu_in_hover_close_state) | ||
104 | 193 | { | ||
105 | 194 | ql_controller.get_view ().set_close_on_leave (true); | ||
106 | 195 | } | ||
107 | 196 | return false; | ||
108 | 197 | }); | ||
109 | 198 | } | 201 | } |
110 | 199 | 202 | ||
111 | 200 | unowned GLib.List<Mutter.Window> mutter_windows = owner.plugin.get_windows (); | 203 | unowned GLib.List<Mutter.Window> mutter_windows = owner.plugin.get_windows (); |
112 | @@ -211,7 +214,7 @@ | |||
113 | 211 | if (coverflow) | 214 | if (coverflow) |
114 | 212 | position_windows_coverflow (exposed_windows, exposed_windows.nth_data (coverflow_index)); | 215 | position_windows_coverflow (exposed_windows, exposed_windows.nth_data (coverflow_index)); |
115 | 213 | else | 216 | else |
117 | 214 | position_windows_on_grid (exposed_windows); | 217 | position_windows_on_grid (exposed_windows, top_buffer, left_buffer, right_buffer, bottom_buffer); |
118 | 215 | 218 | ||
119 | 216 | expose_showing = true; | 219 | expose_showing = true; |
120 | 217 | 220 | ||
121 | @@ -223,13 +226,6 @@ | |||
122 | 223 | { | 226 | { |
123 | 224 | if (!expose_showing) | 227 | if (!expose_showing) |
124 | 225 | return; | 228 | return; |
125 | 226 | |||
126 | 227 | var controller = Launcher.QuicklistController.get_current_menu (); | ||
127 | 228 | if (controller.is_menu_open ()) | ||
128 | 229 | { | ||
129 | 230 | controller.get_view ().destroy.disconnect (this.end_expose); | ||
130 | 231 | controller.state = Launcher.QuicklistControllerState.CLOSED; | ||
131 | 232 | } | ||
132 | 233 | 229 | ||
133 | 234 | unowned GLib.List<Mutter.Window> mutter_windows = owner.plugin.get_windows (); | 230 | unowned GLib.List<Mutter.Window> mutter_windows = owner.plugin.get_windows (); |
134 | 235 | foreach (Mutter.Window window in mutter_windows) | 231 | foreach (Mutter.Window window in mutter_windows) |
135 | @@ -249,8 +245,8 @@ | |||
136 | 249 | window.reactive = true; | 245 | window.reactive = true; |
137 | 250 | } | 246 | } |
138 | 251 | 247 | ||
141 | 252 | foreach (Clutter.Actor actor in exposed_windows) | 248 | foreach (ExposeClone actor in exposed_windows) |
142 | 253 | restore_window_position (actor); | 249 | actor.restore_window_position (Mutter.MetaScreen.get_active_workspace_index (owner.plugin.get_screen ())); |
143 | 254 | 250 | ||
144 | 255 | if (this.last_selected_clone is ExposeClone && | 251 | if (this.last_selected_clone is ExposeClone && |
145 | 256 | this.last_selected_clone.source is Mutter.Window) | 252 | this.last_selected_clone.source is Mutter.Window) |
146 | @@ -355,7 +351,7 @@ | |||
147 | 355 | return 0; | 351 | return 0; |
148 | 356 | } | 352 | } |
149 | 357 | 353 | ||
151 | 358 | void position_windows_on_grid (List<Clutter.Actor> _windows) | 354 | public void position_windows_on_grid (List<Clutter.Actor> _windows, int top_buffer, int left_buffer, int right_buffer, int bottom_buffer) |
152 | 359 | { | 355 | { |
153 | 360 | List<Clutter.Actor> windows = _windows.copy (); | 356 | List<Clutter.Actor> windows = _windows.copy (); |
154 | 361 | windows.sort ((CompareFunc) direct_comparison); | 357 | windows.sort ((CompareFunc) direct_comparison); |
155 | @@ -426,34 +422,6 @@ | |||
156 | 426 | } | 422 | } |
157 | 427 | } | 423 | } |
158 | 428 | 424 | ||
159 | 429 | private void restore_window_position (Clutter.Actor actor) | ||
160 | 430 | { | ||
161 | 431 | if (!(actor is ExposeClone)) | ||
162 | 432 | return; | ||
163 | 433 | |||
164 | 434 | actor.set_anchor_point_from_gravity (Clutter.Gravity.NORTH_WEST); | ||
165 | 435 | Clutter.Actor window = (actor as ExposeClone).source; | ||
166 | 436 | |||
167 | 437 | uint8 opacity = 0; | ||
168 | 438 | if ((window as Mutter.Window).showing_on_its_workspace () && | ||
169 | 439 | (window as Mutter.Window).get_workspace () == Mutter.MetaScreen.get_active_workspace_index (owner.plugin.get_screen ())) | ||
170 | 440 | opacity = 255; | ||
171 | 441 | |||
172 | 442 | actor.set ("scale-gravity", Clutter.Gravity.CENTER); | ||
173 | 443 | Clutter.Animation anim = actor.animate (Clutter.AnimationMode.EASE_IN_OUT_SINE, 250, | ||
174 | 444 | "scale-x", 1f, | ||
175 | 445 | "scale-y", 1f, | ||
176 | 446 | "opacity", opacity, | ||
177 | 447 | "x", window.x, | ||
178 | 448 | "y", window.y); | ||
179 | 449 | |||
180 | 450 | window.opacity = 0; | ||
181 | 451 | |||
182 | 452 | anim.completed.connect (() => { | ||
183 | 453 | actor.destroy (); | ||
184 | 454 | window.opacity = 255; | ||
185 | 455 | }); | ||
186 | 456 | } | ||
187 | 457 | 425 | ||
188 | 458 | void handle_event_coverflow (Clutter.Event event) | 426 | void handle_event_coverflow (Clutter.Event event) |
189 | 459 | { | 427 | { |
190 | @@ -524,23 +492,13 @@ | |||
191 | 524 | if (event.type == Clutter.EventType.ENTER || event.type == Clutter.EventType.LEAVE) | 492 | if (event.type == Clutter.EventType.ENTER || event.type == Clutter.EventType.LEAVE) |
192 | 525 | return false; | 493 | return false; |
193 | 526 | 494 | ||
194 | 527 | bool event_over_menu = false; | ||
195 | 528 | 495 | ||
196 | 529 | float x, y; | 496 | float x, y; |
197 | 530 | event.get_coords (out x, out y); | 497 | event.get_coords (out x, out y); |
198 | 531 | 498 | ||
199 | 532 | unowned Clutter.Actor actor = this.stage.get_actor_at_pos (Clutter.PickMode.REACTIVE, (int) x, (int) y); | 499 | unowned Clutter.Actor actor = this.stage.get_actor_at_pos (Clutter.PickMode.REACTIVE, (int) x, (int) y); |
200 | 533 | 500 | ||
211 | 534 | Clutter.Actor? menu = null; | 501 | if (event.type == Clutter.EventType.BUTTON_PRESS) |
202 | 535 | if (Unity.Launcher.QuicklistController.get_current_menu ().is_menu_open ()) | ||
203 | 536 | menu = Unity.Launcher.QuicklistController.get_current_menu ().get_view (); | ||
204 | 537 | if (menu != null) | ||
205 | 538 | { | ||
206 | 539 | if (x > menu.x && x < menu.x + menu.width && y > menu.y && y < menu.y + menu.height) | ||
207 | 540 | event_over_menu = true; | ||
208 | 541 | } | ||
209 | 542 | |||
210 | 543 | if (event.type == Clutter.EventType.BUTTON_PRESS && !event_over_menu) | ||
212 | 544 | pick_window (event, actor); | 502 | pick_window (event, actor); |
213 | 545 | 503 | ||
214 | 546 | if (coverflow) | 504 | if (coverflow) |
215 | @@ -548,7 +506,7 @@ | |||
216 | 548 | else | 506 | else |
217 | 549 | handle_event_expose (event, actor); | 507 | handle_event_expose (event, actor); |
218 | 550 | 508 | ||
220 | 551 | return !event_over_menu; | 509 | return true; |
221 | 552 | } | 510 | } |
222 | 553 | } | 511 | } |
223 | 554 | } | 512 | } |
224 | 555 | 513 | ||
225 | === modified file 'targets/mutter/plugin.vala' | |||
226 | --- targets/mutter/plugin.vala 2010-07-16 08:43:18 +0000 | |||
227 | +++ targets/mutter/plugin.vala 2010-07-22 16:19:42 +0000 | |||
228 | @@ -107,6 +107,8 @@ | |||
229 | 107 | set { _plugin = value; Idle.add (real_construct); } | 107 | set { _plugin = value; Idle.add (real_construct); } |
230 | 108 | } | 108 | } |
231 | 109 | 109 | ||
232 | 110 | public ExposeManager expose_manager { get; private set; } | ||
233 | 111 | |||
234 | 110 | public bool menus_swallow_events { get { return false; } } | 112 | public bool menus_swallow_events { get { return false; } } |
235 | 111 | 113 | ||
236 | 112 | public bool expose_showing { get { return expose_manager.expose_showing; } } | 114 | public bool expose_showing { get { return expose_manager.expose_showing; } } |
237 | @@ -121,7 +123,6 @@ | |||
238 | 121 | 123 | ||
239 | 122 | /* Unity Components */ | 124 | /* Unity Components */ |
240 | 123 | private Background background; | 125 | private Background background; |
241 | 124 | private ExposeManager expose_manager; | ||
242 | 125 | private SpacesManager spaces_manager; | 126 | private SpacesManager spaces_manager; |
243 | 126 | private Launcher.Launcher launcher; | 127 | private Launcher.Launcher launcher; |
244 | 127 | private Places.Controller places_controller; | 128 | private Places.Controller places_controller; |
245 | @@ -243,6 +244,13 @@ | |||
246 | 243 | this.spaces_manager = new SpacesManager (this); | 244 | this.spaces_manager = new SpacesManager (this); |
247 | 244 | this.spaces_manager.set_padding (50, 50, 125, 50); | 245 | this.spaces_manager.set_padding (50, 50, 125, 50); |
248 | 245 | 246 | ||
249 | 247 | this.launcher.model.add (spaces_manager.button); | ||
250 | 248 | this.launcher.model.order_changed.connect (() => { | ||
251 | 249 | var index = launcher.model.index_of (spaces_manager.button); | ||
252 | 250 | if (index < launcher.model.size) | ||
253 | 251 | launcher.model.move (spaces_manager.button, launcher.model.size -1); | ||
254 | 252 | }); | ||
255 | 253 | |||
256 | 246 | this.expose_manager = new ExposeManager (this, launcher); | 254 | this.expose_manager = new ExposeManager (this, launcher); |
257 | 247 | this.expose_manager.hovered_opacity = 255; | 255 | this.expose_manager.hovered_opacity = 255; |
258 | 248 | this.expose_manager.unhovered_opacity = 255; | 256 | this.expose_manager.unhovered_opacity = 255; |
259 | @@ -308,7 +316,6 @@ | |||
260 | 308 | 316 | ||
261 | 309 | private void on_focus_window_fullscreen_changed () | 317 | private void on_focus_window_fullscreen_changed () |
262 | 310 | { | 318 | { |
263 | 311 | warning ("FOCUS WINDOW FULLSCREEN CHANGED"); | ||
264 | 312 | check_fullscreen_obstruction (); | 319 | check_fullscreen_obstruction (); |
265 | 313 | } | 320 | } |
266 | 314 | 321 | ||
267 | @@ -466,32 +473,6 @@ | |||
268 | 466 | /* | 473 | /* |
269 | 467 | * SHELL IMPLEMENTATION | 474 | * SHELL IMPLEMENTATION |
270 | 468 | */ | 475 | */ |
271 | 469 | |||
272 | 470 | /* | ||
273 | 471 | public void show_window_picker () | ||
274 | 472 | { | ||
275 | 473 | this.show_unity (); | ||
276 | 474 | return; | ||
277 | 475 | } | ||
278 | 476 | |||
279 | 477 | if (expose_manager.expose_showing == true) | ||
280 | 478 | { | ||
281 | 479 | this.dexpose_windows (); | ||
282 | 480 | return; | ||
283 | 481 | } | ||
284 | 482 | |||
285 | 483 | GLib.SList <Clutter.Actor> windows = null; | ||
286 | 484 | |||
287 | 485 | unowned GLib.List<Mutter.Window> mutter_windows = this.plugin.get_windows (); | ||
288 | 486 | foreach (Mutter.Window window in mutter_windows) | ||
289 | 487 | { | ||
290 | 488 | windows.append (window as Clutter.Actor); | ||
291 | 489 | } | ||
292 | 490 | |||
293 | 491 | this.expose_windows (windows, 80); | ||
294 | 492 | } | ||
295 | 493 | */ | ||
296 | 494 | |||
297 | 495 | public Clutter.Stage get_stage () | 476 | public Clutter.Stage get_stage () |
298 | 496 | { | 477 | { |
299 | 497 | return this.stage; | 478 | return this.stage; |
300 | @@ -539,7 +520,7 @@ | |||
301 | 539 | 520 | ||
302 | 540 | public void stop_expose () | 521 | public void stop_expose () |
303 | 541 | { | 522 | { |
305 | 542 | dexpose_windows (); | 523 | expose_manager.end_expose (); |
306 | 543 | } | 524 | } |
307 | 544 | 525 | ||
308 | 545 | public void show_window (uint32 xid) | 526 | public void show_window (uint32 xid) |
309 | @@ -585,10 +566,6 @@ | |||
310 | 585 | expose_manager.start_expose (windows); | 566 | expose_manager.start_expose (windows); |
311 | 586 | } | 567 | } |
312 | 587 | 568 | ||
313 | 588 | public void dexpose_windows () | ||
314 | 589 | { | ||
315 | 590 | expose_manager.end_expose (); | ||
316 | 591 | } | ||
317 | 592 | 569 | ||
318 | 593 | public void hide_unity () | 570 | public void hide_unity () |
319 | 594 | { | 571 | { |
320 | 595 | 572 | ||
321 | === modified file 'targets/mutter/spaces-manager.vala' | |||
322 | --- targets/mutter/spaces-manager.vala 2010-06-21 21:44:09 +0000 | |||
323 | +++ targets/mutter/spaces-manager.vala 2010-07-22 16:19:42 +0000 | |||
324 | @@ -17,14 +17,52 @@ | |||
325 | 17 | * | 17 | * |
326 | 18 | */ | 18 | */ |
327 | 19 | 19 | ||
328 | 20 | using Unity.Launcher; | ||
329 | 21 | |||
330 | 20 | namespace Unity { | 22 | namespace Unity { |
331 | 21 | 23 | ||
332 | 24 | public class SpacesButtonController : ScrollerChildController | ||
333 | 25 | { | ||
334 | 26 | SpacesManager parent { get; set; } | ||
335 | 27 | |||
336 | 28 | public SpacesButtonController (SpacesManager _parent, ScrollerChild _child) | ||
337 | 29 | { | ||
338 | 30 | Object (child: _child); | ||
339 | 31 | this.parent = _parent; | ||
340 | 32 | |||
341 | 33 | name = "Workspace Overview"; | ||
342 | 34 | load_icon_from_icon_name ("workspace-switcher"); | ||
343 | 35 | } | ||
344 | 36 | |||
345 | 37 | construct | ||
346 | 38 | { | ||
347 | 39 | } | ||
348 | 40 | |||
349 | 41 | public override void activate () | ||
350 | 42 | { | ||
351 | 43 | parent.show_spaces_picker (); | ||
352 | 44 | } | ||
353 | 45 | } | ||
354 | 46 | |||
355 | 22 | public class SpacesManager : GLib.Object | 47 | public class SpacesManager : GLib.Object |
356 | 23 | { | 48 | { |
357 | 24 | Clutter.Actor background; | 49 | Clutter.Actor background; |
358 | 25 | List<Clutter.Actor> clones; | 50 | List<Clutter.Actor> clones; |
359 | 26 | Plugin plugin; | 51 | Plugin plugin; |
360 | 27 | unowned Mutter.MetaScreen screen; | 52 | unowned Mutter.MetaScreen screen; |
361 | 53 | ScrollerChild _button; | ||
362 | 54 | SpacesButtonController controller; | ||
363 | 55 | |||
364 | 56 | public ScrollerChild button { | ||
365 | 57 | get { | ||
366 | 58 | if (!(_button is ScrollerChild)) | ||
367 | 59 | { | ||
368 | 60 | _button = new ScrollerChild (); | ||
369 | 61 | controller = new SpacesButtonController (this, _button); | ||
370 | 62 | } | ||
371 | 63 | return _button; | ||
372 | 64 | } | ||
373 | 65 | } | ||
374 | 28 | 66 | ||
375 | 29 | public uint top_padding { get; set; } | 67 | public uint top_padding { get; set; } |
376 | 30 | public uint right_padding { get; set; } | 68 | public uint right_padding { get; set; } |
377 | @@ -114,17 +152,29 @@ | |||
378 | 114 | 152 | ||
379 | 115 | private Clutter.Actor workspace_clone (Mutter.MetaWorkspace workspace) { | 153 | private Clutter.Actor workspace_clone (Mutter.MetaWorkspace workspace) { |
380 | 116 | Clutter.Group wsp; | 154 | Clutter.Group wsp; |
382 | 117 | unowned GLib.List<Mutter.Window> windows = plugin.plugin.get_windows (); | 155 | GLib.List<weak Mutter.Window> windows = (GLib.List<weak Mutter.Window>) plugin.plugin.get_windows ().copy (); |
383 | 118 | 156 | ||
384 | 119 | wsp = new Clutter.Group (); | 157 | wsp = new Clutter.Group (); |
385 | 120 | 158 | ||
386 | 159 | List<Clutter.Actor> toplevel_windows = new List<Clutter.Actor> (); | ||
387 | 160 | |||
388 | 161 | int active_workspace = Mutter.MetaScreen.get_active_workspace_index (plugin.plugin.get_screen ()); | ||
389 | 162 | |||
390 | 163 | Clutter.Actor last = null, wspclone = null; | ||
391 | 164 | |||
392 | 121 | foreach (Mutter.Window window in windows) | 165 | foreach (Mutter.Window window in windows) |
393 | 122 | { | 166 | { |
394 | 123 | if (Mutter.MetaWindow.is_on_all_workspaces (window.get_meta_window ()) || | 167 | if (Mutter.MetaWindow.is_on_all_workspaces (window.get_meta_window ()) || |
395 | 124 | window.get_window_type () == Mutter.MetaCompWindowType.DESKTOP || | 168 | window.get_window_type () == Mutter.MetaCompWindowType.DESKTOP || |
396 | 125 | window.get_workspace () == Mutter.MetaWorkspace.index (workspace)) | 169 | window.get_workspace () == Mutter.MetaWorkspace.index (workspace)) |
397 | 126 | { | 170 | { |
399 | 127 | Clutter.Actor clone = new Clutter.Clone (window); | 171 | |
400 | 172 | if (window.get_window_type () == Mutter.MetaCompWindowType.DOCK) | ||
401 | 173 | continue; | ||
402 | 174 | |||
403 | 175 | ExposeClone clone = new ExposeClone (window); | ||
404 | 176 | clone.fade_on_close = false; | ||
405 | 177 | |||
406 | 128 | wsp.add_actor (clone); | 178 | wsp.add_actor (clone); |
407 | 129 | 179 | ||
408 | 130 | clone.set_size (window.width, window.height); | 180 | clone.set_size (window.width, window.height); |
409 | @@ -134,10 +184,21 @@ | |||
410 | 134 | 184 | ||
411 | 135 | if (window.get_window_type () == Mutter.MetaCompWindowType.DESKTOP) | 185 | if (window.get_window_type () == Mutter.MetaCompWindowType.DESKTOP) |
412 | 136 | { | 186 | { |
413 | 187 | wspclone = clone; | ||
414 | 137 | clone.lower_bottom (); | 188 | clone.lower_bottom (); |
415 | 138 | } | 189 | } |
416 | 190 | else | ||
417 | 191 | { | ||
418 | 192 | last = clone; | ||
419 | 193 | toplevel_windows.prepend (clone); | ||
420 | 194 | } | ||
421 | 139 | } | 195 | } |
422 | 140 | } | 196 | } |
423 | 197 | |||
424 | 198 | if (last != null && wspclone != null && active_workspace != Mutter.MetaWorkspace.index (workspace)) | ||
425 | 199 | last.raise (wspclone); | ||
426 | 200 | |||
427 | 201 | plugin.expose_manager.position_windows_on_grid (toplevel_windows, 50, 50, 50, 50); | ||
428 | 141 | 202 | ||
429 | 142 | return wsp; | 203 | return wsp; |
430 | 143 | } | 204 | } |
431 | @@ -170,6 +231,11 @@ | |||
432 | 170 | "scale-x", 1.0f, | 231 | "scale-x", 1.0f, |
433 | 171 | "scale-y", 1.0f); | 232 | "scale-y", 1.0f); |
434 | 172 | 233 | ||
435 | 234 | int active_workspace = Mutter.MetaScreen.get_active_workspace_index (plugin.plugin.get_screen ()); | ||
436 | 235 | foreach (Clutter.Actor actor in (clone as Clutter.Group).get_children ()) | ||
437 | 236 | if (actor is ExposeClone) | ||
438 | 237 | (actor as ExposeClone).restore_window_position (active_workspace); | ||
439 | 238 | |||
440 | 173 | anim.completed.connect (() => { | 239 | anim.completed.connect (() => { |
441 | 174 | clone.destroy (); | 240 | clone.destroy (); |
442 | 175 | if (background != null) | 241 | if (background != null) |
443 | 176 | 242 | ||
444 | === modified file 'tests/unit/test-launcher.vala' | |||
445 | --- tests/unit/test-launcher.vala 2010-07-15 13:19:02 +0000 | |||
446 | +++ tests/unit/test-launcher.vala 2010-07-22 16:19:42 +0000 | |||
447 | @@ -141,9 +141,6 @@ | |||
448 | 141 | 141 | ||
449 | 142 | public class TestScrollerChild : ScrollerChild | 142 | public class TestScrollerChild : ScrollerChild |
450 | 143 | { | 143 | { |
451 | 144 | public override void force_rotation_jump (float degrees) | ||
452 | 145 | { | ||
453 | 146 | } | ||
454 | 147 | } | 144 | } |
455 | 148 | 145 | ||
456 | 149 | public class LauncherSuite | 146 | public class LauncherSuite |
457 | 150 | 147 | ||
458 | === modified file 'unity-private/Makefile.am' | |||
459 | --- unity-private/Makefile.am 2010-07-16 08:43:18 +0000 | |||
460 | +++ unity-private/Makefile.am 2010-07-22 16:19:42 +0000 | |||
461 | @@ -105,7 +105,6 @@ | |||
462 | 105 | launcher_sources = \ | 105 | launcher_sources = \ |
463 | 106 | launcher/application-controller.vala \ | 106 | launcher/application-controller.vala \ |
464 | 107 | launcher/launcher.vala \ | 107 | launcher/launcher.vala \ |
465 | 108 | launcher/launcher-child.vala \ | ||
466 | 109 | launcher/quicklist-check-menu-item.vala \ | 108 | launcher/quicklist-check-menu-item.vala \ |
467 | 110 | launcher/quicklist-controller.vala \ | 109 | launcher/quicklist-controller.vala \ |
468 | 111 | launcher/quicklist-image-menu-item.vala \ | 110 | launcher/quicklist-image-menu-item.vala \ |
469 | 112 | 111 | ||
470 | === modified file 'unity-private/launcher/application-controller.vala' | |||
471 | --- unity-private/launcher/application-controller.vala 2010-07-22 09:06:10 +0000 | |||
472 | +++ unity-private/launcher/application-controller.vala 2010-07-22 16:19:42 +0000 | |||
473 | @@ -33,7 +33,6 @@ | |||
474 | 33 | 33 | ||
475 | 34 | private KeyFile desktop_keyfile; | 34 | private KeyFile desktop_keyfile; |
476 | 35 | private string icon_name; | 35 | private string icon_name; |
477 | 36 | private Unity.ThemeFilePath theme_file_path; | ||
478 | 37 | private Bamf.Application? app = null; | 36 | private Bamf.Application? app = null; |
479 | 38 | private Dbusmenu.Client menu_client; | 37 | private Dbusmenu.Client menu_client; |
480 | 39 | private Dbusmenu.Menuitem cached_menu; | 38 | private Dbusmenu.Menuitem cached_menu; |
481 | @@ -58,25 +57,16 @@ | |||
482 | 58 | 57 | ||
483 | 59 | construct | 58 | construct |
484 | 60 | { | 59 | { |
485 | 61 | theme_file_path = new Unity.ThemeFilePath (); | ||
486 | 62 | var favorites = Unity.Favorites.get_default (); | 60 | var favorites = Unity.Favorites.get_default (); |
487 | 63 | favorites.favorite_added.connect (on_favorite_added); | 61 | favorites.favorite_added.connect (on_favorite_added); |
488 | 64 | favorites.favorite_removed.connect (on_favorite_removed); | 62 | favorites.favorite_removed.connect (on_favorite_removed); |
489 | 65 | 63 | ||
492 | 66 | // we need to figure out if we are a favorite | 64 | // we need to figure out if we are a favoritem |
493 | 67 | is_favorite = true; | 65 | |
494 | 66 | is_favorite = is_sticky (); | ||
495 | 68 | child.pin_type = PinType.UNPINNED; | 67 | child.pin_type = PinType.UNPINNED; |
507 | 69 | foreach (string uid in favorites.get_favorites ()) | 68 | if (is_sticky ()) |
508 | 70 | { | 69 | child.pin_type = PinType.PINNED; |
498 | 71 | if (favorites.get_string (uid, "desktop_file") == desktop_file) | ||
499 | 72 | { | ||
500 | 73 | is_favorite = true; | ||
501 | 74 | child.pin_type = PinType.PINNED; | ||
502 | 75 | break; | ||
503 | 76 | } | ||
504 | 77 | } | ||
505 | 78 | |||
506 | 79 | notify["menu"].connect (on_notify_menu); | ||
509 | 80 | } | 70 | } |
510 | 81 | 71 | ||
511 | 82 | public override QuicklistController get_menu_controller () | 72 | public override QuicklistController get_menu_controller () |
512 | @@ -85,28 +75,19 @@ | |||
513 | 85 | return new_menu; | 75 | return new_menu; |
514 | 86 | } | 76 | } |
515 | 87 | 77 | ||
516 | 88 | private void on_notify_menu () | ||
517 | 89 | { | ||
518 | 90 | menu.notify["state"].connect (() => { | ||
519 | 91 | if (menu.state == QuicklistControllerState.MENU) | ||
520 | 92 | { | ||
521 | 93 | Unity.global_shell.expose_xids (app.get_xids ()); | ||
522 | 94 | } | ||
523 | 95 | else | ||
524 | 96 | { | ||
525 | 97 | Unity.global_shell.stop_expose (); | ||
526 | 98 | } | ||
527 | 99 | }); | ||
528 | 100 | } | ||
529 | 101 | |||
530 | 102 | public void set_sticky (bool is_sticky = true) | 78 | public void set_sticky (bool is_sticky = true) |
531 | 103 | { | 79 | { |
532 | 104 | if (desktop_file == "" || desktop_file == null) | 80 | if (desktop_file == "" || desktop_file == null) |
533 | 105 | return; | 81 | return; |
535 | 106 | //string uid = "app-" + Path.get_basename (desktop_file); | 82 | |
536 | 107 | var favorites = Unity.Favorites.get_default (); | 83 | var favorites = Unity.Favorites.get_default (); |
537 | 108 | 84 | ||
538 | 109 | string uid = favorites.find_uid_for_desktop_file (desktop_file); | 85 | string uid = favorites.find_uid_for_desktop_file (desktop_file); |
539 | 86 | if (uid == "" || uid == null) | ||
540 | 87 | { | ||
541 | 88 | var filepath = desktop_file.split ("/"); | ||
542 | 89 | uid = "app-" + filepath[filepath.length - 1]; | ||
543 | 90 | } | ||
544 | 110 | 91 | ||
545 | 111 | if (is_sticky) | 92 | if (is_sticky) |
546 | 112 | { | 93 | { |
547 | @@ -127,10 +108,10 @@ | |||
548 | 127 | 108 | ||
549 | 128 | var favorites = Unity.Favorites.get_default (); | 109 | var favorites = Unity.Favorites.get_default (); |
550 | 129 | string uid = favorites.find_uid_for_desktop_file (desktop_file); | 110 | string uid = favorites.find_uid_for_desktop_file (desktop_file); |
552 | 130 | if (uid != null && uid != "") | 111 | if (uid == null || uid == "") |
553 | 112 | return false; | ||
554 | 113 | else | ||
555 | 131 | return true; | 114 | return true; |
556 | 132 | else | ||
557 | 133 | return false; | ||
558 | 134 | } | 115 | } |
559 | 135 | 116 | ||
560 | 136 | public void close_windows () | 117 | public void close_windows () |
561 | @@ -188,15 +169,17 @@ | |||
562 | 188 | } | 169 | } |
563 | 189 | } | 170 | } |
564 | 190 | 171 | ||
565 | 172 | /* | ||
566 | 173 | private get_menu_for_client (ScrollerChildController.menu_cb callback, Dbusmenu.Client client) | ||
567 | 174 | { | ||
568 | 175 | |||
569 | 176 | } | ||
570 | 177 | */ | ||
571 | 178 | |||
572 | 191 | public override void get_menu_actions (ScrollerChildController.menu_cb callback) | 179 | public override void get_menu_actions (ScrollerChildController.menu_cb callback) |
573 | 192 | { | 180 | { |
574 | 193 | 181 | ||
575 | 194 | // first check to see if we have a cached client, if we do, just re-use that | 182 | // first check to see if we have a cached client, if we do, just re-use that |
576 | 195 | if (menu_client is Dbusmenu.Client && cached_menu is Dbusmenu.Menuitem) | ||
577 | 196 | { | ||
578 | 197 | callback (cached_menu); | ||
579 | 198 | } | ||
580 | 199 | |||
581 | 200 | // check for a menu from bamf | 183 | // check for a menu from bamf |
582 | 201 | if (app is Bamf.Application) | 184 | if (app is Bamf.Application) |
583 | 202 | { | 185 | { |
584 | @@ -279,13 +262,19 @@ | |||
585 | 279 | Dbusmenu.Menuitem root = new Dbusmenu.Menuitem (); | 262 | Dbusmenu.Menuitem root = new Dbusmenu.Menuitem (); |
586 | 280 | root.set_root (true); | 263 | root.set_root (true); |
587 | 281 | 264 | ||
589 | 282 | if (desktop_file != null) | 265 | if (desktop_file != null && desktop_file != "") |
590 | 283 | { | 266 | { |
591 | 284 | Dbusmenu.Menuitem pinning_item = new Dbusmenu.Menuitem (); | 267 | Dbusmenu.Menuitem pinning_item = new Dbusmenu.Menuitem (); |
596 | 285 | if (is_sticky ()) | 268 | if (is_sticky () && app is Bamf.Application) |
597 | 286 | pinning_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Remove from launcher")); | 269 | { |
598 | 287 | else | 270 | pinning_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Keep in Launcher")); |
599 | 288 | pinning_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Add to launcher")); | 271 | pinning_item.property_set (Dbusmenu.MENUITEM_PROP_TOGGLE_TYPE, Dbusmenu.MENUITEM_TOGGLE_CHECK); |
600 | 272 | pinning_item.property_set_int (Dbusmenu.MENUITEM_PROP_TOGGLE_STATE, Dbusmenu.MENUITEM_TOGGLE_STATE_CHECKED); | ||
601 | 273 | } | ||
602 | 274 | else if (is_sticky ()) | ||
603 | 275 | { | ||
604 | 276 | pinning_item.property_set (Dbusmenu.MENUITEM_PROP_LABEL, _("Remove from launcher")); | ||
605 | 277 | } | ||
606 | 289 | 278 | ||
607 | 290 | pinning_item.property_set_bool (Dbusmenu.MENUITEM_PROP_ENABLED, true); | 279 | pinning_item.property_set_bool (Dbusmenu.MENUITEM_PROP_ENABLED, true); |
608 | 291 | pinning_item.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, true); | 280 | pinning_item.property_set_bool (Dbusmenu.MENUITEM_PROP_VISIBLE, true); |
609 | @@ -317,6 +306,8 @@ | |||
610 | 317 | } | 306 | } |
611 | 318 | 307 | ||
612 | 319 | private static int order_app_windows (void* a, void* b) | 308 | private static int order_app_windows (void* a, void* b) |
613 | 309 | requires (a is Bamf.Window) | ||
614 | 310 | requires (b is Bamf.Window) | ||
615 | 320 | { | 311 | { |
616 | 321 | if ((b as Bamf.Window).last_active () > (a as Bamf.Window).last_active ()) | 312 | if ((b as Bamf.Window).last_active () > (a as Bamf.Window).last_active ()) |
617 | 322 | { | 313 | { |
618 | @@ -337,7 +328,12 @@ | |||
619 | 337 | 328 | ||
620 | 338 | if (app is Bamf.Application) | 329 | if (app is Bamf.Application) |
621 | 339 | { | 330 | { |
623 | 340 | if (app.is_running ()) | 331 | if (app.is_active ()) |
624 | 332 | { | ||
625 | 333 | Array<uint32> xids = app.get_xids (); | ||
626 | 334 | global_shell.expose_xids (xids); | ||
627 | 335 | } | ||
628 | 336 | else if (app.is_running ()) | ||
629 | 341 | { | 337 | { |
630 | 342 | unowned List<Bamf.Window> windows = app.get_windows (); | 338 | unowned List<Bamf.Window> windows = app.get_windows (); |
631 | 343 | windows.sort ((CompareFunc)order_app_windows); | 339 | windows.sort ((CompareFunc)order_app_windows); |
632 | @@ -375,7 +371,7 @@ | |||
633 | 375 | public void attach_application (Bamf.Application application) | 371 | public void attach_application (Bamf.Application application) |
634 | 376 | { | 372 | { |
635 | 377 | app = application; | 373 | app = application; |
637 | 378 | desktop_file = app.get_desktop_file (); | 374 | desktop_file = app.get_desktop_file ().dup (); |
638 | 379 | child.running = app.is_running (); | 375 | child.running = app.is_running (); |
639 | 380 | child.active = app.is_active (); | 376 | child.active = app.is_active (); |
640 | 381 | child.activating = false; | 377 | child.activating = false; |
641 | @@ -384,12 +380,15 @@ | |||
642 | 384 | app.active_changed.connect (on_app_active_changed); | 380 | app.active_changed.connect (on_app_active_changed); |
643 | 385 | app.closed.connect (detach_application); | 381 | app.closed.connect (detach_application); |
644 | 386 | app.urgent_changed.connect (on_app_urgant_changed); | 382 | app.urgent_changed.connect (on_app_urgant_changed); |
645 | 383 | app.user_visible_changed.connect ((value) => { | ||
646 | 384 | hide = !value; | ||
647 | 385 | }); | ||
648 | 387 | name = app.get_name (); | 386 | name = app.get_name (); |
649 | 388 | if (name == null || name == "") | 387 | if (name == null || name == "") |
650 | 389 | warning (@"Bamf returned null for app.get_name (): $desktop_file"); | 388 | warning (@"Bamf returned null for app.get_name (): $desktop_file"); |
651 | 390 | 389 | ||
652 | 391 | icon_name = app.get_icon (); | 390 | icon_name = app.get_icon (); |
654 | 392 | load_icon_from_icon_name (); | 391 | load_icon_from_icon_name (icon_name); |
655 | 393 | } | 392 | } |
656 | 394 | 393 | ||
657 | 395 | public void detach_application () | 394 | public void detach_application () |
658 | @@ -444,7 +443,7 @@ | |||
659 | 444 | try | 443 | try |
660 | 445 | { | 444 | { |
661 | 446 | icon_name = desktop_keyfile.get_string (KeyFileDesktop.GROUP, KeyFileDesktop.KEY_ICON); | 445 | icon_name = desktop_keyfile.get_string (KeyFileDesktop.GROUP, KeyFileDesktop.KEY_ICON); |
663 | 447 | load_icon_from_icon_name (); | 446 | load_icon_from_icon_name (icon_name); |
664 | 448 | } | 447 | } |
665 | 449 | catch (Error e) | 448 | catch (Error e) |
666 | 450 | { | 449 | { |
667 | @@ -468,86 +467,5 @@ | |||
668 | 468 | { | 467 | { |
669 | 469 | } | 468 | } |
670 | 470 | } | 469 | } |
671 | 471 | |||
672 | 472 | /* all this icon loading stuff can go when we switch from liblauncher to | ||
673 | 473 | * bamf - please ignore any icon loading bugs :-) | ||
674 | 474 | */ | ||
675 | 475 | private void load_icon_from_icon_name () | ||
676 | 476 | { | ||
677 | 477 | // first try to load from a path; | ||
678 | 478 | if (try_load_from_file (icon_name)) | ||
679 | 479 | { | ||
680 | 480 | return; | ||
681 | 481 | } | ||
682 | 482 | |||
683 | 483 | //try to load from a path that we augment | ||
684 | 484 | if (try_load_from_file ("/usr/share/pixmaps/" + icon_name)) | ||
685 | 485 | { | ||
686 | 486 | return; | ||
687 | 487 | } | ||
688 | 488 | |||
689 | 489 | theme_file_path = new Unity.ThemeFilePath (); | ||
690 | 490 | |||
691 | 491 | // add our searchable themes | ||
692 | 492 | Gtk.IconTheme theme = Gtk.IconTheme.get_default (); | ||
693 | 493 | theme_file_path.add_icon_theme (theme); | ||
694 | 494 | theme = new Gtk.IconTheme (); | ||
695 | 495 | |||
696 | 496 | theme.set_custom_theme ("unity-icon-theme"); | ||
697 | 497 | theme_file_path.add_icon_theme (theme); | ||
698 | 498 | theme.set_custom_theme ("Web"); | ||
699 | 499 | theme_file_path.add_icon_theme (theme); | ||
700 | 500 | |||
701 | 501 | theme_file_path.found_icon_path.connect ((theme, filepath) => { | ||
702 | 502 | try | ||
703 | 503 | { | ||
704 | 504 | child.icon = new Gdk.Pixbuf.from_file (filepath); | ||
705 | 505 | } | ||
706 | 506 | catch (Error e) | ||
707 | 507 | { | ||
708 | 508 | warning (@"Could not load from $filepath"); | ||
709 | 509 | } | ||
710 | 510 | }); | ||
711 | 511 | theme_file_path.failed.connect (() => { | ||
712 | 512 | // we didn't get an icon, so just load the failcon | ||
713 | 513 | try | ||
714 | 514 | { | ||
715 | 515 | var default_theme = Gtk.IconTheme.get_default (); | ||
716 | 516 | child.icon = default_theme.load_icon(Gtk.STOCK_MISSING_IMAGE, 48, 0); | ||
717 | 517 | } | ||
718 | 518 | catch (Error e) | ||
719 | 519 | { | ||
720 | 520 | warning (@"Could not load any icon for %s", app.get_name ()); | ||
721 | 521 | } | ||
722 | 522 | }); | ||
723 | 523 | |||
724 | 524 | theme_file_path.get_icon_filepath (icon_name); | ||
725 | 525 | } | ||
726 | 526 | |||
727 | 527 | private bool try_load_from_file (string filepath) | ||
728 | 528 | { | ||
729 | 529 | Gdk.Pixbuf pixbuf = null; | ||
730 | 530 | if (FileUtils.test(filepath, FileTest.IS_REGULAR)) | ||
731 | 531 | { | ||
732 | 532 | try | ||
733 | 533 | { | ||
734 | 534 | pixbuf = new Gdk.Pixbuf.from_file_at_scale(filepath, | ||
735 | 535 | 48, 48, true); | ||
736 | 536 | } | ||
737 | 537 | catch (Error e) | ||
738 | 538 | { | ||
739 | 539 | warning ("Unable to load image from file '%s': %s", | ||
740 | 540 | filepath, | ||
741 | 541 | e.message); | ||
742 | 542 | } | ||
743 | 543 | |||
744 | 544 | if (pixbuf is Gdk.Pixbuf) | ||
745 | 545 | { | ||
746 | 546 | child.icon = pixbuf; | ||
747 | 547 | return true; | ||
748 | 548 | } | ||
749 | 549 | } | ||
750 | 550 | return false; | ||
751 | 551 | } | ||
752 | 552 | } | 470 | } |
753 | 553 | } | 471 | } |
754 | 554 | 472 | ||
755 | === removed file 'unity-private/launcher/launcher-child.vala' | |||
756 | --- unity-private/launcher/launcher-child.vala 2010-06-22 13:18:52 +0000 | |||
757 | +++ unity-private/launcher/launcher-child.vala 1970-01-01 00:00:00 +0000 | |||
758 | @@ -1,571 +0,0 @@ | |||
759 | 1 | /* -*- Mode: vala; indent-tabs-mode: nil; c-basic-offset: 2; tab-width: 2 -*- */ | ||
760 | 2 | /* | ||
761 | 3 | * Copyright (C) 2009 Canonical Ltd | ||
762 | 4 | * | ||
763 | 5 | * This program is free software: you can redistribute it and/or modify | ||
764 | 6 | * it under the terms of the GNU General Public License version 3 as | ||
765 | 7 | * published by the Free Software Foundation. | ||
766 | 8 | * | ||
767 | 9 | * This program is distributed in the hope that it will be useful, | ||
768 | 10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
769 | 11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
770 | 12 | * GNU General Public License for more details. | ||
771 | 13 | * | ||
772 | 14 | * You should have received a copy of the GNU General Public License | ||
773 | 15 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
774 | 16 | * | ||
775 | 17 | * Authored by Gordon Allott <gord.allott@canonical.com> | ||
776 | 18 | * | ||
777 | 19 | */ | ||
778 | 20 | |||
779 | 21 | namespace Unity.Launcher | ||
780 | 22 | { | ||
781 | 23 | const string HONEYCOMB_MASK_FILE = Unity.PKGDATADIR | ||
782 | 24 | + "/honeycomb-mask.png"; | ||
783 | 25 | const string MENU_BG_FILE = Unity.PKGDATADIR | ||
784 | 26 | + "/tight_check_4px.png"; | ||
785 | 27 | |||
786 | 28 | const float WIGGLE_SIZE = 5; // how many degree's to wiggle on either side. | ||
787 | 29 | const int WIGGLE_FREQUENCY = 5; // x times a second | ||
788 | 30 | const int WIGGLE_RUN_LENGTH = 5000; // 5 seconds of wiggle | ||
789 | 31 | const int WIGGLE_PAUSE_LENGTH = 20; // followed by 20 seconds of no wiggle | ||
790 | 32 | |||
791 | 33 | private enum AnimState { | ||
792 | 34 | RISING, | ||
793 | 35 | LOOPING, | ||
794 | 36 | FALLING, | ||
795 | 37 | STOPPED | ||
796 | 38 | } | ||
797 | 39 | |||
798 | 40 | |||
799 | 41 | class LauncherChild : ScrollerChild | ||
800 | 42 | { | ||
801 | 43 | private UnityIcon processed_icon; | ||
802 | 44 | private ThemeImage active_indicator; | ||
803 | 45 | private ThemeImage running_indicator; | ||
804 | 46 | private Gdk.Pixbuf honeycomb_mask; | ||
805 | 47 | |||
806 | 48 | // effects | ||
807 | 49 | private Ctk.EffectDropShadow effect_drop_shadow; | ||
808 | 50 | private Ctk.EffectGlow effect_icon_glow; | ||
809 | 51 | |||
810 | 52 | // animations | ||
811 | 53 | private Clutter.Animation active_indicator_anim; | ||
812 | 54 | private Clutter.Animation running_indicator_anim; | ||
813 | 55 | private Clutter.Animation rotate_anim; | ||
814 | 56 | private Clutter.Timeline wiggle_timeline; | ||
815 | 57 | private Clutter.Timeline glow_timeline; | ||
816 | 58 | private Clutter.Timeline rotate_timeline; | ||
817 | 59 | private AnimState glow_state; | ||
818 | 60 | private AnimState wiggle_state; | ||
819 | 61 | private AnimState rotate_state; | ||
820 | 62 | |||
821 | 63 | private float old_rotate_value = 0.0f; | ||
822 | 64 | |||
823 | 65 | construct | ||
824 | 66 | { | ||
825 | 67 | load_textures (); | ||
826 | 68 | position = 0.0f; | ||
827 | 69 | |||
828 | 70 | //icon glow | ||
829 | 71 | glow_timeline = new Clutter.Timeline (1); | ||
830 | 72 | wiggle_timeline = new Clutter.Timeline (1); | ||
831 | 73 | rotate_timeline = new Clutter.Timeline (1); | ||
832 | 74 | |||
833 | 75 | glow_timeline.new_frame.connect (on_glow_timeline_new_frame); | ||
834 | 76 | wiggle_timeline.new_frame.connect (on_wiggle_timeline_new_frame); | ||
835 | 77 | rotate_timeline.new_frame.connect (on_rotate_timeline_new_frame); | ||
836 | 78 | |||
837 | 79 | notify["rotation"].connect (on_rotation_changed); | ||
838 | 80 | } | ||
839 | 81 | |||
840 | 82 | ~LauncherChild () | ||
841 | 83 | { | ||
842 | 84 | running_indicator.unparent (); | ||
843 | 85 | active_indicator.unparent (); | ||
844 | 86 | } | ||
845 | 87 | |||
846 | 88 | /* private methods */ | ||
847 | 89 | private void load_textures () | ||
848 | 90 | { | ||
849 | 91 | active_indicator = new ThemeImage ("application-selected"); | ||
850 | 92 | running_indicator = new ThemeImage ("application-running"); | ||
851 | 93 | |||
852 | 94 | active_indicator.set_parent (this); | ||
853 | 95 | running_indicator.set_parent (this); | ||
854 | 96 | active_indicator.set_opacity (0); | ||
855 | 97 | running_indicator.set_opacity (0); | ||
856 | 98 | |||
857 | 99 | try | ||
858 | 100 | { | ||
859 | 101 | honeycomb_mask = new Gdk.Pixbuf.from_file(HONEYCOMB_MASK_FILE); | ||
860 | 102 | } | ||
861 | 103 | catch (Error e) | ||
862 | 104 | { | ||
863 | 105 | warning ("Unable to load asset %s: %s", | ||
864 | 106 | HONEYCOMB_MASK_FILE, | ||
865 | 107 | e.message); | ||
866 | 108 | } | ||
867 | 109 | |||
868 | 110 | processed_icon = new UnityIcon (null, null); | ||
869 | 111 | processed_icon.set_size (48, 48); | ||
870 | 112 | processed_icon.set_parent (this); | ||
871 | 113 | |||
872 | 114 | notify["icon"].connect (on_icon_changed); | ||
873 | 115 | notify["running"].connect (on_running_changed); | ||
874 | 116 | notify["active"].connect (on_active_changed); | ||
875 | 117 | notify["activating"].connect (on_activating_changed); | ||
876 | 118 | notify["needs-attention"].connect (on_needs_attention_changed); | ||
877 | 119 | |||
878 | 120 | // just trigger some notifications now to set inital state | ||
879 | 121 | on_running_changed (); | ||
880 | 122 | on_active_changed (); | ||
881 | 123 | on_rotation_changed (); | ||
882 | 124 | } | ||
883 | 125 | |||
884 | 126 | /* alpha helpers */ | ||
885 | 127 | private static float get_ease_out_sine (float alpha) | ||
886 | 128 | { | ||
887 | 129 | return (float)(Math.sin ((Math.PI_2 * alpha))); | ||
888 | 130 | } | ||
889 | 131 | |||
890 | 132 | private static float get_circular_alpha (float alpha) | ||
891 | 133 | { | ||
892 | 134 | //float sine = (float)(Math.sin (-Math.PI + (alpha * (Math.PI * 2)))); | ||
893 | 135 | var sine = Math.sin ((alpha * (Math.PI * 2)) - Math.PI); | ||
894 | 136 | return Math.fmaxf(((float)sine / 2.0f) + 0.5f, 0.0f);; | ||
895 | 137 | } | ||
896 | 138 | /* animation callbacks */ | ||
897 | 139 | |||
898 | 140 | private void on_rotate_timeline_new_frame () | ||
899 | 141 | { | ||
900 | 142 | float progress = (float)rotate_timeline.get_progress (); | ||
901 | 143 | switch (rotate_state) | ||
902 | 144 | { | ||
903 | 145 | case AnimState.RISING: | ||
904 | 146 | rotate_anim_rising (progress); | ||
905 | 147 | break; | ||
906 | 148 | |||
907 | 149 | case AnimState.STOPPED: | ||
908 | 150 | rotate_timeline.stop (); | ||
909 | 151 | break; | ||
910 | 152 | } | ||
911 | 153 | processed_icon.do_queue_redraw (); | ||
912 | 154 | } | ||
913 | 155 | |||
914 | 156 | private void rotate_anim_rising (float progress) | ||
915 | 157 | { | ||
916 | 158 | progress = get_ease_out_sine (progress); | ||
917 | 159 | var diff = rotation - old_rotate_value; | ||
918 | 160 | float rotate_val = old_rotate_value + (progress * diff); | ||
919 | 161 | |||
920 | 162 | processed_icon.rotation = rotate_val; | ||
921 | 163 | if (progress >= 1.0) | ||
922 | 164 | { | ||
923 | 165 | rotate_state = AnimState.STOPPED; | ||
924 | 166 | rotate_timeline.stop (); | ||
925 | 167 | } | ||
926 | 168 | } | ||
927 | 169 | |||
928 | 170 | public override void force_rotation_jump (float degrees) | ||
929 | 171 | { | ||
930 | 172 | processed_icon.rotation = degrees; | ||
931 | 173 | rotation = degrees; | ||
932 | 174 | rotate_state = AnimState.STOPPED; | ||
933 | 175 | rotate_timeline.stop (); | ||
934 | 176 | do_queue_redraw (); | ||
935 | 177 | } | ||
936 | 178 | |||
937 | 179 | private void on_glow_timeline_new_frame () | ||
938 | 180 | { | ||
939 | 181 | float progress = (float)glow_timeline.get_progress (); | ||
940 | 182 | switch (glow_state) | ||
941 | 183 | { | ||
942 | 184 | case AnimState.RISING: | ||
943 | 185 | glow_anim_rising (progress); | ||
944 | 186 | break; | ||
945 | 187 | |||
946 | 188 | case AnimState.LOOPING: | ||
947 | 189 | glow_anim_looping (progress); | ||
948 | 190 | break; | ||
949 | 191 | |||
950 | 192 | case AnimState.FALLING: | ||
951 | 193 | glow_anim_falling (progress); | ||
952 | 194 | break; | ||
953 | 195 | |||
954 | 196 | default: | ||
955 | 197 | glow_state = AnimState.STOPPED; | ||
956 | 198 | glow_timeline.stop (); | ||
957 | 199 | break; | ||
958 | 200 | } | ||
959 | 201 | |||
960 | 202 | processed_icon.do_queue_redraw (); | ||
961 | 203 | } | ||
962 | 204 | |||
963 | 205 | private float previous_glow_alpha = 0.0f; | ||
964 | 206 | private void glow_anim_rising (float progress) | ||
965 | 207 | { | ||
966 | 208 | progress = get_ease_out_sine (progress); | ||
967 | 209 | effect_icon_glow.set_opacity (progress); | ||
968 | 210 | previous_glow_alpha = progress; | ||
969 | 211 | if (progress >= 1.0) | ||
970 | 212 | { | ||
971 | 213 | glow_state = AnimState.LOOPING; | ||
972 | 214 | glow_timeline.stop (); | ||
973 | 215 | glow_timeline.set_duration (LONG_DELAY); | ||
974 | 216 | glow_timeline.set_loop (true); | ||
975 | 217 | glow_timeline.start (); | ||
976 | 218 | return; | ||
977 | 219 | } | ||
978 | 220 | } | ||
979 | 221 | |||
980 | 222 | private void glow_anim_looping (float progress) | ||
981 | 223 | { | ||
982 | 224 | progress = 1.0f - get_circular_alpha (progress); | ||
983 | 225 | effect_icon_glow.set_opacity (progress); | ||
984 | 226 | previous_glow_alpha = progress; | ||
985 | 227 | processed_icon.do_queue_redraw (); | ||
986 | 228 | } | ||
987 | 229 | |||
988 | 230 | private void glow_anim_falling (float progress) | ||
989 | 231 | { | ||
990 | 232 | float alpha_length = previous_glow_alpha; | ||
991 | 233 | effect_icon_glow.set_opacity (alpha_length - (progress * alpha_length)); | ||
992 | 234 | |||
993 | 235 | if (progress >= 1.0) | ||
994 | 236 | { | ||
995 | 237 | glow_state = AnimState.STOPPED; | ||
996 | 238 | glow_timeline.stop (); | ||
997 | 239 | glow_timeline.set_loop (false); | ||
998 | 240 | } | ||
999 | 241 | } | ||
1000 | 242 | |||
1001 | 243 | private void on_wiggle_timeline_new_frame () | ||
1002 | 244 | { | ||
1003 | 245 | float progress = (float)wiggle_timeline.get_progress (); | ||
1004 | 246 | |||
1005 | 247 | switch (wiggle_state) | ||
1006 | 248 | { | ||
1007 | 249 | case AnimState.RISING: | ||
1008 | 250 | wiggle_anim_rising (progress); | ||
1009 | 251 | break; | ||
1010 | 252 | |||
1011 | 253 | case AnimState.LOOPING: | ||
1012 | 254 | wiggle_anim_looping (progress); | ||
1013 | 255 | break; | ||
1014 | 256 | |||
1015 | 257 | case AnimState.FALLING: | ||
1016 | 258 | wiggle_anim_falling (progress); | ||
1017 | 259 | break; | ||
1018 | 260 | |||
1019 | 261 | default: | ||
1020 | 262 | wiggle_state = AnimState.STOPPED; | ||
1021 | 263 | wiggle_timeline.stop (); | ||
1022 | 264 | break; | ||
1023 | 265 | } | ||
1024 | 266 | |||
1025 | 267 | processed_icon.do_queue_redraw (); | ||
1026 | 268 | } | ||
1027 | 269 | |||
1028 | 270 | private float previous_wiggle_alpha = 0.0f; | ||
1029 | 271 | private void wiggle_anim_rising (float progress) | ||
1030 | 272 | { | ||
1031 | 273 | progress = get_ease_out_sine (progress); | ||
1032 | 274 | processed_icon.set_rotation (Clutter.RotateAxis.Z_AXIS, progress * WIGGLE_SIZE, | ||
1033 | 275 | 25.0f, 25.0f, 0.0f); | ||
1034 | 276 | previous_wiggle_alpha = progress; | ||
1035 | 277 | if (progress >= 1.0) | ||
1036 | 278 | { | ||
1037 | 279 | wiggle_state = AnimState.LOOPING; | ||
1038 | 280 | wiggle_timeline.stop (); | ||
1039 | 281 | wiggle_timeline.set_duration (WIGGLE_RUN_LENGTH); | ||
1040 | 282 | wiggle_timeline.set_loop (true); | ||
1041 | 283 | wiggle_timeline.start (); | ||
1042 | 284 | return; | ||
1043 | 285 | } | ||
1044 | 286 | } | ||
1045 | 287 | |||
1046 | 288 | private void wiggle_anim_looping (float progress) | ||
1047 | 289 | { | ||
1048 | 290 | if (progress >= 1.0) | ||
1049 | 291 | { | ||
1050 | 292 | wiggle_state = AnimState.FALLING; | ||
1051 | 293 | wiggle_timeline.stop (); | ||
1052 | 294 | wiggle_timeline.set_loop (false); | ||
1053 | 295 | wiggle_timeline.start (); | ||
1054 | 296 | } | ||
1055 | 297 | |||
1056 | 298 | int frequency = WIGGLE_FREQUENCY * (WIGGLE_RUN_LENGTH / 1000); | ||
1057 | 299 | progress = get_circular_alpha (Math.fmodf (progress * frequency, 1.0f)); | ||
1058 | 300 | progress = (1.0f - progress) * 2.0f - 1.0f; | ||
1059 | 301 | processed_icon.set_rotation (Clutter.RotateAxis.Z_AXIS, progress * WIGGLE_SIZE, | ||
1060 | 302 | 25.0f, 25.0f, 0.0f); | ||
1061 | 303 | processed_icon.do_queue_redraw (); | ||
1062 | 304 | previous_wiggle_alpha = progress; | ||
1063 | 305 | |||
1064 | 306 | |||
1065 | 307 | } | ||
1066 | 308 | |||
1067 | 309 | private bool check_continue_wiggle () | ||
1068 | 310 | { | ||
1069 | 311 | if (needs_attention) | ||
1070 | 312 | { | ||
1071 | 313 | wiggle_timeline.set_duration (500 / WIGGLE_FREQUENCY); | ||
1072 | 314 | wiggle_state = AnimState.RISING; | ||
1073 | 315 | wiggle_timeline.start (); | ||
1074 | 316 | } | ||
1075 | 317 | return false; | ||
1076 | 318 | } | ||
1077 | 319 | |||
1078 | 320 | private void wiggle_anim_falling (float progress) | ||
1079 | 321 | { | ||
1080 | 322 | float alpha_length = previous_wiggle_alpha; | ||
1081 | 323 | float angle = alpha_length - (progress * alpha_length); | ||
1082 | 324 | processed_icon.set_rotation (Clutter.RotateAxis.Z_AXIS, angle, | ||
1083 | 325 | 25.0f, 25.0f, 0.0f); | ||
1084 | 326 | |||
1085 | 327 | if (progress >= 1.0) | ||
1086 | 328 | { | ||
1087 | 329 | wiggle_state = AnimState.STOPPED; | ||
1088 | 330 | wiggle_timeline.stop (); | ||
1089 | 331 | wiggle_timeline.set_loop (false); | ||
1090 | 332 | GLib.Timeout.add_seconds (WIGGLE_PAUSE_LENGTH, check_continue_wiggle); | ||
1091 | 333 | } | ||
1092 | 334 | } | ||
1093 | 335 | |||
1094 | 336 | /* notifications */ | ||
1095 | 337 | private void on_icon_changed () | ||
1096 | 338 | { | ||
1097 | 339 | if (icon is Gdk.Pixbuf) | ||
1098 | 340 | { | ||
1099 | 341 | Gdk.Pixbuf scaled_buf; | ||
1100 | 342 | int max_size = 48; | ||
1101 | 343 | if (!Unity.pixbuf_is_tile (icon)) | ||
1102 | 344 | max_size = 40; | ||
1103 | 345 | |||
1104 | 346 | if (icon.get_width () > max_size || icon.get_height () > max_size) | ||
1105 | 347 | { | ||
1106 | 348 | scaled_buf = icon.scale_simple (max_size, max_size, Gdk.InterpType.HYPER); | ||
1107 | 349 | } | ||
1108 | 350 | else | ||
1109 | 351 | { | ||
1110 | 352 | scaled_buf = icon; | ||
1111 | 353 | } | ||
1112 | 354 | |||
1113 | 355 | Gdk.Pixbuf color_buf = new Gdk.Pixbuf (Gdk.Colorspace.RGB, true, 8, 1, 1); | ||
1114 | 356 | uint red, green, blue; | ||
1115 | 357 | Unity.get_average_color (scaled_buf, out red, out green, out blue); | ||
1116 | 358 | unowned uchar[] pixels = color_buf.get_pixels (); | ||
1117 | 359 | pixels[0] = (uchar)red; | ||
1118 | 360 | pixels[1] = (uchar)green; | ||
1119 | 361 | pixels[2] = (uchar)blue; | ||
1120 | 362 | pixels[3] = 255; | ||
1121 | 363 | |||
1122 | 364 | var tex = GtkClutter.texture_new_from_pixbuf (scaled_buf); | ||
1123 | 365 | var color = GtkClutter.texture_new_from_pixbuf (color_buf); | ||
1124 | 366 | |||
1125 | 367 | processed_icon = new UnityIcon (tex as Clutter.Texture, color as Clutter.Texture); | ||
1126 | 368 | processed_icon.set_parent (this); | ||
1127 | 369 | processed_icon.rotation = rotation; | ||
1128 | 370 | |||
1129 | 371 | this.effect_drop_shadow = new Ctk.EffectDropShadow (5.0f, 0, 2); | ||
1130 | 372 | effect_drop_shadow.set_opacity (0.4f); | ||
1131 | 373 | this.effect_drop_shadow.set_margin (5); | ||
1132 | 374 | this.processed_icon.add_effect (effect_drop_shadow); | ||
1133 | 375 | |||
1134 | 376 | do_queue_redraw (); | ||
1135 | 377 | } | ||
1136 | 378 | } | ||
1137 | 379 | |||
1138 | 380 | private void on_running_changed () | ||
1139 | 381 | { | ||
1140 | 382 | uint target_opacity = 0; | ||
1141 | 383 | if (running) | ||
1142 | 384 | target_opacity = 255; | ||
1143 | 385 | |||
1144 | 386 | if (running_indicator_anim is Clutter.Animation) | ||
1145 | 387 | running_indicator_anim.completed (); | ||
1146 | 388 | |||
1147 | 389 | running_indicator_anim = running_indicator.animate (Clutter.AnimationMode.EASE_IN_OUT_SINE, | ||
1148 | 390 | SHORT_DELAY, | ||
1149 | 391 | "opacity", target_opacity); | ||
1150 | 392 | } | ||
1151 | 393 | |||
1152 | 394 | private void on_active_changed () | ||
1153 | 395 | { | ||
1154 | 396 | uint target_opacity = 0; | ||
1155 | 397 | if (active) | ||
1156 | 398 | target_opacity = 255; | ||
1157 | 399 | |||
1158 | 400 | if (active_indicator_anim is Clutter.Animation) | ||
1159 | 401 | active_indicator_anim.completed (); | ||
1160 | 402 | active_indicator_anim = active_indicator.animate (Clutter.AnimationMode.EASE_IN_OUT_SINE, | ||
1161 | 403 | SHORT_DELAY, | ||
1162 | 404 | "opacity", target_opacity); | ||
1163 | 405 | } | ||
1164 | 406 | |||
1165 | 407 | private void on_rotation_changed () | ||
1166 | 408 | { | ||
1167 | 409 | old_rotate_value = processed_icon.rotation; | ||
1168 | 410 | |||
1169 | 411 | if (rotate_timeline is Clutter.Timeline == false) | ||
1170 | 412 | return; | ||
1171 | 413 | |||
1172 | 414 | if (rotate_timeline.is_playing ()) | ||
1173 | 415 | { | ||
1174 | 416 | rotate_timeline.stop (); | ||
1175 | 417 | processed_icon.rotation = old_rotate_value; | ||
1176 | 418 | } | ||
1177 | 419 | |||
1178 | 420 | rotate_timeline.set_duration (300); | ||
1179 | 421 | rotate_state = AnimState.RISING; | ||
1180 | 422 | rotate_timeline.start (); | ||
1181 | 423 | } | ||
1182 | 424 | |||
1183 | 425 | private void on_activating_changed () | ||
1184 | 426 | { | ||
1185 | 427 | if (glow_timeline.is_playing () && activating == false) | ||
1186 | 428 | { | ||
1187 | 429 | glow_timeline.stop (); | ||
1188 | 430 | glow_timeline.set_duration (SHORT_DELAY); | ||
1189 | 431 | glow_state = AnimState.FALLING; | ||
1190 | 432 | glow_timeline.start (); | ||
1191 | 433 | } | ||
1192 | 434 | else if (glow_timeline.is_playing () == false && activating) | ||
1193 | 435 | { | ||
1194 | 436 | effect_icon_glow = new Ctk.EffectGlow (); | ||
1195 | 437 | Clutter.Color c = Clutter.Color () { | ||
1196 | 438 | red = 255, | ||
1197 | 439 | green = 255, | ||
1198 | 440 | blue = 255, | ||
1199 | 441 | alpha = 255 | ||
1200 | 442 | }; | ||
1201 | 443 | effect_icon_glow.set_background_texture (honeycomb_mask); | ||
1202 | 444 | effect_icon_glow.set_color (c); | ||
1203 | 445 | effect_icon_glow.set_opacity (1.0f); | ||
1204 | 446 | processed_icon.add_effect (effect_icon_glow); | ||
1205 | 447 | effect_icon_glow.set_margin (6); | ||
1206 | 448 | |||
1207 | 449 | glow_timeline.set_duration (SHORT_DELAY); | ||
1208 | 450 | glow_state = AnimState.RISING; | ||
1209 | 451 | glow_timeline.start (); | ||
1210 | 452 | } | ||
1211 | 453 | } | ||
1212 | 454 | |||
1213 | 455 | private void on_needs_attention_changed () | ||
1214 | 456 | { | ||
1215 | 457 | if (needs_attention && wiggle_timeline.is_playing () == false) | ||
1216 | 458 | { | ||
1217 | 459 | //start wiggling | ||
1218 | 460 | wiggle_timeline.set_duration (500 / WIGGLE_FREQUENCY); | ||
1219 | 461 | wiggle_state = AnimState.RISING; | ||
1220 | 462 | wiggle_timeline.start (); | ||
1221 | 463 | } | ||
1222 | 464 | else if (needs_attention == false && wiggle_timeline.is_playing ()) | ||
1223 | 465 | { | ||
1224 | 466 | //stop wiggling | ||
1225 | 467 | wiggle_timeline.stop (); | ||
1226 | 468 | wiggle_timeline.set_duration (500 / WIGGLE_FREQUENCY); | ||
1227 | 469 | wiggle_state = AnimState.FALLING; | ||
1228 | 470 | wiggle_timeline.start (); | ||
1229 | 471 | } | ||
1230 | 472 | } | ||
1231 | 473 | |||
1232 | 474 | /* clutter overrides */ | ||
1233 | 475 | public override void get_preferred_width (float for_height, | ||
1234 | 476 | out float minimum_width, | ||
1235 | 477 | out float natural_width) | ||
1236 | 478 | { | ||
1237 | 479 | float nat, min; | ||
1238 | 480 | processed_icon.get_preferred_width (for_height, out min, out nat); | ||
1239 | 481 | natural_width = nat; | ||
1240 | 482 | minimum_width = min; | ||
1241 | 483 | |||
1242 | 484 | running_indicator.get_preferred_width (for_height, out min, out nat); | ||
1243 | 485 | natural_width += nat; | ||
1244 | 486 | |||
1245 | 487 | active_indicator.get_preferred_width (for_height, out min, out nat); | ||
1246 | 488 | natural_width += nat; | ||
1247 | 489 | } | ||
1248 | 490 | |||
1249 | 491 | public override void get_preferred_height (float for_width, | ||
1250 | 492 | out float minimum_height, | ||
1251 | 493 | out float natural_height) | ||
1252 | 494 | { | ||
1253 | 495 | natural_height = 48; | ||
1254 | 496 | minimum_height = 48; | ||
1255 | 497 | } | ||
1256 | 498 | |||
1257 | 499 | public override void allocate (Clutter.ActorBox box, Clutter.AllocationFlags flags) | ||
1258 | 500 | { | ||
1259 | 501 | float x, y; | ||
1260 | 502 | x = 0; | ||
1261 | 503 | y = 0; | ||
1262 | 504 | base.allocate (box, flags); | ||
1263 | 505 | |||
1264 | 506 | Clutter.ActorBox child_box = Clutter.ActorBox (); | ||
1265 | 507 | |||
1266 | 508 | //allocate the running indicator first | ||
1267 | 509 | float width, height, n_width, n_height; | ||
1268 | 510 | running_indicator.get_preferred_width (58, out n_width, out width); | ||
1269 | 511 | running_indicator.get_preferred_height (58, out n_height, out height); | ||
1270 | 512 | child_box.x1 = 0; | ||
1271 | 513 | child_box.y1 = (box.get_height () - height) / 2.0f; | ||
1272 | 514 | child_box.x2 = child_box.x1 + width; | ||
1273 | 515 | child_box.y2 = child_box.y1 + height; | ||
1274 | 516 | running_indicator.allocate (child_box, flags); | ||
1275 | 517 | x += child_box.get_width (); | ||
1276 | 518 | |||
1277 | 519 | //allocate the icon | ||
1278 | 520 | processed_icon.get_preferred_width (48, out width, out n_width); | ||
1279 | 521 | processed_icon.get_preferred_height (48, out height, out n_height); | ||
1280 | 522 | child_box.x1 = (box.get_width () - width) / 2.0f; | ||
1281 | 523 | child_box.y1 = y; | ||
1282 | 524 | child_box.x2 = child_box.x1 + 48; | ||
1283 | 525 | child_box.y2 = child_box.y1 + height; | ||
1284 | 526 | processed_icon.allocate (child_box, flags); | ||
1285 | 527 | |||
1286 | 528 | //allocate the active indicator | ||
1287 | 529 | active_indicator.get_preferred_width (48, out n_width, out width); | ||
1288 | 530 | active_indicator.get_preferred_height (48, out n_height, out height); | ||
1289 | 531 | child_box.x1 = box.get_width () - width; | ||
1290 | 532 | child_box.y1 = (box.get_height () - height) / 2.0f; | ||
1291 | 533 | child_box.x2 = child_box.x1 + width; | ||
1292 | 534 | child_box.y2 = child_box.y1 + height; | ||
1293 | 535 | active_indicator.allocate (child_box, flags); | ||
1294 | 536 | |||
1295 | 537 | } | ||
1296 | 538 | |||
1297 | 539 | public override void pick (Clutter.Color color) | ||
1298 | 540 | { | ||
1299 | 541 | base.pick (color); | ||
1300 | 542 | } | ||
1301 | 543 | |||
1302 | 544 | public override void paint () | ||
1303 | 545 | { | ||
1304 | 546 | active_indicator.paint (); | ||
1305 | 547 | running_indicator.paint (); | ||
1306 | 548 | |||
1307 | 549 | processed_icon.paint (); | ||
1308 | 550 | } | ||
1309 | 551 | |||
1310 | 552 | public override void map () | ||
1311 | 553 | { | ||
1312 | 554 | base.map (); | ||
1313 | 555 | running_indicator.map (); | ||
1314 | 556 | active_indicator.map (); | ||
1315 | 557 | processed_icon.map (); | ||
1316 | 558 | } | ||
1317 | 559 | |||
1318 | 560 | public override void unmap () | ||
1319 | 561 | { | ||
1320 | 562 | base.unmap (); | ||
1321 | 563 | running_indicator.unmap (); | ||
1322 | 564 | active_indicator.unmap (); | ||
1323 | 565 | processed_icon.unmap (); | ||
1324 | 566 | } | ||
1325 | 567 | } | ||
1326 | 568 | } | ||
1327 | 569 | |||
1328 | 570 | |||
1329 | 571 | |||
1330 | 572 | 0 | ||
1331 | === modified file 'unity-private/launcher/launcher.vala' | |||
1332 | --- unity-private/launcher/launcher.vala 2010-04-26 13:47:08 +0000 | |||
1333 | +++ unity-private/launcher/launcher.vala 2010-07-22 16:19:42 +0000 | |||
1334 | @@ -33,9 +33,10 @@ | |||
1335 | 33 | public class Launcher : Object | 33 | public class Launcher : Object |
1336 | 34 | { | 34 | { |
1337 | 35 | public Shell shell {get; construct;} | 35 | public Shell shell {get; construct;} |
1338 | 36 | public ScrollerModel model { get; private set; } | ||
1339 | 37 | |||
1340 | 36 | private ScrollerController controller; | 38 | private ScrollerController controller; |
1341 | 37 | private ScrollerView view; | 39 | private ScrollerView view; |
1342 | 38 | private ScrollerModel model; | ||
1343 | 39 | 40 | ||
1344 | 40 | public Launcher (Shell shell) | 41 | public Launcher (Shell shell) |
1345 | 41 | { | 42 | { |
1346 | 42 | 43 | ||
1347 | === modified file 'unity-private/launcher/quicklist-controller.vala' | |||
1348 | --- unity-private/launcher/quicklist-controller.vala 2010-07-16 15:50:39 +0000 | |||
1349 | +++ unity-private/launcher/quicklist-controller.vala 2010-07-22 16:19:42 +0000 | |||
1350 | @@ -36,6 +36,9 @@ | |||
1351 | 36 | get { return _state; } | 36 | get { return _state; } |
1352 | 37 | set | 37 | set |
1353 | 38 | { | 38 | { |
1354 | 39 | var drag_controller = Unity.Drag.Controller.get_default (); | ||
1355 | 40 | if (drag_controller.is_dragging) value = QuicklistControllerState.CLOSED; | ||
1356 | 41 | |||
1357 | 39 | if (value == QuicklistControllerState.LABEL || | 42 | if (value == QuicklistControllerState.LABEL || |
1358 | 40 | value == QuicklistControllerState.MENU) | 43 | value == QuicklistControllerState.MENU) |
1359 | 41 | { | 44 | { |
1360 | @@ -95,7 +98,6 @@ | |||
1361 | 95 | 98 | ||
1362 | 96 | } | 99 | } |
1363 | 97 | 100 | ||
1364 | 98 | |||
1365 | 99 | public class ApplicationQuicklistController : QuicklistController | 101 | public class ApplicationQuicklistController : QuicklistController |
1366 | 100 | { | 102 | { |
1367 | 101 | public ApplicationQuicklistController (ScrollerChildController scroller_child) | 103 | public ApplicationQuicklistController (ScrollerChildController scroller_child) |
1368 | @@ -111,6 +113,11 @@ | |||
1369 | 111 | new_menu (); | 113 | new_menu (); |
1370 | 112 | notify["state"].connect (on_state_change); | 114 | notify["state"].connect (on_state_change); |
1371 | 113 | state = QuicklistControllerState.LABEL; | 115 | state = QuicklistControllerState.LABEL; |
1372 | 116 | |||
1373 | 117 | var drag_controller = Unity.Drag.Controller.get_default (); | ||
1374 | 118 | drag_controller.drag_start.connect (() => { | ||
1375 | 119 | state = QuicklistControllerState.CLOSED; | ||
1376 | 120 | }); | ||
1377 | 114 | } | 121 | } |
1378 | 115 | 122 | ||
1379 | 116 | private void new_menu () | 123 | private void new_menu () |
1380 | 117 | 124 | ||
1381 | === modified file 'unity-private/launcher/scroller-controller.vala' | |||
1382 | --- unity-private/launcher/scroller-controller.vala 2010-07-15 13:19:02 +0000 | |||
1383 | +++ unity-private/launcher/scroller-controller.vala 2010-07-22 16:19:42 +0000 | |||
1384 | @@ -76,37 +76,34 @@ | |||
1385 | 76 | Bamf.Application app = object as Bamf.Application; | 76 | Bamf.Application app = object as Bamf.Application; |
1386 | 77 | // need to hook up to its visible changed signals | 77 | // need to hook up to its visible changed signals |
1387 | 78 | 78 | ||
1419 | 79 | // this is wrong as it will never re-hide a window | 79 | string desktop_file = app.get_desktop_file (); |
1420 | 80 | app.user_visible_changed.connect ((a, changed) => { | 80 | |
1421 | 81 | if (changed) | 81 | ScrollerChildController controller = null; |
1422 | 82 | { | 82 | if (desktop_file != null && desktop_file != "") |
1423 | 83 | handle_bamf_view_opened (a as Object); | 83 | { |
1424 | 84 | } | 84 | controller = find_controller_by_desktop_file (desktop_file); |
1425 | 85 | }); | 85 | } |
1426 | 86 | 86 | ||
1427 | 87 | if (app.user_visible ()) | 87 | if (controller is ApplicationController) |
1428 | 88 | { | 88 | { |
1429 | 89 | string desktop_file = app.get_desktop_file (); | 89 | (controller as ApplicationController).attach_application (app); |
1430 | 90 | 90 | } | |
1431 | 91 | ScrollerChildController controller = null; | 91 | else |
1432 | 92 | if (desktop_file != null && desktop_file != "") | 92 | { |
1433 | 93 | { | 93 | ScrollerChild child = new ScrollerChild (); |
1434 | 94 | controller = find_controller_by_desktop_file (desktop_file); | 94 | controller = new ApplicationController (null, child); |
1435 | 95 | } | 95 | (controller as ApplicationController).attach_application (app); |
1436 | 96 | 96 | if (app.user_visible ()) | |
1437 | 97 | if (controller is ApplicationController) | 97 | model.add (child); |
1438 | 98 | { | 98 | |
1439 | 99 | (controller as ApplicationController).attach_application (app); | 99 | childcontrollers.add (controller); |
1440 | 100 | } | 100 | controller.closed.connect (on_scroller_controller_closed); |
1441 | 101 | else | 101 | controller.notify["hide"].connect (() => { |
1442 | 102 | { | 102 | if (controller.hide && controller.child in model) |
1443 | 103 | LauncherChild child = new LauncherChild (); | 103 | model.remove (controller.child); |
1444 | 104 | controller = new ApplicationController (null, child); | 104 | if (!controller.hide && (controller.child in model) == false) |
1445 | 105 | (controller as ApplicationController).attach_application (app); | 105 | model.add (controller.child); |
1446 | 106 | model.add (child); | 106 | }); |
1416 | 107 | childcontrollers.add (controller); | ||
1417 | 108 | controller.closed.connect (on_scroller_controller_closed); | ||
1418 | 109 | } | ||
1447 | 110 | } | 107 | } |
1448 | 111 | } | 108 | } |
1449 | 112 | } | 109 | } |
1450 | @@ -115,7 +112,7 @@ | |||
1451 | 115 | { | 112 | { |
1452 | 116 | if (controller is ApplicationController) | 113 | if (controller is ApplicationController) |
1453 | 117 | { | 114 | { |
1455 | 118 | if (controller.child.pin_type == PinType.UNPINNED) | 115 | if (!(controller as ApplicationController).is_sticky ()) |
1456 | 119 | { | 116 | { |
1457 | 120 | model.remove (controller.child); | 117 | model.remove (controller.child); |
1458 | 121 | childcontrollers.remove (controller); | 118 | childcontrollers.remove (controller); |
1459 | @@ -174,7 +171,7 @@ | |||
1460 | 174 | ApplicationController controller = find_controller_by_desktop_file (desktop_file); | 171 | ApplicationController controller = find_controller_by_desktop_file (desktop_file); |
1461 | 175 | if (!(controller is ScrollerChildController)) | 172 | if (!(controller is ScrollerChildController)) |
1462 | 176 | { | 173 | { |
1464 | 177 | LauncherChild child = new LauncherChild (); | 174 | ScrollerChild child = new ScrollerChild (); |
1465 | 178 | controller = new ApplicationController (desktop_file, child); | 175 | controller = new ApplicationController (desktop_file, child); |
1466 | 179 | model.add (child); | 176 | model.add (child); |
1467 | 180 | childcontrollers.add (controller); | 177 | childcontrollers.add (controller); |
1468 | @@ -199,7 +196,7 @@ | |||
1469 | 199 | ApplicationController controller = find_controller_by_desktop_file (desktop_file); | 196 | ApplicationController controller = find_controller_by_desktop_file (desktop_file); |
1470 | 200 | if (!(controller is ScrollerChildController)) | 197 | if (!(controller is ScrollerChildController)) |
1471 | 201 | { | 198 | { |
1473 | 202 | LauncherChild child = new LauncherChild (); | 199 | ScrollerChild child = new ScrollerChild (); |
1474 | 203 | controller = new ApplicationController (desktop_file, child); | 200 | controller = new ApplicationController (desktop_file, child); |
1475 | 204 | model.add (child); | 201 | model.add (child); |
1476 | 205 | childcontrollers.add (controller); | 202 | childcontrollers.add (controller); |
1477 | @@ -267,8 +264,17 @@ | |||
1478 | 267 | } | 264 | } |
1479 | 268 | } | 265 | } |
1480 | 269 | 266 | ||
1481 | 267 | float last_drag_x = 0.0f; | ||
1482 | 268 | float last_drag_y = 0.0f; | ||
1483 | 270 | private void on_unity_drag_motion (Drag.Model drag_model, float x, float y) | 269 | private void on_unity_drag_motion (Drag.Model drag_model, float x, float y) |
1484 | 271 | { | 270 | { |
1485 | 271 | if (x == last_drag_x && y == last_drag_y) | ||
1486 | 272 | return; | ||
1487 | 273 | |||
1488 | 274 | last_drag_x = x; | ||
1489 | 275 | last_drag_y = y; | ||
1490 | 276 | |||
1491 | 277 | |||
1492 | 272 | var drag_controller = Drag.Controller.get_default (); | 278 | var drag_controller = Drag.Controller.get_default (); |
1493 | 273 | // check to see if the data matches any of our children | 279 | // check to see if the data matches any of our children |
1494 | 274 | if (!(drag_controller.get_drag_model () is ScrollerChildController)) | 280 | if (!(drag_controller.get_drag_model () is ScrollerChildController)) |
1495 | @@ -286,13 +292,40 @@ | |||
1496 | 286 | { | 292 | { |
1497 | 287 | // if the actor is not in the model, add it. because its now in there! | 293 | // if the actor is not in the model, add it. because its now in there! |
1498 | 288 | // find the index at this position | 294 | // find the index at this position |
1502 | 289 | int model_index = view.get_model_index_at_y_pos (y); | 295 | int model_index = view.get_model_index_at_y_pos_no_anim (y, true); |
1503 | 290 | if (retcont in model) | 296 | if (model_index < 0) return; |
1504 | 291 | model.move (retcont, int.max (model_index, 0)); | 297 | |
1505 | 298 | //we have to check to see if we would still be over the index | ||
1506 | 299 | //if it was done animating | ||
1507 | 300 | /* | ||
1508 | 301 | GLib.Value value = Value (typeof (float)); | ||
1509 | 302 | var child = model[model_index]; | ||
1510 | 303 | Clutter.Animation anim = child.get_animation (); | ||
1511 | 304 | if (anim is Clutter.Animation) | ||
1512 | 305 | { | ||
1513 | 306 | debug ("is animating"); | ||
1514 | 307 | Clutter.Interval interval = anim.get_interval ("position"); | ||
1515 | 308 | interval.get_final_value (value); | ||
1516 | 309 | } | ||
1517 | 292 | else | 310 | else |
1521 | 293 | model.insert (retcont, int.max (model_index, 0)); | 311 | { |
1522 | 294 | 312 | debug ("is not animating"); | |
1523 | 295 | view.do_queue_redraw (); | 313 | value.set_float (y); |
1524 | 314 | } | ||
1525 | 315 | |||
1526 | 316 | debug ("%f", Math.fabsf (value.get_float () - y)); | ||
1527 | 317 | |||
1528 | 318 | if (Math.fabsf (value.get_float () - y) < 48) | ||
1529 | 319 | { | ||
1530 | 320 | debug ("moving things"); | ||
1531 | 321 | */ | ||
1532 | 322 | if (retcont in model) | ||
1533 | 323 | model.move (retcont, int.max (model_index, 0)); | ||
1534 | 324 | else | ||
1535 | 325 | model.insert (retcont, int.max (model_index, 0)); | ||
1536 | 326 | |||
1537 | 327 | view.do_queue_redraw (); | ||
1538 | 328 | //} | ||
1539 | 296 | } | 329 | } |
1540 | 297 | } | 330 | } |
1541 | 298 | 331 | ||
1542 | 299 | 332 | ||
1543 | === modified file 'unity-private/launcher/scroller-model.vala' | |||
1544 | --- unity-private/launcher/scroller-model.vala 2010-06-16 12:42:46 +0000 | |||
1545 | +++ unity-private/launcher/scroller-model.vala 2010-07-22 16:19:42 +0000 | |||
1546 | @@ -94,6 +94,7 @@ | |||
1547 | 94 | 94 | ||
1548 | 95 | public void add (ScrollerChild child) | 95 | public void add (ScrollerChild child) |
1549 | 96 | { | 96 | { |
1550 | 97 | warning ("Add Icon: %s", child.to_string ()); | ||
1551 | 97 | children.add (child); | 98 | children.add (child); |
1552 | 98 | child_added (child); | 99 | child_added (child); |
1553 | 99 | order_changed (); | 100 | order_changed (); |
1554 | 100 | 101 | ||
1555 | === modified file 'unity-private/launcher/scroller-view.vala' | |||
1556 | --- unity-private/launcher/scroller-view.vala 2010-07-19 13:06:02 +0000 | |||
1557 | +++ unity-private/launcher/scroller-view.vala 2010-07-22 16:19:42 +0000 | |||
1558 | @@ -156,7 +156,35 @@ | |||
1559 | 156 | }); | 156 | }); |
1560 | 157 | } | 157 | } |
1561 | 158 | 158 | ||
1563 | 159 | public int get_model_index_at_y_pos (float y) | 159 | public int get_model_index_at_y_pos_no_anim (float y, bool return_minus_if_fail=false) |
1564 | 160 | { | ||
1565 | 161 | SList<float?> positions = new SList<float?> (); | ||
1566 | 162 | foreach (ScrollerChild child in model) | ||
1567 | 163 | { | ||
1568 | 164 | positions.append (child.position); | ||
1569 | 165 | GLib.Value value = Value (typeof (float)); | ||
1570 | 166 | Clutter.Animation anim = child.get_animation (); | ||
1571 | 167 | if (anim is Clutter.Animation) | ||
1572 | 168 | { | ||
1573 | 169 | Clutter.Interval interval = anim.get_interval ("position"); | ||
1574 | 170 | interval.get_final_value (value); | ||
1575 | 171 | child.position = value.get_float (); | ||
1576 | 172 | } | ||
1577 | 173 | } | ||
1578 | 174 | |||
1579 | 175 | int value = get_model_index_at_y_pos (y, return_minus_if_fail); | ||
1580 | 176 | |||
1581 | 177 | unowned SList<float?> list = positions; | ||
1582 | 178 | foreach (ScrollerChild child in model) | ||
1583 | 179 | { | ||
1584 | 180 | child.position = (float)list.data; | ||
1585 | 181 | list = list.next; | ||
1586 | 182 | } | ||
1587 | 183 | |||
1588 | 184 | return value; | ||
1589 | 185 | } | ||
1590 | 186 | |||
1591 | 187 | public int get_model_index_at_y_pos (float y, bool return_minus_if_fail=false) | ||
1592 | 160 | { | 188 | { |
1593 | 161 | 189 | ||
1594 | 162 | // trying out a different method | 190 | // trying out a different method |
1595 | @@ -174,6 +202,8 @@ | |||
1596 | 174 | 202 | ||
1597 | 175 | if (picked_actor is ScrollerChild == false) | 203 | if (picked_actor is ScrollerChild == false) |
1598 | 176 | { | 204 | { |
1599 | 205 | if (return_minus_if_fail) | ||
1600 | 206 | return -1; | ||
1601 | 177 | // couldn't pick a single actor, return 0 | 207 | // couldn't pick a single actor, return 0 |
1602 | 178 | return (y < padding.top + model[0].get_height () + spacing) ? 0 : model.size -1 ; | 208 | return (y < padding.top + model[0].get_height () + spacing) ? 0 : model.size -1 ; |
1603 | 179 | } | 209 | } |
1604 | @@ -660,7 +690,7 @@ | |||
1605 | 660 | if (child.get_animation () is Clutter.Animation) | 690 | if (child.get_animation () is Clutter.Animation) |
1606 | 661 | { | 691 | { |
1607 | 662 | //GLib.Value value = GLib.Value (GLib.Type.from_name ("string")); | 692 | //GLib.Value value = GLib.Value (GLib.Type.from_name ("string")); |
1609 | 663 | GLib.Value value = typeof (float); | 693 | GLib.Value value = Value (typeof (float)); |
1610 | 664 | Clutter.Interval interval = child.get_animation ().get_interval ("position"); | 694 | Clutter.Interval interval = child.get_animation ().get_interval ("position"); |
1611 | 665 | interval.get_final_value (value); | 695 | interval.get_final_value (value); |
1612 | 666 | if (value.get_float () != transitions[index].position) | 696 | if (value.get_float () != transitions[index].position) |
1613 | @@ -892,17 +922,17 @@ | |||
1614 | 892 | for (int index = draw_btf.size-1; index >= 0; index--) | 922 | for (int index = draw_btf.size-1; index >= 0; index--) |
1615 | 893 | { | 923 | { |
1616 | 894 | ScrollerChild child = draw_btf[index]; | 924 | ScrollerChild child = draw_btf[index]; |
1618 | 895 | if (child is LauncherChild && child.opacity > 0) | 925 | if (child is ScrollerChild && child.opacity > 0) |
1619 | 896 | { | 926 | { |
1621 | 897 | (child as LauncherChild).paint (); | 927 | (child as ScrollerChild).paint (); |
1622 | 898 | } | 928 | } |
1623 | 899 | } | 929 | } |
1624 | 900 | 930 | ||
1625 | 901 | foreach (ScrollerChild child in draw_ftb) | 931 | foreach (ScrollerChild child in draw_ftb) |
1626 | 902 | { | 932 | { |
1628 | 903 | if (child is LauncherChild && child.opacity > 0) | 933 | if (child is ScrollerChild && child.opacity > 0) |
1629 | 904 | { | 934 | { |
1631 | 905 | (child as LauncherChild).paint (); | 935 | (child as ScrollerChild).paint (); |
1632 | 906 | } | 936 | } |
1633 | 907 | } | 937 | } |
1634 | 908 | 938 | ||
1635 | @@ -919,17 +949,17 @@ | |||
1636 | 919 | for (int index = draw_btf.size-1; index >= 0; index--) | 949 | for (int index = draw_btf.size-1; index >= 0; index--) |
1637 | 920 | { | 950 | { |
1638 | 921 | ScrollerChild child = draw_btf[index]; | 951 | ScrollerChild child = draw_btf[index]; |
1640 | 922 | if (child is LauncherChild && child.opacity > 0) | 952 | if (child is ScrollerChild && child.opacity > 0) |
1641 | 923 | { | 953 | { |
1643 | 924 | (child as LauncherChild).paint (); | 954 | (child as ScrollerChild).paint (); |
1644 | 925 | } | 955 | } |
1645 | 926 | } | 956 | } |
1646 | 927 | 957 | ||
1647 | 928 | foreach (ScrollerChild child in draw_ftb) | 958 | foreach (ScrollerChild child in draw_ftb) |
1648 | 929 | { | 959 | { |
1650 | 930 | if (child is LauncherChild && child.opacity > 0) | 960 | if (child is ScrollerChild && child.opacity > 0) |
1651 | 931 | { | 961 | { |
1653 | 932 | (child as LauncherChild).paint (); | 962 | (child as ScrollerChild).paint (); |
1654 | 933 | } | 963 | } |
1655 | 934 | } | 964 | } |
1656 | 935 | 965 | ||
1657 | 936 | 966 | ||
1658 | === modified file 'unity-private/launcher/scrollerchild-controller.vala' | |||
1659 | --- unity-private/launcher/scrollerchild-controller.vala 2010-07-15 09:29:49 +0000 | |||
1660 | +++ unity-private/launcher/scrollerchild-controller.vala 2010-07-22 16:19:42 +0000 | |||
1661 | @@ -37,7 +37,10 @@ | |||
1662 | 37 | { | 37 | { |
1663 | 38 | public ScrollerChild child {get; construct;} | 38 | public ScrollerChild child {get; construct;} |
1664 | 39 | public signal void request_removal (); //call when not needed anymore so we can unref | 39 | public signal void request_removal (); //call when not needed anymore so we can unref |
1666 | 40 | public string name = "If you can read this, file a bug!!"; | 40 | |
1667 | 41 | public string name {get; set;} | ||
1668 | 42 | public bool hide {get; set;} | ||
1669 | 43 | |||
1670 | 41 | 44 | ||
1671 | 42 | public signal void closed (); | 45 | public signal void closed (); |
1672 | 43 | 46 | ||
1673 | @@ -46,6 +49,7 @@ | |||
1674 | 46 | protected bool button_down = false; | 49 | protected bool button_down = false; |
1675 | 47 | protected float click_start_pos = 0.0f; | 50 | protected float click_start_pos = 0.0f; |
1676 | 48 | protected int drag_sensitivity = 7; | 51 | protected int drag_sensitivity = 7; |
1677 | 52 | private Unity.ThemeFilePath theme_file_path; | ||
1678 | 49 | 53 | ||
1679 | 50 | protected QuicklistController? menu {get; set;} | 54 | protected QuicklistController? menu {get; set;} |
1680 | 51 | 55 | ||
1681 | @@ -56,6 +60,8 @@ | |||
1682 | 56 | 60 | ||
1683 | 57 | construct | 61 | construct |
1684 | 58 | { | 62 | { |
1685 | 63 | theme_file_path = new Unity.ThemeFilePath (); | ||
1686 | 64 | name = "Bug Found, You Defeated Unity"; | ||
1687 | 59 | child.controller = this; | 65 | child.controller = this; |
1688 | 60 | child.button_press_event.connect (on_press_event); | 66 | child.button_press_event.connect (on_press_event); |
1689 | 61 | child.button_release_event.connect (on_release_event); | 67 | child.button_release_event.connect (on_release_event); |
1690 | @@ -71,11 +77,26 @@ | |||
1691 | 71 | } | 77 | } |
1692 | 72 | 78 | ||
1693 | 73 | public delegate void menu_cb (Dbusmenu.Menuitem? menu); | 79 | public delegate void menu_cb (Dbusmenu.Menuitem? menu); |
1699 | 74 | public abstract void get_menu_actions (menu_cb callback); | 80 | |
1700 | 75 | public abstract void get_menu_navigation (menu_cb callback); | 81 | public virtual void get_menu_actions (menu_cb callback) |
1701 | 76 | 82 | { | |
1702 | 77 | public abstract void activate (); | 83 | callback (null); |
1703 | 78 | public abstract QuicklistController get_menu_controller (); | 84 | } |
1704 | 85 | |||
1705 | 86 | public virtual void get_menu_navigation (menu_cb callback) | ||
1706 | 87 | { | ||
1707 | 88 | callback (null); | ||
1708 | 89 | } | ||
1709 | 90 | |||
1710 | 91 | public virtual void activate () | ||
1711 | 92 | { | ||
1712 | 93 | // do nothing! | ||
1713 | 94 | } | ||
1714 | 95 | |||
1715 | 96 | public virtual QuicklistController get_menu_controller () | ||
1716 | 97 | { | ||
1717 | 98 | return null; | ||
1718 | 99 | } | ||
1719 | 79 | 100 | ||
1720 | 80 | private bool on_leave_event (Clutter.Event event) | 101 | private bool on_leave_event (Clutter.Event event) |
1721 | 81 | { | 102 | { |
1722 | @@ -140,6 +161,7 @@ | |||
1723 | 140 | private void ensure_menu_state () | 161 | private void ensure_menu_state () |
1724 | 141 | { | 162 | { |
1725 | 142 | //no tooltips on drag | 163 | //no tooltips on drag |
1726 | 164 | |||
1727 | 143 | if (Unity.Drag.Controller.get_default ().is_dragging) return; | 165 | if (Unity.Drag.Controller.get_default ().is_dragging) return; |
1728 | 144 | 166 | ||
1729 | 145 | if (menu is QuicklistController == false) | 167 | if (menu is QuicklistController == false) |
1730 | @@ -177,7 +199,7 @@ | |||
1731 | 177 | // this is for our drag handling | 199 | // this is for our drag handling |
1732 | 178 | public Clutter.Actor get_icon () | 200 | public Clutter.Actor get_icon () |
1733 | 179 | { | 201 | { |
1735 | 180 | return child; | 202 | return child.get_content (); |
1736 | 181 | } | 203 | } |
1737 | 182 | 204 | ||
1738 | 183 | public string get_drag_data () | 205 | public string get_drag_data () |
1739 | @@ -204,5 +226,85 @@ | |||
1740 | 204 | } | 226 | } |
1741 | 205 | return false; | 227 | return false; |
1742 | 206 | } | 228 | } |
1743 | 229 | |||
1744 | 230 | /* all this icon loading stuff can go when we switch from liblauncher to | ||
1745 | 231 | * bamf - please ignore any icon loading bugs :-) | ||
1746 | 232 | */ | ||
1747 | 233 | protected void load_icon_from_icon_name (string icon_name) | ||
1748 | 234 | { | ||
1749 | 235 | // first try to load from a path; | ||
1750 | 236 | if (try_load_from_file (icon_name)) | ||
1751 | 237 | { | ||
1752 | 238 | return; | ||
1753 | 239 | } | ||
1754 | 240 | |||
1755 | 241 | //try to load from a path that we augment | ||
1756 | 242 | if (try_load_from_file ("/usr/share/pixmaps/" + icon_name)) | ||
1757 | 243 | { | ||
1758 | 244 | return; | ||
1759 | 245 | } | ||
1760 | 246 | |||
1761 | 247 | theme_file_path = new Unity.ThemeFilePath (); | ||
1762 | 248 | |||
1763 | 249 | // add our searchable themes | ||
1764 | 250 | Gtk.IconTheme theme = Gtk.IconTheme.get_default (); | ||
1765 | 251 | theme_file_path.add_icon_theme (theme); | ||
1766 | 252 | theme = new Gtk.IconTheme (); | ||
1767 | 253 | |||
1768 | 254 | theme.set_custom_theme ("unity-icon-theme"); | ||
1769 | 255 | theme_file_path.add_icon_theme (theme); | ||
1770 | 256 | theme.set_custom_theme ("Web"); | ||
1771 | 257 | theme_file_path.add_icon_theme (theme); | ||
1772 | 258 | |||
1773 | 259 | theme_file_path.found_icon_path.connect ((theme, filepath) => { | ||
1774 | 260 | try | ||
1775 | 261 | { | ||
1776 | 262 | child.icon = new Gdk.Pixbuf.from_file (filepath); | ||
1777 | 263 | } | ||
1778 | 264 | catch (Error e) | ||
1779 | 265 | { | ||
1780 | 266 | warning (@"Could not load from $filepath"); | ||
1781 | 267 | } | ||
1782 | 268 | }); | ||
1783 | 269 | theme_file_path.failed.connect (() => { | ||
1784 | 270 | // we didn't get an icon, so just load the failcon | ||
1785 | 271 | try | ||
1786 | 272 | { | ||
1787 | 273 | var default_theme = Gtk.IconTheme.get_default (); | ||
1788 | 274 | child.icon = default_theme.load_icon(Gtk.STOCK_MISSING_IMAGE, 48, 0); | ||
1789 | 275 | } | ||
1790 | 276 | catch (Error e) | ||
1791 | 277 | { | ||
1792 | 278 | warning (@"Could not load any icon for %s", icon_name); | ||
1793 | 279 | } | ||
1794 | 280 | }); | ||
1795 | 281 | theme_file_path.get_icon_filepath (icon_name); | ||
1796 | 282 | } | ||
1797 | 283 | |||
1798 | 284 | private bool try_load_from_file (string filepath) | ||
1799 | 285 | { | ||
1800 | 286 | Gdk.Pixbuf pixbuf = null; | ||
1801 | 287 | if (FileUtils.test(filepath, FileTest.IS_REGULAR)) | ||
1802 | 288 | { | ||
1803 | 289 | try | ||
1804 | 290 | { | ||
1805 | 291 | pixbuf = new Gdk.Pixbuf.from_file_at_scale(filepath, | ||
1806 | 292 | 48, 48, true); | ||
1807 | 293 | } | ||
1808 | 294 | catch (Error e) | ||
1809 | 295 | { | ||
1810 | 296 | warning ("Unable to load image from file '%s': %s", | ||
1811 | 297 | filepath, | ||
1812 | 298 | e.message); | ||
1813 | 299 | } | ||
1814 | 300 | |||
1815 | 301 | if (pixbuf is Gdk.Pixbuf) | ||
1816 | 302 | { | ||
1817 | 303 | child.icon = pixbuf; | ||
1818 | 304 | return true; | ||
1819 | 305 | } | ||
1820 | 306 | } | ||
1821 | 307 | return false; | ||
1822 | 308 | } | ||
1823 | 207 | } | 309 | } |
1824 | 208 | } | 310 | } |
1825 | 209 | 311 | ||
1826 | === modified file 'unity-private/launcher/scrollerchild.vala' | |||
1827 | --- unity-private/launcher/scrollerchild.vala 2010-06-24 11:22:50 +0000 | |||
1828 | +++ unity-private/launcher/scrollerchild.vala 2010-07-22 16:19:42 +0000 | |||
1829 | @@ -24,6 +24,23 @@ | |||
1830 | 24 | 24 | ||
1831 | 25 | namespace Unity.Launcher | 25 | namespace Unity.Launcher |
1832 | 26 | { | 26 | { |
1833 | 27 | const string HONEYCOMB_MASK_FILE = Unity.PKGDATADIR | ||
1834 | 28 | + "/honeycomb-mask.png"; | ||
1835 | 29 | const string MENU_BG_FILE = Unity.PKGDATADIR | ||
1836 | 30 | + "/tight_check_4px.png"; | ||
1837 | 31 | |||
1838 | 32 | const float WIGGLE_SIZE = 5; // how many degree's to wiggle on either side. | ||
1839 | 33 | const int WIGGLE_FREQUENCY = 5; // x times a second | ||
1840 | 34 | const int WIGGLE_RUN_LENGTH = 5000; // 5 seconds of wiggle | ||
1841 | 35 | const int WIGGLE_PAUSE_LENGTH = 20; // followed by 20 seconds of no wiggle | ||
1842 | 36 | |||
1843 | 37 | private enum AnimState { | ||
1844 | 38 | RISING, | ||
1845 | 39 | LOOPING, | ||
1846 | 40 | FALLING, | ||
1847 | 41 | STOPPED | ||
1848 | 42 | } | ||
1849 | 43 | |||
1850 | 27 | public enum PinType { | 44 | public enum PinType { |
1851 | 28 | UNPINNED, | 45 | UNPINNED, |
1852 | 29 | PINNED, | 46 | PINNED, |
1853 | @@ -31,12 +48,8 @@ | |||
1854 | 31 | NEVER | 48 | NEVER |
1855 | 32 | } | 49 | } |
1856 | 33 | 50 | ||
1858 | 34 | public abstract class ScrollerChild : Ctk.Actor | 51 | public class ScrollerChild : Ctk.Actor |
1859 | 35 | { | 52 | { |
1860 | 36 | construct | ||
1861 | 37 | { | ||
1862 | 38 | } | ||
1863 | 39 | |||
1864 | 40 | public Gdk.Pixbuf icon {get; set;} | 53 | public Gdk.Pixbuf icon {get; set;} |
1865 | 41 | public PinType pin_type; | 54 | public PinType pin_type; |
1866 | 42 | public float position {get; set;} | 55 | public float position {get; set;} |
1867 | @@ -47,8 +60,6 @@ | |||
1868 | 47 | public float rotation {get; set;} | 60 | public float rotation {get; set;} |
1869 | 48 | public ScrollerChildController controller; // this sucks. shouldn't be here, can't help it. | 61 | public ScrollerChildController controller; // this sucks. shouldn't be here, can't help it. |
1870 | 49 | 62 | ||
1871 | 50 | public abstract void force_rotation_jump (float degrees); | ||
1872 | 51 | |||
1873 | 52 | public string to_string () | 63 | public string to_string () |
1874 | 53 | { | 64 | { |
1875 | 54 | return "A scroller child; running: %s, active: %s, position: %f, opacity %f".printf ( | 65 | return "A scroller child; running: %s, active: %s, position: %f, opacity %f".printf ( |
1876 | @@ -57,5 +68,535 @@ | |||
1877 | 57 | position, | 68 | position, |
1878 | 58 | opacity); | 69 | opacity); |
1879 | 59 | } | 70 | } |
1880 | 71 | |||
1881 | 72 | private UnityIcon processed_icon; | ||
1882 | 73 | private ThemeImage active_indicator; | ||
1883 | 74 | private ThemeImage running_indicator; | ||
1884 | 75 | private Gdk.Pixbuf honeycomb_mask; | ||
1885 | 76 | |||
1886 | 77 | // effects | ||
1887 | 78 | private Ctk.EffectDropShadow effect_drop_shadow; | ||
1888 | 79 | private Ctk.EffectGlow effect_icon_glow; | ||
1889 | 80 | |||
1890 | 81 | // animations | ||
1891 | 82 | private Clutter.Animation active_indicator_anim; | ||
1892 | 83 | private Clutter.Animation running_indicator_anim; | ||
1893 | 84 | private Clutter.Animation rotate_anim; | ||
1894 | 85 | private Clutter.Timeline wiggle_timeline; | ||
1895 | 86 | private Clutter.Timeline glow_timeline; | ||
1896 | 87 | private Clutter.Timeline rotate_timeline; | ||
1897 | 88 | private AnimState glow_state; | ||
1898 | 89 | private AnimState wiggle_state; | ||
1899 | 90 | private AnimState rotate_state; | ||
1900 | 91 | |||
1901 | 92 | private float old_rotate_value = 0.0f; | ||
1902 | 93 | |||
1903 | 94 | construct | ||
1904 | 95 | { | ||
1905 | 96 | load_textures (); | ||
1906 | 97 | position = 0.0f; | ||
1907 | 98 | |||
1908 | 99 | //icon glow | ||
1909 | 100 | glow_timeline = new Clutter.Timeline (1); | ||
1910 | 101 | wiggle_timeline = new Clutter.Timeline (1); | ||
1911 | 102 | rotate_timeline = new Clutter.Timeline (1); | ||
1912 | 103 | |||
1913 | 104 | glow_timeline.new_frame.connect (on_glow_timeline_new_frame); | ||
1914 | 105 | wiggle_timeline.new_frame.connect (on_wiggle_timeline_new_frame); | ||
1915 | 106 | rotate_timeline.new_frame.connect (on_rotate_timeline_new_frame); | ||
1916 | 107 | |||
1917 | 108 | notify["rotation"].connect (on_rotation_changed); | ||
1918 | 109 | } | ||
1919 | 110 | |||
1920 | 111 | ~ScrollerChild () | ||
1921 | 112 | { | ||
1922 | 113 | running_indicator.unparent (); | ||
1923 | 114 | active_indicator.unparent (); | ||
1924 | 115 | } | ||
1925 | 116 | |||
1926 | 117 | /* private methods */ | ||
1927 | 118 | private void load_textures () | ||
1928 | 119 | { | ||
1929 | 120 | active_indicator = new ThemeImage ("application-selected"); | ||
1930 | 121 | running_indicator = new ThemeImage ("application-running"); | ||
1931 | 122 | |||
1932 | 123 | active_indicator.set_parent (this); | ||
1933 | 124 | running_indicator.set_parent (this); | ||
1934 | 125 | active_indicator.set_opacity (0); | ||
1935 | 126 | running_indicator.set_opacity (0); | ||
1936 | 127 | |||
1937 | 128 | try | ||
1938 | 129 | { | ||
1939 | 130 | honeycomb_mask = new Gdk.Pixbuf.from_file(HONEYCOMB_MASK_FILE); | ||
1940 | 131 | } | ||
1941 | 132 | catch (Error e) | ||
1942 | 133 | { | ||
1943 | 134 | warning ("Unable to load asset %s: %s", | ||
1944 | 135 | HONEYCOMB_MASK_FILE, | ||
1945 | 136 | e.message); | ||
1946 | 137 | } | ||
1947 | 138 | |||
1948 | 139 | processed_icon = new UnityIcon (null, null); | ||
1949 | 140 | processed_icon.set_size (48, 48); | ||
1950 | 141 | processed_icon.set_parent (this); | ||
1951 | 142 | |||
1952 | 143 | notify["icon"].connect (on_icon_changed); | ||
1953 | 144 | notify["running"].connect (on_running_changed); | ||
1954 | 145 | notify["active"].connect (on_active_changed); | ||
1955 | 146 | notify["activating"].connect (on_activating_changed); | ||
1956 | 147 | notify["needs-attention"].connect (on_needs_attention_changed); | ||
1957 | 148 | |||
1958 | 149 | // just trigger some notifications now to set inital state | ||
1959 | 150 | on_running_changed (); | ||
1960 | 151 | on_active_changed (); | ||
1961 | 152 | on_rotation_changed (); | ||
1962 | 153 | } | ||
1963 | 154 | |||
1964 | 155 | public Clutter.Actor get_content () | ||
1965 | 156 | { | ||
1966 | 157 | return processed_icon; | ||
1967 | 158 | } | ||
1968 | 159 | |||
1969 | 160 | /* alpha helpers */ | ||
1970 | 161 | private static float get_ease_out_sine (float alpha) | ||
1971 | 162 | { | ||
1972 | 163 | return (float)(Math.sin ((Math.PI_2 * alpha))); | ||
1973 | 164 | } | ||
1974 | 165 | |||
1975 | 166 | private static float get_circular_alpha (float alpha) | ||
1976 | 167 | { | ||
1977 | 168 | //float sine = (float)(Math.sin (-Math.PI + (alpha * (Math.PI * 2)))); | ||
1978 | 169 | var sine = Math.sin ((alpha * (Math.PI * 2)) - Math.PI); | ||
1979 | 170 | return Math.fmaxf(((float)sine / 2.0f) + 0.5f, 0.0f);; | ||
1980 | 171 | } | ||
1981 | 172 | /* animation callbacks */ | ||
1982 | 173 | |||
1983 | 174 | private void on_rotate_timeline_new_frame () | ||
1984 | 175 | { | ||
1985 | 176 | float progress = (float)rotate_timeline.get_progress (); | ||
1986 | 177 | switch (rotate_state) | ||
1987 | 178 | { | ||
1988 | 179 | case AnimState.RISING: | ||
1989 | 180 | rotate_anim_rising (progress); | ||
1990 | 181 | break; | ||
1991 | 182 | |||
1992 | 183 | case AnimState.STOPPED: | ||
1993 | 184 | rotate_timeline.stop (); | ||
1994 | 185 | break; | ||
1995 | 186 | } | ||
1996 | 187 | processed_icon.do_queue_redraw (); | ||
1997 | 188 | } | ||
1998 | 189 | |||
1999 | 190 | private void rotate_anim_rising (float progress) | ||
2000 | 191 | { | ||
2001 | 192 | progress = get_ease_out_sine (progress); | ||
2002 | 193 | var diff = rotation - old_rotate_value; | ||
2003 | 194 | float rotate_val = old_rotate_value + (progress * diff); | ||
2004 | 195 | |||
2005 | 196 | processed_icon.rotation = rotate_val; | ||
2006 | 197 | if (progress >= 1.0) | ||
2007 | 198 | { | ||
2008 | 199 | rotate_state = AnimState.STOPPED; | ||
2009 | 200 | rotate_timeline.stop (); | ||
2010 | 201 | } | ||
2011 | 202 | } | ||
2012 | 203 | |||
2013 | 204 | public void force_rotation_jump (float degrees) | ||
2014 | 205 | { | ||
2015 | 206 | processed_icon.rotation = degrees; | ||
2016 | 207 | rotation = degrees; | ||
2017 | 208 | rotate_state = AnimState.STOPPED; | ||
2018 | 209 | rotate_timeline.stop (); | ||
2019 | 210 | do_queue_redraw (); | ||
2020 | 211 | } | ||
2021 | 212 | |||
2022 | 213 | private void on_glow_timeline_new_frame () | ||
2023 | 214 | { | ||
2024 | 215 | float progress = (float)glow_timeline.get_progress (); | ||
2025 | 216 | switch (glow_state) | ||
2026 | 217 | { | ||
2027 | 218 | case AnimState.RISING: | ||
2028 | 219 | glow_anim_rising (progress); | ||
2029 | 220 | break; | ||
2030 | 221 | |||
2031 | 222 | case AnimState.LOOPING: | ||
2032 | 223 | glow_anim_looping (progress); | ||
2033 | 224 | break; | ||
2034 | 225 | |||
2035 | 226 | case AnimState.FALLING: | ||
2036 | 227 | glow_anim_falling (progress); | ||
2037 | 228 | break; | ||
2038 | 229 | |||
2039 | 230 | default: | ||
2040 | 231 | glow_state = AnimState.STOPPED; | ||
2041 | 232 | glow_timeline.stop (); | ||
2042 | 233 | break; | ||
2043 | 234 | } | ||
2044 | 235 | |||
2045 | 236 | processed_icon.do_queue_redraw (); | ||
2046 | 237 | } | ||
2047 | 238 | |||
2048 | 239 | private float previous_glow_alpha = 0.0f; | ||
2049 | 240 | private void glow_anim_rising (float progress) | ||
2050 | 241 | { | ||
2051 | 242 | progress = get_ease_out_sine (progress); | ||
2052 | 243 | effect_icon_glow.set_opacity (progress); | ||
2053 | 244 | previous_glow_alpha = progress; | ||
2054 | 245 | if (progress >= 1.0) | ||
2055 | 246 | { | ||
2056 | 247 | glow_state = AnimState.LOOPING; | ||
2057 | 248 | glow_timeline.stop (); | ||
2058 | 249 | glow_timeline.set_duration (LONG_DELAY); | ||
2059 | 250 | glow_timeline.set_loop (true); | ||
2060 | 251 | glow_timeline.start (); | ||
2061 | 252 | return; | ||
2062 | 253 | } | ||
2063 | 254 | } | ||
2064 | 255 | |||
2065 | 256 | private void glow_anim_looping (float progress) | ||
2066 | 257 | { | ||
2067 | 258 | progress = 1.0f - get_circular_alpha (progress); | ||
2068 | 259 | effect_icon_glow.set_opacity (progress); | ||
2069 | 260 | previous_glow_alpha = progress; | ||
2070 | 261 | processed_icon.do_queue_redraw (); | ||
2071 | 262 | } | ||
2072 | 263 | |||
2073 | 264 | private void glow_anim_falling (float progress) | ||
2074 | 265 | { | ||
2075 | 266 | float alpha_length = previous_glow_alpha; | ||
2076 | 267 | effect_icon_glow.set_opacity (alpha_length - (progress * alpha_length)); | ||
2077 | 268 | |||
2078 | 269 | if (progress >= 1.0) | ||
2079 | 270 | { | ||
2080 | 271 | glow_state = AnimState.STOPPED; | ||
2081 | 272 | glow_timeline.stop (); | ||
2082 | 273 | glow_timeline.set_loop (false); | ||
2083 | 274 | } | ||
2084 | 275 | } | ||
2085 | 276 | |||
2086 | 277 | private void on_wiggle_timeline_new_frame () | ||
2087 | 278 | { | ||
2088 | 279 | float progress = (float)wiggle_timeline.get_progress (); | ||
2089 | 280 | |||
2090 | 281 | switch (wiggle_state) | ||
2091 | 282 | { | ||
2092 | 283 | case AnimState.RISING: | ||
2093 | 284 | wiggle_anim_rising (progress); | ||
2094 | 285 | break; | ||
2095 | 286 | |||
2096 | 287 | case AnimState.LOOPING: | ||
2097 | 288 | wiggle_anim_looping (progress); | ||
2098 | 289 | break; | ||
2099 | 290 | |||
2100 | 291 | case AnimState.FALLING: | ||
2101 | 292 | wiggle_anim_falling (progress); | ||
2102 | 293 | break; | ||
2103 | 294 | |||
2104 | 295 | default: | ||
2105 | 296 | wiggle_state = AnimState.STOPPED; | ||
2106 | 297 | wiggle_timeline.stop (); | ||
2107 | 298 | break; | ||
2108 | 299 | } | ||
2109 | 300 | |||
2110 | 301 | processed_icon.do_queue_redraw (); | ||
2111 | 302 | } | ||
2112 | 303 | |||
2113 | 304 | private float previous_wiggle_alpha = 0.0f; | ||
2114 | 305 | private void wiggle_anim_rising (float progress) | ||
2115 | 306 | { | ||
2116 | 307 | progress = get_ease_out_sine (progress); | ||
2117 | 308 | processed_icon.set_rotation (Clutter.RotateAxis.Z_AXIS, progress * WIGGLE_SIZE, | ||
2118 | 309 | 25.0f, 25.0f, 0.0f); | ||
2119 | 310 | previous_wiggle_alpha = progress; | ||
2120 | 311 | if (progress >= 1.0) | ||
2121 | 312 | { | ||
2122 | 313 | wiggle_state = AnimState.LOOPING; | ||
2123 | 314 | wiggle_timeline.stop (); | ||
2124 | 315 | wiggle_timeline.set_duration (WIGGLE_RUN_LENGTH); | ||
2125 | 316 | wiggle_timeline.set_loop (true); | ||
2126 | 317 | wiggle_timeline.start (); | ||
2127 | 318 | return; | ||
2128 | 319 | } | ||
2129 | 320 | } | ||
2130 | 321 | |||
2131 | 322 | private void wiggle_anim_looping (float progress) | ||
2132 | 323 | { | ||
2133 | 324 | if (progress >= 1.0) | ||
2134 | 325 | { | ||
2135 | 326 | wiggle_state = AnimState.FALLING; | ||
2136 | 327 | wiggle_timeline.stop (); | ||
2137 | 328 | wiggle_timeline.set_loop (false); | ||
2138 | 329 | wiggle_timeline.start (); | ||
2139 | 330 | } | ||
2140 | 331 | |||
2141 | 332 | int frequency = WIGGLE_FREQUENCY * (WIGGLE_RUN_LENGTH / 1000); | ||
2142 | 333 | progress = get_circular_alpha (Math.fmodf (progress * frequency, 1.0f)); | ||
2143 | 334 | progress = (1.0f - progress) * 2.0f - 1.0f; | ||
2144 | 335 | processed_icon.set_rotation (Clutter.RotateAxis.Z_AXIS, progress * WIGGLE_SIZE, | ||
2145 | 336 | 25.0f, 25.0f, 0.0f); | ||
2146 | 337 | processed_icon.do_queue_redraw (); | ||
2147 | 338 | previous_wiggle_alpha = progress; | ||
2148 | 339 | |||
2149 | 340 | |||
2150 | 341 | } | ||
2151 | 342 | |||
2152 | 343 | private bool check_continue_wiggle () | ||
2153 | 344 | { | ||
2154 | 345 | if (needs_attention) | ||
2155 | 346 | { | ||
2156 | 347 | wiggle_timeline.set_duration (500 / WIGGLE_FREQUENCY); | ||
2157 | 348 | wiggle_state = AnimState.RISING; | ||
2158 | 349 | wiggle_timeline.start (); | ||
2159 | 350 | } | ||
2160 | 351 | return false; | ||
2161 | 352 | } | ||
2162 | 353 | |||
2163 | 354 | private void wiggle_anim_falling (float progress) | ||
2164 | 355 | { | ||
2165 | 356 | float alpha_length = previous_wiggle_alpha; | ||
2166 | 357 | float angle = alpha_length - (progress * alpha_length); | ||
2167 | 358 | processed_icon.set_rotation (Clutter.RotateAxis.Z_AXIS, angle, | ||
2168 | 359 | 25.0f, 25.0f, 0.0f); | ||
2169 | 360 | |||
2170 | 361 | if (progress >= 1.0) | ||
2171 | 362 | { | ||
2172 | 363 | wiggle_state = AnimState.STOPPED; | ||
2173 | 364 | wiggle_timeline.stop (); | ||
2174 | 365 | wiggle_timeline.set_loop (false); | ||
2175 | 366 | GLib.Timeout.add_seconds (WIGGLE_PAUSE_LENGTH, check_continue_wiggle); | ||
2176 | 367 | } | ||
2177 | 368 | } | ||
2178 | 369 | |||
2179 | 370 | /* notifications */ | ||
2180 | 371 | private void on_icon_changed () | ||
2181 | 372 | { | ||
2182 | 373 | if (icon is Gdk.Pixbuf) | ||
2183 | 374 | { | ||
2184 | 375 | Gdk.Pixbuf scaled_buf; | ||
2185 | 376 | int max_size = 48; | ||
2186 | 377 | if (!Unity.pixbuf_is_tile (icon)) | ||
2187 | 378 | max_size = 40; | ||
2188 | 379 | |||
2189 | 380 | if (icon.get_width () > max_size || icon.get_height () > max_size) | ||
2190 | 381 | { | ||
2191 | 382 | scaled_buf = icon.scale_simple (max_size, max_size, Gdk.InterpType.HYPER); | ||
2192 | 383 | } | ||
2193 | 384 | else | ||
2194 | 385 | { | ||
2195 | 386 | scaled_buf = icon; | ||
2196 | 387 | } | ||
2197 | 388 | |||
2198 | 389 | Gdk.Pixbuf color_buf = new Gdk.Pixbuf (Gdk.Colorspace.RGB, true, 8, 1, 1); | ||
2199 | 390 | uint red, green, blue; | ||
2200 | 391 | Unity.get_average_color (scaled_buf, out red, out green, out blue); | ||
2201 | 392 | unowned uchar[] pixels = color_buf.get_pixels (); | ||
2202 | 393 | pixels[0] = (uchar)red; | ||
2203 | 394 | pixels[1] = (uchar)green; | ||
2204 | 395 | pixels[2] = (uchar)blue; | ||
2205 | 396 | pixels[3] = 255; | ||
2206 | 397 | |||
2207 | 398 | var tex = GtkClutter.texture_new_from_pixbuf (scaled_buf); | ||
2208 | 399 | var color = GtkClutter.texture_new_from_pixbuf (color_buf); | ||
2209 | 400 | |||
2210 | 401 | processed_icon = new UnityIcon (tex as Clutter.Texture, color as Clutter.Texture); | ||
2211 | 402 | processed_icon.set_parent (this); | ||
2212 | 403 | processed_icon.rotation = rotation; | ||
2213 | 404 | |||
2214 | 405 | this.effect_drop_shadow = new Ctk.EffectDropShadow (5.0f, 0, 2); | ||
2215 | 406 | effect_drop_shadow.set_opacity (0.4f); | ||
2216 | 407 | this.effect_drop_shadow.set_margin (5); | ||
2217 | 408 | this.processed_icon.add_effect (effect_drop_shadow); | ||
2218 | 409 | |||
2219 | 410 | do_queue_redraw (); | ||
2220 | 411 | } | ||
2221 | 412 | } | ||
2222 | 413 | |||
2223 | 414 | private void on_running_changed () | ||
2224 | 415 | { | ||
2225 | 416 | uint target_opacity = 0; | ||
2226 | 417 | if (running) | ||
2227 | 418 | target_opacity = 255; | ||
2228 | 419 | |||
2229 | 420 | if (running_indicator_anim is Clutter.Animation) | ||
2230 | 421 | running_indicator_anim.completed (); | ||
2231 | 422 | |||
2232 | 423 | running_indicator_anim = running_indicator.animate (Clutter.AnimationMode.EASE_IN_OUT_SINE, | ||
2233 | 424 | SHORT_DELAY, | ||
2234 | 425 | "opacity", target_opacity); | ||
2235 | 426 | } | ||
2236 | 427 | |||
2237 | 428 | private void on_active_changed () | ||
2238 | 429 | { | ||
2239 | 430 | uint target_opacity = 0; | ||
2240 | 431 | if (active) | ||
2241 | 432 | target_opacity = 255; | ||
2242 | 433 | |||
2243 | 434 | if (active_indicator_anim is Clutter.Animation) | ||
2244 | 435 | active_indicator_anim.completed (); | ||
2245 | 436 | active_indicator_anim = active_indicator.animate (Clutter.AnimationMode.EASE_IN_OUT_SINE, | ||
2246 | 437 | SHORT_DELAY, | ||
2247 | 438 | "opacity", target_opacity); | ||
2248 | 439 | } | ||
2249 | 440 | |||
2250 | 441 | private void on_rotation_changed () | ||
2251 | 442 | { | ||
2252 | 443 | old_rotate_value = processed_icon.rotation; | ||
2253 | 444 | |||
2254 | 445 | if (rotate_timeline is Clutter.Timeline == false) | ||
2255 | 446 | return; | ||
2256 | 447 | |||
2257 | 448 | if (rotate_timeline.is_playing ()) | ||
2258 | 449 | { | ||
2259 | 450 | rotate_timeline.stop (); | ||
2260 | 451 | processed_icon.rotation = old_rotate_value; | ||
2261 | 452 | } | ||
2262 | 453 | |||
2263 | 454 | rotate_timeline.set_duration (300); | ||
2264 | 455 | rotate_state = AnimState.RISING; | ||
2265 | 456 | rotate_timeline.start (); | ||
2266 | 457 | } | ||
2267 | 458 | |||
2268 | 459 | private void on_activating_changed () | ||
2269 | 460 | { | ||
2270 | 461 | if (glow_timeline.is_playing () && activating == false) | ||
2271 | 462 | { | ||
2272 | 463 | glow_timeline.stop (); | ||
2273 | 464 | glow_timeline.set_duration (SHORT_DELAY); | ||
2274 | 465 | glow_state = AnimState.FALLING; | ||
2275 | 466 | glow_timeline.start (); | ||
2276 | 467 | } | ||
2277 | 468 | else if (glow_timeline.is_playing () == false && activating) | ||
2278 | 469 | { | ||
2279 | 470 | effect_icon_glow = new Ctk.EffectGlow (); | ||
2280 | 471 | Clutter.Color c = Clutter.Color () { | ||
2281 | 472 | red = 255, | ||
2282 | 473 | green = 255, | ||
2283 | 474 | blue = 255, | ||
2284 | 475 | alpha = 255 | ||
2285 | 476 | }; | ||
2286 | 477 | effect_icon_glow.set_background_texture (honeycomb_mask); | ||
2287 | 478 | effect_icon_glow.set_color (c); | ||
2288 | 479 | effect_icon_glow.set_opacity (1.0f); | ||
2289 | 480 | processed_icon.add_effect (effect_icon_glow); | ||
2290 | 481 | effect_icon_glow.set_margin (6); | ||
2291 | 482 | |||
2292 | 483 | glow_timeline.set_duration (SHORT_DELAY); | ||
2293 | 484 | glow_state = AnimState.RISING; | ||
2294 | 485 | glow_timeline.start (); | ||
2295 | 486 | } | ||
2296 | 487 | } | ||
2297 | 488 | |||
2298 | 489 | private void on_needs_attention_changed () | ||
2299 | 490 | { | ||
2300 | 491 | if (needs_attention && wiggle_timeline.is_playing () == false) | ||
2301 | 492 | { | ||
2302 | 493 | //start wiggling | ||
2303 | 494 | wiggle_timeline.set_duration (500 / WIGGLE_FREQUENCY); | ||
2304 | 495 | wiggle_state = AnimState.RISING; | ||
2305 | 496 | wiggle_timeline.start (); | ||
2306 | 497 | } | ||
2307 | 498 | else if (needs_attention == false && wiggle_timeline.is_playing ()) | ||
2308 | 499 | { | ||
2309 | 500 | //stop wiggling | ||
2310 | 501 | wiggle_timeline.stop (); | ||
2311 | 502 | wiggle_timeline.set_duration (500 / WIGGLE_FREQUENCY); | ||
2312 | 503 | wiggle_state = AnimState.FALLING; | ||
2313 | 504 | wiggle_timeline.start (); | ||
2314 | 505 | } | ||
2315 | 506 | } | ||
2316 | 507 | |||
2317 | 508 | /* clutter overrides */ | ||
2318 | 509 | public override void get_preferred_width (float for_height, | ||
2319 | 510 | out float minimum_width, | ||
2320 | 511 | out float natural_width) | ||
2321 | 512 | { | ||
2322 | 513 | float nat, min; | ||
2323 | 514 | processed_icon.get_preferred_width (for_height, out min, out nat); | ||
2324 | 515 | natural_width = nat; | ||
2325 | 516 | minimum_width = min; | ||
2326 | 517 | |||
2327 | 518 | running_indicator.get_preferred_width (for_height, out min, out nat); | ||
2328 | 519 | natural_width += nat; | ||
2329 | 520 | |||
2330 | 521 | active_indicator.get_preferred_width (for_height, out min, out nat); | ||
2331 | 522 | natural_width += nat; | ||
2332 | 523 | } | ||
2333 | 524 | |||
2334 | 525 | public override void get_preferred_height (float for_width, | ||
2335 | 526 | out float minimum_height, | ||
2336 | 527 | out float natural_height) | ||
2337 | 528 | { | ||
2338 | 529 | natural_height = 48; | ||
2339 | 530 | minimum_height = 48; | ||
2340 | 531 | } | ||
2341 | 532 | |||
2342 | 533 | public override void allocate (Clutter.ActorBox box, Clutter.AllocationFlags flags) | ||
2343 | 534 | { | ||
2344 | 535 | float x, y; | ||
2345 | 536 | x = 0; | ||
2346 | 537 | y = 0; | ||
2347 | 538 | base.allocate (box, flags); | ||
2348 | 539 | |||
2349 | 540 | Clutter.ActorBox child_box = Clutter.ActorBox (); | ||
2350 | 541 | |||
2351 | 542 | //allocate the running indicator first | ||
2352 | 543 | float width, height, n_width, n_height; | ||
2353 | 544 | running_indicator.get_preferred_width (58, out n_width, out width); | ||
2354 | 545 | running_indicator.get_preferred_height (58, out n_height, out height); | ||
2355 | 546 | child_box.x1 = 0; | ||
2356 | 547 | child_box.y1 = (box.get_height () - height) / 2.0f; | ||
2357 | 548 | child_box.x2 = child_box.x1 + width; | ||
2358 | 549 | child_box.y2 = child_box.y1 + height; | ||
2359 | 550 | running_indicator.allocate (child_box, flags); | ||
2360 | 551 | x += child_box.get_width (); | ||
2361 | 552 | |||
2362 | 553 | //allocate the icon | ||
2363 | 554 | processed_icon.get_preferred_width (48, out width, out n_width); | ||
2364 | 555 | processed_icon.get_preferred_height (48, out height, out n_height); | ||
2365 | 556 | child_box.x1 = (box.get_width () - width) / 2.0f; | ||
2366 | 557 | child_box.y1 = y; | ||
2367 | 558 | child_box.x2 = child_box.x1 + 48; | ||
2368 | 559 | child_box.y2 = child_box.y1 + height; | ||
2369 | 560 | processed_icon.allocate (child_box, flags); | ||
2370 | 561 | |||
2371 | 562 | //allocate the active indicator | ||
2372 | 563 | active_indicator.get_preferred_width (48, out n_width, out width); | ||
2373 | 564 | active_indicator.get_preferred_height (48, out n_height, out height); | ||
2374 | 565 | child_box.x1 = box.get_width () - width; | ||
2375 | 566 | child_box.y1 = (box.get_height () - height) / 2.0f; | ||
2376 | 567 | child_box.x2 = child_box.x1 + width; | ||
2377 | 568 | child_box.y2 = child_box.y1 + height; | ||
2378 | 569 | active_indicator.allocate (child_box, flags); | ||
2379 | 570 | |||
2380 | 571 | } | ||
2381 | 572 | |||
2382 | 573 | public override void pick (Clutter.Color color) | ||
2383 | 574 | { | ||
2384 | 575 | base.pick (color); | ||
2385 | 576 | } | ||
2386 | 577 | |||
2387 | 578 | public override void paint () | ||
2388 | 579 | { | ||
2389 | 580 | active_indicator.paint (); | ||
2390 | 581 | running_indicator.paint (); | ||
2391 | 582 | |||
2392 | 583 | processed_icon.paint (); | ||
2393 | 584 | } | ||
2394 | 585 | |||
2395 | 586 | public override void map () | ||
2396 | 587 | { | ||
2397 | 588 | base.map (); | ||
2398 | 589 | running_indicator.map (); | ||
2399 | 590 | active_indicator.map (); | ||
2400 | 591 | processed_icon.map (); | ||
2401 | 592 | } | ||
2402 | 593 | |||
2403 | 594 | public override void unmap () | ||
2404 | 595 | { | ||
2405 | 596 | base.unmap (); | ||
2406 | 597 | running_indicator.unmap (); | ||
2407 | 598 | active_indicator.unmap (); | ||
2408 | 599 | processed_icon.unmap (); | ||
2409 | 600 | } | ||
2410 | 60 | } | 601 | } |
2411 | 61 | } | 602 | } |
2412 | 62 | 603 | ||
2413 | === modified file 'unity/drag-controller.vala' | |||
2414 | --- unity/drag-controller.vala 2010-06-08 09:43:43 +0000 | |||
2415 | +++ unity/drag-controller.vala 2010-07-22 16:19:42 +0000 | |||
2416 | @@ -63,10 +63,12 @@ | |||
2417 | 63 | 63 | ||
2418 | 64 | public void start_drag (Unity.Drag.Model model, float offset_x, float offset_y) | 64 | public void start_drag (Unity.Drag.Model model, float offset_x, float offset_y) |
2419 | 65 | { | 65 | { |
2420 | 66 | |||
2421 | 66 | if (!(this.view is View)) { | 67 | if (!(this.view is View)) { |
2422 | 67 | this.view = new View (model.get_icon ().get_stage () as Clutter.Stage); | 68 | this.view = new View (model.get_icon ().get_stage () as Clutter.Stage); |
2423 | 68 | } | 69 | } |
2424 | 69 | this.view.hook_actor_to_cursor (model.get_icon (), offset_x, offset_y); | 70 | this.view.hook_actor_to_cursor (model.get_icon (), offset_x, offset_y); |
2425 | 71 | |||
2426 | 70 | model.get_icon ().parent_set.connect (rehouse_orphaned_child); | 72 | model.get_icon ().parent_set.connect (rehouse_orphaned_child); |
2427 | 71 | this.model = model; | 73 | this.model = model; |
2428 | 72 | this.drag_start (model); | 74 | this.drag_start (model); |
2429 | @@ -88,7 +90,7 @@ | |||
2430 | 88 | // no parent. so set stage | 90 | // no parent. so set stage |
2431 | 89 | Clutter.Stage stage = old_parent.get_stage () as Clutter.Stage; | 91 | Clutter.Stage stage = old_parent.get_stage () as Clutter.Stage; |
2432 | 90 | actor.set_parent (stage); | 92 | actor.set_parent (stage); |
2434 | 91 | actor.set_position (-10000, -10000); | 93 | actor.set_position (20000, 20000); |
2435 | 92 | } | 94 | } |
2436 | 93 | } | 95 | } |
2437 | 94 | 96 | ||
2438 | 95 | 97 | ||
2439 | === modified file 'unity/drag-view.vala' | |||
2440 | --- unity/drag-view.vala 2010-06-08 09:43:43 +0000 | |||
2441 | +++ unity/drag-view.vala 2010-07-22 16:19:42 +0000 | |||
2442 | @@ -50,7 +50,6 @@ | |||
2443 | 50 | this.offset_y = offset_y; | 50 | this.offset_y = offset_y; |
2444 | 51 | 51 | ||
2445 | 52 | this.hooked_actor = new Clutter.Clone (actor); | 52 | this.hooked_actor = new Clutter.Clone (actor); |
2446 | 53 | this.hooked_actor.unparent (); | ||
2447 | 54 | this.stage.add_actor (this.hooked_actor); | 53 | this.stage.add_actor (this.hooked_actor); |
2448 | 55 | 54 | ||
2449 | 56 | actor.get_transformed_position (out x, out y); | 55 | actor.get_transformed_position (out x, out y); |
2450 | @@ -94,6 +93,8 @@ | |||
2451 | 94 | this.hooked_actor.set_position (event.motion.x - this.offset_x, | 93 | this.hooked_actor.set_position (event.motion.x - this.offset_x, |
2452 | 95 | event.motion.y - this.offset_y); | 94 | event.motion.y - this.offset_y); |
2453 | 96 | this.motion (event.motion.x, event.motion.y); | 95 | this.motion (event.motion.x, event.motion.y); |
2454 | 96 | this.hooked_actor.set_opacity (255); | ||
2455 | 97 | this.hooked_actor.show (); | ||
2456 | 97 | return false; | 98 | return false; |
2457 | 98 | } | 99 | } |
2458 | 99 | 100 | ||
2459 | 100 | 101 | ||
2460 | === modified file 'unity/icon-postprocessor.vala' | |||
2461 | --- unity/icon-postprocessor.vala 2010-06-24 09:10:53 +0000 | |||
2462 | +++ unity/icon-postprocessor.vala 2010-07-22 16:19:42 +0000 | |||
2463 | @@ -254,6 +254,11 @@ | |||
2464 | 254 | g_total = g_total / uint.max (total_caught_pixels, 1); | 254 | g_total = g_total / uint.max (total_caught_pixels, 1); |
2465 | 255 | b_total = b_total / uint.max (total_caught_pixels, 1); | 255 | b_total = b_total / uint.max (total_caught_pixels, 1); |
2466 | 256 | 256 | ||
2467 | 257 | rs_total = rs_total / (width * height); | ||
2468 | 258 | gs_total = gs_total / (width * height); | ||
2469 | 259 | bs_total = bs_total / (width * height); | ||
2470 | 260 | |||
2471 | 261 | |||
2472 | 257 | // get a new super saturated value based on our totals | 262 | // get a new super saturated value based on our totals |
2473 | 258 | if (total_caught_pixels <= 20) | 263 | if (total_caught_pixels <= 20) |
2474 | 259 | { | 264 | { |
2475 | @@ -491,7 +496,9 @@ | |||
2476 | 491 | } | 496 | } |
2477 | 492 | }; | 497 | }; |
2478 | 493 | 498 | ||
2480 | 494 | uchar opacity = self.get_paint_opacity (); | 499 | uchar opacity = self.get_opacity (); |
2481 | 500 | |||
2482 | 501 | //debug (@"opacity is set to $opacity"); | ||
2483 | 495 | 502 | ||
2484 | 496 | self.bg_mat.set_color4ub (opacity, opacity, opacity, opacity); | 503 | self.bg_mat.set_color4ub (opacity, opacity, opacity, opacity); |
2485 | 497 | self.bgcol_material.set_color4ub (opacity, opacity, opacity, opacity); | 504 | self.bgcol_material.set_color4ub (opacity, opacity, opacity, opacity); |
+1