diff options
| author | Mirco Müller <mirco.mueller@ubuntu.com> | 2010-08-26 16:51:43 +0200 |
|---|---|---|
| committer | Mirco Müller <mirco.mueller@ubuntu.com> | 2010-08-26 16:51:43 +0200 |
| commit | bb2a7f9eed5fe996bf7cf988b524a4b75651aa11 (patch) | |
| tree | e16fde70c46a7aaa0e277e8311e983401b7dbab5 /unity-private | |
| parent | 6d31353d833ccd7d60ee214a333875e2899f943e (diff) | |
| parent | 2cddc0939d225fc336ac9b869d3ba3ec677333a3 (diff) | |
modified:
unity-private/launcher/quicklist-controller.vala unity-private/launcher/scroller-view.vala unity-private/launcher/scrollerchild-controller.vala Merged in gord's unity.scrolling-update branch, since his machine is broken atm. (bzr r463)
Diffstat (limited to 'unity-private')
| -rw-r--r-- | unity-private/launcher/quicklist-controller.vala | 1 | ||||
| -rw-r--r-- | unity-private/launcher/scroller-view.vala | 93 | ||||
| -rw-r--r-- | unity-private/launcher/scrollerchild-controller.vala | 32 |
3 files changed, 102 insertions, 24 deletions
diff --git a/unity-private/launcher/quicklist-controller.vala b/unity-private/launcher/quicklist-controller.vala index 45e929a03..6ed011d23 100644 --- a/unity-private/launcher/quicklist-controller.vala +++ b/unity-private/launcher/quicklist-controller.vala @@ -20,6 +20,7 @@ namespace Unity.Launcher { public static QuicklistController? ql_controller_singleton; + public static bool disable_quicklists = false; public enum QuicklistControllerState { LABEL, diff --git a/unity-private/launcher/scroller-view.vala b/unity-private/launcher/scroller-view.vala index 4da0b3198..1ae1f4d43 100644 --- a/unity-private/launcher/scroller-view.vala +++ b/unity-private/launcher/scroller-view.vala @@ -167,6 +167,7 @@ namespace Unity.Launcher button_release_event.connect (on_button_release_event); motion_event.connect (on_motion_event); enter_event.connect (on_enter_event); + scroll_event.connect (on_scroll_event); leave_event.connect (on_leave_event); notify["is-autoscrolling"].connect (on_auto_scrolling_state_change); @@ -191,7 +192,7 @@ namespace Unity.Launcher drag_controller.drag_start.connect (() => { is_scrolling = false; button_down = false; - is_scrolling = false; + Unity.Launcher.disable_quicklists = true; Clutter.ungrab_pointer (); get_stage ().motion_event.disconnect (on_motion_event); current_phase = ScrollerPhase.FLUNG; @@ -202,6 +203,7 @@ namespace Unity.Launcher }); drag_controller.drag_drop.connect ((drag_model, x, y) => { + Unity.Launcher.disable_quicklists = false; foreach (Clutter.Actor child in model) { child.set_reactive (false); @@ -664,17 +666,32 @@ namespace Unity.Launcher } // will move the scroller by the given pixels - private void move_scroll_position (float pixels, bool check_bounds=false) + private void move_scroll_position (float pixels, bool check_bounds=false, float limit = 160.0f) { scroll_position += pixels; - + float old_scroll_position = scroll_position; if (check_bounds) { scroll_position = Math.fminf (scroll_position, 0); scroll_position = Math.fmaxf (scroll_position, - (get_total_children_height () - get_available_height ())); } + else if (scroll_position > 0) + { + float new_scroll_position = scroll_position; + new_scroll_position = limit * ( 1 - Math.powf ((limit - 1) / limit, new_scroll_position)); + scroll_position = new_scroll_position; + } + else if (scroll_position < -(get_total_children_height () - get_available_height ())) + { + float diff = scroll_position + (get_total_children_height () - get_available_height ()); + float new_scroll_position = limit * ( 1 - Math.powf ((limit - 1) / limit, Math.fabsf (diff))); + new_scroll_position = -(get_total_children_height () - get_available_height ()) - new_scroll_position; + scroll_position = new_scroll_position; + } order_children (true); queue_relayout (); + + scroll_position = old_scroll_position; } /* disables animations and events on children so that they don't @@ -853,14 +870,22 @@ namespace Unity.Launcher if (is_scrolling) { - passthrough_button_release_event (event); + //passthrough_button_release_event (event); + foreach (ScrollerChild child in model) + { + child.grabbed_push = 0; + } is_scrolling = false; + Unity.Launcher.disable_quicklists = false; Clutter.ungrab_pointer (); get_stage ().motion_event.disconnect (on_motion_event); - if ((event.button.time - last_motion_event_time) > 120) + if (scroll_position > 0 || scroll_position < -(get_total_children_height () - get_available_height ())) { current_phase = ScrollerPhase.SETTLING; - settle_position = get_aligned_settle_position (); + if (scroll_position > 0) + settle_position = 0; + else + settle_position = -(get_total_children_height () - get_available_height ()); } else { @@ -894,7 +919,10 @@ namespace Unity.Launcher private bool on_queue_contract_launcher () { if (queue_contract_launcher != 0) - contract_launcher (); + { + current_phase = ScrollerPhase.NONE; + contract_launcher (); + } queue_contract_launcher = 0; return false; } @@ -961,7 +989,6 @@ namespace Unity.Launcher private bool on_motion_event (Clutter.Event event) { - on_autoscroll_motion_check (event.motion.y); var drag_controller = Drag.Controller.get_default (); @@ -980,6 +1007,7 @@ namespace Unity.Launcher */ //var diff = event.motion.y - previous_y_position; is_scrolling = true; + Unity.Launcher.disable_quicklists = true; Unity.global_shell.add_fullscreen_request (this); Clutter.grab_pointer (this); get_stage ().motion_event.connect (on_motion_event); @@ -1012,6 +1040,26 @@ namespace Unity.Launcher return false; } + private bool on_scroll_event (Clutter.Event event) + { + // got a mouse wheel scroll + float modifier = 0.0f; + if (event.scroll.direction == Clutter.ScrollDirection.UP) + modifier = 1.0f; + else if (event.scroll.direction == Clutter.ScrollDirection.DOWN) + modifier = -1.0f; + + if (modifier != 0.0f) + { + float speed = ((48 + spacing) * 3) * 6.0f; + scroll_speed += speed * modifier; + current_phase = ScrollerPhase.FLUNG; + fling_timeline.start (); + } + + return false; + } + /* * Methods to handle our scroller animation, generally todo with the scrolling */ @@ -1034,6 +1082,9 @@ namespace Unity.Launcher { is_animating = true; delta -= 16; + if (fling_timeout_source != 0 && current_phase != ScrollerPhase.NONE) + Source.remove (fling_timeout_source); + switch (current_phase) { case (ScrollerPhase.SETTLING): do_anim_settle (timeline, msecs); @@ -1076,32 +1127,32 @@ namespace Unity.Launcher } + uint fling_timeout_source = 0; private void do_anim_fling (Clutter.Timeline timeline, int msecs) { scroll_speed *= friction; // slow our speed // we devide by 60 because get 60 ticks a second float scroll_move_amount = scroll_speed / 60.0f; - move_scroll_position (scroll_move_amount); + move_scroll_position (scroll_move_amount, false, 60.0f); //after a fling, we have to figure out if we want to change our // scroller phase or not - if(scroll_move_amount <= -1.0 && -scroll_position > total_child_height - height || - scroll_move_amount >= 1.0 && scroll_position > 0) - { - current_phase = ScrollerPhase.BOUNCE; - } - if (Math.fabsf (scroll_move_amount) < 1.0 && - (scroll_position > 0 || -scroll_position > total_child_height - height)) - { - settle_position = get_aligned_settle_position (); - current_phase = ScrollerPhase.SETTLING; - } - else if (Math.fabsf (scroll_move_amount) < 1.0) + if (Math.fabsf (scroll_move_amount) < 1.0) { current_phase = ScrollerPhase.NONE; + fling_timeout_source = GLib.Timeout.add (300, () => + { + current_phase = ScrollerPhase.SETTLING; + if (scroll_position > 0) + settle_position = 0; + else + settle_position = -(get_total_children_height () - get_available_height ()); + fling_timeline.start (); + return false; + }); } } diff --git a/unity-private/launcher/scrollerchild-controller.vala b/unity-private/launcher/scrollerchild-controller.vala index fda7c9f80..fc0e07f21 100644 --- a/unity-private/launcher/scrollerchild-controller.vala +++ b/unity-private/launcher/scrollerchild-controller.vala @@ -115,7 +115,7 @@ namespace Unity.Launcher ensure_menu_state (); return false; } - + private bool no_activate = false; private bool on_press_event (Clutter.Event event) { switch (event.button.button) @@ -124,6 +124,7 @@ namespace Unity.Launcher { last_press_time = event.button.time; button_down = true; + no_activate = false; click_start_pos_x = event.button.x; click_start_pos_y = event.button.y; } break; @@ -142,7 +143,8 @@ namespace Unity.Launcher child.grabbed_push = 0; if (event.button.button == 1 && button_down == true && - event.button.time - last_press_time < 500) + event.button.time - last_press_time < 500 && + no_activate == false) { if (menu is QuicklistController) { @@ -155,6 +157,12 @@ namespace Unity.Launcher activate (); } + else + { + menu.state = QuicklistControllerState.LABEL; + ensure_menu_state (); + } + button_down = false; return false; } @@ -178,6 +186,11 @@ namespace Unity.Launcher if (menu is QuicklistController == false) return; } + if (Unity.Launcher.disable_quicklists) + { + menu.state = QuicklistControllerState.CLOSED; + return; + } if (menu.state == QuicklistControllerState.MENU && QuicklistController.is_menu_open () @@ -203,7 +216,6 @@ namespace Unity.Launcher { Idle.add (() => { - debug ("setting menu to menu"); menu.state = QuicklistControllerState.MENU; menu_state = ScrollerChildControllerMenuState.NO_MENU; return false; @@ -225,9 +237,23 @@ namespace Unity.Launcher private bool on_motion_event (Clutter.Event event) { var drag_controller = Unity.Drag.Controller.get_default (); + if (!Unity.Launcher.disable_quicklists) + { + button_down = false; + return false; + } + if (button_down && drag_controller.is_dragging == false && can_drag ()) { + menu_state = ScrollerChildControllerMenuState.NO_MENU; + ensure_menu_state (); float diff = Math.fabsf (event.motion.x - click_start_pos_x); + float diff_y = Math.fabsf (event.motion.y - click_start_pos_y); + if (diff_y > 5) + { + no_activate = true; + } + if (event.motion.x - click_start_pos_x > 0) { child.grabbed_push = Math.powf (diff, 0.5f); |
