From 138deb8ea81f24c1fa5ae4662e08384b05e9ddd7 Mon Sep 17 00:00:00 2001 From: mavrick Date: Thu, 26 Nov 2026 19:25:29 -0600 Subject: [PATCH] feat(ui): the map's coordinate system from its entry in the layer list, and a status bar button that looks like one MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The map's entry at the top of the Layers pane now has the map's menu, as its tab and the Browser do, and that menu gains Coordinate System…. The row is greyed, with the reason, for a map that is not in view, as the dialog changes only the map in view. The coordinate system and the pointer coordinates in the status bar are small framed buttons. Narrower gaps around them make up for their padding. --- crates/ui-egui/src/chrome.rs | 19 +++++---- crates/ui-egui/src/panes.rs | 77 +++++++++++++++++++++++++++++------- docs/user-guide/index.md | 6 +-- docs/user-guide/maps.md | 6 ++- docs/user-guide/workspace.md | 20 +++++----- 5 files changed, 93 insertions(+), 35 deletions(-) diff --git a/crates/ui-egui/src/chrome.rs b/crates/ui-egui/src/chrome.rs index 7639439e34..d6fedcd9fa 100644 --- a/crates/ui-egui/src/chrome.rs +++ b/crates/ui-egui/src/chrome.rs @@ -466,6 +466,12 @@ pub fn status_bar(app: &mut RustGisApp, ui: &mut Ui) { if resp.clicked() && !level { let _ = app.run("map.resetNorth", json!({})); } + // The pointer's coordinates and the map's coordinate system change on a click, so + // they are buttons, framed to look it. The two buttons' padding takes what the three + // narrower gaps give up, so the bar, full in a narrow window, stays about as wide. + let (gap, padding) = (ui.spacing().item_spacing.x, ui.spacing().button_padding.x); + ui.spacing_mut().item_spacing.x = 6.0; + ui.spacing_mut().button_padding.x = 3.0; sep(ui, &t); // Pointer coordinates. let format = app.map.coord_format; @@ -482,12 +488,9 @@ pub fn status_bar(app: &mut RustGisApp, ui: &mut Ui) { if let Some(s) = system.as_ref().filter(|_| format == crate::CoordReadout::Layer && kept.is_some()) { text = format!("{text} {}", s.name()); } - let resp = ui.add( - egui::Label::new( - egui::RichText::new(text).monospace().size(11.5).color(if live { t.text_dim } else { t.text_disabled }), - ) - .sense(Sense::click()), - ); + // Dimmed, not disabled: in its frame, disabled text would look like a button that is off. + let color = if live { t.text } else { t.text_dim }; + let resp = ui.add(egui::Button::new(egui::RichText::new(text).monospace().size(11.5).color(color)).small()); if resp.on_hover_text(format.hover()).clicked() { let _ = app.run("ui.coordinateFormat", Value::Null); } @@ -496,10 +499,12 @@ pub fn status_bar(app: &mut RustGisApp, ui: &mut Ui) { rustgis_engine::map::Projection::WebMercator => tl!("WGS 84 / Web Mercator").to_string(), p => tl!(p.label().as_str()).to_string(), }; - let resp = ui.add(egui::Label::new(egui::RichText::new(projection).size(11.0).color(t.text_dim)).sense(Sense::click())); + let resp = ui.add(egui::Button::new(egui::RichText::new(projection).size(11.0)).small()); if resp.on_hover_text(tl!("Change the map's coordinate system")).clicked() { let _ = app.run("ui.dialog", json!({"name": "coordinateSystem"})); } + ui.spacing_mut().item_spacing.x = gap; + ui.spacing_mut().button_padding.x = padding; sep(ui, &t); let n = app.session.map().selection_count(); ui.label( diff --git a/crates/ui-egui/src/panes.rs b/crates/ui-egui/src/panes.rs index 44b1c1acde..6af05246b3 100644 --- a/crates/ui-egui/src/panes.rs +++ b/crates/ui-egui/src/panes.rs @@ -697,6 +697,8 @@ fn filter_shows(q: &str, name: &str) -> bool { q.is_empty() || name.to_lowercase().contains(q) } +/// The Layers pane: the name filter and the view buttons, then the map's entry (right-click for +/// the map's menu) over the layers and tables as the view picked lists them. fn contents(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens) { // The name filter (#300), above the list so it stays in view. let map_name = app.session.map().name.clone(); @@ -756,15 +758,15 @@ fn contents(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens) { ui.label(egui::RichText::new(&map_name).font(semibold(12.5))); }) .response; - // The map's row takes copied layers (#491), at the top: there is one even with no layers. - // Across the pane, like the layer rows, not just its name. + // The map's row has the map's menu, as its tab does, which pastes copied layers on top + // (#491): there is one even with no layers. Across the pane, like the layer rows, not + // just its name. let row = Rect::from_min_max(header.rect.min, pos2(ui.max_rect().max.x, header.rect.max.y)); let header = ui.interact(row, egui::Id::unique("layers_map_header"), Sense::click()); - header.context_menu(|ui| { - if paste_layers_button(app, ui) { - ui.close(); - } - }); + // Not named by the map alone, which is its view tab's name. + let label = crate::i18n::fmt("Map: {name}", &[("name", &map_name)]); + header.widget_info(|| egui::WidgetInfo::labeled(egui::Role::Button, true, &label)); + header.context_menu(|ui| map_menu(app, ui, &map_name)); let layers: Vec = app.session.map().layers.clone(); let groups = app.session.map().service_groups.clone(); let layer_groups = app.session.map().groups.clone(); @@ -958,14 +960,11 @@ fn paste_label(app: &RustGisApp) -> &'static str { } } -/// A button pasting the copied layers (#491) on top of the map in view, off while none are; -/// returns whether it was clicked. -fn paste_layers_button(app: &mut RustGisApp, ui: &mut Ui) -> bool { - let clicked = ui.add_enabled(app.session.layer_clipboard.is_some(), egui::Button::new(paste_label(app))).clicked(); - if clicked { +/// A button pasting the copied layers (#491) on top of the map in view, off while none are. +fn paste_layers_button(app: &mut RustGisApp, ui: &mut Ui) { + if ui.add_enabled(app.session.layer_clipboard.is_some(), egui::Button::new(paste_label(app))).clicked() { let _ = app.run("layer.paste", Value::Null); } - clicked } /// The Layers pane's filter box: the shared search field (#337) within the pane's 10 px margins, @@ -7850,7 +7849,8 @@ fn raster_masking(app: &mut RustGisApp, ui: &mut Ui, l: &Layer, d: &rustgis_engi }); } -/// A map's menu, in the Browser and on its view tab: rename, duplicate, paste layers, delete. +/// A map's menu, in the Browser, on its view tab and on its entry in the layer list: rename, +/// duplicate, paste layers, coordinate system, move, delete. pub(crate) fn map_menu(app: &mut RustGisApp, ui: &mut Ui, m: &str) { if ui.button(tl!("Rename…")).clicked() { let _ = app.run("ui.dialog", json!({"name": "renameMap", "target": m})); @@ -7869,6 +7869,12 @@ pub(crate) fn map_menu(app: &mut RustGisApp, ui: &mut Ui, m: &str) { let _ = app.run("layer.paste", json!({"map": m})); ui.close(); } + // The dialog changes the map in view only, so another map's row is off, and says why. + let crs = ui.add_enabled(app.session.map().name == m, egui::Button::new(tl!("Coordinate System…"))); + if crs.on_disabled_hover_text(tl!("Open this map to change its coordinate system")).clicked() { + let _ = app.run("ui.dialog", json!({"name": "coordinateSystem"})); + ui.close(); + } let at = app.session.project.maps.iter().position(|x| x.name == m); move_buttons(app, ui, "map.move", m, at, app.session.project.maps.len()); // A project keeps at least one map (`map.remove` refuses the last). @@ -7959,6 +7965,49 @@ pub(crate) mod tests { assert_eq!(tint, Some(false)); } + /// A right-click on the map's entry at the top of the layer list opens the map's menu, whose + /// Coordinate System… opens that dialog. The menu of a map not in view greys the row, as the + /// dialog changes only the map in view. + #[test] + fn right_clicking_the_map_entry_offers_its_coordinate_system() { + use egui::{Event, Modifiers, PointerButton, Role}; + use egui_kittest::kittest::{NodeT, Queryable}; + let app = RustGisApp::with_sample(); + let name = app.session.map().name.clone(); + let mut fonts = false; + let mut h = egui_kittest::Harness::builder().with_size(vec2(300.0, 700.0)).build_ui_state( + move |ui, app: &mut RustGisApp| { + if !fonts { + crate::theme::install_fonts(ui.ctx(), &[], None); + fonts = true; + return; + } + contents(app, ui, &Tokens::light()); + }, + app, + ); + h.run_steps(3); + let at = h.get_by_role_and_label(Role::Button, &format!("Map: {name}")).rect().center(); + h.event(Event::PointerMoved(at)); + h.step(); + for pressed in [true, false] { + h.event(Event::PointerButton { pos: at, button: PointerButton::Secondary, pressed, modifiers: Modifiers::NONE }); + h.step(); + } + h.run_steps(2); + h.get_by_label("Coordinate System…").click(); + h.run_steps(2); + assert_eq!(h.state().dialogs.open, Some("coordinateSystem")); + assert!(h.query_by_label("Coordinate System…").is_none(), "choosing the row closes the menu"); + + // The new map comes into view, so the first one's menu is another map's. + h.state_mut().run("map.new", json!({"name": "Second"})).unwrap(); + let app = h.into_state(); + let mut h = egui_kittest::Harness::builder().build_ui_state(move |ui, app: &mut RustGisApp| map_menu(app, ui, &name), app); + h.run_steps(2); + assert!(h.get_by_label("Coordinate System…").accesskit_node().is_disabled()); + } + /// An editor sends back an image that draws as it is, and one refused for itself (not an /// image) as the circle it is drawn as, counted. The rule is render's /// `picture_marker_kept_refusal`, whose tests cover one refused only until a restart. diff --git a/docs/user-guide/index.md b/docs/user-guide/index.md index c673b4afa0..886ac80128 100644 --- a/docs/user-guide/index.md +++ b/docs/user-guide/index.md @@ -100,9 +100,9 @@ This guide walks through RustGIS by task. Each page covers one part of the app: - **Status bar**: the scale (type one, or pick from the list), the zoom level, bearing and pitch (click them to face north and look straight down again), the pointer's coordinates (click them to step through map coordinates (the map's own system, the default), decimal degrees, DMS, UTM, MGRS and layer coordinates (the active layer's projected system); see [Coordinate readouts](maps.md#coordinate-readouts)), - the coordinate system (click it to change the - projection), the selection count (with a button to clear it), the latest notice (click to open - **Messages**), a **Messages** button, the last draw time, the frame rate and a **GPU**/**CPU** + the coordinate system (click its button to + change the projection), the selection count (with a button to clear it), the latest notice (click + to open **Messages**), a **Messages** button, the last draw time, the frame rate and a **GPU**/**CPU** renderer switch. While agents control the desktop app, it also shows the MCP relay or file bridge. **Command Search** (++ctrl+k++, or the box at the top right) finds commands and geoprocessing diff --git a/docs/user-guide/maps.md b/docs/user-guide/maps.md index 9b8fc79781..66466651dd 100644 --- a/docs/user-guide/maps.md +++ b/docs/user-guide/maps.md @@ -769,8 +769,10 @@ project switches its countries when the new borders arrive; others keep the laye ## Projections The flat map is drawn in Web Mercator by default. **View › Projection** switches it to another -projection, and clicking the coordinate system in the status bar opens the **Coordinate -System** dialog, which also takes a projected EPSG code (such as `3035`, `32633` for UTM zone +projection. The coordinate system button in the status bar opens the **Coordinate System** +dialog, as does **Coordinate System…** on the right-click menu of the map's entry at the top of +the Layers pane (also on the menus of the map's tab and of its entry in the Browser, for the map +in view). The dialog also takes a projected EPSG code (such as `3035`, `32633` for UTM zone 33N or `2056` for Switzerland) or an ESRI code, the one `.prj` files and ArcGIS name (such as `ESRI:102033` for South America Albers Equal Area Conic, or `ESRI:54030` for World Robinson). A code whose projection method RustGIS can't compute is refused with the reason, rather than drawn diff --git a/docs/user-guide/workspace.md b/docs/user-guide/workspace.md index 3317176fff..554040679d 100644 --- a/docs/user-guide/workspace.md +++ b/docs/user-guide/workspace.md @@ -484,15 +484,17 @@ tabs: select a tab to bring it forward, or its × to close it. Right-click a tab the other panes or all panes; an overflow menu lists tabs that do not fit. Right-click a map or layout tab (or its entry in Browser) to **Rename**, **Duplicate**, -**Move Up**, **Move Down** or **Delete** it. Deletion asks for confirmation; a project must keep -at least one map. Drag a map or layout tab to another place to change the order of the maps or -the layouts (maps stay before layouts); near the ends of a strip whose tabs don't all fit, the -tabs scroll. In Browser, drag a map or layout up or down its list the same way; near the -Browser's top or bottom, the list scrolls, the row you drag is filled, and a line across the list -shows where it will land. On a touch screen a swipe scrolls the tab strips and the Browser's -lists; to drag a tab, a row or a layer, hold it until its menu opens, then move your finger (the -menu closes and the item follows). The map or layout in view stays in view, each move is -one undo step, and the order is saved with the project. From scripts: `map.move` and +**Move Up**, **Move Down** or **Delete** it. The map's entry at the top of the Layers pane has +the same menu. A map's menu also pastes copied layers onto it and, for the map in view, has +**Coordinate System…** (see [Projections](maps.md#projections)). Deletion asks for +confirmation; a project must keep at least one map. Drag a map or layout tab to another place to +change the order of the maps or the layouts (maps stay before layouts); near the ends of a strip +whose tabs don't all fit, the tabs scroll. In Browser, drag a map or layout up or down its list +the same way; near the Browser's top or bottom, the list scrolls, the row you drag is filled, and +a line across the list shows where it will land. On a touch screen a swipe scrolls the tab +strips and the Browser's lists; to drag a tab, a row or a layer, hold it until its menu opens, +then move your finger (the menu closes and the item follows). The map or layout in view stays +in view, each move is one undo step, and the order is saved with the project. From scripts: `map.move` and `layout.move`, with the name and the new place (`"to"`: 0 for the first). Click **Command Search** at the right of the title bar or on the Help tab, or press ++ctrl+k++