summaryrefslogtreecommitdiff
path: root/unity-private
diff options
authorGord Allott <gord.allott@canonical.com>2010-08-24 11:50:24 +0100
committerGord Allott <gord.allott@canonical.com>2010-08-24 11:50:24 +0100
commit3883a49d4106d7de69ef4c4c3568d4fcdea0e3df (patch)
treefe458cd1fe390db078bed35c3383b4ce2f863e30 /unity-private
parent6f199d8d64b9831eb0d327fa95e8951194ccce75 (diff)
close icon supported
(bzr r433.6.4)
Diffstat (limited to 'unity-private')
-rw-r--r--unity-private/launcher/scroller-controller.vala55
-rw-r--r--unity-private/launcher/scroller-view.vala20
-rw-r--r--unity-private/launcher/scrollerchild.vala80
3 files changed, 118 insertions, 37 deletions
diff --git a/unity-private/launcher/scroller-controller.vala b/unity-private/launcher/scroller-controller.vala
index 1b723991c..3edc54f94 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;
@@ -302,9 +302,25 @@ namespace Unity.Launcher
// 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 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);
@@ -312,38 +328,15 @@ 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
+ model.insert (retcont, int.max (model_index, 0));
+ if (model_index != view.drag_indicator_index)
{
- debug ("is not animating");
- value.set_float (y);
+ view.drag_indicator_index = model_index;
+ view.do_queue_redraw ();
}
-
- debug ("%f", Math.fabsf (value.get_float () - y));
-
- if (Math.fabsf (value.get_float () - y) < 48)
- {
- debug ("moving things");
-*/
- if (retcont in model)
- 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;
- view.do_queue_redraw ();
- }
- //}
}
}
@@ -365,7 +358,7 @@ namespace Unity.Launcher
{
; /* 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)
diff --git a/unity-private/launcher/scroller-view.vala b/unity-private/launcher/scroller-view.vala
index 3597b4a4e..960ca25a9 100644
--- a/unity-private/launcher/scroller-view.vala
+++ b/unity-private/launcher/scroller-view.vala
@@ -193,16 +193,28 @@ namespace Unity.Launcher
"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 (last_known_pointer_x > get_width ()) contract_launcher ();
+ 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);
child_refs = new Gee.ArrayList <ScrollerChild> ();
@@ -346,7 +358,6 @@ namespace Unity.Launcher
private void on_drag_indicator_active_change ()
{
- debug ("active change");
if (drag_indicator_active)
{
animate (Clutter.AnimationMode.EASE_OUT_SINE, 150,
@@ -363,7 +374,7 @@ namespace Unity.Launcher
private void on_drag_indicator_index_change ()
{
- debug (@"index changed $drag_indicator_index");
+ //debug (@"index changed $drag_indicator_index");
order_children (false);
queue_relayout ();
}
@@ -473,7 +484,6 @@ namespace Unity.Launcher
picked_actor = (get_stage () as Clutter.Stage).get_actor_at_pos (Clutter.PickMode.REACTIVE, 25, iy + spacing*2);
if (picked_actor is ScrollerChild == false)
{
- debug (@"didn't pick scroller child for pos $iy - fallbacking");
if (return_minus_if_fail)
ret_val = -1;
// couldn't pick a single actor, return 0
diff --git a/unity-private/launcher/scrollerchild.vala b/unity-private/launcher/scrollerchild.vala
index 81b936a49..f118170f0 100644
--- a/unity-private/launcher/scrollerchild.vala
+++ b/unity-private/launcher/scrollerchild.vala
@@ -66,9 +66,13 @@ namespace Unity.Launcher
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 string to_string ()
{
@@ -80,6 +84,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;
@@ -131,11 +136,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
{
@@ -157,6 +170,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 ();
@@ -166,9 +182,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)
{
@@ -185,6 +249,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 ();
@@ -423,6 +488,8 @@ 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)
@@ -544,6 +611,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)
@@ -557,11 +632,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 ();
@@ -570,6 +647,7 @@ namespace Unity.Launcher
public override void unmap ()
{
base.unmap ();
+ close_symbol.map ();
running_indicator.unmap ();
active_indicator.unmap ();
processed_icon.unmap ();