Exemplo n.º 1
0
        public void complex_horizontal_layout_using_uibuilder()
        {
            var scene            = new Scene(null);
            var uiBuilder        = new UIBuilder(UIStyle.Empty);
            var horizontalLayout = scene.AddActor("Layout");

            new BoundingRect(horizontalLayout, 256, 128);
            var uiGroup = new LayoutGroup(horizontalLayout, Orientation.Horizontal);

            uiGroup.SetPaddingBetweenElements(5);
            uiGroup.SetMarginSize(new Point(15, 15));
            Actor e1 = null;
            Actor e2 = null;
            Actor e3 = null;

            uiGroup.AddElement("e1", new Point(32, 32), act => e1 = act);
            uiGroup.AddElement("e2", new Point(64, 32), act => e2 = act).StretchVertically();
            uiGroup.AddElement("e3", new Point(32, 32), act => e3 = act).StretchHorizontally().StretchVertically();
            scene.FlushBuffers();
            uiGroup.ExecuteLayout();

            Assert.Equal(15, e1.transform.Position.X);
            Assert.Equal(52, e2.transform.Position.X);
            Assert.Equal(121, e3.transform.Position.X);

            Assert.Equal(32, e1.GetComponent <BoundingRect>().Width);
            Assert.Equal(64, e2.GetComponent <BoundingRect>().Width);
            Assert.Equal(120, e3.GetComponent <BoundingRect>().Width);

            Assert.Equal(32, e1.GetComponent <BoundingRect>().Height);
            Assert.Equal(98, e2.GetComponent <BoundingRect>().Height);
            Assert.Equal(98, e3.GetComponent <BoundingRect>().Height);
        }