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); }
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); }
public void PropertyAccess() { var w = LayoutTestWidget.FixedSize(200, 200); w.Tag = "Test"; w.GetPropertyValue(nameof(w.Tag)).Should().Be("Test"); }
public void IsPinned_InitialState() { var tab = new NotebookTab(LayoutTestStyle.Create(), LayoutTestWidget.FixedSize(100, 20), LayoutTestWidget.FixedSize(500, 400)); tab.IsClosable.Should().Be(true); tab.IsPinned.Should().Be(false); tab[0][0].Should().BeAssignableTo <Button>(); tab[0][0].Visibility.Should().Be(Visibility.Visible); }
public void Mouse_Clicks_in_label_Activate_Tab() { var activationRequested = false; var tab = new NotebookTab(LayoutTestStyle.Create(), LayoutTestWidget.FixedSize(100, 20), LayoutTestWidget.FixedSize(500, 400)); tab.ActivationRequested += (s, e) => activationRequested = true; tab[0][1].DispatchMouseClick(MouseButton.Left, 10, 20); activationRequested.Should().Be(true); }
public void ToolTip_Default_Mode() { var widget = LayoutTestWidget.FixedSize(200, 20); widget.UIStyle.StyleResolver.AddRoot(widget); widget.Arrange(new Rectangle(10, 20, 200, 20)); widget.ShowTooltip("4"); widget.Tooltip.TooltipPosition.Should().Be(TooltipPositionMode.FollowMouse); }
public void Hover_State_Is_Reflected_In_PseudoClasses() { var w = LayoutTestWidget.FixedSize(100, 100); w.PseudoClasses.Contains(WidgetPseudoClasses.HoveredPseudoClass).Should().Be(false); w.Hovered = true; w.PseudoClasses.Contains(WidgetPseudoClasses.HoveredPseudoClass).Should().Be(true); w.Hovered = false; w.PseudoClasses.Contains(WidgetPseudoClasses.HoveredPseudoClass).Should().Be(false); }
public void CloseButton_Triggers_Close_Request() { var closeRequested = false; var tab = new NotebookTab(LayoutTestStyle.Create(), LayoutTestWidget.FixedSize(100, 20), LayoutTestWidget.FixedSize(500, 400)); tab.CloseRequested += (s, e) => closeRequested = true; tab[0][0].DispatchMouseClick(MouseButton.Left, 10, 20); closeRequested.Should().Be(true); }
public void MeasureTwoElementsLeftFill() { var p = new DockPanel(LayoutTestStyle.Create()); p.LastChildFill = true; p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Left); p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Left); p.Measure(Size.Auto); p.DesiredSize.Should().Be(new Size(200, 50)); }
public void PseudoClassChangeTriggeresLayoutChange() { bool invalidateCalled = false; var w = LayoutTestWidget.FixedSize(100, 100); w.Arrange(new Rectangle(10, 20, 200, 40)); w.StyleInvalidated += (o, e) => invalidateCalled = true; w.LayoutInvalid.Should().Be(false); w.AddPseudoStyleClass("Test"); invalidateCalled.Should().Be(true); }
public void MeasureInfinite() { var s = new Splitter(LayoutTestStyle.Create(), Direction.Left) { FirstPane = LayoutTestWidget.FixedSize(500, 500), SecondPane = LayoutTestWidget.FixedSize(200, 200) }; s.UIStyle.StyleResolver.AddRoot(s); s.Measure(Size.Auto); s.DesiredSize.Should().Be(new Size(310, 500)); }
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)); }
public void LayoutTwoElementsLeftFill() { var p = new DockPanel(LayoutTestStyle.Create()); p.LastChildFill = true; p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Left); p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Left); p.Arrange(new Rectangle(10, 20, 500, 300)); p.LayoutRect.Should().Be(new Rectangle(10, 20, 500, 300)); p[0].LayoutRect.Should().Be(new Rectangle(10, 20, 100, 300)); p[1].LayoutRect.Should().Be(new Rectangle(110, 20, 400, 300)); }
public void TestImplicitFixedMeasure() { var g = new Grid(LayoutTestStyle.Create()); g.AddChildAt(LayoutTestWidget.FixedSize(100, 100), 0, 0); g.AddChildAt(LayoutTestWidget.FixedSize(200, 200), 1, 1); g.Arrange(new Rectangle(10, 20, 0, 0)); g.DesiredSize.Should().Be(new Size(300, 300)); g.LayoutRect.Should().Be(new Rectangle(10, 20, 300, 300)); g[0].LayoutRect.Should().Be(new Rectangle(10, 20, 100, 100)); g[1].LayoutRect.Should().Be(new Rectangle(110, 120, 200, 200)); }
public void TestGridSpacing() { var g = new Grid(LayoutTestStyle.Create()); g.Spacing = 10; g.AddChildAt(LayoutTestWidget.FixedSize(100, 100), 0, 0); g.AddChildAt(LayoutTestWidget.FixedSize(200, 200), 1, 1); g.AddChildAt(LayoutTestWidget.FixedSize(200, 200), 1, 2); g.Measure(Size.Auto); g.Arrange(new Rectangle(10, 20, g.DesiredSize.WidthInt, g.DesiredSize.HeightInt)); g.LayoutRect.Size.Should().Be(new Point(g.DesiredSize.WidthInt, g.DesiredSize.HeightInt)); }
public void LayoutSingleElementTopNoFill() { var p = new DockPanel(LayoutTestStyle.Create()); p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Top); p.Measure(Size.Auto); p.DesiredSize.Should().Be(new Size(100, 50)); p.Arrange(new Rectangle(10, 20, 500, 300)); p.LayoutRect.Should().Be(new Rectangle(10, 20, 500, 300)); p[0].LayoutRect.Should().Be(new Rectangle(10, 20, 500, 50)); }
public void MeasureVertical() { var g = new BoxGroup(LayoutTestStyle.Create()); g.Spacing = 5; g.Add(LayoutTestWidget.FixedSize(200, 100)); g.Add(LayoutTestWidget.FixedSize(150, 50)); g.Measure(Size.Auto); g.DesiredSize.Should().Be(new Size(200, 155)); g[0].DesiredSize.Should().Be(new Size(200, 100)); g[1].DesiredSize.Should().Be(new Size(150, 50)); }
public void ArrangeVerticalWithAnchor() { var g = new BoxGroup(LayoutTestStyle.Create()); g.Spacing = 5; g.Add(LayoutTestWidget.FixedSize(200, 100).WithAnchorRect(AnchoredRect.Full)); g.Add(LayoutTestWidget.FixedSize(150, 50).WithAnchorRect(AnchoredRect.Full)); g.Arrange(new Rectangle(10, 20, 400, 300)); g.LayoutRect.Should().Be(new Rectangle(10, 20, 400, 155)); g[0].LayoutRect.Should().Be(new Rectangle(10, 20, 400, 100)); g[1].LayoutRect.Should().Be(new Rectangle(10, 125, 400, 50)); }
public void ArrangeNonZeroOffset() { var p = new DockPanel(LayoutTestStyle.Create()); p.LastChildFill = true; p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Top); p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Bottom); p.Arrange(new Rectangle(10, 20, 800, 600)); p.DesiredSize.Should().Be(new Size(100, 100)); p.LayoutRect.Should().Be(new Rectangle(10, 20, 800, 600)); p[0].LayoutRect.Should().Be(new Rectangle(10, 20, 800, 50)); p[1].LayoutRect.Should().Be(new Rectangle(10, 70, 800, 550)); }
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)); }
public void MeasureHorizontal() { var g = new BoxGroup(LayoutTestStyle.Create()); g.Spacing = 5; g.Orientation = Orientation.Horizontal; g.Add(LayoutTestWidget.FixedSize(200, 100)); g.Add(LayoutTestWidget.FixedSize(150, 50)); g.Measure(Size.Auto); g.DesiredSize.Should().Be(new Size(355, 100)); g[0].DesiredSize.Should().Be(new Size(200, 100)); g[1].DesiredSize.Should().Be(new Size(150, 50)); }
public void LayoutVerticallyOpposingElementTopNoFill() { var p = new DockPanel(LayoutTestStyle.Create()); p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Left); p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Right); p.Measure(Size.Auto); p.DesiredSize.Should().Be(new Size(200, 50)); p.Arrange(new Rectangle(10, 20, 500, 300)); p.LayoutRect.Should().Be(new Rectangle(10, 20, 500, 300)); p[0].LayoutRect.Should().Be(new Rectangle(10, 20, 100, 300)); p[1].LayoutRect.Should().Be(new Rectangle(410, 20, 100, 300)); }
public void ArrangeHorizontal() { var g = new BoxGroup(LayoutTestStyle.Create()); g.Spacing = 5; g.Orientation = Orientation.Horizontal; g.Add(LayoutTestWidget.FixedSize(200, 100).WithAnchorRect(AnchoredRect.CreateTopLeftAnchored(0, 0))); g.Add(LayoutTestWidget.FixedSize(150, 50).WithAnchorRect(AnchoredRect.CreateTopLeftAnchored(0, 0))); g.Arrange(new Rectangle(10, 20, 400, 300)); g.LayoutRect.Should().Be(new Rectangle(10, 20, 355, 300)); g[0].LayoutRect.Should().Be(new Rectangle(10, 20, 200, 100)); g[1].LayoutRect.Should().Be(new Rectangle(215, 20, 150, 50)); }
public void ArrangeWithLargeElement() { //// Shows that large elements will make the content overflow. var p = new DockPanel(LayoutTestStyle.Create()); p.LastChildFill = true; p.Add(LayoutTestWidget.FixedSize(100, 50), DockPanelConstraint.Top); p.Add(LayoutTestWidget.FixedSize(100, 850), DockPanelConstraint.Bottom); p.Arrange(new Rectangle(10, 20, 800, 600)); p.DesiredSize.Should().Be(new Size(100, 900)); p.LayoutRect.Should().Be(new Rectangle(10, 20, 800, 600)); p[0].LayoutRect.Should().Be(new Rectangle(10, 20, 800, 50)); p[1].LayoutRect.Should().Be(new Rectangle(10, 70, 800, 850)); }
public void ArrangeHorizontalExpanded() { var g = new BoxGroup(LayoutTestStyle.Create()); g.Spacing = 5; g.Orientation = Orientation.Horizontal; g.Add(LayoutTestWidget.FixedSize(200, 100).WithAnchorRect(AnchoredRect.Full)); g.Add(LayoutTestWidget.FixedSize(150, 50).WithAnchorRect(AnchoredRect.Full), true); g.Add(LayoutTestWidget.FixedSize(150, 50).WithAnchorRect(AnchoredRect.Full)); g.Arrange(new Rectangle(10, 20, 800, 500)); g.LayoutRect.Should().Be(new Rectangle(10, 20, 800, 500)); g[0].LayoutRect.Should().Be(new Rectangle(10, 20, 200, 500)); g[1].LayoutRect.Should().Be(new Rectangle(215, 20, 440, 500)); g[2].LayoutRect.Should().Be(new Rectangle(660, 20, 150, 500)); }
public void ArrangeVerticalExpanded() { var g = new BoxGroup(LayoutTestStyle.Create()); g.Spacing = 5; g.Add(LayoutTestWidget.FixedSize(200, 100)); g.Add(LayoutTestWidget.FixedSize(150, 50), true); g.Add(LayoutTestWidget.FixedSize(150, 50), true); g.Add(LayoutTestWidget.FixedSize(150, 50)); g.Arrange(new Rectangle(10, 20, 400, 1300)); g.LayoutRect.Should().Be(new Rectangle(10, 20, 400, 1300)); g[0].LayoutRect.Should().Be(new Rectangle(10, 20, 400, 100)); g[1].LayoutRect.Should().Be(new Rectangle(10, 125, 400, 567)); g[2].LayoutRect.Should().Be(new Rectangle(10, 697, 400, 568)); g[3].LayoutRect.Should().Be(new Rectangle(10, 1270, 400, 50)); }
public void Auto_Relative_Mixed() { var g = new Grid(LayoutTestStyle.Create()); g.ColumnConstraints.Add(LengthConstraint.Auto); g.ColumnConstraints.Add(LengthConstraint.Relative(1)); g.ColumnConstraints.Add(LengthConstraint.Relative(1)); g.AddChildAt(LayoutTestWidget.FixedSize(100, 10), 0, 0); g.AddChildAt(LayoutTestWidget.FixedSize(200, 10), 1, 0); g.AddChildAt(LayoutTestWidget.FixedSize(10, 10), 2, 0); g.Arrange(new Rectangle(10, 20, 400, 20)); g.DesiredSize.Should().Be(new Size(400, 10)); g.LayoutRect.Should().Be(new Rectangle(10, 20, 400, 10)); g[0].LayoutRect.Should().Be(new Rectangle(10, 20, 100, 10)); g[1].LayoutRect.Should().Be(new Rectangle(110, 20, 150, 10)); g[2].LayoutRect.Should().Be(new Rectangle(260, 20, 150, 10)); }
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)); }
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)); }
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); }