add more help to grab-help
This commit is contained in:
@@ -2,23 +2,37 @@
|
|||||||
<elements>
|
<elements>
|
||||||
<div interactable="0">
|
<div interactable="0">
|
||||||
<rectangle
|
<rectangle
|
||||||
max_width="500"
|
max_width="600"
|
||||||
padding="16"
|
padding="16"
|
||||||
flex_direction="column"
|
flex_direction="column"
|
||||||
gap="8"
|
gap="8"
|
||||||
color="#000000c0" border_color="~color_accent" border="2" round="8">
|
color="#000000c0" border_color="~color_accent" border="2" round="8">
|
||||||
|
|
||||||
<div flex_direction="row" align_items="center" gap="8">
|
<div flex_direction="row" padding="8" justify_content="space_between">
|
||||||
<sprite src="grab-help/controller-grip-joy.svg" min_width="128" min_height="128" max_width="128" max_height="128" flex_grow="1" />
|
<div flex_direction="column" align_items="center" gap="8" max_width="160" min_width="160">
|
||||||
<label wrap="1" size="25" padding_left="16" padding_right="16" translation="GRAB.ADJUST_DISTANCE" />
|
<sprite src="grab-help/controller-grip-joy.svg" min_width="128" min_height="128" max_width="128" max_height="128" flex_grow="1" />
|
||||||
|
<label wrap="1" size="25" padding_left="16" padding_right="16" translation="GRAB.ADJUST_DISTANCE" align="center" />
|
||||||
|
</div>
|
||||||
|
<div flex_direction="column" align_items="center" gap="8" max_width="160" min_width="160">
|
||||||
|
<sprite src="grab-help/controller-grip-trigger-joy.svg" min_width="128" min_height="128" max_width="128" max_height="128" flex_grow="1" />
|
||||||
|
<label wrap="1" size="25" padding_left="16" padding_right="16" translation="GRAB.ADJUST_SIZE" align="center" />
|
||||||
|
</div>
|
||||||
|
<div flex_direction="column" align_items="center" gap="8" max_width="160" min_width="160">
|
||||||
|
<sprite src="grab-help/controller-grip-b.svg" min_width="128" min_height="128" max_width="128" max_height="128" flex_grow="1" />
|
||||||
|
<label wrap="1" size="25" padding_left="16" padding_right="16" translation="GRAB.UNRESTRICTED_MOVEMENT" align="center" />
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div flex_direction="row" align_items="center" gap="8">
|
|
||||||
<sprite src="grab-help/controller-grip-trigger-joy.svg" min_width="128" min_height="128" max_width="128" max_height="128" flex_grow="1" />
|
<!-- A simple separator -->
|
||||||
<label wrap="1" size="25" padding_left="16" padding_right="16" translation="GRAB.ADJUST_SIZE" />
|
<rectangle width="100%" height="2" color="~color_accent" />
|
||||||
</div>
|
|
||||||
<div flex_direction="row" align_items="center" gap="8">
|
<div align_items="center" padding="8" >
|
||||||
<sprite src="grab-help/controller-grip-b.svg" min_width="128" min_height="128" max_width="128" max_height="128" flex_grow="1" />
|
<label display="none" id="grabbing_watch" wrap="1" size="20" padding_right="16" translation="GRAB.GRABBING_WATCH" />
|
||||||
<label wrap="1" size="25" padding_left="16" padding_right="16" translation="GRAB.UNRESTRICTED_MOVEMENT" />
|
<label display="none" id="grabbing_static" wrap="1" size="20" padding_left="16" padding_right="16" translation="GRAB.GRABBING_STATIC" />
|
||||||
|
<label display="none" id="grabbing_anchored" wrap="1" size="20" padding_left="16" padding_right="16" translation="GRAB.GRABBING_ANCHORED" />
|
||||||
|
<label display="none" id="grabbing_anchored_edit" wrap="1" size="20" padding_left="16" padding_right="16" translation="GRAB.GRABBING_ANCHORED_EDIT" />
|
||||||
|
<label display="none" id="grabbing_floating" wrap="1" size="20" padding_left="16" padding_right="16" translation="GRAB.GRABBING_FLOATING" />
|
||||||
|
<label display="none" id="grabbing_follow" wrap="1" size="20" padding_left="16" padding_right="16" translation="GRAB.GRABBING_FOLLOW" />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</rectangle>
|
</rectangle>
|
||||||
|
|||||||
@@ -49,7 +49,13 @@
|
|||||||
"GRAB": {
|
"GRAB": {
|
||||||
"ADJUST_DISTANCE": "Adjust distance",
|
"ADJUST_DISTANCE": "Adjust distance",
|
||||||
"ADJUST_SIZE": "Adjust size",
|
"ADJUST_SIZE": "Adjust size",
|
||||||
"UNRESTRICTED_MOVEMENT": "Unrestricted movement"
|
"UNRESTRICTED_MOVEMENT": "Unrestricted movement",
|
||||||
|
"GRABBING_WATCH": "To swap hands, move the watch in front and grab it with the other hand.",
|
||||||
|
"GRABBING_STATIC": "This overlay is Static and will stay in place, ignoring recenter.",
|
||||||
|
"GRABBING_ANCHORED": "Anchored overlays all move together. Separate a single window by grabbing it with the other hand while still grabbing the anchor.",
|
||||||
|
"GRABBING_ANCHORED_EDIT": "This overlay will stay anchored to the center marker.",
|
||||||
|
"GRABBING_FLOATING": "This overlay is Floating and will stay in place, unless recentered.",
|
||||||
|
"GRABBING_FOLLOW": "This overlay will follow the device it is attached to."
|
||||||
},
|
},
|
||||||
"WATCH": {
|
"WATCH": {
|
||||||
"ADD_NEW_SET": "Add a new set",
|
"ADD_NEW_SET": "Add a new set",
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
use std::process::{Child, Command};
|
use std::process::{Child, Command};
|
||||||
|
use std::sync::Arc;
|
||||||
use std::time::Instant;
|
use std::time::Instant;
|
||||||
|
|
||||||
use glam::{Affine3A, Vec2, Vec3A, Vec3Swizzles};
|
use glam::{Affine3A, Vec2, Vec3A, Vec3Swizzles};
|
||||||
@@ -15,6 +16,7 @@ use crate::overlays::watch::WATCH_NAME;
|
|||||||
use crate::state::{AppSession, AppState};
|
use crate::state::{AppSession, AppState};
|
||||||
use crate::subsystem::hid::WheelDelta;
|
use crate::subsystem::hid::WheelDelta;
|
||||||
use crate::subsystem::input::KeyboardFocus;
|
use crate::subsystem::input::KeyboardFocus;
|
||||||
|
use crate::windowing::backend::OverlayEventData;
|
||||||
use crate::windowing::manager::OverlayWindowManager;
|
use crate::windowing::manager::OverlayWindowManager;
|
||||||
use crate::windowing::window::{self, OverlayWindowData, realign};
|
use crate::windowing::window::{self, OverlayWindowData, realign};
|
||||||
use crate::windowing::{OverlayID, OverlaySelector};
|
use crate::windowing::{OverlayID, OverlaySelector};
|
||||||
@@ -403,7 +405,15 @@ where
|
|||||||
&mut app.hid_provider.keyboard_focus,
|
&mut app.hid_provider.keyboard_focus,
|
||||||
hovered.config.keyboard_focus,
|
hovered.config.keyboard_focus,
|
||||||
);
|
);
|
||||||
start_grab(idx, hit.overlay, hovered_state, app, edit_mode);
|
start_grab(
|
||||||
|
idx,
|
||||||
|
hit.overlay,
|
||||||
|
hovered.config.name.clone(),
|
||||||
|
hovered.config.editing,
|
||||||
|
hovered_state,
|
||||||
|
app,
|
||||||
|
edit_mode,
|
||||||
|
);
|
||||||
log::debug!("Hand {}: grabbed {}", hit.pointer, hovered.config.name);
|
log::debug!("Hand {}: grabbed {}", hit.pointer, hovered.config.name);
|
||||||
return (
|
return (
|
||||||
hit.dist,
|
hit.dist,
|
||||||
@@ -606,6 +616,8 @@ where
|
|||||||
fn start_grab(
|
fn start_grab(
|
||||||
idx: usize,
|
idx: usize,
|
||||||
id: OverlayID,
|
id: OverlayID,
|
||||||
|
name: Arc<str>,
|
||||||
|
editing: bool,
|
||||||
state: &mut OverlayWindowState,
|
state: &mut OverlayWindowState,
|
||||||
app: &mut AppState,
|
app: &mut AppState,
|
||||||
edit_mode: bool,
|
edit_mode: bool,
|
||||||
@@ -644,9 +656,15 @@ fn start_grab(
|
|||||||
)));
|
)));
|
||||||
|
|
||||||
if let Some(hand) = pointer.hand().clone() {
|
if let Some(hand) = pointer.hand().clone() {
|
||||||
|
let pos = state.positioning;
|
||||||
app.tasks.enqueue(TaskType::Overlay(OverlayTask::Modify(
|
app.tasks.enqueue(TaskType::Overlay(OverlayTask::Modify(
|
||||||
OverlaySelector::Name(GRAB_HELP_NAME.clone()),
|
OverlaySelector::Name(GRAB_HELP_NAME.clone()),
|
||||||
Box::new(move |app, o| {
|
Box::new(move |app, o| {
|
||||||
|
let _ = o
|
||||||
|
.backend
|
||||||
|
.notify(app, OverlayEventData::OverlayGrabbed { name, pos, editing })
|
||||||
|
.inspect_err(|e| log::warn!("Error during Notify OverlayGrabbed: {e:?}"));
|
||||||
|
|
||||||
o.default_state.positioning = Positioning::FollowHand {
|
o.default_state.positioning = Positioning::FollowHand {
|
||||||
hand,
|
hand,
|
||||||
lerp: 0.1,
|
lerp: 0.1,
|
||||||
|
|||||||
@@ -1,9 +1,14 @@
|
|||||||
use glam::{Affine3A, Quat, Vec3};
|
use glam::{Affine3A, Quat, Vec3};
|
||||||
use std::sync::{Arc, LazyLock};
|
use std::sync::{Arc, LazyLock};
|
||||||
|
use wgui::event::{EventAlterables, StyleSetRequest};
|
||||||
|
use wgui::parser::Fetchable;
|
||||||
|
use wgui::taffy;
|
||||||
use wlx_common::windowing::{OverlayWindowState, Positioning};
|
use wlx_common::windowing::{OverlayWindowState, Positioning};
|
||||||
|
|
||||||
use crate::gui::panel::GuiPanel;
|
use crate::gui::panel::GuiPanel;
|
||||||
|
use crate::overlays::watch::WATCH_NAME;
|
||||||
use crate::state::AppState;
|
use crate::state::AppState;
|
||||||
|
use crate::windowing::backend::OverlayEventData;
|
||||||
use crate::windowing::window::OverlayWindowConfig;
|
use crate::windowing::window::OverlayWindowConfig;
|
||||||
use crate::windowing::{Z_ORDER_ANCHOR, Z_ORDER_HELP};
|
use crate::windowing::{Z_ORDER_ANCHOR, Z_ORDER_HELP};
|
||||||
|
|
||||||
@@ -38,6 +43,61 @@ pub fn create_grab_help(app: &mut AppState) -> anyhow::Result<OverlayWindowConfi
|
|||||||
let mut panel = GuiPanel::new_from_template(app, "gui/grab-help.xml", (), Default::default())?;
|
let mut panel = GuiPanel::new_from_template(app, "gui/grab-help.xml", (), Default::default())?;
|
||||||
panel.update_layout()?;
|
panel.update_layout()?;
|
||||||
|
|
||||||
|
let id_watch = panel.parser_state.data.get_widget_id("grabbing_watch")?;
|
||||||
|
let id_static = panel.parser_state.data.get_widget_id("grabbing_static")?;
|
||||||
|
let id_anchored = panel.parser_state.data.get_widget_id("grabbing_anchored")?;
|
||||||
|
let id_anchored_edit = panel
|
||||||
|
.parser_state
|
||||||
|
.data
|
||||||
|
.get_widget_id("grabbing_anchored_edit")?;
|
||||||
|
let id_floating = panel.parser_state.data.get_widget_id("grabbing_floating")?;
|
||||||
|
let id_follow = panel.parser_state.data.get_widget_id("grabbing_follow")?;
|
||||||
|
|
||||||
|
let all = [
|
||||||
|
id_watch,
|
||||||
|
id_static,
|
||||||
|
id_anchored,
|
||||||
|
id_anchored_edit,
|
||||||
|
id_floating,
|
||||||
|
id_follow,
|
||||||
|
];
|
||||||
|
|
||||||
|
panel.on_notify = Some(Box::new(move |panel, _app, event_data| {
|
||||||
|
let mut alterables = EventAlterables::default();
|
||||||
|
|
||||||
|
let OverlayEventData::OverlayGrabbed { name, pos, editing } = event_data else {
|
||||||
|
return Ok(());
|
||||||
|
};
|
||||||
|
|
||||||
|
let show_id = match pos {
|
||||||
|
Positioning::Static => id_static,
|
||||||
|
Positioning::Floating => id_floating,
|
||||||
|
Positioning::Anchored => {
|
||||||
|
if editing {
|
||||||
|
id_anchored_edit
|
||||||
|
} else {
|
||||||
|
id_anchored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Positioning::FollowHand { .. } if &*name == WATCH_NAME => id_watch,
|
||||||
|
Positioning::FollowHead { .. } | Positioning::FollowHand { .. } => id_follow,
|
||||||
|
};
|
||||||
|
|
||||||
|
for id in &all {
|
||||||
|
let display = if *id == show_id {
|
||||||
|
taffy::Display::Flex
|
||||||
|
} else {
|
||||||
|
taffy::Display::None
|
||||||
|
};
|
||||||
|
|
||||||
|
alterables.set_style(*id, StyleSetRequest::Display(display));
|
||||||
|
}
|
||||||
|
|
||||||
|
panel.layout.process_alterables(alterables)?;
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}));
|
||||||
|
|
||||||
Ok(OverlayWindowConfig {
|
Ok(OverlayWindowConfig {
|
||||||
name: GRAB_HELP_NAME.clone(),
|
name: GRAB_HELP_NAME.clone(),
|
||||||
z_order: Z_ORDER_HELP,
|
z_order: Z_ORDER_HELP,
|
||||||
|
|||||||
@@ -420,6 +420,7 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
_ => {}
|
||||||
}
|
}
|
||||||
|
|
||||||
panel.layout.process_alterables(alterables)?;
|
panel.layout.process_alterables(alterables)?;
|
||||||
|
|||||||
@@ -6,7 +6,10 @@ use wgui::gfx::{
|
|||||||
WGfx,
|
WGfx,
|
||||||
cmd::{GfxCommandBuffer, WGfxClearMode},
|
cmd::{GfxCommandBuffer, WGfxClearMode},
|
||||||
};
|
};
|
||||||
use wlx_common::overlays::{BackendAttrib, BackendAttribValue};
|
use wlx_common::{
|
||||||
|
overlays::{BackendAttrib, BackendAttribValue},
|
||||||
|
windowing::Positioning,
|
||||||
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
backend::input::{HoverResult, PointerHit},
|
backend::input::{HoverResult, PointerHit},
|
||||||
@@ -112,6 +115,11 @@ pub enum OverlayEventData {
|
|||||||
EditModeChanged(bool),
|
EditModeChanged(bool),
|
||||||
OverlaysChanged(Vec<OverlayMeta>),
|
OverlaysChanged(Vec<OverlayMeta>),
|
||||||
DevicesChanged,
|
DevicesChanged,
|
||||||
|
OverlayGrabbed {
|
||||||
|
name: Arc<str>,
|
||||||
|
pos: Positioning,
|
||||||
|
editing: bool,
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait OverlayBackend: Any {
|
pub trait OverlayBackend: Any {
|
||||||
|
|||||||
Reference in New Issue
Block a user