コード例 #1
0
ファイル: GUICanvas.cs プロジェクト: yivoDev/Modelviewer
 //Draw the GUI, cycle through the children
 public override void Draw(GUIRenderer.GUIRenderer guiRenderer, Vector2 parentPosition, Vector2 mousePosition)
 {
     if (!IsEnabled)
     {
         return;
     }
     for (int index = 0; index < _children.Count; index++)
     {
         GUIElement child = _children[index];
         if (child.IsHidden)
         {
             continue;
         }
         child.Draw(guiRenderer, parentPosition + Position, mousePosition);
     }
 }
コード例 #2
0
ファイル: GuiListToggle.cs プロジェクト: yivoDev/Modelviewer
        public override void Draw(GUIRenderer.GUIRenderer guiRenderer, Vector2 parentPosition, Vector2 mousePosition)
        {
            if (IsHidden)
            {
                return;
            }
            //Draw toggle element
            guiRenderer.DrawQuad(parentPosition + Position, _toggleDimensions, _isHovered ? HoverColor : ToggleBlockColor);

            //arrow
            if (IsToggled)
            {
                guiRenderer.DrawQuad(
                    parentPosition + Position + _toggleDimensions * 0.5f - ArrowButtonHeight * Vector2.One * 0.5f,
                    new Vector2(ArrowButtonHeight, ArrowButtonHeight * 0.25f), Color.White);
                guiRenderer.DrawQuad(
                    parentPosition + Position + _toggleDimensions * 0.5f - ArrowButtonHeight * Vector2.UnitX * 0.25f,
                    new Vector2(ArrowButtonHeight, ArrowButtonHeight * 0.5f) * 0.5f, Color.White);
            }
            else
            {
                guiRenderer.DrawQuad(
                    parentPosition + Position + _toggleDimensions * 0.5f - ArrowButtonHeight * Vector2.UnitX * 0.5f,
                    new Vector2(ArrowButtonHeight, ArrowButtonHeight * 0.25f), Color.White);
                guiRenderer.DrawQuad(
                    parentPosition + Position + _toggleDimensions * 0.5f - ArrowButtonHeight * new Vector2(0.25f, 0.5f),
                    new Vector2(ArrowButtonHeight, ArrowButtonHeight * 0.5f) * 0.5f, Color.White);
            }

            if (IsToggled)
            {
                float height = ToggleButtonHeight;

                for (int index = 0; index < _children.Count; index++)
                {
                    GUIElement child = _children[index];
                    child.Draw(guiRenderer, parentPosition + Position + height * Vector2.UnitY, mousePosition);

                    height += _children[index].Dimensions.Y;
                }
            }
        }
コード例 #3
0
        //Draw the GUI, cycle through the children
        public override void Draw(GUIRenderer.GUIRenderer guiRenderer, Vector2 parentPosition, Vector2 mousePosition)
        {
            if (IsHidden)
            {
                return;
            }

            float height = 0;

            for (int index = 0; index < _children.Count; index++)
            {
                GUIElement child = _children[index];

                if (child.IsHidden)
                {
                    continue;
                }

                child.Draw(guiRenderer, parentPosition + Position + height * Vector2.UnitY, mousePosition);

                height += _children[index].Dimensions.Y;
            }
        }
コード例 #4
0
        public override void Draw(GUIRenderer.GUIRenderer guiRenderer, Vector2 parentPosition, Vector2 mousePosition)
        {
            if (IsHidden)
            {
                return;
            }

            Vector2 initialPosition = parentPosition + Position + ScrollTranslation * Vector2.UnitY;

            //Draw toggle element
            guiRenderer.DrawQuad(initialPosition, _toggleDimensions, _isHovered ? HoverColor : Color.DimGray);

            //arrow
            if (IsToggled)
            {
                guiRenderer.DrawQuad(
                    initialPosition + _toggleDimensions * 0.5f - ArrowButtonHeight * Vector2.One * 0.5f,
                    new Vector2(ArrowButtonHeight, ArrowButtonHeight * 0.25f), Color.White);
                guiRenderer.DrawQuad(
                    initialPosition + _toggleDimensions * 0.5f - ArrowButtonHeight * Vector2.UnitX * 0.25f,
                    new Vector2(ArrowButtonHeight, ArrowButtonHeight * 0.5f) * 0.5f, Color.White);
            }
            else
            {
                guiRenderer.DrawQuad(
                    initialPosition + _toggleDimensions * 0.5f - ArrowButtonHeight * Vector2.UnitX * 0.5f,
                    new Vector2(ArrowButtonHeight, ArrowButtonHeight * 0.25f), Color.White);
                guiRenderer.DrawQuad(
                    initialPosition + _toggleDimensions * 0.5f - ArrowButtonHeight * new Vector2(0.25f, 0.5f),
                    new Vector2(ArrowButtonHeight, ArrowButtonHeight * 0.5f) * 0.5f, Color.White);
            }

            if (IsToggled)
            {
                float height = ToggleButtonHeight;

                for (int index = 0; index < _children.Count; index++)
                {
                    GUIElement child = _children[index];

                    if (child.IsHidden)
                    {
                        continue;
                    }

                    if (ScrollTranslation + height < ParentDimensions.Y)
                    {
                        child.Draw(guiRenderer, initialPosition + height * Vector2.UnitY, mousePosition);
                    }
                    height += _children[index].Dimensions.Y;
                }

                ScrollBarEnabled = height > ParentDimensions.Y;

                if (ScrollBarEnabled)
                {
                    ScrollTotalHeight = MathHelper.Min(height, ParentDimensions.Y);
                    ListHeight        = height;

                    percentOverscroll = MathHelper.Max(1, ListHeight / ScrollTotalHeight);

                    SliderHeight = ScrollTotalHeight / percentOverscroll;
                }
                else
                {
                    ScrollTotalHeight = height;
                    ScrollTranslation = 0;
                }
                //Sidebar
                guiRenderer.DrawQuad(parentPosition + Position + _toggleDimensions * Vector2.UnitX, new Vector2(Scrollwidth, ScrollTotalHeight), ScrollBarEnabled ? ScrollBarEnabledColor : ScrollBarDisabledColor);

                //Scrollbar
                if (ScrollBarEnabled)
                {
                    guiRenderer.DrawQuad(parentPosition + Position + _toggleDimensions * Vector2.UnitX + percentScroll * (ScrollTotalHeight - SliderHeight) * Vector2.UnitY, new Vector2(Scrollwidth, SliderHeight), ScrollBarHovered ? SliderHoveredColor : SliderColor);
                }
            }
        }