summaryrefslogtreecommitdiff
path: root/unity-private
diff options
authorGord Allott <gord.allott@canonical.com>2010-08-26 10:31:34 +0100
committerGord Allott <gord.allott@canonical.com>2010-08-26 10:31:34 +0100
commit41b81b57db0cbab2f6138351c51bb1090e6ad7a5 (patch)
tree9c896d1c6fc825ff266c3a0aa281faf67a2bdce8 /unity-private
parent862826f4182973a4d62754f61dd2cf34b7d53b67 (diff)
new scroller animations finished
(bzr r433.6.10)
Diffstat (limited to 'unity-private')
-rw-r--r--unity-private/launcher/quicklist-controller.vala1
-rw-r--r--unity-private/launcher/scroller-view.vala81
-rw-r--r--unity-private/launcher/scrollerchild-controller.vala26
3 files changed, 96 insertions, 12 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..1bbf70c66 100644
--- a/unity-private/launcher/scroller-view.vala
+++ b/unity-private/launcher/scroller-view.vala
@@ -191,7 +191,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 +202,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);
@@ -667,14 +668,31 @@ namespace Unity.Launcher
private void move_scroll_position (float pixels, bool check_bounds=false)
{
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 limit = 160.0f;
+ 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 limit = 160.0f;
+ 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 +871,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 +920,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 +990,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 +1008,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);
@@ -1003,8 +1032,29 @@ namespace Unity.Launcher
previous_y_position = event.motion.y;
previous_y_time = event.motion.time;
- // move the scroller by how far we dragged
- move_scroll_position (pixel_diff);
+
+/*
+ if (scroll_position > 0)
+ {
+ float limit = 160.0f * 8;
+ //float new_scroll_position = limit * ( 1 - Math.powf((limit-1)/limit, scroll_position) );
+ float new_scroll_position = (scroll_position + pixel_diff);// * 0.95f;
+ new_scroll_position = limit * ( 1 - Math.powf ((limit - 1) / limit, new_scroll_position));
+ float diff = Math.fmaxf (new_scroll_position - scroll_position, 0);
+ move_scroll_position (diff);
+ }
+ else if (scroll_position < -(get_total_children_height () - get_available_height ()))
+ {
+
+ }
+ else
+ {
+*/
+ // move the scroller by how far we dragged
+ move_scroll_position (pixel_diff);
+/*
+ }
+*/
return true;
}
@@ -1036,12 +1086,15 @@ namespace Unity.Launcher
delta -= 16;
switch (current_phase) {
case (ScrollerPhase.SETTLING):
+ debug ("settling");
do_anim_settle (timeline, msecs);
break;
case (ScrollerPhase.FLUNG):
+ debug ("flung");
do_anim_fling (timeline, msecs);
break;
case (ScrollerPhase.BOUNCE):
+ debug ("bouncing");
do_anim_bounce (timeline, msecs);
break;
case (ScrollerPhase.NONE):
@@ -1087,22 +1140,32 @@ namespace Unity.Launcher
//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)
+ {
+ current_phase = ScrollerPhase.NONE;
+ }
+/*
if (Math.fabsf (scroll_move_amount) < 1.0 &&
(scroll_position > 0 || -scroll_position > total_child_height - height))
{
settle_position = get_aligned_settle_position ();
+ debug (@"settling to: $settle_position");
current_phase = ScrollerPhase.SETTLING;
}
else if (Math.fabsf (scroll_move_amount) < 1.0)
{
current_phase = ScrollerPhase.NONE;
}
+*/
}
private void do_anim_bounce (Clutter.Timeline timeline, int msecs)
diff --git a/unity-private/launcher/scrollerchild-controller.vala b/unity-private/launcher/scrollerchild-controller.vala
index fda7c9f80..d4f5efd7e 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;
@@ -227,7 +239,15 @@ namespace Unity.Launcher
var drag_controller = Unity.Drag.Controller.get_default ();
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);