mirror of
https://github.com/storytold/lightcraft.git
synced 2026-10-29 04:27:30 -06:00
LR-META-INFO: the Info panel's GPS field is a TextField, so Esc gives an edit up
The GPS box was an egui TextEdit: Esc left the field with the typed text kept, and leaving the field saved it. It is now the app's TextField, as the other Info fields are: Esc puts the text back and saves nothing, and the field gets the Cut / Copy / Paste / Select All menu.
This commit is contained in:
@@ -3117,6 +3117,17 @@ mod tests {
|
||||
h.settle(SETTLE);
|
||||
let gps: Vec<bool> = (0..4).map(|i| meta(&h, i).gps.is_some()).collect();
|
||||
assert_eq!(gps, [true, true, false, false]);
|
||||
// Esc gives a GPS edit up
|
||||
exec(&mut h, "library.select", json!({"ids": [ids[0], ids[1]], "active": ids[0]}));
|
||||
h.settle(SETTLE);
|
||||
let before = meta(&h, 0).gps;
|
||||
ask(&mut h, "ui.clickWidget", json!({"id": "field:gps"}));
|
||||
ask(&mut h, "ui.key", json!({"key": "End"}));
|
||||
ask(&mut h, "ui.text", json!({"text": "5"}));
|
||||
ask(&mut h, "ui.key", json!({"key": "Escape"}));
|
||||
ask(&mut h, "ui.key", json!({"key": "Tab"}));
|
||||
h.settle(SETTLE);
|
||||
assert_eq!((meta(&h, 0).gps, meta(&h, 1).gps), (before, before));
|
||||
}
|
||||
|
||||
/// Local: a folder's photos show without joining the library; the breadcrumb, Include
|
||||
|
||||
@@ -758,17 +758,16 @@ fn info(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId) {
|
||||
ui.label(egui::RichText::new("GPS").size(11.5).color(t.text_dim));
|
||||
let mut edit: FieldEdit = ui.data(|d| d.get_temp(gid)).unwrap_or_else(|| FieldEdit::new(&gps, gps_mixed, &selected));
|
||||
let hint = crate::i18n::tr(if gps_mixed { MIXED } else { "latitude, longitude" });
|
||||
let r = ui.add(egui::TextEdit::singleline(&mut edit.text).hint_text(hint).desired_width(f32::INFINITY));
|
||||
crate::widgets::screen_reader_name(ui.ctx(), r.id, "GPS");
|
||||
register(ui.ctx(), "field:gps", r.rect);
|
||||
let r = crate::text_field::TextField::singleline("field:gps", &mut edit.text).hint(hint).label("GPS").width(f32::INFINITY).show(ui);
|
||||
edit.typed |= edit.text != edit.start;
|
||||
if r.has_focus() {
|
||||
if r.editing {
|
||||
ui.data_mut(|d| d.insert_temp(gid, edit.clone()));
|
||||
} else {
|
||||
ui.data_mut(|d| d.remove::<FieldEdit>(gid));
|
||||
}
|
||||
// Return or leaving saves; Esc gives the edit up
|
||||
let text = edit.text.trim();
|
||||
if r.lost_focus()
|
||||
if r.committed()
|
||||
&& (text != edit.start || edit.clears())
|
||||
&& let Err(e) = app.run("photo.setMeta", json!({"ids": edit.ids, "gps": text}))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user