Exemple #1
0
 public void SetScrollBarH(UIScrollBarH scrollBarH)
 {
     if (_horizontalScrollBar != null)
     {
         _horizontalScrollBar.Parent = null;
         Children.Remove(_horizontalScrollBar);
     }
     _horizontalScrollBar             = scrollBarH;
     _horizontalScrollBar.SizeFactor  = new Vector2(1f, 0f);
     _horizontalScrollBar.Size        = new Vector2(0, 10);
     _horizontalScrollBar.AnchorPoint = new Vector2(0f, 1f);
     _horizontalScrollBar.Pivot       = new Vector2(0f, 1f);
     _horizontalScrollBar.Position    = new Vector2(0, 0);
     AppendChild(_horizontalScrollBar);
     ShouldRecalculate = true;
 }
Exemple #2
0
        public Browser(EditorState editor) : base(editor)
        {
            PropagationRule = PropagationFlags.FocusEvents;
            _listPanel      = new UIPanel()
            {
                AnchorPoint  = new Vector2(0, 0),
                Pivot        = new Vector2(0, 0),
                SizeFactor   = new Vector2(1f, 1f),
                Size         = new Vector2(-15f, -10f),
                Position     = new Vector2(15f, 5f),
                PanelTexture = UIEditor.Instance.SkinManager.GetTexture("Box_Default"),
            };
            _treeList = new UIBrowserTreeList(Editor)
            {
                AnchorPoint = new Vector2(0, 0),
                Pivot       = new Vector2(0, 0),
                SizeFactor  = new Vector2(1f, 1f),
                Size        = new Vector2(-10f, -10f),
                Position    = new Vector2(5f, 5f),
            };
            var scrollBar1 = new UIScrollBarV()
            {
                Name        = "ScrollBar",
                AnchorPoint = new Vector2(1, 0.5f),
                Pivot       = new Vector2(1, 0.5f),
            };
            var scrollBar2 = new UIScrollBarH()
            {
                Name = "ScrollBarH",
            };
            var toolbar2 = new UIToolBarV()
            {
                SizeFactor      = new Vector2(1f, 1f),
                AnchorPoint     = new Vector2(0f, 0.5f),
                Pivot           = new Vector2(0f, 0.5f),
                PropagationRule = PropagationFlags.BLOCK_ALL,
                ButtonTooltip   = "工具栏",
            };

            AppendChild(_listPanel);
            AppendChild(toolbar2);
            _listPanel.AppendChild(_treeList);
            _treeList.SetScrollBarV(scrollBar1);
            _treeList.SetScrollBarH(scrollBar2);
            _treeList.OnSelect += _treeList_OnSelect;

            _toolBarList = new UISelectableList()
            {
                Pivot      = new Vector2(0, 0),
                Position   = new Vector2(10, 10),
                SizeFactor = new Vector2(1, 1),
                Size       = new Vector2(-20, -20),
            };

            SetupButtons();
            var scrollBar3 = new UIScrollBarV()
            {
                Name        = "工具栏滚动条",
                AnchorPoint = new Vector2(1, 0.5f),
                Pivot       = new Vector2(1, 0.5f),
            };

            _toolBarList.SetScrollBarV(scrollBar3);
            toolbar2.AddToPanel(_toolBarList);
        }
