[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [plasma-desktop/Plasma/5.3] containments/panel/contents: fix dnd behavior
From:       Marco Martin <notmart () gmail ! com>
Date:       2015-04-17 10:32:53
Message-ID: E1Yj3Zt-0006t1-LP () scm ! kde ! org
[Download RAW message or body]

Git commit ef61a147be08190e80d2744c39d8679a59ae3914 by Marco Martin.
Committed on 18/04/2015 at 10:29.
Pushed by mart into branch 'Plasma/5.3'.

fix dnd behavior

make the drag and drop spacer behavior more stable:
panel doesn't flicker anymore when moving around the mouse with a drag

M  +29   -1    containments/panel/contents/code/LayoutManager.js
M  +4    -0    containments/panel/contents/ui/main.qml

http://commits.kde.org/plasma-desktop/ef61a147be08190e80d2744c39d8679a59ae3914

diff --git a/containments/panel/contents/code/LayoutManager.js \
b/containments/panel/contents/code/LayoutManager.js index c3dc37e..2463f9e 100644
--- a/containments/panel/contents/code/LayoutManager.js
+++ b/containments/panel/contents/code/LayoutManager.js
@@ -127,6 +127,10 @@ function insertAfter(item1, item2) {
             child.parent = root;
             break;
         } else if (child === item1) {
+            //Already in position, do nothing
+            if (layout.children[i+1] === item2) {
+                return;
+            }
             break;
         }
 
@@ -174,7 +178,31 @@ function insertAtCoordinates(item, x, y) {
     }
     var child = layout.childAt(x, y);
 
-    if (!child || child === item) {
+    //if we got a place inside the space between 2 applets, we have to find it \
manually +    if (!child) {
+        if (root.isHorizontal) {
+            for (var i = 0; i < layout.children.length; ++i) {
+                var candidate = layout.children[i];
+                if (x >= candidate.x && x < candidate.x + candidate.width + \
layout.rowSpacing) { +                    child = candidate;
+                    break;
+                }
+            }
+        } else {
+            for (var i = 0; i < layout.children.length; ++i) {
+                var candidate = layout.children[i];
+                if (y >= candidate.x && y < candidate.y + candidate.height + \
layout.columnSpacing) { +                    child = candidate;
+                    break;
+                }
+            }
+        }
+    }
+    //already in position
+    if (child === item) {
+        return;
+    }
+    if (!child) {
         child = layout.children[0];
     }
     item.parent = root;
diff --git a/containments/panel/contents/ui/main.qml \
b/containments/panel/contents/ui/main.qml index e291240..b9ef1d7 100644
--- a/containments/panel/contents/ui/main.qml
+++ b/containments/panel/contents/ui/main.qml
@@ -192,7 +192,9 @@ function checkLastSpacer() {
         if (plasmoid.immutable) {
             return;
         }
+       
         plasmoid.processMimeData(event.mimeData, event.x, event.y);
+        dndSpacer.parent = root;
         root.fixedWidth = 0;
         root.fixedHeight = 0;
     }
@@ -388,6 +390,8 @@ function checkLastSpacer() {
     GridLayout {
         id: currentLayout
         property bool isLayoutHorizontal
+        rowSpacing: units.gridUnit.smallSpacing
+        columnSpacing: units.gridUnit.smallSpacing
 
         Layout.preferredWidth: {
             var width = 0;


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic