Ejemplo n.º 1
0
 private void DockLeaf(TreeTrunk trunk, TreeLeaf leaf, DockType dockType)
 {
     if (!closedLeafs.Contains(leaf))
     {
         Log.E("Err: Have Exist");
     }
     else
     {
         trunk.DockLeaf(leaf, dockType);
         closedLeafs.Remove(leaf);
         if (onDockLeaf != null)
         {
             onDockLeaf(leaf);
         }
     }
 }
Ejemplo n.º 2
0
        private void DragWindow()
        {
            List <TreeLeaf> OpenLeafs = allLeafs.FindAll((leaf) => { return(!closedLeafs.Contains(leaf)); });
            Event           e         = Event.current;

            if (e.button != 0)
            {
                return;
            }
            if (!position.Contains(e.mousePosition))
            {
                return;
            }

            if (e.type == EventType.Repaint && dragleaf != null)
            {
                Styles.FlowWindow.Draw(new Rect(e.mousePosition, Vector2.one * 150), dragleaf.titleContent, false, false, false, false);
                Styles.SelectRect.Draw(selectionRect, false, false, false, false);
            }
            if (e.type == EventType.MouseDrag)
            {
                if (dragleaf == null)
                {
                    dragleaf = OpenLeafs.Find((leaf) => { return(leaf.IsOverTitle(e.mousePosition)); });
                }
                if (dragleaf == null)
                {
                    return;
                }
                var overLeaf = OpenLeafs.Find((leaf) => { return(leaf.IsOver(e.mousePosition)); });
                if (overLeaf == null)
                {
                    selectionRect = Rect.zero;
                    return;
                }
                Vector2 v   = e.mousePosition;
                Rect    r   = overLeaf.position;
                float   spH = r.height / 3;
                float   spW = r.width / 3;
                if (v.y < r.yMin + spH &&
                    v.x > r.xMin + spW &&
                    v.x < r.xMax - spW)
                {
                    selectionRect = new Rect(r.position, new Vector2(r.width, spH));
                    docktype      = DockType.Up;
                }
                else if (v.y > r.yMax - spH &&
                         v.x > r.xMin + spW &&
                         v.x < r.xMax - spW)
                {
                    selectionRect = new Rect(new Vector2(r.x, r.yMax - spH),
                                             new Vector2(r.width, spH));
                    docktype = DockType.Down;
                }
                else if (v.x > r.xMax - spW &&
                         v.y < r.yMax - spH &&
                         v.y > r.yMin + spH)
                {
                    selectionRect = new Rect(new Vector2(r.xMax - spW, r.y),
                                             new Vector2(spW, r.height));
                    docktype = DockType.Right;
                }
                else if (v.x < r.xMin + spW &&
                         v.y < r.yMax - spH &&
                         v.y > r.yMin + spH)
                {
                    selectionRect = new Rect(r.position, new Vector2(spW, r.height));
                    docktype      = DockType.Left;
                }
                else
                {
                    selectionRect = Rect.zero;
                }
                Repaint();
            }
            else if (e.type == EventType.MouseUp)
            {
                if (dragleaf != null)
                {
                    var overLeaf = OpenLeafs.Find((leaf) => { return(leaf.IsOver(e.mousePosition)); });
                    if (overLeaf != null && selectionRect != Rect.zero && overLeaf != dragleaf)
                    {
                        root.RemoveLeaf(dragleaf);
                        TreeTrunk node = overLeaf.parent as TreeTrunk;
                        node.DockLeaf(overLeaf, dragleaf, docktype);
                    }
                    dragleaf      = null;
                    selectionRect = Rect.zero;
                    Repaint();
                }
            }
        }