Skip to content

Commit 7b69b89

Browse files
committed
Improve layout in tabs
1 parent 1e13062 commit 7b69b89

File tree

13 files changed

+129
-162
lines changed

13 files changed

+129
-162
lines changed

paint/sources/base.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -679,10 +679,7 @@ function base_redraw_status() {
679679
}
680680

681681
function base_redraw_console() {
682-
let statush: i32 = config_raw.layout[layout_size_t.STATUS_H];
683-
if (ui != null && statush > ui_statusbar_default_h * UI_SCALE()) {
684-
ui_base_hwnds[tab_area_t.STATUS].redraws = 2;
685-
}
682+
ui_base_hwnds[tab_area_t.STATUS].redraws = 2;
686683
}
687684

688685
function base_init_undo_layers() {

paint/sources/box_export.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ function box_export_tab_presets() {
285285
box_export_save_preset();
286286
}
287287

288-
row = [ 1 / 8 ];
288+
row = [ 1 / 6 ];
289289
ui_row(row);
290290
if (ui_button(tr("Add"))) {
291291
let tex: export_preset_texture_t = {name : "base", channels : [ "base_r", "base_g", "base_b", "1.0" ], color_space : "linear"};

paint/sources/tab_browser.ts

Lines changed: 99 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,14 @@ function tab_browser_show_directory(directory: string) {
1515
}
1616

1717
function tab_browser_draw(htab: ui_handle_t) {
18-
let statush: i32 = config_raw.layout[layout_size_t.STATUS_H];
19-
if (ui_tab(htab, tr("Browser")) && statush > ui_statusbar_default_h * UI_SCALE()) {
18+
if (ui_tab(htab, tr("Browser")) && ui._window_h > ui_statusbar_default_h * UI_SCALE()) {
2019

2120
if (config_raw.bookmarks == null) {
2221
config_raw.bookmarks = [];
2322
}
2423

2524
let bookmarks_w: i32 = math_floor(100 * UI_SCALE());
25+
let show_full: bool = ui._w > (500 * UI_SCALE());
2626

2727
if (tab_browser_hpath.text == "" && config_raw.bookmarks.length > 0) { // Init to first bookmark
2828
tab_browser_hpath.text = config_raw.bookmarks[0];
@@ -32,36 +32,44 @@ function tab_browser_draw(htab: ui_handle_t) {
3232
}
3333

3434
ui_begin_sticky();
35-
let step: f32 = (1.0 - bookmarks_w / ui._w);
36-
if (tab_browser_hsearch.text != "") {
37-
let row: f32[] = [ bookmarks_w / ui._w, step * 0.07, step * 0.07, step * 0.66, step * 0.17, step * 0.03 ];
38-
ui_row(row);
35+
36+
if (show_full) {
37+
let step: f32 = (1.0 - bookmarks_w / ui._w);
38+
if (tab_browser_hsearch.text != "") {
39+
let row: f32[] = [ bookmarks_w / ui._w, step * 0.07, step * 0.07, step * 0.66, step * 0.17, step * 0.03 ];
40+
ui_row(row);
41+
}
42+
else {
43+
let row: f32[] = [ bookmarks_w / ui._w, step * 0.07, step * 0.07, step * 0.66, step * 0.2 ];
44+
ui_row(row);
45+
}
46+
47+
// Bookmark
48+
if (ui_button("+")) {
49+
let bookmark: string = tab_browser_hpath.text;
50+
/// if arm_windows
51+
bookmark = string_replace_all(bookmark, "\\", "/");
52+
/// end
53+
array_push(config_raw.bookmarks, bookmark);
54+
config_save();
55+
}
56+
if (ui.is_hovered) {
57+
ui_tooltip(tr("Add bookmark"));
58+
}
59+
60+
// Refresh
61+
let in_focus: bool =
62+
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;
63+
if (ui_button(tr("Refresh")) || (in_focus && ui.is_key_pressed && ui.key_code == key_code_t.F5)) {
64+
tab_browser_refresh = true;
65+
}
3966
}
4067
else {
41-
let row: f32[] = [ bookmarks_w / ui._w, step * 0.07, step * 0.07, step * 0.66, step * 0.2 ];
68+
// Up, Refresh
69+
let row: f32[] = [ 1 / 4, 3 / 4 ];
4270
ui_row(row);
4371
}
4472

45-
// Bookmark
46-
if (ui_button("+")) {
47-
let bookmark: string = tab_browser_hpath.text;
48-
/// if arm_windows
49-
bookmark = string_replace_all(bookmark, "\\", "/");
50-
/// end
51-
array_push(config_raw.bookmarks, bookmark);
52-
config_save();
53-
}
54-
if (ui.is_hovered) {
55-
ui_tooltip(tr("Add bookmark"));
56-
}
57-
58-
// Refresh
59-
let in_focus: bool =
60-
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;
61-
if (ui_button(tr("Refresh")) || (in_focus && ui.is_key_pressed && ui.key_code == key_code_t.F5)) {
62-
tab_browser_refresh = true;
63-
}
64-
6573
// Previous folder
6674
let text: string = tab_browser_hpath.text;
6775
let i1: i32 = string_index_of(text, path_sep);
@@ -97,16 +105,19 @@ function tab_browser_draw(htab: ui_handle_t) {
97105
}
98106
/// end
99107

100-
tab_browser_hsearch.text = ui_text_input(tab_browser_hsearch, tr("Search"), ui_align_t.LEFT, true, true);
101-
if (ui.is_hovered) {
102-
ui_tooltip(tr("ctrl+f to search") + "\n" + tr("esc to cancel"));
103-
}
104-
if (ui.is_ctrl_down && ui.is_key_pressed && ui.key_code == key_code_t.F) { // Start searching via ctrl+f
105-
ui_start_text_edit(tab_browser_hsearch);
106-
}
107-
if (tab_browser_hsearch.text != "" && (ui_button(tr("X")) || ui.is_escape_down)) {
108-
tab_browser_hsearch.text = "";
108+
if (show_full) {
109+
tab_browser_hsearch.text = ui_text_input(tab_browser_hsearch, tr("Search"), ui_align_t.LEFT, true, true);
110+
if (ui.is_hovered) {
111+
ui_tooltip(tr("ctrl+f to search") + "\n" + tr("esc to cancel"));
112+
}
113+
if (ui.is_ctrl_down && ui.is_key_pressed && ui.key_code == key_code_t.F) { // Start searching via ctrl+f
114+
ui_start_text_edit(tab_browser_hsearch);
115+
}
116+
if (tab_browser_hsearch.text != "" && (ui_button(tr("X")) || ui.is_escape_down)) {
117+
tab_browser_hsearch.text = "";
118+
}
109119
}
120+
110121
ui_end_sticky();
111122

112123
if (tab_browser_last_path != tab_browser_hpath.text) {
@@ -115,8 +126,10 @@ function tab_browser_draw(htab: ui_handle_t) {
115126
tab_browser_last_path = tab_browser_hpath.text;
116127

117128
let _y: f32 = ui._y;
118-
ui._x = bookmarks_w;
119-
ui._w -= bookmarks_w;
129+
if (show_full) {
130+
ui._x = bookmarks_w;
131+
ui._w -= bookmarks_w;
132+
}
120133

121134
ui_files_file_browser(tab_browser_hpath, true, tab_browser_hsearch.text, tab_browser_refresh, function(file: string) {
122135
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) {
218231
}
219232
/// end
220233

221-
let bottom_y: i32 = ui._y;
222-
ui._x = 0;
223-
ui._y = _y;
224-
ui._w = bookmarks_w;
225-
226-
if (ui_button(tr("Cloud"), ui_align_t.LEFT)) {
227-
tab_browser_hpath.text = "cloud";
228-
}
229-
230-
if (ui_button(tr("Disk"), ui_align_t.LEFT)) {
231-
/// if arm_android
232-
ui_menu_draw(function() {
233-
if (ui_menu_button(tr("Download"))) {
234-
tab_browser_hpath.text = ui_files_default_path;
235-
}
236-
if (ui_menu_button(tr("Pictures"))) {
237-
tab_browser_hpath.text = "/storage/emulated/0/Pictures";
238-
}
239-
if (ui_menu_button(tr("Camera"))) {
240-
tab_browser_hpath.text = "/storage/emulated/0/DCIM/Camera";
241-
}
242-
if (ui_menu_button(tr("Projects"))) {
243-
tab_browser_hpath.text = iron_internal_save_path();
244-
}
245-
});
246-
/// else
247-
tab_browser_hpath.text = ui_files_default_path;
248-
/// end
249-
}
250-
251-
for (let i: i32 = 0; i < config_raw.bookmarks.length; ++i) {
252-
let b: string = config_raw.bookmarks[i];
253-
let folder: string = substring(b, string_last_index_of(b, "/") + 1, b.length);
234+
if (show_full) {
235+
let bottom_y: i32 = ui._y;
236+
ui._x = 0;
237+
ui._y = _y;
238+
ui._w = bookmarks_w;
254239

255-
if (ui_button(folder, ui_align_t.LEFT)) {
256-
tab_browser_hpath.text = b;
257-
/// if arm_windows
258-
tab_browser_hpath.text = string_replace_all(tab_browser_hpath.text, "/", "\\");
259-
/// end
240+
if (ui_button(tr("Cloud"), ui_align_t.LEFT)) {
241+
tab_browser_hpath.text = "cloud";
260242
}
261243

262-
if (ui.is_hovered && ui.input_released_r) {
263-
_tab_browser_draw_b = b;
244+
if (ui_button(tr("Disk"), ui_align_t.LEFT)) {
245+
/// if arm_android
264246
ui_menu_draw(function() {
265-
if (ui_menu_button(tr("Delete"))) {
266-
array_remove(config_raw.bookmarks, _tab_browser_draw_b);
267-
config_save();
247+
if (ui_menu_button(tr("Download"))) {
248+
tab_browser_hpath.text = ui_files_default_path;
249+
}
250+
if (ui_menu_button(tr("Pictures"))) {
251+
tab_browser_hpath.text = "/storage/emulated/0/Pictures";
252+
}
253+
if (ui_menu_button(tr("Camera"))) {
254+
tab_browser_hpath.text = "/storage/emulated/0/DCIM/Camera";
255+
}
256+
if (ui_menu_button(tr("Projects"))) {
257+
tab_browser_hpath.text = iron_internal_save_path();
268258
}
269259
});
260+
/// else
261+
tab_browser_hpath.text = ui_files_default_path;
262+
/// end
270263
}
271-
}
272264

273-
if (ui._y < bottom_y) {
274-
ui._y = bottom_y;
265+
for (let i: i32 = 0; i < config_raw.bookmarks.length; ++i) {
266+
let b: string = config_raw.bookmarks[i];
267+
let folder: string = substring(b, string_last_index_of(b, "/") + 1, b.length);
268+
269+
if (ui_button(folder, ui_align_t.LEFT)) {
270+
tab_browser_hpath.text = b;
271+
/// if arm_windows
272+
tab_browser_hpath.text = string_replace_all(tab_browser_hpath.text, "/", "\\");
273+
/// end
274+
}
275+
276+
if (ui.is_hovered && ui.input_released_r) {
277+
_tab_browser_draw_b = b;
278+
ui_menu_draw(function() {
279+
if (ui_menu_button(tr("Delete"))) {
280+
array_remove(config_raw.bookmarks, _tab_browser_draw_b);
281+
config_save();
282+
}
283+
});
284+
}
285+
}
286+
287+
if (ui._y < bottom_y) {
288+
ui._y = bottom_y;
289+
}
275290
}
276291
}
277292
}

paint/sources/tab_brushes.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ let _tab_brushes_draw_i: i32;
44
function tab_brushes_draw(htab: ui_handle_t) {
55
if (ui_tab(htab, tr("Brushes"))) {
66
ui_begin_sticky();
7-
let row: f32[] = [ 1 / 4, 1 / 4, 1 / 4 ];
7+
let row: f32[] = [ -70, -70, -70 ];
88
ui_row(row);
99
if (ui_button(tr("New"))) {
1010
context_raw.brush = slot_brush_create();
@@ -22,7 +22,7 @@ function tab_brushes_draw(htab: ui_handle_t) {
2222
ui_separator(3, false);
2323

2424
let slotw: i32 = math_floor(51 * UI_SCALE());
25-
let num: i32 = math_floor(config_raw.layout[layout_size_t.SIDEBAR_W] / slotw);
25+
let num: i32 = math_floor(ui._window_w / slotw);
2626
if (num == 0) {
2727
return;
2828
}

paint/sources/tab_console.ts

Lines changed: 4 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,29 +3,15 @@ function tab_console_draw(htab: ui_handle_t) {
33
let title: string = console_message_timer > 0 ? console_message + " " : tr("Console");
44
let color: i32 = console_message_timer > 0 ? console_message_color : -1;
55

6-
let statush: i32 = config_raw.layout[layout_size_t.STATUS_H];
7-
if (ui_tab(htab, title, false, color) && statush > ui_statusbar_default_h * UI_SCALE()) {
6+
if (ui_tab(htab, title, false, color) && ui._window_h > ui_statusbar_default_h * UI_SCALE()) {
87

98
ui_begin_sticky();
109
/// if (arm_windows || arm_linux || arm_macos) // Copy
11-
if (config_raw.touch_ui) {
12-
let row: f32[] = [ 1 / 4, 1 / 4, 1 / 4 ];
13-
ui_row(row);
14-
}
15-
else {
16-
let row: f32[] = [ 1 / 14, 1 / 14, 1 / 14 ];
17-
ui_row(row);
18-
}
10+
let row: f32[] = [ -100, -100, -100 ];
1911
/// else
20-
if (config_raw.touch_ui) {
21-
let row: f32[] = [ 1 / 4, 1 / 4 ];
22-
ui_row(row);
23-
}
24-
else {
25-
let row: f32[] = [ 1 / 14, 1 / 14 ];
26-
ui_row(row);
27-
}
12+
let row: f32[] = [ -100, -100 ];
2813
/// end
14+
ui_row(row);
2915

3016
if (ui_button(tr("Clear"))) {
3117
console_last_traces = [];

paint/sources/tab_fonts.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,11 @@
22
let _tab_fonts_draw_i: i32;
33

44
function tab_fonts_draw(htab: ui_handle_t) {
5-
let statush: i32 = config_raw.layout[layout_size_t.STATUS_H];
6-
if (ui_tab(htab, tr("Fonts")) && statush > ui_statusbar_default_h * UI_SCALE()) {
5+
if (ui_tab(htab, tr("Fonts")) && ui._window_h > ui_statusbar_default_h * UI_SCALE()) {
76

87
ui_begin_sticky();
9-
if (config_raw.touch_ui) {
10-
let row: f32[] = [ 1 / 4, 1 / 4 ];
11-
ui_row(row);
12-
}
13-
else {
14-
let row: f32[] = [ 1 / 14, 1 / 14 ];
15-
ui_row(row);
16-
}
8+
let row: f32[] = [ -100, -100 ];
9+
ui_row(row);
1710

1811
if (ui_button(tr("Import"))) {
1912
project_import_asset("ttf,ttc,otf");
@@ -28,9 +21,8 @@ function tab_fonts_draw(htab: ui_handle_t) {
2821
ui_end_sticky();
2922
ui_separator(3, false);
3023

31-
let statusw: i32 = iron_window_width() - ui_toolbar_w(true) - config_raw.layout[layout_size_t.SIDEBAR_W];
32-
let slotw: i32 = math_floor(51 * UI_SCALE());
33-
let num: i32 = math_floor(statusw / slotw);
24+
let slotw: i32 = math_floor(51 * UI_SCALE());
25+
let num: i32 = math_floor(ui._window_w / slotw);
3426
if (num == 0) {
3527
return;
3628
}

paint/sources/tab_layers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ function tab_layers_draw_mini(htab: ui_handle_t) {
3535
function tab_layers_draw_full(htab: ui_handle_t) {
3636
if (ui_tab(htab, tr("Layers"))) {
3737
ui_begin_sticky();
38-
let row: f32[] = [ 1 / 4, 1 / 4, 1 / 2 ];
38+
let row: f32[] = [ -70, -70, -140 ];
3939
ui_row(row);
4040

4141
tab_layers_button_new(tr("New"));

paint/sources/tab_materials.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
let _tab_materials_draw_slots: i32;
33

44
function tab_materials_draw(htab: ui_handle_t) {
5-
let mini: bool = config_raw.layout[layout_size_t.SIDEBAR_W] <= ui_sidebar_w_mini;
5+
let mini: bool = ui._window_w <= ui_sidebar_w_mini;
66
mini ? tab_materials_draw_mini(htab) : tab_materials_draw_full(htab);
77
}
88

@@ -23,7 +23,7 @@ function tab_materials_draw_mini(htab: ui_handle_t) {
2323
function tab_materials_draw_full(htab: ui_handle_t) {
2424
if (ui_tab(htab, tr("Materials"))) {
2525
ui_begin_sticky();
26-
let row: f32[] = [ 1 / 4, 1 / 4, 1 / 4 ];
26+
let row: f32[] = [ -70, -70, -70 ];
2727
ui_row(row);
2828

2929
tab_materials_button_new(tr("New"));
@@ -49,7 +49,7 @@ function tab_materials_button_nodes() {
4949

5050
function tab_materials_draw_slots(mini: bool) {
5151
let slotw: i32 = math_floor((51 + math_floor(config_raw.window_scale * 2)) * UI_SCALE());
52-
let num: i32 = math_floor(config_raw.layout[layout_size_t.SIDEBAR_W] / slotw);
52+
let num: i32 = math_floor(ui._window_w / slotw);
5353
if (num == 0) {
5454
return;
5555
}

0 commit comments

Comments
 (0)