Пример #1
0
        public void Render(Entity entity, SpriteBatch batch, AssetManager assetManager)
        {
            var tex = assetManager[AssetManager.SolidGrayColor];

            var rectBg = new Rectangle(RenderPosition.ToPoint(), LayoutSize.ToPoint());

            if (MouseState == ElementMouseState.Pressed)
            {
                rectBg.Offset(1, 1);
            }

            var rectShadow = rectBg;

            rectShadow.Offset(2, 2);

            var   textOffset  = new Vector2(2);
            Color buttonColor = Color.White;

            if (MouseState == ElementMouseState.Pressed)
            {
                textOffset += new Vector2(1);
                buttonColor = Color.LightGray;
            }
            else if (MouseState == ElementMouseState.Hover)
            {
                buttonColor = Color.LightGray;
            }

            batch.Draw(tex, rectShadow, Color.Gray);
            batch.Draw(tex, rectBg, buttonColor);
            batch.DrawString(Font, Text, RenderPosition + textOffset, Color.Black);
        }
 public static void saveConfig()
 {
     getElement("greenhousemode").Value = GreenHouseMode.ToString();
     getElement("selectedlayout").Value = SelectedLayout.Name;
     getElement("layoutsize").Value     = LayoutSize.ToString();
     doc.Save(docPath);
 }
Пример #3
0
    private Vector2Int OnGUIFraction(Rect position, SerializedProperty property)
    {
        SerializedProperty numerator   = property.FindPropertyRelative("n");
        SerializedProperty denominator = property.FindPropertyRelative("d");
        Vector2Int         inputs      = new Vector2Int();

        GUIStyle slashStyle = new GUIStyle(EditorStyles.boldLabel);

        slashStyle.alignment = TextAnchor.MiddleCenter;
        slashStyle.fontStyle = FontStyle.Bold;

        Layout.Builder builder = new Layout.Builder();
        builder.PushChild(new LayoutChild(LayoutSize.RatioOfRemainder(0.5f)));
        builder.PushChild(new LayoutChild(LayoutSize.Exact(CENTER_BUFFER)));
        builder.PushChild(new LayoutChild(LayoutSize.RatioOfRemainder(0.5f)));
        Layout layout = builder.Compile(position);

        // Reset to no indent
        int oldIndent = EditorGUI.indentLevel;

        EditorGUI.indentLevel = 0;

        // Put the numerator, slash, denominator
        inputs.x = EditorGUI.DelayedIntField(layout.Next(), numerator.intValue);
        EditorGUI.LabelField(layout.Next(), new GUIContent("/"), slashStyle);
        inputs.y = EditorGUI.DelayedIntField(layout.Next(), denominator.intValue);

        // Restore old indent
        EditorGUI.indentLevel = oldIndent;

        return(inputs);
    }
Пример #4
0
        public override void RunLayoutHorizontal(int frameId)
        {
            AwesomeLayoutBox ptr = firstChild;

            float contentAreaWidth = finalWidth - (paddingBorderHorizontalStart + paddingBorderHorizontalEnd);

            float alignment = element.style.AlignItemsHorizontal;

            // SpaceDistribution extraSpace = element.style.DistributeExtraSpaceHorizontal;

            float inset = paddingBorderHorizontalStart;

            while (ptr != null)
            {
                LayoutSize size = default;
                ptr.GetWidths(ref size);
                float clampedWidth = size.Clamped;

                float x               = inset + size.marginStart;
                float originBase      = x;
                float originOffset    = contentAreaWidth * alignment;
                float alignedPosition = originBase + originOffset + (clampedWidth * -alignment);
                ptr.ApplyLayoutHorizontal(x, alignedPosition, size, clampedWidth, contentAreaWidth, LayoutFit.None, frameId);
                ptr = ptr.nextSibling;
            }
        }
Пример #5
0
 private void GetLayoutSize()
 {
     if (this.socket.Connected) // Socket connection check.
     {
         this.socket.Send(this.SerializeData("Send layout size please."));
         this.size = (LayoutSize)this.ReceiveData();
     }
 }
