diff options
| author | Gord Allott <gord.allott@canonical.com> | 2010-08-24 16:13:35 +0100 |
|---|---|---|
| committer | Gord Allott <gord.allott@canonical.com> | 2010-08-24 16:13:35 +0100 |
| commit | 12177ddd469d817b5913e44de7dd714ac965108a (patch) | |
| tree | b81edf7a53eee55b8d03a240ac7d4e3dbe40fee6 /unity-private | |
| parent | 3883a49d4106d7de69ef4c4c3568d4fcdea0e3df (diff) | |
working new drag-drop animations, woohoo\!
(bzr r433.6.5)
Diffstat (limited to 'unity-private')
| -rw-r--r-- | unity-private/launcher/scroller-controller.vala | 18 | ||||
| -rw-r--r-- | unity-private/launcher/scroller-view.vala | 135 | ||||
| -rw-r--r-- | unity-private/launcher/scrollerchild.vala | 8 |
3 files changed, 116 insertions, 45 deletions
diff --git a/unity-private/launcher/scroller-controller.vala b/unity-private/launcher/scroller-controller.vala index 3edc54f94..c338d7ba3 100644 --- a/unity-private/launcher/scroller-controller.vala +++ b/unity-private/launcher/scroller-controller.vala @@ -271,6 +271,7 @@ namespace Unity.Launcher child.opacity = 0; child.do_not_render = true; view.drag_indicator_active = true; + view.drag_indicator_space = true; view.do_queue_redraw (); } } @@ -285,7 +286,6 @@ namespace Unity.Launcher last_drag_x = x; last_drag_y = y; - var drag_controller = Drag.Controller.get_default (); // check to see if the data matches any of our children if (!(drag_controller.get_drag_model () is ScrollerChildController)) @@ -294,7 +294,6 @@ namespace Unity.Launcher } ScrollerChild retcont = (drag_controller.get_drag_model () as ScrollerChildController).child; - if (x > view.get_width () + DRAG_SAFE_ZONE && retcont.group_type != ScrollerChild.GroupType.PLACE && retcont.group_type != ScrollerChild.GroupType.SYSTEM) @@ -321,6 +320,20 @@ namespace Unity.Launcher } } + if (x < view.get_width ()) + { + if (view.drag_indicator_space != true) + view.drag_indicator_space = true; + } + else if (x > view.get_width () && x < view.get_width () + DRAG_SAFE_ZONE) + { + if (view.drag_indicator_space != false) + view.drag_indicator_space = false; + + if (view.drag_indicator_active != true) + view.drag_indicator_active = true; + } + // if the actor is not in the model, add it. because its now in there! // find the index at this position int model_index = view.get_model_index_at_y_pos_no_anim (y, true); @@ -332,6 +345,7 @@ namespace Unity.Launcher model.move (retcont, int.max (model_index, 0)); else model.insert (retcont, int.max (model_index, 0)); + if (model_index != view.drag_indicator_index) { view.drag_indicator_index = model_index; diff --git a/unity-private/launcher/scroller-view.vala b/unity-private/launcher/scroller-view.vala index 960ca25a9..01a272cf1 100644 --- a/unity-private/launcher/scroller-view.vala +++ b/unity-private/launcher/scroller-view.vala @@ -53,9 +53,9 @@ namespace Unity.Launcher public Ctk.EffectCache cache {get; construct;} public bool drag_indicator_active {get; set;} + public bool drag_indicator_space {get; set;} public int drag_indicator_index {get; set;} public float drag_indicator_opacity {get; set;} - private float drag_indicator_position = 0.0f; @@ -148,6 +148,7 @@ namespace Unity.Launcher notify["drag-indicator-active"].connect (on_drag_indicator_active_change); notify["drag-indicator-index"].connect (on_drag_indicator_index_change); + notify["drag-indicator-space"].connect (on_drag_indicator_space_change); model.child_added.connect (model_child_added); model.child_removed.connect (model_child_removed); @@ -225,6 +226,8 @@ namespace Unity.Launcher queue_relayout (); }); + drag_indicator_space = false; + } /* hoo-boy this sucks. because of mutter and clutter issues, i have to set @@ -356,22 +359,37 @@ namespace Unity.Launcher return false; } - private void on_drag_indicator_active_change () + private void on_drag_indicator_space_change () { if (drag_indicator_active) { - animate (Clutter.AnimationMode.EASE_OUT_SINE, 150, - "drag-indicator-opacity", 1.0f); - order_children (false); + if (drag_indicator_space) + { + animate (Clutter.AnimationMode.EASE_OUT_SINE, 150, + "drag-indicator-opacity", 0.0f); + order_children (false); + return; + } + else + { + animate (Clutter.AnimationMode.EASE_OUT_SINE, 150, + "drag-indicator-opacity", 1.0f); + order_children (false); + } } else { animate (Clutter.AnimationMode.EASE_OUT_SINE, 150, - "drag-indicator-opacity", 0.0f); + "drag-indicator-opacity", 1.0f); order_children (false); } } + private void on_drag_indicator_active_change () + { + on_drag_indicator_space_change (); + } + private void on_drag_indicator_index_change () { //debug (@"index changed $drag_indicator_index"); @@ -462,6 +480,29 @@ namespace Unity.Launcher public int get_model_index_at_y_pos (float y, bool return_minus_if_fail=false) { + if (view_type == ScrollerViewType.CONTRACTED) + return get_model_index_at_y_pos_pick (y, return_minus_if_fail); + else + return get_model_index_at_y_pos_logic (y, return_minus_if_fail); + } + + private int get_model_index_at_y_pos_logic (float y, bool return_minus_if_fail=false) + { + foreach (ScrollerChild child in model) + { + if (child.position + padding.top + child.get_height () > y) + return model.index_of (child as ScrollerChild); + } + + if (return_minus_if_fail) + return -1; + + return (y < padding.top + model[0].get_height () + spacing) ? 0 : model.size -1; + + } + + private int get_model_index_at_y_pos_pick(float y, bool return_minus_if_fail=false) + { // trying out a different method int iy = (int)y; foreach (ScrollerChild actor in model) @@ -475,13 +516,13 @@ namespace Unity.Launcher if (picked_actor is ScrollerChild == false) { - // we didn't pick a scroller child. lets pick spacing above us - picked_actor = (get_stage () as Clutter.Stage).get_actor_at_pos (Clutter.PickMode.REACTIVE, 25, iy - spacing*2); + // we didn't pick a scroller child. lets pick below us + picked_actor = (get_stage () as Clutter.Stage).get_actor_at_pos (Clutter.PickMode.REACTIVE, 25, iy - 24); if (picked_actor is ScrollerChild == false) { - // again nothing good! lets try again but spacing below - picked_actor = (get_stage () as Clutter.Stage).get_actor_at_pos (Clutter.PickMode.REACTIVE, 25, iy + spacing*2); + // again nothing good! lets try again above us + picked_actor = (get_stage () as Clutter.Stage).get_actor_at_pos (Clutter.PickMode.REACTIVE, 25, iy + 24); if (picked_actor is ScrollerChild == false) { if (return_minus_if_fail) @@ -1160,6 +1201,7 @@ namespace Unity.Launcher assert_not_reached (); } } + queue_relayout (); } private void change_child_position_rotation (ScrollerChild child, @@ -1197,8 +1239,14 @@ namespace Unity.Launcher child.rotation = rotation; if (do_new_position) - child.animate (Clutter.AnimationMode.EASE_OUT_QUAD, 300, - "position", position); + { + if (view_type == ScrollerViewType.CONTRACTED) + child.animate (Clutter.AnimationMode.EASE_IN_OUT_QUAD, 300, + "position", position); + else + child.animate (Clutter.AnimationMode.EASE_OUT_QUINT, 300, + "position", position); + } } } @@ -1216,16 +1264,26 @@ namespace Unity.Launcher int index = 0; foreach (ScrollerChild child in model) { - if (index == drag_indicator_index && drag_indicator_active) - h += 2 + spacing; - if (child.do_not_render) continue; - child.get_preferred_height (get_width (), out min_height, out nat_height); - change_child_position_rotation (child, h + scroll_position, 0.0f, immediate); + if (index == drag_indicator_index && drag_indicator_active) + { + if (drag_indicator_space) + { + child.get_preferred_height (get_width (), out min_height, out nat_height); + h += nat_height + spacing; + } + else + { + h += 2 + spacing; + } + } + else + { + child.get_preferred_height (get_width (), out min_height, out nat_height); + change_child_position_rotation (child, h + scroll_position, 0.0f, immediate); - //if (!(child in draw_ftb || child in draw_ftb)) - // draw_ftb.add (child); - h += nat_height + spacing; + h += nat_height + spacing; + } index += 1; } } @@ -1379,6 +1437,9 @@ namespace Unity.Launcher total_child_height = 0.0f; int index = 0; + if (drag_indicator_active) + drag_indicator_position = model[drag_indicator_index].position + padding.top; + foreach (ScrollerChild child in model) { @@ -1398,14 +1459,6 @@ namespace Unity.Launcher if (!child.do_not_render) ; child.allocate (child_box, flags); - if (index == drag_indicator_index && drag_indicator_active) - { - float c_pos = 0.0f + padding.top; - if (index > 0) - c_pos = model[index-1].position + padding.top + child_box.get_height () + spacing; - - drag_indicator_position = c_pos; - } child.remove_clip (); if (child_box.y1 < 0) child.set_clip (0, Math.fabsf (child_box.y1), @@ -1485,6 +1538,19 @@ namespace Unity.Launcher public override void paint () { bgtex.paint (); + + if (drag_indicator_active) + { + //debug (@"drawing at $drag_indicator_position with $drag_indicator_opacity opacity"); + Cogl.set_source_color4f (1.0f, 1.0f, 1.0f, + drag_indicator_opacity); + + Cogl.rectangle (0, drag_indicator_position, + get_width (), + drag_indicator_position + 2); + + } + for (int index = draw_btf.size-1; index >= 0; index--) { ScrollerChild child = draw_btf[index]; @@ -1525,19 +1591,6 @@ namespace Unity.Launcher kb_ind.paint (); } - - if (drag_indicator_active) - { - //debug (@"drawing at $drag_indicator_position with $drag_indicator_opacity opacity"); - Cogl.set_source_color4f (1.0f, 1.0f, 1.0f, - 1.0f);//drag_indicator_opacity); - - Cogl.rectangle (0, drag_indicator_position, - get_width (), - drag_indicator_position + 2); - - } - top_shadow.paint (); } diff --git a/unity-private/launcher/scrollerchild.vala b/unity-private/launcher/scrollerchild.vala index f118170f0..53f31624a 100644 --- a/unity-private/launcher/scrollerchild.vala +++ b/unity-private/launcher/scrollerchild.vala @@ -496,8 +496,12 @@ namespace Unity.Launcher processed_icon.get_animation ().completed (); processed_icon.rotation = old_rotate_value; - processed_icon.animate (Clutter.AnimationMode.EASE_OUT_QUINT, 300, - "rotation", rotation); + if (rotation <= 1.0 && rotation >= 0.0) + processed_icon.animate (Clutter.AnimationMode.EASE_IN_OUT_QUAD, 300, + "rotation", rotation); + else + processed_icon.animate (Clutter.AnimationMode.EASE_OUT_QUINT, 300, + "rotation", rotation); } private void on_activating_changed () |
