mirror of https://github.com/wayvr-org/wayvr.git
dash-frontend: use SettingsTab trait for each settings tab
This commit is contained in:
parent
7f822b6787
commit
a3460fbe70
|
|
@ -546,31 +546,36 @@ impl<T> TabSettings<T> {
|
|||
idx: 9001,
|
||||
};
|
||||
|
||||
let settings_mount_params = SettingsMountParams {
|
||||
mp: &mut mp,
|
||||
globals: &globals,
|
||||
parent_id: root,
|
||||
};
|
||||
|
||||
match name {
|
||||
TabNameEnum::LookAndFeel => {
|
||||
tab_look_and_feel::mount(&mut mp, root)?;
|
||||
self.current_tab = Some(Box::new(tab_look_and_feel::State::mount(settings_mount_params)?));
|
||||
}
|
||||
TabNameEnum::Features => {
|
||||
tab_features::mount(&mut mp, root)?;
|
||||
self.current_tab = Some(Box::new(tab_features::State::mount(settings_mount_params)?));
|
||||
}
|
||||
TabNameEnum::Controls => {
|
||||
tab_controls::mount(&mut mp, root)?;
|
||||
self.current_tab = Some(Box::new(tab_controls::State::mount(settings_mount_params)?));
|
||||
}
|
||||
TabNameEnum::Misc => {
|
||||
tab_misc::mount(&mut mp, root)?;
|
||||
self.current_tab = Some(Box::new(tab_misc::State::mount(settings_mount_params)?));
|
||||
}
|
||||
TabNameEnum::AutostartApps => {
|
||||
tab_autostart_apps::mount(&mut mp, root, &mut self.app_button_ids)?;
|
||||
self.current_tab = Some(Box::new(tab_autostart_apps::State::mount(
|
||||
settings_mount_params,
|
||||
&mut self.app_button_ids,
|
||||
)?));
|
||||
}
|
||||
TabNameEnum::Troubleshooting => {
|
||||
tab_troubleshooting::mount(&mut mp, root)?;
|
||||
self.current_tab = Some(Box::new(tab_troubleshooting::State::mount(settings_mount_params)?));
|
||||
}
|
||||
TabNameEnum::Skybox => {
|
||||
self.current_tab = Some(Box::new(tab_skybox::State::mount(SettingsMountParams {
|
||||
mp: &mut mp,
|
||||
globals: &globals,
|
||||
parent_id: root,
|
||||
})?));
|
||||
self.current_tab = Some(Box::new(tab_skybox::State::mount(settings_mount_params)?));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,19 +1,32 @@
|
|||
use std::rc::Rc;
|
||||
|
||||
use crate::tab::settings::macros::{MacroParams, options_autostart_app, options_category};
|
||||
use wgui::layout::WidgetID;
|
||||
use crate::tab::settings::{
|
||||
SettingsMountParams, SettingsTab,
|
||||
macros::{options_autostart_app, options_category},
|
||||
};
|
||||
|
||||
pub fn mount(mp: &mut MacroParams, parent: WidgetID, app_button_ids: &mut Vec<Rc<str>>) -> anyhow::Result<()> {
|
||||
*app_button_ids = Vec::new();
|
||||
pub struct State {}
|
||||
|
||||
if !mp.config.autostart_apps.is_empty() {
|
||||
let c = options_category(mp, parent, "APP_SETTINGS.AUTOSTART_APPS", "dashboard/apps.svg")?;
|
||||
impl SettingsTab for State {}
|
||||
|
||||
// todo: prevent clone
|
||||
let autostart_apps = mp.config.autostart_apps.clone();
|
||||
for app in autostart_apps {
|
||||
options_autostart_app(mp, c, &app.name, app_button_ids)?;
|
||||
impl State {
|
||||
pub fn mount(par: SettingsMountParams, app_button_ids: &mut Vec<Rc<str>>) -> anyhow::Result<State> {
|
||||
*app_button_ids = Vec::new();
|
||||
|
||||
if !par.mp.config.autostart_apps.is_empty() {
|
||||
let c = options_category(
|
||||
par.mp,
|
||||
par.parent_id,
|
||||
"APP_SETTINGS.AUTOSTART_APPS",
|
||||
"dashboard/apps.svg",
|
||||
)?;
|
||||
|
||||
// todo: prevent clone
|
||||
let autostart_apps = par.mp.config.autostart_apps.clone();
|
||||
for app in autostart_apps {
|
||||
options_autostart_app(par.mp, c, &app.name, app_button_ids)?;
|
||||
}
|
||||
}
|
||||
Ok(State {})
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,23 +1,33 @@
|
|||
use crate::tab::settings::{
|
||||
SettingType,
|
||||
macros::{MacroParams, options_category, options_checkbox, options_dropdown, options_slider_f32, options_slider_i32},
|
||||
SettingType, SettingsMountParams, SettingsTab,
|
||||
macros::{options_category, options_checkbox, options_dropdown, options_slider_f32, options_slider_i32},
|
||||
};
|
||||
use wgui::layout::WidgetID;
|
||||
|
||||
pub fn mount(mp: &mut MacroParams, parent: WidgetID) -> anyhow::Result<()> {
|
||||
let c = options_category(mp, parent, "APP_SETTINGS.CONTROLS", "dashboard/controller.svg")?;
|
||||
options_dropdown::<wlx_common::config::AltModifier>(mp, c, &SettingType::KeyboardMiddleClick)?;
|
||||
options_dropdown::<wlx_common::config::HandsfreePointer>(mp, c, &SettingType::HandsfreePointer)?;
|
||||
options_checkbox(mp, c, SettingType::FocusFollowsMouseMode)?;
|
||||
options_checkbox(mp, c, SettingType::LeftHandedMouse)?;
|
||||
options_checkbox(mp, c, SettingType::AllowSliding)?;
|
||||
options_checkbox(mp, c, SettingType::InvertScrollDirectionX)?;
|
||||
options_checkbox(mp, c, SettingType::InvertScrollDirectionY)?;
|
||||
options_slider_f32(mp, c, SettingType::ScrollSpeed, 0.1, 5.0, 0.1)?;
|
||||
options_slider_f32(mp, c, SettingType::LongPressDuration, 0.1, 2.0, 0.1)?;
|
||||
options_slider_f32(mp, c, SettingType::PointerLerpFactor, 0.1, 1.0, 0.1)?;
|
||||
options_slider_f32(mp, c, SettingType::XrClickSensitivity, 0.1, 1.0, 0.1)?;
|
||||
options_slider_f32(mp, c, SettingType::XrClickSensitivityRelease, 0.1, 1.0, 0.1)?;
|
||||
options_slider_i32(mp, c, SettingType::ClickFreezeTimeMs, 0, 500, 50)?;
|
||||
Ok(())
|
||||
pub struct State {}
|
||||
|
||||
impl SettingsTab for State {}
|
||||
|
||||
impl State {
|
||||
pub fn mount(par: SettingsMountParams) -> anyhow::Result<State> {
|
||||
let c = options_category(
|
||||
par.mp,
|
||||
par.parent_id,
|
||||
"APP_SETTINGS.CONTROLS",
|
||||
"dashboard/controller.svg",
|
||||
)?;
|
||||
options_dropdown::<wlx_common::config::AltModifier>(par.mp, c, &SettingType::KeyboardMiddleClick)?;
|
||||
options_dropdown::<wlx_common::config::HandsfreePointer>(par.mp, c, &SettingType::HandsfreePointer)?;
|
||||
options_checkbox(par.mp, c, SettingType::FocusFollowsMouseMode)?;
|
||||
options_checkbox(par.mp, c, SettingType::LeftHandedMouse)?;
|
||||
options_checkbox(par.mp, c, SettingType::AllowSliding)?;
|
||||
options_checkbox(par.mp, c, SettingType::InvertScrollDirectionX)?;
|
||||
options_checkbox(par.mp, c, SettingType::InvertScrollDirectionY)?;
|
||||
options_slider_f32(par.mp, c, SettingType::ScrollSpeed, 0.1, 5.0, 0.1)?;
|
||||
options_slider_f32(par.mp, c, SettingType::LongPressDuration, 0.1, 2.0, 0.1)?;
|
||||
options_slider_f32(par.mp, c, SettingType::PointerLerpFactor, 0.1, 1.0, 0.1)?;
|
||||
options_slider_f32(par.mp, c, SettingType::XrClickSensitivity, 0.1, 1.0, 0.1)?;
|
||||
options_slider_f32(par.mp, c, SettingType::XrClickSensitivityRelease, 0.1, 1.0, 0.1)?;
|
||||
options_slider_i32(par.mp, c, SettingType::ClickFreezeTimeMs, 0, 500, 50)?;
|
||||
Ok(State {})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,25 @@
|
|||
use crate::tab::settings::{
|
||||
SettingType,
|
||||
macros::{MacroParams, options_category, options_checkbox, options_slider_f32},
|
||||
SettingType, SettingsMountParams, SettingsTab,
|
||||
macros::{options_category, options_checkbox, options_slider_f32},
|
||||
};
|
||||
use wgui::layout::WidgetID;
|
||||
|
||||
pub fn mount(mp: &mut MacroParams, parent: WidgetID) -> anyhow::Result<()> {
|
||||
let c = options_category(mp, parent, "APP_SETTINGS.FEATURES", "dashboard/options.svg")?;
|
||||
options_checkbox(mp, c, SettingType::NotificationsEnabled)?;
|
||||
options_checkbox(mp, c, SettingType::NotificationsSoundEnabled)?;
|
||||
options_checkbox(mp, c, SettingType::KeyboardSoundEnabled)?;
|
||||
options_checkbox(mp, c, SettingType::KeyboardSwipeToTypeEnabled)?;
|
||||
options_checkbox(mp, c, SettingType::SpaceDragUnlocked)?;
|
||||
options_checkbox(mp, c, SettingType::SpaceRotateUnlocked)?;
|
||||
options_slider_f32(mp, c, SettingType::SpaceDragMultiplier, -10.0, 10.0, 0.5)?;
|
||||
options_checkbox(mp, c, SettingType::BlockGameInput)?;
|
||||
options_checkbox(mp, c, SettingType::BlockGameInputIgnoreWatch)?;
|
||||
options_checkbox(mp, c, SettingType::BlockPosesOnKbdInteraction)?;
|
||||
Ok(())
|
||||
pub struct State {}
|
||||
|
||||
impl SettingsTab for State {}
|
||||
|
||||
impl State {
|
||||
pub fn mount(par: SettingsMountParams) -> anyhow::Result<State> {
|
||||
let c = options_category(par.mp, par.parent_id, "APP_SETTINGS.FEATURES", "dashboard/options.svg")?;
|
||||
options_checkbox(par.mp, c, SettingType::NotificationsEnabled)?;
|
||||
options_checkbox(par.mp, c, SettingType::NotificationsSoundEnabled)?;
|
||||
options_checkbox(par.mp, c, SettingType::KeyboardSoundEnabled)?;
|
||||
options_checkbox(par.mp, c, SettingType::KeyboardSwipeToTypeEnabled)?;
|
||||
options_checkbox(par.mp, c, SettingType::SpaceDragUnlocked)?;
|
||||
options_checkbox(par.mp, c, SettingType::SpaceRotateUnlocked)?;
|
||||
options_slider_f32(par.mp, c, SettingType::SpaceDragMultiplier, -10.0, 10.0, 0.5)?;
|
||||
options_checkbox(par.mp, c, SettingType::BlockGameInput)?;
|
||||
options_checkbox(par.mp, c, SettingType::BlockGameInputIgnoreWatch)?;
|
||||
options_checkbox(par.mp, c, SettingType::BlockPosesOnKbdInteraction)?;
|
||||
Ok(State {})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,20 +1,30 @@
|
|||
use crate::tab::settings::{
|
||||
SettingType,
|
||||
macros::{MacroParams, options_category, options_checkbox, options_dropdown, options_slider_f32},
|
||||
SettingType, SettingsMountParams, SettingsTab,
|
||||
macros::{options_category, options_checkbox, options_dropdown, options_slider_f32},
|
||||
};
|
||||
use wgui::layout::WidgetID;
|
||||
|
||||
pub fn mount(mp: &mut MacroParams, parent: WidgetID) -> anyhow::Result<()> {
|
||||
let c = options_category(mp, parent, "APP_SETTINGS.LOOK_AND_FEEL", "dashboard/palette.svg")?;
|
||||
options_dropdown::<wlx_common::locale::Language>(mp, c, &SettingType::Language)?;
|
||||
options_checkbox(mp, c, SettingType::HideUsername)?;
|
||||
options_checkbox(mp, c, SettingType::HideGrabHelp)?;
|
||||
options_slider_f32(mp, c, SettingType::UiAnimationSpeed, 0.5, 5.0, 0.1)?; // min, max, step
|
||||
options_slider_f32(mp, c, SettingType::UiGradientIntensity, 0.0, 1.0, 0.05)?; // min, max, step
|
||||
options_slider_f32(mp, c, SettingType::UiRoundMultiplier, 0.5, 5.0, 0.1)?;
|
||||
options_checkbox(mp, c, SettingType::SetsOnWatch)?;
|
||||
options_slider_f32(mp, c, SettingType::GridOpacity, 0.0, 1.0, 0.05)?; // min, max, step
|
||||
options_checkbox(mp, c, SettingType::UsePassthrough)?;
|
||||
options_checkbox(mp, c, SettingType::Clock12h)?;
|
||||
Ok(())
|
||||
pub struct State {}
|
||||
|
||||
impl SettingsTab for State {}
|
||||
|
||||
impl State {
|
||||
pub fn mount(par: SettingsMountParams) -> anyhow::Result<State> {
|
||||
let c = options_category(
|
||||
par.mp,
|
||||
par.parent_id,
|
||||
"APP_SETTINGS.LOOK_AND_FEEL",
|
||||
"dashboard/palette.svg",
|
||||
)?;
|
||||
options_dropdown::<wlx_common::locale::Language>(par.mp, c, &SettingType::Language)?;
|
||||
options_checkbox(par.mp, c, SettingType::HideUsername)?;
|
||||
options_checkbox(par.mp, c, SettingType::HideGrabHelp)?;
|
||||
options_slider_f32(par.mp, c, SettingType::UiAnimationSpeed, 0.5, 5.0, 0.1)?; // min, max, step
|
||||
options_slider_f32(par.mp, c, SettingType::UiGradientIntensity, 0.0, 1.0, 0.05)?; // min, max, step
|
||||
options_slider_f32(par.mp, c, SettingType::UiRoundMultiplier, 0.5, 5.0, 0.1)?;
|
||||
options_checkbox(par.mp, c, SettingType::SetsOnWatch)?;
|
||||
options_slider_f32(par.mp, c, SettingType::GridOpacity, 0.0, 1.0, 0.05)?; // min, max, step
|
||||
options_checkbox(par.mp, c, SettingType::UsePassthrough)?;
|
||||
options_checkbox(par.mp, c, SettingType::Clock12h)?;
|
||||
Ok(State {})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,15 +1,20 @@
|
|||
use crate::tab::settings::{
|
||||
SettingType,
|
||||
macros::{MacroParams, options_category, options_checkbox, options_dropdown},
|
||||
SettingType, SettingsMountParams, SettingsTab,
|
||||
macros::{options_category, options_checkbox, options_dropdown},
|
||||
};
|
||||
use wgui::layout::WidgetID;
|
||||
|
||||
pub fn mount(mp: &mut MacroParams, parent: WidgetID) -> anyhow::Result<()> {
|
||||
let c = options_category(mp, parent, "APP_SETTINGS.MISC", "dashboard/blocks.svg")?;
|
||||
options_dropdown::<wlx_common::config::CaptureMethod>(mp, c, &SettingType::CaptureMethod)?;
|
||||
options_checkbox(mp, c, SettingType::XwaylandByDefault)?;
|
||||
options_checkbox(mp, c, SettingType::UprightScreenFix)?;
|
||||
options_checkbox(mp, c, SettingType::DoubleCursorFix)?;
|
||||
options_checkbox(mp, c, SettingType::ScreenRenderDown)?;
|
||||
Ok(())
|
||||
pub struct State {}
|
||||
|
||||
impl SettingsTab for State {}
|
||||
|
||||
impl State {
|
||||
pub fn mount(par: SettingsMountParams) -> anyhow::Result<State> {
|
||||
let c = options_category(par.mp, par.parent_id, "APP_SETTINGS.MISC", "dashboard/blocks.svg")?;
|
||||
options_dropdown::<wlx_common::config::CaptureMethod>(par.mp, c, &SettingType::CaptureMethod)?;
|
||||
options_checkbox(par.mp, c, SettingType::XwaylandByDefault)?;
|
||||
options_checkbox(par.mp, c, SettingType::UprightScreenFix)?;
|
||||
options_checkbox(par.mp, c, SettingType::DoubleCursorFix)?;
|
||||
options_checkbox(par.mp, c, SettingType::ScreenRenderDown)?;
|
||||
Ok(State {})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,45 +1,55 @@
|
|||
use crate::tab::settings::{
|
||||
Task,
|
||||
macros::{MacroParams, options_category, options_danger_button},
|
||||
SettingsMountParams, SettingsTab, Task,
|
||||
macros::{options_category, options_danger_button},
|
||||
};
|
||||
use wgui::layout::WidgetID;
|
||||
|
||||
pub fn mount(mp: &mut MacroParams, parent: WidgetID) -> anyhow::Result<()> {
|
||||
let c = options_category(mp, parent, "APP_SETTINGS.TROUBLESHOOTING", "dashboard/cpu.svg")?;
|
||||
options_danger_button(
|
||||
mp,
|
||||
c,
|
||||
"APP_SETTINGS.RESET_PLAYSPACE",
|
||||
"dashboard/recenter.svg",
|
||||
Task::ResetPlayspace,
|
||||
)?;
|
||||
options_danger_button(
|
||||
mp,
|
||||
c,
|
||||
"APP_SETTINGS.CLEAR_PIPEWIRE_TOKENS",
|
||||
"dashboard/display.svg",
|
||||
Task::ClearPipewireTokens,
|
||||
)?;
|
||||
options_danger_button(
|
||||
mp,
|
||||
c,
|
||||
"APP_SETTINGS.CLEAR_SAVED_STATE",
|
||||
"dashboard/binary.svg",
|
||||
Task::ClearSavedState,
|
||||
)?;
|
||||
options_danger_button(
|
||||
mp,
|
||||
c,
|
||||
"APP_SETTINGS.DELETE_ALL_CONFIGS",
|
||||
"dashboard/circle.svg",
|
||||
Task::DeleteAllConfigs,
|
||||
)?;
|
||||
options_danger_button(
|
||||
mp,
|
||||
c,
|
||||
"APP_SETTINGS.RESTART_SOFTWARE",
|
||||
"dashboard/refresh.svg",
|
||||
Task::RestartSoftware,
|
||||
)?;
|
||||
Ok(())
|
||||
pub struct State {}
|
||||
|
||||
impl SettingsTab for State {}
|
||||
|
||||
impl State {
|
||||
pub fn mount(par: SettingsMountParams) -> anyhow::Result<Self> {
|
||||
let c = options_category(
|
||||
par.mp,
|
||||
par.parent_id,
|
||||
"APP_SETTINGS.TROUBLESHOOTING",
|
||||
"dashboard/cpu.svg",
|
||||
)?;
|
||||
options_danger_button(
|
||||
par.mp,
|
||||
c,
|
||||
"APP_SETTINGS.RESET_PLAYSPACE",
|
||||
"dashboard/recenter.svg",
|
||||
Task::ResetPlayspace,
|
||||
)?;
|
||||
options_danger_button(
|
||||
par.mp,
|
||||
c,
|
||||
"APP_SETTINGS.CLEAR_PIPEWIRE_TOKENS",
|
||||
"dashboard/display.svg",
|
||||
Task::ClearPipewireTokens,
|
||||
)?;
|
||||
options_danger_button(
|
||||
par.mp,
|
||||
c,
|
||||
"APP_SETTINGS.CLEAR_SAVED_STATE",
|
||||
"dashboard/binary.svg",
|
||||
Task::ClearSavedState,
|
||||
)?;
|
||||
options_danger_button(
|
||||
par.mp,
|
||||
c,
|
||||
"APP_SETTINGS.DELETE_ALL_CONFIGS",
|
||||
"dashboard/circle.svg",
|
||||
Task::DeleteAllConfigs,
|
||||
)?;
|
||||
options_danger_button(
|
||||
par.mp,
|
||||
c,
|
||||
"APP_SETTINGS.RESTART_SOFTWARE",
|
||||
"dashboard/refresh.svg",
|
||||
Task::RestartSoftware,
|
||||
)?;
|
||||
Ok(State {})
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue