diff --git a/crates/ui-egui/src/chrome.rs b/crates/ui-egui/src/chrome.rs index 695c079f3f..0286127841 100644 --- a/crates/ui-egui/src/chrome.rs +++ b/crates/ui-egui/src/chrome.rs @@ -917,6 +917,8 @@ pub fn shortcuts(app: &mut RustGisApp, ctx: &egui::Context) { let element = app.session.active_layout.is_some() && app.layout.selected.is_some(); // The pane the user last pressed or scrolled in: Delete and Rename act on it. let pane = crate::inuse::pane(app); + // The arrows nudge that element, unless the attribute table is in use: they are its cells'. + let nudges = element && pane != Pane::Table; // What to run now, each with the pane that was in use as its key went down, and what to run // once the panes are drawn ([`late_keys`]). let mut run: Vec<(String, Value, Pane)> = Vec::new(); @@ -954,7 +956,7 @@ pub fn shortcuts(app: &mut RustGisApp, ctx: &egui::Context) { } // With a layout element selected, the arrows nudge it (below), whatever else they run; // the nudge never takes Ctrl (⌘), so a shortcut with it still runs. - if element && !b.chord.command && matches!(b.chord.key, Key::ArrowLeft | Key::ArrowRight | Key::ArrowUp | Key::ArrowDown) { + if nudges && !b.chord.command && matches!(b.chord.key, Key::ArrowLeft | Key::ArrowRight | Key::ArrowUp | Key::ArrowDown) { continue; } if i.consume_shortcut(&KeyboardShortcut::new(b.chord.modifiers(), b.chord.key)) { @@ -988,7 +990,7 @@ pub fn shortcuts(app: &mut RustGisApp, ctx: &egui::Context) { } // Arrow keys nudge the selected layout element, further with Shift; held, it keeps // going. Shift first: a plain arrow's pattern takes Shift-arrows too. - if element { + if nudges { use crate::layoutview::{NUDGE_FAST_MM, NUDGE_MM}; for (key, dx, dy) in [(Key::ArrowLeft, -1.0, 0.0), (Key::ArrowRight, 1.0, 0.0), (Key::ArrowUp, 0.0, -1.0), (Key::ArrowDown, 0.0, 1.0)] @@ -1023,6 +1025,10 @@ pub fn shortcuts(app: &mut RustGisApp, ctx: &egui::Context) { } } }); + // After the shortcuts, so a key the user bound to a command still runs it. + if !typing { + crate::table::take_keys(app, ctx); + } let dialogs = dialogs_up(app); crate::inuse::keep_late(app, late, dialogs); run_keys(app, ctx, &run); diff --git a/crates/ui-egui/src/mapview.rs b/crates/ui-egui/src/mapview.rs index e47afb3909..d49cc90a35 100644 --- a/crates/ui-egui/src/mapview.rs +++ b/crates/ui-egui/src/mapview.rs @@ -3075,8 +3075,10 @@ fn interact(app: &mut RustGisApp, ui: &mut Ui, resp: &egui::Response, rect: Rect } // Arrow keys pan; Shift+Left and Shift+Right turn the map, Shift+Up and Shift+Down tilt it // (as in MapLibre). With Alt or Mod held the arrows are shortcuts (Alt+Shift+arrows move the - // active layer in the Layers pane's outline, #836), not map moves. - if !ui.ctx().egui_wants_keyboard_input() { + // active layer in the Layers pane's outline, #836), not map moves. With the attribute table + // in use they move its current cell, and the map stays: held keys are read here, so the + // table taking the key presses wouldn't stop them. + if !ui.ctx().egui_wants_keyboard_input() && crate::inuse::pane(app) != crate::inuse::Pane::Table { let (mut dx, mut dy, mut turn, mut tilt) = (0.0, 0.0, 0.0, 0.0); ui.input(|i| { if i.modifiers.alt || i.modifiers.command { diff --git a/crates/ui-egui/src/table.rs b/crates/ui-egui/src/table.rs index e561a7a1ee..71b9c95142 100644 --- a/crates/ui-egui/src/table.rs +++ b/crates/ui-egui/src/table.rs @@ -1,6 +1,7 @@ //! The attribute table, docked under the map: sort, filter to the selection, select rows (synced //! with the map) and edit values in place, a layer's or a standalone table's. +mod cursor; mod dates; mod rowmenu; @@ -15,6 +16,7 @@ use serde_json::{Value, json}; use crate::theme::{Tokens, semibold}; use crate::widgets::{small, small_for}; use crate::{RustGisApp, icons}; +pub(crate) use cursor::take_keys; #[derive(Default)] pub struct TableState { @@ -39,6 +41,12 @@ pub struct TableState { stats: Option, /// The cell a row's right-click menu was last opened on. menu: Option, + /// The cell the arrow keys move and Enter edits. + current: Option, + /// The frame's cell keys, taken as it began ([`take_keys`]) for [`show`] to act on. + keys: Vec, + /// Whether the next frame scrolls the current cell into view. + reveal: bool, } struct RowOrder { @@ -188,6 +196,7 @@ pub(crate) fn prune_views(app: &mut RustGisApp) { app.table.sort_schema = None; app.table.row_order = None; app.table.menu = None; + app.table.current = None; app.table.opened = app.session.opened; } let project = &app.session.project; @@ -358,6 +367,7 @@ impl CellEdit { /// shown, docked under the map: its rows, toolbar and cell editor. Edits run as commands. pub fn show(app: &mut RustGisApp, ui: &mut Ui) { dates::show(app, ui.ctx()); + let keys = std::mem::take(&mut app.table.keys); let layer_id = app.session.table_layer; // An edit is the layer's or table's it was opened on: the view closed (however) or showing // another, it is dropped rather than written later to whatever row has its place. @@ -371,6 +381,7 @@ pub fn show(app: &mut RustGisApp, ui: &mut Ui) { if layer_id.is_none() && app.session.table_standalone.is_none() { app.table.stats = None; app.table.row_order = None; + app.table.current = None; return; } if app.table.stats.as_ref().is_some_and(|s| !s.of(app, layer_id)) { @@ -497,6 +508,24 @@ pub fn show(app: &mut RustGisApp, ui: &mut Ui) { (app.table.selected_only && is_layer).then_some(selection.as_slice()), ); let row_count = rows.map_or(ds.features.len(), <[usize]>::len); + let table = cursor::Shown { view: key, table_instance, ds: &ds, rows, columns: &shown }; + if app.table.current.as_mut().is_some_and(|c| !c.follow(&table)) { + app.table.current = None; + } + let mark = app.table.current.as_ref().and_then(|c| c.mark(&ds)); + // The place and field of the current cell, when this frame is to scroll to it. + let reveal = std::mem::take(&mut app.table.reveal) + .then(|| app.table.current.as_mut().and_then(|c| c.place(&table).zip(c.mark(&ds)).map(|(at, (_, field))| (at, field)))) + .flatten(); + // Sideways, the column's header is scrolled to: it is drawn wherever the rows are, and + // the rows' own scroll area keeps what is asked inside it. + let reveal_column = |ui: &Ui, field: Option| { + if reveal.is_some_and(|(_, f)| f == field) { + ui.scroll_to_rect_animation(ui.max_rect(), None, egui::style::ScrollAnimation::none()); + } + }; + // The place and field of the cell clicked. + let mut pressed: Option<(usize, Option)> = None; let mut clicked: Option<(usize, bool)> = None; let mut commits: Vec<(u64, usize, String, String)> = Vec::new(); // Whether the cell being typed in was laid out (its row scrolled into view). @@ -515,6 +544,8 @@ pub fn show(app: &mut RustGisApp, ui: &mut Ui) { // The row right-clicked, or whose menu is open. let mut menu_row: Option = None; egui::ScrollArea::horizontal().show(ui, |ui| { + // The table's width on screen. + let view = ui.clip_rect().x_range(); let mut tb = TableBuilder::new(ui) .striped(true) .resizable(true) @@ -524,14 +555,19 @@ pub fn show(app: &mut RustGisApp, ui: &mut Ui) { for _ in &shown { tb = tb.column(Column::initial(120.0).at_least(50.0).clip(true)); } + if let Some((at, _)) = reveal { + tb = tb.scroll_to_row(at, None).animate_scrolling(false); + } tb.min_scrolled_height(0.0) .header(24.0, |mut h| { h.col(|ui| { + reveal_column(ui, None); ui.label(egui::RichText::new(tl!("Feature ID")).font(semibold(11.5)).color(t.text_dim)) .on_hover_text(tl!("Feature identifier, not a dataset field or a row position.")); }); for &i in &shown { h.col(|ui| { + reveal_column(ui, Some(i)); let Some(fd) = ds.fields.get(i) else { return }; let arrow = match app.table.sort { Some((c, true)) if c == i => " ↑", @@ -630,6 +666,7 @@ pub fn show(app: &mut RustGisApp, ui: &mut Ui) { // and the cell right-clicked. let mut over: Option = None; let mut right: Option = None; + let at = row.index(); let mut take = |cell: egui::Response, text: Option, col: Option| { let cell = match text { Some(text) => cell | text, @@ -638,6 +675,9 @@ pub fn show(app: &mut RustGisApp, ui: &mut Ui) { if cell.secondary_clicked() { right = col; } + if cell.clicked() || cell.secondary_clicked() { + pressed = Some((at, col)); + } match over.as_mut() { Some(o) => *o |= cell, None => over = Some(cell), @@ -646,6 +686,9 @@ pub fn show(app: &mut RustGisApp, ui: &mut Ui) { let mut text = None; let (_, cell) = row.col(|ui| { text = Some(ui.label(egui::RichText::new(oid.to_string()).size(11.5).color(t.text_dim))); + if mark == Some((r, None)) { + cursor::outline(ui, &t, view); + } }); take(cell, text, None); for &c in &shown { @@ -684,24 +727,15 @@ pub fn show(app: &mut RustGisApp, ui: &mut Ui) { let txt = egui::RichText::new(shown).size(11.5); let txt = if matches!(v, V::Null) || picture { txt.color(t.text_disabled).italics() } else { txt }; let resp = ui.add(egui::Label::new(txt).sense(Sense::click()).truncate()); - if resp.double_clicked() && ds.fields.get(c).is_some_and(|f| ds.field_index(&f.name) != Some(c)) { - // Its value would be written to the field its name finds. - by_other_name = true; - } else if resp.double_clicked() { - // The cell being typed in is kept first (once: its - // editor may have kept it on losing the focus). - if let Some(e) = app.table.editing.take() - && !commits.iter().any(|q| q.0 == e.fid && q.1 == e.col) - && cancel != Some((e.fid, e.col)) - { - commits.push((e.fid, e.col, e.text, e.was)); - } - let text = if matches!(v, V::Null) { String::new() } else { v.to_string() }; - app.table.editing = Some(CellEdit::new(key, oid, c, text, &ds.fields, table_instance)); + if resp.double_clicked() { + by_other_name |= !table.open_editor((r, oid, c), &mut app.table.editing, &mut commits, cancel); } else if resp.clicked() { clicked = Some((r, ui.input(|i| i.modifiers.command || i.modifiers.shift))); } text = Some(resp); + if mark == Some((r, Some(c))) { + cursor::outline(ui, &t, view); + } } }); take(cell, text, Some(c)); @@ -718,6 +752,32 @@ pub fn show(app: &mut RustGisApp, ui: &mut Ui) { }); }); }); + // The frame's click, then its keys: a cell clicked and a key pressed in one frame act + // in that order. What they change shows on the next frame. + if let Some((at, field)) = pressed { + app.table.current = table.cell(at, field); + ui.ctx().request_repaint(); + } + for pressed_key in keys { + if pressed_key == egui::Key::Enter { + let Some(at) = app.table.current.as_mut().and_then(|c| c.editable(&table)) else { continue }; + // Pressed again before the editor was drawn (its row is being scrolled to): + // it stays as it is. + if !app.table.editing.as_ref().is_some_and(|e| e.fid == at.1 && e.col == at.2) { + by_other_name |= !table.open_editor(at, &mut app.table.editing, &mut commits, cancel); + } + } else if let Some(next) = table.step(app.table.current.as_mut(), pressed_key) { + app.table.current = Some(next); + } else { + continue; + } + app.table.reveal = true; + ui.ctx().request_repaint(); + // What was pressed after the Enter that opened a cell is not the table's. + if pressed_key == egui::Key::Enter { + break; + } + } if let Some(i) = sort_click { app.table.sort = match app.table.sort { Some((c, true)) if c == i => Some((i, false)), @@ -1323,6 +1383,476 @@ mod tests { assert_eq!(h.state().ui.copy_out.as_deref(), Some("Delta")); } + type Window = egui_kittest::Harness<'static, RustGisApp>; + + /// The whole window, as its frames run, so the keys are read where a frame reads them and the + /// pane in use follows the pointer. No right pane: more room for the table and the map. + fn window(mut app: RustGisApp) -> Window { + app.ui.right_open.clear(); + app.ui.right = None; + let mut h = egui_kittest::Harness::builder().with_size(vec2(1200.0, 900.0)).with_max_steps(64).with_step_dt(0.25).build_ui_state( + |ui, app: &mut RustGisApp| { + let ctx = ui.ctx().clone(); + app.logic(&ctx); + app.ui(ui); + }, + app, + ); + h.run_steps(6); + h + } + + /// An app whose table shows "Places", with fields Name, Note and Rank and editing on: four + /// points whose names and ranks sort them differently. + fn places() -> (RustGisApp, u32) { + use rustgis_engine::data::{FieldType, Geometry, GeometryType}; + use rustgis_engine::geom::Coord; + let mut app = RustGisApp::new(rustgis_engine::Session::new(rustgis_engine::Project::default())); + let schema = vec![Field::new("Name", FieldType::Text), Field::new("Note", FieldType::Text), Field::new("Rank", FieldType::Integer)]; + let mut ds = Dataset::new("Places", GeometryType::Point, schema); + for (i, (name, rank)) in [("Alpha", 3), ("Bravo", 1), ("Charlie", 4), ("Delta", 2)].into_iter().enumerate() { + let at = Geometry::Point(Coord::new(10.0 * i as f64, 0.0)); + ds.push(Some(at), vec![V::Text(name.into()), V::Text(format!("note {name}")), V::Int(rank)]); + } + let id = app.session.map_mut().add_dataset(ds); + app.session.table_layer = Some(id); + app.run("edit.enable", json!({"on": true})).unwrap(); + (app, id) + } + + /// Of two fields of one name, one is deleted: which of them the current cell was in can't be + /// told any more, so there is none, rather than one in the field that is left. + #[test] + fn the_current_cell_goes_when_a_field_of_its_name_does() { + use rustgis_engine::data::{FieldType, Geometry, GeometryType}; + use rustgis_engine::geom::Coord; + let mut app = RustGisApp::new(rustgis_engine::Session::new(rustgis_engine::Project::default())); + let schema = vec![Field::new("Name", FieldType::Text), Field::new("v", FieldType::Text), Field::new("v", FieldType::Text)]; + let mut ds = Dataset::new("Twins", GeometryType::Point, schema); + ds.push( + Some(Geometry::Point(Coord::new(0.0, 0.0))), + vec![V::Text("Alpha".into()), V::Text("first".into()), V::Text("second".into())], + ); + let id = app.session.map_mut().add_dataset(ds); + app.session.table_layer = Some(id); + let mut h = window(app); + h.get_by_label("first").click(); + h.run_steps(3); + assert!(h.state().table.current.is_some(), "the click made the cell current"); + // An unrelated field added leaves it. + h.state_mut().run("edit.addField", json!({"layer": id, "name": "Rank", "type": "long"})).unwrap(); + h.run_steps(3); + assert!(h.state().table.current.is_some(), "another field added leaves the current cell"); + h.state_mut().run("edit.deleteField", json!({"layer": id, "field": "v"})).unwrap(); + h.run_steps(3); + assert!(h.state().table.current.is_none(), "one of the two fields named v has gone"); + } + + /// The current cell as its row's Name and its field's name, "Feature ID" for that column. + fn current(h: &Window) -> Option<(String, String)> { + let app = h.state(); + let ds = match app.session.table_layer { + Some(id) => &app.session.map().layer(id)?.dataset, + None => &app.session.project.table(app.session.table_standalone?)?.dataset, + }; + let (row, field) = app.table.current.as_ref()?.mark(ds)?; + let field = field.map_or_else(|| "Feature ID".to_string(), |i| ds.fields[i].name.clone()); + Some((ds.value(row, ds.field_index("Name")?).to_string(), field)) + } + + /// What [`current`] answers for the cell of the row named `name`, in `field`. + fn at(name: &str, field: &str) -> Option<(String, String)> { + Some((name.to_string(), field.to_string())) + } + + /// A key pressed and let go. + fn key(h: &mut Window, key: egui::Key) { + h.key_press(key); + h.run_steps(2); + } + + /// A turn of the mouse wheel at `pos`, which makes the pane there the one in use. + fn wheel(h: &mut Window, pos: egui::Pos2, lines: f32) { + h.event(egui::Event::PointerMoved(pos)); + h.step(); + h.event(egui::Event::MouseWheel { + unit: egui::MouseWheelUnit::Line, + delta: vec2(0.0, lines), + modifiers: egui::Modifiers::NONE, + phase: egui::TouchPhase::Move, + source: egui::MouseWheelSource::Wheel, + }); + h.run_steps(8); + } + + /// Where the map or the layout is, above the table. + const ON_THE_VIEW: egui::Pos2 = egui::pos2(700.0, 350.0); + + /// A click makes a cell current, and each arrow moves it as the table shows its rows and + /// columns: sorted, filtered, reordered and with a column hidden. It stops at the edges, leaves + /// the selection alone, and goes with its feature, its field or its table. + #[test] + fn arrow_keys_move_the_current_cell_as_the_table_shows_it() { + use egui::Key::{ArrowDown, ArrowLeft, ArrowRight, ArrowUp}; + let (app, id) = places(); + let mut h = window(app); + assert_eq!(current(&h), None); + h.get_by_label("Bravo").click(); + h.run_steps(3); + assert_eq!(current(&h), at("Bravo", "Name")); + let selected = |h: &Window| h.state().session.map().layer(id).unwrap().selection.clone(); + assert_eq!(selected(&h), [1], "the click selects, as before"); + + for (pressed, want) in [ + (ArrowDown, ("Charlie", "Name")), + (ArrowRight, ("Charlie", "Note")), + (ArrowRight, ("Charlie", "Rank")), + (ArrowRight, ("Charlie", "Rank")), + (ArrowDown, ("Delta", "Rank")), + (ArrowDown, ("Delta", "Rank")), + (ArrowLeft, ("Delta", "Note")), + (ArrowLeft, ("Delta", "Name")), + (ArrowLeft, ("Delta", "Feature ID")), + (ArrowLeft, ("Delta", "Feature ID")), + (ArrowUp, ("Charlie", "Feature ID")), + (ArrowUp, ("Bravo", "Feature ID")), + (ArrowUp, ("Alpha", "Feature ID")), + (ArrowUp, ("Alpha", "Feature ID")), + ] { + key(&mut h, pressed); + assert_eq!(current(&h), at(want.0, want.1), "after {pressed:?}"); + assert_eq!(selected(&h), [1], "the selection stays"); + } + // A widget that has the keyboard (reached with Tab) keeps the keys: the cell stays. A + // click on a cell takes the keyboard back for the table. + key(&mut h, egui::Key::Tab); + assert!(h.ctx.memory(|m| m.focused()).is_some(), "Tab gave a widget the keyboard"); + key(&mut h, ArrowDown); + assert_eq!(current(&h), at("Alpha", "Feature ID"), "the arrows are the focused widget's"); + h.get_by_label("Bravo").click(); + h.run_steps(3); + assert_eq!(current(&h), at("Bravo", "Name")); + key(&mut h, ArrowUp); + key(&mut h, ArrowLeft); + assert_eq!(current(&h), at("Alpha", "Feature ID"), "the arrows are the table's again"); + assert_eq!(selected(&h), [1]); + // Two presses in one frame move twice. + h.input_mut().events.extend([ArrowDown, ArrowDown].map(|key| egui::Event::Key { + key, + physical_key: None, + pressed: true, + repeat: false, + modifiers: egui::Modifiers::NONE, + })); + h.run_steps(3); + assert_eq!(current(&h), at("Charlie", "Feature ID")); + // A held key repeats. + for (held, want) in [(ArrowUp, "Alpha"), (ArrowDown, "Charlie")] { + h.key_down(held); + h.key_down(held); + h.key_up(held); + h.run_steps(3); + assert_eq!(current(&h), at(want, "Feature ID"), "held {held:?}"); + } + + // Sorted by rank (Bravo, Delta, Alpha, Charlie), Rank moved to the front and Note hidden. + let fields = h.state().session.map().layer(id).unwrap().dataset.fields.clone(); + let instance = h.state().session.map().layer(id).unwrap().instance_id(); + let mut view = ColumnView::default(); + view.shift(&fields, 2, true); + view.shift(&fields, 2, true); + view.hide(&fields, 1); + h.state_mut().table.views.insert(ViewKey::Layer(instance), view); + h.run_steps(2); + h.get_by_label("Rank").click(); + h.run_steps(3); + assert_eq!(current(&h), at("Charlie", "Feature ID"), "the cell stays with its feature"); + for (pressed, want) in [ + (ArrowUp, ("Alpha", "Feature ID")), + (ArrowRight, ("Alpha", "Rank")), + (ArrowRight, ("Alpha", "Name")), + (ArrowRight, ("Alpha", "Name")), + (ArrowUp, ("Delta", "Name")), + (ArrowUp, ("Bravo", "Name")), + (ArrowUp, ("Bravo", "Name")), + ] { + key(&mut h, pressed); + assert_eq!(current(&h), at(want.0, want.1), "sorted, after {pressed:?}"); + } + // Filtered to the names with an "l" (Delta, Alpha, Charlie): Bravo is left out, so an arrow + // starts at the first row shown, in the same column. + h.state_mut().table.filter = "l".into(); + h.run_steps(2); + for (pressed, want) in [(ArrowDown, "Delta"), (ArrowDown, "Alpha"), (ArrowDown, "Charlie"), (ArrowDown, "Charlie")] { + key(&mut h, pressed); + assert_eq!(current(&h), at(want, "Name"), "filtered, after {pressed:?}"); + } + // A hidden column's cell starts again at the first column, in the same row. + let mut view = ColumnView::default(); + view.hide(&fields, 0); + h.state_mut().table.views.insert(ViewKey::Layer(instance), view); + h.state_mut().table.filter.clear(); + h.state_mut().table.sort = None; + h.run_steps(2); + key(&mut h, ArrowUp); + assert_eq!(current(&h), at("Charlie", "Feature ID")); + assert_eq!(selected(&h), [1]); + + // Edits under it: another field added and a row before it deleted leave it; its own field + // or feature gone, it goes. Then the first arrow starts at the first row and column. + key(&mut h, ArrowRight); + assert_eq!(current(&h), at("Charlie", "Note")); + h.state_mut().run("edit.addField", json!({"layer": id, "name": "Extra", "type": "long"})).unwrap(); + h.state_mut().run("edit.delete", Value::Null).unwrap(); + h.run_steps(2); + assert_eq!(current(&h), at("Charlie", "Note"), "Bravo, above it, was deleted"); + h.state_mut().run("edit.deleteField", json!({"layer": id, "field": "Note"})).unwrap(); + h.run_steps(2); + assert!(h.state().table.current.is_none(), "its field is gone"); + key(&mut h, ArrowDown); + assert_eq!(current(&h), at("Alpha", "Feature ID")); + h.state_mut().run("select.rows", json!({"layer": id, "rows": [0], "mode": "new"})).unwrap(); + h.state_mut().run("edit.delete", Value::Null).unwrap(); + h.run_steps(2); + assert!(h.state().table.current.is_none(), "its feature is gone"); + + // Another table, and another project, start with none. + let table = h.state_mut().run("layer.addDataText", json!({"fileName": "sites.csv", "text": "Name\nEcho\nFoxtrot\n"})).unwrap(); + key(&mut h, ArrowDown); + assert!(h.state().table.current.is_some()); + h.state_mut().session.table_layer = None; + h.state_mut().session.table_standalone = table["id"].as_u64().and_then(|id| u32::try_from(id).ok()); + h.run_steps(2); + assert!(h.state().table.current.is_none(), "another table"); + h.get_by_label("Echo").click(); + h.run_steps(3); + key(&mut h, ArrowDown); + assert_eq!(current(&h), at("Foxtrot", "Name"), "a standalone table's cells too"); + h.state_mut().run("project.new", Value::Null).unwrap(); + h.run_steps(2); + assert!(h.state().table.current.is_none(), "another project"); + } + + /// The arrows are the table's only while it is the pane in use and nothing is being typed: with + /// the map in use they pan it; a text box keeps them; and a selected layout element is nudged + /// only while the layout is in use. + #[test] + fn the_cell_keys_are_the_tables_only_while_it_is_in_use() { + use crate::inuse::{Pane, pane}; + use egui::Key::{ArrowDown, ArrowRight, Enter}; + let (app, id) = places(); + let mut h = window(app); + let center = |h: &Window| { + let at = h.state().session.map().camera.center_lonlat(); + (at.x, at.y) + }; + h.get_by_label("Alpha").click(); + h.run_steps(3); + assert_eq!(pane(h.state()), Pane::Table); + let before = center(&h); + key(&mut h, ArrowDown); + assert_eq!(current(&h), at("Bravo", "Name")); + assert_eq!(center(&h), before, "the map doesn't pan too"); + + wheel(&mut h, ON_THE_VIEW, 1.0); + assert_eq!(pane(h.state()), Pane::View); + let before = center(&h); + key(&mut h, ArrowDown); + key(&mut h, Enter); + assert_eq!(current(&h), at("Bravo", "Name"), "the map is in use"); + assert!(h.state().table.editing.is_none()); + assert_ne!(center(&h), before, "the arrow pans the map"); + + // In the filter box the arrows move its cursor, and Enter leaves the cell alone. + h.get_by_label("Alpha").click(); + h.run_steps(3); + let row = h.get_by_label("Selected only").rect().center().y; + let inputs = h.query_all_by_role(egui::accesskit::Role::TextInput); + let filter: Vec<_> = inputs.filter(|n| (n.rect().center().y - row).abs() < 12.0).collect(); + assert_eq!(filter.len(), 1, "the filter box is the text box in the table's toolbar"); + filter[0].click(); + h.run_steps(3); + assert!(h.ctx.egui_wants_keyboard_input(), "the cursor is in the filter box"); + assert_eq!(pane(h.state()), Pane::Table); + key(&mut h, ArrowDown); + key(&mut h, ArrowRight); + assert_eq!(current(&h), at("Alpha", "Name")); + key(&mut h, Enter); + assert!(h.state().table.editing.is_none()); + + // A key the user bound to a command still runs it. + let bound = crate::keymap::Chord::parse("ArrowRight").unwrap(); + h.state_mut().ui.keymap.assign(bound, "select.clear", Value::Null); + h.get_by_label("Alpha").click(); + h.run_steps(3); + key(&mut h, ArrowRight); + assert!(h.state().session.map().layer(id).unwrap().selection.is_empty(), "the shortcut ran"); + assert_eq!(current(&h), at("Alpha", "Name"), "and the cell stayed"); + h.state_mut().ui.keymap.remove(bound); + + // A layout's element selected: the arrows are the cells' while the table is in use. + h.state_mut().run("layout.new", json!({"name": "Sheet"})).unwrap(); + let li = h.state().session.active_layout.unwrap(); + let title = h.state().session.project.layouts[li].elements.iter().find(|e| e.name == "Title").unwrap().id; + h.run_steps(3); + h.get_by_label("Alpha").click(); + h.run_steps(3); + h.state_mut().layout.selected = Some(title); + h.run_steps(2); + let place = |h: &Window| { + let e = h.state().session.project.layouts[li].element(title).unwrap(); + (e.x, e.y) + }; + let before = place(&h); + key(&mut h, ArrowDown); + h.key_press_modifiers(egui::Modifiers::SHIFT, ArrowDown); + h.run_steps(2); + assert_eq!(current(&h), at("Bravo", "Name")); + assert_eq!(place(&h), before, "no nudge, with Shift or without"); + wheel(&mut h, ON_THE_VIEW, 1.0); + assert_eq!(pane(h.state()), Pane::View); + key(&mut h, ArrowDown); + assert_ne!(place(&h), before, "the layout is in use"); + assert_eq!(current(&h), at("Bravo", "Name")); + } + + /// Enter edits the current cell as a double-click does: the value typed is kept, Escape leaves + /// it, a held Enter doesn't reopen it, and Feature ID or a dialog up leave Enter alone. + #[test] + fn enter_edits_the_current_cell() { + use egui::Key::{ArrowDown, ArrowLeft, Enter, Escape}; + let (app, id) = places(); + let mut h = window(app); + let name = |h: &Window, row: usize| h.state().session.map().layer(id).unwrap().dataset.value(row, 0).to_string(); + h.get_by_label("Alpha").click(); + h.run_steps(3); + let selected = h.state().session.map().layer(id).unwrap().selection.clone(); + key(&mut h, ArrowDown); + key(&mut h, Enter); + let fid = h.state().session.map().layer(id).unwrap().dataset.features.row(1).unwrap().id(); + assert_eq!(h.state().table.editing.as_ref().map(|e| (e.fid, e.col)), Some((fid, 0)), "the current cell, not the selected"); + h.event(egui::Event::Text(" two".into())); + h.run_steps(2); + // The arrows are the editor's. + key(&mut h, ArrowDown); + assert_eq!(current(&h), at("Bravo", "Name")); + // Enter held: it keeps the value, and its repeat doesn't open the cell again. + h.key_down(Enter); + h.run_steps(2); + h.key_down(Enter); + h.run_steps(2); + h.key_up(Enter); + h.run_steps(2); + assert_eq!(name(&h, 1), "Bravo two"); + assert!(h.state().table.editing.is_none(), "the editor closed"); + assert_eq!(current(&h), at("Bravo two", "Name"), "still the current cell"); + assert_eq!(h.state().session.map().layer(id).unwrap().selection, selected); + + key(&mut h, Enter); + h.event(egui::Event::Text(" no".into())); + h.run_steps(2); + key(&mut h, Escape); + assert!(h.state().table.editing.is_none()); + assert_eq!(name(&h, 1), "Bravo two", "Escape leaves it"); + key(&mut h, ArrowDown); + assert_eq!(current(&h), at("Charlie", "Name"), "the arrows are the table's again"); + + // With editing turned off it opens, and keeping the value says why it can't. + h.state_mut().run("edit.enable", json!({"on": false})).unwrap(); + let mark = h.state().session.notice_mark(); + key(&mut h, Enter); + h.event(egui::Event::Text("x".into())); + h.run_steps(2); + key(&mut h, Enter); + assert_eq!(name(&h, 2), "Charlie"); + assert!(h.state().session.notices_since(mark).iter().any(|n| n.text.contains("editing is turned off"))); + h.state_mut().run("edit.enable", json!({"on": true})).unwrap(); + + // A dialog that is up has Enter. + h.state_mut().run("ui.dialog", json!({"name": "bookmark"})).unwrap(); + h.run_steps(3); + key(&mut h, Enter); + assert!(h.state().table.editing.is_none(), "Enter was the dialog's"); + h.state_mut().dialogs.open = None; + h.run_steps(2); + + // Feature ID can't be edited. + h.get_by_label("Alpha").click(); + h.run_steps(3); + key(&mut h, ArrowLeft); + assert_eq!(current(&h), at("Alpha", "Feature ID")); + key(&mut h, Enter); + assert!(h.state().table.editing.is_none()); + } + + /// The table scrolls, down and sideways, to keep the current cell in view, and Enter scrolls + /// back to a cell scrolled away from before it edits it. + #[test] + fn the_table_scrolls_to_the_current_cell() { + use egui::Key::{ArrowDown, ArrowLeft, ArrowRight, ArrowUp, Enter}; + let names: Vec = (0..14).map(|c| format!("field{c}")).collect(); + let mut ds = + Dataset::new("Grid", rustgis_engine::data::GeometryType::Point, fields(&names.iter().map(String::as_str).collect::>())); + for r in 0..200 { + ds.push(None, (0..14).map(|c| V::Text(format!("r{r}c{c}"))).collect()); + } + let mut app = RustGisApp::new(rustgis_engine::Session::new(rustgis_engine::Project::default())); + let id = app.session.map_mut().add_dataset(ds); + app.session.table_layer = Some(id); + app.run("edit.enable", json!({"on": true})).unwrap(); + let mut h = window(app); + h.get_by_label("r0c0").click(); + h.run_steps(3); + // Where the table's columns start, right of the Layers pane. + let left = h.get_by_label("Feature ID").rect().left() - 8.0; + // Drawn inside the table: right of its edge, below the column headers and above the + // status bar. + let in_view = |h: &Window, cell: &str| { + let header = h.get_by_label("Feature ID").rect().bottom(); + let Some(r) = h.query_by_label(cell).map(|n| n.rect()) else { return false }; + r.left() >= left && r.right() <= 1200.0 && r.top() >= header && r.bottom() <= 875.0 + }; + // A key, and the frames in which the scroll it asks for is drawn. + let step = |h: &mut Window, pressed: egui::Key| { + key(h, pressed); + h.run_steps(2); + }; + assert!(in_view(&h, "r0c0") && !in_view(&h, "r40c0") && !in_view(&h, "r0c13")); + for row in 1..=40 { + step(&mut h, ArrowDown); + assert!(in_view(&h, &format!("r{row}c0")), "row {row} is in view"); + } + for column in 1..14 { + step(&mut h, ArrowRight); + assert!(in_view(&h, &format!("r40c{column}")), "column {column} is in view"); + } + for column in (0..13).rev() { + step(&mut h, ArrowLeft); + assert!(in_view(&h, &format!("r40c{column}")), "column {column} is back in view"); + } + step(&mut h, ArrowLeft); + let id_header = h.get_by_label("Feature ID").rect(); + assert!(id_header.left() >= left, "the Feature ID column is in view: {id_header:?}"); + step(&mut h, ArrowRight); + for row in (0..40).rev() { + step(&mut h, ArrowUp); + assert!(in_view(&h, &format!("r{row}c0")), "row {row} is back in view"); + } + + // Scrolled far from the cell, Enter scrolls back and the editor takes what is typed. + let on_table = h.get_by_label("r2c3").rect().center(); + wheel(&mut h, on_table, -60.0); + assert!(h.query_by_label("r0c0").is_none(), "scrolled away"); + key(&mut h, Enter); + h.run_steps(4); + h.event(egui::Event::Text("!".into())); + h.run_steps(2); + key(&mut h, Enter); + let value = h.state().session.map().layer(id).unwrap().dataset.value(0, 0).to_string(); + assert_eq!(value, "r0c0!"); + assert!(in_view(&h, "r0c0!"), "and the table shows it"); + } + fn fields(names: &[&str]) -> Vec { names.iter().map(|n| Field::new(*n, rustgis_engine::data::FieldType::Text)).collect() } diff --git a/crates/ui-egui/src/table/cursor.rs b/crates/ui-egui/src/table/cursor.rs new file mode 100644 index 0000000000..f5d8aa5aeb --- /dev/null +++ b/crates/ui-egui/src/table/cursor.rs @@ -0,0 +1,222 @@ +//! The attribute table's current cell: the one last clicked, which the arrow keys move and Enter +//! edits. View state only: never saved, and no command sees it. + +use std::sync::Weak; + +use egui::{Context, Event, Key, Rangef, Stroke, StrokeKind, Ui}; +use rustgis_engine::data::{Dataset, Feature, Value}; + +use super::{CellEdit, ViewKey, tag}; +use crate::RustGisApp; +use crate::inuse::Pane; +use crate::theme::Tokens; + +/// Takes the table's keys while it is the pane in use: the arrows with no modifier, and Enter +/// while there is a current cell. [`crate::chrome::shortcuts`] calls it once the shortcuts have +/// taken theirs, and not while text is being typed, so nothing drawn later in the frame takes +/// these too. [`super::show`] acts on them. +pub(crate) fn take_keys(app: &mut RustGisApp, ctx: &Context) { + // An open menu is over the table: no cell moves or opens under it. And a widget that has the + // keyboard (a toolbar button reached with Tab) keeps the keys: Enter presses it, and the + // arrows move the focus on. + if crate::inuse::pane(app) != Pane::Table || egui::Popup::is_any_open(ctx) || ctx.memory(|m| m.focused()).is_some() { + return; + } + // A dialog that is up has Enter for itself. + let enter = app.table.current.is_some() && app.table.dates.is_none() && app.dialogs.open.is_none() && app.ui.choosing.is_empty(); + let keys = &mut app.table.keys; + ctx.input_mut(|input| { + input.events.retain(|event| { + let Event::Key { key, pressed: true, repeat, modifiers, .. } = event else { return true }; + match key { + _ if !modifiers.is_none() => true, + Key::ArrowUp | Key::ArrowDown | Key::ArrowLeft | Key::ArrowRight => { + keys.push(*key); + false + } + Key::Enter if enter => { + // Held after it kept a value, its repeats would open the cell again. + if !*repeat { + keys.push(*key); + } + false + } + _ => true, + } + }); + }); +} + +/// The table as the frame draws it. +pub(super) struct Shown<'a> { + pub view: ViewKey, + pub table_instance: Option, + pub ds: &'a Dataset, + /// The rows shown, each by its row in the dataset, or None for all of them in its order. + pub rows: Option<&'a [usize]>, + /// The fields shown, in the order of their columns, which follow Feature ID's. + pub columns: &'a [usize], +} + +impl Shown<'_> { + /// The cell in the row at place `at` of those shown, in field `field` (None: Feature ID). + pub fn cell(&self, at: usize, field: Option) -> Option { + let row = match self.rows { + Some(rows) => *rows.get(at)?, + None => at, + }; + let fid = self.ds.features.row(row)?.id(); + let field = match field { + Some(i) => Some(tag(&self.ds.fields, i)?), + None => None, + }; + let named = field.as_ref().map_or(0, |(name, _)| self.ds.fields.iter().filter(|f| &f.name == name).count()); + let source = self.ds.features.allocation_key(); + Some(Current { view: self.view, table_instance: self.table_instance, fid, field, named, row, at, source }) + } + + /// Where an arrow key puts the current cell: one row or column on, as shown, or None at an + /// edge. With no current cell, it goes to the first row and column shown; with its row or its + /// column no longer shown, to the first of those, keeping the other. + pub fn step(&self, current: Option<&mut Current>, key: Key) -> Option { + let (at, column) = current.map_or((None, None), |c| (c.place(self), c.column(self))); + let (at, column) = match (at, column) { + (Some(at), Some(column)) => match key { + Key::ArrowUp => (at.checked_sub(1)?, column), + Key::ArrowDown => (at.checked_add(1)?, column), + Key::ArrowLeft => (at, column.checked_sub(1)?), + Key::ArrowRight => (at, column.checked_add(1)?), + _ => return None, + }, + (at, column) => (at.unwrap_or(0), column.unwrap_or(0)), + }; + let field = match column.checked_sub(1) { + Some(i) => Some(*self.columns.get(i)?), + None => None, + }; + self.cell(at, field) + } + + /// Opens the editor on field `field` of feature `fid`, in row `row`: what a double-click on a + /// cell does, and Enter on the current one. What the editor open before it holds is kept first, + /// in `commits` (once: it may have been kept on losing the focus, or left by `cancel`). False, + /// with nothing changed, for a column whose name finds another field, where its value would be + /// written. + pub fn open_editor( + &self, + (row, fid, field): (usize, u64, usize), + editing: &mut Option, + commits: &mut Vec<(u64, usize, String, String)>, + cancel: Option<(u64, usize)>, + ) -> bool { + let fields = &self.ds.fields; + if fields.get(field).is_some_and(|f| self.ds.field_index(&f.name) != Some(field)) { + return false; + } + if let Some(e) = editing.take() + && !commits.iter().any(|q| q.0 == e.fid && q.1 == e.col) + && cancel != Some((e.fid, e.col)) + { + commits.push((e.fid, e.col, e.text, e.was)); + } + let value = self.ds.value(row, field); + let text = if matches!(value, Value::Null) { String::new() } else { value.to_string() }; + *editing = Some(CellEdit::new(self.view, fid, field, text, fields, self.table_instance)); + true + } +} + +/// The current cell. Its feature is kept by id and its field by [`tag`], so sorting, filtering, +/// hiding or moving columns and edits to other rows and fields leave it where it is. +pub(super) struct Current { + view: ViewKey, + /// Which standalone table it is of: another can take its id. + table_instance: Option, + fid: u64, + /// None for the Feature ID cell. + field: Option<(String, usize)>, + /// How many fields had its field's name. With another number of them (one of a repeated name + /// added or deleted), which of them it was can't be told, and the cell is dropped. + named: usize, + /// The feature's row in the dataset, and its place among the rows shown, when last found. + /// Looked at first, so the rows are searched only once they or their order have changed. + row: usize, + at: usize, + /// The rows it was found in ([`rustgis_engine::data::Features::allocation_key`]). + source: Weak>, +} + +impl Current { + /// The index of its field: Some(None) for Feature ID, None when the field has gone. + fn field_index(&self, ds: &Dataset) -> Option> { + let Some((name, nth)) = &self.field else { return Some(None) }; + let named = || ds.fields.iter().enumerate().filter(|(_, f)| &f.name == name); + if named().count() != self.named { + return None; + } + named().nth(*nth).map(|(i, _)| Some(i)) + } + + /// Keeps up with the table as it is now. False, for the cell to be dropped, when the table + /// shows another layer or table, or the feature or the field has gone. The feature is looked + /// for only after a change to the rows, and in every row only when it left its own. + pub fn follow(&mut self, table: &Shown) -> bool { + if self.view != table.view || self.table_instance != table.table_instance || self.field_index(table.ds).is_none() { + return false; + } + let source = table.ds.features.allocation_key(); + if !self.source.ptr_eq(&source) { + if table.ds.features.row(self.row).is_none_or(|r| r.id() != self.fid) { + let Some(row) = table.ds.features.rows().position(|r| r.id() == self.fid) else { return false }; + self.row = row; + } + self.source = source; + } + true + } + + /// The cell to outline: its row in the dataset and its field (None: Feature ID). + pub fn mark(&self, ds: &Dataset) -> Option<(usize, Option)> { + Some((self.row, self.field_index(ds)?)) + } + + /// Its place among the rows shown, or None when the filter or Selected only leaves it out. + pub fn place(&mut self, table: &Shown) -> Option { + match table.rows { + None => self.at = self.row, + Some(rows) if rows.get(self.at) == Some(&self.row) => {} + Some(rows) => self.at = rows.iter().position(|&r| r == self.row)?, + } + Some(self.at) + } + + /// Its column among those shown, Feature ID's being the first; None when its field is hidden. + fn column(&self, table: &Shown) -> Option { + match self.field_index(table.ds)? { + Some(field) => table.columns.iter().position(|&c| c == field).map(|i| i + 1), + None => Some(0), + } + } + + /// What Enter edits: the row, feature and field of a cell that is shown. None for a Feature ID + /// cell, which can't be edited, and for a cell the table leaves out. + pub fn editable(&mut self, table: &Shown) -> Option<(usize, u64, usize)> { + self.place(table)?; + let field = self.field_index(table.ds)??; + table.columns.contains(&field).then_some((self.row, self.fid, field)) + } +} + +/// The current cell's outline, around the cell `ui` is. It reaches halfway into the gap before +/// the cell, to stand clear of the text, but not past `view`, the table's width on screen. +pub(super) fn outline(ui: &Ui, t: &Tokens, view: Rangef) { + let gap = ui.spacing().item_spacing.x * 0.5; + let (mut rect, mut clip) = (ui.max_rect(), ui.clip_rect()); + rect.min.x = (rect.min.x - gap).max(view.min); + clip.min.x = (clip.min.x - gap).max(view.min); + if rect.is_positive() { + let mut painter = ui.painter().clone(); + painter.set_clip_rect(clip); + painter.rect_stroke(rect, 2.0, Stroke::new(1.5, t.accent), StrokeKind::Inside); + } +} diff --git a/docs/user-guide/analysis.md b/docs/user-guide/analysis.md index c04e43237c..7aa9f7e48a 100644 --- a/docs/user-guide/analysis.md +++ b/docs/user-guide/analysis.md @@ -32,6 +32,16 @@ deletes the selection, adds or calculates a field, and calculates geometry attri The first column, **Feature ID**, shows each feature's identifier, not its current row position after sorting or filtering. It is not a dataset field: do not use it as a geoprocessing field name. +The cell last clicked is the current cell, shown with an outline. After a click or a scroll in the +table, the **arrow keys** move it: up and down through the rows as the table sorts and filters them, +left and right through the columns shown, **Feature ID** first. It stops at the edges, the table +scrolls to keep it in view, and a held key keeps moving. With no current cell, or with its row or +column no longer shown, an arrow starts at the first row or column shown. Moving it doesn't change +the selection. **Enter** edits it, as a double-click does (Feature ID can't be edited). While the +table is in use the arrow keys don't pan, turn or tilt the map or nudge a layout element; click or +scroll the map or layout and they do again. While you type in a cell or in **Filter rows…**, the +keys are the text box's. A shortcut you give an arrow key or Enter still runs its command. + Right-click a row for **Zoom To**, **Remove from Selection**, **Copy** (the feature, as **Copy** in the ribbon does), **Copy Value** (the text of the cell clicked; a number is copied in full and a picture gives its stored data) and **Delete** (Undo brings the rows back; greyed while diff --git a/docs/user-guide/index.md b/docs/user-guide/index.md index 94bae3db3c..611fe73ceb 100644 --- a/docs/user-guide/index.md +++ b/docs/user-guide/index.md @@ -549,6 +549,7 @@ with `{"layer":"parcels"}`. | ++delete++ | Delete selected features; with Edit Vertices, the chosen vertex; in a layout, the selected element; in the layer list, remove the selected layers (++backspace++ too) | | ++ctrl+d++ | Duplicate the selected layout element | | Arrow keys / ++shift++ + arrow keys | Nudge the selected layout element / nudge it further | +| Arrow keys / ++enter++ | In the attribute table, move the current cell / edit it | | ++alt+shift+right++ / ++alt+shift+left++ | Indent the active layer into the group above it / outdent it out of its group | | ++alt+shift+up++ / ++alt+shift+down++ | Move the active layer up / down one step in the Layers pane | | ++f2++ | Rename the active layer; on the map and layout tabs, and in a layout, the map or layout in view | @@ -559,10 +560,12 @@ On macOS, ++cmd++ takes the place of ++ctrl++. **Help › Shortcuts** lists them from the same table the app runs them from. While you type in a text field, undo and redo take back its typing, not the project's last change. -++delete++ and ++f2++ act on the part of the window you last clicked, dragged or scrolled in. -Click a layer in the Layers pane and ++delete++ removes it (Undo brings it back), whatever is -selected on the map; click or scroll the map and it deletes the selected features again. When -++delete++ has nothing to act on, a notice says why. +++delete++, ++f2++ and the arrow keys act on the part of the window you last clicked, dragged or +scrolled in. Click a layer in the Layers pane and ++delete++ removes it (Undo brings it back), +whatever is selected on the map; click or scroll the map and it deletes the selected features +again. When ++delete++ has nothing to act on, a notice says why. In the +[attribute table](analysis.md#the-attribute-table) the arrow keys move between cells; on the map +they pan it, and in a layout they nudge the selected element. Copy and Paste follow it too. In the Layers pane they copy and paste the selected layers, as **Copy Layer** and **Paste Layer** in a layer's menu do: the copies go above the active layer, or at the diff --git a/docs/user-guide/layouts.md b/docs/user-guide/layouts.md index 0af58791e4..96aee2263e 100644 --- a/docs/user-guide/layouts.md +++ b/docs/user-guide/layouts.md @@ -586,7 +586,8 @@ Layouts open as tabs next to the maps; while one is open, its groups lead the Pu **Delete** (or **Backspace**, the delete key on a Mac) deletes the selected element, and **Ctrl+D** (**⌘D** on a Mac) duplicates it: the copy is placed 5 mm down and to the right, on top, and selected. The **arrow keys** nudge it 1 mm, or - 10 mm with **Shift**, and keep it moving while held; a run of nudges is one step to undo. + 10 mm with **Shift**, and keep it moving while held; a run of nudges is one step to undo. After + a click or a scroll in the attribute table, the arrows move between its cells instead. **Right-click** an element to select it and open a menu of Duplicate, Delete, the four Arrange steps and, on a map frame, **Zoom Frame** (the map view's extent, as a double-click does). - **Arrange**: elements later in the layout are drawn over earlier ones, and a click picks the one diff --git a/docs/user-guide/maps.md b/docs/user-guide/maps.md index 66466651dd..e0bb6cfd1f 100644 --- a/docs/user-guide/maps.md +++ b/docs/user-guide/maps.md @@ -71,7 +71,9 @@ view to it, and says so. **Rotating and tilting the map.** Drag with the right mouse button, or hold ++ctrl++ and drag with the Pan tool, to turn the map about the centre of the view (to the right turns it clockwise) and to tilt it (up tilts it further), as in MapLibre; or hold ++shift++ and press ++arrow-left++ or ++arrow-right++ to turn it, ++arrow-up++ or ++arrow-down++ -to tilt it. The north arrow turns with the map to point north and leans back as it tilts; click +to tilt it (after a click or a scroll in the +[attribute table](analysis.md#the-attribute-table), the arrow keys move between its cells +instead). The north arrow turns with the map to point north and leans back as it tilts; click it to face north and look straight down again. The bearing (the compass direction the top of the view faces, in degrees clockwise from north) and the pitch (the tilt from looking straight down, 0 to 85 degrees) work as in MapLibre. They are saved with the project, its bookmarks and bookmark