@@ -518,6 +518,9 @@ fn format_path(path: &Option<PathBuf>, appearance: &Appearance) -> RichText {
518
518
RichText :: new ( text) . color ( color) . family ( FontFamily :: Monospace )
519
519
}
520
520
521
+ pub const CONFIG_DISABLED_TEXT : & str =
522
+ "Option disabled because it's set by the project configuration file." ;
523
+
521
524
fn pick_folder_ui (
522
525
ui : & mut egui:: Ui ,
523
526
dir : & Option < PathBuf > ,
@@ -530,6 +533,7 @@ fn pick_folder_ui(
530
533
subheading ( ui, label, appearance) ;
531
534
ui. link ( HELP_ICON ) . on_hover_ui ( tooltip) ;
532
535
ui. add_enabled ( enabled, egui:: Button :: new ( "Select" ) )
536
+ . on_disabled_hover_text ( CONFIG_DISABLED_TEXT )
533
537
} ) ;
534
538
ui. label ( format_path ( dir, appearance) ) ;
535
539
response. inner
@@ -620,7 +624,14 @@ fn split_obj_config_ui(
620
624
} ) ;
621
625
} ) ;
622
626
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
+ {
624
635
if custom_make_str. is_empty ( ) {
625
636
config. custom_make = None ;
626
637
} else {
@@ -675,7 +686,12 @@ fn split_obj_config_ui(
675
686
FileDialogResult :: TargetDir ,
676
687
) ;
677
688
}
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| {
679
695
let mut job = LayoutJob :: default ( ) ;
680
696
job. append (
681
697
"Tells the build system to produce the target object.\n " ,
@@ -726,7 +742,12 @@ fn split_obj_config_ui(
726
742
FileDialogResult :: BaseDir ,
727
743
) ;
728
744
}
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| {
730
751
let mut job = LayoutJob :: default ( ) ;
731
752
job. append (
732
753
"Tells the build system to produce the base object.\n " ,
@@ -769,7 +790,11 @@ fn split_obj_config_ui(
769
790
770
791
ui. horizontal ( |ui| {
771
792
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
+ {
773
798
config. watch_patterns =
774
799
DEFAULT_WATCH_PATTERNS . iter ( ) . map ( |s| Glob :: new ( s) . unwrap ( ) ) . collect ( ) ;
775
800
config. watcher_change = true ;
@@ -783,7 +808,11 @@ fn split_obj_config_ui(
783
808
. color ( appearance. text_color )
784
809
. family ( FontFamily :: Monospace ) ,
785
810
) ;
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
+ {
787
816
remove_at = Some ( idx) ;
788
817
}
789
818
} ) ;
@@ -793,8 +822,16 @@ fn split_obj_config_ui(
793
822
config. watcher_change = true ;
794
823
}
795
824
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
+ {
798
835
if let Ok ( glob) = Glob :: new ( & state. watch_pattern_text ) {
799
836
config. watch_patterns . push ( glob) ;
800
837
config. watcher_change = true ;
0 commit comments