Exemple #1
0
        public override void RemoveChild(ParentedElement child, bool destroy)
        {
            int index = _childStack.FindIndex(x => x == child);

            _childStack.Remove(child);
            placeChild(_childStack[index]);
            base.RemoveChild(child, destroy);
        }
Exemple #2
0
        /// <summary>
        /// Arranges Panel Properly
        /// </summary>
        /// <param name="child"></param>
        private void placeChild(ParentedElement child)
        {
            int index = _childStack.FindIndex(x => x == child);

            if (index == 0)
            {
                child.RelativeLocation = Vector2.Zero;
                index++;
            }

            Action <Func <ParentedElement, Vector2> > place =
                func =>
            {
                for (int i = index; i < _childStack.Count; i++)
                {
                    var prev = _childStack[i - 1];
                    var cur  = _childStack[i];

                    cur.SilentlyMove(func(prev));
                }
            };

            switch (StackingDirection)
            {
            case DirectionType.Down:
                place(prev =>
                      prev.Location + (prev.ElementSize.Y + Buffering) * Vector2.UnitY);
                break;

            case DirectionType.Left:
                place(prev =>
                      prev.Location + (prev.Location.X + prev.ElementSize.X + Buffering) * Vector2.UnitX);
                break;

            case DirectionType.Up:
                place(prev =>
                      prev.Location - (prev.Location.Y + prev.ElementSize.Y + Buffering) * Vector2.UnitY);
                break;

            case DirectionType.Right:
                place(prev =>
                      prev.Location - (prev.Location.X + prev.ElementSize.X + Buffering) * Vector2.UnitX);
                break;
            }
            EnlargeToFitChildren(0f);
        }
Exemple #3
0
 public void InsertChild(ParentedElement child, int index, bool makeActive)
 {
     _childStack.Insert(index, child);
     placeChild(child);
     base.AddChild(child, makeActive);
 }
Exemple #4
0
 public override void  AddChild(ParentedElement child, bool makeActive)
 {
     base.AddChild(child, makeActive);
     _childStack.Add(child);
     placeChild(child);
 }