Exemple #1
0
 public SliverConstraints(
     AxisDirection axisDirection,
     GrowthDirection growthDirection,
     ScrollDirection userScrollDirection,
     double scrollOffset,
     double overlap,
     double remainingPaintExtent,
     double crossAxisExtent,
     AxisDirection crossAxisDirection,
     double viewportMainAxisExtent,
     double remainingCacheExtent,
     double cacheOrigin
     )
 {
     this.axisDirection          = axisDirection;
     this.growthDirection        = growthDirection;
     this.userScrollDirection    = userScrollDirection;
     this.scrollOffset           = scrollOffset;
     this.overlap                = overlap;
     this.remainingPaintExtent   = remainingPaintExtent;
     this.crossAxisExtent        = crossAxisExtent;
     this.crossAxisDirection     = crossAxisDirection;
     this.viewportMainAxisExtent = viewportMainAxisExtent;
     this.remainingCacheExtent   = remainingCacheExtent;
     this.cacheOrigin            = cacheOrigin;
 }
Exemple #2
0
        private static Rectangle GetGrowthBounds(IArrangedElement element, Size newSize)
        {
            GrowthDirection direction = GetGrowthDirection(element);
            Rectangle       oldBounds = GetCachedBounds(element);
            Point           location  = oldBounds.Location;

            Debug.Assert((CommonProperties.GetAutoSizeMode(element) == AutoSizeMode.GrowAndShrink || (newSize.Height >= oldBounds.Height && newSize.Width >= oldBounds.Width)),
                         "newSize expected to be >= current size.");

            if ((direction & GrowthDirection.Left) != GrowthDirection.None)
            {
                // We are growing towards the left, translate X
                location.X -= newSize.Width - oldBounds.Width;
            }

            if ((direction & GrowthDirection.Upward) != GrowthDirection.None)
            {
                // We are growing towards the top, translate Y
                location.Y -= newSize.Height - oldBounds.Height;
            }

            Rectangle newBounds = new Rectangle(location, newSize);

            Debug.Assert((CommonProperties.GetAutoSizeMode(element) == AutoSizeMode.GrowAndShrink || newBounds.Contains(oldBounds)), "How did we resize in such a way we no longer contain our old bounds?");

            return(newBounds);
        }
 public SliverConstraints(
     AxisDirection axisDirection,
     GrowthDirection growthDirection,
     ScrollDirection userScrollDirection,
     float scrollOffset,
     float precedingScrollExtent,
     float overlap,
     float remainingPaintExtent,
     float crossAxisExtent,
     AxisDirection crossAxisDirection,
     float viewportMainAxisExtent,
     float remainingCacheExtent,
     float cacheOrigin
     )
 {
     this.axisDirection         = axisDirection;
     this.growthDirection       = growthDirection;
     this.userScrollDirection   = userScrollDirection;
     this.scrollOffset          = scrollOffset;
     this.precedingScrollExtent = precedingScrollExtent;
     this.overlap = overlap;
     this.remainingPaintExtent   = remainingPaintExtent;
     this.crossAxisExtent        = crossAxisExtent;
     this.crossAxisDirection     = crossAxisDirection;
     this.viewportMainAxisExtent = viewportMainAxisExtent;
     this.remainingCacheExtent   = remainingCacheExtent;
     this.cacheOrigin            = cacheOrigin;
 }
        public static ScrollDirection applyGrowthDirectionToScrollDirection(
            ScrollDirection scrollDirection, GrowthDirection growthDirection)
        {
            switch (growthDirection)
            {
            case GrowthDirection.forward:
                return(scrollDirection);

            case GrowthDirection.reverse:
                return(ScrollDirectionUtils.flipScrollDirection(scrollDirection));
            }

            throw new Exception("unknown growthDirection");
        }
        public static AxisDirection applyGrowthDirectionToAxisDirection(
            AxisDirection axisDirection, GrowthDirection growthDirection)
        {
            switch (growthDirection)
            {
            case GrowthDirection.forward:
                return(axisDirection);

            case GrowthDirection.reverse:
                return(AxisUtils.flipAxisDirection(axisDirection));
            }

            throw new Exception("unknown growthDirection");
        }
Exemple #6
0
        void _debugDrawArrow(Canvas canvas, Paint paint, Offset p0, Offset p1, GrowthDirection direction)
        {
            D.assert(() => {
                if (p0 == p1)
                {
                    return(true);
                }

                D.assert(p0.dx == p1.dx || p0.dy == p1.dy);
                float d = (p1 - p0).distance * 0.2f;
                Offset temp;
                float dx1 = 0, dx2 = 0, dy1 = 0, dy2 = 0;
                switch (direction)
                {
                case GrowthDirection.forward:
                    dx1 = dx2 = dy1 = dy2 = d;
                    break;

                case GrowthDirection.reverse:
                    temp = p0;
                    p0   = p1;
                    p1   = temp;
                    dx1  = dx2 = dy1 = dy2 = -d;
                    break;
                }

                if (p0.dx == p1.dx)
                {
                    dx2 = -dx2;
                }
                else
                {
                    dy2 = -dy2;
                }
                var path = new Path();
                path.moveTo(p0.dx, p0.dy);
                path.lineTo(p1.dx, p1.dy);
                path.moveTo(p1.dx - dx1, p1.dy - dy1);
                path.lineTo(p1.dx, p1.dy);
                path.lineTo(p1.dx - dx2, p1.dy - dy2);
                canvas.drawPath(
                    path,
                    paint
                    );

                return(true);
            });
        }
        private static Rectangle GetGrowthBounds(IArrangedElement element, Size newSize)
        {
            GrowthDirection growthDirection = GetGrowthDirection(element);
            Rectangle       cachedBounds    = GetCachedBounds(element);
            Point           location        = cachedBounds.Location;

            if ((growthDirection & GrowthDirection.Left) != GrowthDirection.None)
            {
                location.X -= newSize.Width - cachedBounds.Width;
            }
            if ((growthDirection & GrowthDirection.Upward) != GrowthDirection.None)
            {
                location.Y -= newSize.Height - cachedBounds.Height;
            }
            return(new Rectangle(location, newSize));
        }