Пример #6
0
        public override void RunLayoutHorizontal(int frameId)
        {
            float contentAreaWidth = finalWidth - (paddingBorderHorizontalStart + paddingBorderHorizontalEnd);

            float inset = paddingBorderHorizontalStart;

            LayoutSize size = default;

            firstChild.GetWidths(ref size);

            float contentWidth           = size.Clamped;
            float scrollOffsetPercentage = Mathf.Clamp(scrollView.scrollPercentageX, 0, 1);

            float x               = inset + size.marginStart;
            float originBase      = x;
            float originOffset    = contentAreaWidth * scrollOffsetPercentage;
            float alignedPosition = originBase + originOffset + (contentWidth * -scrollOffsetPercentage);

            firstChild.ApplyLayoutHorizontalExplicit(alignedPosition, contentWidth, frameId);
            firstChild.flags |= LayoutBoxFlags.RequiresMatrixUpdate;

            scrollView.scrollPixelAmountX = alignedPosition;

            AwesomeLayoutBox verticalTrack    = element.children.array[1].layoutBox;
            AwesomeLayoutBox verticalHandle   = element.children.array[2].layoutBox;
            AwesomeLayoutBox horizontalTrack  = element.children.array[3].layoutBox;
            AwesomeLayoutBox horizontalHandle = element.children.array[4].layoutBox;

            float trackSize = Mathf.Max(5f, scrollView.trackSize);

            float horizontalWidth = scrollView.verticalScrollingEnabled ? contentAreaWidth - trackSize : contentAreaWidth;

            if (verticalTrack != null && verticalTrack.element.isEnabled)
            {
                verticalTrack.ApplyLayoutHorizontalExplicit(paddingBorderHorizontalStart + paddingBorderHorizontalEnd + contentAreaWidth - trackSize, trackSize, frameId);
                verticalTrack.flags |= LayoutBoxFlags.RequiresMatrixUpdate;
            }

            if (verticalHandle != null && verticalHandle.element.isEnabled)
            {
                verticalHandle.ApplyLayoutHorizontalExplicit(paddingBorderHorizontalStart + paddingBorderHorizontalEnd + contentAreaWidth - trackSize, trackSize, frameId);
                verticalHandle.flags |= LayoutBoxFlags.RequiresMatrixUpdate;
            }

            if (horizontalTrack != null && horizontalTrack.element.isEnabled)
            {
                horizontalTrack.ApplyLayoutHorizontalExplicit(paddingBorderHorizontalStart, horizontalWidth, frameId);
                horizontalTrack.flags |= LayoutBoxFlags.RequiresMatrixUpdate;
            }

            if (horizontalHandle != null && horizontalHandle.element.isEnabled)
            {
                float handleWidth    = (contentAreaWidth / contentWidth) * horizontalWidth;
                float handlePosition = (contentAreaWidth - handleWidth) * scrollOffsetPercentage;
                horizontalHandle.ApplyLayoutHorizontalExplicit(handlePosition + inset, handleWidth, frameId);
                horizontalHandle.flags |= LayoutBoxFlags.RequiresMatrixUpdate;
            }
        }
Пример #7
0
        public override void RunLayoutVertical(int frameId)
        {
            float contentAreaHeight = finalHeight - (paddingBorderVerticalStart + paddingBorderVerticalEnd);

            LayoutSize size = default;

            firstChild.GetHeights(ref size);
            float contentHeight = size.Clamped;

            float inset = paddingBorderVerticalStart;
            float scrollOffsetPercentage = Mathf.Clamp01(scrollView.scrollPercentageY);

            float y               = inset + size.marginStart;
            float originBase      = y;
            float originOffset    = contentAreaHeight * scrollOffsetPercentage;
            float alignedPosition = contentAreaHeight > contentHeight ? originBase : originBase + originOffset + (contentHeight * -scrollOffsetPercentage);

            firstChild.ApplyLayoutVerticalExplicit(alignedPosition, contentHeight, frameId);
            firstChild.flags |= LayoutBoxFlags.RequiresMatrixUpdate;

            scrollView.scrollPixelAmountY = alignedPosition - originBase;

            AwesomeLayoutBox verticalTrack    = element.children.array[1].layoutBox;
            AwesomeLayoutBox verticalHandle   = element.children.array[2].layoutBox;
            AwesomeLayoutBox horizontalTrack  = element.children.array[3].layoutBox;
            AwesomeLayoutBox horizontalHandle = element.children.array[4].layoutBox;

            float trackSize      = Mathf.Max(5f, scrollView.trackSize);
            float verticalHeight = scrollView.verticalScrollingEnabled ? contentAreaHeight - trackSize : contentAreaHeight;

            if (verticalTrack != null && verticalTrack.element.isEnabled)
            {
                verticalTrack.ApplyLayoutVerticalExplicit(inset, contentAreaHeight, frameId);
                verticalTrack.flags |= LayoutBoxFlags.RequiresMatrixUpdate;
            }

            if (verticalHandle != null && verticalHandle.element.isEnabled)
            {
                float handleHeight   = (contentAreaHeight / contentHeight) * verticalHeight;
                float handlePosition = (contentAreaHeight - handleHeight) * scrollOffsetPercentage;
                verticalHandle.ApplyLayoutVerticalExplicit(handlePosition + inset, handleHeight, frameId);
                verticalHandle.flags |= LayoutBoxFlags.RequiresMatrixUpdate;
                verticalHandle.flags |= LayoutBoxFlags.RequiresMatrixUpdate;
            }

            if (horizontalTrack != null && horizontalTrack.element.isEnabled)
            {
                horizontalTrack.ApplyLayoutVerticalExplicit(paddingBorderVerticalStart + contentAreaHeight - trackSize, trackSize, frameId);
                horizontalTrack.flags |= LayoutBoxFlags.RequiresMatrixUpdate;
            }

            if (horizontalHandle != null && horizontalHandle.element.isEnabled)
            {
                horizontalHandle.ApplyLayoutVerticalExplicit(paddingBorderVerticalStart + contentAreaHeight - trackSize, trackSize, frameId);
                horizontalHandle.flags |= LayoutBoxFlags.RequiresMatrixUpdate;
            }
        }
