paint: touch ui fixes

This commit is contained in:
luboslenco
2026-06-14 11:55:40 +02:00
parent b890099dc7
commit 82b19904b6
2 changed files with 86 additions and 63 deletions
+47 -35
View File
@@ -567,6 +567,7 @@ void ui_nodes_draw_menubar() {
g_ui->_x = 0; g_ui->_x = 0;
g_ui->_y = 2 + start_y; g_ui->_y = 2 + start_y;
// Back button
if (g_config->touch_ui && !base_view3d_show && !ui_view2d_show) { if (g_config->touch_ui && !base_view3d_show && !ui_view2d_show) {
g_ui->_w = math_floor(ew + 3); g_ui->_w = math_floor(ew + 3);
if (ui_icon_button("Back", ICON_ARROW_LEFT, UI_ALIGN_CENTER)) { if (ui_icon_button("Back", ICON_ARROW_LEFT, UI_ALIGN_CENTER)) {
@@ -579,51 +580,62 @@ void ui_nodes_draw_menubar() {
g_ui->_y = 2 + start_y; g_ui->_y = 2 + start_y;
} }
bool full = true;
#ifdef IRON_IOS
if (config_is_iphone()) {
full = false;
}
#endif
// Editable canvas name // Editable canvas name
g_ui->_w = ew; if (full) {
ui_handle_t *h = ui_handle(__ID__); g_ui->_w = ew;
h->text = string_copy(c->name); ui_handle_t *h = ui_handle(__ID__);
g_ui->_w = math_floor(math_min(draw_string_width(g_font, g_ui->font_size, h->text) + 15 * UI_SCALE(), 100 * UI_SCALE())); h->text = string_copy(c->name);
char *new_name = ui_text_input(h, "", UI_ALIGN_LEFT, true, false); g_ui->_w = math_floor(math_min(draw_string_width(g_font, g_ui->font_size, h->text) + 15 * UI_SCALE(), 100 * UI_SCALE()));
g_ui->_x += g_ui->_w + 3; char *new_name = ui_text_input(h, "", UI_ALIGN_LEFT, true, false);
g_ui->_y = 2 + start_y; g_ui->_x += g_ui->_w + 3;
g_ui->_w = ew; g_ui->_y = 2 + start_y;
if (h->changed) { // Check whether renaming is possible and update group links g_ui->_w = ew;
if (ui_nodes_group_stack->length > 0) { if (h->changed) { // Check whether renaming is possible and update group links
bool can_rename = true; if (ui_nodes_group_stack->length > 0) {
for (i32 i = 0; i < g_project->_->material_groups->length; ++i) { bool can_rename = true;
node_group_t *m = g_project->_->material_groups->buffer[i];
if (string_equals(m->canvas->name, new_name)) {
can_rename = false; // Name already used
}
}
if (can_rename) {
char *old_name = c->name;
c->name = string_copy(new_name);
ui_node_canvas_t_array_t *canvases = any_array_create_from_raw((void *[]){}, 0);
for (i32 i = 0; i < g_project->_->materials->length; ++i) {
slot_material_t *m = g_project->_->materials->buffer[i];
any_array_push(canvases, m->canvas);
}
for (i32 i = 0; i < g_project->_->material_groups->length; ++i) { for (i32 i = 0; i < g_project->_->material_groups->length; ++i) {
node_group_t *m = g_project->_->material_groups->buffer[i]; node_group_t *m = g_project->_->material_groups->buffer[i];
any_array_push(canvases, m->canvas); if (string_equals(m->canvas->name, new_name)) {
can_rename = false; // Name already used
}
} }
for (i32 i = 0; i < canvases->length; ++i) { if (can_rename) {
ui_node_canvas_t *canvas = canvases->buffer[i]; char *old_name = c->name;
for (i32 i = 0; i < canvas->nodes->length; ++i) { c->name = string_copy(new_name);
ui_node_t *n = canvas->nodes->buffer[i]; ui_node_canvas_t_array_t *canvases = any_array_create_from_raw((void *[]){}, 0);
if (string_equals(n->type, "GROUP") && string_equals(n->name, old_name)) { for (i32 i = 0; i < g_project->_->materials->length; ++i) {
n->name = string_copy(c->name); slot_material_t *m = g_project->_->materials->buffer[i];
any_array_push(canvases, m->canvas);
}
for (i32 i = 0; i < g_project->_->material_groups->length; ++i) {
node_group_t *m = g_project->_->material_groups->buffer[i];
any_array_push(canvases, m->canvas);
}
for (i32 i = 0; i < canvases->length; ++i) {
ui_node_canvas_t *canvas = canvases->buffer[i];
for (i32 i = 0; i < canvas->nodes->length; ++i) {
ui_node_t *n = canvas->nodes->buffer[i];
if (string_equals(n->type, "GROUP") && string_equals(n->name, old_name)) {
n->name = string_copy(c->name);
}
} }
} }
} }
} }
} else {
else { c->name = string_copy(new_name);
c->name = string_copy(new_name); }
} }
} }
// Category buttons
i32 _BUTTON_COL = g_theme->BUTTON_COL; i32 _BUTTON_COL = g_theme->BUTTON_COL;
bool _SHADOWS = g_theme->SHADOWS; bool _SHADOWS = g_theme->SHADOWS;
g_theme->BUTTON_COL = g_theme->WINDOW_BG_COL; g_theme->BUTTON_COL = g_theme->WINDOW_BG_COL;
+39 -28
View File
@@ -532,6 +532,7 @@ void ui_view2d_update(void *_) {
g_ui->_x = 2; g_ui->_x = 2;
g_ui->_y = 2 + start_y; g_ui->_y = 2 + start_y;
// Back button
if (g_config->touch_ui && !base_view3d_show) { if (g_config->touch_ui && !base_view3d_show) {
g_ui->_w = math_floor(ew * 0.7 + 3); g_ui->_w = math_floor(ew * 0.7 + 3);
if (ui_icon_button(tr("Back"), ICON_ARROW_LEFT, UI_ALIGN_CENTER)) { if (ui_icon_button(tr("Back"), ICON_ARROW_LEFT, UI_ALIGN_CENTER)) {
@@ -544,40 +545,50 @@ void ui_view2d_update(void *_) {
g_ui->_y = 2 + start_y; g_ui->_y = 2 + start_y;
} }
bool full = true;
#ifdef IRON_IOS
if (config_is_iphone()) {
full = false;
}
#endif
// Editable layer name // Editable layer name
g_ui->_w = ew; if (full) {
ui_handle_t *h = ui_handle(__ID__); g_ui->_w = ew;
char *text = ui_view2d_type == VIEW_2D_TYPE_NODE ? g_context->node_preview_name : h->text; ui_handle_t *h = ui_handle(__ID__);
char *text = ui_view2d_type == VIEW_2D_TYPE_NODE ? g_context->node_preview_name : h->text;
g_ui->_w = math_floor(math_min(draw_string_width(g_font, g_ui->font_size, text) + 15 * UI_SCALE(), 100 * UI_SCALE())); g_ui->_w = math_floor(math_min(draw_string_width(g_font, g_ui->font_size, text) + 15 * UI_SCALE(), 100 * UI_SCALE()));
if (ui_view2d_type == VIEW_2D_TYPE_ASSET) { if (ui_view2d_type == VIEW_2D_TYPE_ASSET) {
asset_t *asset = g_context->texture; asset_t *asset = g_context->texture;
if (asset != NULL) { if (asset != NULL) {
h->text = string_copy(asset->name); h->text = string_copy(asset->name);
asset->name = string_copy(ui_text_input(h, "", UI_ALIGN_LEFT, true, false)); asset->name = string_copy(ui_text_input(h, "", UI_ALIGN_LEFT, true, false));
}
} }
} else if (ui_view2d_type == VIEW_2D_TYPE_NODE) {
else if (ui_view2d_type == VIEW_2D_TYPE_NODE) { ui_text(g_context->node_preview_name, UI_ALIGN_LEFT, 0x00000000);
ui_text(g_context->node_preview_name, UI_ALIGN_LEFT, 0x00000000); }
} else if (ui_view2d_type == VIEW_2D_TYPE_LAYER) {
else if (ui_view2d_type == VIEW_2D_TYPE_LAYER) { h->text = string_copy(l->name);
h->text = string_copy(l->name); char *new_name = string_copy(ui_text_input(h, "", UI_ALIGN_LEFT, true, false));
char *new_name = string_copy(ui_text_input(h, "", UI_ALIGN_LEFT, true, false)); tab_stages_rename_layer(l->name, new_name);
tab_stages_rename_layer(l->name, new_name); l->name = new_name;
l->name = new_name; ui_view2d_text_input_hover = g_ui->is_hovered;
ui_view2d_text_input_hover = g_ui->is_hovered; }
} else if (ui_view2d_type == VIEW_2D_TYPE_FONT) {
else if (ui_view2d_type == VIEW_2D_TYPE_FONT) { h->text = string_copy(g_context->font->name);
h->text = string_copy(g_context->font->name); g_context->font->name = ui_text_input(h, "", UI_ALIGN_LEFT, true, false);
g_context->font->name = ui_text_input(h, "", UI_ALIGN_LEFT, true, false); }
if (h->changed) {
ui_base_hwnds->buffer[0]->redraws = 2;
}
g_ui->_x += g_ui->_w + 3;
g_ui->_y = 2 + start_y;
} }
if (h->changed) {
ui_base_hwnds->buffer[0]->redraws = 2;
}
g_ui->_x += g_ui->_w + 3;
g_ui->_y = 2 + start_y;
g_ui->_w = ew; g_ui->_w = ew;
if (ui_view2d_type == VIEW_2D_TYPE_LAYER) { if (ui_view2d_type == VIEW_2D_TYPE_LAYER) {