Ejemplo n.º 1
0
        public RadialSlider(string title, Func <float> getValueCallback, Action <float> setValueCallback,
                            float min = 0, float max = 1, float radius = 25f) : base(radius)
        {
            _radius = radius;
            _min    = min;
            _max    = max;

            _emptySpace = new EmptySpace(_radius * 2, _radius * 2);
            AddChild(_emptySpace);
            AddChild(new ValueLabel(title, () => string.Format("{0:0.00}", Value)));

            _valueComponent = new ValueComponent <float>(getValueCallback, setValueCallback);
        }
Ejemplo n.º 2
0
        public ColorPicker(string title, Func <Col> getValueCallback = null,
                           Action <Col> setValueCallback             = null, float pickerHeight = 100) : base(100)
        {
            // Initialize texture here
            _colorDisplayWidth = 10f;
            Title              = title;
            _valueComponent    = new ValueComponent <Col>(getValueCallback, setValueCallback);
            _colorDisplayBlock = new EmptySpace(ColorDisplayWidth, pickerHeight);
            TargetColor        = _valueComponent.Value;

            Init();


            // Inititialize texture end...
            _header = new HeaderWidget(Title);
            _header.SetToggleCallback(x =>
            {
                if (!x)
                {
                    _header.Style.Set <Col>(Styles.BackgroundColor, TargetColor);
                }
                else
                {
                    _header.Style.Set <Col>(Styles.BackgroundColor, HeaderColor);
                }
                _pickerLayout.Style.Set(Styles.Hidden, !x);
            });
            // vertical layout
            _pickerLayout = new VerticalLayout();
            var horizontalGrid = new HorizontalLayout();

            _colorDisplayBlock = new EmptySpace(ColorDisplayWidth, pickerHeight);
            _pickerBlock       = new TextureWidget(_pickingTexture, InnerWidth - _colorDisplayWidth, pickerHeight);

            _colorDisplayBlock.Style.Set <Col>(Styles.BackgroundColor, TargetColor);
            _pickerBlock.Style.Set <Col>(Styles.BackgroundColor, new Col(0, 0, 0, 0));

            ColorDisplayWidth = _colorDisplayWidth;

            horizontalGrid.Attach(_colorDisplayBlock, _pickerBlock);

            // add slider
            _hueSlider = new TextureWidget(_hueTexture, InnerWidth, 10);
            _hueSlider.Style.Set <Col>(Styles.BackgroundColor, Col.red);
            _pickerLayout.Attach(horizontalGrid, _hueSlider);

            AddChild(_header);
            AddChild(_pickerLayout);
        }
Ejemplo n.º 3
0
        public VerticalSlider(string title, Func <float> getValueCallback,
                              Action <float> setValueCallback, float min = 0, float max = 1, float width = 12, float height = 50)
        {
            _min            = min; _max = max; _width = width; _height = height;
            _valueComponent = new ValueComponent <float>(getValueCallback, setValueCallback);

            Attach(
                new HorizontalLayout().Attach(
                    (_placeHolder = new VerticalLayout(_width)).Attach(
                        (_inactiveBar = new EmptySpace(_width, _height)),
                        (_activeBar = new EmptySpace(_width, 0))
                        )
                    ),
                (_valueLabel = new Label(title))
                );

            Value = getValueCallback();
        }