Ejemplo n.º 1
0
        static void SetSize(
            WidgetList widgets,
            int width,
            int height,
            Point2 new_size,
            bool debug     = false,
            Point2?spacing = null  // TODO: what does null spacing mean? is it different from zero spacing?
            )
        {
            if (spacing.HasValue)
            {
                new_size -= TotalSpacingOffset(width, height, spacing.Value);
            }

            var original_size = new Point2(
                GridReader.GetRow(widgets, width, 0).CombinedWidth,
                GridReader.GetColumn(widgets, width, height, 0).CombinedHeight
                );

            var fixed_size = GridReader.FixedContentSizeTotal(widgets, width, height);

            var total_offset         = TotalSpacingOffset(width, height, spacing ?? new Point2());
            var fixed_with_offset    = fixed_size.Inverted().WithOffset(total_offset);
            var original_with_offset = original_size.WithOffset(fixed_with_offset).WithMinValue(0.0001f);
            var modifier             = new_size.DividedBy(original_with_offset);

            widgets.ExpandAll(modifier);
        }