Esempio n. 1
0
        // リストのつなぎ換えだけ
        private void UnlinkChild(DebugUiControl child)
        {
            Debug.Assert(child._parent == this, "それは樸の子じゃないよ!");
            // 前と後を取得
            var next = child._nextBrother;
            var prev = child._previousBrother;

            if (next != null)
            {
                next._previousBrother = prev;
            }
            // nextがないケースではこれが最後。
            else
            {
                _lastChild = prev;
            }

            if (prev != null)
            {
                prev._nextBrother = next;
            }
            // prevがないケースではこれが最初
            else
            {
                _firstChild = next;
            }
            child._nextBrother = child._previousBrother = null;
        }
Esempio n. 2
0
 public void Add(
     DebugUiControl control,
     float offsetX = 0f,
     float offsetY = 0)
 {
     _root.AddChild(control, offsetX, offsetY);
 }
Esempio n. 3
0
 public override void AddChild(
     DebugUiControl child,
     float offsetX = 0f,
     float offsetY = 0f)
 {
     _contentPanel.AddChild(child, offsetX, offsetY);
 }
Esempio n. 4
0
        private void DrawDragMark(DebugUiControl dragged)
        {
            float s  = dragged.dragMarkSize;
            float x0 = _input.pointerX;
            float y0 = _input.pointerY;
            float x1 = x0 - (s * 0.5f);
            float y1 = y0 - s;
            float x2 = x0 + (s * 0.5f);
            float y2 = y0 - s;

            // 背景
            _renderer.color = dragged.dragMarkColor;
            _renderer.AddTriangle(x0, y0, x1, y1, x2, y2);
            // 枠
            _renderer.color = new Color32(255, 255, 255, 255);
            _renderer.AddTriangleFrame(x0, y0, x1, y1, x2, y2, s * 0.125f);
            // テキスト
            if (dragged.dragMarkLetter != '\0')
            {
                _renderer.color = dragged.dragMarkLetterColor;
                _renderer.AddText(
                    new string(dragged.dragMarkLetter, 1),
                    s * 0.5f,
                    x0 - (s * 0.25f),
                    y1,
                    dragged.dragMarkSize,
                    dragged.dragMarkSize);
            }
        }
Esempio n. 5
0
        // offsetはLocalPositionに足されるので注意
        public void Add(
            DebugUiControl child,
            float offsetX = 0f,
            float offsetY = 0f,
            AlignX alignX = AlignX.Left,
            AlignY alignY = AlignY.Top)
        {
            float x = 0f;

            switch (alignX)
            {
            case AlignX.Center: x = (this.width - child.width) * 0.5f; break;

            case AlignX.Right: x = this.width - child.width; break;
            }
            float y = 0f;

            switch (alignY)
            {
            case AlignY.Center: y = (this.height - child.height) * 0.5f; break;

            case AlignY.Bottom: y = (this.height - child.height); break;
            }
            child.SetLocalPosition(
                child.localLeftX + offsetX + x,
                child.localTopY + offsetY + y);
            AddChildAsTail(child);
        }
Esempio n. 6
0
 public virtual void RemoveChild(DebugUiControl child)
 {
     // リストから切断
     UnlinkChild(child);
     // まず内部を破棄
     child.Dispose();
     child.Destroy();
 }
Esempio n. 7
0
 public void AddAuto(DebugUiControl child)
 {
     // 一旦無限に広げて配置後、再配置
     _contentPanel.SetSize(float.MaxValue, float.MaxValue);
     _contentPanel.AddAuto(child);
     _contentPanel.FitSize();
     Layout();
 }
Esempio n. 8
0
 public void Initialize(DebugPrimitiveRenderer2D renderer)
 {
     _renderer          = renderer;
     _root              = new DebugUiControl();
     _input             = new Input();
     this.raycastTarget = true;
     inputEnabled       = true;
 }
Esempio n. 9
0
 public void Add(
     DebugUiControl control,
     float offsetX         = 0f,
     float offsetY         = 0,
     DebugUi.AlignX alignX = DebugUi.AlignX.Left,
     DebugUi.AlignY alignY = DebugUi.AlignY.Top)
 {
     _root.Add(control, offsetX, offsetY, alignX, alignY);
 }
Esempio n. 10
0
 public void Add(
     DebugUiControl child,
     float offsetX = 0f,
     float offsetY = 0f,
     AlignX alignX = AlignX.Left,
     AlignY alignY = AlignY.Top)
 {
     _contentPanel.Add(child, offsetX, offsetY, alignX, alignY);
 }
