mirror of https://github.com/wayvr-org/wayvr.git
Rebase main: integrate wgui changes with the new bindings ui
This commit is contained in:
parent
169fa0d32a
commit
e166d46806
|
|
@ -1,5 +1,5 @@
|
||||||
use std::{collections::HashMap, rc::Rc};
|
use std::rc::Rc;
|
||||||
|
use wgui::parser::TemplateParams;
|
||||||
use wgui::{
|
use wgui::{
|
||||||
components::button::ComponentButton, globals::WguiGlobals, layout::WidgetID, parser::Fetchable, task::Tasks,
|
components::button::ComponentButton, globals::WguiGlobals, layout::WidgetID, parser::Fetchable, task::Tasks,
|
||||||
};
|
};
|
||||||
|
|
@ -56,10 +56,10 @@ fn create_input_profiles_button(
|
||||||
let id = mp.idx.to_string();
|
let id = mp.idx.to_string();
|
||||||
mp.idx += 1;
|
mp.idx += 1;
|
||||||
|
|
||||||
let mut params: HashMap<Rc<str>, Rc<str>> = HashMap::new();
|
let mut params = TemplateParams::new();
|
||||||
params.insert(Rc::from("id"), Rc::from(id.as_ref()));
|
params.insert("id", &id);
|
||||||
params.insert(Rc::from("translation"), Rc::from("APP_SETTINGS.INPUT_PROFILES"));
|
params.insert("translation", "APP_SETTINGS.INPUT_PROFILES");
|
||||||
params.insert(Rc::from("icon"), Rc::from("dashboard/controller.svg"));
|
params.insert("icon", "dashboard/controller.svg");
|
||||||
|
|
||||||
mp.parser_state
|
mp.parser_state
|
||||||
.instantiate_template(mp.doc_params, "ButtonText", mp.layout, parent, params)?;
|
.instantiate_template(mp.doc_params, "ButtonText", mp.layout, parent, params)?;
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
use std::{collections::HashMap, rc::Rc};
|
|
||||||
|
|
||||||
use glam::Vec2;
|
use glam::Vec2;
|
||||||
|
use std::rc::Rc;
|
||||||
use strum::EnumProperty;
|
use strum::EnumProperty;
|
||||||
use wgui::{
|
use wgui::{
|
||||||
assets::AssetPath,
|
assets::AssetPath,
|
||||||
|
|
@ -12,7 +11,7 @@ use wgui::{
|
||||||
i18n::Translation,
|
i18n::Translation,
|
||||||
layout::{Layout, WidgetID},
|
layout::{Layout, WidgetID},
|
||||||
log::LogErr,
|
log::LogErr,
|
||||||
parser::{Fetchable, ParseDocumentParams, ParserState},
|
parser::{Fetchable, ParseDocumentParams, ParserState, TemplateParams},
|
||||||
task::Tasks,
|
task::Tasks,
|
||||||
widget::label::WidgetLabel,
|
widget::label::WidgetLabel,
|
||||||
windowing::context_menu::{self, TickResult},
|
windowing::context_menu::{self, TickResult},
|
||||||
|
|
@ -358,14 +357,11 @@ fn input_controls_for_action(
|
||||||
let id = mp.idx.to_string();
|
let id = mp.idx.to_string();
|
||||||
mp.idx += 1;
|
mp.idx += 1;
|
||||||
|
|
||||||
let mut params: HashMap<Rc<str>, Rc<str>> = HashMap::new();
|
let mut params = TemplateParams::new();
|
||||||
params.insert(Rc::from("id"), Rc::from(id.as_ref()));
|
params.insert("id", &id);
|
||||||
params.insert(
|
params.insert_str(
|
||||||
Rc::from("translation"),
|
"translation",
|
||||||
Rc::from(format!(
|
format!("APP_SETTINGS.BINDINGS.ACTION.{}", action.as_ref().to_uppercase()),
|
||||||
"APP_SETTINGS.BINDINGS.ACTION.{}",
|
|
||||||
action.as_ref().to_uppercase()
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
|
|
||||||
mp.parser_state
|
mp.parser_state
|
||||||
|
|
@ -487,9 +483,9 @@ fn subpath_dropdown(
|
||||||
available: Rc<[XrInputSubpathKind]>,
|
available: Rc<[XrInputSubpathKind]>,
|
||||||
current: Option<XrInputSubpathKind>,
|
current: Option<XrInputSubpathKind>,
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let mut params: HashMap<Rc<str>, Rc<str>> = HashMap::new();
|
let mut params = TemplateParams::new();
|
||||||
params.insert(Rc::from("tooltip"), Rc::from("APP_SETTINGS.BINDINGS.SUBPATH"));
|
params.insert("tooltip", "APP_SETTINGS.BINDINGS.SUBPATH");
|
||||||
params.insert(Rc::from("min_width"), Rc::from("100"));
|
params.insert("min_width", "100");
|
||||||
|
|
||||||
// left/right hand icon
|
// left/right hand icon
|
||||||
wgui_simple::create_icon(
|
wgui_simple::create_icon(
|
||||||
|
|
@ -520,10 +516,10 @@ fn component_dropdown(
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut params: HashMap<Rc<str>, Rc<str>> = HashMap::new();
|
let mut params = TemplateParams::new();
|
||||||
params.insert(Rc::from("text"), Rc::from("・"));
|
params.insert("text", "・");
|
||||||
params.insert(Rc::from("tooltip"), Rc::from("APP_SETTINGS.BINDINGS.COMPONENT"));
|
params.insert("tooltip", "APP_SETTINGS.BINDINGS.COMPONENT");
|
||||||
params.insert(Rc::from("min_width"), Rc::from("100"));
|
params.insert("min_width", "100");
|
||||||
|
|
||||||
let current_text = current
|
let current_text = current
|
||||||
.map(|c| c.translation())
|
.map(|c| c.translation())
|
||||||
|
|
@ -535,10 +531,10 @@ fn component_dropdown(
|
||||||
}
|
}
|
||||||
|
|
||||||
fn clicks_dropdown(mp: &mut MacroParams, parent: WidgetID, action: Rc<str>, current: ClickType) -> anyhow::Result<()> {
|
fn clicks_dropdown(mp: &mut MacroParams, parent: WidgetID, action: Rc<str>, current: ClickType) -> anyhow::Result<()> {
|
||||||
let mut params: HashMap<Rc<str>, Rc<str>> = HashMap::new();
|
let mut params = TemplateParams::new();
|
||||||
params.insert(Rc::from("text"), Rc::from("・"));
|
params.insert("text", "・");
|
||||||
params.insert(Rc::from("tooltip"), Rc::from("APP_SETTINGS.BINDINGS.CLICK.TYPE"));
|
params.insert("tooltip", "APP_SETTINGS.BINDINGS.CLICK.TYPE");
|
||||||
params.insert(Rc::from("min_width"), Rc::from("100"));
|
params.insert("min_width", "100");
|
||||||
|
|
||||||
let current_text = current.translation();
|
let current_text = current.translation();
|
||||||
let available = [ClickType::Any, ClickType::Double, ClickType::Triple].into();
|
let available = [ClickType::Any, ClickType::Double, ClickType::Triple].into();
|
||||||
|
|
@ -559,14 +555,14 @@ fn threshold_slider(
|
||||||
|
|
||||||
let current = current.unwrap_or(DEFAULT_BUTTON_THRESHOLDS);
|
let current = current.unwrap_or(DEFAULT_BUTTON_THRESHOLDS);
|
||||||
|
|
||||||
let mut params: HashMap<Rc<str>, Rc<str>> = HashMap::new();
|
let mut params = TemplateParams::new();
|
||||||
params.insert(Rc::from("id"), Rc::from(id.as_ref()));
|
params.insert("id", &id);
|
||||||
params.insert(Rc::from("tooltip"), Rc::from("APP_SETTINGS.BINDINGS.THRESHOLD"));
|
params.insert("tooltip", "APP_SETTINGS.BINDINGS.THRESHOLD");
|
||||||
params.insert(Rc::from("value"), Rc::from(format!("{:.2}", current[0])));
|
params.insert_str("value", format!("{:.2}", current[0]));
|
||||||
params.insert(Rc::from("value2"), Rc::from(format!("{:.2}", current[1])));
|
params.insert_str("value2", format!("{:.2}", current[1]));
|
||||||
params.insert(Rc::from("min"), Rc::from("0.0"));
|
params.insert("min", "0.0");
|
||||||
params.insert(Rc::from("max"), Rc::from("1.0"));
|
params.insert("max", "1.0");
|
||||||
params.insert(Rc::from("step"), Rc::from("0.1"));
|
params.insert("step", "0.1");
|
||||||
|
|
||||||
mp.parser_state
|
mp.parser_state
|
||||||
.instantiate_template(mp.doc_params, "ThresholdSlider", mp.layout, parent, params)?;
|
.instantiate_template(mp.doc_params, "ThresholdSlider", mp.layout, parent, params)?;
|
||||||
|
|
@ -589,7 +585,7 @@ fn threshold_slider(
|
||||||
fn create_dropdown<B: 'static + BindingsDropdown>(
|
fn create_dropdown<B: 'static + BindingsDropdown>(
|
||||||
mp: &mut MacroParams,
|
mp: &mut MacroParams,
|
||||||
parent: WidgetID,
|
parent: WidgetID,
|
||||||
mut params: HashMap<Rc<str>, Rc<str>>,
|
mut params: TemplateParams,
|
||||||
action: Rc<str>,
|
action: Rc<str>,
|
||||||
side: XrInputSide,
|
side: XrInputSide,
|
||||||
current_text: Translation,
|
current_text: Translation,
|
||||||
|
|
@ -597,7 +593,7 @@ fn create_dropdown<B: 'static + BindingsDropdown>(
|
||||||
) -> anyhow::Result<()> {
|
) -> anyhow::Result<()> {
|
||||||
let id = mp.idx.to_string();
|
let id = mp.idx.to_string();
|
||||||
mp.idx += 1;
|
mp.idx += 1;
|
||||||
params.insert(Rc::from("id"), Rc::from(id.as_ref()));
|
params.insert("id", &id);
|
||||||
|
|
||||||
mp.parser_state
|
mp.parser_state
|
||||||
.instantiate_template(mp.doc_params, "DropdownButton", mp.layout, parent, params)?;
|
.instantiate_template(mp.doc_params, "DropdownButton", mp.layout, parent, params)?;
|
||||||
|
|
|
||||||
|
|
@ -1,12 +1,11 @@
|
||||||
use std::{collections::HashMap, rc::Rc};
|
use std::rc::Rc;
|
||||||
|
|
||||||
use wgui::{
|
use wgui::{
|
||||||
assets::AssetPath,
|
assets::AssetPath,
|
||||||
components::button::ComponentButton,
|
components::button::ComponentButton,
|
||||||
globals::WguiGlobals,
|
globals::WguiGlobals,
|
||||||
i18n::Translation,
|
i18n::Translation,
|
||||||
layout::{Layout, WidgetID},
|
layout::{Layout, WidgetID},
|
||||||
parser::{Fetchable, ParseDocumentParams},
|
parser::{Fetchable, ParseDocumentParams, TemplateParams},
|
||||||
task::Tasks,
|
task::Tasks,
|
||||||
};
|
};
|
||||||
use wlx_common::{openxr_bindings_schema::XrControllerProfile, openxr_controller_profiles::OPENXR_INPUT_PROFILES};
|
use wlx_common::{openxr_bindings_schema::XrControllerProfile, openxr_controller_profiles::OPENXR_INPUT_PROFILES};
|
||||||
|
|
@ -73,9 +72,9 @@ impl View {
|
||||||
for (idx, profile) in OPENXR_INPUT_PROFILES.iter().enumerate() {
|
for (idx, profile) in OPENXR_INPUT_PROFILES.iter().enumerate() {
|
||||||
let id = format!("profile_btn_{idx}");
|
let id = format!("profile_btn_{idx}");
|
||||||
|
|
||||||
let mut cell_params: HashMap<Rc<str>, Rc<str>> = HashMap::new();
|
let mut cell_params = TemplateParams::new();
|
||||||
cell_params.insert(Rc::from("id"), Rc::from(id.clone()));
|
cell_params.insert("id", &id);
|
||||||
cell_params.insert(Rc::from("text"), Rc::from(profile.display_name));
|
cell_params.insert("text", profile.display_name);
|
||||||
|
|
||||||
parser_state.instantiate_template(
|
parser_state.instantiate_template(
|
||||||
doc_params,
|
doc_params,
|
||||||
|
|
|
||||||
|
|
@ -127,6 +127,10 @@ impl TemplateParams {
|
||||||
pub fn insert_rc(&mut self, key: &str, value: Rc<str>) -> Option<Rc<str>> {
|
pub fn insert_rc(&mut self, key: &str, value: Rc<str>) -> Option<Rc<str>> {
|
||||||
self.0.insert(Rc::from(key), value)
|
self.0.insert(Rc::from(key), value)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn insert_str(&mut self, key: &str, value: String) -> Option<Rc<str>> {
|
||||||
|
self.0.insert(Rc::from(key), value.into())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ParserData {
|
impl ParserData {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue