add more help to grab-help

This commit is contained in:
galister
2025-12-21 17:03:40 +09:00
parent 1c6ebc745d
commit a139ab7b15
6 changed files with 121 additions and 14 deletions

View File

@@ -1,9 +1,14 @@
use glam::{Affine3A, Quat, Vec3};
use std::sync::{Arc, LazyLock};
use wgui::event::{EventAlterables, StyleSetRequest};
use wgui::parser::Fetchable;
use wgui::taffy;
use wlx_common::windowing::{OverlayWindowState, Positioning};
use crate::gui::panel::GuiPanel;
use crate::overlays::watch::WATCH_NAME;
use crate::state::AppState;
use crate::windowing::backend::OverlayEventData;
use crate::windowing::window::OverlayWindowConfig;
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())?;
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 {
name: GRAB_HELP_NAME.clone(),
z_order: Z_ORDER_HELP,

View File

@@ -420,6 +420,7 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
}
}
}
_ => {}
}
panel.layout.process_alterables(alterables)?;