fix: watch notifications
This commit is contained in:
@@ -66,12 +66,7 @@ fn def_auto() -> Arc<str> {
|
||||
}
|
||||
|
||||
fn def_toast_topics() -> IdMap<ToastTopic, DisplayMethod> {
|
||||
let mut map = IdMap::new();
|
||||
map.insert(ToastTopic::System, DisplayMethod::Center);
|
||||
map.insert(ToastTopic::DesktopNotification, DisplayMethod::Center);
|
||||
map.insert(ToastTopic::XSNotification, DisplayMethod::Center);
|
||||
map.insert(ToastTopic::IpdChange, DisplayMethod::Hide);
|
||||
map
|
||||
IdMap::new()
|
||||
}
|
||||
|
||||
#[derive(Deserialize, Serialize)]
|
||||
@@ -94,6 +89,9 @@ pub struct GeneralConfig {
|
||||
#[serde(default = "def_true")]
|
||||
pub notifications_sound_enabled: bool,
|
||||
|
||||
#[serde(default = "def_toast_topics")]
|
||||
pub notification_topics: IdMap<ToastTopic, DisplayMethod>,
|
||||
|
||||
#[serde(default = "def_true")]
|
||||
pub keyboard_sound_enabled: bool,
|
||||
|
||||
@@ -115,9 +113,6 @@ pub struct GeneralConfig {
|
||||
#[serde(default = "def_pw_tokens")]
|
||||
pub pw_tokens: Vec<(String, String)>,
|
||||
|
||||
#[serde(default = "def_toast_topics")]
|
||||
pub toast_topics: IdMap<ToastTopic, DisplayMethod>,
|
||||
|
||||
#[serde(default = "def_osc_port")]
|
||||
pub osc_out_port: u16,
|
||||
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
use std::{
|
||||
f32::consts::PI,
|
||||
ops::Add,
|
||||
sync::{atomic::AtomicUsize, Arc},
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
use glam::{vec3a, Vec3A};
|
||||
use glam::{vec3a, Quat, Vec3A};
|
||||
use idmap_derive::IntegerId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
@@ -108,22 +109,27 @@ fn new_toast(
|
||||
) -> Option<(OverlayState, Box<dyn OverlayBackend>)> {
|
||||
let current_method = app
|
||||
.session
|
||||
.config
|
||||
.toast_topics
|
||||
.get(toast.topic)
|
||||
.copied()
|
||||
.unwrap_or(DisplayMethod::Hide);
|
||||
|
||||
let (spawn_point, relative_to) = match current_method {
|
||||
let (spawn_point, spawn_rotation, relative_to) = match current_method {
|
||||
DisplayMethod::Hide => return None,
|
||||
DisplayMethod::Center => (vec3a(0., -2.0, -0.5), RelativeTo::Head),
|
||||
DisplayMethod::Center => (vec3a(0., -0.2, -0.5), Quat::IDENTITY, RelativeTo::Head),
|
||||
DisplayMethod::Watch => {
|
||||
let mut watch_pos =
|
||||
Vec3A::from_slice(&app.session.config.watch_pos) + vec3a(-0.005, -0.05, 0.02);
|
||||
let mut watch_rot = Quat::from_slice(&app.session.config.watch_rot);
|
||||
let relative_to = match app.session.config.watch_hand {
|
||||
LeftRight::Left => RelativeTo::Hand(0),
|
||||
LeftRight::Right => RelativeTo::Hand(1),
|
||||
LeftRight::Right => {
|
||||
watch_pos.x = -watch_pos.x;
|
||||
watch_rot = watch_rot * Quat::from_rotation_x(PI) * Quat::from_rotation_z(PI);
|
||||
RelativeTo::Hand(1)
|
||||
}
|
||||
};
|
||||
let watch_pos = Vec3A::from_slice(&app.session.config.watch_pos);
|
||||
(watch_pos + Vec3A::Y * 0.05, relative_to)
|
||||
(watch_pos, watch_rot, relative_to)
|
||||
}
|
||||
};
|
||||
|
||||
@@ -183,6 +189,7 @@ fn new_toast(
|
||||
name,
|
||||
want_visible: true,
|
||||
spawn_scale: size.0 * PIXELS_TO_METERS,
|
||||
spawn_rotation,
|
||||
spawn_point,
|
||||
relative_to,
|
||||
..Default::default()
|
||||
|
||||
@@ -528,7 +528,7 @@ elements:
|
||||
rect: [330, 505, 220, 30]
|
||||
font_size: 12
|
||||
fg_color: "#ffffff"
|
||||
bg_color: "#606020"
|
||||
bg_color: "#303010"
|
||||
text: "Enabled"
|
||||
click_down:
|
||||
- type: System
|
||||
@@ -539,7 +539,7 @@ elements:
|
||||
rect: [330, 555, 220, 30]
|
||||
font_size: 12
|
||||
fg_color: "#ffffff"
|
||||
bg_color: "#606020"
|
||||
bg_color: "#303010"
|
||||
text: "Sound Enabled"
|
||||
click_down:
|
||||
- type: System
|
||||
|
||||
14
src/state.rs
14
src/state.rs
@@ -2,6 +2,7 @@ use std::{io::Cursor, path::PathBuf, sync::Arc};
|
||||
|
||||
use anyhow::bail;
|
||||
use glam::Vec3;
|
||||
use idmap::IdMap;
|
||||
use rodio::{Decoder, OutputStream, OutputStreamHandle, Source};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use smallvec::{smallvec, SmallVec};
|
||||
@@ -14,6 +15,7 @@ use crate::{
|
||||
graphics::WlxGraphics,
|
||||
gui::font::FontCache,
|
||||
hid::HidProvider,
|
||||
overlays::toast::{DisplayMethod, ToastTopic},
|
||||
shaders::{frag_color, frag_glyph, frag_screen, frag_sprite, frag_srgb, vert_common},
|
||||
};
|
||||
|
||||
@@ -74,6 +76,8 @@ pub struct AppSession {
|
||||
pub config_root_path: PathBuf,
|
||||
pub config: GeneralConfig,
|
||||
|
||||
pub toast_topics: IdMap<ToastTopic, DisplayMethod>,
|
||||
|
||||
pub color_norm: Vec3,
|
||||
pub color_shift: Vec3,
|
||||
pub color_alt: Vec3,
|
||||
@@ -86,9 +90,19 @@ impl AppSession {
|
||||
log::info!("Config root path: {}", config_root_path.to_string_lossy());
|
||||
let config = GeneralConfig::load_from_disk();
|
||||
|
||||
let mut toast_topics = IdMap::new();
|
||||
toast_topics.insert(ToastTopic::System, DisplayMethod::Center);
|
||||
toast_topics.insert(ToastTopic::DesktopNotification, DisplayMethod::Center);
|
||||
toast_topics.insert(ToastTopic::XSNotification, DisplayMethod::Center);
|
||||
|
||||
config.notification_topics.iter().for_each(|(k, v)| {
|
||||
toast_topics.insert(*k, *v);
|
||||
});
|
||||
|
||||
AppSession {
|
||||
config_root_path,
|
||||
config,
|
||||
toast_topics,
|
||||
color_norm: Vec3 {
|
||||
x: 0.,
|
||||
y: 1.,
|
||||
|
||||
Reference in New Issue
Block a user