Пример #8
0
    private void OnGUIMatrix(Layout verticalLayout, SerializedProperty property)
    {
        SerializedProperty data = property.FindPropertyRelative("data");
        int rows = property.FindPropertyRelative("_rows").intValue;

        // The style for a label of the row, column
        GUIStyle labelStyle = new GUIStyle(EditorStyles.boldLabel)
        {
            alignment = TextAnchor.MiddleCenter
        };

        for (int i = -1; i < rows; i++)
        {
            // Build the horizontal layout that will be in the current part of the vertical layout
            Layout.Builder builder = new Layout.Builder();
            builder.PushChild(new LayoutChild(LayoutSize.Exact(ITEM_LABEL_WIDTH)));
            for (int j = 0; j < cols; j++)
            {
                builder.PushChild(new LayoutChild(LayoutSize.RatioOfRemainder(1f / cols), LayoutMargin.Right(HORIZONTAL_ITEM_SPACE)));
            }
            Layout horizontalLayout = builder.Compile(EditorGUI.IndentedRect(verticalLayout.Next()));

            // No indent because it is accounted for when the builder built the rect in the indented rect
            EditorGUIExt.PushIndent(0);

            for (int j = -1; j < cols; j++)
            {
                // Code inside is for the row with the labels
                if (i == -1)
                {
                    // If we're at the top corner, put "[X, Y]"
                    if (j == -1)
                    {
                        EditorGUI.LabelField(horizontalLayout.Next(), new GUIContent("[X, Y]"), labelStyle);
                    }
                    // If we're in the top row, put down the column numbers
                    else
                    {
                        EditorGUI.LabelField(horizontalLayout.Next(), new GUIContent(j.ToString()), labelStyle);
                    }
                }
                // Code inside is for the column with the labels
                else if (j == -1)
                {
                    EditorGUI.LabelField(horizontalLayout.Next(), new GUIContent(i.ToString()), labelStyle);
                }
                // Code in here displays the property
                else
                {
                    EditorGUI.PropertyField(horizontalLayout.Next(), data.GetArrayElementAtIndex(MyMath.Index2Dto1D(i, j, cols)), GUIContent.none);
                }
            }
        }

        EditorGUIExt.PopIndent();
    }
Пример #9
0
        public void stretch_horizontally()
        {
            var size = LayoutSize.StretchedHorizontally(30);

            size.IsFixedAspectRatio().Should().BeFalse();
            size.IsMeasurableAlong(Orientation.Horizontal).Should().BeFalse();
            size.IsMeasurableAlong(Orientation.Vertical).Should().BeTrue();
            size.IsStretchedAlong(Orientation.Vertical).Should().BeFalse();
            size.IsStretchedPerpendicular(Orientation.Vertical).Should().BeTrue();
        }
