A classic
And for those who don't hate curly braces, but do want more vertical density:
void MainReportsUiState::onMouseDown(EventHandler::MouseButton button, int x, int y) {
if (button == EventHandler::BUTTON_LEFT) {
for (Panel& panel : Panels) {
panel.Selected = isPointInRect(MOUSE_COORDS, panel.Rect);
}
}
}
The curly braces do help guard against common mistakes, such as revisiting code a long time later to add or remove a line, and thus breaking a loop or if statement because they only apply to the next statement. And also, indentation might lie, but curly braces don't.