X button on dashboard
This commit is contained in:
@@ -25,6 +25,13 @@
|
||||
</template>
|
||||
|
||||
<elements>
|
||||
<div position="absolute" width="100%" justify_content="space_between">
|
||||
<div />
|
||||
<div padding="6">
|
||||
<Button id="btn_close" sprite_src_builtin="dashboard/close.svg" color="#000000" border="2" border_color="~color_faded" />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- left/right separator (menu and rest) -->
|
||||
<div flex_direction="row" gap="8" width="100%" height="100%" padding="4" interactable="0">
|
||||
<!-- LEFT MENU -->
|
||||
|
||||
@@ -100,6 +100,7 @@ pub enum FrontendTask {
|
||||
RecenterPlayspace,
|
||||
PushToast(Translation),
|
||||
PlaySound(SoundType),
|
||||
HideDashboard,
|
||||
}
|
||||
|
||||
impl<T: 'static> Frontend<T> {
|
||||
@@ -333,6 +334,7 @@ impl<T: 'static> Frontend<T> {
|
||||
FrontendTask::RecenterPlayspace => self.action_recenter_playspace(params.data)?,
|
||||
FrontendTask::PushToast(content) => self.toast_manager.push(content),
|
||||
FrontendTask::PlaySound(sound_type) => self.queue_play_sound(sound_type),
|
||||
FrontendTask::HideDashboard => self.action_hide_dashboard(params.data),
|
||||
};
|
||||
Ok(())
|
||||
}
|
||||
@@ -357,6 +359,12 @@ impl<T: 'static> Frontend<T> {
|
||||
}
|
||||
|
||||
fn register_widgets(&mut self) -> anyhow::Result<()> {
|
||||
// "X" button
|
||||
self.tasks.handle_button(
|
||||
&self.state.fetch_component_as::<ComponentButton>("btn_close")?,
|
||||
FrontendTask::HideDashboard,
|
||||
);
|
||||
|
||||
// ################################
|
||||
// SIDE BUTTONS
|
||||
// ################################
|
||||
@@ -461,4 +469,8 @@ impl<T: 'static> Frontend<T> {
|
||||
self.interface.recenter_playspace(data)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn action_hide_dashboard(&mut self, data: &mut T) {
|
||||
self.interface.toggle_dashboard(data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -447,6 +447,11 @@ impl DashInterface<AppState> for DashInterfaceLive {
|
||||
RESTART.store(true, Ordering::Relaxed);
|
||||
}
|
||||
|
||||
fn toggle_dashboard(&mut self, data: &mut AppState) {
|
||||
data.tasks
|
||||
.enqueue(TaskType::Overlay(OverlayTask::ToggleDashboard));
|
||||
}
|
||||
|
||||
#[cfg(feature = "openxr")]
|
||||
fn monado_client_list(
|
||||
&mut self,
|
||||
|
||||
@@ -38,6 +38,7 @@ pub trait DashInterface<T> {
|
||||
fn general_config<'a>(&'a mut self, data: &'a mut T) -> &'a mut GeneralConfig;
|
||||
fn config_changed(&mut self, data: &mut T);
|
||||
fn restart(&mut self, data: &mut T);
|
||||
fn toggle_dashboard(&mut self, data: &mut T);
|
||||
}
|
||||
|
||||
pub type BoxDashInterface<T> = Box<dyn DashInterface<T>>;
|
||||
|
||||
@@ -227,6 +227,8 @@ impl DashInterface<()> for DashInterfaceEmulated {
|
||||
|
||||
fn restart(&mut self, _data: &mut ()) {}
|
||||
|
||||
fn toggle_dashboard(&mut self, _data: &mut ()) {}
|
||||
|
||||
fn monado_client_list(&mut self, _data: &mut ()) -> anyhow::Result<Vec<dash_interface::MonadoClient>> {
|
||||
Ok(self.monado_clients.clone())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user