Пример #10
0
        public override void RunLayoutVertical(int frameId)
        {
            if (firstChild == null)
            {
                return;
            }
            LayoutSize size = default;

            firstChild.GetHeights(ref size);
            firstChild.ApplyLayoutVertical(0, 0, size, size.preferred, size.preferred, LayoutFit.None, frameId);
        }
Пример #11
0
        public void linear_layout_test_with_margin_and_padding()
        {
            var layout = LayoutNode.VerticalParent("root", LayoutSize.Pixels(50, 100), new LayoutStyle(padding: 5, margin: new Point(3, 6)),
                                                   LayoutNode.Leaf("item-1", LayoutSize.StretchedHorizontally(10)),
                                                   LayoutNode.Leaf("item-2", LayoutSize.StretchedHorizontally(20)),
                                                   LayoutNode.Leaf("item-3", LayoutSize.StretchedBoth())
                                                   );

            var layoutResult = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(layoutResult));
        }
Пример #12
0
        public void fixed_aspect_with_alignment()
        {
            var layout = LayoutNode.VerticalParent("root", LayoutSize.Pixels(50, 80), new LayoutStyle(alignment: Alignment.Center),
                                                   LayoutNode.Leaf("fixed-aspect", LayoutSize.FixedAspectRatio(16, 9))
                                                   );

            var firstBakeResult = layout.Bake();

            Approvals.Verify(
                LayoutNodeUtils.DrawResult(firstBakeResult)
                );
        }
Пример #13
0
        public void linear_layout_test()
        {
            var layout = LayoutNode.VerticalParent("root", LayoutSize.Pixels(50, 100), LayoutStyle.Empty,
                                                   LayoutNode.Leaf("item-1", LayoutSize.StretchedHorizontally(10)),
                                                   LayoutNode.Leaf("item-2", LayoutSize.StretchedHorizontally(20)),
                                                   LayoutNode.Leaf("item-3", LayoutSize.StretchedBoth())
                                                   );

            var layoutResult = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(layoutResult));
        }
Пример #14
0
        public void spacer_test()
        {
            var layout = LayoutNode.HorizontalParent("root", LayoutSize.Pixels(50, 20), LayoutStyle.Empty,
                                                     LayoutNode.StretchedSpacer(),
                                                     LayoutNode.Leaf("nudged-item", LayoutSize.StretchedVertically(10)),
                                                     LayoutNode.Spacer(5)
                                                     );

            var firstBakeResult = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(firstBakeResult));
        }
Пример #15
0
        protected void SetViewMode(LayoutType layoutType, LayoutSize layoutSize)
        {
            LayoutType = layoutType;
            LayoutSize = layoutSize;

            ISettingsManager settingsManager = ServiceRegistration.Get <ISettingsManager>();
            ViewSettings     settings        = settingsManager.Load <ViewSettings>();

            settings.LayoutType = layoutType;
            settings.LayoutSize = layoutSize;
            settingsManager.Save(settings);
        }
Пример #16
0
 protected void UpdateSelectedFlag(ItemsList itemsList)
 {
     foreach (ListItem item in itemsList)
     {
         object layout;
         object size;
         if (item.AdditionalProperties.TryGetValue(Consts.KEY_LAYOUT_TYPE, out layout) && item.AdditionalProperties.TryGetValue(Consts.KEY_LAYOUT_SIZE, out size))
         {
             item.Selected = LayoutType.Equals(layout) && LayoutSize.Equals(size);
         }
     }
 }
Пример #17
0
    public override void OnGUI(Rect position, SerializedProperty property, GUIContent label)
    {
        // Store min-max sub-properties for ease of use
        SerializedProperty min = property.FindPropertyRelative("_min");
        SerializedProperty max = property.FindPropertyRelative("_max");

        // Put in the prefix label
        position = EditorGUI.PrefixLabel(position, label);

        // Store the old indent
        int oldIndent = EditorGUI.indentLevel;

        EditorGUI.indentLevel = 0;

        // Build a single-line layout where the float editors stretch and the labels stay at the same width
        Layout.Builder builder = new Layout.Builder();
        builder.PushChild(LayoutChild.Width(LayoutSize.Exact(35f)));
        builder.PushChild(LayoutChild.Width(LayoutSize.RatioOfRemainder(0.5f), LayoutMargin.Right(5f)));
        builder.PushChild(LayoutChild.Width(LayoutSize.Exact(35f)));
        builder.PushChild(LayoutChild.Width(LayoutSize.RatioOfRemainder(0.5f)));
        Layout layout = builder.Compile(position);

        // Create the min label
        EditorGUI.LabelField(layout.Next(), new GUIContent("Min:"));

        // Create the min editor
        EditorGUI.BeginChangeCheck();
        min.floatValue = EditorGUI.DelayedFloatField(layout.Next(), min.floatValue);

        // If the max was modified, ensure that the max is not smaller than the new min
        if (EditorGUI.EndChangeCheck())
        {
            max.floatValue = Mathf.Max(min.floatValue, max.floatValue);
        }

        // Create the max label
        EditorGUI.LabelField(layout.Next(), new GUIContent("Max:"));

        // Create the max editor
        EditorGUI.BeginChangeCheck();
        max.floatValue = EditorGUI.DelayedFloatField(layout.Next(), max.floatValue);

        // If the max was modified, ensure that the min is not bigger than the new max
        if (EditorGUI.EndChangeCheck())
        {
            min.floatValue = Mathf.Min(min.floatValue, max.floatValue);
        }

        // Restore indent level
        EditorGUI.indentLevel = oldIndent;
    }
