Grid Layout

grid-layout demonstrates how FrameBorder and GridLayout work together. You can change each border element independently and resize the logical grid while the layout keeps every content cell aligned.

Use This Demo When You Need…

  • A compact example for drawing table-like grids into a Buffer.

  • A visual check for mixed light, dashed, heavy, double, rounded, and None border elements.

  • A reference for using GridLayout::cellRect() to place content inside grid cells.

Run the Demo

Start the demo from the build directory:

$ ./cmake-build-debug/demo-apps/grid-layout

Use keys 1 through 6 to cycle the top, bottom, left, right, horizontal separator, and vertical separator elements through the supported grid line styles. Use C to cycle between one and five columns, R to cycle between one and three rows, and Q to quit.

Captured Output (80x25)

FrameBorder + GridLayout | 3 columns x 2 rows

  ┌────────────────────────┬────────────────────────┬────────────────────────┐
                                                                                                                                                                                                                                         R1 C1                   R1 C2                   R1 C3                                                                                                                                                                                                                                          ├────────────────────────┼────────────────────────┼────────────────────────┤
                                                                                                                                                               R2 C1                   R2 C2                   R2 C3                                                                                                                                                                                                                                          └────────────────────────┴────────────────────────┴────────────────────────┘

  [1] Top:Light [2] Bottom:Light
  [3] Left:Light [4] Right:Light
  [5] HLine:Light [6] VLine:Light

[1-6] cycle border styles [C] columns [R] rows [Q] quit

Features Demonstrated

  • Uniform FrameBorder setup with bright white grid lines.

  • Per-element border style changes without rebuilding the layout code.

  • Responsive GridLayout creation from the available terminal area.

  • Cell content placement with GridLayout::cellRect().

Relevant Source Files

If you want to explore the implementation, start with demo/grid-layout/src/GridLayoutApp.cpp.

This file contains the border state, grid sizing logic, and the render loop that draws the cells and grid lines.