Part of #1465: selected text in value fields is readable

Selected text in a numeric or text field was drawn in the accent colour on the accent-tinted
selection, in every brightness. The fields that draw their own frame (panel and Control bar fields,
dialog fields, the hex field) now draw it in the strong text colour.
This commit is contained in:
bflatastic
2026-10-13 02:48:41 +07:00
parent 974325b62a
commit 09f62097f0
4 changed files with 21 additions and 3 deletions
+8 -2
View File
@@ -126,7 +126,10 @@ pub(super) fn text_edit(ui: &mut egui::Ui, d: &mut Dialog, key: &str, width: f32
.stroke(egui::Stroke::new(1.0, t.input_border))
.corner_radius(egui::CornerRadius::same(3))
.inner_margin(egui::Margin::symmetric(6, 3))
.show(ui, |ui| ui.add(egui::TextEdit::singleline(&mut s).id(id).frame(egui::Frame::NONE).desired_width(width)));
.show(ui, |ui| {
crate::theme::strong_selected_text(ui);
ui.add(egui::TextEdit::singleline(&mut s).id(id).frame(egui::Frame::NONE).desired_width(width))
});
if r.inner.changed() {
d.fields.insert(key.into(), Value::String(s));
}
@@ -143,7 +146,10 @@ pub(super) fn text_area(ui: &mut egui::Ui, d: &mut Dialog, key: &str, width: f32
.stroke(egui::Stroke::new(1.0, t.input_border))
.corner_radius(egui::CornerRadius::same(3))
.inner_margin(egui::Margin::symmetric(6, 3))
.show(ui, |ui| ui.add(egui::TextEdit::multiline(&mut s).frame(egui::Frame::NONE).desired_width(width).desired_rows(rows)));
.show(ui, |ui| {
crate::theme::strong_selected_text(ui);
ui.add(egui::TextEdit::multiline(&mut s).frame(egui::Frame::NONE).desired_width(width).desired_rows(rows))
});
if r.inner.changed() {
d.fields.insert(key.into(), Value::String(s));
}
+4 -1
View File
@@ -258,7 +258,10 @@ fn hex_field(ui: &mut egui::Ui, hex: &str) -> Option<Color> {
.stroke(egui::Stroke::new(1.0, if editing { t.accent } else { t.input_border }))
.corner_radius(2)
.inner_margin(egui::Margin::symmetric(6, 4))
.show(ui, |ui| ui.add(egui::TextEdit::singleline(&mut buf).id(id).frame(egui::Frame::NONE).desired_width(70.0).char_limit(7)))
.show(ui, |ui| {
crate::theme::strong_selected_text(ui);
ui.add(egui::TextEdit::singleline(&mut buf).id(id).frame(egui::Frame::NONE).desired_width(70.0).char_limit(7))
})
.inner;
ui.data_mut(|m| m.insert_temp(id, buf.clone()));
(resp.lost_focus() && buf != hex).then(|| parse_hex(&buf)).flatten()
+8
View File
@@ -229,6 +229,14 @@ impl Tokens {
}
}
/// Selected text in the text fields `ui` draws from here on is in the strong text colour. egui
/// paints it in the selection stroke's colour, the accent, which is hard to read on the selection's
/// accent tint (#1465). For fields that draw their own frame: egui's frame takes its focus ring from
/// the same stroke.
pub fn strong_selected_text(ui: &mut egui::Ui) {
ui.visuals_mut().selection.stroke.color = Tokens::get(ui.ctx()).text_strong;
}
pub const FONT_UI: &str = "ui";
pub const FONT_UI_SEMIBOLD: &str = "ui-semibold";
pub const FONT_MONO: &str = "mono";
+1
View File
@@ -363,6 +363,7 @@ fn recessed_text(ui: &mut Ui, id: egui::Id, shown: &str, width: f32, rows: usize
let resp = egui::Frame::NONE
.inner_margin(margin)
.show(ui, |ui| {
crate::theme::strong_selected_text(ui);
let edit = if rows > 1 { egui::TextEdit::multiline(&mut buf).desired_rows(rows) } else { egui::TextEdit::singleline(&mut buf) };
ui.add(
edit.id(id)