Improve browser layout
This commit is contained in:
@@ -70,6 +70,9 @@ function box_projects_tab(ui: ui_t) {
|
||||
|
||||
let slotw: i32 = math_floor(150 * ui_SCALE(ui));
|
||||
let num: i32 = math_floor(sys_width() / slotw);
|
||||
if (num == 0) {
|
||||
return;
|
||||
}
|
||||
let recent_projects: string[] = config_raw.recent_projects;
|
||||
let show_asset_names: bool = true;
|
||||
|
||||
|
||||
@@ -33,14 +33,15 @@ 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.73, step * 0.07, step * 0.17, step * 0.03];
|
||||
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.73, step * 0.07, step * 0.2];
|
||||
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
|
||||
@@ -53,6 +54,32 @@ function tab_browser_draw(htab: ui_handle_t) {
|
||||
ui_tooltip(tr("Add bookmark"));
|
||||
}
|
||||
|
||||
// Refresh
|
||||
let refresh: bool = false;
|
||||
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)) {
|
||||
refresh = true;
|
||||
}
|
||||
|
||||
// Previous folder
|
||||
let text: string = tab_browser_hpath.text;
|
||||
let i1: i32 = string_index_of(text, path_sep);
|
||||
let nested: bool = i1 > -1 && text.length - 1 > i1;
|
||||
///if arm_windows
|
||||
// Server addresses like \\server are not nested
|
||||
nested = nested && !(text.length >= 2 && char_at(text, 0) == path_sep && char_at(text, 1) == path_sep && string_last_index_of(text, path_sep) == 1);
|
||||
///end
|
||||
|
||||
ui.enabled = nested;
|
||||
if (ui_button("<")) {
|
||||
ui_files_go_up(tab_browser_hpath);
|
||||
}
|
||||
ui.enabled = true;
|
||||
if (ui.is_hovered) {
|
||||
ui_tooltip(tr("Previous folder"));
|
||||
}
|
||||
|
||||
///if arm_android
|
||||
let stripped: bool = false;
|
||||
let strip: string = "/storage/emulated/0/";
|
||||
@@ -70,12 +97,6 @@ function tab_browser_draw(htab: ui_handle_t) {
|
||||
}
|
||||
///end
|
||||
|
||||
let refresh: bool = false;
|
||||
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)) {
|
||||
refresh = true;
|
||||
}
|
||||
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"));
|
||||
|
||||
@@ -24,6 +24,9 @@ function tab_brushes_draw(htab: ui_handle_t) {
|
||||
|
||||
let slotw: i32 = math_floor(51 * ui_SCALE(ui));
|
||||
let num: i32 = math_floor(config_raw.layout[layout_size_t.SIDEBAR_W] / slotw);
|
||||
if (num == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let row: i32 = 0; row < math_floor(math_ceil(project_brushes.length / num)); ++row) {
|
||||
let mult: i32 = config_raw.show_asset_names ? 2 : 1;
|
||||
|
||||
@@ -32,6 +32,9 @@ function tab_fonts_draw(htab: ui_handle_t) {
|
||||
let statusw: i32 = sys_width() - ui_toolbar_w - config_raw.layout[layout_size_t.SIDEBAR_W];
|
||||
let slotw: i32 = math_floor(51 * ui_SCALE(ui));
|
||||
let num: i32 = math_floor(statusw / slotw);
|
||||
if (num == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let row: i32 = 0; row < math_floor(math_ceil(project_fonts.length / num)); ++row) {
|
||||
let mult: i32 = config_raw.show_asset_names ? 2 : 1;
|
||||
|
||||
@@ -82,6 +82,9 @@ function tab_swatches_draw(htab: ui_handle_t) {
|
||||
|
||||
let slotw: i32 = math_floor(26 * ui_SCALE(ui));
|
||||
let num: i32 = math_floor(ui._w / (slotw + 3));
|
||||
if (num == 0) {
|
||||
return;
|
||||
}
|
||||
let drag_pos_set: bool = false;
|
||||
|
||||
let uix: f32 = 0.0;
|
||||
|
||||
@@ -48,6 +48,9 @@ function tab_textures_draw(htab: ui_handle_t) {
|
||||
|
||||
let slotw: i32 = math_floor(52 * ui_SCALE(ui));
|
||||
let num: i32 = math_floor(statusw / slotw);
|
||||
if (num == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
for (let row: i32 = 0; row < math_floor(math_ceil(project_assets.length / num)); ++row) {
|
||||
let mult: i32 = config_raw.show_asset_names ? 2 : 1;
|
||||
|
||||
+12
-13
@@ -103,19 +103,7 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool =
|
||||
if (handle.text != ui_files_last_path || search != ui_files_last_search || refresh) {
|
||||
ui_files_files = [];
|
||||
|
||||
// Up directory
|
||||
let text: string = handle.text;
|
||||
let i1: i32 = string_index_of(text, path_sep);
|
||||
let nested: bool = i1 > -1 && text.length - 1 > i1;
|
||||
///if arm_windows
|
||||
// Server addresses like \\server are not nested
|
||||
nested = nested && !(text.length >= 2 && char_at(text, 0) == path_sep && char_at(text, 1) == path_sep && string_last_index_of(text, path_sep) == 1);
|
||||
///end
|
||||
if (nested) {
|
||||
array_push(ui_files_files, "..");
|
||||
}
|
||||
|
||||
let dir_path: string = text;
|
||||
let dir_path: string = handle.text;
|
||||
///if arm_ios
|
||||
if (!is_cloud) {
|
||||
dir_path = document_directory + dir_path;
|
||||
@@ -146,6 +134,9 @@ function ui_files_file_browser(ui: ui_t, handle: ui_handle_t, drag_files: bool =
|
||||
|
||||
let slotw: i32 = math_floor(70 * ui_SCALE(ui));
|
||||
let num: i32 = math_floor(ui._w / slotw);
|
||||
if (num == 0) {
|
||||
return handle.text;
|
||||
}
|
||||
|
||||
ui._y += 4; // Don't cut off the border around selected materials
|
||||
// Directory contents
|
||||
@@ -445,6 +436,14 @@ function ui_files_make_icon (args: ui_files_make_icon_t) {
|
||||
data_delete_image(args.shandle); // The big image is not needed anymore
|
||||
}
|
||||
|
||||
function ui_files_go_up(handle: ui_handle_t) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
type ui_files_make_icon_t = {
|
||||
image: image_t;
|
||||
shandle: string;
|
||||
|
||||
Reference in New Issue
Block a user