Better bigclock positioning

Signed-off-by: AnErrupTion <anerruption@disroot.org>
This commit is contained in:
AnErrupTion
2026-02-08 21:36:18 +01:00
parent 769aefd6e9
commit e9e2d51261

View File

@@ -1434,10 +1434,15 @@ fn positionComponents(state: *UiState) void {
state.box.positionXY(TerminalBuffer.START_POSITION);
if (state.config.bigclock != .none) {
state.bigclock_label.positionXY(Position.init(
state.buffer.width / 2 - @min(state.buffer.width, (state.bigclock_label.text.len * (bigLabel.CHAR_WIDTH + 1))) / 2,
(state.buffer.height - state.box.height) / 2 - bigLabel.CHAR_HEIGHT - 2,
).add(TerminalBuffer.START_POSITION));
const half_width = state.buffer.width / 2;
const half_label_width = (state.bigclock_label.text.len * (bigLabel.CHAR_WIDTH + 1)) / 2;
const half_height = (if (state.buffer.height > state.box.height) state.buffer.height - state.box.height else state.buffer.height) / 2;
state.bigclock_label.positionXY(TerminalBuffer.START_POSITION
.addX(half_width)
.removeXIf(half_label_width, half_width > half_label_width)
.addY(half_height)
.removeYIf(bigLabel.CHAR_HEIGHT + 2, half_height > bigLabel.CHAR_HEIGHT + 2));
}
state.info_line.label.positionY(state.box