Build to PI
Signed-off-by: Frank Villaro-Dixon <frank@villaro-dixon.eu>
This commit is contained in:
parent
d91d3b013e
commit
c6d124aa14
1 changed files with 19 additions and 4 deletions
23
src/ui.rs
23
src/ui.rs
|
@ -33,6 +33,16 @@ impl Beo {
|
|||
self.draw_main_menu(canvas, fonts);
|
||||
}
|
||||
|
||||
fn lasered_application(&self) -> Option<&Box<dyn App>> {
|
||||
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<T: Renderer>(&self, canvas: &mut Canvas<T>, 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);
|
||||
|
|
Loading…
Reference in a new issue