summaryrefslogtreecommitdiff
path: root/unity-private
diff options
authorGord Allott <gord.allott@canonical.com>2010-08-24 17:47:01 +0100
committerGord Allott <gord.allott@canonical.com>2010-08-24 17:47:01 +0100
commit40e3a3e3804a0a8c63ca76574ec597d9306f81b4 (patch)
tree5c6d1007cf837b11d8399b7ef479c3feff2ec2f1 /unity-private
parent12177ddd469d817b5913e44de7dd714ac965108a (diff)
resistance to launcher dragging enabled
(bzr r433.6.6)
Diffstat (limited to 'unity-private')
-rw-r--r--unity-private/launcher/scroller-view.vala45
-rw-r--r--unity-private/launcher/scrollerchild-controller.vala16
-rw-r--r--unity-private/launcher/scrollerchild.vala4
3 files changed, 42 insertions, 23 deletions
diff --git a/unity-private/launcher/scroller-view.vala b/unity-private/launcher/scroller-view.vala
index 01a272cf1..b3bd1e08c 100644
--- a/unity-private/launcher/scroller-view.vala
+++ b/unity-private/launcher/scroller-view.vala
@@ -190,6 +190,10 @@ 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);
+
animate (Clutter.AnimationMode.EASE_OUT_SINE, 150,
"drag-indicator-opacity", 1.0f);
});
@@ -237,7 +241,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;
@@ -254,6 +258,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);
@@ -304,12 +311,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);
@@ -318,6 +328,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;
}
@@ -325,7 +339,6 @@ 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);
@@ -344,7 +357,6 @@ 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);
@@ -615,8 +627,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;
@@ -941,6 +951,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 ();
@@ -957,25 +968,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;
@@ -1452,17 +1461,19 @@ 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;
if (!child.do_not_render) ;
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);
+*/
total_child_height += child_height + spacing;
diff --git a/unity-private/launcher/scrollerchild-controller.vala b/unity-private/launcher/scrollerchild-controller.vala
index 40101c95a..e0e520ba5 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:
{
@@ -224,13 +226,17 @@ 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);
+ 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 53f31624a..26f1ff2b3 100644
--- a/unity-private/launcher/scrollerchild.vala
+++ b/unity-private/launcher/scrollerchild.vala
@@ -74,6 +74,8 @@ namespace Unity.Launcher
public GroupType group_type { get; construct set; }
public bool is_dragging_state { get; set; }
+ public float grabbed_push = 0.0f;
+
public string to_string ()
{
return "A scroller child; running: %s, active: %s, position: %f, opacity %f".printf (
@@ -600,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;