mirror of
https://github.com/a-b-street/abstreet.git
synced 2024-11-25 03:41:09 +03:00
make text entry work when empty
This commit is contained in:
parent
9182a57af5
commit
46c07dc57a
@ -68,6 +68,7 @@
|
||||
- speed
|
||||
- make polygon store points and indices efficiently
|
||||
- change ezgui API to allow uploading geometry once
|
||||
- experiment with batching and not passing colors
|
||||
- measure performance of huge maps
|
||||
- quality
|
||||
- need padding around text
|
||||
|
@ -128,14 +128,15 @@ impl Text {
|
||||
so_far.push_str(&span.text);
|
||||
so_far
|
||||
});
|
||||
// Empty lines or whitespace-only lines effectively have 0 width.
|
||||
glyphs
|
||||
.pixel_bounds(Section {
|
||||
text: &full_line,
|
||||
scale: Scale::uniform(FONT_SIZE),
|
||||
..Section::default()
|
||||
})
|
||||
.expect("can't get text dims of a whitespace-only span")
|
||||
.width()
|
||||
.map(|rect| rect.width())
|
||||
.unwrap_or(0)
|
||||
})
|
||||
.max()
|
||||
.unwrap() as f64;
|
||||
|
@ -28,12 +28,12 @@ impl TextBox {
|
||||
|
||||
txt.add_line(self.line[0..self.cursor_x].to_string());
|
||||
if self.cursor_x < self.line.len() {
|
||||
// TODO This bit was highlighted
|
||||
// TODO This "cursor" looks awful!
|
||||
txt.append("|".to_string(), Some(text::SELECTED_COLOR));
|
||||
txt.append(self.line[self.cursor_x..=self.cursor_x].to_string(), None);
|
||||
txt.append(self.line[self.cursor_x + 1..].to_string(), None);
|
||||
} else {
|
||||
// TODO This bit was highlighted
|
||||
txt.append(" ".to_string(), None);
|
||||
txt.append("|".to_string(), Some(text::SELECTED_COLOR));
|
||||
}
|
||||
|
||||
canvas.draw_blocking_text(g, txt, CENTERED);
|
||||
|
Loading…
Reference in New Issue
Block a user