Esempio n. 11
0
 // offsetはLocalPositionに足されるので注意
 public virtual void AddChild(
     DebugUiControl child,
     float offsetX = 0f,
     float offsetY = 0f)
 {
     child.SetLocalPosition(
         child.localLeftX + offsetX,
         child.localTopY + offsetY);
     LinkChildToTail(child);
     child._parent = this;
 }
Esempio n. 12
0
 public void Destroy()
 {
     Dispose();
     _nextBrother = _previousBrother = null;
     _enabled     = false;
     // 以下まともな値が取れないようにしてバグを発覚しやすく
     localLeftX = float.NaN;
     localTopY  = float.NaN;
     width      = float.NaN;
     height     = float.NaN;
 }
Esempio n. 13
0
 private void Destroy()
 {
     RemoveAllChild();
     _parent  = _nextBrother = _previousBrother = null;
     _enabled = false;
     // 以下まともな値が取れないようにしてバグを発覚しやすく
     localLeftX = float.NaN;
     localTopY  = float.NaN;
     width      = float.NaN;
     height     = float.NaN;
 }
Esempio n. 14
0
        public void RemoveAllChild()
        {
            var child = _firstChild;

            while (child != null)
            {
                var next = child.nextBrother;
                child.Destroy();
                child = next;
            }
            _firstChild = _lastChild = null;
        }
Esempio n. 15
0
        public void InsertAfter(DebugUiControl newNode)
        {
            Debug.Assert(newNode._previousBrother == null, "already in tree.");
            Debug.Assert(newNode._nextBrother == null, "already in tree.");
            var next = _nextBrother;

            newNode._previousBrother = this;
            newNode._nextBrother     = next;
            _nextBrother             = newNode;
            if (next != null)
            {
                next._previousBrother = newNode;
            }
        }
Esempio n. 16
0
        public void InsertBefore(DebugUiControl newNode)
        {
            Debug.Assert(newNode._previousBrother == null, "already in tree.");
            Debug.Assert(newNode._nextBrother == null, "already in tree.");
            var prev = _previousBrother;

            newNode._nextBrother     = this;
            newNode._previousBrother = prev;
            _previousBrother         = newNode;
            if (prev != null)
            {
                prev._nextBrother = newNode;
            }
        }
Esempio n. 17
0
 // リストのつなぎ換えだけ
 public void UnlinkChild(DebugUiControl child)
 {
     // 先頭であれば、
     if (child == _firstChild)
     {
         _firstChild = child.nextBrother;
     }
     // 末尾であれば
     if (child == _lastChild)
     {
         _lastChild = child.previousBrother;
     }
     child.Unlink();
 }
Esempio n. 18
0
        public void Unlink()
        {
            var prev = _previousBrother;
            var next = _nextBrother;

            _previousBrother = _nextBrother = null;
            if (prev != null)
            {
                prev._nextBrother = next;
            }
            if (next != null)
            {
                next._previousBrother = prev;
            }
        }
Esempio n. 19
0
 // リストのつなぎ換えだけ
 private void LinkChildToTail(DebugUiControl child)
 {
     child._nextBrother = null;
     // 末尾がnullの場合、先頭もnull。
     if (_lastChild == null)
     {
         Debug.Assert(_firstChild == null);
         _firstChild            = _lastChild = child;
         child._previousBrother = null;
     }
     // 末尾が非nullの場合、リンクを生成
     else
     {
         _lastChild._nextBrother = child;
         child._previousBrother  = _lastChild;
         _lastChild = child;
     }
 }
Esempio n. 20
0
 // リストのつなぎ換えだけ
 public void AddChildAsTail(DebugUiControl child)
 {
     Debug.Assert(child.previousBrother == null, "already in tree.");
     Debug.Assert(child.nextBrother == null, "already in tree.");
     // 末尾がnullの場合、先頭もnull。
     if (_lastChild == null)
     {
         Debug.Assert(_firstChild == null);
         _firstChild = _lastChild = child;
     }
     // 末尾が非nullの場合、リンクを生成
     else
     {
         if (_lastChild == child)                 // 同じものを二連続足したバグは無限ループして厄介なので検出して殺してやる
         {
             throw new System.InvalidOperationException("same object added. it must be BUG.");
         }
         _lastChild.InsertAfter(child);
         _lastChild = child;
     }
     Debug.Assert(child.previousBrother != child);
     Debug.Assert(child.nextBrother != child);
 }
