From c6d124aa147dce42cbe6cb33b27e6142ea13b513 Mon Sep 17 00:00:00 2001 From: Frank Villaro-Dixon Date: Wed, 8 May 2024 00:13:45 +0200 Subject: [PATCH] Build to PI Signed-off-by: Frank Villaro-Dixon --- src/ui.rs | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/src/ui.rs b/src/ui.rs index 68e1bcd..ae790bb 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -33,6 +33,16 @@ impl Beo { self.draw_main_menu(canvas, fonts); } + fn lasered_application(&self) -> Option<&Box> { + let app_count = self.apps.len(); + if app_count == 0 { + return None; + } + + let app_idx = (self.laser_pct * app_count as f32) as usize; + self.apps.get(app_idx) + } + fn draw_main_menu(&self, canvas: &mut Canvas, fonts: &Fonts) { let canvas_width = canvas.width(); let canvas_height = canvas.height(); @@ -51,13 +61,19 @@ impl Beo { y: canvas_height as f32, }; + let apps = &self.apps; // draw the main apps in the circle - let pts = main_menu_circle.get_equidistant_points(8, canvas_size); - for i in 0..pts.len() { + let pts = main_menu_circle.get_equidistant_points(apps.len(), canvas_size); + for i in 0..apps.len() { let mut paint = Paint::color(Color::hex("B7410E")); paint.set_font(&[fonts.bold]); paint.set_text_baseline(Baseline::Top); - let _ = canvas.fill_text(pts[i].x as f32, pts[i].y as f32, format!("XX {i}"), &paint); + let _ = canvas.fill_text( + pts[i].x as f32, + pts[i].y as f32, + format!("XX {}", apps[i].name()), + &paint, + ); } // draw the laser @@ -74,7 +90,6 @@ impl Beo { let mut path = Path::new(); let ey = canvas_height as f32 * self.laser_pct; let ex = main_menu_circle.get_x_on_circle(ey); - println!("ex: {}, ey: {}", ex, ey); path.ellipse(ex, ey, 10., 20.); canvas.fill_path(&path, &ellipse_color);