enter/exit submenus

Signed-off-by: Frank Villaro-Dixon <frank@villaro-dixon.eu>
This commit is contained in:
Frank Villaro-Dixon 2024-05-16 22:25:32 +02:00
parent 376ddf53ac
commit f0885efd27
2 changed files with 23 additions and 3 deletions

View file

@ -1,3 +1,5 @@
use std::thread::current;
pub struct BeoApps {
pub apps: Vec<Box<dyn App>>,
}
@ -11,6 +13,24 @@ impl AppBase {
pub fn name(&self) -> &str {
&self.name
}
pub fn enter_submenu(&mut self, submenu_id: usize) {
let mut current_menu = &mut self.main_menu;
while let Some(ref mut selected_submenu) = current_menu.selected_submenu {
current_menu = selected_submenu
}
current_menu.set_submenu_id(submenu_id)
}
pub fn exit_submenu(&mut self) {
let current_menu = &mut self.main_menu;
while let Some(ref mut selected_submenu) = current_menu.selected_submenu {
if selected_submenu.selected_submenu.is_none() {
current_menu.selected_submenu = None;
return;
}
}
}
}
#[derive(Debug, Clone)]

View file

@ -126,9 +126,7 @@ impl BeoUi {
self.current_app_mut()
.unwrap()
.base_mut()
.main_menu
.get_deepest_selected_submenu_mut()
.set_submenu_id(submenu_id);
.enter_submenu(submenu_id);
self.angle_shift = 0.0;
}
None => {
@ -137,6 +135,8 @@ impl BeoUi {
}
}
Beo5Event::RightButtonPressed => {
// That means that we get out of a submenu
self.current_app_mut().unwrap().base_mut().exit_submenu();
println!("Right button pressed");
}
Beo5Event::SelectionWheelRel(rel_angle_eps) => {