@@ -427,29 +427,48 @@ impl ControlView {
427427 pub fn tab_ui (
428428 ui : & mut Ui ,
429429 asset_server : & AssetServer ,
430+ pathes : & mut TabPathes ,
430431 state : & mut NotationAppState ,
431432 _settings : & mut NotationSettings ,
432433 theme : & mut NotationTheme ,
433- tab_pathes : & TabPathes ,
434434 ) {
435- if tab_pathes. 0 . len ( ) > 1 {
435+ if theme. _bypass_systems {
436+ ui. label ( "Loading Tab ..." ) ;
437+ return ;
438+ }
439+ ui. horizontal ( |ui| {
440+ if ui. button ( "Reset Tab" ) . clicked ( ) {
441+ Control :: reload_tab ( state, theme) ;
442+ }
443+ #[ cfg( not( target_arch = "wasm32" ) ) ]
444+ if ui. button ( "Open Tab" ) . clicked ( ) {
445+ if let Some ( path) = rfd:: FileDialog :: new ( )
446+ . add_filter ( "Fun Notation" , & [ "ron" ] )
447+ . pick_file ( ) {
448+ let path_str = path. clone ( ) . into_os_string ( ) . into_string ( ) ;
449+ if let Ok ( path_str) = path_str {
450+ pathes. 0 . insert ( 0 , path_str. clone ( ) ) ;
451+ state. change_tab ( asset_server, theme, path_str. clone ( ) ) ;
452+ } else {
453+ println ! ( "Failed to convert path to string: {:?} -> {:?}" , path, path_str) ;
454+ }
455+ }
456+ }
457+ } ) ;
458+ if pathes. 0 . len ( ) > 1 {
436459 let width = Self :: calc_width ( state. window_width ) ;
437460 egui:: ComboBox :: from_label ( "" )
438461 . selected_text ( state. tab_path . clone ( ) )
439462 . width ( width - 24.0 )
440463 . show_ui ( ui, |ui| {
441- for path in tab_pathes . 0 . iter ( ) {
464+ for path in pathes . 0 . iter ( ) {
442465 if ui. selectable_label ( * path == state. tab_path , path) . clicked ( )
443466 {
444- theme. _bypass_systems = true ;
445- state. change_tab ( asset_server, path. clone ( ) ) ;
467+ state. change_tab ( asset_server, theme, path. clone ( ) ) ;
446468 }
447469 }
448470 } ) ;
449471 }
450- if ui. button ( "Reset Tab" ) . clicked ( ) {
451- Control :: reload_tab ( state, theme) ;
452- }
453472 }
454473 pub fn guitar_tab_display_ui (
455474 ui : & mut Ui ,
@@ -622,10 +641,10 @@ impl ControlView {
622641 egui_ctx : Res < EguiContext > ,
623642 mut windows : ResMut < Windows > ,
624643 asset_server : Res < AssetServer > ,
644+ mut pathes : ResMut < TabPathes > ,
625645 mut state : ResMut < NotationAppState > ,
626646 mut settings : ResMut < NotationSettings > ,
627647 mut theme : ResMut < NotationTheme > ,
628- tab_pathes : Res < TabPathes > ,
629648 mut midi_settings : ResMut < MidiSettings > ,
630649 mut midi_state : ResMut < MidiState > ,
631650 mut play_control_evts : EventWriter < PlayControlEvent > ,
@@ -649,7 +668,7 @@ impl ControlView {
649668 }
650669 ui.separator();
651670 */
652- Self :: tab_ui ( ui, & asset_server, & mut state , & mut settings , & mut theme , & tab_pathes ) ;
671+ Self :: tab_ui ( ui, & asset_server, & mut pathes , & mut state , & mut settings , & mut theme ) ;
653672 ui. separator ( ) ;
654673 Self :: play_control_ui ( ui, & mut settings, & mut midi_state, & mut play_control_evts) ;
655674 ui. separator ( ) ;
0 commit comments