mirror of https://github.com/wayvr-org/wayvr.git
dont show skymap tab if not openxr
This commit is contained in:
parent
dd3108d423
commit
9734955ebb
|
|
@ -5,6 +5,7 @@ use wgui::{
|
|||
assets::AssetPath,
|
||||
components::tabs::ComponentTabs,
|
||||
drawing,
|
||||
event::StyleSetRequest,
|
||||
globals::WguiGlobals,
|
||||
i18n::Translation,
|
||||
layout::{Layout, WidgetID},
|
||||
|
|
@ -585,7 +586,7 @@ impl<T> TabSettings<T> {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
pub fn new(frontend: &mut Frontend<T>, parent_id: WidgetID, _data: &mut T) -> anyhow::Result<Self> {
|
||||
pub fn new(frontend: &mut Frontend<T>, parent_id: WidgetID, data: &mut T) -> anyhow::Result<Self> {
|
||||
let doc_params = ParseDocumentParams {
|
||||
globals: frontend.layout.state.globals.clone(),
|
||||
path: AssetPath::BuiltIn("gui/tab/settings.xml"),
|
||||
|
|
@ -595,6 +596,16 @@ impl<T> TabSettings<T> {
|
|||
let parser_state = wgui::parser::parse_from_assets(&doc_params, &mut frontend.layout, parent_id)?;
|
||||
let tasks = Tasks::default();
|
||||
let tabs = parser_state.fetch_component_as::<ComponentTabs>("tabs")?;
|
||||
|
||||
if !frontend.interface.get_feats(data).openxr {
|
||||
let skybox_btn = tabs.get_tab_button("skybox").unwrap();
|
||||
frontend
|
||||
.layout
|
||||
.common()
|
||||
.alterables
|
||||
.set_style(skybox_btn.get_rect(), StyleSetRequest::Display(taffy::Display::None));
|
||||
}
|
||||
|
||||
tabs.on_select({
|
||||
let tasks = tasks.clone();
|
||||
Rc::new(move |_common, evt| {
|
||||
|
|
|
|||
|
|
@ -476,6 +476,13 @@ impl DashInterface<AppState> for DashInterfaceLive {
|
|||
.enqueue(TaskType::Overlay(OverlayTask::ToggleDashboard));
|
||||
}
|
||||
|
||||
fn get_feats(&mut self, data: &mut AppState) -> dash_interface::InterfaceFeats {
|
||||
dash_interface::InterfaceFeats {
|
||||
openxr: matches!(data.xr_backend, XrBackend::OpenXR),
|
||||
monado: data.monado_state.is_some(),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(feature = "openxr")]
|
||||
fn monado_client_list(
|
||||
&mut self,
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ use crate::{
|
|||
layout::WidgetPair,
|
||||
widget::{ConstructEssentials, div::WidgetDiv},
|
||||
};
|
||||
use std::{cell::RefCell, rc::Rc};
|
||||
use std::{cell::RefCell, fmt::Pointer, rc::Rc};
|
||||
use taffy::{
|
||||
AlignItems,
|
||||
prelude::{length, percent},
|
||||
|
|
@ -94,6 +94,16 @@ impl ComponentTabs {
|
|||
pub fn on_select(&self, callback: TabSelectCallback) {
|
||||
self.state.borrow_mut().on_select = Some(callback);
|
||||
}
|
||||
|
||||
pub fn get_tab_button(&self, name: &str) -> Option<Rc<ComponentButton>> {
|
||||
self
|
||||
.state
|
||||
.borrow_mut()
|
||||
.mounted_entries
|
||||
.iter()
|
||||
.find(|e| name == &*e.name)
|
||||
.map(|e| e.button.clone())
|
||||
}
|
||||
}
|
||||
|
||||
pub fn construct(ess: &mut ConstructEssentials, params: Params) -> anyhow::Result<(WidgetPair, Rc<ComponentTabs>)> {
|
||||
|
|
|
|||
|
|
@ -43,6 +43,12 @@ pub enum RecenterMode {
|
|||
Reset,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
pub struct InterfaceFeats {
|
||||
pub openxr: bool,
|
||||
pub monado: bool,
|
||||
}
|
||||
|
||||
pub trait DashInterface<T> {
|
||||
fn window_list(&mut self, data: &mut T) -> anyhow::Result<Vec<WvrWindow>>;
|
||||
fn window_set_visible(&mut self, data: &mut T, handle: WvrWindowHandle, visible: bool) -> anyhow::Result<()>;
|
||||
|
|
@ -68,6 +74,7 @@ pub trait DashInterface<T> {
|
|||
fn config_changed(&mut self, data: &mut T, kind: ConfigChangeKind);
|
||||
fn restart(&mut self, data: &mut T);
|
||||
fn toggle_dashboard(&mut self, data: &mut T);
|
||||
fn get_feats(&mut self, data: &mut T) -> InterfaceFeats;
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy)]
|
||||
|
|
|
|||
|
|
@ -236,6 +236,13 @@ impl DashInterface<()> for DashInterfaceEmulated {
|
|||
|
||||
fn toggle_dashboard(&mut self, _data: &mut ()) {}
|
||||
|
||||
fn get_feats(&mut self, _data: &mut ()) -> dash_interface::InterfaceFeats {
|
||||
dash_interface::InterfaceFeats {
|
||||
openxr: true,
|
||||
monado: true,
|
||||
}
|
||||
}
|
||||
|
||||
fn monado_client_list(
|
||||
&mut self,
|
||||
_data: &mut (),
|
||||
|
|
|
|||
Loading…
Reference in New Issue