From 86f148989527a4773e8a8cf55ae44bdbc3330ad4 Mon Sep 17 00:00:00 2001 From: dotCooCoo Date: Sat, 21 Nov 2026 00:57:36 -0800 Subject: [PATCH] Color Wheel: the contrast row's chips show the focus outline of the color fields The fix chip drew no focus indicator, and the background chip recolored its own border. Both now draw the outline a focused color field draws around itself (widgets::focus_outline). --- crates/ui-egui/src/panels/color_wheel.rs | 5 ++--- crates/ui-egui/src/widgets.rs | 2 +- crates/ui-egui/src/widgets/color.rs | 2 +- 3 files changed, 4 insertions(+), 5 deletions(-) diff --git a/crates/ui-egui/src/panels/color_wheel.rs b/crates/ui-egui/src/panels/color_wheel.rs index c7627e68a5..3181a5a903 100644 --- a/crates/ui-egui/src/panels/color_wheel.rs +++ b/crates/ui-egui/src/panels/color_wheel.rs @@ -1106,9 +1106,7 @@ fn contrast_row(app: &mut VectorcraftApp, ui: &mut Ui, m: &Measured) -> Option widgets::swatch_tile(ui, rect, &Paint::solid(c), false, false), None => widgets::swatch_tile(ui, rect, &Paint::None, false, false), } - if chip_resp.has_focus() { - ui.painter().rect_stroke(rect, 0.0, ui.visuals().selection.stroke, StrokeKind::Inside); - } + widgets::focus_outline(ui, &chip_resp, rect); let enabled = ui.is_enabled(); let value = chip.map(|c| hex(bytes(cms::active().display_rgb(&c)))); chip_resp.widget_info(|| egui::WidgetInfo { @@ -1163,6 +1161,7 @@ fn fix_chip(ui: &mut Ui, answer: Option<&Value>, aa: bool, aaa: Option) -> }; let (rect, resp) = ui.allocate_exact_size(vec2(CHIP, CHIP), egui::Sense::click()); widgets::swatch_tile(ui, rect, &Paint::solid(color), false, false); + widgets::focus_outline(ui, &resp, rect); let label = crate::i18n::fmt(tl!("The closest color that passes {level}: click to apply it."), &[("level", name)]); resp.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, ui.is_enabled(), &label)); let resp = resp.on_hover_text(&label); diff --git a/crates/ui-egui/src/widgets.rs b/crates/ui-egui/src/widgets.rs index b67df13c7f..38b1beca0f 100644 --- a/crates/ui-egui/src/widgets.rs +++ b/crates/ui-egui/src/widgets.rs @@ -42,7 +42,7 @@ pub use color::{ color_slider_stepped, color_slider_valued, harmony_wheel, hex_field, hex_field_named, hsb32, hue_ring, recolor_wheel, region_texture, ring_markers, ring_square, segment_color, segment_color_on, segmented_wheel, stepped_area, wheel_of, }; -pub(crate) use color::{HEX_FIELD_CHARS, color_rail_bar, focus_by_pointer, hex_text, pointer_phase}; +pub(crate) use color::{HEX_FIELD_CHARS, color_rail_bar, focus_by_pointer, focus_outline, hex_text, pointer_phase}; #[cfg(test)] pub(crate) use color::{SHADE, shade_cells, shade_edges}; pub use drag::{ diff --git a/crates/ui-egui/src/widgets/color.rs b/crates/ui-egui/src/widgets/color.rs index 8f5ec8b2d9..4bd2846018 100644 --- a/crates/ui-egui/src/widgets/color.rs +++ b/crates/ui-egui/src/widgets/color.rs @@ -383,7 +383,7 @@ fn arrow_steps(ui: &Ui, id: egui::Id, horizontal: bool, vertical: bool) -> (f32, } /// The focus outline of a focused color control. -fn focus_outline(ui: &Ui, resp: &Response, rect: Rect) { +pub(crate) fn focus_outline(ui: &Ui, resp: &Response, rect: Rect) { if ui.memory(|m| m.has_focus(resp.id)) { let t = Tokens::get(ui.ctx()); ui.painter().rect_stroke(rect.expand(2.0), 0.0, Stroke::new(1.0, t.accent), StrokeKind::Outside);