Maps · View: host tiles, pins and a popup, a picker, coordinates
maps::MapView lays the host's tile for each zoom, column and row in Web Mercator, the nearest cut scaled past the zooms it serves, on whole pixels. gpui packs pictures in its atlas without padding and samples them linearly, so each tile draws with a one-pixel rim copied from its own edge, one of its pixels larger each side and clipped, and no seam shows. A drag, the wheel or the arrows pan; Command-wheel, + and - or its buttons zoom about the pointer or the center; the owner keeps the viewport. MapMarker pins take a press and Enter when the map hears them; MapPopup opens toward the map's larger half and stays inside it, closing by its button or Escape. LocationPicker picks the place under a center crosshair; CoordinateDisplay writes degrees or degrees, minutes and seconds with tabular figures and a copy button. The gallery's tiles are Natural Earth's countries, cut z0 to z3 by scripts/tiles.py.
This commit is contained in:
1 parent
090520a9f1
commit
931e0ed6f5
102 files changed
+1978
-6
No files matched your search
@@ -3,6 +3,7 @@ use gpui::{
|
||||
Styled, Window, div, prelude::*,
|
||||
};
|
||||
|
||||
use super::tabular;
|
||||
use crate::{buttons::CopyButton, theme::ActiveTheme};
|
||||
|
||||
/// Text with a copy button that confirms with a check.
|
||||
@@ -11,6 +12,7 @@ pub struct CopyableText {
|
||||
id: ElementId,
|
||||
text: SharedString,
|
||||
mono: bool,
|
||||
tabular: bool,
|
||||
}
|
||||
|
||||
impl CopyableText {
|
||||
@@ -19,6 +21,7 @@ impl CopyableText {
|
||||
id: id.into(),
|
||||
text: text.into(),
|
||||
mono: false,
|
||||
tabular: false,
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +29,12 @@ impl CopyableText {
|
||||
self.mono = true;
|
||||
self
|
||||
}
|
||||
|
||||
/// Figures of one width, so text that changes holds still.
|
||||
pub fn tabular(mut self) -> Self {
|
||||
self.tabular = true;
|
||||
self
|
||||
}
|
||||
}
|
||||
|
||||
impl RenderOnce for CopyableText {
|
||||
@@ -37,6 +46,7 @@ impl RenderOnce for CopyableText {
|
||||
.items_center()
|
||||
.gap_1()
|
||||
.when(self.mono, |row| row.font_family(mono))
|
||||
.when(self.tabular, tabular)
|
||||
.child(self.text.clone())
|
||||
.child(CopyButton::new("copy-slot", self.text))
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user