app menu: always keep current at the same place
Signed-off-by: Frank Villaro-Dixon <frank@villaro-dixon.eu>
This commit is contained in:
parent
0cae87ce18
commit
697fa281cc
1 changed files with 11 additions and 19 deletions
30
src/ui.rs
30
src/ui.rs
|
@ -149,18 +149,6 @@ impl BeoUi {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn draw_app<T: Renderer>(&self, canvas: &mut Canvas<T>, fonts: &Fonts, app: &Box<dyn App>) {
|
fn draw_app<T: Renderer>(&self, canvas: &mut Canvas<T>, fonts: &Fonts, app: &Box<dyn App>) {
|
||||||
/*
|
|
||||||
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_before = 1;
|
||||||
let num_menu_elements_after = 2;
|
let num_menu_elements_after = 2;
|
||||||
// That means max 1 + >1< + 2 = 4 elements in total
|
// That means max 1 + >1< + 2 = 4 elements in total
|
||||||
|
@ -187,13 +175,17 @@ impl BeoUi {
|
||||||
//println!("menu_elems_after: {:?}", menu_elems_after);
|
//println!("menu_elems_after: {:?}", menu_elems_after);
|
||||||
|
|
||||||
let mut toti = 0.;
|
let mut toti = 0.;
|
||||||
for i in 0..menu_elems_before.len() {
|
for i in 0..num_menu_elements_before {
|
||||||
let _ = canvas.fill_text(
|
// This is a special case: we reserve some space
|
||||||
toti * 100. + 50.,
|
//so that the current menu is always at the same place
|
||||||
CANVAS_HEIGHT - 80.,
|
if i < menu_elems_before.len() {
|
||||||
&menu_elems_before[i],
|
let _ = canvas.fill_text(
|
||||||
&fonts.app_menu,
|
toti * 100. + 50.,
|
||||||
);
|
CANVAS_HEIGHT - 80.,
|
||||||
|
&menu_elems_before[i],
|
||||||
|
&fonts.app_menu,
|
||||||
|
);
|
||||||
|
}
|
||||||
toti += 1.;
|
toti += 1.;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue