paint: touch ui fixes
This commit is contained in:
+47
-35
@@ -567,6 +567,7 @@ void ui_nodes_draw_menubar() {
|
||||
g_ui->_x = 0;
|
||||
g_ui->_y = 2 + start_y;
|
||||
|
||||
// Back button
|
||||
if (g_config->touch_ui && !base_view3d_show && !ui_view2d_show) {
|
||||
g_ui->_w = math_floor(ew + 3);
|
||||
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;
|
||||
}
|
||||
|
||||
bool full = true;
|
||||
#ifdef IRON_IOS
|
||||
if (config_is_iphone()) {
|
||||
full = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Editable canvas name
|
||||
g_ui->_w = ew;
|
||||
ui_handle_t *h = ui_handle(__ID__);
|
||||
h->text = string_copy(c->name);
|
||||
g_ui->_w = math_floor(math_min(draw_string_width(g_font, g_ui->font_size, h->text) + 15 * UI_SCALE(), 100 * UI_SCALE()));
|
||||
char *new_name = ui_text_input(h, "", UI_ALIGN_LEFT, true, false);
|
||||
g_ui->_x += g_ui->_w + 3;
|
||||
g_ui->_y = 2 + start_y;
|
||||
g_ui->_w = ew;
|
||||
if (h->changed) { // Check whether renaming is possible and update group links
|
||||
if (ui_nodes_group_stack->length > 0) {
|
||||
bool can_rename = true;
|
||||
for (i32 i = 0; i < g_project->_->material_groups->length; ++i) {
|
||||
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);
|
||||
}
|
||||
if (full) {
|
||||
g_ui->_w = ew;
|
||||
ui_handle_t *h = ui_handle(__ID__);
|
||||
h->text = string_copy(c->name);
|
||||
g_ui->_w = math_floor(math_min(draw_string_width(g_font, g_ui->font_size, h->text) + 15 * UI_SCALE(), 100 * UI_SCALE()));
|
||||
char *new_name = ui_text_input(h, "", UI_ALIGN_LEFT, true, false);
|
||||
g_ui->_x += g_ui->_w + 3;
|
||||
g_ui->_y = 2 + start_y;
|
||||
g_ui->_w = ew;
|
||||
if (h->changed) { // Check whether renaming is possible and update group links
|
||||
if (ui_nodes_group_stack->length > 0) {
|
||||
bool can_rename = true;
|
||||
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);
|
||||
if (string_equals(m->canvas->name, new_name)) {
|
||||
can_rename = false; // Name already used
|
||||
}
|
||||
}
|
||||
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);
|
||||
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) {
|
||||
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 {
|
||||
c->name = string_copy(new_name);
|
||||
else {
|
||||
c->name = string_copy(new_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Category buttons
|
||||
i32 _BUTTON_COL = g_theme->BUTTON_COL;
|
||||
bool _SHADOWS = g_theme->SHADOWS;
|
||||
g_theme->BUTTON_COL = g_theme->WINDOW_BG_COL;
|
||||
|
||||
@@ -532,6 +532,7 @@ void ui_view2d_update(void *_) {
|
||||
g_ui->_x = 2;
|
||||
g_ui->_y = 2 + start_y;
|
||||
|
||||
// Back button
|
||||
if (g_config->touch_ui && !base_view3d_show) {
|
||||
g_ui->_w = math_floor(ew * 0.7 + 3);
|
||||
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;
|
||||
}
|
||||
|
||||
bool full = true;
|
||||
#ifdef IRON_IOS
|
||||
if (config_is_iphone()) {
|
||||
full = false;
|
||||
}
|
||||
#endif
|
||||
|
||||
// Editable layer name
|
||||
g_ui->_w = ew;
|
||||
ui_handle_t *h = ui_handle(__ID__);
|
||||
char *text = ui_view2d_type == VIEW_2D_TYPE_NODE ? g_context->node_preview_name : h->text;
|
||||
if (full) {
|
||||
g_ui->_w = ew;
|
||||
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) {
|
||||
asset_t *asset = g_context->texture;
|
||||
if (asset != NULL) {
|
||||
h->text = string_copy(asset->name);
|
||||
asset->name = string_copy(ui_text_input(h, "", UI_ALIGN_LEFT, true, false));
|
||||
if (ui_view2d_type == VIEW_2D_TYPE_ASSET) {
|
||||
asset_t *asset = g_context->texture;
|
||||
if (asset != NULL) {
|
||||
h->text = string_copy(asset->name);
|
||||
asset->name = string_copy(ui_text_input(h, "", UI_ALIGN_LEFT, true, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ui_view2d_type == VIEW_2D_TYPE_NODE) {
|
||||
ui_text(g_context->node_preview_name, UI_ALIGN_LEFT, 0x00000000);
|
||||
}
|
||||
else if (ui_view2d_type == VIEW_2D_TYPE_LAYER) {
|
||||
h->text = string_copy(l->name);
|
||||
char *new_name = string_copy(ui_text_input(h, "", UI_ALIGN_LEFT, true, false));
|
||||
tab_stages_rename_layer(l->name, new_name);
|
||||
l->name = new_name;
|
||||
ui_view2d_text_input_hover = g_ui->is_hovered;
|
||||
}
|
||||
else if (ui_view2d_type == VIEW_2D_TYPE_FONT) {
|
||||
h->text = string_copy(g_context->font->name);
|
||||
g_context->font->name = ui_text_input(h, "", UI_ALIGN_LEFT, true, false);
|
||||
else if (ui_view2d_type == VIEW_2D_TYPE_NODE) {
|
||||
ui_text(g_context->node_preview_name, UI_ALIGN_LEFT, 0x00000000);
|
||||
}
|
||||
else if (ui_view2d_type == VIEW_2D_TYPE_LAYER) {
|
||||
h->text = string_copy(l->name);
|
||||
char *new_name = string_copy(ui_text_input(h, "", UI_ALIGN_LEFT, true, false));
|
||||
tab_stages_rename_layer(l->name, new_name);
|
||||
l->name = new_name;
|
||||
ui_view2d_text_input_hover = g_ui->is_hovered;
|
||||
}
|
||||
else if (ui_view2d_type == VIEW_2D_TYPE_FONT) {
|
||||
h->text = string_copy(g_context->font->name);
|
||||
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;
|
||||
|
||||
if (ui_view2d_type == VIEW_2D_TYPE_LAYER) {
|
||||
|
||||
Reference in New Issue
Block a user