This commit is contained in:
luboslenco
2025-09-08 15:15:40 +02:00
parent 01bc405878
commit fb23a24566
5 changed files with 6 additions and 122 deletions
-90
View File
@@ -2565,9 +2565,6 @@ void ui_theme_default(ui_theme_t *t) {
}
#define MATH_PI 3.14159265358979323846
static char data_path[128] = "";
static char last_path[512];
static ui_handle_t *wheel_selected_handle = NULL;
static ui_handle_t *gradient_selected_handle = NULL;
static ui_handle_t radio_handle;
@@ -2641,93 +2638,6 @@ float ui_float_input(ui_handle_t *handle, char *label, int align, float precisio
return handle->value;
}
void ui_init_path(ui_handle_t *handle, const char *system_id) {
strcpy(handle->text, strcmp(system_id, "Windows") == 0 ? "C:\\Users" : "/");
// %HOMEDRIVE% + %HomePath%
// ~
}
char *ui_file_browser(ui_handle_t *handle, bool folders_only) {
ui_t *current = ui_get_current();
const char *sep = "/";
char cmd[64];
strcpy(cmd, "ls ");
const char *system_id = iron_system_id();
if (strcmp(system_id, "Windows") == 0) {
strcpy(cmd, "dir /b ");
if (folders_only) {
strcat(cmd, "/ad ");
}
sep = "\\";
handle->text = string_replace_all(handle->text, "\\\\", "\\");
handle->text = string_replace_all(handle->text, "\r", "");
}
if (handle->text[0] == '\0') {
ui_init_path(handle, system_id);
}
char save[256];
strcpy(save, iron_internal_get_files_location());
strcat(save, sep);
strcat(save, data_path);
strcat(save, "dir.txt");
if (strcmp(handle->text, last_path) != 0) {
char str[512];
strcpy(str, cmd);
strcat(str, "\"");
strcat(str, handle->text);
strcat(str, "\" > \"");
strcat(str, save);
strcat(str, "\"");
}
strcpy(last_path, handle->text);
iron_file_reader_t reader;
if (!iron_file_reader_open(&reader, save, IRON_FILE_TYPE_ASSET)) {
return NULL;
}
int reader_size = (int)iron_file_reader_size(&reader);
char str[2048]; // reader_size
iron_file_reader_read(&reader, str, reader_size);
iron_file_reader_close(&reader);
// Up directory
int i1 = strstr(handle->text, "/") - handle->text;
int i2 = strstr(handle->text, "\\") - handle->text;
bool nested =
(i1 > -1 && strlen(handle->text) - 1 > i1) ||
(i2 > -1 && strlen(handle->text) - 1 > i2);
handle->changed = false;
if (nested && ui_button("..", UI_ALIGN_LEFT, "")) {
handle->changed = current->changed = true;
handle->text[strrchr(handle->text, sep[0]) - handle->text] = 0;
// Drive root
if (strlen(handle->text) == 2 && handle->text[1] == ':') {
strcat(handle->text, sep);
}
}
// Directory contents
int count = ui_line_count(str);
for (int i = 0; i < count; ++i) {
char *f = ui_extract_line(str, i);
if (f[0] == '\0' || f[0] == '.') {
continue; // Skip hidden
}
if (ui_button(f, UI_ALIGN_LEFT, "")) {
handle->changed = current->changed = true;
if (handle->text[strlen(handle->text) - 1] != sep[0]) {
strcat(handle->text, sep);
}
strcat(handle->text, f);
}
}
return handle->text;
}
int ui_inline_radio(ui_handle_t *handle, char_ptr_array_t *texts, int align) {
ui_t *current = ui_get_current();
-1
View File
@@ -377,7 +377,6 @@ extern const char *ui_theme_keys[];
extern int ui_theme_keys_count;
float ui_float_input(ui_handle_t *handle, char *label, int align, float precision);
char *ui_file_browser(ui_handle_t *handle, bool folders_only);
int ui_inline_radio(ui_handle_t *handle, char_ptr_array_t *texts, int align);
int ui_color_wheel(ui_handle_t *handle, bool alpha, float w, float h, bool color_preview, void (*picker)(void *), void *data);
char *ui_text_area(ui_handle_t *handle, int align, bool editable, char *label, bool word_wrap);
+1 -6
View File
@@ -136,11 +136,6 @@ function file_download_bytes(url: string, done: (url: string, ab: buffer_t)=>voi
}
function file_cache_cloud(path: string, done: (s: string)=>void) {
///if arm_ios
let path2: string = string_replace_all(path, "/", "_"); // Cache everything into root folder
///else
let path2: string = path;
///end
let dest: string;
if (path_is_protected()) {
dest = iron_internal_save_path();
@@ -148,7 +143,7 @@ function file_cache_cloud(path: string, done: (s: string)=>void) {
else {
dest = iron_get_files_location() + path_sep;
}
dest += path2;
dest += path;
if (iron_file_exists(dest)) {
///if (arm_macos || arm_ios)
-4
View File
@@ -120,10 +120,6 @@ function tab_browser_draw(htab: ui_handle_t) {
ui_files_file_browser(tab_browser_hpath, true, tab_browser_hsearch.text, refresh, function (file: string) {
let file_name: string = substring(file, string_last_index_of(file, path_sep) + 1, file.length);
if (file_name == "..") {
return;
}
_tab_browser_draw_file = file;
// Context menu
+5 -21
View File
@@ -175,7 +175,7 @@ function ui_files_file_browser(handle: ui_handle_t, drag_files: bool = false, se
let generic: bool = true;
let icon: gpu_texture_t = null;
if (is_cloud && f != ".." && !ui_files_offline) {
if (is_cloud && !ui_files_offline) {
if (ui_files_icon_map == null) {
ui_files_icon_map = map_create();
}
@@ -194,14 +194,7 @@ function ui_files_file_browser(handle: ui_handle_t, drag_files: bool = false, se
map_set(ui_files_icon_map, handle.text + path_sep + f, empty);
_ui_files_file_browser_handle = handle;
///if arm_ios
let icon_file_full: string = handle.text + path_sep + icon_file;
icon_file_full = string_replace_all(icon_file_full, "/", "_");
map_set(ui_files_icon_file_map, icon_file_full, f);
///else
map_set(ui_files_icon_file_map, icon_file, f);
///end
file_cache_cloud(handle.text + path_sep + icon_file, function (abs: string) {
if (abs != null) {
@@ -345,7 +338,7 @@ function ui_files_file_browser(handle: ui_handle_t, drag_files: bool = false, se
}
if (state == ui_state_t.STARTED) {
if (f != ".." && drag_files) {
if (drag_files) {
base_drag_off_x = -(mouse_x - uix - ui._window_x - 3);
base_drag_off_y = -(mouse_y - uiy - ui._window_y + 1);
base_drag_file = handle.text;
@@ -367,19 +360,10 @@ function ui_files_file_browser(handle: ui_handle_t, drag_files: bool = false, se
base_drag_file_icon = null;
base_is_dragging = false;
handle.changed = ui.changed = true;
if (f == "..") { // Up
handle.text = substring(handle.text, 0, string_last_index_of(handle.text, path_sep));
// Drive root
if (handle.text.length == 2 && char_at(handle.text, 1) == ":") {
handle.text += path_sep;
}
}
else {
if (char_at(handle.text, handle.text.length - 1) != path_sep) {
handle.text += path_sep;
}
handle.text += f;
if (char_at(handle.text, handle.text.length - 1) != path_sep) {
handle.text += path_sep;
}
handle.text += f;
ui_files_selected = -1;
}
context_raw.select_time = sys_time();