diff --git a/src/ui.rs b/src/ui.rs index 15e30ae..1f6d393 100644 --- a/src/ui.rs +++ b/src/ui.rs @@ -149,18 +149,6 @@ impl BeoUi { } fn draw_app(&self, canvas: &mut Canvas, fonts: &Fonts, app: &Box) { - /* - let biggest_menu_name = app - .base() - .main_menu - .names - .iter() - .max_by_key(|x| x.len()) - .unwrap(); - - let menu_separated_px = biggest_menu_name.len() as f32 * 8.; - */ - let num_menu_elements_before = 1; let num_menu_elements_after = 2; // That means max 1 + >1< + 2 = 4 elements in total @@ -187,13 +175,17 @@ impl BeoUi { //println!("menu_elems_after: {:?}", menu_elems_after); let mut toti = 0.; - for i in 0..menu_elems_before.len() { - let _ = canvas.fill_text( - toti * 100. + 50., - CANVAS_HEIGHT - 80., - &menu_elems_before[i], - &fonts.app_menu, - ); + for i in 0..num_menu_elements_before { + // This is a special case: we reserve some space + //so that the current menu is always at the same place + if i < menu_elems_before.len() { + let _ = canvas.fill_text( + toti * 100. + 50., + CANVAS_HEIGHT - 80., + &menu_elems_before[i], + &fonts.app_menu, + ); + } toti += 1.; }