예제 #1
0
        public void PopUpsHaveHighestPriorityInHitTestZOrder()
        {
            var popUp1 = new PopUp <IWidget>(LayoutTestStyle.Create())
            {
                Padding = new Insets(10), Content = LayoutTestWidget.FixedSize(500, 300)
            };

            popUp1.Anchor = AnchoredRect.CreateTopLeftAnchored(10, 20);

            var popUp2 = new PopUp <IWidget>(LayoutTestStyle.Create())
            {
                Padding = new Insets(10), Content = LayoutTestWidget.FixedSize(500, 300)
            };

            popUp2.Anchor = AnchoredRect.CreateTopLeftAnchored(10, 20);

            var screen = Substitute.For <IScreenService>();

            var root = new RootPane(screen, LayoutTestStyle.Create());

            root.UIStyle.StyleResolver.AddRoot(root);
            root.Content = LayoutTestWidget.FixedSize(400, 400).WithAnchorRect(AnchoredRect.Full);
            root.AddPopUp(popUp1);
            root.AddPopUp(popUp2);

            root.Arrange(new Rectangle(0, 0, 1270, 770));

            root.Content.PerformHitTest(new Point(100, 100)).ShouldBeSameObjectReference(root.Content);
            popUp1.PerformHitTest(new Point(100, 100)).ShouldBeSameObjectReference(popUp1.Content);
            popUp2.PerformHitTest(new Point(100, 100)).ShouldBeSameObjectReference(popUp2.Content);
            root.PerformHitTest(new Point(100, 100)).ShouldBeSameObjectReference(popUp2.Content);
        }
예제 #2
0
        protected override void LoadContent()
        {
            // TODO: use this.Content to load your game content here eg.

            w = new DecoratedWindow();
            //w.Size=new Vector2<float>(600,200);
            w.LocalPosition = new Vector2 <float> (50, 50);
            //w.Insets = defaultWindowState.Insets;
            Label l = new Label("BigFont", "Drag Me", new Vector3 <byte>(255, 0, 255));

            l.LocalPosition = new Vector2 <float> (0, 0);
            w.AddChild(l);
            l.MouseDragListeners += delegate(GuiComponent c, Vector2 <float> mouseDelta) {
                Console.WriteLine("Mouse drag: " + mouseDelta);
                c.LocalPosition += mouseDelta;
            };
            w2               = new Window();
            w2.Size          = new Vector2 <float>(200, 200);
            w2.LocalPosition = new Vector2 <float>(200, 200);
            ButtonBar buttonBar = new ButtonBar(new string[] { "Show Window", "PopUp" },
                                                new Action <string>[] { DoShow, ShowPopUp });

            w2.AddChild(buttonBar);
            w2.AllLoaded += delegate(GuiComponent obj) {
                w2.Pack();
            };
            popup = new Window();
            ButtonBar popupButtons = new ButtonBar(new String[] { "A button", "Another button", "Close" }
                                                   , new Action <string>[] { DoPop, DoPop, DoPop });

            popupButtons.Vertical = true;
            popup.AddChild(popupButtons);
            popup.AllLoaded += delegate(GuiComponent obj) {
                popup.Pack();
                popup.Enabled = false;                 // hide
            };
            scrollWindow        = new DecoratedWindow();
            scrollWindow.Layout = new GridLayoutManager(1, 1);
            ScrollPanel scrollpanel = new ScrollPanel();

            scrollWindow.AddChild(scrollpanel);
            scrollpanel.Layout = new HorizontalLayout();
            ImagePanel imgPanel = new ImagePanel("Thumbnails", 0, 7);

            scrollpanel.AddChild(imgPanel);
            scrollWindow.AllLoaded += delegate(GuiComponent obj) {
                scrollWindow.Pack();
                scrollWindow.Size = new Vector2 <float>(250, scrollWindow.Size.Y);
            };
            scrollpanel.ContentContainerDrag = new Vector3 <float>(1.0f, float.MaxValue, float.MaxValue);
        }
예제 #3
0
        public void PopUpLayoutTest()
        {
            var p = new PopUp <IWidget>(LayoutTestStyle.Create())
            {
                Padding = new Insets(10), Content = LayoutTestWidget.FixedSize(500, 300)
            };

            p.Anchor = AnchoredRect.CreateTopLeftAnchored(10, 20);

            var screen = Substitute.For <IScreenService>();

            var root = new RootPane(screen, LayoutTestStyle.Create());

            root.UIStyle.StyleResolver.AddRoot(root);
            root.AddPopUp(p);

            root.Arrange(new Rectangle(0, 0, 1270, 770));

            p.LayoutRect.Should().Be(new Rectangle(10, 20, 520, 320));
        }
예제 #4
0
        public void InsertOrderTest()
        {
            var p = new PopUp <IWidget>(LayoutTestStyle.Create())
            {
                Padding = new Insets(10), Content = LayoutTestWidget.FixedSize(500, 300)
            };

            p.Anchor = AnchoredRect.CreateTopLeftAnchored(10, 20);

            var screen = Substitute.For <IScreenService>();

            var root = new RootPane(screen, LayoutTestStyle.Create());

            root.Content = LayoutTestWidget.FixedSize(400, 400).WithAnchorRect(AnchoredRect.Full);
            root.AddPopUp(p);

            root.Count.Should().Be(3); // glasspane
            root[0].Should().BeSameAs(root.Content);
            root[1].Should().BeAssignableTo <GlassPane>();
            root[2].Should().BeSameAs(p);
        }