Пример #18
0

        
Пример #19
0
        public void can_create_vertical_flex_layout()
        {
            var layout = FlexLayout.VerticalFlexParent("root", FlexLayoutStyle.Empty,
                                                       LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 3)),
                                                       LayoutNode.Leaf("itemB", LayoutSize.Pixels(12, 10)),
                                                       LayoutNode.Leaf("itemC", LayoutSize.Pixels(8, 5)),
                                                       LayoutNode.Leaf("itemD", LayoutSize.Pixels(9, 10)),
                                                       LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 8))
                                                       );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
Пример #20
0
        public void alignment_with_varied_height_things_top_right()
        {
            var layout = LayoutNode.HorizontalParent("root", LayoutSize.Pixels(68, 20), new LayoutStyle(padding: 3, alignment: Alignment.TopRight),
                                                     LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 3)),
                                                     LayoutNode.Leaf("itemB", LayoutSize.Pixels(12, 10)),
                                                     LayoutNode.Leaf("itemC", LayoutSize.Pixels(8, 5)),
                                                     LayoutNode.Leaf("itemD", LayoutSize.Pixels(9, 10)),
                                                     LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 8))
                                                     );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
Пример #21
0
        public void flex_can_specify_a_min_width()
        {
            var layout = FlexLayout.HorizontalFlexParent("root", new FlexLayoutStyle(minAlongSize: 100, style: new LayoutStyle(margin: new Point(5, 5), padding: 3, alignment: Alignment.BottomCenter)),
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 3)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(12, 10)),
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(8, 5)),
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(9, 10)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 8))
                                                         );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
Пример #22
0
        public void does_not_stretch_evenly()
        {
            var layout = LayoutNode.HorizontalParent("root", LayoutSize.Pixels(20, 5), new LayoutStyle(margin: new Point(1, 1), padding: 1, Alignment.TopLeft),
                                                     LayoutNode.Leaf("a", LayoutSize.StretchedBoth()),
                                                     LayoutNode.Leaf("b", LayoutSize.StretchedBoth()),
                                                     LayoutNode.Leaf("c", LayoutSize.StretchedBoth())
                                                     );

            var result = layout.Bake();

            Approvals.Verify(
                LayoutNodeUtils.DrawResult(result)
                );
        }
Пример #23
0
        public void flex_considers_alignment_when_things_have_varied_perpendicular_size()
        {
            var layout = FlexLayout.HorizontalFlexParent("root", new FlexLayoutStyle(style: new LayoutStyle(margin: new Point(5, 5), padding: 3, alignment: Alignment.BottomCenter)),
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 3)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(12, 10)),
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(8, 5)),
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(9, 10)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 8))
                                                         );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
Пример #24
0
        public void flex_layout_supports_padding()
        {
            var layout = FlexLayout.HorizontalFlexParent("root", new FlexLayoutStyle(style: new LayoutStyle(margin: new Point(5, 5), padding: 3)),
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 3)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(12, 10)),
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(8, 5)),
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(9, 10)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 8))
                                                         );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
Пример #25
0
        public void can_get_baked_layout_node_by_name()
        {
            var layout = LayoutNode.HorizontalParent("root", LayoutSize.Pixels(20, 5), new LayoutStyle(margin: new Point(1, 1), padding: 1, Alignment.TopLeft),
                                                     LayoutNode.Leaf("a", LayoutSize.StretchedBoth()),
                                                     LayoutNode.Leaf("b", LayoutSize.StretchedBoth()),
                                                     LayoutNode.Leaf("c", LayoutSize.StretchedBoth())
                                                     );

            var subject = layout.Bake();

            var acquiredNode = subject.GetNode("b");

            acquiredNode.Size.Should().Be(new Point(5, 3));
        }
