(
ui: &mut egui::Ui,
state: &mut AppState,
property_id: ConfigPropertyId,
)
| 889 | } |
| 890 | |
| 891 | fn config_property_ui( |
| 892 | ui: &mut egui::Ui, |
| 893 | state: &mut AppState, |
| 894 | property_id: ConfigPropertyId, |
| 895 | ) -> bool { |
| 896 | let mut changed = false; |
| 897 | let is_overridden = state.current_project_config.as_ref().is_some_and(|config| { |
| 898 | let key = property_id.name(); |
| 899 | if let Some(selected) = state.config.selected_obj.as_ref() |
| 900 | && let Some(units) = config.units.as_deref() |
| 901 | && let Some(unit) = units.iter().find(|unit| unit.name() == selected.name) |
| 902 | && let Some(options) = unit.options() |
| 903 | && options.contains_key(key) |
| 904 | { |
| 905 | return true; |
| 906 | } |
| 907 | if let Some(options) = config.options.as_ref() |
| 908 | && options.contains_key(key) |
| 909 | { |
| 910 | return true; |
| 911 | } |
| 912 | false |
| 913 | }); |
| 914 | let override_value = |
| 915 | is_overridden.then(|| state.effective_diff_config().get_property_value(property_id)); |
| 916 | let base_value = state.config.diff_obj_config.get_property_value(property_id); |
| 917 | match (property_id.kind(), base_value, override_value) { |
| 918 | ( |
| 919 | ConfigPropertyKind::Boolean, |
| 920 | ConfigPropertyValue::Boolean(base_checked), |
| 921 | override_value, |
| 922 | ) => { |
| 923 | let mut checked = match override_value { |
| 924 | Some(ConfigPropertyValue::Boolean(value)) => value, |
| 925 | _ => base_checked, |
| 926 | }; |
| 927 | let response = ui |
| 928 | .horizontal(|ui| { |
| 929 | let mut response = ui |
| 930 | .add_enabled( |
| 931 | !is_overridden, |
| 932 | egui::widgets::Checkbox::new(&mut checked, property_id.name()), |
| 933 | ) |
| 934 | .on_disabled_hover_text(CONFIG_DISABLED_TEXT); |
| 935 | if let Some(description) = property_id.description() { |
| 936 | response = response.on_hover_text(description); |
| 937 | } |
| 938 | if is_overridden { |
| 939 | project_override_badge(ui).on_hover_text(CONFIG_DISABLED_TEXT); |
| 940 | } |
| 941 | response |
| 942 | }) |
| 943 | .inner; |
| 944 | if !is_overridden && response.changed() { |
| 945 | state |
| 946 | .config |
| 947 | .diff_obj_config |
| 948 | .set_property_value(property_id, ConfigPropertyValue::Boolean(checked)) |
no test coverage detected