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,
|
assets::AssetPath,
|
||||||
components::tabs::ComponentTabs,
|
components::tabs::ComponentTabs,
|
||||||
drawing,
|
drawing,
|
||||||
|
event::StyleSetRequest,
|
||||||
globals::WguiGlobals,
|
globals::WguiGlobals,
|
||||||
i18n::Translation,
|
i18n::Translation,
|
||||||
layout::{Layout, WidgetID},
|
layout::{Layout, WidgetID},
|
||||||
|
|
@ -585,7 +586,7 @@ impl<T> TabSettings<T> {
|
||||||
Ok(())
|
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 {
|
let doc_params = ParseDocumentParams {
|
||||||
globals: frontend.layout.state.globals.clone(),
|
globals: frontend.layout.state.globals.clone(),
|
||||||
path: AssetPath::BuiltIn("gui/tab/settings.xml"),
|
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 parser_state = wgui::parser::parse_from_assets(&doc_params, &mut frontend.layout, parent_id)?;
|
||||||
let tasks = Tasks::default();
|
let tasks = Tasks::default();
|
||||||
let tabs = parser_state.fetch_component_as::<ComponentTabs>("tabs")?;
|
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({
|
tabs.on_select({
|
||||||
let tasks = tasks.clone();
|
let tasks = tasks.clone();
|
||||||
Rc::new(move |_common, evt| {
|
Rc::new(move |_common, evt| {
|
||||||
|
|
|
||||||
|
|
@ -476,6 +476,13 @@ impl DashInterface<AppState> for DashInterfaceLive {
|
||||||
.enqueue(TaskType::Overlay(OverlayTask::ToggleDashboard));
|
.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")]
|
#[cfg(feature = "openxr")]
|
||||||
fn monado_client_list(
|
fn monado_client_list(
|
||||||
&mut self,
|
&mut self,
|
||||||
|
|
|
||||||
|
|
@ -9,7 +9,7 @@ use crate::{
|
||||||
layout::WidgetPair,
|
layout::WidgetPair,
|
||||||
widget::{ConstructEssentials, div::WidgetDiv},
|
widget::{ConstructEssentials, div::WidgetDiv},
|
||||||
};
|
};
|
||||||
use std::{cell::RefCell, rc::Rc};
|
use std::{cell::RefCell, fmt::Pointer, rc::Rc};
|
||||||
use taffy::{
|
use taffy::{
|
||||||
AlignItems,
|
AlignItems,
|
||||||
prelude::{length, percent},
|
prelude::{length, percent},
|
||||||
|
|
@ -94,6 +94,16 @@ impl ComponentTabs {
|
||||||
pub fn on_select(&self, callback: TabSelectCallback) {
|
pub fn on_select(&self, callback: TabSelectCallback) {
|
||||||
self.state.borrow_mut().on_select = Some(callback);
|
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>)> {
|
pub fn construct(ess: &mut ConstructEssentials, params: Params) -> anyhow::Result<(WidgetPair, Rc<ComponentTabs>)> {
|
||||||
|
|
|
||||||
|
|
@ -43,6 +43,12 @@ pub enum RecenterMode {
|
||||||
Reset,
|
Reset,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Copy)]
|
||||||
|
pub struct InterfaceFeats {
|
||||||
|
pub openxr: bool,
|
||||||
|
pub monado: bool,
|
||||||
|
}
|
||||||
|
|
||||||
pub trait DashInterface<T> {
|
pub trait DashInterface<T> {
|
||||||
fn window_list(&mut self, data: &mut T) -> anyhow::Result<Vec<WvrWindow>>;
|
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<()>;
|
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 config_changed(&mut self, data: &mut T, kind: ConfigChangeKind);
|
||||||
fn restart(&mut self, data: &mut T);
|
fn restart(&mut self, data: &mut T);
|
||||||
fn toggle_dashboard(&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)]
|
#[derive(Clone, Copy)]
|
||||||
|
|
|
||||||
|
|
@ -236,6 +236,13 @@ impl DashInterface<()> for DashInterfaceEmulated {
|
||||||
|
|
||||||
fn toggle_dashboard(&mut self, _data: &mut ()) {}
|
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(
|
fn monado_client_list(
|
||||||
&mut self,
|
&mut self,
|
||||||
_data: &mut (),
|
_data: &mut (),
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue