Пример #1
0
 public static void DrawComponent(IGUIComponent component)
 {
     component.InitDrawed = false;
     component.Destroy    = false;
     Context.componentStack.Push(component);
     Event.Use();
 }
Пример #2
0
        public override void Draw(GUIEvent guievent)
        {
            base.Draw(guievent);

            //do draw
            m_needSyncBuffer = false;
            var comp = GUI.Context.componentStack;

            if (comp.Count == 0)
            {
                return;
            }


            //every draw the last one
            IGUIComponent curcomp = comp.Peek();

            if (curcomp.InitDrawed)
            {
                m_drawTarget.bufferRect.RemoveRange(curcomp.BufferRectStart, curcomp.BufferRectCount);
                m_drawTarget.bufferText.RemoveRange(curcomp.BufferTextStart, curcomp.BufferTextCount);
            }

            int rectCount = m_drawTarget.bufferRect.Count;
            int textCount = m_drawTarget.bufferText.Count;

            curcomp.BufferRectStart = rectCount;
            curcomp.BufferTextStart = textCount;

            //get relative depth;
            if (comp.Count > 1)
            {
                float lastDepth = GUI.Depth;
                if (m_drawTarget.bufferRect.Count > 0)
                {
                    lastDepth = Math.Min(lastDepth, m_drawTarget.bufferRect.VerticesZ(rectCount - 1));
                }
                if (m_drawTarget.bufferText.Count > 0)
                {
                    lastDepth = Math.Min(lastDepth, m_drawTarget.bufferText.VerticesZ(textCount - 1));
                }
                GUI.SetDepth(lastDepth);
            }

            curcomp.Draw(guievent);
            guievent.Use();

            curcomp.BufferRectEnd = m_drawTarget.bufferRect.Count;
            curcomp.BufferTextEnd = m_drawTarget.bufferText.Count;

            curcomp.InitDrawed = true;
            m_needSyncBuffer   = true;
        }