mirror of https://github.com/wayvr-org/wayvr.git
Improve "Change input bindings" page a little bit
This commit is contained in:
parent
65fd75eb4a
commit
e7a9df17cf
|
|
@ -1,15 +1,15 @@
|
||||||
<layout>
|
<layout>
|
||||||
<template name="ProfileButton">
|
<!-- id, text -->
|
||||||
<Button id="${id}" height="36" padding="4" gap="8" text="${text}" />
|
<template name="InputProfileButton">
|
||||||
|
<Button id="${id}" width="350" gap="8" justify_content="start" >
|
||||||
|
<sprite margin_left="8" src_builtin="dashboard/controller.svg" min_width="24" min_height="24"/>
|
||||||
|
<label text="${text}" weight="bold"/>
|
||||||
|
</Button>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<elements>
|
<elements>
|
||||||
<div flex_direction="column" gap="8" width="100%" align_items="center">
|
<div flex_direction="column" gap="8" width="100%" align_items="center">
|
||||||
<div id="list_parent" flex_direction="column" gap="4" width="100%"></div>
|
<div id="list_parent" flex_grow="1" flex_wrap="wrap" flex_direction="row" gap="4" width="100%" justify_content="center"></div>
|
||||||
|
|
||||||
<div flex_direction="row" gap="4" align_self="end">
|
|
||||||
<Button id="btn_cancel" height="32" translation="APP_SETTINGS.CANCEL" />
|
|
||||||
</div>
|
|
||||||
</div>
|
</div>
|
||||||
</elements>
|
</elements>
|
||||||
</layout>
|
</layout>
|
||||||
|
|
|
||||||
|
|
@ -23,7 +23,6 @@ use crate::{
|
||||||
#[derive(Clone)]
|
#[derive(Clone)]
|
||||||
enum Task {
|
enum Task {
|
||||||
SelectProfile(Rc<str>),
|
SelectProfile(Rc<str>),
|
||||||
Cancel,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct Params<'a> {
|
pub struct Params<'a> {
|
||||||
|
|
@ -31,14 +30,12 @@ pub struct Params<'a> {
|
||||||
pub layout: &'a mut Layout,
|
pub layout: &'a mut Layout,
|
||||||
pub parent_id: WidgetID,
|
pub parent_id: WidgetID,
|
||||||
pub frontend_tasks: &'a FrontendTasks,
|
pub frontend_tasks: &'a FrontendTasks,
|
||||||
pub close_callback: Box<dyn FnOnce()>,
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct View {
|
pub struct View {
|
||||||
tasks: Tasks<Task>,
|
tasks: Tasks<Task>,
|
||||||
frontend_tasks: FrontendTasks,
|
frontend_tasks: FrontendTasks,
|
||||||
globals: WguiGlobals,
|
globals: WguiGlobals,
|
||||||
close_callback: Option<Box<dyn FnOnce()>>,
|
|
||||||
bindings_popup: PopupHolder<bindings::View>,
|
bindings_popup: PopupHolder<bindings::View>,
|
||||||
bindings_file: openxr_bindings_schema::BindingsFile,
|
bindings_file: openxr_bindings_schema::BindingsFile,
|
||||||
}
|
}
|
||||||
|
|
@ -64,11 +61,6 @@ impl ViewTrait for View {
|
||||||
profile.clone(),
|
profile.clone(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Task::Cancel => {
|
|
||||||
if let Some(close_callback) = self.close_callback.take() {
|
|
||||||
close_callback();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
|
@ -89,11 +81,6 @@ impl View {
|
||||||
|
|
||||||
let tasks = Tasks::new();
|
let tasks = Tasks::new();
|
||||||
|
|
||||||
tasks.handle_button(
|
|
||||||
&parser_state.fetch_component_as::<ComponentButton>("btn_cancel")?,
|
|
||||||
Task::Cancel,
|
|
||||||
);
|
|
||||||
|
|
||||||
let bindings_file = openxr_bindings_schema::BindingsFile::load_embedded();
|
let bindings_file = openxr_bindings_schema::BindingsFile::load_embedded();
|
||||||
|
|
||||||
for (idx, (profile_id, profile)) in bindings_file.profiles.iter().enumerate() {
|
for (idx, (profile_id, profile)) in bindings_file.profiles.iter().enumerate() {
|
||||||
|
|
@ -102,9 +89,15 @@ impl View {
|
||||||
|
|
||||||
let mut cell_params: HashMap<Rc<str>, Rc<str>> = HashMap::new();
|
let mut cell_params: HashMap<Rc<str>, Rc<str>> = HashMap::new();
|
||||||
cell_params.insert(Rc::from("id"), Rc::from(id.clone()));
|
cell_params.insert(Rc::from("id"), Rc::from(id.clone()));
|
||||||
cell_params.insert(Rc::from("text"), Rc::from(profile_name));
|
cell_params.insert(Rc::from("text"), profile_name);
|
||||||
|
|
||||||
parser_state.instantiate_template(doc_params, "ProfileButton", params.layout, list_parent, cell_params)?;
|
parser_state.instantiate_template(
|
||||||
|
doc_params,
|
||||||
|
"InputProfileButton",
|
||||||
|
params.layout,
|
||||||
|
list_parent,
|
||||||
|
cell_params,
|
||||||
|
)?;
|
||||||
|
|
||||||
let btn = parser_state.fetch_component_as::<ComponentButton>(&id)?;
|
let btn = parser_state.fetch_component_as::<ComponentButton>(&id)?;
|
||||||
let tasks_clone = tasks.clone();
|
let tasks_clone = tasks.clone();
|
||||||
|
|
@ -121,7 +114,6 @@ impl View {
|
||||||
tasks,
|
tasks,
|
||||||
frontend_tasks: params.frontend_tasks.clone(),
|
frontend_tasks: params.frontend_tasks.clone(),
|
||||||
globals: params.globals.clone(),
|
globals: params.globals.clone(),
|
||||||
close_callback: Some(params.close_callback),
|
|
||||||
bindings_popup: Default::default(),
|
bindings_popup: Default::default(),
|
||||||
bindings_file,
|
bindings_file,
|
||||||
})
|
})
|
||||||
|
|
@ -134,13 +126,11 @@ pub fn mount_popup(frontend_tasks: FrontendTasks, globals: WguiGlobals, popup: P
|
||||||
.push(FrontendTask::MountPopupOnce(MountPopupOnceParams::new(
|
.push(FrontendTask::MountPopupOnce(MountPopupOnceParams::new(
|
||||||
Translation::from_translation_key("APP_SETTINGS.INPUT_PROFILES"),
|
Translation::from_translation_key("APP_SETTINGS.INPUT_PROFILES"),
|
||||||
Box::new(move |data| {
|
Box::new(move |data| {
|
||||||
let close_callback = popup.get_close_callback(data.layout);
|
|
||||||
let view = View::new(Params {
|
let view = View::new(Params {
|
||||||
globals: globals.clone(),
|
globals: globals.clone(),
|
||||||
layout: data.layout,
|
layout: data.layout,
|
||||||
parent_id: data.id_content,
|
parent_id: data.id_content,
|
||||||
frontend_tasks: &frontend_tasks,
|
frontend_tasks: &frontend_tasks,
|
||||||
close_callback,
|
|
||||||
})?;
|
})?;
|
||||||
|
|
||||||
popup.set_view(data.handle, view, None);
|
popup.set_view(data.handle, view, None);
|
||||||
|
|
|
||||||
|
|
@ -437,8 +437,9 @@ pub fn construct(ess: &mut ConstructEssentials, params: Params) -> anyhow::Resul
|
||||||
let mut style = params.style;
|
let mut style = params.style;
|
||||||
let theme = &ess.layout.state.theme;
|
let theme = &ess.layout.state.theme;
|
||||||
|
|
||||||
// force-override style
|
if style.align_items.is_none() {
|
||||||
style.align_items = Some(AlignItems::Center);
|
style.align_items = Some(AlignItems::Center);
|
||||||
|
}
|
||||||
if style.justify_content.is_none() {
|
if style.justify_content.is_none() {
|
||||||
style.justify_content = Some(JustifyContent::Center);
|
style.justify_content = Some(JustifyContent::Center);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue