示例#1
0
                public DemoBox(HudParentBase parent = null) : base(parent)
                {
                    // Spawn controls
                    //
                    // List of available control types
                    typeList     = new ListBox <DemoElements>();
                    createButton = new BorderedButton()
                    {
                        Text = "Create", Padding = Vector2.Zero
                    };

                    typeColumn = new HudChain(true)
                    {
                        SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                        CollectionContainer = { typeList, createButton },
                        Spacing             = 8f
                    };

                    // Add list of supported test elements to the type list
                    var supportedTypes = Enum.GetValues(typeof(DemoElements)) as DemoElements[];

                    for (int n = 0; n < supportedTypes.Length; n++)
                    {
                        typeList.Add(supportedTypes[n].ToString(), supportedTypes[n]);
                    }

                    createButton.MouseInput.LeftClicked += InstantiateSelectedType;

                    // Instance list
                    instanceList = new ListBox <TestWindowNode>();
                    removeButton = new BorderedButton()
                    {
                        Text = "Remove", Padding = Vector2.Zero
                    };
                    clearAllButton = new BorderedButton()
                    {
                        Text = "Clear All", Padding = Vector2.Zero
                    };

                    instanceButtonRow = new HudChain(false)
                    {
                        SizingMode          = HudChainSizingModes.FitMembersBoth | HudChainSizingModes.FitChainBoth,
                        CollectionContainer = { removeButton, clearAllButton },
                        Spacing             = 8f,
                    };

                    instanceColumn = new HudChain(true)
                    {
                        SizingMode          = HudChainSizingModes.FitMembersOffAxis | HudChainSizingModes.FitChainBoth,
                        CollectionContainer = { instanceList, instanceButtonRow },
                        Spacing             = 8f
                    };

                    removeButton.MouseInput.LeftClicked   += RemoveSelectedInstance;
                    clearAllButton.MouseInput.LeftClicked += ClearInstances;
                    instanceList.SelectionChanged         += UpdateSelection;

                    // Transform controls
                    //
                    // Column 1
                    screenSpaceToggle = new NamedCheckBox()
                    {
                        Name = "Screen Space"
                    };
                    xAxisBar = new NamedSliderBox()
                    {
                        Name = "AxisX", Padding = new Vector2(40f, 0f), Min = -1f, Max = 1f
                    };
                    yAxisBar = new NamedSliderBox()
                    {
                        Name = "AxisY", Padding = new Vector2(40f, 0f), Min = -1f, Max = 1f
                    };
                    zAxisBar = new NamedSliderBox()
                    {
                        Name = "AxisZ", Padding = new Vector2(40f, 0f), Min = -1f, Max = 1f
                    };
                    angleBar = new NamedSliderBox()
                    {
                        Name = "Angle", Padding = new Vector2(40f, 0f), Min = -(float)(Math.PI), Max = (float)(Math.PI)
                    };

                    transformCol1 = new HudChain(true)
                    {
                        Spacing             = 10f,
                        CollectionContainer = { screenSpaceToggle, xAxisBar, yAxisBar, zAxisBar, angleBar }
                    };

                    // Column 2
                    resScaleToggle = new NamedCheckBox()
                    {
                        Name = "Res Scaling"
                    };
                    scaleBar = new NamedSliderBox()
                    {
                        Name = "Scale", Padding = new Vector2(40f, 0f), Min = 0.001f, Max = 1f
                    };
                    xPosBar = new NamedSliderBox()
                    {
                        Name = "PosX", Padding = new Vector2(40f, 0f), Min = -.5f, Max = .5f
                    };
                    yPosBar = new NamedSliderBox()
                    {
                        Name = "PosY", Padding = new Vector2(40f, 0f), Min = -.5f, Max = .5f
                    };
                    zPosBar = new NamedSliderBox()
                    {
                        Name = "PosZ", Padding = new Vector2(40f, 0f), Min = -2f, Max = 0f
                    };

                    transformCol2 = new HudChain(true)
                    {
                        Spacing             = 10f,
                        CollectionContainer = { resScaleToggle, scaleBar, xPosBar, yPosBar, zPosBar }
                    };

                    spawnControls = new HudChain(false)
                    {
                        CollectionContainer = { typeColumn, instanceColumn },
                        Spacing             = 16f,
                    };

                    transformControls = new HudChain(false)
                    {
                        CollectionContainer = { transformCol1, transformCol2 }
                    };

                    var layout = new HudChain(true, this)
                    {
                        ParentAlignment     = ParentAlignments.Left | ParentAlignments.Inner,
                        Spacing             = 10f,
                        CollectionContainer = { spawnControls, transformControls }
                    };

                    Padding  = new Vector2(40f, 8f);
                    demoRoot = new HudCollection(HudMain.HighDpiRoot);
                }
示例#2
0
 public TerminalSlider()
 {
     sliderBox = new NamedSliderBox();
     SetElement(sliderBox);
 }