Browse Source

Added "inside" dragging to listview

Brian Fiete 2 years ago
parent
commit
227b5f4982
2 changed files with 40 additions and 10 deletions
  1. 26 10
      BeefLibs/Beefy2D/src/theme/dark/DarkListView.bf
  2. 14 0
      IDE/src/ui/WatchPanel.bf

+ 26 - 10
BeefLibs/Beefy2D/src/theme/dark/DarkListView.bf

@@ -655,6 +655,11 @@ namespace Beefy.theme.dark
 							}
 							else
 							{
+								var darkListView = (DarkListView)mListView;
+
+								if (mDragTarget.mParentItem != mListView.GetRoot())
+									targetX += darkListView.mLabelX - darkListView.mChildIndent;
+
 						        if ((mDragKind == .Inside) || (mDragKind == .After)) // Inside or after
 						            targetY += mDragTarget.mSelfHeight;
 						        
@@ -805,16 +810,27 @@ namespace Beefy.theme.dark
                 float childX;
                 float childY;
                 foundWidget.SelfToRootTranslate(0, 0, out childX, out childY);
-                
-                float yOfs = aY - childY;
-                if (yOfs < mHeight / 2)
-                    mDragKind = .Before;
-                else
-                {
-                    mDragKind = .After;
-                    if ((listViewItem.mOpenButton != null) && (listViewItem.mOpenButton.mIsOpen))
-                        mDragKind = .None;
-                }
+
+				if ((listViewItem.mOpenButton != null) && (aX - childX < GS!(30)))
+				{
+					mDragKind = .Inside;
+				}
+				else
+				{
+	                float yOfs = aY - childY;
+	                if (yOfs < mHeight / 2)
+	                    mDragKind = .Before;
+	                else
+	                {
+	                    mDragKind = .After;
+	                    if ((listViewItem.mOpenButton != null) && (!listViewItem.mChildItems.IsEmpty)  && (listViewItem.mOpenButton.mIsOpen))
+						{
+							var firstChild = listViewItem.mChildItems[0];
+							foundWidget = firstChild;
+	                        mDragKind = .Before;
+						}
+	                }
+				}
 
 				if (Math.Abs(dY) < mSelfHeight * 0.21f)
 				{

+ 14 - 0
IDE/src/ui/WatchPanel.bf

@@ -1984,6 +1984,20 @@ namespace IDE.ui
                 return;
             if (dragSource.mLabel == "")
                 return;
+
+			if (dragKind == .Inside)
+			{
+				dragSource.SelfToRootTranslate(evt.mX, evt.mY, var rootX, var rootY);
+				dragTarget.RootToSelfTranslate(rootX, rootY, var targetX, var targetY);
+
+				//dragSource.SelfToOtherTranslate(dragTarget, evt.mX, evt.mY, var targetX, var targetY);
+
+				if (targetY < dragTarget.mSelfHeight / 2)
+					dragKind = .Before;
+				else
+					dragKind = .After;
+			}
+
             while (dragTarget.mParentItem != mListView.GetRoot())
             {
                 // Check for if we're dragging after the last open child item.  If so, treat it as if we're dragging to after the topmost parent