From 7b69b89b45b5a7235a197569ab23b4cf4cfe1bbd Mon Sep 17 00:00:00 2001 From: luboslenco Date: Tue, 21 Oct 2025 21:07:28 +0200 Subject: [PATCH] Improve layout in tabs --- paint/sources/base.ts | 5 +- paint/sources/box_export.ts | 2 +- paint/sources/tab_browser.ts | 187 ++++++++++++++++++--------------- paint/sources/tab_brushes.ts | 4 +- paint/sources/tab_console.ts | 22 +--- paint/sources/tab_fonts.ts | 18 +--- paint/sources/tab_layers.ts | 2 +- paint/sources/tab_materials.ts | 6 +- paint/sources/tab_meshes.ts | 14 +-- paint/sources/tab_plugins.ts | 2 +- paint/sources/tab_scripts.ts | 2 +- paint/sources/tab_swatches.ts | 13 +-- paint/sources/tab_textures.ts | 18 +--- 13 files changed, 131 insertions(+), 164 deletions(-) diff --git a/paint/sources/base.ts b/paint/sources/base.ts index c75096de..a4ad3245 100644 --- a/paint/sources/base.ts +++ b/paint/sources/base.ts @@ -679,10 +679,7 @@ function base_redraw_status() { } function base_redraw_console() { - let statush: i32 = config_raw.layout[layout_size_t.STATUS_H]; - if (ui != null && statush > ui_statusbar_default_h * UI_SCALE()) { - ui_base_hwnds[tab_area_t.STATUS].redraws = 2; - } + ui_base_hwnds[tab_area_t.STATUS].redraws = 2; } function base_init_undo_layers() { diff --git a/paint/sources/box_export.ts b/paint/sources/box_export.ts index 1eb13a34..a51bad97 100644 --- a/paint/sources/box_export.ts +++ b/paint/sources/box_export.ts @@ -285,7 +285,7 @@ function box_export_tab_presets() { box_export_save_preset(); } - row = [ 1 / 8 ]; + row = [ 1 / 6 ]; ui_row(row); if (ui_button(tr("Add"))) { let tex: export_preset_texture_t = {name : "base", channels : [ "base_r", "base_g", "base_b", "1.0" ], color_space : "linear"}; diff --git a/paint/sources/tab_browser.ts b/paint/sources/tab_browser.ts index d5d96150..5faef01a 100644 --- a/paint/sources/tab_browser.ts +++ b/paint/sources/tab_browser.ts @@ -15,14 +15,14 @@ function tab_browser_show_directory(directory: string) { } function tab_browser_draw(htab: ui_handle_t) { - let statush: i32 = config_raw.layout[layout_size_t.STATUS_H]; - if (ui_tab(htab, tr("Browser")) && statush > ui_statusbar_default_h * UI_SCALE()) { + if (ui_tab(htab, tr("Browser")) && ui._window_h > ui_statusbar_default_h * UI_SCALE()) { if (config_raw.bookmarks == null) { config_raw.bookmarks = []; } let bookmarks_w: i32 = math_floor(100 * UI_SCALE()); + let show_full: bool = ui._w > (500 * UI_SCALE()); if (tab_browser_hpath.text == "" && config_raw.bookmarks.length > 0) { // Init to first bookmark tab_browser_hpath.text = config_raw.bookmarks[0]; @@ -32,36 +32,44 @@ function tab_browser_draw(htab: ui_handle_t) { } ui_begin_sticky(); - let step: f32 = (1.0 - bookmarks_w / ui._w); - if (tab_browser_hsearch.text != "") { - let row: f32[] = [ bookmarks_w / ui._w, step * 0.07, step * 0.07, step * 0.66, step * 0.17, step * 0.03 ]; - ui_row(row); + + if (show_full) { + let step: f32 = (1.0 - bookmarks_w / ui._w); + if (tab_browser_hsearch.text != "") { + let row: f32[] = [ bookmarks_w / ui._w, step * 0.07, step * 0.07, step * 0.66, step * 0.17, step * 0.03 ]; + ui_row(row); + } + else { + let row: f32[] = [ bookmarks_w / ui._w, step * 0.07, step * 0.07, step * 0.66, step * 0.2 ]; + ui_row(row); + } + + // Bookmark + if (ui_button("+")) { + let bookmark: string = tab_browser_hpath.text; + /// if arm_windows + bookmark = string_replace_all(bookmark, "\\", "/"); + /// end + array_push(config_raw.bookmarks, bookmark); + config_save(); + } + if (ui.is_hovered) { + ui_tooltip(tr("Add bookmark")); + } + + // Refresh + let in_focus: bool = + ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w && ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h; + if (ui_button(tr("Refresh")) || (in_focus && ui.is_key_pressed && ui.key_code == key_code_t.F5)) { + tab_browser_refresh = true; + } } else { - let row: f32[] = [ bookmarks_w / ui._w, step * 0.07, step * 0.07, step * 0.66, step * 0.2 ]; + // Up, Refresh + let row: f32[] = [ 1 / 4, 3 / 4 ]; ui_row(row); } - // Bookmark - if (ui_button("+")) { - let bookmark: string = tab_browser_hpath.text; - /// if arm_windows - bookmark = string_replace_all(bookmark, "\\", "/"); - /// end - array_push(config_raw.bookmarks, bookmark); - config_save(); - } - if (ui.is_hovered) { - ui_tooltip(tr("Add bookmark")); - } - - // Refresh - let in_focus: bool = - ui.input_x > ui._window_x && ui.input_x < ui._window_x + ui._window_w && ui.input_y > ui._window_y && ui.input_y < ui._window_y + ui._window_h; - if (ui_button(tr("Refresh")) || (in_focus && ui.is_key_pressed && ui.key_code == key_code_t.F5)) { - tab_browser_refresh = true; - } - // Previous folder let text: string = tab_browser_hpath.text; let i1: i32 = string_index_of(text, path_sep); @@ -97,16 +105,19 @@ function tab_browser_draw(htab: ui_handle_t) { } /// end - tab_browser_hsearch.text = ui_text_input(tab_browser_hsearch, tr("Search"), ui_align_t.LEFT, true, true); - if (ui.is_hovered) { - ui_tooltip(tr("ctrl+f to search") + "\n" + tr("esc to cancel")); - } - if (ui.is_ctrl_down && ui.is_key_pressed && ui.key_code == key_code_t.F) { // Start searching via ctrl+f - ui_start_text_edit(tab_browser_hsearch); - } - if (tab_browser_hsearch.text != "" && (ui_button(tr("X")) || ui.is_escape_down)) { - tab_browser_hsearch.text = ""; + if (show_full) { + tab_browser_hsearch.text = ui_text_input(tab_browser_hsearch, tr("Search"), ui_align_t.LEFT, true, true); + if (ui.is_hovered) { + ui_tooltip(tr("ctrl+f to search") + "\n" + tr("esc to cancel")); + } + if (ui.is_ctrl_down && ui.is_key_pressed && ui.key_code == key_code_t.F) { // Start searching via ctrl+f + ui_start_text_edit(tab_browser_hsearch); + } + if (tab_browser_hsearch.text != "" && (ui_button(tr("X")) || ui.is_escape_down)) { + tab_browser_hsearch.text = ""; + } } + ui_end_sticky(); if (tab_browser_last_path != tab_browser_hpath.text) { @@ -115,8 +126,10 @@ function tab_browser_draw(htab: ui_handle_t) { tab_browser_last_path = tab_browser_hpath.text; let _y: f32 = ui._y; - ui._x = bookmarks_w; - ui._w -= bookmarks_w; + if (show_full) { + ui._x = bookmarks_w; + ui._w -= bookmarks_w; + } ui_files_file_browser(tab_browser_hpath, true, tab_browser_hsearch.text, tab_browser_refresh, function(file: string) { let file_name: string = substring(file, string_last_index_of(file, path_sep) + 1, file.length); @@ -218,60 +231,62 @@ function tab_browser_draw(htab: ui_handle_t) { } /// end - let bottom_y: i32 = ui._y; - ui._x = 0; - ui._y = _y; - ui._w = bookmarks_w; + if (show_full) { + let bottom_y: i32 = ui._y; + ui._x = 0; + ui._y = _y; + ui._w = bookmarks_w; - if (ui_button(tr("Cloud"), ui_align_t.LEFT)) { - tab_browser_hpath.text = "cloud"; - } + if (ui_button(tr("Cloud"), ui_align_t.LEFT)) { + tab_browser_hpath.text = "cloud"; + } - if (ui_button(tr("Disk"), ui_align_t.LEFT)) { - /// if arm_android - ui_menu_draw(function() { - if (ui_menu_button(tr("Download"))) { - tab_browser_hpath.text = ui_files_default_path; - } - if (ui_menu_button(tr("Pictures"))) { - tab_browser_hpath.text = "/storage/emulated/0/Pictures"; - } - if (ui_menu_button(tr("Camera"))) { - tab_browser_hpath.text = "/storage/emulated/0/DCIM/Camera"; - } - if (ui_menu_button(tr("Projects"))) { - tab_browser_hpath.text = iron_internal_save_path(); - } - }); - /// else - tab_browser_hpath.text = ui_files_default_path; - /// end - } - - for (let i: i32 = 0; i < config_raw.bookmarks.length; ++i) { - let b: string = config_raw.bookmarks[i]; - let folder: string = substring(b, string_last_index_of(b, "/") + 1, b.length); - - if (ui_button(folder, ui_align_t.LEFT)) { - tab_browser_hpath.text = b; - /// if arm_windows - tab_browser_hpath.text = string_replace_all(tab_browser_hpath.text, "/", "\\"); + if (ui_button(tr("Disk"), ui_align_t.LEFT)) { + /// if arm_android + ui_menu_draw(function() { + if (ui_menu_button(tr("Download"))) { + tab_browser_hpath.text = ui_files_default_path; + } + if (ui_menu_button(tr("Pictures"))) { + tab_browser_hpath.text = "/storage/emulated/0/Pictures"; + } + if (ui_menu_button(tr("Camera"))) { + tab_browser_hpath.text = "/storage/emulated/0/DCIM/Camera"; + } + if (ui_menu_button(tr("Projects"))) { + tab_browser_hpath.text = iron_internal_save_path(); + } + }); + /// else + tab_browser_hpath.text = ui_files_default_path; /// end } - if (ui.is_hovered && ui.input_released_r) { - _tab_browser_draw_b = b; - ui_menu_draw(function() { - if (ui_menu_button(tr("Delete"))) { - array_remove(config_raw.bookmarks, _tab_browser_draw_b); - config_save(); - } - }); - } - } + for (let i: i32 = 0; i < config_raw.bookmarks.length; ++i) { + let b: string = config_raw.bookmarks[i]; + let folder: string = substring(b, string_last_index_of(b, "/") + 1, b.length); - if (ui._y < bottom_y) { - ui._y = bottom_y; + if (ui_button(folder, ui_align_t.LEFT)) { + tab_browser_hpath.text = b; + /// if arm_windows + tab_browser_hpath.text = string_replace_all(tab_browser_hpath.text, "/", "\\"); + /// end + } + + if (ui.is_hovered && ui.input_released_r) { + _tab_browser_draw_b = b; + ui_menu_draw(function() { + if (ui_menu_button(tr("Delete"))) { + array_remove(config_raw.bookmarks, _tab_browser_draw_b); + config_save(); + } + }); + } + } + + if (ui._y < bottom_y) { + ui._y = bottom_y; + } } } } diff --git a/paint/sources/tab_brushes.ts b/paint/sources/tab_brushes.ts index 94365874..d344c91e 100644 --- a/paint/sources/tab_brushes.ts +++ b/paint/sources/tab_brushes.ts @@ -4,7 +4,7 @@ let _tab_brushes_draw_i: i32; function tab_brushes_draw(htab: ui_handle_t) { if (ui_tab(htab, tr("Brushes"))) { ui_begin_sticky(); - let row: f32[] = [ 1 / 4, 1 / 4, 1 / 4 ]; + let row: f32[] = [ -70, -70, -70 ]; ui_row(row); if (ui_button(tr("New"))) { context_raw.brush = slot_brush_create(); @@ -22,7 +22,7 @@ function tab_brushes_draw(htab: ui_handle_t) { ui_separator(3, false); let slotw: i32 = math_floor(51 * UI_SCALE()); - let num: i32 = math_floor(config_raw.layout[layout_size_t.SIDEBAR_W] / slotw); + let num: i32 = math_floor(ui._window_w / slotw); if (num == 0) { return; } diff --git a/paint/sources/tab_console.ts b/paint/sources/tab_console.ts index 5346909e..723cb21d 100644 --- a/paint/sources/tab_console.ts +++ b/paint/sources/tab_console.ts @@ -3,29 +3,15 @@ function tab_console_draw(htab: ui_handle_t) { let title: string = console_message_timer > 0 ? console_message + " " : tr("Console"); let color: i32 = console_message_timer > 0 ? console_message_color : -1; - let statush: i32 = config_raw.layout[layout_size_t.STATUS_H]; - if (ui_tab(htab, title, false, color) && statush > ui_statusbar_default_h * UI_SCALE()) { + if (ui_tab(htab, title, false, color) && ui._window_h > ui_statusbar_default_h * UI_SCALE()) { ui_begin_sticky(); /// if (arm_windows || arm_linux || arm_macos) // Copy - if (config_raw.touch_ui) { - let row: f32[] = [ 1 / 4, 1 / 4, 1 / 4 ]; - ui_row(row); - } - else { - let row: f32[] = [ 1 / 14, 1 / 14, 1 / 14 ]; - ui_row(row); - } + let row: f32[] = [ -100, -100, -100 ]; /// else - if (config_raw.touch_ui) { - let row: f32[] = [ 1 / 4, 1 / 4 ]; - ui_row(row); - } - else { - let row: f32[] = [ 1 / 14, 1 / 14 ]; - ui_row(row); - } + let row: f32[] = [ -100, -100 ]; /// end + ui_row(row); if (ui_button(tr("Clear"))) { console_last_traces = []; diff --git a/paint/sources/tab_fonts.ts b/paint/sources/tab_fonts.ts index 6cf9ded5..71a957af 100644 --- a/paint/sources/tab_fonts.ts +++ b/paint/sources/tab_fonts.ts @@ -2,18 +2,11 @@ let _tab_fonts_draw_i: i32; function tab_fonts_draw(htab: ui_handle_t) { - let statush: i32 = config_raw.layout[layout_size_t.STATUS_H]; - if (ui_tab(htab, tr("Fonts")) && statush > ui_statusbar_default_h * UI_SCALE()) { + if (ui_tab(htab, tr("Fonts")) && ui._window_h > ui_statusbar_default_h * UI_SCALE()) { ui_begin_sticky(); - if (config_raw.touch_ui) { - let row: f32[] = [ 1 / 4, 1 / 4 ]; - ui_row(row); - } - else { - let row: f32[] = [ 1 / 14, 1 / 14 ]; - ui_row(row); - } + let row: f32[] = [ -100, -100 ]; + ui_row(row); if (ui_button(tr("Import"))) { project_import_asset("ttf,ttc,otf"); @@ -28,9 +21,8 @@ function tab_fonts_draw(htab: ui_handle_t) { ui_end_sticky(); ui_separator(3, false); - let statusw: i32 = iron_window_width() - ui_toolbar_w(true) - config_raw.layout[layout_size_t.SIDEBAR_W]; - let slotw: i32 = math_floor(51 * UI_SCALE()); - let num: i32 = math_floor(statusw / slotw); + let slotw: i32 = math_floor(51 * UI_SCALE()); + let num: i32 = math_floor(ui._window_w / slotw); if (num == 0) { return; } diff --git a/paint/sources/tab_layers.ts b/paint/sources/tab_layers.ts index 1da3bca4..5a2f4f61 100644 --- a/paint/sources/tab_layers.ts +++ b/paint/sources/tab_layers.ts @@ -35,7 +35,7 @@ function tab_layers_draw_mini(htab: ui_handle_t) { function tab_layers_draw_full(htab: ui_handle_t) { if (ui_tab(htab, tr("Layers"))) { ui_begin_sticky(); - let row: f32[] = [ 1 / 4, 1 / 4, 1 / 2 ]; + let row: f32[] = [ -70, -70, -140 ]; ui_row(row); tab_layers_button_new(tr("New")); diff --git a/paint/sources/tab_materials.ts b/paint/sources/tab_materials.ts index dc145e6d..bed7a074 100644 --- a/paint/sources/tab_materials.ts +++ b/paint/sources/tab_materials.ts @@ -2,7 +2,7 @@ let _tab_materials_draw_slots: i32; function tab_materials_draw(htab: ui_handle_t) { - let mini: bool = config_raw.layout[layout_size_t.SIDEBAR_W] <= ui_sidebar_w_mini; + let mini: bool = ui._window_w <= ui_sidebar_w_mini; mini ? tab_materials_draw_mini(htab) : tab_materials_draw_full(htab); } @@ -23,7 +23,7 @@ function tab_materials_draw_mini(htab: ui_handle_t) { function tab_materials_draw_full(htab: ui_handle_t) { if (ui_tab(htab, tr("Materials"))) { ui_begin_sticky(); - let row: f32[] = [ 1 / 4, 1 / 4, 1 / 4 ]; + let row: f32[] = [ -70, -70, -70 ]; ui_row(row); tab_materials_button_new(tr("New")); @@ -49,7 +49,7 @@ function tab_materials_button_nodes() { function tab_materials_draw_slots(mini: bool) { let slotw: i32 = math_floor((51 + math_floor(config_raw.window_scale * 2)) * UI_SCALE()); - let num: i32 = math_floor(config_raw.layout[layout_size_t.SIDEBAR_W] / slotw); + let num: i32 = math_floor(ui._window_w / slotw); if (num == 0) { return; } diff --git a/paint/sources/tab_meshes.ts b/paint/sources/tab_meshes.ts index 542b94ee..2c1e9224 100644 --- a/paint/sources/tab_meshes.ts +++ b/paint/sources/tab_meshes.ts @@ -2,19 +2,11 @@ let _tab_meshes_draw_i: i32; function tab_meshes_draw(htab: ui_handle_t) { - let statush: i32 = config_raw.layout[layout_size_t.STATUS_H]; - if (ui_tab(htab, tr("Meshes")) && statush > ui_statusbar_default_h * UI_SCALE()) { + if (ui_tab(htab, tr("Meshes")) && ui._window_h > ui_statusbar_default_h * UI_SCALE()) { ui_begin_sticky(); - - if (config_raw.touch_ui) { - let row: f32[] = [ 1 / 4, 1 / 4 ]; - ui_row(row); - } - else { - let row: f32[] = [ 1 / 14, 1 / 14 ]; - ui_row(row); - } + let row: f32[] = [ -100, -100 ]; + ui_row(row); if (ui_button(tr("Import"))) { ui_menu_draw(function() { diff --git a/paint/sources/tab_plugins.ts b/paint/sources/tab_plugins.ts index 84db0471..ff7d1b02 100644 --- a/paint/sources/tab_plugins.ts +++ b/paint/sources/tab_plugins.ts @@ -4,7 +4,7 @@ function tab_plugins_draw(htab: ui_handle_t) { ui_begin_sticky(); - let row: f32[] = [ 1 / 4 ]; + let row: f32[] = [ -70 ]; ui_row(row); if (ui_button(tr("Manager"))) { diff --git a/paint/sources/tab_scripts.ts b/paint/sources/tab_scripts.ts index dc13d830..36af503c 100644 --- a/paint/sources/tab_scripts.ts +++ b/paint/sources/tab_scripts.ts @@ -6,7 +6,7 @@ function tab_scripts_draw(htab: ui_handle_t) { if (ui_tab(htab, tr("Scripts"))) { ui_begin_sticky(); - let row: f32[] = [ 1 / 4, 1 / 4, 1 / 2 ]; + let row: f32[] = [ -70, -70, -140 ]; ui_row(row); if (ui_button(tr("Run"))) { diff --git a/paint/sources/tab_swatches.ts b/paint/sources/tab_swatches.ts index a7c6d388..33246160 100644 --- a/paint/sources/tab_swatches.ts +++ b/paint/sources/tab_swatches.ts @@ -20,18 +20,11 @@ function tab_swatches_empty_get(): gpu_texture_t { } function tab_swatches_draw(htab: ui_handle_t) { - let statush: i32 = config_raw.layout[layout_size_t.STATUS_H]; - if (ui_tab(htab, tr("Swatches")) && statush > ui_statusbar_default_h * UI_SCALE()) { + if (ui_tab(htab, tr("Swatches")) && ui._window_h > ui_statusbar_default_h * UI_SCALE()) { ui_begin_sticky(); - if (config_raw.touch_ui) { - let row: f32[] = [ 1 / 5, 1 / 5, 1 / 5, 1 / 5, 1 / 5 ]; - ui_row5(); - } - else { - let row: f32[] = [ 1 / 14, 1 / 14, 1 / 14, 1 / 14, 1 / 14 ]; - ui_row(row); - } + let row: f32[] = [ -100, -100, -100, -100, -100 ]; + ui_row(row); if (ui_button(tr("New"))) { context_set_swatch(make_swatch()); diff --git a/paint/sources/tab_textures.ts b/paint/sources/tab_textures.ts index dfcfc612..b1d8ac94 100644 --- a/paint/sources/tab_textures.ts +++ b/paint/sources/tab_textures.ts @@ -6,19 +6,13 @@ let _tab_textures_draw_i: i32; let _tab_textures_draw_is_packed: bool; function tab_textures_draw(htab: ui_handle_t) { - let statush: i32 = config_raw.layout[layout_size_t.STATUS_H]; - if (ui_tab(htab, tr("Textures")) && statush > ui_statusbar_default_h * UI_SCALE()) { + + if (ui_tab(htab, tr("Textures")) && ui._window_h > ui_statusbar_default_h * UI_SCALE()) { ui_begin_sticky(); - if (config_raw.touch_ui) { - let row: f32[] = [ 1 / 4, 1 / 4 ]; - ui_row(row); - } - else { - let row: f32[] = [ 1 / 14, 1 / 14 ]; - ui_row(row); - } + let row: f32[] = [ -100, -100 ]; + ui_row(row); if (ui_button(tr("Import"))) { ui_files_show(string_array_join(path_texture_formats, ","), false, true, function(path: string) { @@ -38,10 +32,8 @@ function tab_textures_draw(htab: ui_handle_t) { if (project_assets.length > 0) { - let statusw: i32 = iron_window_width() - ui_toolbar_w(true) - config_raw.layout[layout_size_t.SIDEBAR_W]; - let slotw: i32 = math_floor(52 * UI_SCALE()); - let num: i32 = math_floor(statusw / slotw); + let num: i32 = math_floor(ui._window_w / slotw); if (num == 0) { return; }