Пример #1
0
        public GLSlider(GLGui gui) : base(gui)
        {
            Render     += OnRender;
            MouseMove  += OnMouseMove;
            MouseDown  += OnMouseDown;
            MouseUp    += OnMouseUp;
            MouseEnter += OnMouseEnter;
            MouseLeave += OnMouseLeave;
            MouseWheel += OnMouseWheel;

            skinEnabled  = Gui.Skin.SliderEnabled;
            skinPressed  = Gui.Skin.SliderPressed;
            skinHover    = Gui.Skin.SliderHover;
            skinDisabled = Gui.Skin.SliderDisabled;

            outer   = new Rectangle(0, 0, 8, 8);
            sizeMin = new Size(8, 8);
            sizeMax = new Size(int.MaxValue, int.MaxValue);
        }
Пример #2
0
        protected override void UpdateLayout()
        {
            skin = Enabled ? (down ? skinPressed : (over ? skinHover : skinEnabled)) : skinDisabled;

            if (AutoSize)
            {
                outer.Width  = sizeMin.Width;
                outer.Height = sizeMin.Height;
                if (Parent != null)
                {
                    if (direction == GLSliderOrientation.Horizontal)
                    {
                        outer.Width = Parent.Inner.Width;
                    }
                    else
                    {
                        outer.Height = Parent.Inner.Height;
                    }
                }
            }

            outer.Width  = Math.Min(Math.Max(outer.Width, sizeMin.Width), sizeMax.Width);
            outer.Height = Math.Min(Math.Max(outer.Height, sizeMin.Height), sizeMax.Height);

            if (!enabled)
            {
                value = 0.0f;
            }
            value = Math.Min(Math.Max(value, 0.0f), 1.0f);
            if (direction == GLSliderOrientation.Horizontal)
            {
                Inner = new Rectangle((int)((outer.Width - 8) * value), 0, 8, 8);
            }
            else
            {
                Inner = new Rectangle(0, (int)((outer.Height - 8) * value), 8, 8);
            }
        }