Пример #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);
        }
Пример #2
0
        /// <summary> This will find the longest/tallest widget in each row/collumn and make every other element match. </summary>
        public static void AutoSizeAllWidgets(
            WidgetList widgets,
            int width,
            int height
            )
        {
            for (var x = 0; x < width; x++)
            {
                GridReader.GetColumn(widgets, width, height, x).AutoSizeWidth();
            }

            for (var y = 0; y < height; y++)
            {
                GridReader.GetRow(widgets, width, y).AutoSizeHeight();
            }
        }