From 01ed4734712432d9ed549ddcb30f0b2fbe697270 Mon Sep 17 00:00:00 2001 From: Daniel Hammer Date: Tue, 19 May 2026 17:49:39 +0200 Subject: [PATCH] feat: improve Paint app UI --- programs/src/paint/main.cpp | 7 +++++-- programs/src/paint/paint.h | 4 ++-- programs/src/paint/render.cpp | 7 +++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/programs/src/paint/main.cpp b/programs/src/paint/main.cpp index d5a3ddf..40da627 100644 --- a/programs/src/paint/main.cpp +++ b/programs/src/paint/main.cpp @@ -170,13 +170,16 @@ static bool handle_colorbar_click(int mx, int my, bool right_click) { int preview_sz = COLOR_BAR_H - 8; int sw_x = 4 + preview_sz + 16; + int sw_h = SWATCH_SIZE / 2; + int rows_total_h = 2 * sw_h + 1; + int swatch_top = cbar_y + (COLOR_BAR_H - rows_total_h) / 2; for (int i = 0; i < PALETTE_COUNT; i++) { int row = i >= 14 ? 1 : 0; int col = i >= 14 ? i - 14 : i; int sx = sw_x + col * (SWATCH_SIZE + 2); - int sy = cbar_y + 2 + row * (SWATCH_SIZE / 2 + 1); - int sh = SWATCH_SIZE / 2; + int sy = swatch_top + row * (sw_h + 1); + int sh = sw_h; if (mx >= sx && mx < sx + SWATCH_SIZE && my >= sy && my < sy + sh) { if (right_click) diff --git a/programs/src/paint/paint.h b/programs/src/paint/paint.h index e2a5207..b0d2b54 100644 --- a/programs/src/paint/paint.h +++ b/programs/src/paint/paint.h @@ -31,9 +31,9 @@ static constexpr int TB_BTN_SIZE = 24; static constexpr int TB_BTN_Y = 6; static constexpr int TB_BTN_RAD = 3; static constexpr int STATUS_BAR_H = 24; -static constexpr int COLOR_BAR_H = 36; +static constexpr int COLOR_BAR_H = 42; -static constexpr int SWATCH_SIZE = 20; +static constexpr int SWATCH_SIZE = 24; static constexpr int SWATCH_PAD = 4; static constexpr int SWATCH_Y = 8; diff --git a/programs/src/paint/render.cpp b/programs/src/paint/render.cpp index 6cbb01b..ae09363 100644 --- a/programs/src/paint/render.cpp +++ b/programs/src/paint/render.cpp @@ -76,12 +76,15 @@ void render(uint32_t* pixels) { // Palette swatches int sw_x = preview_x + preview_sz + 16; + int sw_h = SWATCH_SIZE / 2; + int rows_total_h = 2 * sw_h + 1; + int swatch_top = cbar_y + (COLOR_BAR_H - rows_total_h) / 2; for (int i = 0; i < PALETTE_COUNT; i++) { int row = i >= 14 ? 1 : 0; int col = i >= 14 ? i - 14 : i; int sx = sw_x + col * (SWATCH_SIZE + 2); - int sy = cbar_y + 2 + row * (SWATCH_SIZE / 2 + 1); - int sh = SWATCH_SIZE / 2; + int sy = swatch_top + row * (sw_h + 1); + int sh = sw_h; px_fill(pixels, g_win_w, g_win_h, sx, sy, SWATCH_SIZE, sh, PALETTE[i]);