Merge lp:~ricotz/plank/non-zoom-expand into lp:plank

Proposed by Rico Tzschichholz
Status: Merged
Merged at revision: 1481
Proposed branch: lp:~ricotz/plank/non-zoom-expand
Merge into: lp:plank
Diff against target: 155 lines (+33/-22)
5 files modified
lib/DockRenderer.vala (+1/-1)
lib/DragManager.vala (+1/-1)
lib/Items/DockItemProvider.vala (+3/-7)
lib/PositionManager.vala (+27/-13)
lib/libplank.symbols (+1/-0)
To merge this branch: bzr merge lp:~ricotz/plank/non-zoom-expand
Reviewer Review Type Date Requested Status
Docky Core Pending
Review via email: mp+282080@code.launchpad.net
To post a comment you must log in.
lp:~ricotz/plank/non-zoom-expand updated
1481. By Rico Tzschichholz

positionmanager: Expand dock on external-drag without enabled zoom too

Also try harder to insert dropped elements at the actually desired spot.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'lib/DockRenderer.vala'
2--- lib/DockRenderer.vala 2016-01-06 10:56:24 +0000
3+++ lib/DockRenderer.vala 2016-01-09 09:20:52 +0000
4@@ -1055,7 +1055,7 @@
5
6 local_cursor = new_cursor;
7
8- if (controller.prefs.ZoomEnabled) {
9+ if (screen_is_composited) {
10 zoom_changed = true;
11 animated_draw ();
12 }
13
14=== modified file 'lib/DragManager.vala'
15--- lib/DragManager.vala 2015-12-09 13:07:04 +0000
16+++ lib/DragManager.vala 2016-01-09 09:20:52 +0000
17@@ -464,7 +464,7 @@
18 position_manager.get_hover_position (hovered_item, out hx, out hy);
19 hover.set_text (hovered_item.get_drop_text ());
20 hover.show_at (hx, hy, position_manager.Position);
21- } else if (hide_manager.Hovered) {
22+ } else if (hide_manager.Hovered && !controller.prefs.LockItems) {
23 int hx = x, hy = y;
24 position_manager.get_hover_position_at (ref hx, ref hy);
25 hover.set_text (_("Drop to add to dock"));
26
27=== modified file 'lib/Items/DockItemProvider.vala'
28--- lib/Items/DockItemProvider.vala 2015-11-03 10:37:19 +0000
29+++ lib/Items/DockItemProvider.vala 2016-01-09 09:20:52 +0000
30@@ -85,19 +85,15 @@
31 {
32 bool result = false;
33
34- unowned DockItem? hovered_item = null;
35+ unowned DockItem? target_item = null;
36 unowned DockController? controller = get_dock ();
37 if (controller != null && controller.window.HoveredItemProvider == this) {
38- hovered_item = controller.window.HoveredItem;
39- if (hovered_item == null) {
40- var cursor = controller.renderer.local_cursor;
41- hovered_item = controller.position_manager.get_nearest_item_at (cursor.x, cursor.y, this);
42- }
43+ target_item = controller.position_manager.get_current_target_item (this);
44 }
45
46 foreach (var uri in uris) {
47 if (!item_exists_for_uri (uri)) {
48- add_item_with_uri (uri, hovered_item);
49+ add_item_with_uri (uri, target_item);
50 result = true;
51 }
52 }
53
54=== modified file 'lib/PositionManager.vala'
55--- lib/PositionManager.vala 2015-12-09 09:30:43 +0000
56+++ lib/PositionManager.vala 2016-01-09 09:20:52 +0000
57@@ -812,11 +812,10 @@
58 DrawValuesFunc? post_func = null)
59 {
60 unowned DockPreferences prefs = controller.prefs;
61+ unowned DockRenderer renderer = controller.renderer;
62
63 draw_values.clear ();
64
65- bool external_drag_active = controller.drag_manager.ExternalDragActive;
66-
67 // first we do the math as if this is a top dock, to do this we need to set
68 // up some "pretend" variables. we pretend we are a top dock because 0,0 is
69 // at the top.
70@@ -824,8 +823,7 @@
71 int height = DockHeight;
72 int icon_size = IconSize;
73
74- double zoom_in_progress = controller.renderer.zoom_in_progress;
75- Gdk.Point cursor = controller.renderer.local_cursor;
76+ Gdk.Point cursor = renderer.local_cursor;
77
78 // "relocate" our cursor to be on the top
79 switch (Position) {
80@@ -888,8 +886,11 @@
81 // zoom_in_percent is a range of 1 to ZoomPercent.
82 // We need a number that is 1 when ZoomIn is 0, and ZoomPercent when ZoomIn is 1.
83 // Then we treat this as if it were the ZoomPercent for the rest of the calculation.
84- double zoom_in_percent = (prefs.ZoomEnabled ? 1.0 + (ZoomPercent - 1.0) * zoom_in_progress : 1.0);
85- double zoom_icon_size = (prefs.ZoomEnabled ? ZoomIconSize : 2.0 * icon_size);
86+ bool expand_for_drop = (controller.drag_manager.ExternalDragActive && !prefs.LockItems);
87+ bool zoom_enabled = prefs.ZoomEnabled;
88+ double zoom_in_progress = (zoom_enabled || expand_for_drop ? renderer.zoom_in_progress : 0.0);
89+ double zoom_in_percent = (zoom_enabled ? 1.0 + (ZoomPercent - 1.0) * zoom_in_progress : 1.0);
90+ double zoom_icon_size = ZoomIconSize;
91
92 foreach (unowned DockItem item in items) {
93 DockItemDrawValue val = new DockItemDrawValue ();
94@@ -909,10 +910,10 @@
95 double offset = double.min (Math.fabs (cursor_position - center_position), zoom_icon_size);
96
97 double offset_percent;
98- if (external_drag_active) {
99+ if (expand_for_drop) {
100 // Provide space for dropping between items
101 offset += offset * zoom_icon_size / icon_size;
102- offset_percent = double.min (1.0, offset / (zoom_icon_size + ZoomIconSize));
103+ offset_percent = double.min (1.0, offset / (2.0 * zoom_icon_size));
104 } else {
105 offset_percent = offset / zoom_icon_size;
106 }
107@@ -930,11 +931,7 @@
108 // value. The center is 100%. (1 - offset_percent) == 0,1 distance from center
109 // The .66 value comes from the area under the curve. Dont ask me to explain it too much because it's too clever for me.
110
111- // for external drags with no zoom, we pretend there is actually a zoom of 200%
112- if (external_drag_active && ZoomPercent == 1.0)
113- offset *= zoom_in_progress / 2.0;
114- else
115- offset *= zoom_in_percent - 1.0;
116+ offset *= zoom_in_progress / 2.0;
117 offset *= 1.0 - offset_percent / 3.0;
118
119 if (cursor_position > center_position)
120@@ -1206,6 +1203,23 @@
121 }
122
123 /**
124+ * Get the item which is the appropriate target for a drag'n'drop action.
125+ * The returned item may not hovered and is meant to be used as target
126+ * for e.g. DockContainer.add/move_to functions.
127+ * If a container is given the result will be restricted to its children.
128+ *
129+ * @param container a container or NULL
130+ */
131+ public unowned DockItem? get_current_target_item (DockContainer? container = null)
132+ {
133+ unowned DockRenderer renderer = controller.renderer;
134+ var cursor = renderer.local_cursor;
135+ var offset = (int) ((renderer.zoom_in_progress * ZoomIconSize + ItemPadding) / 2.0);
136+
137+ return get_nearest_item_at (cursor.x + offset, cursor.y + offset, container);
138+ }
139+
140+ /**
141 * Get's the x and y position to display a menu for a dock item.
142 *
143 * @param hovered the item that is hovered
144
145=== modified file 'lib/libplank.symbols'
146--- lib/libplank.symbols 2015-12-09 09:30:43 +0000
147+++ lib/libplank.symbols 2016-01-09 09:20:52 +0000
148@@ -521,6 +521,7 @@
149 plank_position_manager_get_background_region
150 plank_position_manager_get_barrier
151 plank_position_manager_get_BottomPadding
152+plank_position_manager_get_current_target_item
153 plank_position_manager_get_cursor_region
154 plank_position_manager_get_dock_draw_position
155 plank_position_manager_get_dock_window_region

Subscribers

People subscribed via source and target branches

to status/vote changes: