コード例 #1
0
        public DropdownList(string[] options, int selectedIndex, float width = 100) : base(width)
        {
            _options = options;

            var grid  = new HorizontalGrid();
            var left  = new HorizontalLayout();
            var right = new HorizontalLayout(true);

            _activeLabel = new Label(options[selectedIndex]);
            left.Attach(_activeLabel);
            float height = Utils.CalcSize("Adsd", Style).y;

            _triangle = new TriangleComponent(height, height, Col.white);
            right.Attach(_triangle);
            grid.Attach(left, right);
            AddChild(grid);

            _opened = new VerticalLayout(InnerWidth);
            foreach (var option in options)
            {
                _opened.Attach(new ClickableLable(option, x =>
                {
                    _activeLabel.Title = x;
                    Toggle();
                }));
            }
        }
コード例 #2
0
ファイル: Slider.cs プロジェクト: crystalboxes/GUIPanels
        public Slider(string title, System.Func <float> getValueCallback = null, System.Action <float> setValueCallback = null, float min = 0, float max = 1, float width = 100f) : base(width)
        {
            _valueComponent = new ValueComponent <float>(getValueCallback, setValueCallback);
            _max            = max;
            _min            = min;

            _inactiveBar    = new HorizontalGrid();
            _activeBar      = new EmptySpace();
            _verticalLayout = new VerticalLayout();
            _valueLabel     = new ValueLabel(title, () => string.Format("{0:0.00}", Value));
            Value           = getValueCallback();

            _verticalLayout.Attach(
                _inactiveBar.Attach(
                    new HorizontalLayout().Attach(
                        _activeBar
                        )
                    )
                );
            BuildLayout();
        }
コード例 #3
0
ファイル: WindowPanel.cs プロジェクト: crystalboxes/GUIPanels
 protected override void AddChild(Widget child)
 {
     _container.Attach(new HorizontalGrid().Attach(child));
 }