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
=== modified file 'lib/DockRenderer.vala'
--- lib/DockRenderer.vala 2016-01-06 10:56:24 +0000
+++ lib/DockRenderer.vala 2016-01-09 09:20:52 +0000
@@ -1055,7 +1055,7 @@
1055 1055
1056 local_cursor = new_cursor;1056 local_cursor = new_cursor;
1057 1057
1058 if (controller.prefs.ZoomEnabled) {1058 if (screen_is_composited) {
1059 zoom_changed = true;1059 zoom_changed = true;
1060 animated_draw ();1060 animated_draw ();
1061 }1061 }
10621062
=== modified file 'lib/DragManager.vala'
--- lib/DragManager.vala 2015-12-09 13:07:04 +0000
+++ lib/DragManager.vala 2016-01-09 09:20:52 +0000
@@ -464,7 +464,7 @@
464 position_manager.get_hover_position (hovered_item, out hx, out hy);464 position_manager.get_hover_position (hovered_item, out hx, out hy);
465 hover.set_text (hovered_item.get_drop_text ());465 hover.set_text (hovered_item.get_drop_text ());
466 hover.show_at (hx, hy, position_manager.Position);466 hover.show_at (hx, hy, position_manager.Position);
467 } else if (hide_manager.Hovered) {467 } else if (hide_manager.Hovered && !controller.prefs.LockItems) {
468 int hx = x, hy = y;468 int hx = x, hy = y;
469 position_manager.get_hover_position_at (ref hx, ref hy);469 position_manager.get_hover_position_at (ref hx, ref hy);
470 hover.set_text (_("Drop to add to dock"));470 hover.set_text (_("Drop to add to dock"));
471471
=== modified file 'lib/Items/DockItemProvider.vala'
--- lib/Items/DockItemProvider.vala 2015-11-03 10:37:19 +0000
+++ lib/Items/DockItemProvider.vala 2016-01-09 09:20:52 +0000
@@ -85,19 +85,15 @@
85 {85 {
86 bool result = false;86 bool result = false;
87 87
88 unowned DockItem? hovered_item = null;88 unowned DockItem? target_item = null;
89 unowned DockController? controller = get_dock ();89 unowned DockController? controller = get_dock ();
90 if (controller != null && controller.window.HoveredItemProvider == this) {90 if (controller != null && controller.window.HoveredItemProvider == this) {
91 hovered_item = controller.window.HoveredItem;91 target_item = controller.position_manager.get_current_target_item (this);
92 if (hovered_item == null) {
93 var cursor = controller.renderer.local_cursor;
94 hovered_item = controller.position_manager.get_nearest_item_at (cursor.x, cursor.y, this);
95 }
96 }92 }
97 93
98 foreach (var uri in uris) {94 foreach (var uri in uris) {
99 if (!item_exists_for_uri (uri)) {95 if (!item_exists_for_uri (uri)) {
100 add_item_with_uri (uri, hovered_item);96 add_item_with_uri (uri, target_item);
101 result = true;97 result = true;
102 }98 }
103 }99 }
104100
=== modified file 'lib/PositionManager.vala'
--- lib/PositionManager.vala 2015-12-09 09:30:43 +0000
+++ lib/PositionManager.vala 2016-01-09 09:20:52 +0000
@@ -812,11 +812,10 @@
812 DrawValuesFunc? post_func = null)812 DrawValuesFunc? post_func = null)
813 {813 {
814 unowned DockPreferences prefs = controller.prefs;814 unowned DockPreferences prefs = controller.prefs;
815 unowned DockRenderer renderer = controller.renderer;
815 816
816 draw_values.clear ();817 draw_values.clear ();
817 818
818 bool external_drag_active = controller.drag_manager.ExternalDragActive;
819
820 // first we do the math as if this is a top dock, to do this we need to set819 // first we do the math as if this is a top dock, to do this we need to set
821 // up some "pretend" variables. we pretend we are a top dock because 0,0 is820 // up some "pretend" variables. we pretend we are a top dock because 0,0 is
822 // at the top.821 // at the top.
@@ -824,8 +823,7 @@
824 int height = DockHeight;823 int height = DockHeight;
825 int icon_size = IconSize;824 int icon_size = IconSize;
826 825
827 double zoom_in_progress = controller.renderer.zoom_in_progress;826 Gdk.Point cursor = renderer.local_cursor;
828 Gdk.Point cursor = controller.renderer.local_cursor;
829 827
830 // "relocate" our cursor to be on the top828 // "relocate" our cursor to be on the top
831 switch (Position) {829 switch (Position) {
@@ -888,8 +886,11 @@
888 // zoom_in_percent is a range of 1 to ZoomPercent.886 // zoom_in_percent is a range of 1 to ZoomPercent.
889 // We need a number that is 1 when ZoomIn is 0, and ZoomPercent when ZoomIn is 1.887 // We need a number that is 1 when ZoomIn is 0, and ZoomPercent when ZoomIn is 1.
890 // Then we treat this as if it were the ZoomPercent for the rest of the calculation.888 // Then we treat this as if it were the ZoomPercent for the rest of the calculation.
891 double zoom_in_percent = (prefs.ZoomEnabled ? 1.0 + (ZoomPercent - 1.0) * zoom_in_progress : 1.0);889 bool expand_for_drop = (controller.drag_manager.ExternalDragActive && !prefs.LockItems);
892 double zoom_icon_size = (prefs.ZoomEnabled ? ZoomIconSize : 2.0 * icon_size);890 bool zoom_enabled = prefs.ZoomEnabled;
891 double zoom_in_progress = (zoom_enabled || expand_for_drop ? renderer.zoom_in_progress : 0.0);
892 double zoom_in_percent = (zoom_enabled ? 1.0 + (ZoomPercent - 1.0) * zoom_in_progress : 1.0);
893 double zoom_icon_size = ZoomIconSize;
893 894
894 foreach (unowned DockItem item in items) {895 foreach (unowned DockItem item in items) {
895 DockItemDrawValue val = new DockItemDrawValue ();896 DockItemDrawValue val = new DockItemDrawValue ();
@@ -909,10 +910,10 @@
909 double offset = double.min (Math.fabs (cursor_position - center_position), zoom_icon_size);910 double offset = double.min (Math.fabs (cursor_position - center_position), zoom_icon_size);
910 911
911 double offset_percent;912 double offset_percent;
912 if (external_drag_active) {913 if (expand_for_drop) {
913 // Provide space for dropping between items914 // Provide space for dropping between items
914 offset += offset * zoom_icon_size / icon_size;915 offset += offset * zoom_icon_size / icon_size;
915 offset_percent = double.min (1.0, offset / (zoom_icon_size + ZoomIconSize));916 offset_percent = double.min (1.0, offset / (2.0 * zoom_icon_size));
916 } else {917 } else {
917 offset_percent = offset / zoom_icon_size;918 offset_percent = offset / zoom_icon_size;
918 }919 }
@@ -930,11 +931,7 @@
930 // value. The center is 100%. (1 - offset_percent) == 0,1 distance from center931 // value. The center is 100%. (1 - offset_percent) == 0,1 distance from center
931 // 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.932 // 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.
932 933
933 // for external drags with no zoom, we pretend there is actually a zoom of 200%934 offset *= zoom_in_progress / 2.0;
934 if (external_drag_active && ZoomPercent == 1.0)
935 offset *= zoom_in_progress / 2.0;
936 else
937 offset *= zoom_in_percent - 1.0;
938 offset *= 1.0 - offset_percent / 3.0;935 offset *= 1.0 - offset_percent / 3.0;
939 936
940 if (cursor_position > center_position)937 if (cursor_position > center_position)
@@ -1206,6 +1203,23 @@
1206 }1203 }
1207 1204
1208 /**1205 /**
1206 * Get the item which is the appropriate target for a drag'n'drop action.
1207 * The returned item may not hovered and is meant to be used as target
1208 * for e.g. DockContainer.add/move_to functions.
1209 * If a container is given the result will be restricted to its children.
1210 *
1211 * @param container a container or NULL
1212 */
1213 public unowned DockItem? get_current_target_item (DockContainer? container = null)
1214 {
1215 unowned DockRenderer renderer = controller.renderer;
1216 var cursor = renderer.local_cursor;
1217 var offset = (int) ((renderer.zoom_in_progress * ZoomIconSize + ItemPadding) / 2.0);
1218
1219 return get_nearest_item_at (cursor.x + offset, cursor.y + offset, container);
1220 }
1221
1222 /**
1209 * Get's the x and y position to display a menu for a dock item.1223 * Get's the x and y position to display a menu for a dock item.
1210 *1224 *
1211 * @param hovered the item that is hovered1225 * @param hovered the item that is hovered
12121226
=== modified file 'lib/libplank.symbols'
--- lib/libplank.symbols 2015-12-09 09:30:43 +0000
+++ lib/libplank.symbols 2016-01-09 09:20:52 +0000
@@ -521,6 +521,7 @@
521plank_position_manager_get_background_region521plank_position_manager_get_background_region
522plank_position_manager_get_barrier522plank_position_manager_get_barrier
523plank_position_manager_get_BottomPadding523plank_position_manager_get_BottomPadding
524plank_position_manager_get_current_target_item
524plank_position_manager_get_cursor_region525plank_position_manager_get_cursor_region
525plank_position_manager_get_dock_draw_position526plank_position_manager_get_dock_draw_position
526plank_position_manager_get_dock_window_region527plank_position_manager_get_dock_window_region

Subscribers

People subscribed via source and target branches

to status/vote changes: