예제 #1
0
        protected override Widget Build(BuildContext context)
        {
            Widget MakeContainer(int w, int h, int n) => new Container(
                size: WidgetSize.Fixed(w, h),
                backgroundColor: Color.Lerp(Color.blue, Color.green, n / 15f)
                );

            return(new Container(
                       backgroundColor: Color.gray,
                       child: new ScrollList(
                           crossAxisAlignment: CrossAxisAlignment.Center,
                           mainAxisAlignment: MainAxisAlignment.Center,
                           children: new List <Widget>
            {
                MakeContainer(100, 100, 1),
                MakeContainer(120, 110, 2),
                MakeContainer(110, 120, 3),
                MakeContainer(100, 140, 4),
                MakeContainer(150, 110, 5),
                MakeContainer(110, 100, 6),
                MakeContainer(100, 100, 7),
                MakeContainer(120, 110, 8),
                MakeContainer(100, 100, 9),
                MakeContainer(100, 100, 10),
            }
                           )
                       ));
        }
예제 #2
0
        public override WidgetSize CalculateSize()
        {
            var size = base.CalculateSize();

            if (_full.Value)
            {
                size = new WidgetSize(250, 250);
            }
            return(size);
        }
예제 #3
0
        private WidgetSize CalculateInnerSize()
        {
            var size = default(WidgetSize?);

            foreach (var child in Children)
            {
                size = size.HasValue ? WidgetSize.StackX(size.Value, child.Size) : child.Size;
            }

            return(size.GetValueOrDefault(WidgetSize.Zero));
        }
예제 #4
0
        private WidgetSize CalculateInnerSize()
        {
            var size = WidgetSize.Zero;

            foreach (var child in Children)
            {
                size = WidgetSize.StackY(size, child.Size);
            }

            return(size);
        }
예제 #5
0
 public virtual WidgetSize GetPreferredWidthForHeight(double height)
 {
     try {
         gettingPreferredSize = true;
         var s = new WidgetSize(Widget.SizeRequest().Width);
         if (minSizeSet && Frontend.MinWidth != -1)
         {
             s.MinSize = Frontend.MinWidth;
         }
         return(s);
     } finally {
         gettingPreferredSize = false;
     }
 }
예제 #6
0
 public virtual WidgetSize GetPreferredHeightForWidth(double width)
 {
     try {
         gettingPreferredSize = true;
         var s = new WidgetSize(Widget.SizeRequest().Height);
         if (minSizeSet && Frontend.MinHeight != -1)
         {
             s.MinSize = Frontend.MinHeight;
         }
         return(s);
     } finally {
         gettingPreferredSize = false;
     }
 }
예제 #7
0
 protected override Widget Build(BuildContext context)
 {
     return(new Container(
                size: WidgetSize.Stretched,
                backgroundColor: Color.white,
                child: new CompositeTransition(
                    opacity: _opacity,
                    position: _position,
                    rotation: _rotation,
                    child: new Container(
                        size: WidgetSize.Fixed(300, 200),
                        backgroundColor: Color.black
                        )
                    )
                ));
 }
예제 #8
0
        private WidgetSize CalculateInnerSize()
        {
            var width  = 0f;
            var height = 0f;

            var lineWidth    = 0.0f;
            var lineHeight   = 0.0f;
            var lineChildNum = 0;

            var maxLineWidth    = Widget.MaxCrossAxisExtent;
            var maxLineChildNum = Widget.MaxCrossAxisCount;

            foreach (var child in Children)
            {
                var childSize = child.Size;

                if (float.IsInfinity(childSize.MaxWidth) || float.IsInfinity(childSize.MaxHeight))
                {
                    continue;
                }

                if (lineChildNum + 1 <= maxLineChildNum &&
                    lineWidth + childSize.MaxWidth <= maxLineWidth)
                {
                    lineChildNum++;
                    lineWidth += childSize.MaxWidth;
                    lineHeight = Math.Max(lineHeight, childSize.MaxHeight);
                }
                else
                {
                    width   = Math.Max(width, lineWidth);
                    height += lineHeight;

                    lineChildNum = 1;
                    lineWidth    = childSize.MaxWidth;
                    lineHeight   = childSize.MaxHeight;
                }
            }

            width   = Math.Max(width, lineWidth);
            height += lineHeight;

            width = Math.Min(width, MaxCrossAxisExtent);

            return(WidgetSize.Fixed(width, height));
        }
