fwb2-fix: BrushPresetPicker::enabled

(cherry picked from commit d5e5926b547cd295e2539771a56b67aa07c29fa4)
This commit is contained in:
aiongg
2026-11-15 12:06:38 +00:00
parent 47b2edf1f2
commit 3a5e093a1c
+10 -1
View File
@@ -271,6 +271,7 @@ pub struct BrushPresetPicker<'a, K: Value + Eq + Hash> {
resizable: Option<SaveKey>,
opened_at: Option<(Pos2, Bind<'a, bool>)>,
compact: bool,
enabled: bool,
app_rows: Option<Box<dyn FnOnce(&mut Ui) + 'a>>,
}
@@ -296,6 +297,7 @@ impl<'a, K: Value + Eq + Hash> BrushPresetPicker<'a, K> {
resizable: None,
opened_at: None,
compact: false,
enabled: true,
app_rows: None,
}
}
@@ -307,6 +309,12 @@ impl<'a, K: Value + Eq + Hash> BrushPresetPicker<'a, K> {
self
}
/// Whether the picker takes input: off disables its field, its head and its popover. It is enabled by default.
pub fn enabled(mut self, on: bool) -> Self {
self.enabled = on;
self
}
/// App rows drawn under the head.
pub fn rows(mut self, rows: impl FnOnce(&mut Ui) + 'a) -> Self {
self.app_rows = Some(Box::new(rows));
@@ -334,12 +342,13 @@ impl<'a, K: Value + Eq + Hash> BrushPresetPicker<'a, K> {
resizable,
mut opened_at,
compact,
enabled,
mut app_rows,
} = self;
let env = Env::of(ui);
let words = env.words::<BrushPresetWords>();
let name: std::sync::Arc<str> = std::sync::Arc::from(label.as_str());
let shown = Stack::new().label(label.clone()).show(ui, |ui, cx| {
let shown = Stack::new().label(label.clone()).enabled(enabled).show(ui, |ui, cx| {
let before = match state.reborrow().read(cx) {
Some(Mixed::Same(held)) => held,
_ => BrushPickerState::new(),