# Layouts

Understanding DWN's window layout system

## Overview

DWN provides six layout modes that determine how windows are arranged on screen. Each workspace maintains its own layout settings independently.

Press `Super+Space` to cycle through layouts: Tiling → Floating → Monocle → Centered Master → Columns → Fibonacci → Tiling

Tip: The current layout is shown in the panel with a symbol: `[]=` for tiling, `><>` for floating, `[M]` for monocle.

## Tiling Layout

The default layout. Windows automatically arrange themselves in a master-stack pattern.

### How It Works

    +------------------+----------+
    |                  |  Window  |
    |     Master       |    2     |
    |     Window       +----------+
    |       1          |  Window  |
    |                  |    3     |
    +------------------+----------+

- The master area (left) contains the primary window(s)
- The stack area (right) contains secondary windows
- Windows are automatically sized to fill the screen
- No manual positioning required

### Master Ratio

Controls the width of the master area relative to the screen.

- `Super+H` - Decrease master ratio (shrink master area)
- `Super+L` - Increase master ratio (expand master area)
- Range: 10% to 90%
- Default: 55%

### Master Count

Controls how many windows occupy the master area.

- `Super+I` - Increase master count
- `Super+D` - Decrease master count
- Range: 1 to 10
- Default: 1

With master count of 2:

    +--------+---------+----------+
    | Master | Master  |  Stack   |
    |   1    |    2    |    3     |
    |        |         +----------+
    |        |         |  Stack   |
    |        |         |    4     |
    +--------+---------+----------+

### Floating Windows in Tiling

Press `Super+F9` to toggle floating mode for a window. Floating windows:

- Are exempt from automatic tiling
- Can be freely moved and resized
- Float above tiled windows
- Useful for dialogs, small utilities, reference windows

## Floating Layout

Traditional overlapping window management like most desktop environments.

### Characteristics

- Windows maintain their own position and size
- No automatic arrangement
- Drag title bars to move windows
- Drag window edges to resize
- Click to raise windows

### Window Controls

In floating mode, windows have full manual control:

- Move: Drag the title bar
- Resize: Drag the window border
- Maximize: `Alt+F10` or click maximize button
- Minimize: `Alt+F9` or click minimize button

## Monocle Layout

Each window takes the full screen. Only one window visible at a time.

### Use Cases

- Focused work on a single application
- Small screens or high window count
- Reading or writing documents
- Video or media playback

### Navigation

- `Alt+Tab` - Switch to next window
- `Alt+Shift+Tab` - Switch to previous window
- Taskbar click - Switch to specific window

Note: Windows maintain decorations in monocle mode unless fullscreen (`Alt+F11`).

## Centered Master Layout

The master window is centered on screen with stack windows divided on left and right sides.

### How It Works

    +--------+------------------+--------+
    | Stack  |     Master       | Stack  |
    |   1    |     Window       |   3    |
    +--------+                  +--------+
    | Stack  |                  | Stack  |
    |   2    |                  |   4    |
    +--------+------------------+--------+

- The master window occupies the center of the screen
- Stack windows are divided between left and right sides
- Odd-numbered stack windows go left, even go right
- Excellent for wide monitors and ultrawide displays

### Use Cases

- Keeping primary work centered while referencing side content
- Video editing with timeline and tools on sides
- Development with editor centered and documentation on sides

## Columns Layout

All windows arranged in equal-width vertical columns spanning the full height.

### How It Works

    +----------+----------+----------+----------+
    |          |          |          |          |
    | Window   | Window   | Window   | Window   |
    |    1     |    2     |    3     |    4     |
    |          |          |          |          |
    |          |          |          |          |
    +----------+----------+----------+----------+

- Each window gets an equal-width column
- Windows span the full usable height
- Simple and predictable arrangement

### Use Cases

- Comparing multiple files side-by-side
- Monitoring multiple log files
- Multi-column text editing
- Concurrent terminal sessions

## Fibonacci Layout

Windows arranged in a spiral pattern using recursive splitting, inspired by the Fibonacci sequence.

### How It Works

    +------------------+----------+
    |                  |          |
    |     Window 1     | Window 2 |
    |                  +----+-----+
    |                  | W3 |     |
    +------------------+----+ W4  |
    |      Window 5         |     |
    +-----------------------+-----+

- First window takes half the screen
- Each subsequent window takes half the remaining space
- Alternates between horizontal and vertical splits
- Creates a visually interesting spiral pattern

### Use Cases

- Hierarchical window importance (larger = more important)
- Primary workspace with progressively smaller utilities
- Creative workflows with main canvas and tool windows

## Grid Layout

Windows are arranged in a grid pattern with automatic row/column calculation.

### How It Works

    +----------+----------+----------+
    |  Window  |  Window  |  Window  |
    |    1     |    2     |    3     |
    +----------+----------+----------+
    |  Window  |  Window  |
    |    4     |    5     |
    +----------+----------+

- Automatically calculates optimal rows and columns
- Uses square root for balanced grid
- All windows have equal size
- Great for viewing multiple documents simultaneously

### Use Cases

- Comparing multiple documents or files
- Monitoring multiple terminals
- Dashboard-style workflows
- Multi-way video calls

## Plugin System (v2.0)

DWN v2.0 introduces a layout plugin system that allows custom layout algorithms to be loaded dynamically or built-in.

### Built-in Layouts

- tiling - Master-stack tiling (default)
- floating - Traditional floating windows
- monocle - Single maximized window
- centered-master - Master centered with stacks on sides
- columns - Equal-width vertical columns
- fibonacci - Spiral recursive splitting
- grid - Grid arrangement

### Custom Layouts

Developers can create custom layout plugins using the Layout Plugin API. See Plugin Development for details.

Plugin API: Layouts implement the `LayoutPluginInterface` vtable with an `arrange()` method that calculates window geometries.

## Per-Workspace Settings

Each workspace maintains independent layout settings:

Setting | Scope | Description
--- | --- | ---
Layout Mode | Per-workspace | Tiling, floating, monocle, centered-master, columns, or fibonacci
Master Ratio | Per-workspace | Width of master area
Master Count | Per-workspace | Windows in master area
Window Floating State | Per-window | Individual floating toggle

Example workflow:

- Workspace 1: Tiling layout for coding (editor + terminal)
- Workspace 2: Floating layout for design work
- Workspace 3: Monocle layout for focused writing
- Workspace 4: Centered-master for wide monitor development
- Workspace 5: Columns layout for log monitoring
- Workspace 6: Fibonacci for hierarchical work

## Layout Shortcuts

Shortcut | Action
--- | ---
`Super+Space` | Cycle layout mode
`Super+H` | Shrink master area
`Super+L` | Expand master area
`Super+I` | Increase master count
`Super+D` | Decrease master count
`Super+F9` | Toggle window floating
`Alt+F10` | Toggle maximize
`Alt+F11` | Toggle fullscreen

## Configuration

Set default layout behavior in `~/.config/dwn/config`:

    [layout]
    # Default layout for new workspaces
    # Options: tiling, floating, monocle, centered-master, columns, fibonacci
    default = tiling
    master_ratio = 0.55      # Default master area ratio (0.1-0.9)
    master_count = 1         # Default master window count (1-10)

    [appearance]
    gap = 5                  # Gap between tiled windows (0-100)