fix dropdowns being stuck open; multi button events
This commit is contained in:
@@ -165,21 +165,21 @@
|
||||
|
||||
<blueprint name="menu_handsfree">
|
||||
<context_menu >
|
||||
<cell translation="BAR.HANDSFREE.NONE" _press="::HandsfreeMode None" />
|
||||
<cell translation="BAR.HANDSFREE.HMD" _press="::HandsfreeMode Hmd" />
|
||||
<cell translation="BAR.HANDSFREE.HMD_ONLY" _press="::HandsfreeMode HmdOnly" />
|
||||
<cell translation="BAR.HANDSFREE.EYE_TRACKING" _press="::HandsfreeMode EyeTracking" />
|
||||
<cell translation="BAR.HANDSFREE.EYE_ONLY" _press="::HandsfreeMode EyeTrackingOnly" />
|
||||
<cell translation="BAR.HANDSFREE.NONE" _press="::HandsfreeMode None" _press2="::ContextMenuClose" />
|
||||
<cell translation="BAR.HANDSFREE.HMD" _press="::HandsfreeMode Hmd" _press2="::ContextMenuClose" />
|
||||
<cell translation="BAR.HANDSFREE.HMD_ONLY" _press="::HandsfreeMode HmdOnly" _press2="::ContextMenuClose" />
|
||||
<cell translation="BAR.HANDSFREE.EYE_TRACKING" _press="::HandsfreeMode EyeTracking" _press2="::ContextMenuClose" />
|
||||
<cell translation="BAR.HANDSFREE.EYE_ONLY" _press="::HandsfreeMode EyeTrackingOnly" _press2="::ContextMenuClose" />
|
||||
</context_menu>
|
||||
</blueprint>
|
||||
|
||||
<blueprint name="menu_burger">
|
||||
<context_menu >
|
||||
<cell translation="BAR.EDIT_MODE_TOGGLE" _press="::EditToggle" _press2="::ContextMenuClose" />
|
||||
<cell translation="BAR.HANDSFREE.TITLE" _press="::ContextMenuOpen menu_handsfree" />
|
||||
<cell translation="BAR.ADD_MIRROR" _press="::NewMirror" />
|
||||
<cell translation="BAR.EDIT_MODE_TOGGLE" _press="::EditToggle" />
|
||||
<cell translation="BAR.ADD_NEW_SET" _press="::AddSet" />
|
||||
<cell translation="BAR.DELETE_CURRENT_SET" _press="::DeleteSet" />
|
||||
<cell translation="BAR.HANDSFREE.TITLE" _press="::ContextMenuOpen menu_handsfree" />
|
||||
</context_menu>
|
||||
</blueprint>
|
||||
|
||||
|
||||
@@ -37,6 +37,8 @@ use crate::{
|
||||
windowing::{OverlaySelector, backend::OverlayEventData, window::OverlayCategory},
|
||||
};
|
||||
|
||||
pub const BUTTON_EVENT_SUFFIX: &[&str] = &["", "2", "3", "4", "5", "6", "7", "8", "9"];
|
||||
|
||||
#[allow(clippy::type_complexity)]
|
||||
pub const BUTTON_EVENTS: [(
|
||||
&str,
|
||||
@@ -196,8 +198,11 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
const TAG: &str = "Button";
|
||||
|
||||
for (name, kind, test_button, test_duration) in &BUTTON_EVENTS {
|
||||
for suffix in BUTTON_EVENT_SUFFIX {
|
||||
let name = &format!("{name}{suffix}");
|
||||
let Some(action) = attribs.get_value(name) else {
|
||||
continue;
|
||||
//if no _press2 then don't attempt _press3 etc
|
||||
break;
|
||||
};
|
||||
|
||||
let mut args = action.split_whitespace();
|
||||
@@ -392,10 +397,9 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
return Ok(EventResult::Pass);
|
||||
}
|
||||
|
||||
app.tasks
|
||||
.enqueue(TaskType::Overlay(OverlayTask::Drop(OverlaySelector::Name(
|
||||
arg.clone(),
|
||||
))));
|
||||
app.tasks.enqueue(TaskType::Overlay(OverlayTask::Drop(
|
||||
OverlaySelector::Name(arg.clone()),
|
||||
)));
|
||||
Ok(EventResult::Consumed)
|
||||
})
|
||||
}
|
||||
@@ -470,7 +474,10 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
Box::new(move |app, owc| {
|
||||
let _ = owc
|
||||
.backend
|
||||
.notify(app, OverlayEventData::WvrCommand(WvrCommand::CloseWindow))
|
||||
.notify(
|
||||
app,
|
||||
OverlayEventData::WvrCommand(WvrCommand::CloseWindow),
|
||||
)
|
||||
.log_warn("Could not close window");
|
||||
}),
|
||||
)));
|
||||
@@ -502,7 +509,9 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
.backend
|
||||
.notify(
|
||||
app,
|
||||
OverlayEventData::WvrCommand(WvrCommand::KillProcess(signal)),
|
||||
OverlayEventData::WvrCommand(WvrCommand::KillProcess(
|
||||
signal,
|
||||
)),
|
||||
)
|
||||
.log_warn("Could not kill process");
|
||||
}),
|
||||
@@ -741,6 +750,7 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
log::debug!("Registered {action} on {:?} as {id:?}", attribs.widget_id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct ShellButtonMutableState {
|
||||
|
||||
@@ -23,7 +23,10 @@ use crate::{
|
||||
input::HoverResult,
|
||||
task::{OverlayTask, TaskContainer, TaskType},
|
||||
},
|
||||
gui::panel::{GuiPanel, NewGuiPanelParams, OnCustomAttribFunc, button::BUTTON_EVENTS},
|
||||
gui::panel::{
|
||||
GuiPanel, NewGuiPanelParams, OnCustomAttribFunc,
|
||||
button::{BUTTON_EVENT_SUFFIX, BUTTON_EVENTS},
|
||||
},
|
||||
overlays::edit::{
|
||||
lock::InteractLockHandler,
|
||||
mouse::new_mouse_tab_handler,
|
||||
@@ -279,8 +282,10 @@ fn make_edit_panel(app: &mut AppState) -> anyhow::Result<EditModeWrapPanel> {
|
||||
};
|
||||
|
||||
for (name, kind, test_button, test_duration) in &BUTTON_EVENTS {
|
||||
for suffix in BUTTON_EVENT_SUFFIX {
|
||||
let name = &format!("{name}{suffix}");
|
||||
let Some(action) = attribs.get_value(name) else {
|
||||
continue;
|
||||
break;
|
||||
};
|
||||
|
||||
let mut args = action.split_whitespace();
|
||||
@@ -407,6 +412,7 @@ fn make_edit_panel(app: &mut AppState) -> anyhow::Result<EditModeWrapPanel> {
|
||||
let id = layout.add_event_listener(attribs.widget_id, *kind, callback);
|
||||
log::debug!("Registered {action} on {:?} as {id:?}", attribs.widget_id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let mut panel = GuiPanel::new_from_template(
|
||||
|
||||
@@ -32,7 +32,10 @@ use crate::{
|
||||
wayvr::{self, SurfaceBufWithImage, process::KillSignal, window::WindowHandle},
|
||||
},
|
||||
graphics::{ExtentExt, Vert2Uv, upload_quad_vertices},
|
||||
gui::panel::{GuiPanel, NewGuiPanelParams, OnCustomAttribFunc, button::BUTTON_EVENTS},
|
||||
gui::panel::{
|
||||
GuiPanel, NewGuiPanelParams, OnCustomAttribFunc,
|
||||
button::{BUTTON_EVENT_SUFFIX, BUTTON_EVENTS},
|
||||
},
|
||||
overlays::screen::capture::ScreenPipeline,
|
||||
state::{self, AppState},
|
||||
subsystem::{hid::WheelDelta, input::KeyboardFocus},
|
||||
@@ -141,8 +144,10 @@ impl WvrWindowBackend {
|
||||
};
|
||||
|
||||
for (name, kind, test_button, test_duration) in &BUTTON_EVENTS {
|
||||
for suffix in BUTTON_EVENT_SUFFIX {
|
||||
let name = &format!("{name}{suffix}");
|
||||
let Some(action) = attribs.get_value(name) else {
|
||||
continue;
|
||||
break;
|
||||
};
|
||||
|
||||
let mut args = action.split_whitespace();
|
||||
@@ -168,6 +173,7 @@ impl WvrWindowBackend {
|
||||
let id = layout.add_event_listener(attribs.widget_id, *kind, callback);
|
||||
log::debug!("Registered {action} on {:?} as {id:?}", attribs.widget_id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
let mut panel = GuiPanel::new_from_template(
|
||||
|
||||
Reference in New Issue
Block a user