From d962a28f420131bebf21750167f7951583b441e5 Mon Sep 17 00:00:00 2001 From: luboslenco Date: Wed, 11 Sep 2024 16:32:12 +0200 Subject: [PATCH] UI tweaks --- armorforge/sources/tab_objects.ts | 6 +-- armorpaint/sources/tab_layers.ts | 30 ++---------- armorsculpt/sources/tab_layers.ts | 2 +- base/assets/themes/light.json | 8 +-- base/sources/args.ts | 6 --- base/sources/base.ts | 17 +++---- base/sources/box_export.ts | 2 +- base/sources/box_preferences.ts | 11 ++--- base/sources/box_projects.ts | 2 +- base/sources/nodes_material.ts | 2 +- base/sources/tab_browser.ts | 6 +-- base/sources/tab_brushes.ts | 3 +- base/sources/tab_fonts.ts | 3 +- base/sources/tab_materials.ts | 5 +- base/sources/tab_meshes.ts | 10 ++-- base/sources/tab_swatches.ts | 17 ++----- base/sources/tab_textures.ts | 11 +---- base/sources/ui_base.ts | 20 +------- base/sources/ui_header.ts | 2 +- base/sources/ui_menu.ts | 81 ++++++++++++++++--------------- base/sources/ui_menubar.ts | 7 ++- base/sources/ui_nodes.ts | 62 +++++++++++++---------- base/sources/ui_toolbar.ts | 21 +------- base/tools/pad/sources/main.ts | 6 +-- 24 files changed, 129 insertions(+), 211 deletions(-) diff --git a/armorforge/sources/tab_objects.ts b/armorforge/sources/tab_objects.ts index d2d0451b..11209f03 100644 --- a/armorforge/sources/tab_objects.ts +++ b/armorforge/sources/tab_objects.ts @@ -79,7 +79,7 @@ function tab_objects_draw_list(ui: ui_t, list_handle: ui_handle_t, current_objec ui._x += 18; // Sign offset // Draw line that shows parent relations - g2_set_color(ui.ops.theme.ACCENT_COL); + g2_set_color(ui.ops.theme.BUTTON_COL); g2_draw_line(ui._x - 10, ui._y + ui_ELEMENT_H(ui) / 2, ui._x, ui._y + ui_ELEMENT_H(ui) / 2); g2_set_color(0xffffffff); @@ -97,7 +97,7 @@ function tab_objects_draw_list(ui: ui_t, list_handle: ui_handle_t, current_objec if (ui.is_hovered && ui.input_released_r) { tab_objects_current_object = current_object; - ui_menu_draw(tab_objects_draw_menu, 1); + ui_menu_draw(tab_objects_draw_menu); } if (b) { @@ -110,7 +110,7 @@ function tab_objects_draw_list(ui: ui_t, list_handle: ui_handle_t, current_objec } // Draw line that shows parent relations - g2_set_color(ui.ops.theme.ACCENT_COL); + g2_set_color(ui.ops.theme.BUTTON_COL); g2_draw_line(ui._x + 14, current_y, ui._x + 14, ui._y - ui_ELEMENT_H(ui) / 2); g2_set_color(0xffffffff); } diff --git a/armorpaint/sources/tab_layers.ts b/armorpaint/sources/tab_layers.ts index e7842e92..a831dc4e 100644 --- a/armorpaint/sources/tab_layers.ts +++ b/armorpaint/sources/tab_layers.ts @@ -162,7 +162,7 @@ function tab_layers_button_new(text: string) { history_new_group(); } ui.enabled = true; - }, 7); + }); } } @@ -690,7 +690,7 @@ function tab_layers_draw_layer_icon(l: slot_layer_t, i: i32, uix: f32, uiy: f32, let height: i32 = g2_font_height(ui.ops.font, ui.font_size); g2_set_color(ui.ops.theme.TEXT_COL); g2_fill_rect(uix, uiy, width, height); - g2_set_color(ui.ops.theme.ACCENT_COL); + g2_set_color(ui.ops.theme.BUTTON_COL); g2_draw_string(number, uix + 5, uiy); } } @@ -730,31 +730,7 @@ let tab_layers_l: slot_layer_t; let tab_layers_mini: bool; function tab_layers_draw_layer_context_menu(l: slot_layer_t, mini: bool) { - let add: i32 = 0; - if (l.fill_layer == null) { - add += 1; // Clear - } - if (l.fill_layer != null && !slot_layer_is_mask(l)) { - add += 3; - } - if (l.fill_layer != null && slot_layer_is_mask(l)) { - add += 2; - } - if (slot_layer_is_mask(l)) { - add += 2; - } - if (mini) { - add += 1; - if (!slot_layer_is_group(l)) { - add += 1; - } - if (slot_layer_is_layer(l)) { - add += 1; - } - } - - let menu_elements: i32 = slot_layer_is_group(l) ? 7 : (19 + add); tab_layers_l = l; tab_layers_mini = mini; @@ -1060,7 +1036,7 @@ function tab_layers_draw_layer_context_menu(l: slot_layer_t, mini: bool) { ui_menu_keep_open = true; } } - }, menu_elements); + }); } function tab_layers_make_mask_preview_rgba32(l: slot_layer_t) { diff --git a/armorsculpt/sources/tab_layers.ts b/armorsculpt/sources/tab_layers.ts index d7dc449d..fb6fa0b6 100644 --- a/armorsculpt/sources/tab_layers.ts +++ b/armorsculpt/sources/tab_layers.ts @@ -79,7 +79,7 @@ function tab_layers_button_new(text: string) { base_new_layer(); history_new_layer(); } - }, 1); + }); } } diff --git a/base/assets/themes/light.json b/base/assets/themes/light.json index bba1d91f..14355898 100644 --- a/base/assets/themes/light.json +++ b/base/assets/themes/light.json @@ -1,19 +1,14 @@ { "WINDOW_BG_COL": 4291611852, - "WINDOW_TINT_COL": 4294967295, - "ACCENT_COL": 4289374890, - "ACCENT_HOVER_COL": 4290493371, + "HOVER_COL": 4290493371, "ACCENT_SELECT_COL": 4283782485, "BUTTON_COL": 4293914607, - "BUTTON_TEXT_COL": 4280427042, - "BUTTON_HOVER_COL": 4294967295, "BUTTON_PRESSED_COL": 4289835441, "TEXT_COL": 4280427042, "LABEL_COL": 4280427042, "SEPARATOR_COL": 4289967027, "HIGHLIGHT_COL": 4284521948, "CONTEXT_COL": 4284521948, - "PANEL_BG_COL": 4291611852, "FONT_SIZE": 13, "ELEMENT_W": 100, "ELEMENT_H": 24, @@ -28,7 +23,6 @@ "TAB_W": 12, "FILL_WINDOW_BG": 1, "FILL_BUTTON_BG": 1, - "FILL_ACCENT_BG": 0, "LINK_STYLE": 0, "FULL_TABS": 0, "ROUND_CORNERS": 1, diff --git a/base/sources/args.ts b/base/sources/args.ts index ea0cf1fb..a13918d2 100644 --- a/base/sources/args.ts +++ b/base/sources/args.ts @@ -2,21 +2,15 @@ let args_use: bool = false; let args_asset_path: string = ""; let args_background: bool = false; -///if (is_paint || is_lab) let args_export_textures: bool = false; let args_export_textures_type: string = ""; let args_export_textures_preset: string = ""; let args_export_textures_path: string = ""; -///end -///if (is_paint || is_sculpt) let args_reimport_mesh: bool = false; let args_export_mesh: bool = false; let args_export_mesh_path: string = ""; -///end -///if is_paint let args_export_material: bool = false; let args_export_material_path: string = ""; -///end function args_parse() { if (iron_get_arg_count() > 1) { diff --git a/base/sources/base.ts b/base/sources/base.ts index 731d4b9a..d1fbcb81 100644 --- a/base/sources/base.ts +++ b/base/sources/base.ts @@ -30,17 +30,14 @@ let base_appx: i32 = 0; let base_appy: i32 = 0; let base_last_window_width: i32 = 0; let base_last_window_height: i32 = 0; -///if (is_paint || is_sculpt) let base_drag_material: slot_material_t = null; let base_drag_layer: slot_layer_t = null; -///end let base_pipe_copy: pipeline_t; let base_pipe_copy8: pipeline_t; let base_pipe_copy128: pipeline_t; let base_pipe_copy_bgra: pipeline_t; let base_pipe_copy_rgb: pipeline_t = null; -///if (is_paint || is_sculpt) let base_pipe_merge: pipeline_t = null; let base_pipe_merge_r: pipeline_t = null; let base_pipe_merge_g: pipeline_t = null; @@ -65,7 +62,7 @@ let base_texpaint_colorid: kinc_tex_unit_t; let base_opac_merge_mask: kinc_const_loc_t; let base_blending_merge_mask: kinc_const_loc_t; let base_temp_mask_image: image_t = null; -///end + ///if is_lab let base_pipe_copy_r: pipeline_t; let base_pipe_copy_g: pipeline_t; @@ -91,14 +88,13 @@ let base_cursor_tint: kinc_const_loc_t; let base_cursor_tex: kinc_tex_unit_t; let base_cursor_gbufferd: kinc_tex_unit_t; -///if (is_paint || is_sculpt) let base_default_base: f32 = 0.5; let base_default_rough: f32 = 0.4; +let base_max_layers: i32 = ///if (arm_android || arm_ios) -let base_max_layers: i32 = 18; + 18; ///else -let base_max_layers: i32 = 255; -///end + 255; ///end let base_default_fov: f32 = 0.69; let _base_material_count: i32; @@ -297,10 +293,11 @@ function base_init() { args_run(); + let has_projects: bool = ///if (arm_android || arm_ios) - let has_projects: bool = config_raw.recent_projects.length > 0; + config_raw.recent_projects.length > 0; ///else - let has_projects: bool = true; + true; ///end if (config_raw.splash_screen && has_projects) { diff --git a/base/sources/box_export.ts b/base/sources/box_export.ts index 861d1f43..43fc5243 100644 --- a/base/sources/box_export.ts +++ b/base/sources/box_export.ts @@ -285,7 +285,7 @@ function box_export_tab_presets(ui: ui_t) { array_remove(box_export_preset.textures, _box_export_t); box_export_save_preset(); } - }, 1); + }); } let hr: ui_handle_t = ui_nest(htex, 0); diff --git a/base/sources/box_preferences.ts b/base/sources/box_preferences.ts index caa3a520..1bf3179e 100644 --- a/base/sources/box_preferences.ts +++ b/base/sources/box_preferences.ts @@ -164,7 +164,7 @@ function box_preferences_show() { }, raw); }); } - }, 2); + }); } if (ui_button(tr("Reset Layout")) && !ui_menu_show) { ui_menu_draw(function (ui: ui_t) { @@ -172,7 +172,7 @@ function box_preferences_show() { base_init_layout(); config_save(); } - }, 1); + }); } } @@ -262,7 +262,7 @@ function box_preferences_show() { if (ui.changed) { ui_menu_keep_open = true; } - }, 11); + }); } let val: u32 = h.color; h.text = i32_to_string_hex(val); @@ -307,7 +307,7 @@ function box_preferences_show() { if (ui.changed) { ui_menu_keep_open = true; } - }, 11); + }); } } @@ -315,7 +315,6 @@ function box_preferences_show() { if (key == "FILL_WINDOW_BG" || key == "FILL_BUTTON_BG" || - key == "FILL_ACCENT_BG" || key == "FULL_TABS" || key == "ROUND_CORNERS" || key == "SHADOWS") { @@ -918,7 +917,7 @@ plugin.draw_ui = function (ui) {\ array_remove(box_preferences_files_plugin, _box_preferences_f); file_delete(path); } - }, 4); + }); } } } diff --git a/base/sources/box_projects.ts b/base/sources/box_projects.ts index 4ebb5aae..9a63c8c4 100644 --- a/base/sources/box_projects.ts +++ b/base/sources/box_projects.ts @@ -154,7 +154,7 @@ function box_projects_tab(ui: ui_t) { array_splice(recent_projects, _box_projects_i, 1); }); } - }, 1); + }); } if (show_asset_names) { diff --git a/base/sources/nodes_material.ts b/base/sources/nodes_material.ts index c03efd02..c2e1c1a4 100644 --- a/base/sources/nodes_material.ts +++ b/base/sources/nodes_material.ts @@ -4124,7 +4124,7 @@ function nodes_material_add_socket_button(ui: ui_t, nodes: ui_nodes_t, node: ui_ array_push(sockets, nodes_material_create_socket(nodes, node, null, "VALUE", c)); nodes_material_sync_sockets(node); } - }, 3); + }); } } diff --git a/base/sources/tab_browser.ts b/base/sources/tab_browser.ts index 02c31240..8cddf626 100644 --- a/base/sources/tab_browser.ts +++ b/base/sources/tab_browser.ts @@ -179,7 +179,7 @@ function tab_browser_draw(htab: ui_handle_t) { if (ui_menu_button(ui, tr("Open Externally"))) { file_start(file); } - }, path_is_texture(file) ? 5 : 2); + }); }); if (tab_browser_known) { @@ -221,7 +221,7 @@ function tab_browser_draw(htab: ui_handle_t) { if (ui_menu_button(ui, tr("Projects"))) { tab_browser_hpath.text = iron_save_path(); } - }, 4); + }); ///else tab_browser_hpath.text = ui_files_default_path; ///end @@ -242,7 +242,7 @@ function tab_browser_draw(htab: ui_handle_t) { array_remove(config_raw.bookmarks, _tab_browser_draw_b); config_save(); } - }, 1); + }); } } diff --git a/base/sources/tab_brushes.ts b/base/sources/tab_brushes.ts index b4c62910..377ae148 100644 --- a/base/sources/tab_brushes.ts +++ b/base/sources/tab_brushes.ts @@ -85,7 +85,6 @@ function tab_brushes_draw(htab: ui_handle_t) { } if (ui.is_hovered && ui.input_released_r) { context_select_brush(i); - let add: i32 = project_brushes.length > 1 ? 1 : 0; _tab_brushes_draw_i = i; @@ -115,7 +114,7 @@ function tab_brushes_draw(htab: ui_handle_t) { if (project_brushes.length > 1 && ui_menu_button(ui, tr("Delete"), "delete")) { tab_brushes_delete_brush(project_brushes[i]); } - }, 2 + add); + }); } if (ui.is_hovered) { diff --git a/base/sources/tab_fonts.ts b/base/sources/tab_fonts.ts index 4b665ddd..5a8fa060 100644 --- a/base/sources/tab_fonts.ts +++ b/base/sources/tab_fonts.ts @@ -107,7 +107,6 @@ function tab_fonts_draw(htab: ui_handle_t) { } if (ui.is_hovered && ui.input_released_r) { context_select_font(i); - let add: i32 = project_fonts.length > 1 ? 1 : 0; _tab_fonts_draw_i = i; ui_menu_draw(function (ui: ui_t) { @@ -116,7 +115,7 @@ function tab_fonts_draw(htab: ui_handle_t) { if (project_fonts.length > 1 && ui_menu_button(ui, tr("Delete"), "delete") && project_fonts[i].file != "") { tab_fonts_delete_font(project_fonts[i]); } - }, 0 + add); + }); } if (ui.is_hovered) { if (img == null) { diff --git a/base/sources/tab_materials.ts b/base/sources/tab_materials.ts index d0915017..8c6e9dde 100644 --- a/base/sources/tab_materials.ts +++ b/base/sources/tab_materials.ts @@ -123,7 +123,7 @@ function tab_materials_draw_slots(mini: bool) { let height: i32 = g2_font_height(ui.ops.font, ui.font_size); g2_set_color(ui.ops.theme.TEXT_COL); g2_fill_rect(uix, uiy, width, height); - g2_set_color(ui.ops.theme.ACCENT_COL); + g2_set_color(ui.ops.theme.BUTTON_COL); g2_draw_string(number, uix + 5, uiy); } } @@ -153,7 +153,6 @@ function tab_materials_draw_slots(mini: bool) { // Context menu if (ui.is_hovered && ui.input_released_r) { context_select_material(i); - let add: i32 = project_materials.length > 1 ? 1 : 0; _tab_materials_draw_slots = i; ui_menu_draw(function (ui: ui_t) { @@ -269,7 +268,7 @@ function tab_materials_draw_slots(mini: bool) { make_material_parse_paint_material(); ui_menu_keep_open = true; } - }, 13 + add); + }); } if (ui.is_hovered) { _ui_tooltip_image(imgFull); diff --git a/base/sources/tab_meshes.ts b/base/sources/tab_meshes.ts index 3aa20c13..e56a3f25 100644 --- a/base/sources/tab_meshes.ts +++ b/base/sources/tab_meshes.ts @@ -38,7 +38,7 @@ function tab_meshes_draw(htab: ui_handle_t) { if (ui_menu_button(ui, tr("Append"))) { project_import_mesh(false); } - }, 2); + }); } if (ui.is_hovered) ui_tooltip(tr("Import mesh file")); @@ -57,7 +57,7 @@ function tab_meshes_draw(htab: ui_handle_t) { if (ui_menu_button(ui, tr("Cylinder"))) { tab_meshes_set_default_mesh(".Cylinder"); } - }, 4); + }); } ///end @@ -76,7 +76,7 @@ function tab_meshes_draw(htab: ui_handle_t) { util_mesh_calc_normals(false); context_raw.ddirty = 2; } - }, 2); + }); } if (ui_button(tr("Geometry to Origin"))) { @@ -114,7 +114,7 @@ function tab_meshes_draw(htab: ui_handle_t) { util_mesh_swap_axis(0, 1); context_raw.ddirty = 2; } - }, 3); + }); } ui_end_sticky(); @@ -155,7 +155,7 @@ function tab_meshes_draw(htab: ui_handle_t) { util_mesh_merge(); context_raw.ddirty = 2; } - }, project_paint_objects.length > 1 ? 2 : 1); + }); } if (h.changed) { let visibles: mesh_object_t[] = []; diff --git a/base/sources/tab_swatches.ts b/base/sources/tab_swatches.ts index c146e2bb..61000149 100644 --- a/base/sources/tab_swatches.ts +++ b/base/sources/tab_swatches.ts @@ -52,7 +52,7 @@ function tab_swatches_draw(htab: ui_handle_t) { if (ui_menu_button(ui, tr("Append"))) { project_import_swatches(false); } - }, 2); + }); } if (ui.is_hovered) { ui_tooltip(tr("Import swatches")); @@ -175,24 +175,13 @@ function tab_swatches_draw(htab: ui_handle_t) { if (ui.input_released) { context_set_swatch(context_raw.swatch); // Trigger material preview update } - }, 16, math_floor(mouse_x - 200 * ui_SCALE(ui)), math_floor(mouse_y - 250 * ui_SCALE(ui))); + }, math_floor(mouse_x - 200 * ui_SCALE(ui)), math_floor(mouse_y - 250 * ui_SCALE(ui))); } context_raw.select_time = time_time(); } if (ui.is_hovered && ui.input_released_r) { context_set_swatch(project_raw.swatches[i]); - let add: i32 = project_raw.swatches.length > 1 ? 1 : 0; - ///if (arm_windows || arm_linux || arm_macos) - add += 1; // Copy - ///end - - ///if (is_paint || is_sculpt) - add += 3; - ///end - ///if is_lav - add += 1; - ///end _tab_swatches_draw_i = i; @@ -224,7 +213,7 @@ function tab_swatches_draw(htab: ui_handle_t) { base_create_color_layer(color, project_raw.swatches[i].occlusion, project_raw.swatches[i].roughness, project_raw.swatches[i].metallic); } ///end - }, add); + }); } if (ui.is_hovered) { let color: i32 = project_raw.swatches[i].base; diff --git a/base/sources/tab_textures.ts b/base/sources/tab_textures.ts index ecb4407c..b0dafbc3 100644 --- a/base/sources/tab_textures.ts +++ b/base/sources/tab_textures.ts @@ -122,15 +122,6 @@ function tab_textures_draw(htab: ui_handle_t) { if (ui.is_hovered && ui.input_released_r) { context_raw.texture = asset; - let count: i32 = 0; - - ///if (is_paint || is_sculpt) - count = is_packed ? 6 : 8; - ///end - ///if is_lab - count = is_packed ? 6 : 6; - ///end - _tab_textures_draw_img = img; _tab_textures_draw_asset = asset; _tab_textures_draw_i = i; @@ -211,7 +202,7 @@ function tab_textures_draw(htab: ui_handle_t) { if (!_tab_textures_draw_is_packed && ui_menu_button(ui, tr("Open in Browser"))) { tab_browser_show_directory(substring(_tab_textures_draw_asset.file, 0, string_last_index_of(_tab_textures_draw_asset.file, path_sep))); } - }, count); + }); } if (config_raw.show_asset_names) { diff --git a/base/sources/ui_base.ts b/base/sources/ui_base.ts index 6c4b7f46..ec8e7887 100644 --- a/base/sources/ui_base.ts +++ b/base/sources/ui_base.ts @@ -659,22 +659,6 @@ function ui_base_update() { } else if (operator_shortcut(map_get(config_keymap, "viewport_mode"))) { - let count: i32; - - ///if (is_paint || is_sculpt) - count = 16; - ///if (arm_direct3d12 || arm_vulkan || arm_metal) - count += 1; - ///end - ///end - - ///if is_lab - count = 9; - ///if (arm_direct3d12 || arm_vulkan || arm_metal) - count += 1; - ///end - ///end - ui_menu_draw(function (ui: ui_t) { let mode_handle: ui_handle_t = ui_handle(__ID__); mode_handle.position = context_raw.viewport_mode; @@ -722,7 +706,7 @@ function ui_base_update() { context_set_viewport_mode(mode_handle.position); ui.changed = true; } - }, count); + }); } } @@ -974,7 +958,7 @@ function ui_base_operator_search() { search_handle.text = ""; } ui.ops.theme.BUTTON_COL = BUTTON_COL; - }, 8, -1, -1); + }); } function ui_base_toggle_distract_free() { diff --git a/base/sources/ui_header.ts b/base/sources/ui_header.ts index 80d0f733..5b2bf786 100644 --- a/base/sources/ui_header.ts +++ b/base/sources/ui_header.ts @@ -154,7 +154,7 @@ function ui_header_draw_tool_properties(ui: ui_t) { if (ui.changed) { ui_menu_keep_open = true; } - }, 10); + }); } if (ui_button(tr("Add Swatch"))) { let new_swatch: swatch_color_t = project_clone_swatch(context_raw.picked_color); diff --git a/base/sources/ui_menu.ts b/base/sources/ui_menu.ts index b83c4a2b..95636b6d 100644 --- a/base/sources/ui_menu.ts +++ b/base/sources/ui_menu.ts @@ -1,11 +1,10 @@ let ui_menu_show: bool = false; let ui_menu_category: i32 = 0; -let ui_menu_category_w: i32 = 0; -let ui_menu_category_h: i32 = 0; let ui_menu_x: i32 = 0; let ui_menu_y: i32 = 0; -let ui_menu_elements: i32 = 0; +let ui_menu_h: i32 = 0; +let ui_menu_elements: i32 = 0; //// let ui_menu_keep_open: bool = false; let ui_menu_commands: (ui: ui_t)=>void = null; let ui_menu_show_first: bool = true; @@ -20,27 +19,30 @@ type update_info_t = { function ui_menu_render() { let ui: ui_t = base_ui_menu; - let menu_w: i32 = ui_menu_commands != null ? math_floor(base_default_element_w * ui_SCALE(base_ui_menu) * 2.3) : math_floor(ui_ELEMENT_W(ui) * 2.3); - let _BUTTON_COL: i32 = ui.ops.theme.BUTTON_COL; - ui.ops.theme.BUTTON_COL = ui.ops.theme.SEPARATOR_COL; + let menu_w: i32 = ui_menu_commands != null ? + math_floor(base_default_element_w * ui_SCALE(base_ui_menu) * 2.3) : + math_floor(ui_ELEMENT_W(ui) * 2.3); + + let _FILL_BUTTON_BG: i32 = ui.ops.theme.FILL_BUTTON_BG; + ui.ops.theme.FILL_BUTTON_BG = false; let _ELEMENT_OFFSET: i32 = ui.ops.theme.ELEMENT_OFFSET; ui.ops.theme.ELEMENT_OFFSET = 0; let _ELEMENT_H: i32 = ui.ops.theme.ELEMENT_H; ui.ops.theme.ELEMENT_H = config_raw.touch_ui ? (28 + 2) : 28; + // First draw out of screen, then align the menu based on menu height + if (ui_menu_show_first) { + ui_menu_x -= sys_width() * 2; + ui_menu_y -= sys_height() * 2; + } + ui_begin_region(ui, ui_menu_x, ui_menu_y, menu_w); + ui_menu_start(ui); if (ui_menu_commands != null) { - g2_set_color(ui.ops.theme.ACCENT_SELECT_COL); - ui_draw_rect(true, ui._x + -1, ui._y + -1, ui._w + 2, ui_ELEMENT_H(ui) * ui_menu_elements + 2); - g2_set_color(ui.ops.theme.SEPARATOR_COL); - ui_draw_rect(true, ui._x + 0, ui._y + 0, ui._w, ui_ELEMENT_H(ui) * ui_menu_elements); - g2_set_color(0xffffffff); - ui_menu_commands(ui); } else { - ui_menu_start(ui); if (ui_menu_category == menu_category_t.FILE) { if (ui_menu_button(ui, tr("New .."), map_get(config_keymap, "file_new"))) { project_new_box(); @@ -632,14 +634,23 @@ function ui_menu_render() { } ui_menu_hide_flag = ui.combo_selected_handle == null && !ui_menu_keep_open && !ui_menu_show_first && (ui.changed || ui.input_released || ui.input_released_r || ui.is_escape_down); - ui_menu_show_first = false; ui_menu_keep_open = false; - ui.ops.theme.BUTTON_COL = _BUTTON_COL; + ui.ops.theme.FILL_BUTTON_BG = _FILL_BUTTON_BG; ui.ops.theme.ELEMENT_OFFSET = _ELEMENT_OFFSET; ui.ops.theme.ELEMENT_H = _ELEMENT_H; + ui_menu_end(ui); ui_end_region(); + if (ui_menu_show_first) { + ui_menu_show_first = false; + ui_menu_h = ui._y - ui_menu_y; + ui_menu_x += sys_width() * 2; + ui_menu_y += sys_height() * 2; + ui_menu_fit_to_screen(); + ui_menu_render(); // Render at correct position now + } + if (ui_menu_hide_flag) { ui_menu_hide(); ui_menu_show_first = true; @@ -652,14 +663,13 @@ function ui_menu_hide() { base_redraw_ui(); } -function ui_menu_draw(commands: (ui: ui_t)=>void = null, elements: i32, x: i32 = -1, y: i32 = -1) { +function ui_menu_draw(commands: (ui: ui_t)=>void = null, x: i32 = -1, y: i32 = -1) { ui_end_input(); ui_menu_show = true; ui_menu_commands = commands; - ui_menu_elements = elements; ui_menu_x = x > -1 ? x : math_floor(mouse_x + 1); ui_menu_y = y > -1 ? y : math_floor(mouse_y + 1); - ui_menu_fit_to_screen(); + ui_menu_h = 0; } function ui_menu_fit_to_screen() { @@ -673,21 +683,18 @@ function ui_menu_fit_to_screen() { ui_menu_x = math_floor(sys_width() - menu_w); } } - let menu_h: f32 = math_floor(ui_menu_elements * 30 * ui_SCALE(base_ui_menu)); // ui.ops.theme.ELEMENT_H - if (ui_menu_y + menu_h > sys_height()) { - if (ui_menu_y - menu_h > 0) { - ui_menu_y = math_floor(ui_menu_y - menu_h); + if (ui_menu_y + ui_menu_h > sys_height()) { + if (ui_menu_y - ui_menu_h > 0) { + ui_menu_y = math_floor(ui_menu_y - ui_menu_h); } else { - ui_menu_y = sys_height() - menu_h; + ui_menu_y = sys_height() - ui_menu_h; } ui_menu_x += 1; // Move out of mouse focus } } function ui_menu_fill(ui: ui_t) { - g2_set_color(ui.ops.theme.ACCENT_SELECT_COL); - g2_fill_rect(ui._x - 1, ui._y, ui._w + 2, ui_ELEMENT_H(ui) + 1 + 1); g2_set_color(ui.ops.theme.SEPARATOR_COL); g2_fill_rect(ui._x, ui._y, ui._w, ui_ELEMENT_H(ui) + 1); g2_set_color(0xffffffff); @@ -725,20 +732,14 @@ function ui_menu_align(ui: ui_t) { } function ui_menu_start(ui: ui_t) { - // Draw top border - g2_set_color(ui.ops.theme.ACCENT_SELECT_COL); - if (config_raw.touch_ui) { - g2_fill_rect(ui._x + ui._w / 2 + ui_menu_category_w / 2, ui._y - 1, ui._w / 2 - ui_menu_category_w / 2 + 1, 1); - g2_fill_rect(ui._x - 1, ui._y - 1, ui._w / 2 - ui_menu_category_w / 2 + 1, 1); - g2_fill_rect(ui._x + ui._w / 2 - ui_menu_category_w / 2, ui._y - ui_menu_category_h, ui_menu_category_w, 1); - g2_fill_rect(ui._x + ui._w / 2 - ui_menu_category_w / 2, ui._y - ui_menu_category_h, 1, ui_menu_category_h); - g2_fill_rect(ui._x + ui._w / 2 + ui_menu_category_w / 2, ui._y - ui_menu_category_h, 1, ui_menu_category_h); - } - else { - g2_fill_rect(ui._x - 1 + ui_menu_category_w, ui._y - 1, ui._w + 2 - ui_menu_category_w, 1); - g2_fill_rect(ui._x - 1, ui._y - ui_menu_category_h, ui_menu_category_w, 1); - g2_fill_rect(ui._x - 1, ui._y - ui_menu_category_h, 1, ui_menu_category_h); - g2_fill_rect(ui._x - 1 + ui_menu_category_w, ui._y - ui_menu_category_h, 1, ui_menu_category_h); - } + ui_draw_shadow(ui._x, ui._y - 4, ui._w, ui_menu_h + 8); + // Round top + g2_set_color(ui.ops.theme.SEPARATOR_COL); + ui_draw_rect(true, ui._x, ui._y - 4, ui._w, 8); + g2_set_color(0xffffffff); +} + +function ui_menu_end(ui: ui_t) { + ui_draw_round_bottom(ui._x, ui._y, ui._w); g2_set_color(0xffffffff); } diff --git a/base/sources/ui_menubar.ts b/base/sources/ui_menubar.ts index 1b0a64b2..1ddd3a85 100644 --- a/base/sources/ui_menubar.ts +++ b/base/sources/ui_menubar.ts @@ -198,11 +198,14 @@ function ui_menubar_render_ui() { } function ui_menubar_show_menu(ui: ui_t, category: i32) { + if (ui_menu_show && ui_menu_category == category) { + return; + } + ui_menu_show = true; + ui_menu_show_first = true; ui_menu_commands = null; ui_menu_category = category; - ui_menu_category_w = ui._w; - ui_menu_category_h = math_floor(ui_MENUBAR_H(ui)); ui_menu_x = math_floor(ui._x - ui._w); ui_menu_y = math_floor(ui_MENUBAR_H(ui)); if (config_raw.touch_ui) { diff --git a/base/sources/ui_nodes.ts b/base/sources/ui_nodes.ts index c4be2915..2ff21417 100644 --- a/base/sources/ui_nodes.ts +++ b/base/sources/ui_nodes.ts @@ -31,6 +31,9 @@ let ui_nodes_release_link: bool = false; let ui_nodes_is_node_menu_op: bool = false; let ui_nodes_grid: image_t = null; +let ui_nodes_grid_redraw: bool = true; +let ui_nodes_grid_cell_w: i32 = 200; +let ui_nodes_grid_small_cell_w: i32 = 40; let ui_nodes_hwnd: ui_handle_t = ui_handle_create(); let ui_nodes_group_stack: node_group_t[] = []; let ui_nodes_controls_down: bool = false; @@ -250,7 +253,7 @@ function ui_viewnodes_on_socket_released(socket_id: i32) { array_remove(node.outputs, socket); nodes_material_sync_sockets(node); } - }, 2); + }); }); } else ui_viewnodes_on_canvas_released(); @@ -291,13 +294,6 @@ function ui_viewnodes_on_canvas_released() { // Node context menu if (!ui_nodes_socket_released) { - let number_of_entries: i32 = 5; - if (ui_nodes_canvas_type == canvas_type_t.MATERIAL) { - ++number_of_entries; - } - if (selected != null && selected.type == "RGB") { - ++number_of_entries; - } _ui_nodes_on_canvas_released_selected = selected; @@ -370,7 +366,7 @@ function ui_viewnodes_on_canvas_released() { } ui_menu.enabled = true; - }, number_of_entries); + }); } } @@ -450,6 +446,9 @@ function ui_nodes_get_canvas_control(ui: ui_t, controls_down: bool): ui_canvas_c if (base_is_combo_selected()) { control.zoom = 0.0; } + if (control.zoom != 0.0) { + ui_nodes_grid_redraw = true; + } return control; } @@ -686,7 +685,7 @@ function ui_nodes_node_search(x: i32 = -1, y: i32 = -1, done: ()=>void = null) { search_handle.text = ""; } ui.ops.theme.BUTTON_COL = BUTTON_COL; - }, 8, x, y); + }, x, y); } function ui_nodes_get_node_x(): i32 { @@ -698,6 +697,9 @@ function ui_nodes_get_node_y(): i32 { } function ui_nodes_draw_grid() { + let ui_nodes: ui_nodes_t = ui_nodes_get_nodes(); + let zoom: f32 = ui_nodes.zoom; + let ww: i32 = config_raw.layout[layout_size_t.NODES_W]; ///if (is_paint || is_sculpt) @@ -707,21 +709,22 @@ function ui_nodes_draw_grid() { ///end let wh: i32 = app_h(); - let step: f32 = 100 * ui_SCALE(ui_nodes_ui); - let w: i32 = math_floor(ww + step * 3); - let h: i32 = math_floor(wh + step * 3); + let step: f32 = ui_nodes_grid_cell_w * zoom; + let w: i32 = math_floor(ww + step * 5); + let h: i32 = math_floor(wh + step * 5); if (w < 1) { w = 1; } if (h < 1) { h = 1; } + ui_nodes_grid = image_create_render_target(w, h); g2_begin(ui_nodes_grid); g2_clear(ui_nodes_ui.ops.theme.SEPARATOR_COL); g2_set_color(ui_nodes_ui.ops.theme.SEPARATOR_COL - 0x00050505); - step = 20 * ui_SCALE(ui_nodes_ui); + step = ui_nodes_grid_small_cell_w * zoom; for (let i: i32 = 0; i < math_floor(h / step) + 1; ++i) { g2_draw_line(0, i * step, w, i * step); } @@ -730,7 +733,7 @@ function ui_nodes_draw_grid() { } g2_set_color(ui_nodes_ui.ops.theme.SEPARATOR_COL - 0x00090909); - step = 100 * ui_SCALE(ui_nodes_ui); + step = ui_nodes_grid_cell_w * zoom; for (let i: i32 = 0; i < math_floor(h / step) + 1; ++i) { g2_draw_line(0, i * step, w, i * step); } @@ -822,7 +825,10 @@ function ui_nodes_render() { g2_end(); - if (ui_nodes_grid == null) { + if (ui_nodes_grid_redraw) { + if (ui_nodes_grid != null) { + image_unload(ui_nodes_grid); + } ui_nodes_draw_grid(); } @@ -877,9 +883,9 @@ function ui_nodes_render() { // Grid g2_set_color(0xffffffff); - let step: f32 = 100 * ui_SCALE(ui_nodes_ui); - let x: f32 = math_fmod(nodes.pan_x * ui_nodes_SCALE(), step) - step; - let y: f32 = math_fmod(nodes.pan_y * ui_nodes_SCALE(), step) - step; + let step: f32 = ui_nodes_grid_cell_w * nodes.zoom; + let x: f32 = math_fmod(ui_nodes_PAN_X(), step) - step; + let y: f32 = math_fmod(ui_nodes_PAN_Y(), step) - step; g2_draw_image(ui_nodes_grid, x, y); // Undo @@ -1146,8 +1152,6 @@ function ui_nodes_render() { ui_nodes_popup_x -= menuw / 2; ui_nodes_popup_x += ui_nodes_ui._w / 2; } - ui_menu_category_w = ui_nodes_ui._w; - ui_menu_category_h = math_floor(ui_MENUBAR_H(ui_nodes_ui)); } ui_nodes_ui._x += ui_nodes_ui._w + 3; ui_nodes_ui._y = 2 + start_y; @@ -1210,13 +1214,18 @@ function ui_nodes_render() { let py: i32 = ui_nodes_popup_y; let menuw: i32 = math_floor(ew * 2.3); ui_begin_region(ui_nodes_ui, math_floor(ui_nodes_popup_x), math_floor(py), menuw); - let _BUTTON_COL: i32 = ui_nodes_ui.ops.theme.BUTTON_COL; - ui_nodes_ui.ops.theme.BUTTON_COL = ui_nodes_ui.ops.theme.SEPARATOR_COL; + let _FILL_BUTTON_BG: i32 = ui_nodes_ui.ops.theme.FILL_BUTTON_BG; + ui_nodes_ui.ops.theme.FILL_BUTTON_BG = false; let _ELEMENT_OFFSET: i32 = ui_nodes_ui.ops.theme.ELEMENT_OFFSET; ui_nodes_ui.ops.theme.ELEMENT_OFFSET = 0; let _ELEMENT_H: i32 = ui_nodes_ui.ops.theme.ELEMENT_H; ui_nodes_ui.ops.theme.ELEMENT_H = config_raw.touch_ui ? (28 + 2) : 28; + ui_menu_h = category.length * ui_ELEMENT_H(ui_nodes_ui); + if (is_group_category) { + ui_menu_h += project_material_groups.length * ui_ELEMENT_H(ui_nodes_ui); + } + ui_menu_start(ui_nodes_ui); for (let i: i32 = 0; i < category.length; ++i) { @@ -1273,9 +1282,10 @@ function ui_nodes_render() { ui_nodes_hide_menu = ui_nodes_ui.combo_selected_handle == null && !ui_nodes_show_menu_first && (ui_nodes_ui.changed || ui_nodes_ui.input_released || ui_nodes_ui.input_released_r || ui_nodes_ui.is_escape_down); ui_nodes_show_menu_first = false; - ui_nodes_ui.ops.theme.BUTTON_COL = _BUTTON_COL; + ui_nodes_ui.ops.theme.FILL_BUTTON_BG = _FILL_BUTTON_BG; ui_nodes_ui.ops.theme.ELEMENT_OFFSET = _ELEMENT_OFFSET; ui_nodes_ui.ops.theme.ELEMENT_H = _ELEMENT_H; + ui_menu_end(ui_nodes_ui); ui_end_region(); } @@ -1448,7 +1458,9 @@ function ui_nodes_make_node(n: ui_node_t, nodes: ui_nodes_t, canvas: ui_node_can but.type = n.buttons[i].type; but.output = n.buttons[i].output; but.default_value = f32_array_create_from_array(n.buttons[i].default_value); - but.data = u8_array_create_from_array(n.buttons[i].data); + if (n.buttons[i].data != null) { + but.data = u8_array_create_from_array(n.buttons[i].data); + } but.min = n.buttons[i].min; but.max = n.buttons[i].max; but.precision = n.buttons[i].precision; diff --git a/base/sources/ui_toolbar.ts b/base/sources/ui_toolbar.ts index 33e46564..591ab897 100644 --- a/base/sources/ui_toolbar.ts +++ b/base/sources/ui_toolbar.ts @@ -213,17 +213,9 @@ function ui_toolbar_render_ui() { } } -let _ui_toolbar_tool_properties_menu_x: i32; -let _ui_toolbar_tool_properties_menu_y: i32; -let _ui_toolbar_tool_properties_menu_w: i32; - function ui_toolbar_tool_properties_menu() { let ui: ui_t = ui_base_ui; - _ui_toolbar_tool_properties_menu_x = ui._x; - _ui_toolbar_tool_properties_menu_y = ui._y; - _ui_toolbar_tool_properties_menu_w = ui._w; ui_menu_draw(function (ui: ui_t) { - let start_y: i32 = ui._y; ui.changed = false; ui_header_draw_tool_properties(ui); @@ -235,18 +227,7 @@ function ui_toolbar_tool_properties_menu() { if (ui_button(tr("Pin to Header"), ui_align_t.LEFT)) { config_raw.layout[layout_size_t.HEADER] = 1; } - - let h: i32 = ui._y - start_y; - ui_menu_elements = math_floor(h / ui_ELEMENT_H(ui)); - ui_menu_x = math_floor(_ui_toolbar_tool_properties_menu_x + _ui_toolbar_tool_properties_menu_w + 2); - ui_menu_y = math_floor(_ui_toolbar_tool_properties_menu_y - 6 * ui_SCALE(ui)); - ui_menu_fit_to_screen(); - - }, 0); - - // First draw out of screen, then align the menu based on menu height - ui_menu_x = -sys_width(); - ui_menu_y = -sys_height(); + }, math_floor(ui._x + ui._w + 2), math_floor(ui._y - 6 * ui_SCALE(ui))); } function ui_toolbar_draw_highlight() { diff --git a/base/tools/pad/sources/main.ts b/base/tools/pad/sources/main.ts index 28beb4da..37978000 100644 --- a/base/tools/pad/sources/main.ts +++ b/base/tools/pad/sources/main.ts @@ -161,15 +161,15 @@ function render() { ui_begin(ui); if (ui_window(sidebar_handle, 0, 0, storage.sidebar_w, sys_height(), false)) { - let _BUTTON_TEXT_COL: i32 = theme.BUTTON_TEXT_COL; - theme.BUTTON_TEXT_COL = theme.ACCENT_COL; + let _TEXT_COL: i32 = theme.TEXT_COL; + theme.TEXT_COL = theme.BUTTON_COL; if (storage.project != "") { list_folder(storage.project); } else { ui_button("Drop folder here", UI_ALIGN_LEFT, ""); } - theme.BUTTON_TEXT_COL = _BUTTON_TEXT_COL; + theme.TEXT_COL = _TEXT_COL; } ui_fill(sys_width() - minimap_w, 0, minimap_w, UI_ELEMENT_H() + UI_ELEMENT_OFFSET() + 1, theme.SEPARATOR_COL);