X button on dashboard

This commit is contained in:
galister
2026-01-10 03:18:08 +09:00
parent 531786f63a
commit 9547da21ce
5 changed files with 27 additions and 0 deletions

View File

@@ -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 -->

View File

@@ -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);
}
}

View File

@@ -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,

View File

@@ -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>>;

View File

@@ -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())
}