@@ -518,6 +518,9 @@ fn format_path(path: &Option<PathBuf>, appearance: &Appearance) -> RichText {
518518 RichText :: new ( text) . color ( color) . family ( FontFamily :: Monospace )
519519}
520520
521+ pub const CONFIG_DISABLED_TEXT : & str =
522+ "Option disabled because it's set by the project configuration file." ;
523+
521524fn pick_folder_ui (
522525 ui : & mut egui:: Ui ,
523526 dir : & Option < PathBuf > ,
@@ -530,6 +533,7 @@ fn pick_folder_ui(
530533 subheading ( ui, label, appearance) ;
531534 ui. link ( HELP_ICON ) . on_hover_ui ( tooltip) ;
532535 ui. add_enabled ( enabled, egui:: Button :: new ( "Select" ) )
536+ . on_disabled_hover_text ( CONFIG_DISABLED_TEXT )
533537 } ) ;
534538 ui. label ( format_path ( dir, appearance) ) ;
535539 response. inner
@@ -620,7 +624,14 @@ fn split_obj_config_ui(
620624 } ) ;
621625 } ) ;
622626 let mut custom_make_str = config. custom_make . clone ( ) . unwrap_or_default ( ) ;
623- if ui. text_edit_singleline ( & mut custom_make_str) . changed ( ) {
627+ if ui
628+ . add_enabled (
629+ config. project_config_info . is_none ( ) ,
630+ egui:: TextEdit :: singleline ( & mut custom_make_str) ,
631+ )
632+ . on_disabled_hover_text ( CONFIG_DISABLED_TEXT )
633+ . changed ( )
634+ {
624635 if custom_make_str. is_empty ( ) {
625636 config. custom_make = None ;
626637 } else {
@@ -675,7 +686,12 @@ fn split_obj_config_ui(
675686 FileDialogResult :: TargetDir ,
676687 ) ;
677688 }
678- ui. checkbox ( & mut config. build_target , "Build target objects" ) . on_hover_ui ( |ui| {
689+ ui. add_enabled (
690+ config. project_config_info . is_none ( ) ,
691+ egui:: Checkbox :: new ( & mut config. build_target , "Build target objects" ) ,
692+ )
693+ . on_disabled_hover_text ( CONFIG_DISABLED_TEXT )
694+ . on_hover_ui ( |ui| {
679695 let mut job = LayoutJob :: default ( ) ;
680696 job. append (
681697 "Tells the build system to produce the target object.\n " ,
@@ -726,7 +742,12 @@ fn split_obj_config_ui(
726742 FileDialogResult :: BaseDir ,
727743 ) ;
728744 }
729- ui. checkbox ( & mut config. build_base , "Build base objects" ) . on_hover_ui ( |ui| {
745+ ui. add_enabled (
746+ config. project_config_info . is_none ( ) ,
747+ egui:: Checkbox :: new ( & mut config. build_base , "Build base objects" ) ,
748+ )
749+ . on_disabled_hover_text ( CONFIG_DISABLED_TEXT )
750+ . on_hover_ui ( |ui| {
730751 let mut job = LayoutJob :: default ( ) ;
731752 job. append (
732753 "Tells the build system to produce the base object.\n " ,
@@ -769,7 +790,11 @@ fn split_obj_config_ui(
769790
770791 ui. horizontal ( |ui| {
771792 ui. label ( RichText :: new ( "File patterns" ) . color ( appearance. text_color ) ) ;
772- if ui. button ( "Reset" ) . clicked ( ) {
793+ if ui
794+ . add_enabled ( config. project_config_info . is_none ( ) , egui:: Button :: new ( "Reset" ) )
795+ . on_disabled_hover_text ( CONFIG_DISABLED_TEXT )
796+ . clicked ( )
797+ {
773798 config. watch_patterns =
774799 DEFAULT_WATCH_PATTERNS . iter ( ) . map ( |s| Glob :: new ( s) . unwrap ( ) ) . collect ( ) ;
775800 config. watcher_change = true ;
@@ -783,7 +808,11 @@ fn split_obj_config_ui(
783808 . color ( appearance. text_color )
784809 . family ( FontFamily :: Monospace ) ,
785810 ) ;
786- if ui. small_button ( "-" ) . clicked ( ) {
811+ if ui
812+ . add_enabled ( config. project_config_info . is_none ( ) , egui:: Button :: new ( "-" ) . small ( ) )
813+ . on_disabled_hover_text ( CONFIG_DISABLED_TEXT )
814+ . clicked ( )
815+ {
787816 remove_at = Some ( idx) ;
788817 }
789818 } ) ;
@@ -793,8 +822,16 @@ fn split_obj_config_ui(
793822 config. watcher_change = true ;
794823 }
795824 ui. horizontal ( |ui| {
796- egui:: TextEdit :: singleline ( & mut state. watch_pattern_text ) . desired_width ( 100.0 ) . show ( ui) ;
797- if ui. small_button ( "+" ) . clicked ( ) {
825+ ui. add_enabled (
826+ config. project_config_info . is_none ( ) ,
827+ egui:: TextEdit :: singleline ( & mut state. watch_pattern_text ) . desired_width ( 100.0 ) ,
828+ )
829+ . on_disabled_hover_text ( CONFIG_DISABLED_TEXT ) ;
830+ if ui
831+ . add_enabled ( config. project_config_info . is_none ( ) , egui:: Button :: new ( "+" ) . small ( ) )
832+ . on_disabled_hover_text ( CONFIG_DISABLED_TEXT )
833+ . clicked ( )
834+ {
798835 if let Ok ( glob) = Glob :: new ( & state. watch_pattern_text ) {
799836 config. watch_patterns . push ( glob) ;
800837 config. watcher_change = true ;
0 commit comments