diff --git a/docs/TODO_ux.md b/docs/TODO_ux.md index d45b5be48b..ecb8e7ef3f 100644 --- a/docs/TODO_ux.md +++ b/docs/TODO_ux.md @@ -65,13 +65,13 @@ ## Switch to OpenGL (for speed) -- get things running again - - forking - - clean up text rendering... remove LINE_HEIGHT and MAX_CHAR_WIDTH constants +- no bugs + - text is very buggy + - forking is buggy (traffic signal diagram) - arrows - - colors still seem off - - make polygon store points and indices efficiently + - some colors are wrong +- make polygon store points and indices efficiently - change ezgui API to allow uploading geometry once - undo the y inversion hacks at last! - probably use f32, not f64 everywhere diff --git a/ezgui/src/lib.rs b/ezgui/src/lib.rs index 5e67a45286..aa4166d1ff 100644 --- a/ezgui/src/lib.rs +++ b/ezgui/src/lib.rs @@ -170,6 +170,8 @@ impl<'a> GfxCtx<'a> { } pub fn draw_arrow(&mut self, color: Color, thickness: f64, line: &Line) { + self.draw_line(color, thickness, line); + // TODO Raw method doesn't work yet in all cases... /*graphics::Line::new_round(color.0, thickness).draw_arrow( [ diff --git a/ezgui/src/text.rs b/ezgui/src/text.rs index d32df668a8..c8bcc48da5 100644 --- a/ezgui/src/text.rs +++ b/ezgui/src/text.rs @@ -18,7 +18,6 @@ const FONT_SIZE: f32 = 24.0; // TODO These are dependent on FONT_SIZE, but hand-tuned. Glyphs all have 0 as their height, and // they need adjustments to their positioning. pub const LINE_HEIGHT: f64 = 32.0; -const SHIFT_TEXT_UP: f64 = 7.0; const MAX_CHAR_WIDTH: f64 = 25.0; #[derive(Debug, Clone)] @@ -126,7 +125,7 @@ impl Text { pub(crate) fn dims(&self, glyphs: &mut GlyphBrush<'static, 'static>) -> (f64, f64) { let mut widths: Vec = Vec::new(); - let mut heights: Vec = Vec::new(); + let mut total_height: i32 = 0; for l in &self.lines { let full_line = l.iter().fold(String::new(), |mut so_far, span| { @@ -139,18 +138,18 @@ impl Text { ..Section::default() }) { widths.push(rect.width()); - heights.push(rect.height()); + total_height += rect.height(); } else { // TODO Sometimes we want to space something like " ", but no drawn glyphs // means pixel_bounds fails. Hack? widths.push((MAX_CHAR_WIDTH * (full_line.len() as f64)) as i32); - heights.push(LINE_HEIGHT as i32); + total_height += LINE_HEIGHT as i32; } } ( widths.into_iter().max().unwrap() as f64, - heights.into_iter().max().unwrap() as f64, + total_height as f64, ) } } @@ -193,7 +192,7 @@ pub fn draw_text_bubble( color: span.fg_color.0, scale: Scale::uniform(FONT_SIZE), bounds: (1024.0, 768.0), - screen_position: (x as f32, (y - SHIFT_TEXT_UP) as f32), + screen_position: (x as f32, (y - LINE_HEIGHT) as f32), ..Section::default() }; let span_width = glyphs.pixel_bounds(section).unwrap().width() as f64;