Ejemplo n.º 1
0
 /// <summary>
 /// 从缓存中读取布局信息
 /// </summary>
 /// <param name="fake">数据缓存</param>
 /// <param name="index">索引位置</param>
 public void LoadFromBuffer(FakeStructArray fake, int index)
 {
     Left  = layout.GetLine(fake[index, 0]);
     Right = layout.GetLine(fake[index, 1]);
     Top   = layout.GetLine(fake[index, 2]);
     Down  = layout.GetLine(fake[index, 3]);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 获取id的存储id
 /// </summary>
 /// <param name="line"></param>
 /// <returns></returns>
 public int GetLineID(DockPanelLine line)
 {
     if (line == Left)
     {
         return(0);
     }
     if (line == Right)
     {
         return(1);
     }
     if (line == Top)
     {
         return(2);
     }
     if (line == Down)
     {
         return(3);
     }
     for (int i = 0; i < lines.Count; i++)
     {
         if (lines[i] == line)
         {
             return(i + 3);
         }
     }
     return(-1);
 }
        void InitialFixLine()
        {
            ModelElement m = new ModelElement();

            m.Load(LineMod.ModData);
            Left = new DockPanelLine(this, m, Direction.Vertical, false);

            m = new ModelElement();
            m.Load(LineMod.ModData);
            Right = new DockPanelLine(this, m, Direction.Vertical, false);

            m = new ModelElement();
            m.Load(LineMod.ModData);
            Top = new DockPanelLine(this, m, Direction.Vertical, false);

            m = new ModelElement();
            m.Load(LineMod.ModData);
            Down = new DockPanelLine(this, m, Direction.Vertical, false);

            Vector2 size = model.data.sizeDelta;
            float   rx   = size.x * 0.5f;
            float   ty   = size.y * 0.5f;

            Left.SetSize(new Vector2(-rx, 0), new Vector2(LineWidth, size.y));
            Right.SetSize(new Vector2(rx, 0), new Vector2(LineWidth, size.y));
            Top.SetSize(new Vector2(0, ty), new Vector2(size.x, LineWidth));
            Down.SetSize(new Vector2(0, -ty), new Vector2(size.x, LineWidth));
        }
        DockPanelLine AddVerticalLine(float r)
        {
            var m = new ModelElement();

            m.Load(Left.model.ModData);
            float ex = Top.model.data.localPosition.y;
            float sx = Down.model.data.localPosition.y;
            float w  = ex - sx;

            if (w < 0)
            {
                w = -w;
            }
            DockPanelLine line = new DockPanelLine(layout, m, Direction.Vertical);
            var           pos  = model.data.localPosition;
            float         dx   = Left.model.data.localPosition.x;

            pos.x  = Right.model.data.localPosition.x - dx;
            pos.x *= r;
            pos.x += dx;
            line.SetSize(pos, new Vector2(DockPanel.LineWidth, w));
            line.SetLineStart(Down);
            line.SetLineEnd(Top);
            return(line);
        }
        DockPanelLine AddHorizontalLine(float r)
        {
            var m = new ModelElement();

            m.Load(Top.model.ModData);
            float ex = Right.model.data.localPosition.x;
            float sx = Left.model.data.localPosition.x;
            float w  = ex - sx;

            if (w < 0)
            {
                w = -w;
            }
            DockPanelLine line = new DockPanelLine(layout, m, Direction.Horizontal);
            var           pos  = model.data.localPosition;
            float         dy   = Down.model.data.localPosition.y;

            pos.y  = Top.model.data.localPosition.y - dy;
            pos.y *= r;
            pos.y += dy;
            line.SetSize(pos, new Vector2(w, DockPanel.LineWidth));
            line.SetLineStart(Left);
            line.SetLineEnd(Right);
            return(line);
        }
Ejemplo n.º 6
0
 public void SetLineStart(DockPanelLine line)
 {
     if (LineStart != null)
     {
         LineStart.AdjacentLines.Remove(this);
     }
     LineStart = line;
     LineStart.AdjacentLines.Add(this);
 }
Ejemplo n.º 7
0
 public void SetLeftLine(DockPanelLine line)
 {
     if (Left != null)
     {
         Left.Right.Remove(this);
     }
     Left = line;
     line.Right.Add(this);
 }
Ejemplo n.º 8
0
 public void SetRightLine(DockPanelLine line)
 {
     if (Right != null)
     {
         Right.Left.Remove(this);
     }
     Right = line;
     line.Left.Add(this);
 }
Ejemplo n.º 9
0
 public void SetTopLine(DockPanelLine line)
 {
     if (Top != null)
     {
         Top.Down.Remove(this);
     }
     Top = line;
     line.Down.Add(this);
 }
Ejemplo n.º 10
0
 public void SetDownLine(DockPanelLine line)
 {
     if (Down != null)
     {
         Down.Top.Remove(this);
     }
     Down = line;
     line.Top.Add(this);
 }
Ejemplo n.º 11
0
 public void SetLineEnd(DockPanelLine line)
 {
     if (LineEnd != null)
     {
         LineEnd.AdjacentLines.Remove(this);
     }
     LineEnd = line;
     LineEnd.AdjacentLines.Add(this);
 }
Ejemplo n.º 12
0
 void Release()
 {
     if (LineStart != null)
     {
         LineStart.AdjacentLines.Remove(this);
     }
     if (LineEnd != null)
     {
         LineEnd.AdjacentLines.Remove(this);
     }
     LineStart = null;
     LineEnd   = null;
 }
Ejemplo n.º 13
0
        DockPanelLine AddVLine(float x)
        {
            var   m  = HGUIManager.GameBuffer.Clone(layout.LineMod).GetComponent <UIElement>();
            float ex = Top.Enity.transform.localPosition.y;
            float sx = Down.Enity.transform.localPosition.y;
            float w  = ex - sx;

            if (w < 0)
            {
                w = -w;
            }
            DockPanelLine line = new DockPanelLine(layout, m, Direction.Vertical);
            var           pos  = model.transform.localPosition;

            pos.x = x;
            line.SetSize(pos, new Vector2(DockPanel.LineWidth, w));
            line.SetLineStart(Down);
            line.SetLineEnd(Top);
            return(line);
        }
        public void MergeDown(DockPanelLine line)
        {
            line.Release();
            Down.AddRange(line.Down);
            var areas = line.Down;

            for (int i = 0; i < areas.Count; i++)
            {
                areas[i].Top = this;
            }
            model.data.localPosition.x = line.model.data.localPosition.x;
            var al = line.AdjacentLines;
            int c  = al.Count - 1;

            for (; c >= 0; c--)
            {
                var l = al[c];
                l.SetLineEnd(this);
            }
        }
Ejemplo n.º 15
0
        DockPanelLine AddHLine(float y)
        {
            var   m  = HGUIManager.GameBuffer.Clone(layout.LineMod).GetComponent <UIElement>();
            float ex = Right.Enity.transform.localPosition.x;
            float sx = Left.Enity.transform.localPosition.x;
            float w  = ex - sx;

            if (w < 0)
            {
                w = -w;
            }
            DockPanelLine line = new DockPanelLine(layout, m, Direction.Horizontal);
            var           pos  = model.transform.localPosition;

            pos.y = y;
            line.SetSize(pos, new Vector2(w, DockPanel.LineWidth));
            line.SetLineStart(Left);
            line.SetLineEnd(Right);
            return(line);
        }
        public void MergeRight(DockPanelLine line)
        {
            line.Release();
            Right.AddRange(line.Right);
            var areas = line.Right;

            for (int i = 0; i < areas.Count; i++)
            {
                areas[i].Left = this;
            }
            model.data.localPosition.y = line.model.data.localPosition.y;
            var al = line.AdjacentLines;
            int c  = al.Count - 1;

            for (; c >= 0; c--)
            {
                var l = al[c];
                l.SetLineStart(this);
            }
        }
Ejemplo n.º 17
0
 /// <summary>
 /// 从布局数据中载入
 /// </summary>
 /// <param name="fake">数据缓存</param>
 /// <param name="index">索引</param>
 public void LoadFromBuffer(FakeStructArray fake, int index)
 {
     direction                     = (Direction)fake[index, 0];
     Enity.m_sizeDelta.x           = fake.GetFloat(index, 1);
     Enity.m_sizeDelta.y           = fake.GetFloat(index, 2);
     Enity.transform.localPosition = new Vector3(fake.GetFloat(index, 3), fake.GetFloat(index, 4), 0);
     LineStart                     = layout.GetLine(fake[index, 5]);
     LineEnd = layout.GetLine(fake[index, 6]);
     LoadAdjacentArea(Left, fake.GetData <int[]>(index, 7));
     LoadAdjacentArea(Right, fake.GetData <int[]>(index, 8));
     LoadAdjacentArea(Top, fake.GetData <int[]>(index, 9));
     LoadAdjacentArea(Down, fake.GetData <int[]>(index, 10));
     int[] ids = fake.GetData <int[]>(index, 11);
     if (ids != null)
     {
         for (int i = 0; i < ids.Length; i++)
         {
             AdjacentLines.Add(layout.GetLine(ids[i]));
         }
     }
 }
Ejemplo n.º 18
0
        /// <summary>
        /// 向左合并
        /// </summary>
        /// <param name="line">目标线</param>
        public void MergeLeft(DockPanelLine line)
        {
            line.Release();
            Left.AddRange(line.Left);
            var areas = line.Left;

            for (int i = 0; i < areas.Count; i++)
            {
                areas[i].Right = this;
            }
            var pos = Enity.localPosition;

            pos.y = line.Enity.localPosition.y;
            Enity.localPosition = pos;
            var al = line.AdjacentLines;
            int c  = al.Count - 1;

            for (; c >= 0; c--)
            {
                var l = al[c];
                l.SetLineEnd(this);
            }
        }
Ejemplo n.º 19
0
        /// <summary>
        /// 向上合并
        /// </summary>
        /// <param name="line">目标线</param>
        public void MergeTop(DockPanelLine line)
        {
            line.Release();
            Top.AddRange(line.Top);
            var areas = line.Top;

            for (int i = 0; i < areas.Count; i++)
            {
                areas[i].Down = this;
            }
            var pos = Enity.localPosition;

            pos.x = line.Enity.localPosition.x;
            Enity.localPosition = pos;
            var al = line.AdjacentLines;
            int c  = al.Count - 1;

            for (; c >= 0; c--)
            {
                var l = al[c];
                l.SetLineStart(this);
            }
        }
Ejemplo n.º 20
0
        void InitialFixLine()
        {
            var m = HGUIManager.GameBuffer.Clone(LineMod).GetComponent <UIElement>();

            Left = new DockPanelLine(this, m, Direction.Vertical, false);

            m     = HGUIManager.GameBuffer.Clone(LineMod).GetComponent <UIElement>();
            Right = new DockPanelLine(this, m, Direction.Vertical, false);

            m   = HGUIManager.GameBuffer.Clone(LineMod).GetComponent <UIElement>();
            Top = new DockPanelLine(this, m, Direction.Vertical, false);

            m    = HGUIManager.GameBuffer.Clone(LineMod).GetComponent <UIElement>();
            Down = new DockPanelLine(this, m, Direction.Vertical, false);

            Vector2 size = Enity.SizeDelta;
            float   rx   = size.x * 0.5f;
            float   ty   = size.y * 0.5f;

            Left.SetSize(new Vector2(-rx, 0), new Vector2(LineWidth, size.y));
            Right.SetSize(new Vector2(rx, 0), new Vector2(LineWidth, size.y));
            Top.SetSize(new Vector2(0, ty), new Vector2(size.x, LineWidth));
            Down.SetSize(new Vector2(0, -ty), new Vector2(size.x, LineWidth));
        }
Ejemplo n.º 21
0
        /// <summary>
        /// 向右合并
        /// </summary>
        /// <param name="line">目标线</param>
        public void MergeRight(DockPanelLine line)
        {
            line.Release();
            Right.AddRange(line.Right);
            var areas = line.Right;

            for (int i = 0; i < areas.Count; i++)
            {
                areas[i].Left = this;
            }
            var trans = Enity.transform;
            var pos   = trans.localPosition;

            pos.y = line.Enity.transform.localPosition.y;
            trans.localPosition = pos;
            var al = line.AdjacentLines;
            int c  = al.Count - 1;

            for (; c >= 0; c--)
            {
                var l = al[c];
                l.SetLineStart(this);
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        /// 向下合并
        /// </summary>
        /// <param name="line">目标线</param>
        public void MergeDown(DockPanelLine line)
        {
            line.Release();
            Down.AddRange(line.Down);
            var areas = line.Down;

            for (int i = 0; i < areas.Count; i++)
            {
                areas[i].Top = this;
            }
            var trans = Enity.transform;
            var pos   = trans.localPosition;

            pos.x = line.Enity.transform.localPosition.x;
            trans.localPosition = pos;
            var al = line.AdjacentLines;
            int c  = al.Count - 1;

            for (; c >= 0; c--)
            {
                var l = al[c];
                l.SetLineEnd(this);
            }
        }