Пример #26
0
        public void flow_layout_supports_horizontal_alignment()
        {
            var layout = FlowLayout.HorizontalFlowParent("root", LayoutSize.Pixels(40, 30), new FlowLayoutStyle(alignment: Alignment.CenterRight),
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(12, 10)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(7, 10)),
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(7, 10)),
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(7, 10)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(7, 10)),
                                                         LayoutNode.Leaf("itemF", LayoutSize.Pixels(7, 10))
                                                         );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
Пример #27
0
        public void flow_layout_can_have_padding_between_rows()
        {
            var layout = FlowLayout.HorizontalFlowParent("root", LayoutSize.Pixels(30, 30), new FlowLayoutStyle(paddingBetweenRows: 3),
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemF", LayoutSize.Pixels(10, 10))
                                                         );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
Пример #28
0
        public void flow_layout_can_have_margin()
        {
            var layout = FlowLayout.HorizontalFlowParent("root", LayoutSize.Pixels(40, 40), new FlowLayoutStyle(margin: new Point(5)),
                                                         LayoutNode.Leaf("itemA", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemB", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemC", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemD", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemE", LayoutSize.Pixels(10, 10)),
                                                         LayoutNode.Leaf("itemF", LayoutSize.Pixels(10, 10))
                                                         );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
Пример #29
0
        public void flow_layout_can_be_vertical_with_alignment()
        {
            var layout = FlowLayout.VerticalFlowParent("root", LayoutSize.Pixels(25, 40), new FlowLayoutStyle(alignment: Alignment.BottomRight),
                                                       LayoutNode.Leaf("itemA", LayoutSize.Pixels(12, 10)),
                                                       LayoutNode.Leaf("itemB", LayoutSize.Pixels(7, 10)),
                                                       LayoutNode.Leaf("itemC", LayoutSize.Pixels(9, 10)),
                                                       LayoutNode.Leaf("itemD", LayoutSize.Pixels(10, 10)),
                                                       LayoutNode.Leaf("itemE", LayoutSize.Pixels(13, 10)),
                                                       LayoutNode.Leaf("itemF", LayoutSize.Pixels(7, 10))
                                                       );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
Пример #30
0
        public void flow_layout_can_be_vertical()
        {
            var layout = FlowLayout.VerticalFlowParent("root", LayoutSize.Pixels(25, 40), new FlowLayoutStyle(paddingBetweenItemsInEachRow: 4),
                                                       LayoutNode.Leaf("itemA", LayoutSize.Pixels(12, 10)),
                                                       LayoutNode.Leaf("itemB", LayoutSize.Pixels(7, 10)),
                                                       LayoutNode.Leaf("itemC", LayoutSize.Pixels(9, 10)),
                                                       LayoutNode.Leaf("itemD", LayoutSize.Pixels(10, 10)),
                                                       LayoutNode.Leaf("itemE", LayoutSize.Pixels(13, 10)),
                                                       LayoutNode.Leaf("itemF", LayoutSize.Pixels(7, 10))
                                                       );

            var result = layout.Bake();

            Approvals.Verify(LayoutNodeUtils.DrawResult(result));
        }
Пример #31
0
    protected void SetViewMode(LayoutType layoutType, LayoutSize layoutSize)
    {
      LayoutType = layoutType;
      LayoutSize = layoutSize;

      ISettingsManager settingsManager = ServiceRegistration.Get<ISettingsManager>();
      ViewSettings settings = settingsManager.Load<ViewSettings>();
      settings.LayoutType = layoutType;
      settings.LayoutSize = layoutSize;
      settingsManager.Save(settings);
    }
Пример #32
0
    protected void SetViewMode(LayoutType layoutType, LayoutSize layoutSize)
    {
      LayoutType = layoutType;
      LayoutSize = layoutSize;

      MediaNavigationModel model = MediaNavigationModel.GetCurrentInstance();
      NavigationData navigationData = model.NavigationData;
      if (navigationData == null)
        return;

      navigationData.LayoutType = layoutType;
      navigationData.LayoutSize = layoutSize;
    }