# 4. Arrange the controls

Source: https://daybrite.dev/docs/tutorials/layout

Add a reset button and a horizontal button row to the app from [lesson 3](https://daybrite.dev/docs/tutorials/state).

## 1. Add the layout messages

Append to `resource/locales/en/app.ftl`:

**All platforms: Append to `resource/locales/en/app.ftl`**

```ftl
reset_count = Reset
session_hint = Add one after each session. Reset when you start a new day.
```

## 2. Compose the layout

Replace `src/lib.rs`:

**All platforms: Write `src/lib.rs`**

```rust
use day::prelude::*;

day::resources!();
day::day_start!(options: res::window_options(), root);

pub fn root() -> impl Piece {
    let count = Signal::new(0i64);

    column((
        label(res::str::welcome()),
        label(res::str::counter_value(count)).id(id!(counter_label)),
        row((
            button(res::str::add_one())
                .action(move || count.update(|n| *n = n.saturating_add(1)))
                .id(id!(increment_button)),
            button(res::str::reset_count())
                .action(move || count.set(0))
                .id(id!(reset_button)),
        ))
        .spacing(Space::M),
        label(res::str::session_hint()),
    ))
    .spacing(Space::M)
    .padding(Space::L)
    .grow(Dimension::Both)
}
```

[`row`](https://docs.rs/day-pieces/latest/day_pieces/fn.row.html) arranges children horizontally;
[`column`](https://docs.rs/day-pieces/latest/day_pieces/fn.column.html) arranges them vertically.
Both accept tuples of Pieces. [`.spacing`](https://docs.rs/day-pieces/latest/day_pieces/trait.ColumnBuilder.html#tymethod.spacing)
separates siblings; [`.padding`](https://docs.rs/day-pieces/latest/day_pieces/trait.Decorate.html#method.padding)
adds space around content. [`.grow(Dimension::Both)`](https://docs.rs/day-pieces/latest/day_pieces/trait.Decorate.html#method.grow)
uses available width and height. Labels wrap by default. `Space::M` and `Space::L` are spacing tokens.

[`set(0)`](https://docs.rs/day-reactive/latest/day_reactive/struct.Signal.html#method.set) resets
the shared count.

## 3. Resize and reset

**macOS: Run in `first-app`**

```sh
day launch -t macos-appkit
```

**Windows: Run in `first-app`**

```powershell
day launch -t windows-winui
```

**Linux: Run in `first-app`**

```sh
day launch -t linux-gtk
```

**macOS:** Quit with Command-Q before continuing.

**Windows:** Close the app window before continuing.

**Linux:** Close the app window before continuing.

Press **Add one** twice, then **Reset**; expect **Count: 0**. Check initial and minimum window
sizes: buttons remain in one row, and the hint wraps as needed. Quit before editing.

## Troubleshooting

If buttons stack, place them in [`row((...))`](https://docs.rs/day-pieces/latest/day_pieces/fn.row.html).
If the hint is clipped, check available space and manifest minimum dimensions. Test longer
translations at minimum size.

## Next step

Continue to [5. Navigate between pages](https://daybrite.dev/docs/tutorials/navigation).