Exemple #3
0
        public override void Initialize()
        {
            base.Initialize();
            var button = new UIButton()
            {
                Name     = "tbDebug",
                Size     = new Vector2(10 * 16, 3 * 16),
                Position = new Vector2(10 * 16, 3 * 16) / 2
            };
            var box13 = new UIWindow()
            {
                Name        = "a",
                Size        = new Vector2(800, 640),
                AnchorPoint = new Vector2(0.5f, 0.5f),
                Position    = new Vector2(100, 100)
            };
            var textbox = new UITextArea {
                Name        = "emmm",
                Size        = new Vector2(20 * 16, 6.5f * 16),
                Position    = new Vector2(0, 300),
                Pivot       = new Vector2(0.5f, 0),
                AnchorPoint = new Vector2(0.5f, 0),
                TextAlign   = Enums.Align.TopLeft
            };
            //var menu = new UIMenu() {
            //    Name = "text menu",
            //    Pivot = new Vector2(0.5f, 0),
            //    AnchorPoint = new Vector2(0.5f, 0),
            //};
            var checkbox = new UICheckBox {
                Tooltip  = "Debug模式",
                Name     = "test checkbox",
                Position = new Vector2(90, 90)
            };
            var colorwheel = new UIColorBar()
            {
                Position = new Vector2(200, 200),
                Size     = new Vector2(128, 128),
            };

            //var selector = new UIEnumSelector<TypeCode>() {
            //    Position = new Vector2(140, 280),
            //    Size = new Vector2(100, 30),
            //    Pivot = new Vector2(0, 0),
            //    AnchorPoint = new Vector2(0, 0)
            //};
            //selector.HangElement = box13;

            checkbox.OnCheckedChange += Checkbox_OnCheckedChange;
            button.OnClick           += (e, sender) => {
                switch (textbox.TextAlign)
                {
                case Enums.Align.Top:
                    textbox.TextAlign = Enums.Align.TopRight;
                    break;

                case Enums.Align.TopRight:
                    textbox.TextAlign = Enums.Align.Right;
                    break;

                case Enums.Align.Right:
                    textbox.TextAlign = Enums.Align.BottomRight;
                    break;

                case Enums.Align.BottomRight:
                    textbox.TextAlign = Enums.Align.Bottom;
                    break;

                case Enums.Align.Bottom:
                    textbox.TextAlign = Enums.Align.BottomLeft;
                    break;

                case Enums.Align.BottomLeft:
                    textbox.TextAlign = Enums.Align.Left;
                    break;

                case Enums.Align.Left:
                    textbox.TextAlign = Enums.Align.TopLeft;
                    break;

                case Enums.Align.TopLeft:
                    textbox.TextAlign = Enums.Align.Top;
                    break;
                }
                button.Text = textbox.TextAlign.ToString();
            };
            box13.OnClose += Box1_OnClose;
            AppendChild(box13);
            box13.AppendChild(textbox);
            //{
            //    var item1 = new UIMenuItem();
            //    item1.Text = nameof(item1);
            //    item1.AddItem(new UIMenuItem { Text = "item1.item1" });
            //    item1.AddItem(new UIMenuItem { Text = "item1.item2" });
            //    item1.AddItem(new UIMenuItem { Text = "item1.item3" });
            //    menu.AddItem(item1);
            //    var item2 = new UIMenuItem();
            //    item2.Text = nameof(item2);
            //    item2.AddItem(new UIMenuItem { Text = "item2.item1" });
            //    item2.AddItem(new UIMenuItem { Text = "item2.item2" });
            //    menu.AddItem(item2);
            //    {
            //        var item2_3 = new UIMenuItem();
            //        item2_3.Text = "item2.item3";
            //        item2_3.AddItem(new UIMenuItem { Text = "item231" });
            //        item2_3.AddItem(new UIMenuItem { Text = "item232" });
            //        item2_3.AddItem(new UIMenuItem { Text = "item233" });
            //        item2_3.AddItem(new UIMenuItem { Text = "item234" });
            //        item2.AddItem(item2_3);
            //    }
            //}

            var scrollBarH = new UIScrollBarH()
            {
                AnchorPoint = new Vector2(0.5f, 1),
                Pivot       = new Vector2(0.5f, 1),
                SizeFactor  = new Vector2(1f, 0f),
                Size        = new Vector2(0, 20),
            };

            box13.AppendChild(scrollBarH);
            box13.AppendChild(button);
            box13.AppendChild(checkbox);
            //box13.AppendChild(button2);
            // box13.AppendChild(selector);
            //box13.AppendChild(colorwheel);
            //UIValueSlider slider = new UIValueSlider() {
            //    Position = new Vector2(400, 300),
            //    Size = new Vector2(230, 30),
            //    Min = 0,
            //    Max = 255,
            //};
            //box13.AppendChild(slider);
        }