From e2acc2fc012f3ebdc1f08c9199b3fb0af5cb02d9 Mon Sep 17 00:00:00 2001 From: aiongg Date: Mon, 16 Nov 2026 00:17:27 +0000 Subject: [PATCH] tfix5-f9: CustomContext::pick_color opens the picker at the colour the row shows; the context keeps no copy of the values --- .../src/patterns/form_dialogs/param.rs | 17 +++++++---------- .../src/patterns/form_dialogs/rows.rs | 2 +- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/crates/ui-patterns/src/patterns/form_dialogs/param.rs b/crates/ui-patterns/src/patterns/form_dialogs/param.rs index 6430bd84c..96036a921 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/param.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/param.rs @@ -375,7 +375,6 @@ impl PartialEq for CustomRow { #[non_exhaustive] pub struct CustomContext { title: Label, - colors: DialogFields, request: Option, canvas: Option, eyedropper: Option, @@ -383,9 +382,9 @@ pub struct CustomContext { } impl CustomContext { - /// The context of a row labelled `title` over `colors`, the values at the start of the pass. - pub(crate) fn new(title: Label, colors: DialogFields, canvas: Option) -> Self { - CustomContext { title, colors, request: None, canvas, eyedropper: None, sampling: false } + /// The context of a row labelled `title`. + pub(crate) fn new(title: Label, canvas: Option) -> Self { + CustomContext { title, request: None, canvas, eyedropper: None, sampling: false } } /// Arms the host's eyedropper for the colour under `request.key`, as a colour row's dropper toggle does. @@ -403,12 +402,10 @@ impl CustomContext { self.canvas } - /// Asks the host for its colour picker for the value under `key`, which needs no row of its own. The picker opens - /// at the colour the form holds under `key` (black without one), titled with the row's label. The request is - /// reported once, as a colour row's press is (`ParamRowsOutput::pick_color`); the host answers by writing the - /// colour under `key`. - pub fn pick_color(&mut self, key: &str) { - let color = Srgba::from_rgb_array(self.colors.color(key).unwrap_or([0.0; 3])); + /// Asks the host for its colour picker, open at `color` (the colour the row shows) and titled with the row's label; + /// the host answers by writing the picked colour under `key`, which needs no row of its own. The request is + /// reported once, as a colour row's press is (`ParamRowsOutput::pick_color`). + pub fn pick_color(&mut self, key: &str, color: Srgba) { self.request = Some(ColorRequest::new(key, color).title(self.title.clone())); } diff --git a/crates/ui-patterns/src/patterns/form_dialogs/rows.rs b/crates/ui-patterns/src/patterns/form_dialogs/rows.rs index 7e9f669c5..e38177f2c 100644 --- a/crates/ui-patterns/src/patterns/form_dialogs/rows.rs +++ b/crates/ui-patterns/src/patterns/form_dialogs/rows.rs @@ -807,7 +807,7 @@ impl<'p> Pass<'p> { fn custom(&mut self, ui: &mut Ui, line: &Line<'_>) { let ParamKind::Custom(row) = &line.param.kind else { return }; - let mut context = CustomContext::new(line.name.clone(), self.work.clone(), self.canvas); + let mut context = CustomContext::new(line.name.clone(), self.canvas); line.show_body(ui, |ui| { let _ = row.draw(ui, &mut self.work, &mut context); });