Example #1
0
        /// <summary>
        /// 用OpenGL初始化和渲染一个模型。
        /// <para>Initialize and render something with OpenGL.</para>
        /// </summary>
        /// <param name="anchor"></param>
        public GLControl(GUIAnchorStyles anchor)
        {
            this.Id       = idCounter++;
            this.Children = new GLControlChildren(this);

            this.Anchor = anchor;
        }
Example #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="capacity"></param>
        /// <param name="anchor"></param>
        public CtrlLabel(int capacity, GUIAnchorStyles anchor)
            : base(anchor)
        {
            if (capacity < 0)
            {
                throw new ArgumentException("capacity");
            }

            this.Size = new GUISize(20, 20);

            var model = new GlyphsModel(capacity);

            this.labelModel = model;
            var vs    = new VertexShader(vert);
            var fs    = new FragmentShader(frag);
            var codes = new ShaderArray(vs, fs);
            var map   = new AttributeMap();

            map.Add(inPosition, GlyphsModel.position);
            map.Add(inSTR, GlyphsModel.STR);
            var blend         = new BlendSwitch(BlendingSourceFactor.SourceAlpha, BlendingDestinationFactor.OneMinusSourceAlpha);
            var methodBuilder = new RenderMethodBuilder(codes, map, blend);

            this.RenderUnit = new ModernRenderUnit(model, methodBuilder);

            this.Initialize();
        }
Example #3
0
        internal static void LayoutAfterAddChild(GLControl control, GLControl parent)
        {
            GUIAnchorStyles anchor = control.Anchor;

            if ((anchor & leftRightAnchor) == leftRightAnchor)
            {
                control.Width = parent.width - control.left - control.right;
            }
            else if ((anchor & leftAnchor) == leftAnchor)
            {
                control.right = parent.width - control.left - control.width;
            }
            else if ((anchor & rightAnchor) == rightAnchor)
            {
                control.left = parent.width - control.width - control.right;
            }
            else // if ((anchor & noneAnchor) == nonAnchor)
            {
                int diff          = parent.width - control.left - control.width - control.right;
                int halfDiff      = diff / 2;
                int otherHalfDiff = diff - halfDiff;
                control.left  += halfDiff;
                control.right += otherHalfDiff;
            }
        }
Example #4
0
 private static void LayoutAfterHeightChanged(GLControl parent, GLControlChildren glControlChildren)
 {
     foreach (var control in glControlChildren)
     {
         GUIAnchorStyles anchor = control.Anchor;
         if ((anchor & bottomTopAnchor) == bottomTopAnchor)
         {
             control.Height = parent.height - control.bottom - control.top;
         }
         else if ((anchor & bottomAnchor) == bottomAnchor)
         {
             control.top = parent.height - control.bottom - control.height;
         }
         else if ((anchor & topAnchor) == topAnchor)
         {
             control.bottom    = parent.height - control.top - control.height;
             control.absBottom = parent.absBottom + control.bottom;
         }
         else // if ((anchor & noneAnchor) == noneAnchor)
         {
             int diff          = parent.height - control.top - control.height - control.bottom;
             int halfDiff      = diff / 2;
             int OtherHalfDiff = diff - halfDiff;
             control.bottom   += halfDiff;
             control.absBottom = parent.absBottom + control.bottom;
             control.top      += OtherHalfDiff;
         }
     }
 }
Example #5
0
        private static void LayoutAfterWidthChanged(GLControl parent, GLControlChildren glControlChildren)
        {
            foreach (var control in glControlChildren)
            {
                if (control.parent != parent)
                {
                    throw new Exception("Parent info not matching!");
                }

                GUIAnchorStyles anchor = control.Anchor;
                if ((anchor & leftRightAnchor) == leftRightAnchor)
                {
                    control.Width = parent.width - control.left - control.right;
                }
                else if ((anchor & leftAnchor) == leftAnchor)
                {
                    control.right = parent.width - control.left - control.width;
                }
                else if ((anchor & rightAnchor) == rightAnchor)
                {
                    control.left    = parent.width - control.right - control.width;
                    control.absLeft = parent.absLeft + control.left;
                }
                else // if ((anchor & noneAnchor) == noneAnchor)
                {
                    int diff          = parent.width - control.left - control.width - control.right;
                    int halfDiff      = diff / 2;
                    int OtherHalfDiff = diff - halfDiff;
                    control.left   += halfDiff;
                    control.absLeft = parent.absLeft + control.left;
                    control.right  += OtherHalfDiff;
                }
            }
        }
Example #6
0
        private static void LayoutAfterYChanged(GLControl parent, GLControl control)
        {
            GUIAnchorStyles anchor = control.Anchor;

            if ((anchor & topAnchor) == topAnchor)
            {
                control.Height = parent.height - control.bottom - control.top;
            }
            else
            {
                control.top = parent.height - control.bottom - control.height;
            }
        }
Example #7
0
        private static void LayoutAfterXChanged(GLControl parent, GLControl control)
        {
            GUIAnchorStyles anchor = control.Anchor;

            if ((anchor & rightAnchor) == rightAnchor)
            {
                control.Width = parent.width - control.left - control.right;
            }
            else
            {
                control.right = parent.width - control.left - control.width;
            }
        }