Пример #1
0
        public static Widget CreateRootPanel(IUIStyle uiStyle)
        {
            var basicDemoPane = new BasicDemoPane(uiStyle);

            var demoPanel = new ScrollPanel(uiStyle)
            {
                VerticalScrollbarMode = ScrollbarMode.None,
                Content = basicDemoPane
            }.DoWith(d => d.AddStyleClass("DemoPanel"));

            // Splitter
            return(new Splitter(uiStyle, Direction.Left)
            {
                Anchor = AnchoredRect.CreateFull(10),
                Collapsable = true,
                Collapsed = true,
                FirstPane = new BoxGroup(uiStyle, Orientation.Vertical, 0)
                {
                    { CreateDemoButton("Basic", demoPanel, basicDemoPane), true },
                    { CreateDemoButton("Notebook", demoPanel, new NotebookPane(uiStyle)), true },
                    { CreateDemoButton("Text Area", demoPanel, new TextAreaPane(uiStyle)), true },
                    { CreateDemoButton("Custom Viewport", demoPanel, new CustomViewportPane(uiStyle)), true }
                },
                SecondPane = demoPanel,
                FirstPaneMinSize = 200
            });
        }
Пример #2
0
        NotebookTab CreateHomeTab()
        {
            void CreateNewTab(object sender, EventArgs args)
            {
                tabCounter += 1;
                var tab = new NotebookTab(UIStyle)
                {
                    Tag           = "Tab Content for " + tabCounter,
                    HeaderContent = new Label(UIStyle, $"Tab {tabCounter}"),
                    Content       = new Label(UIStyle, "Tab Content for " + tabCounter)
                };

                Content.Tabs.Add(tab);
            }

            return(new NotebookTab(UIStyle)
            {
                Content = new Button(UIStyle, "CreatePopup tab")
                {
                    Anchor = AnchoredRect.CreateFull(10),
                    OnActionPerformed = CreateNewTab
                },
                HeaderContent = new Label(UIStyle, "Home"),
                IsPinned = true,
                Tag = "Home"
            });
        }
Пример #3
0
        public void Arrange_Ignores_AnchorRects()
        {
            var p = new TestScrollPanel(LayoutTestStyle.Create())
            {
                // CornerSize = 10,
                Padding = new Insets(10),
                VerticalScrollbarMode = ScrollbarMode.Always,
                Content = LayoutTestWidget.FixedSize(500, 300).WithAnchorRect(AnchoredRect.CreateFull(40))
            };

            p.UIStyle.StyleResolver.AddRoot(p);
            p.Arrange(new Rectangle(10, 20, 300, 200));

            WidgetVisitor.PrintLayoutVisitor().Visit(p);

            p.DesiredSize.Should().Be(new Size(610, 400));
            p.Content.DesiredSize.Should().Be(new Size(500, 300));

            p.LayoutRect.Should().Be(new Rectangle(10, 20, 300, 200));

            // width = 300 - 2*40 (anchor) - 2*10 (padding) - 10 (scrollbar)
            p.Content.LayoutRect.Should().Be(new Rectangle(20, 30, 270, 300));
            p.TestScrollbar.LayoutRect.Should().Be(new Rectangle(290, 30, 10, 180));

            // height = 300 + 2*40 from anchor
            p.TestScrollbar.ScrollContentHeight.Should().Be(300);
        }
Пример #4
0
        public void MeasureNoScroll()
        {
            var p = new ScrollPanel(LayoutTestStyle.Create())
            {
                // CornerSize = 10,
                Padding = new Insets(10),
                VerticalScrollbarMode = ScrollbarMode.None,
                Content = LayoutTestWidget.FixedSize(500, 300).WithAnchorRect(AnchoredRect.CreateFull(40))
            };

            p.UIStyle.StyleResolver.AddRoot(p);
            p.Measure(Size.Auto);

            p.DesiredSize.Should().Be(new Size(600, 400));
        }
Пример #5
0
        public void ArrangeHugeAnchored()
        {
            var g = new BoxGroup(LayoutTestStyle.Create());

            g.Spacing     = 5;
            g.Orientation = Orientation.Horizontal;
            g.Add(LayoutTestWidget.FixedSize(2000, 1000).WithAnchorRect(AnchoredRect.CreateCentered(500, 500)));
            g.Add(LayoutTestWidget.FixedSize(150, 50).WithAnchorRect(AnchoredRect.CreateFull(10)));

            g.Arrange(new Rectangle(10, 20, 400, 300));

            g.DesiredSize.Should().Be(new Size(675, 500)); // 500 + 150 + 20 (from full-anchor) + 5
            g[0].DesiredSize.Should().Be(new Size(2000, 1000));
            g[1].DesiredSize.Should().Be(new Size(150, 50));

            g.LayoutRect.Should().Be(new Rectangle(10, 20, 675, 300));
            g[0].LayoutRect.Should().Be(new Rectangle(10, -80, 500, 500));
            g[1].LayoutRect.Should().Be(new Rectangle(525, 30, 150, 280));
        }
Пример #6
0
        public void MeasureNoScroll()
        {
            var p = new PopUp <IWidget>(LayoutTestStyle.Create())
            {
                Padding = new Insets(10), Content = LayoutTestWidget.FixedSize(500, 300).WithAnchorRect(AnchoredRect.CreateFull(40))
            };

            p.Measure(Size.Auto);

            p.DesiredSize.Should().Be(new Size(520, 320));
            p.Content.DesiredSize.Should().Be(new Size(500, 300));
        }