Update icons

This commit is contained in:
luboslenco
2026-01-07 20:33:04 +01:00
parent ea6aafd759
commit 822f2b87b8
18 changed files with 95 additions and 50 deletions
+6 -9
View File
@@ -45,7 +45,7 @@ function tab_browser_draw(htab: ui_handle_t) {
}
// Bookmark
if (ui_button("+")) {
if (ui_icon_button(tr("Bookmark"), icon_t.PLUS, ui_align_t.LEFT)) {
let bookmark: string = tab_browser_hpath.text;
/// if arm_windows
bookmark = string_replace_all(bookmark, "\\", "/");
@@ -53,14 +53,11 @@ function tab_browser_draw(htab: ui_handle_t) {
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)) {
if (ui_icon_button(tr("Refresh"), icon_t.REFRESH) || (in_focus && ui.is_key_pressed && ui.key_code == key_code_t.F5)) {
tab_browser_refresh = true;
}
}
@@ -80,7 +77,7 @@ function tab_browser_draw(htab: ui_handle_t) {
/// end
ui.enabled = nested;
if (ui_button("<")) {
if (ui_icon_button("", icon_t.CHEVRON_LEFT)) {
ui_files_go_up(tab_browser_hpath);
}
ui.enabled = true;
@@ -236,11 +233,11 @@ function tab_browser_draw(htab: ui_handle_t) {
ui._y = _y;
ui._w = bookmarks_w;
if (ui_button(tr("Cloud"), ui_align_t.LEFT)) {
if (ui_icon_button(tr("Cloud"), icon_t.CLOUD, ui_align_t.LEFT)) {
tab_browser_hpath.text = "cloud";
}
if (ui_button(tr("Disk"), ui_align_t.LEFT)) {
if (ui_icon_button(tr("Disk"), icon_t.STORAGE, ui_align_t.LEFT)) {
/// if arm_android
ui_menu_draw(function() {
if (ui_menu_button(tr("Download"), "", icon_t.FOLDER)) {
@@ -265,7 +262,7 @@ function tab_browser_draw(htab: ui_handle_t) {
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)) {
if (ui_icon_button(folder, icon_t.FOLDER)) {
tab_browser_hpath.text = b;
/// if arm_windows
tab_browser_hpath.text = string_replace_all(tab_browser_hpath.text, "/", "\\");
+2 -2
View File
@@ -6,13 +6,13 @@ function tab_brushes_draw(htab: ui_handle_t) {
ui_begin_sticky();
let row: f32[] = [ -70, -70, -70 ];
ui_row(row);
if (ui_button(tr("New"))) {
if (ui_icon_button(tr("New"), icon_t.PLUS)) {
context_raw.brush = slot_brush_create();
array_push(project_brushes, context_raw.brush);
make_material_parse_brush();
ui_nodes_hwnd.redraws = 2;
}
if (ui_button(tr("Import"))) {
if (ui_icon_button(tr("Import"), icon_t.IMPORT)) {
project_import_brush();
}
if (ui_button(tr("Nodes"))) {
+3 -3
View File
@@ -13,10 +13,10 @@ function tab_console_draw(htab: ui_handle_t) {
/// end
ui_row(row);
if (ui_button(tr("Clear"))) {
if (ui_icon_button(tr("Clear"), icon_t.ERASE)) {
console_last_traces = [];
}
if (ui_button(tr("Export"))) {
if (ui_icon_button(tr("Export"), icon_t.EXPORT)) {
ui_files_show("txt", true, false, function(path: string) {
let str: string = string_array_join(console_last_traces, "\n");
let f: string = ui_files_filename;
@@ -31,7 +31,7 @@ function tab_console_draw(htab: ui_handle_t) {
});
}
/// if (arm_windows || arm_linux || arm_macos)
if (ui_button(tr("Copy"))) {
if (ui_icon_button(tr("Copy"), icon_t.COPY)) {
let str: string = string_array_join(console_last_traces, "\n");
iron_copy_to_clipboard(str);
}
+2 -2
View File
@@ -8,14 +8,14 @@ function tab_fonts_draw(htab: ui_handle_t) {
let row: f32[] = [ -100, -100 ];
ui_row(row);
if (ui_button(tr("Import"))) {
if (ui_icon_button(tr("Import"), icon_t.IMPORT)) {
project_import_asset("ttf,ttc,otf");
}
if (ui.is_hovered) {
ui_tooltip(tr("Import font file"));
}
if (ui_button(tr("2D View"))) {
if (ui_icon_button(tr("2D View"), icon_t.WINDOW)) {
ui_base_show_2d_view(view_2d_type_t.FONT);
}
ui_end_sticky();
+2 -2
View File
@@ -21,7 +21,7 @@ function tab_layers_draw_mini(htab: ui_handle_t) {
tab_layers_combo_filter();
tab_layers_button_2d_view();
tab_layers_button_new("+");
tab_layers_button_new("");
ui_end_sticky();
ui._y += 2;
@@ -81,7 +81,7 @@ function tab_layers_highlight_odd_lines() {
}
function tab_layers_button_new(text: string) {
if (ui_button(text)) {
if (ui_icon_button(text, icon_t.PLUS)) {
ui_menu_draw(function() {
let l: slot_layer_t = context_raw.layer;
if (ui_menu_button(tr("Paint Layer"), "", icon_t.PAINT)) {
+3 -3
View File
@@ -13,7 +13,7 @@ function tab_materials_draw_mini(htab: ui_handle_t) {
ui_separator(5);
tab_materials_button_nodes();
tab_materials_button_new("+");
tab_materials_button_new("");
ui_end_sticky();
ui_separator(3, false);
@@ -27,7 +27,7 @@ function tab_materials_draw_full(htab: ui_handle_t) {
ui_row(row);
tab_materials_button_new(tr("New"));
if (ui_button(tr("Import"))) {
if (ui_icon_button(tr("Import"), icon_t.IMPORT)) {
project_import_material();
}
tab_materials_button_nodes();
@@ -292,7 +292,7 @@ function tab_materials_draw_slots(mini: bool) {
}
function tab_materials_button_new(text: string) {
if (ui_button(text)) {
if (ui_icon_button(text, icon_t.PLUS)) {
sys_notify_on_next_frame(function() {
context_raw.material = slot_material_create(project_materials[0].data);
array_push(project_materials, context_raw.material);
+2 -2
View File
@@ -8,7 +8,7 @@ function tab_meshes_draw(htab: ui_handle_t) {
let row: f32[] = [ -100, -100 ];
ui_row(row);
if (ui_button(tr("Import"))) {
if (ui_icon_button(tr("Import"), icon_t.IMPORT)) {
ui_menu_draw(function() {
if (ui_menu_button(tr("Replace Existing"), map_get(config_keymap, "file_import_assets"))) {
project_import_mesh(true);
@@ -34,7 +34,7 @@ function tab_meshes_draw(htab: ui_handle_t) {
if (ui.is_hovered)
ui_tooltip(tr("Import mesh file"));
if (ui_button(tr("Edit"))) {
if (ui_icon_button(tr("Edit"), icon_t.EDIT)) {
ui_menu_draw(function() {
if (ui_menu_button(tr("Flip Normals"))) {
+2 -2
View File
@@ -4,10 +4,10 @@ function tab_plugins_draw(htab: ui_handle_t) {
ui_begin_sticky();
let row: f32[] = [ -70 ];
let row: f32[] = [ -100 ];
ui_row(row);
if (ui_button(tr("Manager"))) {
if (ui_icon_button(tr("Preferences"), icon_t.COG)) {
box_preferences_htab.i = preference_tab_t.PLUGINS;
box_preferences_show();
}
+2 -2
View File
@@ -9,11 +9,11 @@ function tab_scripts_draw(htab: ui_handle_t) {
let row: f32[] = [ -70, -70, -140 ];
ui_row(row);
if (ui_button(tr("Run"))) {
if (ui_icon_button(tr("Run"), icon_t.PLAY)) {
js_eval(tab_scripts_hscript.text);
}
if (ui_button(tr("Edit"))) {
if (ui_icon_button(tr("Edit"), icon_t.EDIT)) {
ui_menu_draw(function() {
if (ui_menu_button(tr("Clear"), "", icon_t.ERASE)) {
+5 -5
View File
@@ -26,7 +26,7 @@ function tab_swatches_draw(htab: ui_handle_t) {
let row: f32[] = [ -100, -100, -100, -100, -100 ];
ui_row(row);
if (ui_button(tr("New"))) {
if (ui_icon_button(tr("New"), icon_t.PLUS)) {
context_set_swatch(make_swatch());
array_push(project_raw.swatches, context_raw.swatch);
}
@@ -34,7 +34,7 @@ function tab_swatches_draw(htab: ui_handle_t) {
ui_tooltip(tr("Add new swatch"));
}
if (ui_button(tr("Import"))) {
if (ui_icon_button(tr("Import"), icon_t.IMPORT)) {
ui_menu_draw(function() {
if (ui_menu_button(tr("Replace Existing"))) {
project_import_swatches(true);
@@ -49,19 +49,19 @@ function tab_swatches_draw(htab: ui_handle_t) {
ui_tooltip(tr("Import swatches"));
}
if (ui_button(tr("Export"))) {
if (ui_icon_button(tr("Export"), icon_t.EXPORT)) {
project_export_swatches();
}
if (ui.is_hovered) {
ui_tooltip(tr("Export swatches"));
}
if (ui_button(tr("Clear"))) {
if (ui_icon_button(tr("Clear"), icon_t.ERASE)) {
context_set_swatch(make_swatch());
project_raw.swatches = [ context_raw.swatch ];
}
if (ui_button(tr("Restore"))) {
if (ui_icon_button(tr("Restore"), icon_t.REPLAY)) {
project_set_default_swatches();
context_set_swatch(project_raw.swatches[0]);
}
+2 -2
View File
@@ -14,7 +14,7 @@ function tab_textures_draw(htab: ui_handle_t) {
let row: f32[] = [ -100, -100 ];
ui_row(row);
if (ui_button(tr("Import"))) {
if (ui_icon_button(tr("Import"), icon_t.IMPORT)) {
ui_files_show(string_array_join(path_texture_formats, ","), false, true, function(path: string) {
import_asset_run(path, -1.0, -1.0, true, false);
ui_base_hwnds[tab_area_t.STATUS].redraws = 2;
@@ -24,7 +24,7 @@ function tab_textures_draw(htab: ui_handle_t) {
ui_tooltip(tr("Import texture file") + " (" + map_get(config_keymap, "file_import_assets") + ")");
}
if (ui_button(tr("2D View"))) {
if (ui_icon_button(tr("2D View"), icon_t.WINDOW)) {
ui_base_show_2d_view(view_2d_type_t.ASSET);
}
+9 -6
View File
@@ -81,6 +81,7 @@ function ui_files_file_browser(handle: ui_handle_t, drag_files: bool = false, se
let icons: gpu_texture_t = resource_get("icons.k");
let folder: rect_t = resource_tile50(icons, icon_t.FOLDER_FULL);
let file: rect_t = resource_tile50(icons, icon_t.FILE);
let downloading: rect_t = resource_tile50(icons, icon_t.DOWNLOADING);
let is_cloud: bool = starts_with(handle.text, "cloud");
if (is_cloud && file_cloud == null) {
@@ -164,6 +165,9 @@ function ui_files_file_browser(handle: ui_handle_t, drag_files: bool = false, se
let _x: f32 = ui._x;
let rect: rect_t = string_index_of(f, ".") > 0 ? file : folder;
if (rect == file && is_cloud) {
rect = downloading;
}
let col: i32 = rect == file ? ui.ops.theme.LABEL_COL : ui.ops.theme.LABEL_COL - 0x00202020;
if (ui_files_selected == i)
col = ui.ops.theme.HIGHLIGHT_COL;
@@ -191,9 +195,7 @@ function ui_files_file_browser(handle: ui_handle_t, drag_files: bool = false, se
let files_all: string[] = file_read_directory(handle.text);
let icon_file: string = substring(f, 0, dot) + "_icon.jpg";
if (array_index_of(files_all, icon_file) >= 0) {
let rt: render_target_t = map_get(render_path_render_targets, "empty_black");
let empty: gpu_texture_t = rt._image;
map_set(ui_files_icon_map, handle.text + path_sep + f, empty);
map_set(ui_files_icon_map, handle.text + path_sep + f, icons);
_ui_files_file_browser_handle = handle;
map_set(ui_files_icon_file_map, icon_file, f);
@@ -235,7 +237,7 @@ function ui_files_file_browser(handle: ui_handle_t, drag_files: bool = false, se
}
}
}
if (icon != null) {
if (icon != null && icon != icons) {
let w: i32 = 50;
if (i == ui_files_selected) {
ui_fill(-2, -2, w + 4, 2, ui.ops.theme.HIGHLIGHT_COL);
@@ -251,13 +253,14 @@ function ui_files_file_browser(handle: ui_handle_t, drag_files: bool = false, se
generic = false;
}
}
if (ends_with(f, ".arm") && !is_cloud) {
if (ui_files_icon_map == null) {
ui_files_icon_map = map_create();
}
let key: string = handle.text + path_sep + f;
icon = map_get(ui_files_icon_map, key);
if (map_get(ui_files_icon_map, key) == null) {
if (icon == null) {
let blob_path: string = key;
/// if arm_ios
@@ -280,7 +283,7 @@ function ui_files_file_browser(handle: ui_handle_t, drag_files: bool = false, se
/// else
let buf: buffer_t = lz4_decode(bytes_icon, 256 * 256 * 8);
/// end
icon = gpu_create_texture_from_bytes(buf, 256, 256, gpu_texture_format_t.RGBA64);
icon = gpu_create_texture_from_bytes(buf, 256, 256, gpu_texture_format_t.RGBA64);
}
else if (raw.mesh_icons != null) {
let bytes_icon: buffer_t = raw.mesh_icons[0];
+48 -3
View File
@@ -126,19 +126,64 @@ function ui_menu_button(text: string, label: string = "", icon: icon_t = icon_t.
let result: bool = ui_button(config_button_spacing + text, config_button_align, label);
if (icon != icon_t.NONE) {
let _y_bottom: i32 = ui._y;
let _y_bottom: i32 = ui._y;
let icons: gpu_texture_t = resource_get("icons05x.k");
let folder: rect_t = resource_tile50(icons, icon);
let rect: rect_t = resource_tile50(icons, icon);
let icon_h: i32 = 25 * UI_SCALE();
ui._y = _y_top - 1;
ui._x -= 5 * UI_SCALE();
ui_sub_image(icons, ui.ops.theme.LABEL_COL - 0x00222222, icon_h, folder.x / 2, folder.y / 2, folder.w / 2, folder.h / 2);
ui_sub_image(icons, ui.ops.theme.LABEL_COL - 0x00222222, icon_h, rect.x / 2, rect.y / 2, rect.w / 2, rect.h / 2);
ui._x += 5 * UI_SCALE();
ui._y = _y_bottom;
}
return result;
}
function ui_icon_button(text: string, icon: icon_t = icon_t.NONE, align: ui_align_t = ui_align_t.CENTER): bool {
let _x_left: i32 = ui._x;
let _y_top: i32 = ui._y;
let _w: i32 = ui._w;
if (text != "") {
text = align == ui_align_t.LEFT ? " " + text : " " + text;
}
let tooltip: string = "";
let textw: i32 = draw_string_width(ui.ops.font, ui.font_size, text);
if (textw > _w * 0.8) {
tooltip = text;
text = "";
textw = 0;
}
let result: bool = ui_button(text, align);
if (ui.is_hovered && tooltip != "") {
ui_tooltip(tooltip);
}
if (icon != icon_t.NONE) {
let _x_right: i32 = ui._x;
let _y_bottom: i32 = ui._y;
let icons: gpu_texture_t = resource_get("icons05x.k");
let rect: rect_t = resource_tile50(icons, icon);
let icon_h: i32 = 25 * UI_SCALE();
ui._x = align == ui_align_t.LEFT ? _x_left : _x_left + _w / 2 - textw / 2 - icon_h / 2;
ui._y = _y_top - 1;
if (ui.current_ratio > -1) {
ui.current_ratio--;
}
ui.image_scroll_align = false;
ui_sub_image(icons, ui.enabled ? ui.ops.theme.LABEL_COL - 0x00333333 : 0xffffffff, icon_h, rect.x / 2, rect.y / 2, rect.w / 2, rect.h / 2);
ui.image_scroll_align = true;
ui._x = _x_right;
ui._y = _y_bottom;
}
return result;
}
function ui_menu_sub_button(handle: ui_handle_t, text: string): bool {
ui.is_hovered = false;
ui_menu_button(text, ">");
+1 -1
View File
@@ -117,7 +117,7 @@ function ui_menubar_render_ui() {
else {
let categories: string[] = [ tr("File"), tr("Edit"), tr("Viewport"), tr("Mode"), tr("Camera"), tr("Help") ];
for (let i: i32 = 0; i < categories.length; ++i) {
if (_ui_menu_button(categories[i]) || (ui_menu_show && ui_menu_commands == ui_menubar_draw_category_items && ui.is_hovered)) {
if (ui_menubar_button(categories[i]) || (ui_menu_show && ui_menu_commands == ui_menubar_draw_category_items && ui.is_hovered)) {
ui_menubar_show_menu(i);
}
}
+3 -3
View File
@@ -1234,7 +1234,7 @@ function ui_nodes_draw_menubar() {
let cats: string[] = ui_nodes_canvas_type == canvas_type_t.MATERIAL ? nodes_material_categories : nodes_brush_categories;
for (let i: i32 = 0; i < cats.length; ++i) {
if ((_ui_menu_button(tr(cats[i]))) || (ui.is_hovered && ui_nodes_show_menu)) {
if ((ui_menubar_button(tr(cats[i]))) || (ui.is_hovered && ui_nodes_show_menu)) {
ui_nodes_show_menu = true;
ui_nodes_menu_category = i;
ui_nodes_popup_x = ui_nodes_wx + ui._x;
@@ -1260,7 +1260,7 @@ function ui_nodes_draw_menubar() {
ui._w = _w;
}
else {
if (_ui_menu_button(tr("Search"))) {
if (ui_menubar_button(tr("Search"))) {
ui_nodes_node_search_x = ui._window_x + ui._x;
ui_nodes_node_search_y = ui._window_y + ui._y;
// Allow for node menu to be closed first
@@ -1278,7 +1278,7 @@ function ui_nodes_draw_menubar() {
ui.ops.theme.BUTTON_COL = _BUTTON_COL;
// Close node group
if (ui_nodes_group_stack.length > 0 && _ui_menu_button(tr("Close"))) {
if (ui_nodes_group_stack.length > 0 && ui_menubar_button(tr("Close"))) {
array_pop(ui_nodes_group_stack);
}
}