Exemplo n.º 1
0
        public static void Align(
            WidgetList widgets,
            int width,
            int height,
            RectangleF new_area,
            Point2?spacing = null,
            bool debug     = false
            )
        {
            if (width == 0 || height == 0)
            {
                return;
            }

            AutoSizeAllWidgets(widgets, width, height);
            SetSize(widgets, width, height, new_area.Size, debug, spacing); // expand
            AutoSpaceAllWidgets(widgets, width, height, new_area.Position, spacing);
        }
Exemplo n.º 2
0
        public static void AutoSpaceAllWidgets(
            WidgetList widgets,
            int width,
            int height,
            Point2 start,
            Point2?spacing = null
            )
        {
            if (spacing.HasValue)
            {
                start = start.WithOffset(spacing.Value);
            }

            var position = start;

            for (var x = 0; x < width; x++)
            {
                position.Y = start.Y;
                for (var y = 0; y < height; y++)
                {
                    var widget = GridReader.Get(widgets, width, height, x, y);
                    widget.Position = position;
                    position.Y     += widget.Height;
                    if (spacing.HasValue)
                    {
                        position.Y += spacing.Value.Y;
                    }
                }

                position.X += widgets[x].Width;
                if (spacing.HasValue)
                {
                    position.X += spacing.Value.X;
                }
            }
        }
Exemplo n.º 3
0
 public static WidgetList GetRow(
     WidgetList widgets,
     int width,
     int y_row
     ) =>
 widgets.GetRange(y_row * width, width);