Exemplo n.º 1
0
        public IMGUI() : base(0)
        {
            CurrentParent = this;
            ActiveComponents.Add(Id, this);

            GuiHelper.CurrentIMGUI = this;
        }
Exemplo n.º 2
0
 private void Cleanup()
 {
     Reset();
     foreach (var kc in ActiveComponents.Reverse())
     {
         if (kc.Value.LastPing != InputHelper.CurrentFrame - 1)
         {
             Remove(kc.Key, kc.Value);
         }
     }
     CurrentParent = this;
     MaxChildren   = 0;
     ChildrenCount = 0;
     Parents.Clear();
     _idsUsedThisFrame.Clear();
 }
Exemplo n.º 3
0
        private void Remove(int id, IComponent c)
        {
            if (Focus == id)
            {
                Focus = null;
            }

            ActiveComponents.Remove(id);
            if (c.Parent != null)
            {
                c.Parent.Remove(c);
            }
            else
            {
                _children.Remove(c);
            }
            // TODO: Remove from PendingComponents? Probably not since that case can't happen?
        }
Exemplo n.º 4
0
        public bool TryGetValue(int id, out IComponent c)
        {
            if (ActiveComponents.TryGetValue(id, out c))
            {
                return(true);
            }

            foreach (var pc in PendingComponents)
            {
                if (pc.Id == id)
                {
                    c = pc.Component;
                    return(true);
                }
            }

            return(false);
        }
Exemplo n.º 5
0
        public override void UpdateSetup(GameTime gameTime)
        {
            // 1. Ping ourself to prevent cleanup.
            // 2. Cleanup last cycle
            // 3. Pending components become active.
            //      a. Set parenting.
            // 4. Update pref sizes.
            // 5. Apply pref sizes.
            // 6. Update setup.
            LastPing = InputHelper.CurrentFrame - 1;
            Cleanup();
            _idsUsedThisFrame.Add(Id, 1);
            while (PendingComponents.Count > 0)
            {
                var pc = PendingComponents.Dequeue();
                if (pc.Component.Parent == null)
                {
                    ActiveComponents.Add(pc.Id, pc.Component);
                }
                else
                {
                    pc.Component.Parent.Remove(pc.Component);
                }
                pc.Parent.Add(pc.Component);
                pc.Component.GrabFocus = GrabFocus;
            }

            while (_nextTick.Count > 0)
            {
                _nextTick.Dequeue().Invoke();
            }

            foreach (var c in _children)
            {
                c.UpdatePrefSize(gameTime);
                // TODO: Update position?
                c.Width  = c.PrefWidth;
                c.Height = c.PrefHeight;
                c.UpdateSetup(gameTime);
            }
        }