mirror of
https://github.com/emilk/egui.git
synced 2026-09-03 07:10:04 -04:00
Feat(egui): make style::ImePreedit::inactive_underline_stroke customizable
This commit is contained in:
@@ -1214,6 +1214,7 @@ pub struct Selection {
|
|||||||
#[cfg_attr(feature = "serde", serde(default))]
|
#[cfg_attr(feature = "serde", serde(default))]
|
||||||
pub struct ImePreedit {
|
pub struct ImePreedit {
|
||||||
pub active_underline_stroke: Stroke,
|
pub active_underline_stroke: Stroke,
|
||||||
|
pub inactive_underline_stroke: Stroke,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Shape of the handle for sliders and similar widgets.
|
/// Shape of the handle for sliders and similar widgets.
|
||||||
@@ -1629,16 +1630,28 @@ impl Default for Selection {
|
|||||||
|
|
||||||
impl ImePreedit {
|
impl ImePreedit {
|
||||||
fn dark() -> Self {
|
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 {
|
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)),
|
active_underline_stroke: Stroke::new(2.0, Color32::from_rgb(192, 222, 255)),
|
||||||
|
inactive_underline_stroke,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn light() -> Self {
|
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 {
|
Self {
|
||||||
// Same as the default value of [`TextCursorStyle::stroke`] in light mode.
|
active_underline_stroke,
|
||||||
active_underline_stroke: Stroke::new(2.0, Color32::from_rgb(0, 83, 125)),
|
inactive_underline_stroke,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2174,6 +2187,7 @@ impl ImePreedit {
|
|||||||
pub fn ui(&mut self, ui: &mut crate::Ui) {
|
pub fn ui(&mut self, ui: &mut crate::Ui) {
|
||||||
let Self {
|
let Self {
|
||||||
active_underline_stroke,
|
active_underline_stroke,
|
||||||
|
inactive_underline_stroke,
|
||||||
} = self;
|
} = self;
|
||||||
|
|
||||||
ui.label("IME preedit");
|
ui.label("IME preedit");
|
||||||
@@ -2182,6 +2196,10 @@ impl ImePreedit {
|
|||||||
ui.label("Active underline stroke");
|
ui.label("Active underline stroke");
|
||||||
ui.add(active_underline_stroke);
|
ui.add(active_underline_stroke);
|
||||||
ui.end_row();
|
ui.end_row();
|
||||||
|
|
||||||
|
ui.label("Inactive underline stroke");
|
||||||
|
ui.add(inactive_underline_stroke);
|
||||||
|
ui.end_row();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -146,10 +146,7 @@ pub fn paint_ime_preedit_text_visuals(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let active_underline_stroke = visuals.ime_preedit.active_underline_stroke;
|
let active_underline_stroke = visuals.ime_preedit.active_underline_stroke;
|
||||||
let inactive_underline_stroke = Stroke {
|
let inactive_underline_stroke = visuals.ime_preedit.inactive_underline_stroke;
|
||||||
width: active_underline_stroke.width,
|
|
||||||
color: active_underline_stroke.color.linear_multiply(0.5),
|
|
||||||
};
|
|
||||||
|
|
||||||
if let Some(relative_active_range) = &relative_active_range
|
if let Some(relative_active_range) = &relative_active_range
|
||||||
&& !relative_active_range.is_empty()
|
&& !relative_active_range.is_empty()
|
||||||
|
|||||||
Reference in New Issue
Block a user