summaryrefslogtreecommitdiff
path: root/unity-private
diff options
authorGord Allott <gord.allott@canonical.com>2010-08-26 11:33:04 +0100
committerGord Allott <gord.allott@canonical.com>2010-08-26 11:33:04 +0100
commit3bd3fdc3150b8ba01f9557da781ff63cfe2d7c01 (patch)
treef32dbd41dc9932df511983e7a61408dfa0c4756a /unity-private
parentfd91629035e718156e2f569003d6cb8be0245306 (diff)
parent862826f4182973a4d62754f61dd2cf34b7d53b67 (diff)
new dnd code, to fit visual design
(bzr r460)
Diffstat (limited to 'unity-private')
-rw-r--r--unity-private/launcher/scroller-controller.vala75
-rw-r--r--unity-private/launcher/scroller-view.vala366
-rw-r--r--unity-private/launcher/scrollerchild-controller.vala20
-rw-r--r--unity-private/launcher/scrollerchild.vala93
4 files changed, 409 insertions, 145 deletions
diff --git a/unity-private/launcher/scroller-controller.vala b/unity-private/launcher/scroller-controller.vala
index cdd3e2ccc..c338d7ba3 100644
--- a/unity-private/launcher/scroller-controller.vala
+++ b/unity-private/launcher/scroller-controller.vala
@@ -27,7 +27,7 @@ namespace Unity.Launcher
private Gee.ArrayList<ScrollerChildController> childcontrollers;
/* constants */
- private const uint DRAG_SAFE_ZONE = 300;
+ private const uint DRAG_SAFE_ZONE = 200;
private Bamf.Matcher matcher;
@@ -269,6 +269,9 @@ namespace Unity.Launcher
{
ScrollerChild child = (drag_controller.get_drag_model () as ScrollerChildController).child;
child.opacity = 0;
+ child.do_not_render = true;
+ view.drag_indicator_active = true;
+ view.drag_indicator_space = true;
view.do_queue_redraw ();
}
}
@@ -283,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))
@@ -292,16 +294,46 @@ 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)
{
// we need to remove this child from the model, its been dragged out
model.remove (retcont);
+ view.drag_indicator_active = false;
+ if (retcont is ScrollerChild)
+ {
+ if (retcont.enable_close_state == false);
+ {
+ retcont.enable_close_state = true;
+ }
+ }
}
else
{
+ if (retcont is ScrollerChild)
+ {
+
+ if (retcont.enable_close_state == true)
+ {
+ retcont.enable_close_state = false;
+ }
+ }
+
+ 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);
@@ -309,35 +341,16 @@ namespace Unity.Launcher
//we have to check to see if we would still be over the index
//if it was done animating
-/*
- GLib.Value value = Value (typeof (float));
- var child = model[model_index];
- Clutter.Animation anim = child.get_animation ();
- if (anim is Clutter.Animation)
- {
- debug ("is animating");
- Clutter.Interval interval = anim.get_interval ("position");
- interval.get_final_value (value);
- }
+ if (retcont in model)
+ model.move (retcont, int.max (model_index, 0));
else
- {
- debug ("is not animating");
- value.set_float (y);
- }
-
- debug ("%f", Math.fabsf (value.get_float () - y));
+ model.insert (retcont, int.max (model_index, 0));
- if (Math.fabsf (value.get_float () - y) < 48)
+ if (model_index != view.drag_indicator_index)
{
- debug ("moving things");
-*/
- if (retcont in model)
- model.move (retcont, int.max (model_index, 0));
- else
- model.insert (retcont, int.max (model_index, 0));
-
+ view.drag_indicator_index = model_index;
view.do_queue_redraw ();
- //}
+ }
}
}
@@ -350,15 +363,16 @@ namespace Unity.Launcher
view.cache.update_texture_cache ();
return;
}
+ view.drag_indicator_active = false;
ScrollerChildController model_controller = drag_controller.get_drag_model () as ScrollerChildController;
ScrollerChild retcont = model_controller.child;
-
+
if (retcont.group_type == ScrollerChild.GroupType.PLACE ||
retcont.group_type == ScrollerChild.GroupType.SYSTEM)
{
; /* Do nothing */
}
- else if (x > view.get_width ())
+ else if (x > view.get_width () + DRAG_SAFE_ZONE)
{
// it was dropped outside of the launcher.. oh well, obliterate it.
if (retcont.controller is ApplicationController)
@@ -387,6 +401,7 @@ namespace Unity.Launcher
}
// if it was dropped inside of the launcher, its allready been added
retcont.opacity = 255;
+ retcont.do_not_render = false;
// disconnect our drag controller signals
drag_controller.drag_motion.disconnect (this.on_unity_drag_motion);
drag_controller.drag_drop.disconnect (this.on_unity_drag_drop);
diff --git a/unity-private/launcher/scroller-view.vala b/unity-private/launcher/scroller-view.vala
index c2a144887..4da0b3198 100644
--- a/unity-private/launcher/scroller-view.vala
+++ b/unity-private/launcher/scroller-view.vala
@@ -52,6 +52,13 @@ namespace Unity.Launcher
public ScrollerModel model {get; construct;}
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;
+
+
/* our scroller constants */
public int spacing = 6;
public int drag_sensitivity = 7;
@@ -73,6 +80,7 @@ namespace Unity.Launcher
private ScrollerPhase current_phase = ScrollerPhase.SETTLING;
private uint last_motion_event_time = 0;
private ScrollerViewType view_type = ScrollerViewType.CONTRACTED;
+ private bool do_logic_pick = true;
private float last_known_pointer_x = 0.0f;
/*
@@ -132,6 +140,17 @@ namespace Unity.Launcher
keyboard_indicators = new Gee.ArrayList <Clutter.CairoTexture> ();
load_textures ();
+ Clutter.Color color = Clutter.Color () {
+ red = 0xff,
+ green = 0xff,
+ blue = 0xff,
+ alpha = 0xff
+ };
+
+ 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);
model.order_changed.connect (model_order_changed);
@@ -172,13 +191,36 @@ namespace Unity.Launcher
drag_controller.drag_start.connect (() => {
is_scrolling = false;
button_down = false;
+ is_scrolling = false;
+ Clutter.ungrab_pointer ();
+ get_stage ().motion_event.disconnect (on_motion_event);
+ current_phase = ScrollerPhase.FLUNG;
+ fling_timeline.start ();
+
+ animate (Clutter.AnimationMode.EASE_OUT_SINE, 150,
+ "drag-indicator-opacity", 1.0f);
});
- drag_controller.drag_drop.connect (() => {
+ drag_controller.drag_drop.connect ((drag_model, x, y) => {
foreach (Clutter.Actor child in model)
{
child.set_reactive (false);
}
+ if (x > get_width ()) contract_launcher ();
+ else
+ {
+ Idle.add (() => {
+ order_children (false);
+ });
+ }
+ animate (Clutter.AnimationMode.EASE_OUT_SINE, 150,
+ "drag-indicator-opacity", 0.0f);
+ });
+
+ drag_controller.drag_motion.connect ((model, x, y) => {
+ last_known_pointer_x = x;
+ if (x > 200 + get_width ()) contract_launcher ();
+ else expand_launcher (y);
});
set_reactive (true);
@@ -191,6 +233,8 @@ namespace Unity.Launcher
queue_relayout ();
});
+ drag_indicator_space = false;
+
}
/* hoo-boy this sucks. because of mutter and clutter issues, i have to set
@@ -200,7 +244,7 @@ namespace Unity.Launcher
* is real... sheesh
*/
private Clutter.Actor? last_picked_actor = null;
- private Clutter.Actor? handle_event (Clutter.Event event)
+ private Clutter.Actor? handle_event (Clutter.Event event, bool assume_on_launcher=false)
{
if (disable_child_events)
return null;
@@ -217,6 +261,9 @@ namespace Unity.Launcher
float x, y;
event.get_coords (out x, out y);
+ if (assume_on_launcher)
+ x = 25;
+
Clutter.Actor picked_actor = (get_stage () as Clutter.Stage).get_actor_at_pos (Clutter.PickMode.REACTIVE, (int)x, (int)y);
@@ -267,12 +314,15 @@ namespace Unity.Launcher
{
var drag_controller = Drag.Controller.get_default ();
if (drag_controller.is_dragging) return false;
- if (is_scrolling) return false;
enter_event.disconnect (on_enter_event);
leave_event.disconnect (on_leave_event);
motion_event.disconnect (on_motion_event);
motion_event.disconnect (passthrough_motion_event);
- Clutter.Actor picked_actor = handle_event (event);
+ if (is_scrolling)
+ {
+ get_stage ().motion_event.disconnect (on_motion_event);
+ }
+ Clutter.Actor picked_actor = handle_event (event, is_scrolling);
if (picked_actor is Clutter.Actor)
picked_actor.do_event (event, false);
@@ -281,6 +331,10 @@ namespace Unity.Launcher
leave_event.connect (on_leave_event);
motion_event.connect (on_motion_event);
motion_event.connect (passthrough_motion_event);
+ if (is_scrolling)
+ {
+ get_stage ().motion_event.connect (on_motion_event);
+ }
return false;
}
@@ -288,12 +342,11 @@ namespace Unity.Launcher
{
var drag_controller = Drag.Controller.get_default ();
if (drag_controller.is_dragging) return false;
- if (is_scrolling) return false;
enter_event.disconnect (on_enter_event);
leave_event.disconnect (on_leave_event);
button_press_event.disconnect (passthrough_button_press_event);
- Clutter.Actor picked_actor = handle_event (event);
+ Clutter.Actor picked_actor = handle_event (event, is_scrolling);
if (picked_actor is Clutter.Actor)
picked_actor.do_event (event, false);
@@ -307,12 +360,11 @@ namespace Unity.Launcher
{
var drag_controller = Drag.Controller.get_default ();
if (drag_controller.is_dragging) return false;
- if (is_scrolling) return false;
enter_event.disconnect (on_enter_event);
leave_event.disconnect (on_leave_event);
button_release_event.disconnect (passthrough_button_release_event);
- Clutter.Actor picked_actor = handle_event (event);
+ Clutter.Actor picked_actor = handle_event (event, is_scrolling);
if (picked_actor is Clutter.Actor)
picked_actor.do_event (event, false);
@@ -322,6 +374,44 @@ namespace Unity.Launcher
return false;
}
+ private void on_drag_indicator_space_change ()
+ {
+ if (drag_indicator_active)
+ {
+ 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", 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");
+ order_children (false);
+ queue_relayout ();
+ }
+
private float last_scroll_position = 0.0f;
public void enable_keyboard_selection_mode (bool choice)
{
@@ -398,18 +488,42 @@ namespace Unity.Launcher
ScrollerChild child = (Drag.Controller.get_default ().get_drag_model () as ScrollerChildController).child;
- value = model.clamp (child, value);
+ //value = model.clamp (child, value);
return value;
}
public int get_model_index_at_y_pos (float y, bool return_minus_if_fail=false)
{
+ if (!do_logic_pick)
+ 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 (Clutter.Actor actor in model)
+ foreach (ScrollerChild actor in model)
{
- actor.set_reactive (true);
+ if (!actor.do_not_render)
+ actor.set_reactive (true);
}
Clutter.Actor picked_actor = (get_stage () as Clutter.Stage).get_actor_at_pos (Clutter.PickMode.REACTIVE, 25, iy);
@@ -417,14 +531,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);
+ // 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);
-
+ // 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)
@@ -517,8 +630,6 @@ namespace Unity.Launcher
alpha = 0xff
};
- //!!FIXME!! these are positioned wrong, needs to know the absolute
- // size of the resulting cario surface before creating it =\
int index = 1;
// indicator size find out activate!
int key_indicator_w, key_indicator_h;
@@ -601,6 +712,7 @@ namespace Unity.Launcher
// get the index of the icon we are hovering over
if (get_total_children_height () > get_available_height ())
{
+ do_logic_pick = false;
int index = get_model_index_at_y_pos (absolute_y);
// set our state to what we will end up being so we can find the correct
@@ -624,6 +736,7 @@ namespace Unity.Launcher
order_children (false); // have to order twice, boo
queue_relayout ();
+ do_logic_pick = true;
}
}
@@ -713,6 +826,10 @@ namespace Unity.Launcher
}
//Clutter.grab_pointer (this);
+ if (is_scrolling)
+ {
+ passthrough_button_press_event (event);
+ }
button_down = true;
previous_y_position = event.button.y;
previous_y_time = event.button.time;
@@ -736,6 +853,7 @@ namespace Unity.Launcher
if (is_scrolling)
{
+ passthrough_button_release_event (event);
is_scrolling = false;
Clutter.ungrab_pointer ();
get_stage ().motion_event.disconnect (on_motion_event);
@@ -790,6 +908,8 @@ namespace Unity.Launcher
private bool on_leave_event (Clutter.Event event)
{
last_known_pointer_x = 200;
+ var drag_controller = Drag.Controller.get_default ();
+ if (drag_controller.is_dragging) return false;
if (is_scrolling) return false;
do_queue_contract_launcher ();
@@ -841,6 +961,7 @@ 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 ();
@@ -857,25 +978,23 @@ namespace Unity.Launcher
* monitor how far away we have dragged from the original click, once
* we get far enough away we can start scrolling.
*/
- var diff = event.motion.y - previous_y_position;
- if (Math.fabsf (diff) > drag_sensitivity)
- {
- is_scrolling = true;
- Unity.global_shell.add_fullscreen_request (this);
- Clutter.grab_pointer (this);
- get_stage ().motion_event.connect (on_motion_event);
- }
+ //var diff = event.motion.y - previous_y_position;
+ is_scrolling = true;
+ Unity.global_shell.add_fullscreen_request (this);
+ Clutter.grab_pointer (this);
+ get_stage ().motion_event.connect (on_motion_event);
}
if (is_scrolling)
{
/* Disable any animations on the children */
- disable_animations_on_children (event);
+ //disable_animations_on_children (event);
/* we need to compare the event y position from this event to the
* previous event. once we have that we can compute a velocity based
* on how long it was since the previous event
*/
+ passthrough_motion_event (event);
float pixel_diff = event.motion.y - previous_y_position;
uint time_diff = event.motion.time - previous_y_time;
@@ -1081,74 +1200,78 @@ namespace Unity.Launcher
private void order_children (bool immediate)
{
- Gee.ArrayList<ChildTransition> transitions;
if (get_total_children_height () < get_available_height ())
{
- transitions = order_children_expanded ();
+ order_children_expanded (immediate);
}
else
{
switch (view_type)
{
case ScrollerViewType.CONTRACTED:
- transitions = order_children_contracted ();
+ order_children_contracted (immediate);
break;
case ScrollerViewType.EXPANDED:
- transitions = order_children_expanded ();
+ order_children_expanded (immediate);
break;
default:
assert_not_reached ();
}
}
+ queue_relayout ();
+ }
- for (int index = 0; index < model.size; index++)
+ private void change_child_position_rotation (ScrollerChild child,
+ float position, float rotation,
+ bool immediate = false)
+ {
+ if (immediate)
{
- var child = model[index];
- if (immediate)
- {
- child.position = transitions[index].position;
- child.force_rotation_jump (transitions[index].rotation);
- }
- else
+ child.position = position;
+ child.force_rotation_jump (rotation);
+ }
+ else
+ {
+ bool do_new_position = true;
+ if (child.get_animation () is Clutter.Animation)
{
- bool do_new_position = true;
- if (child.get_animation () is Clutter.Animation)
+ //GLib.Value value = GLib.Value (GLib.Type.from_name ("string"));
+ GLib.Value value = Value (typeof (float));
+ Clutter.Interval interval = child.get_animation ().get_interval ("position");
+ if (interval is Clutter.Interval)
+ interval.get_final_value (value);
+ if (value.get_float () != position)
{
- //GLib.Value value = GLib.Value (GLib.Type.from_name ("string"));
- GLib.Value value = Value (typeof (float));
- Clutter.Interval interval = child.get_animation ().get_interval ("position");
- if (interval is Clutter.Interval)
- interval.get_final_value (value);
- if (value.get_float () != transitions[index].position)
- {
- // disable the current animation before starting a new one
- float current_pos = child.position;
- child.get_animation ().completed ();
- child.position = current_pos;
- }
- else
- {
- do_new_position = false;
- }
+ // disable the current animation before starting a new one
+ float current_pos = child.position;
+ child.get_animation ().completed ();
+ child.position = current_pos;
}
+ else
+ {
+ do_new_position = false;
+ }
+ }
- child.rotation = transitions[index].rotation;
+ child.rotation = rotation;
- if (do_new_position)
- child.animate (Clutter.AnimationMode.EASE_OUT_QUAD,
- 300,
- "position", transitions[index].position
- );
+ if (do_new_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);
}
}
}
- private Gee.ArrayList<ChildTransition> order_children_expanded ()
+ private void order_children_expanded (bool immediate = false)
{
// figures out the position of each child based on its order in the model
- Gee.ArrayList<ChildTransition> ret_transitions = new Gee.ArrayList<ChildTransition> ();
float h = 0.0f;
float min_height, nat_height;
if (!(draw_ftb is Gee.ArrayList))
@@ -1157,28 +1280,43 @@ namespace Unity.Launcher
if (!(draw_ftb is Gee.ArrayList))
draw_btf = new Gee.ArrayList<ScrollerChild> ();
+ int index = 0;
foreach (ScrollerChild child in model)
{
- child.get_preferred_height (get_width (), out min_height, out nat_height);
- var transition = new ChildTransition ();
- transition.position = h + scroll_position;
- transition.rotation = 0.0f;
- ret_transitions.add (transition);
- //if (!(child in draw_ftb || child in draw_ftb))
- //draw_ftb.add (child);
- h += nat_height + spacing;
+
+ 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);
+
+ h += nat_height + spacing;
+ }
+ index += 1;
}
- return ret_transitions;
}
- private Gee.ArrayList<ChildTransition> order_children_contracted ()
+ private void order_children_contracted (bool immediate = false)
{
- Gee.ArrayList<ChildTransition> ret_transitions = new Gee.ArrayList<ChildTransition> ();
float h = 0.0f;
float min_height, nat_height;
int num_launchers = 0;
//get the total size of the children in a flat state
float total_child_height = get_total_children_height ();
+ int actual_model_size = model.size;
+ foreach (ScrollerChild child in model)
+ if (child.do_not_render) actual_model_size -= 1;
if (total_child_height > get_available_height ())
{
@@ -1192,7 +1330,8 @@ namespace Unity.Launcher
//check to see if we can fit everything in
float flat_space = num_launchers * (48.0f + spacing);
float contracted_space = 0.0f;
- contracted_space = ((model.size - num_launchers) * (8 + spacing));
+
+ contracted_space = ((actual_model_size - num_launchers) * (8 + spacing));
if (flat_space + spacing + contracted_space < (get_available_height () - (spacing * 2)))
{
@@ -1205,20 +1344,20 @@ namespace Unity.Launcher
}
else
{
- num_launchers = model.size;
+ num_launchers = actual_model_size;
}
int num_children_handled = 0;
int index_start_flat, index_end_flat = 0;
- if (focused_launcher < model.size - (num_launchers -(num_launchers / 2)))
+ if (focused_launcher < actual_model_size - (num_launchers -(num_launchers / 2)))
{
index_start_flat = int.max (0, focused_launcher - (num_launchers / 2));
index_end_flat = index_start_flat + num_launchers;
}
else
{
- index_end_flat = model.size;
+ index_end_flat = actual_model_size;
index_start_flat = index_end_flat - num_launchers;
}
draw_ftb = new Gee.ArrayList<ScrollerChild> ();
@@ -1227,14 +1366,12 @@ namespace Unity.Launcher
for (int index = 0; index < model.size; index++)
{
ScrollerChild child = model[index];
- var transition = new ChildTransition ();
child.get_preferred_height (get_width (), out min_height, out nat_height);
if (index >= index_start_flat && index < index_end_flat)
{
- transition.position = h;
+ change_child_position_rotation (child, h, 0.0f, immediate);
h += nat_height + spacing;
num_children_handled++;
- transition.rotation = 0.0f;
if (index == index_start_flat)
draw_ftb.add (child);
@@ -1245,45 +1382,44 @@ namespace Unity.Launcher
{
// contracted launcher
if (index == index_end_flat) h -= nat_height * 0.3333f - spacing;//spacing * 2;
-
+ float rotation = 0.0f;
+ float position = 0.0f;
if (num_children_handled < index_start_flat)
{
if (num_children_handled == index_start_flat - 1)
{
- transition.rotation = -contract_icon_partial_degrees;
+ rotation = -contract_icon_partial_degrees;
h += spacing;
}
else
{
- transition.rotation = -contract_icon_degrees;
+ rotation = -contract_icon_degrees;
}
- transition.position = h;
+ position = h;
draw_ftb.add (child);
}
else
{
- transition.position = h;
+ position = h;
if (index == index_end_flat)
{
- transition.rotation = contract_icon_partial_degrees;
+ rotation = contract_icon_partial_degrees;
h += spacing;
}
else
{
- transition.rotation = contract_icon_degrees;
+ rotation = contract_icon_degrees;
}
draw_btf.add (child);
}
+ change_child_position_rotation (child, position, rotation, immediate);
h += 8 + spacing;
num_children_handled++;
if (index +1 == index_start_flat) h += 30;
}
- ret_transitions.add (transition);
}
-
- return ret_transitions;
}
@@ -1293,6 +1429,7 @@ namespace Unity.Launcher
float min_height, nat_height;
foreach (ScrollerChild child in model)
{
+ if (child.do_not_render) continue;
child.get_preferred_height (get_width (), out min_height, out nat_height);
h += nat_height + spacing;
}
@@ -1311,15 +1448,20 @@ namespace Unity.Launcher
{
base.allocate (box, flags);
Clutter.ActorBox child_box = Clutter.ActorBox ();
+ Clutter.ActorBox temp_child_box = Clutter.ActorBox ();
float current_width = padding.left;
float available_height = box.get_height () - padding.bottom;
float available_width = box.get_width () - padding.right;
total_child_height = 0.0f;
- uint index = 0;
+ int index = 0;
+
+ if (drag_indicator_active)
+ drag_indicator_position = model[drag_indicator_index].position + padding.top;
foreach (ScrollerChild child in model)
{
+
float child_height, child_width, natural, min;
child.get_preferred_width (available_height, out min, out natural);
@@ -1329,17 +1471,12 @@ namespace Unity.Launcher
child_height = Math.fmaxf (min, Math.fminf (natural, available_height));
child_box.x1 = current_width;
- child_box.x2 = box.get_width () - padding.right;
+ child_box.x2 = child_box.x1 + child_width;//box.get_width () - padding.right;
child_box.y1 = child.position + padding.top;
child_box.y2 = child_box.y1 + child_height;
- child.allocate (child_box, flags);
-
- child.remove_clip ();
- if (child_box.y1 < 0)
- child.set_clip (0, Math.fabsf (child_box.y1),
- child_box.get_width (), child_box.get_height () - child_box.y1);
-
+ if (!child.do_not_render) ;
+ child.allocate (child_box, flags);
total_child_height += child_height + spacing;
@@ -1389,7 +1526,7 @@ namespace Unity.Launcher
for (int index = draw_btf.size-1; index >= 0; index--)
{
ScrollerChild child = draw_btf[index];
- if (child is ScrollerChild && child.opacity > 0)
+ if (child is ScrollerChild && child.opacity > 0 && !child.do_not_render)
{
(child as ScrollerChild).paint ();
}
@@ -1397,7 +1534,7 @@ namespace Unity.Launcher
foreach (ScrollerChild child in draw_ftb)
{
- if (child is ScrollerChild && child.opacity > 0)
+ if (child is ScrollerChild && child.opacity > 0 && !child.do_not_render)
{
(child as ScrollerChild).paint ();
}
@@ -1405,6 +1542,7 @@ namespace Unity.Launcher
foreach (ScrollerChild child in child_refs)
{
+ if (child.do_not_render) continue;
child.paint ();
}
}
@@ -1413,10 +1551,23 @@ 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];
- if (child is ScrollerChild && child.opacity > 0)
+ if (child is ScrollerChild && child.opacity > 0 && !child.do_not_render)
{
(child as ScrollerChild).paint ();
}
@@ -1424,7 +1575,7 @@ namespace Unity.Launcher
foreach (ScrollerChild child in draw_ftb)
{
- if (child is ScrollerChild && child.opacity > 0)
+ if (child is ScrollerChild && child.opacity > 0 && !child.do_not_render)
{
(child as ScrollerChild).paint ();
}
@@ -1444,6 +1595,7 @@ namespace Unity.Launcher
foreach (ScrollerChild child in child_refs)
{
+ if (child.do_not_render) continue;
child.paint ();
}
@@ -1460,6 +1612,7 @@ namespace Unity.Launcher
base.map ();
bgtex.map ();
top_shadow.map ();
+
foreach (Clutter.CairoTexture kb_ind in keyboard_indicators)
{
kb_ind.map ();
@@ -1477,6 +1630,7 @@ namespace Unity.Launcher
base.unmap ();
bgtex.map ();
top_shadow.map ();
+
foreach (Clutter.CairoTexture kb_ind in keyboard_indicators)
{
kb_ind.paint ();
diff --git a/unity-private/launcher/scrollerchild-controller.vala b/unity-private/launcher/scrollerchild-controller.vala
index 40101c95a..fda7c9f80 100644
--- a/unity-private/launcher/scrollerchild-controller.vala
+++ b/unity-private/launcher/scrollerchild-controller.vala
@@ -44,8 +44,9 @@ namespace Unity.Launcher
protected ScrollerChildControllerMenuState menu_state;
protected uint32 last_press_time = 0;
protected bool button_down = false;
- protected float click_start_pos = 0.0f;
- protected int drag_sensitivity = 7;
+ protected float click_start_pos_x = 0.0f;
+ protected float click_start_pos_y = 0.0f;
+ protected int drag_sensitivity = 60;
private Unity.ThemeFilePath theme_file_path;
protected QuicklistController? menu {get; set;}
@@ -123,7 +124,8 @@ namespace Unity.Launcher
{
last_press_time = event.button.time;
button_down = true;
- click_start_pos = event.button.x;
+ click_start_pos_x = event.button.x;
+ click_start_pos_y = event.button.y;
} break;
case 3:
{
@@ -137,6 +139,7 @@ namespace Unity.Launcher
private bool on_release_event (Clutter.Event event)
{
+ child.grabbed_push = 0;
if (event.button.button == 1 &&
button_down == true &&
event.button.time - last_press_time < 500)
@@ -224,13 +227,20 @@ namespace Unity.Launcher
var drag_controller = Unity.Drag.Controller.get_default ();
if (button_down && drag_controller.is_dragging == false && can_drag ())
{
- float diff = Math.fabsf (event.motion.x - click_start_pos);
+ float diff = Math.fabsf (event.motion.x - click_start_pos_x);
+ if (event.motion.x - click_start_pos_x > 0)
+ {
+ child.grabbed_push = Math.powf (diff, 0.5f);
+ child.queue_relayout ();
+ }
if (diff > drag_sensitivity)
{
+ child.grabbed_push = 0;
+ child.queue_relayout ();
float x, y;
child.get_transformed_position (out x, out y);
drag_controller.start_drag (this,
- event.button.x - x,
+ click_start_pos_x - x,
event.button.y - y);
child.set_reactive (true);
button_down = false;
diff --git a/unity-private/launcher/scrollerchild.vala b/unity-private/launcher/scrollerchild.vala
index 62a6288f7..26f1ff2b3 100644
--- a/unity-private/launcher/scrollerchild.vala
+++ b/unity-private/launcher/scrollerchild.vala
@@ -65,9 +65,16 @@ namespace Unity.Launcher
public bool needs_attention {get; set;}
public bool activating {get; set;}
public float rotation {get; set;}
+ public bool do_not_render = false;
+
+ public bool enable_close_state {get; set;}
+
public ScrollerChildController controller; // this sucks. shouldn't be here, can't help it.
public GroupType group_type { get; construct set; }
+ public bool is_dragging_state { get; set; }
+
+ public float grabbed_push = 0.0f;
public string to_string ()
{
@@ -79,6 +86,7 @@ namespace Unity.Launcher
}
private UnityIcon processed_icon;
+ private ThemeImage close_symbol;
private ThemeImage active_indicator;
private ThemeImage running_indicator;
private Gdk.Pixbuf honeycomb_mask;
@@ -130,11 +138,19 @@ namespace Unity.Launcher
{
active_indicator = new ThemeImage ("application-selected");
running_indicator = new ThemeImage ("application-running");
+ close_symbol = new ThemeImage ("close_symbol");
active_indicator.set_parent (this);
running_indicator.set_parent (this);
+ close_symbol.set_parent (this);
+
active_indicator.set_opacity (0);
running_indicator.set_opacity (0);
+ close_symbol.set_opacity (0);
+
+ close_symbol.scale_gravity = Clutter.Gravity.CENTER;
+ close_symbol.scale_x = 0.0;
+ close_symbol.scale_y = 0.0;
try
{
@@ -156,6 +172,9 @@ namespace Unity.Launcher
notify["active"].connect (on_active_changed);
notify["activating"].connect (on_activating_changed);
notify["needs-attention"].connect (on_needs_attention_changed);
+ notify["is-dragging-state"].connect (on_dragging_state_changed);
+ Drag.Controller.get_default ().drag_drop.connect (on_drag_drop);
+ notify["enable-close-state"].connect (on_enable_close_state_changed);
// just trigger some notifications now to set inital state
on_running_changed ();
@@ -165,9 +184,57 @@ namespace Unity.Launcher
public Clutter.Actor get_content ()
{
- return processed_icon;
+ is_dragging_state = true;
+ return this;
}
+ private void on_drag_drop (Unity.Drag.Model model, float x, float y)
+ {
+ if (is_dragging_state)
+ is_dragging_state = false;
+ }
+
+ private void on_dragging_state_changed ()
+ {
+ if (is_dragging_state)
+ {
+ running_indicator_anim = running_indicator.animate (Clutter.AnimationMode.EASE_IN_OUT_SINE,
+ SHORT_DELAY,
+ "opacity", 0x00);
+
+ active_indicator_anim = active_indicator.animate (Clutter.AnimationMode.EASE_IN_OUT_SINE,
+ SHORT_DELAY,
+ "opacity", 0x00);
+ }
+ else
+ {
+ on_running_changed ();
+ on_active_changed ();
+ }
+ }
+
+ private bool previous_close_state = false;
+ private void on_enable_close_state_changed ()
+ {
+ if (enable_close_state == true && previous_close_state == false)
+ {
+ close_symbol.animate (Clutter.AnimationMode.EASE_OUT_CUBIC,
+ 300,
+ "opacity", 0xff,
+ "scale-x", 1.0,
+ "scale-y", 1.0);
+ }
+ else if (enable_close_state == false && previous_close_state == true)
+ {
+ close_symbol.animate (Clutter.AnimationMode.EASE_OUT_CUBIC,
+ 300,
+ "opacity", 0x00,
+ "scale-x", 0.0,
+ "scale-y", 0.0);
+ }
+ previous_close_state = enable_close_state;
+ }
+
/* alpha helpers */
private static float get_ease_out_sine (float alpha)
{
@@ -184,6 +251,7 @@ namespace Unity.Launcher
public void force_rotation_jump (float degrees)
{
+ if (is_dragging_state) return;
if (processed_icon.get_animation () is Clutter.Animation)
processed_icon.get_animation ().completed ();
@@ -422,14 +490,20 @@ namespace Unity.Launcher
private void on_rotation_changed ()
{
+ if (is_dragging_state) return;
+
old_rotate_value = processed_icon.rotation;
if (processed_icon.get_animation () is Clutter.Animation)
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 ()
@@ -528,7 +602,7 @@ namespace Unity.Launcher
//allocate the icon
processed_icon.get_preferred_width (48, out width, out n_width);
processed_icon.get_preferred_height (48, out height, out n_height);
- child_box.x1 = (box.get_width () - width) / 2.0f;
+ child_box.x1 = grabbed_push + (box.get_width () - width) / 2.0f;
child_box.y1 = y;
child_box.x2 = child_box.x1 + 48;
child_box.y2 = child_box.y1 + height;
@@ -543,6 +617,14 @@ namespace Unity.Launcher
child_box.y2 = child_box.y1 + height;
active_indicator.allocate (child_box, flags);
+ close_symbol.get_preferred_width (48, out n_width, out width);
+ close_symbol.get_preferred_height (48, out n_height, out height);
+ child_box.x1 = -(width / 2.0f) + 5;
+ child_box.y1 = -(height / 2.0f);
+ child_box.x2 = (width / 2.0f) + 5;
+ child_box.y2 = (height / 2.0f);
+ close_symbol.allocate (child_box, flags);
+
}
public override void pick (Clutter.Color color)
@@ -556,11 +638,13 @@ namespace Unity.Launcher
running_indicator.paint ();
processed_icon.paint ();
+ close_symbol.paint ();
}
public override void map ()
{
base.map ();
+ close_symbol.map ();
running_indicator.map ();
active_indicator.map ();
processed_icon.map ();
@@ -569,6 +653,7 @@ namespace Unity.Launcher
public override void unmap ()
{
base.unmap ();
+ close_symbol.map ();
running_indicator.unmap ();
active_indicator.unmap ();
processed_icon.unmap ();