diff --git a/crates/egui/src/style.rs b/crates/egui/src/style.rs index 1f72f2233..4919c28e3 100644 --- a/crates/egui/src/style.rs +++ b/crates/egui/src/style.rs @@ -1214,6 +1214,7 @@ pub struct Selection { #[cfg_attr(feature = "serde", serde(default))] pub struct ImePreedit { pub active_underline_stroke: Stroke, + pub inactive_underline_stroke: Stroke, } /// Shape of the handle for sliders and similar widgets. @@ -1629,16 +1630,28 @@ impl Default for Selection { impl ImePreedit { fn dark() -> Self { + // Same as the default value of [`TextCursorStyle::stroke`] in dark mode. + let active_underline_stroke = Stroke::new(2.0, Color32::from_rgb(192, 222, 255)); + let inactive_underline_stroke = Stroke { + width: active_underline_stroke.width, + color: active_underline_stroke.color.linear_multiply(0.5), + }; Self { - // Same as the default value of [`TextCursorStyle::stroke`] in dark mode. active_underline_stroke: Stroke::new(2.0, Color32::from_rgb(192, 222, 255)), + inactive_underline_stroke, } } fn light() -> Self { + // Same as the default value of [`TextCursorStyle::stroke`] in light mode. + let active_underline_stroke = Stroke::new(2.0, Color32::from_rgb(0, 83, 125)); + let inactive_underline_stroke = Stroke { + width: active_underline_stroke.width, + color: active_underline_stroke.color.linear_multiply(0.5), + }; Self { - // Same as the default value of [`TextCursorStyle::stroke`] in light mode. - active_underline_stroke: Stroke::new(2.0, Color32::from_rgb(0, 83, 125)), + active_underline_stroke, + inactive_underline_stroke, } } } @@ -2174,6 +2187,7 @@ impl ImePreedit { pub fn ui(&mut self, ui: &mut crate::Ui) { let Self { active_underline_stroke, + inactive_underline_stroke, } = self; ui.label("IME preedit"); @@ -2182,6 +2196,10 @@ impl ImePreedit { ui.label("Active underline stroke"); ui.add(active_underline_stroke); ui.end_row(); + + ui.label("Inactive underline stroke"); + ui.add(inactive_underline_stroke); + ui.end_row(); }); } } diff --git a/crates/egui/src/text_selection/visuals.rs b/crates/egui/src/text_selection/visuals.rs index 003bac879..625299f16 100644 --- a/crates/egui/src/text_selection/visuals.rs +++ b/crates/egui/src/text_selection/visuals.rs @@ -146,10 +146,7 @@ pub fn paint_ime_preedit_text_visuals( } let active_underline_stroke = visuals.ime_preedit.active_underline_stroke; - let inactive_underline_stroke = Stroke { - width: active_underline_stroke.width, - color: active_underline_stroke.color.linear_multiply(0.5), - }; + let inactive_underline_stroke = visuals.ime_preedit.inactive_underline_stroke; if let Some(relative_active_range) = &relative_active_range && !relative_active_range.is_empty()