@@ -15,14 +15,14 @@ function tab_browser_show_directory(directory: string) {
1515}
1616
1717function 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}
0 commit comments