enter/exit submenus
Signed-off-by: Frank Villaro-Dixon <frank@villaro-dixon.eu>
This commit is contained in:
parent
376ddf53ac
commit
f0885efd27
2 changed files with 23 additions and 3 deletions
20
src/apps.rs
20
src/apps.rs
|
@ -1,3 +1,5 @@
|
||||||
|
use std::thread::current;
|
||||||
|
|
||||||
pub struct BeoApps {
|
pub struct BeoApps {
|
||||||
pub apps: Vec<Box<dyn App>>,
|
pub apps: Vec<Box<dyn App>>,
|
||||||
}
|
}
|
||||||
|
@ -11,6 +13,24 @@ impl AppBase {
|
||||||
pub fn name(&self) -> &str {
|
pub fn name(&self) -> &str {
|
||||||
&self.name
|
&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)]
|
#[derive(Debug, Clone)]
|
||||||
|
|
|
@ -126,9 +126,7 @@ impl BeoUi {
|
||||||
self.current_app_mut()
|
self.current_app_mut()
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.base_mut()
|
.base_mut()
|
||||||
.main_menu
|
.enter_submenu(submenu_id);
|
||||||
.get_deepest_selected_submenu_mut()
|
|
||||||
.set_submenu_id(submenu_id);
|
|
||||||
self.angle_shift = 0.0;
|
self.angle_shift = 0.0;
|
||||||
}
|
}
|
||||||
None => {
|
None => {
|
||||||
|
@ -137,6 +135,8 @@ impl BeoUi {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Beo5Event::RightButtonPressed => {
|
Beo5Event::RightButtonPressed => {
|
||||||
|
// That means that we get out of a submenu
|
||||||
|
self.current_app_mut().unwrap().base_mut().exit_submenu();
|
||||||
println!("Right button pressed");
|
println!("Right button pressed");
|
||||||
}
|
}
|
||||||
Beo5Event::SelectionWheelRel(rel_angle_eps) => {
|
Beo5Event::SelectionWheelRel(rel_angle_eps) => {
|
||||||
|
|
Loading…
Reference in a new issue