diff --git a/crates/ui-egui/src/backstage.rs b/crates/ui-egui/src/backstage.rs index 79745cee4f..fadf298bee 100644 --- a/crates/ui-egui/src/backstage.rs +++ b/crates/ui-egui/src/backstage.rs @@ -124,11 +124,11 @@ fn start(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens) { if card(ui, t, "Open…", "Open a .rgis project", "open") { let _ = app.run("ui.open", Value::Null); } - if card(ui, t, "GeoLibre Project…", "A .geolibre project as a map", "open") { + if card(ui, t, "GeoLibre Project…", "A .geolibre project as a map", "project_globe") { let _ = app.run("ui.openItem", json!({"kind": "geolibreProject"})); app.ui.backstage = false; } - if card(ui, t, "QGIS Project…", "A .qgs or .qgz project as a map", "open") { + if card(ui, t, "QGIS Project…", "A .qgs or .qgz project as a map", "project_layers") { let _ = app.run("ui.openItem", json!({"kind": "qgisProject"})); app.ui.backstage = false; } diff --git a/crates/ui-egui/src/connectionui.rs b/crates/ui-egui/src/connectionui.rs index 292faaaa23..e92c5cebf5 100644 --- a/crates/ui-egui/src/connectionui.rs +++ b/crates/ui-egui/src/connectionui.rs @@ -229,6 +229,16 @@ pub(crate) const KINDS: [(&str, &str); 13] = [ ("s3", "S3"), ]; +/// The icon of a connection kind, as the Data Sources pane shows its sources. +pub(crate) fn icon(kind: &str) -> &'static str { + match kind { + kind if DATABASE_KINDS.contains(&kind) => "database", + "stac" => "search", + "s3" => "bucket", + _ => "globe_view", + } +} + /// The kinds Add From Service connects to. pub(crate) const SERVICE_KINDS: &[&str] = &["service", "wms", "wmts", "wfs", "wcs", "ogcapi", "arcgis", "csw"]; diff --git a/crates/ui-egui/src/icons.rs b/crates/ui-egui/src/icons.rs index c42d870ef7..ef5140562b 100644 --- a/crates/ui-egui/src/icons.rs +++ b/crates/ui-egui/src/icons.rs @@ -1215,6 +1215,99 @@ pub fn paint(painter: &Painter, r: Rect, name: &str, ink: Color32, accent: Color p.arc(15.0, 15.0, 5.0, 200.0, 520.0, 1.5, accent); p.fill(&[(19.5, 9.5), (21.5, 13.5), (17.0, 12.5)], accent); } + "database" => { + p.rect(4.0, 5.0, 16.0, 14.0, Some(p.tint(110)), None, 0.0); + p.line(&[(4.0, 5.0), (4.0, 19.0)], 1.3, ink); + p.line(&[(20.0, 5.0), (20.0, 19.0)], 1.3, ink); + let rim = |y: f32, sides: std::ops::RangeInclusive| -> Vec<(f32, f32)> { + sides.map(|i| (i as f32 * 15.0).to_radians()).map(|a| (12.0 + 8.0 * a.cos(), y + 3.0 * a.sin())).collect() + }; + p.fill(&rim(19.0, 0..=12), p.tint(110)); + for y in [10.0, 14.5, 19.0] { + p.line(&rim(y, 0..=12), 1.2, ink); + } + p.fill(&rim(5.0, 0..=23), accent); + p.closed(&rim(5.0, 0..=23), 1.2, ink); + } + "link" => { + // Two links of a chain, the second through the first. + p.arc(8.0, 12.0, 5.0, 60.0, 300.0, 2.4, accent); + p.arc(16.0, 12.0, 5.0, -120.0, 120.0, 2.4, accent); + p.line(&[(8.0, 12.0), (16.0, 12.0)], 2.2, ink); + } + "bucket" => { + p.arc(12.0, 8.0, 8.0, 180.0, 360.0, 1.4, ink); + p.fill(&[(4.0, 8.0), (20.0, 8.0), (17.5, 21.0), (6.5, 21.0)], p.tint(110)); + p.closed(&[(4.0, 8.0), (20.0, 8.0), (17.5, 21.0), (6.5, 21.0)], 1.4, ink); + p.line(&[(4.8, 12.0), (19.2, 12.0)], 1.8, accent); + } + "cube" => { + // A block of cells, cut in two along each edge. + p.fill(&[(12.0, 2.0), (21.0, 7.0), (12.0, 12.0), (3.0, 7.0)], p.tint(60)); + p.fill(&[(3.0, 7.0), (12.0, 12.0), (12.0, 22.0), (3.0, 17.0)], p.tint(110)); + p.fill(&[(12.0, 12.0), (21.0, 7.0), (21.0, 17.0), (12.0, 22.0)], p.tint(180)); + p.closed(&[(12.0, 2.0), (21.0, 7.0), (21.0, 17.0), (12.0, 22.0), (3.0, 17.0), (3.0, 7.0)], 1.3, ink); + p.line(&[(3.0, 7.0), (12.0, 12.0), (21.0, 7.0)], 1.2, ink); + p.line(&[(12.0, 12.0), (12.0, 22.0)], 1.2, ink); + p.line(&[(3.0, 12.0), (12.0, 17.0), (21.0, 12.0)], 0.9, ink); + p.line(&[(7.5, 4.5), (16.5, 9.5), (16.5, 19.5)], 0.9, ink); + p.line(&[(16.5, 4.5), (7.5, 9.5), (7.5, 19.5)], 0.9, ink); + } + "drawing" => { + // A drafting triangle, its inside cut out. + p.fill(&[(4.0, 3.0), (21.0, 20.0), (4.0, 20.0)], p.tint(130)); + p.closed(&[(4.0, 3.0), (21.0, 20.0), (4.0, 20.0)], 1.4, ink); + p.fill(&[(8.0, 12.0), (12.5, 16.5), (8.0, 16.5)], p.paper()); + p.closed(&[(8.0, 12.0), (12.5, 16.5), (8.0, 16.5)], 1.1, ink); + } + "table_edit" => { + p.table(2.0, 4.0, 17.0, 15.0); + p.line(&[(21.0, 11.0), (14.0, 18.0)], 4.4, ink); + p.line(&[(21.0, 11.0), (14.0, 18.0)], 2.4, amber); + p.fill(&[(12.0, 21.0), (12.6, 17.4), (15.6, 20.4)], ink); + } + "connection" => { + // A plug and its cord. + p.line(&[(9.0, 2.0), (9.0, 8.0)], 1.8, ink); + p.line(&[(15.0, 2.0), (15.0, 8.0)], 1.8, ink); + p.fill(&[(5.5, 7.5), (18.5, 7.5), (18.5, 11.0), (15.5, 15.5), (8.5, 15.5), (5.5, 11.0)], accent); + p.closed(&[(5.5, 7.5), (18.5, 7.5), (18.5, 11.0), (15.5, 15.5), (8.5, 15.5), (5.5, 11.0)], 1.3, ink); + p.line(&[(12.0, 15.5), (12.0, 22.0)], 1.8, ink); + } + "observation" => { + // Binoculars. + for x in [7.0, 17.0] { + p.rect(x - 2.5, 4.0, 5.0, 8.0, Some(p.tint(110)), Some((1.3, ink)), 1.0); + p.circle(x, 15.5, 5.0, Some(p.tint(110)), Some((1.4, ink))); + p.circle(x, 15.5, 2.2, Some(accent), None); + } + p.rect(9.5, 8.0, 5.0, 3.0, Some(ink), None, 0.0); + } + "keyboard" => { + p.rect(1.5, 5.5, 21.0, 13.0, Some(p.tint(40)), Some((1.3, ink)), 2.0); + for x in [4.0, 8.5, 13.0, 17.5] { + p.rect(x, 8.0, 2.5, 2.2, Some(ink), None, 0.4); + p.rect(x, 11.3, 2.5, 2.2, Some(ink), None, 0.4); + } + p.rect(7.0, 14.7, 10.0, 1.8, Some(accent), None, 0.4); + } + "quick_access" => { + // A toolbar of buttons, one being added. + p.rect(1.5, 5.0, 21.0, 9.0, Some(p.tint(40)), Some((1.3, ink)), 2.0); + for x in [4.0, 10.0, 16.0] { + p.rect(x, 7.5, 4.0, 4.0, Some(accent), None, 0.8); + } + p.plus_badge(18.0, 18.0); + } + "project_globe" | "project_layers" => { + paint(painter, r, "open", ink, accent); + p.circle(17.0, 17.0, 6.2, Some(p.paper()), None); + if name == "project_globe" { + p.globe(17.0, 17.0, 5.0); + } else { + p.layers(12.0, 13.0, 0.5); + } + } "graphics_layer" => { p.layers(2.0, 4.0, 0.9); p.circle(17.0, 16.0, 4.0, Some(accent), Some((1.2, ink))); @@ -1330,6 +1423,18 @@ pub const ALL: &[&str] = &[ "web_data", "add_folder", "open", + "database", + "link", + "bucket", + "cube", + "drawing", + "table_edit", + "connection", + "observation", + "keyboard", + "quick_access", + "project_globe", + "project_layers", "select", "select_attr", "select_loc", diff --git a/crates/ui-egui/src/ribbon.rs b/crates/ui-egui/src/ribbon.rs index ebff762bf3..4d0b65bcdb 100644 --- a/crates/ui-egui/src/ribbon.rs +++ b/crates/ui-egui/src/ribbon.rs @@ -540,32 +540,32 @@ fn home_tab(app: &mut RustGisApp, ui: &mut Ui) { "Add data from another source or use a data-adding option.", true, |ui, app| { - menu_item(ui, app, "", "Delimited Text…", "ui.addDelimited", Value::Null); - menu_item(ui, app, "", "DXF…", "ui.addDxf", Value::Null); - menu_item(ui, app, "", "Geocode Addresses…", "ui.dialog", json!({"name": "geocode"})); - menu_item(ui, app, "", "From URL…", "ui.addUrl", Value::Null); - menu_item(ui, app, "", "From Service…", "ui.addService", Value::Null); - menu_item(ui, app, "", "Zarr…", "ui.dialog", json!({"name": "zarr"})); + menu_item(ui, app, "table", "Delimited Text…", "ui.addDelimited", Value::Null); + menu_item(ui, app, "drawing", "DXF…", "ui.addDxf", Value::Null); + menu_item(ui, app, "locate", "Geocode Addresses…", "ui.dialog", json!({"name": "geocode"})); + menu_item(ui, app, "link", "From URL…", "ui.addUrl", Value::Null); + menu_item(ui, app, "globe_view", "From Service…", "ui.addService", Value::Null); + menu_item(ui, app, "cube", "Zarr…", "ui.dialog", json!({"name": "zarr"})); // Databases are read through DuckDB, a program the browser can't run. A phone keeps // the row: its PostGIS, MySQL and SQL Server connections need no program, and a // DuckDB database refused there says why (#1902). #[cfg(not(target_arch = "wasm32"))] - menu_item(ui, app, "", "Database…", "ui.dialog", json!({"name": "addDatabase"})); + menu_item(ui, app, "database", "Database…", "ui.dialog", json!({"name": "addDatabase"})); #[cfg(not(target_arch = "wasm32"))] - menu_item(ui, app, "", "Edit GeoPackage Table…", "ui.dialog", json!({"name": "gpkgAddLayer"})); - menu_item(ui, app, "", "S3…", "ui.dialog", json!({"name": "s3"})); - submenu_row(ui, "", tl!("New Connection"), |ui| { + menu_item(ui, app, "table_edit", "Edit GeoPackage Table…", "ui.dialog", json!({"name": "gpkgAddLayer"})); + menu_item(ui, app, "bucket", "S3…", "ui.dialog", json!({"name": "s3"})); + submenu_row(ui, "connection", tl!("New Connection"), |ui| { for (kind, label) in crate::connectionui::KINDS { // Database drivers aren't built for the browser. if cfg!(target_arch = "wasm32") && rustgis_engine::connections::DATABASE_KINDS.contains(&kind) { continue; } - menu_item(ui, app, "", label, "ui.connection", json!({"kind": kind})); + menu_item(ui, app, crate::connectionui::icon(kind), label, "ui.connection", json!({"kind": kind})); // An Esri enterprise geodatabase is a SQL Server connection, entered as // ArcGIS Pro asks for it or from its .sde file. if kind == "sqlserver" { let form = json!({"kind": "sqlserver", "form": true}); - menu_item(ui, app, "", "Enterprise Geodatabase…", "ui.connection", form); + menu_item(ui, app, "database", "Enterprise Geodatabase…", "ui.connection", form); } } }); @@ -744,12 +744,23 @@ fn web_data_menu(ui: &mut Ui, app: &mut RustGisApp) { }); } +/// The icon of sample layer `name`: its geometry's. +pub(crate) fn sample_icon(name: &str) -> &'static str { + match name { + "countries" | "lakes" => "polygon_layer", + "cities" => "point_layer", + "rivers" => "line_layer", + _ => "map", + } +} + +/// The sample layers, each with its geometry's icon: in the Add Data menu and the Add Sample dialog. pub(crate) fn sample_data_gallery(ui: &mut Ui, app: &mut RustGisApp) { ui.label(egui::RichText::new(tl!("Sample data (Natural Earth)")).small().weak()); for (name, label) in [("countries", "World Countries"), ("cities", "Populated Places"), ("rivers", "Major Rivers"), ("lakes", "Major Lakes")] { - menu_item(ui, app, "", label, "layer.addSample", json!({"name": name})); + menu_item(ui, app, sample_icon(name), label, "layer.addSample", json!({"name": name})); } } @@ -1582,17 +1593,18 @@ fn layer_templates_group(app: &mut RustGisApp, ui: &mut Ui) { }); } +/// The layer templates, each with its geometry's icon: in the Layer Templates menu and its dialog. pub(crate) fn layer_templates_gallery(ui: &mut Ui, app: &mut RustGisApp) { - for (id, label) in [ - ("points", "Points"), - ("lines", "Lines"), - ("polygons", "Polygons"), - ("places", "Places (name, category, address, rating)"), - ("routes", "Routes (name, surface, length)"), - ("areas", "Areas (name, land use, area)"), - ("observations", "Observations (observer, date, species, count)"), + for (id, icon, label) in [ + ("points", "point_layer", "Points"), + ("lines", "line_layer", "Lines"), + ("polygons", "polygon_layer", "Polygons"), + ("places", "point_layer", "Places (name, category, address, rating)"), + ("routes", "line_layer", "Routes (name, surface, length)"), + ("areas", "polygon_layer", "Areas (name, land use, area)"), + ("observations", "observation", "Observations (observer, date, species, count)"), ] { - menu_item(ui, app, "add_data", label, "layer.template", json!({"template": id})); + menu_item(ui, app, icon, label, "layer.template", json!({"template": id})); } } @@ -4126,9 +4138,19 @@ fn settings_tab(app: &mut RustGisApp, ui: &mut Ui) { } } }); - big(ui, app, "command", "Keyboard\nShortcuts", "Customize keyboard shortcuts.", "ui.customizeShortcuts", Value::Null, false, false); + big( + ui, + app, + "keyboard", + "Keyboard\nShortcuts", + "Customize keyboard shortcuts.", + "ui.customizeShortcuts", + Value::Null, + false, + false, + ); let qa = app.ui.quick_access.clone(); - big_form_menu(ui, app, "command", "Quick\nAccess", "Choose extra buttons for the Quick Access Toolbar.", move |ui, app| { + big_form_menu(ui, app, "quick_access", "Quick\nAccess", "Choose extra buttons for the Quick Access Toolbar.", move |ui, app| { for (id, label) in QUICK { let mut on = qa.iter().any(|c| c == id); if ui.checkbox(&mut on, tl!(*label)).clicked() { @@ -4522,8 +4544,8 @@ fn help_tab(app: &mut RustGisApp, ui: &mut Ui) { false, ); } - big(ui, app, "command", "Command\nSearch", "Find any command by name (Ctrl+K).", "ui.commandSearch", Value::Null, false, false); - big(ui, app, "settings", "Shortcuts", "Keyboard shortcuts.", "ui.shortcuts", Value::Null, false, false); + big(ui, app, "search", "Command\nSearch", "Find any command by name (Ctrl+K).", "ui.commandSearch", Value::Null, false, false); + big(ui, app, "keyboard", "Shortcuts", "Keyboard shortcuts.", "ui.shortcuts", Value::Null, false, false); }); } diff --git a/crates/ui-egui/src/sourcespane.rs b/crates/ui-egui/src/sourcespane.rs index dda123c7ac..3f7d3568a0 100644 --- a/crates/ui-egui/src/sourcespane.rs +++ b/crates/ui-egui/src/sourcespane.rs @@ -114,17 +114,17 @@ pub fn save_connections(app: &mut RustGisApp) { } } +/// The icon of a source kind (Favourites, Recent and Library); connections have [`crate::connectionui::icon`]. fn icon_of(kind: &str) -> &'static str { match kind { "file" => "add_data", - "url" => "web_map", + "url" => "link", "tiles" => "basemap", "service" => "globe_view", - "database" => "table", - "zarr" => "raster_layer", + "database" => "database", + "zarr" => "cube", "stac" => "search", - "sample" => "map", - "s3" => "package", + "s3" => "bucket", _ => "add_data", } } @@ -206,7 +206,8 @@ pub fn open(app: &mut RustGisApp, s: &Source) -> Result<(), String> { fn row(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens, s: &Source, list: Option<&str>) { ui.horizontal(|ui| { let (r, _) = ui.allocate_exact_size(vec2(16.0, 16.0), Sense::hover()); - icons::paint(ui.painter(), r, icon_of(&s.kind), t.icon, t.accent); + let icon = if s.kind == "sample" { crate::ribbon::sample_icon(&s.address) } else { icon_of(&s.kind) }; + icons::paint(ui.painter(), r, icon, t.icon, t.accent); let resp = ui.link(&s.name).on_hover_text(&s.address); if resp.clicked() && let Err(e) = open(app, s) @@ -330,15 +331,7 @@ fn connection_row(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens, c: &Connection) /// A connection's icon, name, kind and menu. True when the name was clicked. fn connection_header(app: &mut RustGisApp, ui: &mut Ui, t: &Tokens, c: &Connection, unavailable: bool) -> bool { - let icon = if DATABASE_KINDS.contains(&c.kind.as_str()) { - "table" - } else { - match c.kind.as_str() { - "stac" => "search", - "s3" => "package", - _ => "globe_view", - } - }; + let icon = crate::connectionui::icon(&c.kind); let (r, _) = ui.allocate_exact_size(vec2(16.0, 16.0), Sense::hover()); icons::paint(ui.painter(), r, icon, t.icon, t.accent); let response = if unavailable {