예제 #9
0
        public virtual WidgetSize GetPreferredWidthForHeight(double height)
        {
            bool oldFlag = doubleSizeRequestCheckSupported;

            try {
                gettingPreferredSize            = true;
                doubleSizeRequestCheckSupported = false;
                var s = new WidgetSize(Widget.SizeRequest().Width);
                if (minSizeSet && Frontend.MinWidth != -1)
                {
                    s.MinSize = Frontend.MinWidth;
                }
                return(s);
            } finally {
                gettingPreferredSize            = false;
                doubleSizeRequestCheckSupported = oldFlag;
            }
        }
예제 #10
0
 /// <summary>
 /// Initializes a new instance of the <see cref="WidgetBase"/> class.
 /// </summary>
 /// <param name="widgetSize">Size of the widget.</param>
 protected WidgetBase(WidgetSize widgetSize)
 {
     WidgetSize = widgetSize;
 }
예제 #11
0
 private WidgetSize CalculateSizeInternal()
 {
     return(WidgetSize.Lerp(FirstChild.Size, SecondChild.Size, _controller.Value));
 }
예제 #12
0
        protected override void Render()
        {
            var children  = State.Children;
            var mainAxis  = State.MainAxisAlignment;
            var crossAxis = State.CrossAxisAlignment;
            var listSize  = State.InnerSize;

            var alignX = crossAxis == CrossAxisAlignment.Start ? Alignment.TopLeft.X
                : crossAxis == CrossAxisAlignment.End ? Alignment.TopRight.X
                : Alignment.Center.X;

            var childAlignment = new Alignment(alignX, Alignment.TopCenter.Y);
            var corner         = childAlignment.WithTop();
            var cornerPosition = new Vector2(0, 0);

            // content root
            {
                var contentPivotX = crossAxis == CrossAxisAlignment.Start ? 0.0f
                    : crossAxis == CrossAxisAlignment.End ? 1.0f
                    : 0.5f;

                var contentPivotY = mainAxis == MainAxisAlignment.Start ? 1.0f
                    : mainAxis == MainAxisAlignment.End ? 0.0f
                    : 0.5f;

                _contentRoot.pivot = new Vector2(contentPivotX, contentPivotY);

                LayoutData contentLayout;
                contentLayout.Size           = WidgetSize.FixedHeight(listSize.Height);
                contentLayout.Alignment      = childAlignment;
                contentLayout.Corner         = childAlignment;
                contentLayout.CornerPosition = Vector2.zero;
                ViewLayoutUtility.SetLayout(_contentRoot, contentLayout);
            }

            using (var render = _mapper.CreateRender())
            {
                foreach (var child in children)
                {
                    var childSize = child.Size;

                    if (childSize.IsHeightStretched)
                    {
                        Debug.LogError("Cannot render vertically stretched widgets inside ScrollList.\n" +
                                       $"Try to wrap '{child.GetType().Name}' into another widget with fixed height");
                        continue;
                    }

                    var childView = render.RenderItem(child);

                    LayoutData layout;
                    layout.Size           = childSize;
                    layout.Alignment      = childAlignment;
                    layout.Corner         = corner;
                    layout.CornerPosition = cornerPosition;
                    ViewLayoutUtility.SetLayout(childView.rectTransform, layout);

                    cornerPosition += new Vector2(0, childSize.Height);
                }
            }
        }
예제 #13
0
 public WidgetModel MakeWidget(WidgetShape widgetShape, WidgetColor widgetColor, WidgetSize widgetSize)
 {
     return(new WidgetBModel()
     {
         ID = Guid.NewGuid(),
         WidgetShape = widgetShape,
         WidgetColor = widgetColor,
         WidgetSize = widgetSize,
         AddtionalInformation = "This is Widgit B",
         Connectors = new List <WidgetConnectorModel>()
     });
 }
예제 #14
0
 public override WidgetSize CalculateSize() => WidgetSize.Fixed(0, 0);
예제 #15
0
 public WidgetModel MakeWidget(WidgetShape widgetShape, WidgetColor widgetColor, WidgetSize widgetSize)
 {
     return(new WidgetAModel()
     {
         ID = Guid.NewGuid(),
         WidgetShape = widgetShape,
         WidgetColor = widgetColor,
         WidgetSize = widgetSize,
         Connectors = new List <WidgetConnectorModel>()
     });
 }
예제 #16
0
 public UniMobText(WidgetSize size)
 {
     Size = size;
 }