Esempio n. 21
0
        public void AddChildAuto(DebugUiControl control)
        {
            // 今の位置に入れて入るかを判定
            float childWidth  = control.width;
            float childHeight = control.height;
            float childRight  = _x + borderWidth + childWidth;
            float maxRight    = width;
            float maxBottom   = height;

            if (borderEnabled)
            {
                maxRight  -= borderWidth * 2f;
                maxBottom -= borderWidth * 2f;
            }
            // 右にあふれた。改行する。
            if (childRight > maxRight)
            {
                BreakLine();
            }
            // 下にあふれる分には使い手の責任とする。
            AddChild(control, _x, _y);
            _x += childWidth + borderWidth;
            _currentLineHeight = Mathf.Max(_currentLineHeight, childHeight);
        }
Esempio n. 22
0
 public void ClearLink()
 {
     _previousBrother = _nextBrother = null;
 }
Esempio n. 23
0
 public void Dispose()
 {
     _root     = null;
     _input    = null;
     _renderer = null;
 }
Esempio n. 24
0
        public virtual void AddAuto(DebugUiControl child)
        {
            float minX         = 0f;
            float minY         = 0f;
            float maxX         = width;
            float maxY         = height;
            float borderOffset = borderEnabled ? (borderWidth * 2f) : 0f;

            if (borderEnabled)
            {
                minX += borderOffset;
                minY += borderOffset;
                maxX -= borderOffset;
                maxY -= borderOffset;
            }
            // 右
            float  dx     = 0f;
            float  dy     = 0f;
            float  size   = 0f;
            AlignX alignX = AlignX.Left;
            AlignY alignY = AlignY.Top;

            if ((layout == Layout.RightDown) || (layout == Layout.RightUp))
            {
                alignX = AlignX.Left;
                alignY = (layout == Layout.RightDown) ? AlignY.Top : AlignY.Bottom;
                float childRight = _x + borderWidth + child.width;
                if (childRight > maxX)                 // あふれた。改行する。
                {
                    BreakLine();
                }
                dx   = child.width + borderWidth;
                size = child.height;
            }
            else if ((layout == Layout.LeftDown) || (layout == Layout.LeftUp))
            {
                alignX = AlignX.Right;
                alignY = (layout == Layout.LeftDown) ? AlignY.Top : AlignY.Bottom;
                float childLeft = _x - borderWidth - child.width;
                if (childLeft < minX)                 // あふれた。改行する。
                {
                    BreakLine();
                }
                dx   = -child.width - borderWidth;
                size = child.height;
            }
            else if ((layout == Layout.DownRight) || (layout == Layout.DownLeft))
            {
                alignY = AlignY.Top;
                alignX = (layout == Layout.DownRight) ? AlignX.Left : AlignX.Right;
                float childBottom = _y + borderWidth + child.height;
                if (childBottom > maxY)                 // あふれた。改行する。
                {
                    BreakLine();
                }
                dy   = child.height + borderWidth;
                size = child.width;
            }
            else if ((layout == Layout.UpRight) || (layout == Layout.UpLeft))
            {
                alignY = AlignY.Bottom;
                alignX = (layout == Layout.UpRight) ? AlignX.Left : AlignX.Right;
                float childTop = _y - borderWidth - child.height;
                if (childTop < minY)                 // あふれた。改行する。
                {
                    BreakLine();
                }
                dy   = -child.height - borderWidth;
                size = child.width;
            }
            Add(child, _x, _y, alignX, alignY);
            _x += dx;
            _y += dy;
            _currentLineSize = Mathf.Max(_currentLineSize, size);
        }
Esempio n. 25
0
 private void SetAsLastChild(DebugUiControl child)
 {
     UnlinkChild(child);
     LinkChildToTail(child);
 }
Esempio n. 26
0
 private void SetAsFirstChild(DebugUiControl child)
 {
     UnlinkChild(child);
     LinkChildToHead(child);
 }
Esempio n. 27
0
 public void Remove(DebugUiControl control)
 {
     _root.RemoveChild(control);
 }
Esempio n. 28
0
 public override void RemoveChild(DebugUiControl child)
 {
     _contentPanel.RemoveChild(child);
 }
Esempio n. 29
0
 public void MoveToTop(DebugUiControl control)
 {
     _root.UnlinkChild(control);
     _root.AddChildAsTail(control);
 }