void SetLocation(IGridLayout grid, IView view, int row = 0, int col = 0, int rowSpan = 1, int colSpan = 1) { grid.GetRow(view).Returns(row); grid.GetRowSpan(view).Returns(rowSpan); grid.GetColumn(view).Returns(col); grid.GetColumnSpan(view).Returns(colSpan); }
public GridStructure(IGridLayout grid, double widthConstraint, double heightConstraint) { _grid = grid; _gridWidthConstraint = widthConstraint; _gridHeightConstraint = heightConstraint; _rows = new Row[_grid.RowDefinitions.Count]; for (int n = 0; n < _grid.RowDefinitions.Count; n++) { _rows[n] = new Row(_grid.RowDefinitions[n]); } _columns = new Column[_grid.ColumnDefinitions.Count]; for (int n = 0; n < _grid.ColumnDefinitions.Count; n++) { _columns[n] = new Column(_grid.ColumnDefinitions[n]); } _children = _grid.Children.Where(child => child.Visibility != Visibility.Collapsed).ToArray(); // We'll ignore any collapsed child views during layout _cells = new Cell[_children.Length]; InitializeCells(); MeasureCells(); }
public GridStructure(IGridLayout grid, double widthConstraint, double heightConstraint) { _grid = grid; _gridWidthConstraint = widthConstraint; _gridHeightConstraint = heightConstraint; _rows = new Row[_grid.RowDefinitions.Count]; for (int n = 0; n < _grid.RowDefinitions.Count; n++) { _rows[n] = new Row(_grid.RowDefinitions[n]); } _columns = new Column[_grid.ColumnDefinitions.Count]; for (int n = 0; n < _grid.ColumnDefinitions.Count; n++) { _columns[n] = new Column(_grid.ColumnDefinitions[n]); } _cells = new Cell[_grid.Children.Count]; InitializeCells(); MeasureCells(); }
public override void PaintPreview(IGridLayout grid, BoundsInt position) { var zPosition = new Vector3Int(position.min.x, position.min.y, z); BoundsInt newPosition = new BoundsInt(zPosition, position.size); base.PaintPreview(grid, newPosition); }
private VGrid(VCell[] cells, IGridLayout columnHeader, IGridLayout rowHeader, IGridLayout body) { Cells = cells; ColumnHeader = columnHeader; RowHeader = rowHeader; Body = body; }
internal GridVector Measure(IGridLayout layout, GridMeasure available) { var measure = layout.Measure(available, this); Touch(layout.ElementKey).LastMeasure = measure; return(measure); }
public override void Paint(IGridLayout grid, GameObject[] layers, Vector3Int position) { if (lineStartActive) { Vector2Int startPos = new Vector2Int(lineStart.x, lineStart.y); Vector2Int endPos = new Vector2Int(position.x, position.y); if (startPos == endPos) { base.Paint(grid, layers, position); } else { foreach (var point in GetPointsOnLine(startPos, endPos)) { Vector3Int paintPos = new Vector3Int(point.x, point.y, position.z); base.Paint(grid, layers, paintPos); } } lineStartActive = false; } else { lineStart = position; lineStartActive = true; } }
public GridStructure(IGridLayout grid, double widthConstraint, double heightConstraint) { _grid = grid; _explicitGridHeight = _grid.Height; _explicitGridWidth = _grid.Width; _gridWidthConstraint = Dimension.IsExplicitSet(_explicitGridWidth) ? _explicitGridWidth : widthConstraint; _gridHeightConstraint = Dimension.IsExplicitSet(_explicitGridHeight) ? _explicitGridHeight : heightConstraint; _gridMaxHeight = _grid.MaximumHeight; _gridMinHeight = _grid.MinimumHeight; _gridMaxWidth = _grid.MaximumWidth; _gridMinWidth = _grid.MinimumWidth; // Cache these GridLayout properties so we don't have to keep looking them up via _grid // (Property access via _grid may have performance implications for some SDKs.) _padding = grid.Padding; _columnSpacing = grid.ColumnSpacing; _rowSpacing = grid.RowSpacing; _rowDefinitions = grid.RowDefinitions; _columnDefinitions = grid.ColumnDefinitions; // Determine whether "*" values make sense in each dimension, given our constraints bool treatStarRowsAsAuto = ShouldTreatStarsAsAuto(_gridHeightConstraint, _explicitGridHeight, _grid.VerticalLayoutAlignment); bool treatStarColumnsAsAuto = ShouldTreatStarsAsAuto(_gridWidthConstraint, _explicitGridWidth, _grid.HorizontalLayoutAlignment); _rows = InitializeRows(treatStarRowsAsAuto); _columns = InitializeColumns(treatStarColumnsAsAuto); // We could work out the _childrenToLayOut array (with the Collapsed items filtered out) with a Linq 1-liner // but doing it the hard way means we don't allocate extra enumerators, especially if we're in the // happy path where _none_ of the children are Collapsed. var gridChildCount = _grid.Count; _childrenToLayOut = new IView[gridChildCount]; int currentChild = 0; for (int n = 0; n < gridChildCount; n++) { if (_grid[n].Visibility != Visibility.Collapsed) { _childrenToLayOut[currentChild] = _grid[n]; currentChild += 1; } } if (currentChild < gridChildCount) { Array.Resize(ref _childrenToLayOut, currentChild); } // We'll ignore any collapsed child views during layout _cells = new Cell[_childrenToLayOut.Length]; InitializeCells(); MeasureCells(); }
Size MeasureAndArrange(IGridLayout grid, double widthConstraint = double.PositiveInfinity, double heightConstraint = double.PositiveInfinity) { var manager = new GridLayoutManager(grid); var measuredSize = manager.Measure(widthConstraint, heightConstraint); manager.ArrangeChildren(new Rectangle(Point.Zero, measuredSize)); return(measuredSize); }
public Size Measure(double widthConstraint, double heightConstraint) { // We have to rebuild this every time because the StackLayout contents // and values may have changed _gridLayout?.Clear(); _gridLayout = Gridify(_stackLayout); _manager = new GridLayoutManager(_gridLayout); return(_manager.Measure(widthConstraint, heightConstraint)); }
void SubColDefs(IGridLayout grid, IEnumerable <IGridColumnDefinition> cols = null) { if (cols == null) { var colDefs = CreateTestColumns("auto"); grid.ColumnDefinitions.Returns(colDefs); } else { grid.ColumnDefinitions.Returns(cols); } }
void SubColDefs(IGridLayout grid, IEnumerable <IGridColumnDefinition> cols = null) { if (cols == null) { var colDefs = new List <IGridColumnDefinition>(); grid.ColumnDefinitions.Returns(colDefs); } else { grid.ColumnDefinitions.Returns(cols); } }
void SubRowDefs(IGridLayout grid, IEnumerable <IGridRowDefinition> rows = null) { if (rows == null) { var rowDefs = new List <IGridRowDefinition>(); grid.RowDefinitions.Returns(rowDefs); } else { grid.RowDefinitions.Returns(rows); } }
private void SetupDockPanelLayout() { var xtraScrollableControl = new XtraScrollableControl(); xtraScrollableControl.Dock = DockStyle.Fill; var dockLayoutPanel = new DockLayoutPanel { Dock = DockStyle.Fill, AutoScroll = true }; _currentGridLayout = dockLayoutPanel; xtraScrollableControl.Controls.Add(dockLayoutPanel); xtraTabPageResultsGrid.Controls.Add(xtraScrollableControl); }
private void SetupWpfGridLayout() { var wpfGridLayout = new WPFGridLayoutPanel(); _currentGridLayout = wpfGridLayout; var elementHostWpfGridLayoutPanel = new ElementHost { Dock = DockStyle.Fill, Child = wpfGridLayout }; xtraTabPageResultsGrid.Controls.Add(elementHostWpfGridLayoutPanel); }
public override void OnPaintSceneGUI(IGridLayout grid, GameObject[] layers, BoundsInt position, GridBrushBase.Tool tool, bool executing) { base.OnPaintSceneGUI(grid, layers, position, tool, executing); if (lineBrush.lineStartActive) { foreach (GameObject go in layers) { Tilemap tilemap = go.GetComponent <Tilemap>(); if (tilemap != null) { tilemap.ClearAllEditorPreviewTiles(); } } // Draw preview tiles for tilemap Vector2Int startPos = new Vector2Int(lineBrush.lineStart.x, lineBrush.lineStart.y); Vector2Int endPos = new Vector2Int(position.x, position.y); if (startPos == endPos) { brush.PaintPreview(grid, layers, position); } else { foreach (var point in LineBrush.GetPointsOnLine(startPos, endPos)) { Vector3Int paintPos = new Vector3Int(point.x, point.y, position.z); BoundsInt previewPos = new BoundsInt(paintPos, position.size); brush.PaintPreview(grid, layers, previewPos); } } if (Event.current.type == EventType.Repaint) { var min = lineBrush.lineStart; var max = lineBrush.lineStart + position.size; // Draws a box on the picked starting position GL.PushMatrix(); GL.MultMatrix(GUI.matrix); GL.Begin(GL.LINES); Handles.color = Color.blue; Handles.DrawLine(new Vector3(min.x, min.y, min.z), new Vector3(max.x, min.y, min.z)); Handles.DrawLine(new Vector3(max.x, min.y, min.z), new Vector3(max.x, max.y, min.z)); Handles.DrawLine(new Vector3(max.x, max.y, min.z), new Vector3(min.x, max.y, min.z)); Handles.DrawLine(new Vector3(min.x, max.y, min.z), new Vector3(min.x, min.y, min.z)); GL.End(); GL.PopMatrix(); } } }
public static void Layout(IContainer container, IUFControl ctrl, uint x, uint y, int xspan, int yspan, Unit width, Unit height, bool isAutoSize) { IGridLayout gl = container.Layout as IGridLayout; if (gl == null) { return; } GridLayoutInfo glInfo = new GridLayoutInfo((uint)x, (uint)y, (uint)xspan, (uint)yspan, width, height); glInfo.AutoSize = isAutoSize; gl.Controls.Add((Control)ctrl, glInfo); }
public GridStructure(IGridLayout grid, double widthConstraint, double heightConstraint) { _grid = grid; _gridWidthConstraint = widthConstraint; _gridHeightConstraint = heightConstraint; if (_grid.RowDefinitions.Count == 0) { // Since no rows are specified, we'll create an implied row 0 _rows = new Row[1]; _rows[0] = new Row(new ImpliedRow()); } else { _rows = new Row[_grid.RowDefinitions.Count]; for (int n = 0; n < _grid.RowDefinitions.Count; n++) { _rows[n] = new Row(_grid.RowDefinitions[n]); } } if (_grid.ColumnDefinitions.Count == 0) { // Since no columns are specified, we'll create an implied column 0 _columns = new Column[1]; _columns[0] = new Column(new ImpliedColumn()); } else { _columns = new Column[_grid.ColumnDefinitions.Count]; for (int n = 0; n < _grid.ColumnDefinitions.Count; n++) { _columns[n] = new Column(_grid.ColumnDefinitions[n]); } } _children = _grid.Children.Where(child => child.Visibility != Visibility.Collapsed).ToArray(); // We'll ignore any collapsed child views during layout _cells = new Cell[_children.Length]; InitializeCells(); MeasureCells(); }
void SubRowDefs(IGridLayout grid, IEnumerable <IGridRowDefinition> rows = null) { if (rows == null) { var rowDef = Substitute.For <IGridRowDefinition>(); rowDef.Height.Returns(GridLength.Auto); var rowDefs = new List <IGridRowDefinition> { rowDef }; grid.RowDefinitions.Returns(rowDefs); } else { grid.RowDefinitions.Returns(rows); } }
public override void OnPaintSceneGUI(IGridLayout grid, BoundsInt position, Tool tool, bool executing) { base.OnPaintSceneGUI(grid, position, tool, executing); if (z != 0) { var zPosition = new Vector3Int(position.min.x, position.min.y, z); BoundsInt newPosition = new BoundsInt(zPosition, position.size); Vector3[] cellLocals = new Vector3[] { grid.CellToLocal(new Vector3Int(newPosition.min.x, newPosition.min.y, newPosition.min.z)), grid.CellToLocal(new Vector3Int(newPosition.max.x, newPosition.min.y, newPosition.min.z)), grid.CellToLocal(new Vector3Int(newPosition.max.x, newPosition.max.y, newPosition.min.z)), grid.CellToLocal(new Vector3Int(newPosition.min.x, newPosition.max.y, newPosition.min.z)) }; Handles.color = z > 0 ? Color.blue : Color.red; int i = 0; for (int j = cellLocals.Length - 1; i < cellLocals.Length; j = i++) { Handles.DrawLine(cellLocals[j], cellLocals[i]); } } Handles.Label(grid.CellToWorld(new Vector3Int(position.x, position.y, z)), new Vector3Int(position.x, position.y, z).ToString()); }
public GridStructure(IGridLayout grid, double widthConstraint, double heightConstraint) { _grid = grid; _gridWidthConstraint = widthConstraint; _gridHeightConstraint = heightConstraint; _explicitGridHeight = _grid.Height; _explicitGridWidth = _grid.Width; _gridMaxHeight = _grid.MaximumHeight; _gridMinHeight = _grid.MinimumHeight; _gridMaxWidth = _grid.MaximumWidth; _gridMinWidth = _grid.MinimumWidth; // Cache these GridLayout properties so we don't have to keep looking them up via _grid // (Property access via _grid may have performance implications for some SDKs.) _padding = grid.Padding; _columnSpacing = grid.ColumnSpacing; _rowSpacing = grid.RowSpacing; _rowDefinitions = grid.RowDefinitions; _columnDefinitions = grid.ColumnDefinitions; if (_rowDefinitions.Count == 0) { // Since no rows are specified, we'll create an implied row 0 _rows = new Row[1]; _rows[0] = new Row(new ImpliedRow()); } else { _rows = new Row[_rowDefinitions.Count]; for (int n = 0; n < _rowDefinitions.Count; n++) { _rows[n] = new Row(_rowDefinitions[n]); } } if (_columnDefinitions.Count == 0) { // Since no columns are specified, we'll create an implied column 0 _columns = new Column[1]; _columns[0] = new Column(new ImpliedColumn()); } else { _columns = new Column[_columnDefinitions.Count]; for (int n = 0; n < _columnDefinitions.Count; n++) { _columns[n] = new Column(_columnDefinitions[n]); } } // We could work out the _childrenToLayOut array (with the Collapsed items filtered out) with a Linq 1-liner // but doing it the hard way means we don't allocate extra enumerators, especially if we're in the // happy path where _none_ of the children are Collapsed. var gridChildCount = _grid.Count; _childrenToLayOut = new IView[gridChildCount]; int currentChild = 0; for (int n = 0; n < gridChildCount; n++) { if (_grid[n].Visibility != Visibility.Collapsed) { _childrenToLayOut[currentChild] = _grid[n]; currentChild += 1; } } if (currentChild < gridChildCount) { Array.Resize(ref _childrenToLayOut, currentChild); } // We'll ignore any collapsed child views during layout _cells = new Cell[_childrenToLayOut.Length]; InitializeCells(); MeasureCells(); }
public VGrid WithColumnHeader(IGridLayout columnHeader) { return(new VGrid(Cells, columnHeader, RowHeader, Body)); }
public VGrid WithRowHeader(IGridLayout rowHeader) { return(new VGrid(Cells, ColumnHeader, rowHeader, Body)); }
internal void Arrange(IGridLayout layout, GridRange range) { layout.Arrange(range, this); Touch(layout.ElementKey).LastArrange = range; }
public GridLayoutElement Patch(IGridLayout layout) { return(_root); }
public VerticalLinkGridLayout(IGridLayout first, IGridLayout second) { First = first; Second = second; }
public HorizontalLinkGridLayout(IGridLayout first, IGridLayout second) { First = first; Second = second; }
public override void FloodFill(IGridLayout grid, Vector3Int position) { var zPosition = new Vector3Int(position.x, position.y, z); base.FloodFill(grid, zPosition); }
public GridLayoutManager(IGridLayout layout) : base(layout) { Grid = layout; }
public override void Paint(IGridLayout grid, Vector3Int position) { var zPosition = new Vector3Int(position.x, position.y, z); base.Paint(grid, zPosition); }