From 4e770586181c7dc15ecb224163af78c5323a22a4 Mon Sep 17 00:00:00 2001 From: galister <22305755+galister@users.noreply.github.com> Date: Mon, 22 Dec 2025 20:50:00 +0900 Subject: [PATCH] toast translations, empty set warning --- wlx-common/src/overlays.rs | 1 + wlx-overlay-s/src/assets/lang/en.json | 11 ++++++ wlx-overlay-s/src/backend/openxr/playspace.rs | 2 +- wlx-overlay-s/src/gui/panel/button.rs | 19 +++++----- wlx-overlay-s/src/overlays/toast.rs | 37 ++++++++----------- wlx-overlay-s/src/state.rs | 1 + wlx-overlay-s/src/windowing/manager.rs | 31 ++++++++++++++-- 7 files changed, 65 insertions(+), 37 deletions(-) diff --git a/wlx-common/src/overlays.rs b/wlx-common/src/overlays.rs index 150f16b..1b82d44 100644 --- a/wlx-common/src/overlays.rs +++ b/wlx-common/src/overlays.rs @@ -4,6 +4,7 @@ use serde::{Deserialize, Serialize}; #[derive(Debug, Clone, Copy, PartialEq, Eq, IntegerId, Serialize, Deserialize)] pub enum ToastTopic { System, + Error, DesktopNotification, XSNotification, IpdChange, diff --git a/wlx-overlay-s/src/assets/lang/en.json b/wlx-overlay-s/src/assets/lang/en.json index 0bdb704..bf683c8 100644 --- a/wlx-overlay-s/src/assets/lang/en.json +++ b/wlx-overlay-s/src/assets/lang/en.json @@ -58,6 +58,17 @@ "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." }, + "TOAST": { + "DEFAULT_TITLE": "Notification", + "ERROR": "Error", + "CANNOT_REMOVE_SET": "Cannot remove set!", + "NO_SET_SELECTED": "No set is selected.", + "LAST_EXISTING_SET": "This is the last existing set.", + "EMPTY_SET": "Empty set!", + "LETS_ADD_OVERLAYS": "Let's add some overlays from the watch!", + "FIXING_FLOOR": "Fixing floor in 5 seconds...", + "ONE_CONTROLLER_ON_FLOOR": "Place one controller on the floor!" + }, "WATCH": { "ADD_NEW_SET": "Add a new set", "CLEANUP_MIRRORS": "Remove mirrors that are\nnot currently visible", diff --git a/wlx-overlay-s/src/backend/openxr/playspace.rs b/wlx-overlay-s/src/backend/openxr/playspace.rs index 8c0bdaf..1c402ca 100644 --- a/wlx-overlay-s/src/backend/openxr/playspace.rs +++ b/wlx-overlay-s/src/backend/openxr/playspace.rs @@ -238,7 +238,7 @@ impl PlayspaceMover { let y1 = input.pointers[0].raw_pose.translation.y; let y2 = input.pointers[1].raw_pose.translation.y; - let delta = y1.min(y2) - 0.03; + let delta = y1.min(y2) - 0.05; pose.position.y += delta; diff --git a/wlx-overlay-s/src/gui/panel/button.rs b/wlx-overlay-s/src/gui/panel/button.rs index 81f8d1f..578b902 100644 --- a/wlx-overlay-s/src/gui/panel/button.rs +++ b/wlx-overlay-s/src/gui/panel/button.rs @@ -306,16 +306,15 @@ pub(super) fn setup_custom_button( return Ok(EventResult::Pass); } - for i in 0..5 { - Toast::new( - ToastTopic::System, - format!("Fixing floor in {}", 5 - i), - "Touch your controller to the floor!".into(), - ) - .with_timeout(1.) - .with_sound(true) - .submit_at(app, Instant::now() + Duration::from_secs(i)); - } + Toast::new( + ToastTopic::System, + "TOAST.FIXING_FLOOR".into(), + "TOAST.ONE_CONTROLLER_ON_FLOOR".into(), + ) + .with_timeout(5.) + .with_sound(true) + .submit(app); + app.tasks.enqueue_at( TaskType::Playspace(PlayspaceTask::FixFloor), Instant::now() + Duration::from_secs(5), diff --git a/wlx-overlay-s/src/overlays/toast.rs b/wlx-overlay-s/src/overlays/toast.rs index a2bb58f..7ad73a4 100644 --- a/wlx-overlay-s/src/overlays/toast.rs +++ b/wlx-overlay-s/src/overlays/toast.rs @@ -16,7 +16,6 @@ use wlx_common::{ use crate::{ backend::task::{OverlayTask, TaskType}, gui::panel::{GuiPanel, NewGuiPanelParams, OnCustomIdFunc}, - overlays::watch::{WATCH_POS, WATCH_ROT}, state::AppState, windowing::{OverlaySelector, Z_ORDER_TOAST, window::OverlayWindowConfig}, }; @@ -121,35 +120,29 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option { Positioning::FollowHead { lerp: 0.1 }, ), ToastDisplayMethod::Watch => { - //FIXME: properly follow watch - let watch_pos = WATCH_POS + vec3(-0.005, -0.05, 0.02); - let watch_rot = WATCH_ROT; - let relative_to = /*match app.session.config.watch_hand { - LeftRight::Left =>*/ Positioning::FollowHand { - hand: LeftRight::Left, - lerp: 1.0, - align_to_hmd: true, - /* - }, - LeftRight::Right => { - watch_pos.x = -watch_pos.x; - watch_rot = watch_rot * Quat::from_rotation_x(PI) * Quat::from_rotation_z(PI); - Positioning::FollowHand { - hand: LeftRight::Right, - lerp: 1.0, - } - }*/ + let relative_to = Positioning::FollowHand { + hand: LeftRight::Left, + lerp: 0.1, + align_to_hmd: true, }; - (watch_pos, watch_rot, relative_to) + (vec3(0., 0., 0.), Quat::IDENTITY, relative_to) } }; let title = if toast.title.is_empty() { Translation::from_translation_key("TOAST.DEFAULT_TITLE") + } else if matches!(toast.topic, ToastTopic::System | ToastTopic::Error) { + Translation::from_translation_key(&toast.title) } else { Translation::from_raw_text(&toast.title) }; + let body = if matches!(toast.topic, ToastTopic::System) { + Translation::from_translation_key(&toast.body) + } else { + Translation::from_raw_text(&toast.body) + }; + let on_custom_id: OnCustomIdFunc<()> = Box::new(move |id, widget, _doc_params, layout, _parser_state, ()| { if &*id == "toast_title" { @@ -168,7 +161,7 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option { .get_as::(widget) .context("toast.xml: missing element with id: toast_body")?; let mut globals = layout.state.globals.get(); - label.set_text_simple(&mut globals, Translation::from_raw_text(&toast.body)); + label.set_text_simple(&mut globals, body.clone()); } Ok(()) }); @@ -206,7 +199,7 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option { } fn msg_err(app: &mut AppState, message: &str) { - Toast::new(ToastTopic::System, "Error".into(), message.into()) + Toast::new(ToastTopic::Error, "TOAST.ERROR".into(), message.into()) .with_timeout(3.) .submit(app); } diff --git a/wlx-overlay-s/src/state.rs b/wlx-overlay-s/src/state.rs index 072e463..0c083f1 100644 --- a/wlx-overlay-s/src/state.rs +++ b/wlx-overlay-s/src/state.rs @@ -200,6 +200,7 @@ impl AppSession { let mut toast_topics = IdMap::new(); toast_topics.insert(ToastTopic::System, ToastDisplayMethod::Center); + toast_topics.insert(ToastTopic::Error, ToastDisplayMethod::Center); toast_topics.insert(ToastTopic::DesktopNotification, ToastDisplayMethod::Center); toast_topics.insert(ToastTopic::XSNotification, ToastDisplayMethod::Center); diff --git a/wlx-overlay-s/src/windowing/manager.rs b/wlx-overlay-s/src/windowing/manager.rs index 95de2f7..76373ed 100644 --- a/wlx-overlay-s/src/windowing/manager.rs +++ b/wlx-overlay-s/src/windowing/manager.rs @@ -49,6 +49,7 @@ pub struct OverlayWindowManager { watch_id: OverlayID, edit_mode: bool, dropped_overlays: VecDeque>, + initialized: bool, } impl OverlayWindowManager @@ -66,6 +67,7 @@ where watch_id: OverlayID::null(), // set down below edit_mode: false, dropped_overlays: VecDeque::with_capacity(8), + initialized: false, }; let mut wayland = false; @@ -148,6 +150,8 @@ where .notify(app, ev)?; } + me.initialized = true; + Ok(me) } @@ -199,8 +203,8 @@ where let Some(set) = self.current_set else { Toast::new( ToastTopic::System, - "Can't remove set".into(), - "No set is selected!".into(), + "TOAST.CANNOT_REMOVE_SET".into(), + "TOAST.NO_SET_SELECTED".into(), ) .with_timeout(5.) .with_sound(true) @@ -211,8 +215,8 @@ where if self.sets.len() <= 1 { Toast::new( ToastTopic::System, - "Can't remove set".into(), - "This is the last existing set!".into(), + "TOAST.CANNOT_REMOVE_SET".into(), + "TOAST.LAST_EXISTING_SET".into(), ) .with_timeout(5.) .with_sound(true) @@ -658,6 +662,7 @@ impl OverlayWindowManager { return; } + let mut num_overlays = 0; let ws = &mut self.sets[new_set]; for (id, data) in self.overlays.iter_mut().filter(|(_, d)| !d.config.global) { if let Some(state) = ws.overlays.remove(id) { @@ -666,10 +671,28 @@ impl OverlayWindowManager { if !keep_transforms { data.config.reset(app, false); } + if !matches!( + data.config.category, + OverlayCategory::Internal + | OverlayCategory::Keyboard + | OverlayCategory::Dashboard + ) { + num_overlays += 1; + } } } ws.overlays.clear(); self.restore_set = new_set; + + if !self.edit_mode && self.initialized && num_overlays < 1 { + Toast::new( + ToastTopic::System, + "TOAST.EMPTY_SET".into(), + "TOAST.LETS_ADD_OVERLAYS".into(), + ) + .with_timeout(3.) + .submit(app); + } } self.current_set = new_set;