Exemple #8
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextLog"/> class.
        /// </summary>
        /// <param name="parent">This controls parent control.</param>
        /// <param name="font">The font to use to draw the text contained by this log.</param>
        public TextLog(Control parent, SpriteFont font, int historyCapacity)
            : base(parent)
        {
            this.historyCapacity = historyCapacity;
            text      = new List <StringPart>();
            Font      = font;
            Colour    = Color.White;
            Scale     = Vector2.One;
            Direction = GrowthDirection.Up;

            //Action<Frame> recalc = delegate(Frame c)
            //{
            //    Recalculate();
            //};

            //AreaChanged += recalc;
        }
        private static GrowthDirection GetGrowthDirection(IArrangedElement element)
        {
            AnchorStyles    anchor = GetAnchor(element);
            GrowthDirection none   = GrowthDirection.None;

            if (((anchor & AnchorStyles.Right) != AnchorStyles.None) && ((anchor & AnchorStyles.Left) == AnchorStyles.None))
            {
                none |= GrowthDirection.Left;
            }
            else
            {
                none |= GrowthDirection.Right;
            }
            if (((anchor & AnchorStyles.Bottom) != AnchorStyles.None) && ((anchor & AnchorStyles.Top) == AnchorStyles.None))
            {
                return(none | GrowthDirection.Upward);
            }
            return(none | GrowthDirection.Downward);
        }
        void _paintSide(Canvas canvas, Size size, _GlowController controller, AxisDirection axisDirection,
                        GrowthDirection growthDirection)
        {
            if (controller == null)
            {
                return;
            }

            switch (GrowthDirectionUtils.applyGrowthDirectionToAxisDirection(axisDirection, growthDirection))
            {
            case AxisDirection.up:
                controller.paint(canvas, size);
                break;

            case AxisDirection.down:
                canvas.save();
                canvas.translate(0.0f, size.height);
                canvas.scale(1.0f, -1.0f);
                controller.paint(canvas, size);
                canvas.restore();
                break;

            case AxisDirection.left:
                canvas.save();
                canvas.rotate(piOver2);
                canvas.scale(1.0f, -1.0f);
                controller.paint(canvas, new Size(size.height, size.width));
                canvas.restore();
                break;

            case AxisDirection.right:
                canvas.save();
                canvas.translate(size.width, 0.0f);
                canvas.rotate(piOver2);
                controller.paint(canvas, new Size(size.height, size.width));
                canvas.restore();
                break;
            }
        }
Exemple #11
0
        private static GrowthDirection GetGrowthDirection(IArrangedElement element)
        {
            AnchorStyles    anchor          = GetAnchor(element);
            GrowthDirection growthDirection = GrowthDirection.None;

            if ((anchor & AnchorStyles.Right) != AnchorStyles.None &&
                (anchor & AnchorStyles.Left) == AnchorStyles.None)
            {
                // element is anchored to the right, but not the left.
                growthDirection |= GrowthDirection.Left;
            }
            else
            {
                // otherwise we grow towards the right (common case)
                growthDirection |= GrowthDirection.Right;
            }

            if ((anchor & AnchorStyles.Bottom) != AnchorStyles.None &&
                (anchor & AnchorStyles.Top) == AnchorStyles.None)
            {
                // element is anchored to the bottom, but not the top.
                growthDirection |= GrowthDirection.Upward;
            }
            else
            {
                // otherwise we grow towards the bottom. (common case)
                growthDirection |= GrowthDirection.Downward;
            }

            Debug.Assert((growthDirection & GrowthDirection.Left) == GrowthDirection.None ||
                         (growthDirection & GrowthDirection.Right) == GrowthDirection.None,
                         "We shouldn't allow growth to both the left and right.");
            Debug.Assert((growthDirection & GrowthDirection.Upward) == GrowthDirection.None ||
                         (growthDirection & GrowthDirection.Downward) == GrowthDirection.None,
                         "We shouldn't allow both upward and downward growth.");
            return(growthDirection);
        }
Exemple #12
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TextLog"/> class.
        /// </summary>
        /// <param name="parent">This controls parent control.</param>
        /// <param name="font">The font to use to draw the text contained by this log.</param>
        /// <param name="historyCapacity"></param>
        public TextLog(Control parent, SpriteFont font, int historyCapacity)
            : base(parent)
        {
            _historyCapacity = historyCapacity;
            _text = new List<StringPart>();
            Font = font;
            Colour = Color.White;
            Scale = Vector2.One;
            Direction = GrowthDirection.Up;

            //Action<Frame> recalc = delegate(Frame c)
            //{
            //    Recalculate();
            //};

            //AreaChanged += recalc;
        }