mirror of
https://github.com/storytold/vectorcraft.git
synced 2026-10-26 02:37:01 -06:00
Merge pull request #1490 from storytold/fix/1465-selected-text
Part of #1465: selected text in value fields is readable
This commit is contained in:
@@ -124,7 +124,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));
|
||||
}
|
||||
@@ -141,7 +144,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));
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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";
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user