feat: improve Paint app UI

This commit is contained in:
2026-05-19 17:49:39 +02:00
parent c6ca17984b
commit 01ed473471
3 changed files with 12 additions and 6 deletions
+5 -2
View File
@@ -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)
+2 -2
View File
@@ -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;
+5 -2
View File
@@ -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]);