events with user data to also trigger internal listeners + toast fix
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
</template>
|
||||
|
||||
<template name="Set">
|
||||
<Button macro="button_style" _press="::SetToggle ${handle}">
|
||||
<Button macro="button_style" _press="::SetToggle ${handle}" tooltip="Switch to set" tooltip_side="top">
|
||||
<sprite width="40" height="40" color="~set_color" src="watch/set2.svg" />
|
||||
<div position="absolute" margin_top="9">
|
||||
<label text="${display}" size="24" color="#00050F" weight="bold" />
|
||||
@@ -64,13 +64,13 @@
|
||||
</div>
|
||||
</div>
|
||||
<div width="100%" flex_direction="row">
|
||||
<Button macro="button_style" _press="::DashToggle">
|
||||
<Button macro="button_style" _press="::DashToggle" tooltip="Toggle dashboard" tooltip_side="top">
|
||||
<sprite color="~set_color" width="40" height="40" src="watch/home.svg" />
|
||||
</Button>
|
||||
<div id="sets">
|
||||
<!-- Will populate <Set> tags at runtime -->
|
||||
</div>
|
||||
<Button macro="button_style" _press="::EditToggle">
|
||||
<Button macro="button_style" _press="::EditToggle" tooltip="Edit sets" tooltip_side="top">
|
||||
<sprite color="~set_color" width="40" height="40" src="watch/edit.svg" />
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -240,7 +240,9 @@ pub fn openxr_run(
|
||||
continue 'main_loop;
|
||||
}
|
||||
|
||||
log::trace!("xrWaitFrame");
|
||||
let xr_frame_state = frame_wait.wait()?;
|
||||
log::trace!("xrBeginFrame");
|
||||
frame_stream.begin()?;
|
||||
|
||||
xr_state.predicted_display_time = xr_frame_state.predicted_display_time;
|
||||
@@ -263,6 +265,7 @@ pub fn openxr_run(
|
||||
};
|
||||
|
||||
if !xr_frame_state.should_render {
|
||||
log::trace!("xrEndFrame");
|
||||
frame_stream.end(
|
||||
xr_frame_state.predicted_display_time,
|
||||
environment_blend_mode,
|
||||
@@ -478,6 +481,7 @@ pub fn openxr_run(
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
log::trace!("xrEndFrame");
|
||||
frame_stream.end(
|
||||
xr_state.predicted_display_time,
|
||||
environment_blend_mode,
|
||||
|
||||
@@ -258,27 +258,20 @@ impl<S: 'static> OverlayBackend for GuiPanel<S> {
|
||||
}
|
||||
|
||||
fn on_scroll(&mut self, app: &mut AppState, hit: &PointerHit, delta_y: f32, delta_x: f32) {
|
||||
self.layout
|
||||
.push_event(
|
||||
&WguiEvent::MouseWheel(MouseWheelEvent {
|
||||
shift: vec2(delta_x, delta_y),
|
||||
pos: hit.uv * self.layout.content_size,
|
||||
device: hit.pointer,
|
||||
}),
|
||||
app,
|
||||
&mut self.state,
|
||||
)
|
||||
.unwrap(); // want panic
|
||||
let e = WguiEvent::MouseWheel(MouseWheelEvent {
|
||||
shift: vec2(delta_x, delta_y),
|
||||
pos: hit.uv * self.layout.content_size,
|
||||
device: hit.pointer,
|
||||
});
|
||||
self.push_event(app, &e);
|
||||
}
|
||||
|
||||
fn on_hover(&mut self, app: &mut AppState, hit: &PointerHit) -> Option<Haptics> {
|
||||
self.push_event(
|
||||
app,
|
||||
&WguiEvent::MouseMotion(MouseMotionEvent {
|
||||
pos: hit.uv * self.layout.content_size,
|
||||
device: hit.pointer,
|
||||
}),
|
||||
);
|
||||
let e = &WguiEvent::MouseMotion(MouseMotionEvent {
|
||||
pos: hit.uv * self.layout.content_size,
|
||||
device: hit.pointer,
|
||||
});
|
||||
self.push_event(app, &e);
|
||||
|
||||
self.layout
|
||||
.check_toggle_haptics_triggered()
|
||||
@@ -290,10 +283,8 @@ impl<S: 'static> OverlayBackend for GuiPanel<S> {
|
||||
}
|
||||
|
||||
fn on_left(&mut self, app: &mut AppState, pointer: usize) {
|
||||
self.push_event(
|
||||
app,
|
||||
&WguiEvent::MouseLeave(MouseLeaveEvent { device: pointer }),
|
||||
);
|
||||
let e = WguiEvent::MouseLeave(MouseLeaveEvent { device: pointer });
|
||||
self.push_event(app, &e);
|
||||
}
|
||||
|
||||
fn on_pointer(&mut self, app: &mut AppState, hit: &PointerHit, pressed: bool) {
|
||||
@@ -304,25 +295,21 @@ impl<S: 'static> OverlayBackend for GuiPanel<S> {
|
||||
_ => return,
|
||||
};
|
||||
|
||||
if pressed {
|
||||
self.push_event(
|
||||
app,
|
||||
&WguiEvent::MouseDown(MouseDownEvent {
|
||||
pos: hit.uv * self.layout.content_size,
|
||||
index,
|
||||
device: hit.pointer,
|
||||
}),
|
||||
);
|
||||
let e = if pressed {
|
||||
WguiEvent::MouseDown(MouseDownEvent {
|
||||
pos: hit.uv * self.layout.content_size,
|
||||
index,
|
||||
device: hit.pointer,
|
||||
})
|
||||
} else {
|
||||
self.push_event(
|
||||
app,
|
||||
&WguiEvent::MouseUp(MouseUpEvent {
|
||||
pos: hit.uv * self.layout.content_size,
|
||||
index,
|
||||
device: hit.pointer,
|
||||
}),
|
||||
);
|
||||
}
|
||||
WguiEvent::MouseUp(MouseUpEvent {
|
||||
pos: hit.uv * self.layout.content_size,
|
||||
index,
|
||||
device: hit.pointer,
|
||||
})
|
||||
};
|
||||
|
||||
self.push_event(app, &e);
|
||||
}
|
||||
|
||||
fn get_interaction_transform(&mut self) -> Option<Affine2> {
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
pub mod anchor;
|
||||
pub mod bar;
|
||||
pub mod custom;
|
||||
//pub mod edit;
|
||||
pub mod keyboard;
|
||||
#[cfg(feature = "wayland")]
|
||||
pub mod mirror;
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::{
|
||||
time::Instant,
|
||||
};
|
||||
|
||||
use glam::{Affine3A, Quat, Vec3, vec3};
|
||||
use glam::{vec3, Affine3A, Quat, Vec3};
|
||||
use idmap_derive::IntegerId;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use wgui::{
|
||||
@@ -28,8 +28,8 @@ use crate::{
|
||||
gui::panel::GuiPanel,
|
||||
state::{AppState, LeftRight},
|
||||
windowing::{
|
||||
OverlaySelector, Z_ORDER_TOAST,
|
||||
window::{OverlayWindowConfig, OverlayWindowState, Positioning},
|
||||
OverlaySelector, Z_ORDER_TOAST,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -249,6 +249,7 @@ fn new_toast(toast: Toast, app: &mut AppState) -> Option<OverlayWindowConfig> {
|
||||
},
|
||||
global: true,
|
||||
z_order: Z_ORDER_TOAST,
|
||||
show_on_spawn: true,
|
||||
..OverlayWindowConfig::from_backend(Box::new(panel))
|
||||
})
|
||||
}
|
||||
|
||||
@@ -129,14 +129,14 @@ impl OverlayWindowConfig {
|
||||
}
|
||||
|
||||
pub fn activate(&mut self, app: &mut AppState) {
|
||||
log::warn!("activate {}", self.name.as_ref());
|
||||
log::debug!("activate {}", self.name.as_ref());
|
||||
self.dirty = true;
|
||||
self.active_state = Some(self.default_state.clone());
|
||||
self.reset(app, true);
|
||||
}
|
||||
|
||||
pub fn deactivate(&mut self) {
|
||||
log::warn!("deactivate {}", self.name.as_ref());
|
||||
log::debug!("deactivate {}", self.name.as_ref());
|
||||
self.active_state = None;
|
||||
}
|
||||
|
||||
@@ -144,7 +144,7 @@ impl OverlayWindowConfig {
|
||||
if self.active_state.take().is_none() {
|
||||
self.activate(app);
|
||||
} else {
|
||||
log::warn!("deactivate {}", self.name.as_ref());
|
||||
log::debug!("deactivate {}", self.name.as_ref());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user