watch controls for edit mode
This commit is contained in:
@@ -2,6 +2,7 @@ use std::{
|
||||
cell::RefCell,
|
||||
io::BufReader,
|
||||
process::{Child, ChildStdout},
|
||||
sync::Arc,
|
||||
};
|
||||
|
||||
use wgui::{
|
||||
@@ -11,7 +12,7 @@ use wgui::{
|
||||
widget::EventResult,
|
||||
};
|
||||
|
||||
use crate::state::AppState;
|
||||
use crate::{backend::task::ManagerTask, state::AppState, windowing::OverlaySelector};
|
||||
|
||||
#[cfg(feature = "wayvr")]
|
||||
use crate::backend::{task::TaskType, wayvr::WayVRAction};
|
||||
@@ -48,21 +49,42 @@ pub(super) fn setup_custom_button<S: 'static>(
|
||||
"::SetToggle" => {
|
||||
let arg = args.next().unwrap_or_default();
|
||||
let Ok(set_idx) = arg.parse() else {
|
||||
log::error!("::SetToggle has invalid argument: \"{arg}\"");
|
||||
log::error!("{command} has invalid argument: \"{arg}\"");
|
||||
return;
|
||||
};
|
||||
Box::new(move |_common, _data, app, _| {
|
||||
app.tasks.enqueue(TaskType::ToggleSet(set_idx));
|
||||
app.tasks
|
||||
.enqueue(TaskType::Manager(ManagerTask::ToggleSet(set_idx)));
|
||||
Ok(EventResult::Consumed)
|
||||
})
|
||||
}
|
||||
"::OverlayToggle" => {
|
||||
let Some(arg): Option<Arc<str>> = args.next().map(|a| a.into()) else {
|
||||
log::error!("{command} has missing arguments");
|
||||
return;
|
||||
};
|
||||
|
||||
Box::new(move |_common, _data, app, _| {
|
||||
app.tasks.enqueue(TaskType::Overlay(
|
||||
OverlaySelector::Name(arg.clone()),
|
||||
Box::new(move |app, owc| {
|
||||
if owc.active_state.is_none() {
|
||||
owc.activate(app);
|
||||
} else {
|
||||
owc.deactivate();
|
||||
}
|
||||
}),
|
||||
));
|
||||
Ok(EventResult::Consumed)
|
||||
})
|
||||
}
|
||||
"::WatchHide" => todo!(),
|
||||
"::WatchSwapHand" => todo!(),
|
||||
// TODO
|
||||
"::EditToggle" => Box::new(move |_common, _data, app, _| {
|
||||
app.tasks.enqueue(TaskType::ToggleEditMode);
|
||||
app.tasks
|
||||
.enqueue(TaskType::Manager(ManagerTask::ToggleEditMode));
|
||||
Ok(EventResult::Consumed)
|
||||
}),
|
||||
"::WatchHide" => todo!(),
|
||||
"::WatchSwapHand" => todo!(),
|
||||
// TODO
|
||||
#[allow(clippy::match_same_arms)]
|
||||
"::OscSend" => return,
|
||||
|
||||
@@ -7,7 +7,7 @@ use wgui::{
|
||||
assets::AssetPath,
|
||||
drawing,
|
||||
event::{
|
||||
Event as WguiEvent, EventCallback, EventListenerID, EventListenerKind,
|
||||
Event as WguiEvent, EventAlterables, EventCallback, EventListenerID, EventListenerKind,
|
||||
InternalStateChangeEvent, MouseButtonIndex, MouseDownEvent, MouseLeaveEvent,
|
||||
MouseMotionEvent, MouseUpEvent, MouseWheelEvent,
|
||||
},
|
||||
@@ -15,6 +15,7 @@ use wgui::{
|
||||
layout::{Layout, LayoutParams, WidgetID},
|
||||
parser::{CustomAttribsInfoOwned, ParserState},
|
||||
renderer_vk::context::Context as WguiContext,
|
||||
taffy,
|
||||
widget::{label::WidgetLabel, rectangle::WidgetRectangle, EventResult},
|
||||
};
|
||||
|
||||
@@ -220,6 +221,22 @@ impl<S: 'static> GuiPanel<S> {
|
||||
) -> Option<EventListenerID> {
|
||||
self.layout.add_event_listener(widget_id, kind, callback)
|
||||
}
|
||||
|
||||
pub fn widget_set_display(
|
||||
&self,
|
||||
widget_id: WidgetID,
|
||||
display: taffy::Display,
|
||||
alterables: &mut EventAlterables,
|
||||
) {
|
||||
let mut style = self
|
||||
.layout
|
||||
.state
|
||||
.get_widget_style(widget_id)
|
||||
.unwrap_or(&taffy::Style::DEFAULT)
|
||||
.clone();
|
||||
style.display = display;
|
||||
alterables.set_style(widget_id, style);
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: 'static> OverlayBackend for GuiPanel<S> {
|
||||
|
||||
Reference in New Issue
Block a user