From b6d5023b18f9f8e02fcaba5fee1ce8d1cbf3f442 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Tue, 2 Jun 2026 14:00:09 +0200 Subject: [PATCH] paint: ui fixes --- paint/sources/tab_layers.c | 17 +++++++++-------- paint/sources/tab_timeline.c | 15 ++++++++++++--- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/paint/sources/tab_layers.c b/paint/sources/tab_layers.c index 6eb7a122..7e4cdb16 100644 --- a/paint/sources/tab_layers.c +++ b/paint/sources/tab_layers.c @@ -373,7 +373,7 @@ void tab_layers_draw_layer_slot_full(slot_layer_t *l, i32 i) { if (parent_hidden) { col -= 0x99000000; } - if (ui_sub_image(icons, col, -1.0, r->x, r->y, r->w, r->h) == UI_STATE_RELEASED) { + if (ui_sub_image(icons, col, r->h, r->x, r->y, r->w, r->h) == UI_STATE_RELEASED) { tab_layers_layer_toggle_visible(l); } @@ -387,19 +387,20 @@ void tab_layers_draw_layer_slot_full(slot_layer_t *l, i32 i) { } // Layer icon + i32 icon_h = (UI_ELEMENT_H() - 3) * 2; ui->_x = uix + uiw * 0.08 + offx; ui->_y = uiy + 3; - ui->_w = uiw * 0.16; + ui->_w = math_max(uiw * 0.16, icon_h); ui_state_t state = tab_layers_draw_layer_icon(l, i, uix, uiy, false); tab_layers_handle_layer_icon_state(l, i, state, uix, uiy); // Draw layer name - ui->_x = uix + uiw * 0.25 + 2 * UI_SCALE() + offx; - ui->_y = uiy + center; - ui->_w = uiw * 0.36; - if (g_config->touch_ui) { - ui->_x += 12 * UI_SCALE(); - } + bool has_blending = !slot_layer_is_group(l) && !slot_layer_is_mask(l) && !slot_layer_is_filter(l); + f32 name_x = math_max(uix + uiw * 0.25 + offx, uix + uiw * 0.08 + offx + icon_h + 4 * UI_SCALE()); + f32 name_right = has_blending ? uix + uiw * 0.60 : (has_children ? uix + uiw * 0.90 : uix + uiw); // Blending combo / panel / window edge + ui->_x = name_x; + ui->_y = uiy + center; + ui->_w = name_right - name_x; if (tab_layers_layer_name_edit == l->id) { tab_layers_layer_name_handle->text = string_copy(l->name); l->name = string_copy(ui_text_input(tab_layers_layer_name_handle, "", UI_ALIGN_LEFT, true, false)); diff --git a/paint/sources/tab_timeline.c b/paint/sources/tab_timeline.c index 486378cf..1791e2f5 100644 --- a/paint/sources/tab_timeline.c +++ b/paint/sources/tab_timeline.c @@ -753,7 +753,10 @@ void tab_timeline_draw(ui_handle_t *htab) { draw_set_color(ui->ops->theme->LABEL_COL); i32 label_start = (tab_timeline_scroll / 5) * 5; for (i32 i = label_start; i < tab_timeline_scroll + visible + 1 && i < tab_timeline_max_frames; i += 5) { - f32 lx = start_x + (i - tab_timeline_scroll) * frame_w; + f32 lx = start_x + (i - tab_timeline_scroll) * frame_w; + if (lx < start_x) { + continue; + } char *label = i32_to_string(i); f32 label_w = draw_string_width(ui->ops->font, ui->font_size, label); draw_string(label, lx + (frame_w - label_w) / 2.0f, start_y); @@ -779,7 +782,10 @@ void tab_timeline_draw(ui_handle_t *htab) { draw_string(layer->name, ui->_x + icon_size + 2, row_y + (strip_h - font_h) / 2.0f); for (i32 i = tab_timeline_scroll; i < tab_timeline_scroll + visible + 1 && i < tab_timeline_max_frames; i++) { - f32 x = start_x + (i - tab_timeline_scroll) * frame_w; + f32 x = start_x + (i - tab_timeline_scroll) * frame_w; + if (x < start_x) { + continue; + } bool selected = i == tab_timeline_selected_frame && ri == tab_timeline_selected_row; u32 col = selected ? sel_col : (i % 5 == 0) ? bright_col : base_col; @@ -820,7 +826,10 @@ void tab_timeline_draw(ui_handle_t *htab) { draw_string(mesh->base->name, ui->_x + icon_size + 2, row_y + (strip_h - font_h) / 2.0f); for (i32 i = tab_timeline_scroll; i < tab_timeline_scroll + visible + 1 && i < tab_timeline_max_frames; i++) { - f32 x = start_x + (i - tab_timeline_scroll) * frame_w; + f32 x = start_x + (i - tab_timeline_scroll) * frame_w; + if (x < start_x) { + continue; + } bool selected = i == tab_timeline_selected_frame && ri == tab_timeline_selected_row; u32 col = selected ? sel_col : (i % 5 == 0) ? bright_col : base_col;