watch: highlight current set
This commit is contained in:
@@ -26,7 +26,7 @@ use crate::{
|
||||
state::AppState,
|
||||
subsystem::hid::WheelDelta,
|
||||
windowing::{
|
||||
backend::{DummyBackend, OverlayBackend, RenderResources, ShouldRender},
|
||||
backend::{DummyBackend, OverlayBackend, OverlayEventData, RenderResources, ShouldRender},
|
||||
window::OverlayWindowConfig,
|
||||
OverlayID,
|
||||
},
|
||||
@@ -204,6 +204,9 @@ impl OverlayBackend for EditModeBackendWrapper {
|
||||
) {
|
||||
self.panel.on_scroll(app, hit, delta);
|
||||
}
|
||||
fn notify(&mut self, app: &mut AppState, event_data: OverlayEventData) -> anyhow::Result<()> {
|
||||
self.panel.notify(app, event_data)
|
||||
}
|
||||
fn get_interaction_transform(&mut self) -> Option<glam::Affine2> {
|
||||
self.inner.get_interaction_transform()
|
||||
}
|
||||
|
||||
@@ -12,8 +12,10 @@ use crate::{
|
||||
backend::input::{HoverResult, PointerHit},
|
||||
gui::panel::GuiPanel,
|
||||
state::AppState,
|
||||
subsystem::hid::{ALT, CTRL, KeyModifier, META, SHIFT, SUPER, VirtualKey, WheelDelta},
|
||||
windowing::backend::{FrameMeta, OverlayBackend, RenderResources, ShouldRender},
|
||||
subsystem::hid::{KeyModifier, VirtualKey, WheelDelta, ALT, CTRL, META, SHIFT, SUPER},
|
||||
windowing::backend::{
|
||||
FrameMeta, OverlayBackend, OverlayEventData, RenderResources, ShouldRender,
|
||||
},
|
||||
};
|
||||
|
||||
pub mod builder;
|
||||
@@ -53,6 +55,10 @@ impl OverlayBackend for KeyboardBackend {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn notify(&mut self, app: &mut AppState, event_data: OverlayEventData) -> anyhow::Result<()> {
|
||||
self.panel.notify(app, event_data)
|
||||
}
|
||||
|
||||
fn on_pointer(&mut self, app: &mut AppState, hit: &PointerHit, pressed: bool) {
|
||||
self.panel.on_pointer(app, hit, pressed);
|
||||
self.panel.push_event(
|
||||
|
||||
@@ -15,7 +15,10 @@ use crate::{
|
||||
state::{AppSession, AppState},
|
||||
subsystem::hid::WheelDelta,
|
||||
windowing::{
|
||||
backend::{ui_transform, FrameMeta, OverlayBackend, RenderResources, ShouldRender},
|
||||
backend::{
|
||||
ui_transform, FrameMeta, OverlayBackend, OverlayEventData, RenderResources,
|
||||
ShouldRender,
|
||||
},
|
||||
window::{OverlayWindowConfig, OverlayWindowState},
|
||||
OverlaySelector,
|
||||
},
|
||||
@@ -124,6 +127,13 @@ impl OverlayBackend for MirrorBackend {
|
||||
self.renderer.as_mut().and_then(ScreenBackend::frame_meta)
|
||||
}
|
||||
|
||||
fn notify(&mut self, app: &mut AppState, event_data: OverlayEventData) -> anyhow::Result<()> {
|
||||
let Some(renderer) = self.renderer.as_mut() else {
|
||||
return Ok(());
|
||||
};
|
||||
renderer.notify(app, event_data)
|
||||
}
|
||||
|
||||
fn on_hover(&mut self, _: &mut AppState, _: &PointerHit) -> HoverResult {
|
||||
HoverResult {
|
||||
consume: true,
|
||||
|
||||
@@ -11,7 +11,9 @@ use crate::{
|
||||
graphics::ExtentExt,
|
||||
state::AppState,
|
||||
subsystem::hid::{WheelDelta, MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT},
|
||||
windowing::backend::{FrameMeta, OverlayBackend, RenderResources, ShouldRender},
|
||||
windowing::backend::{
|
||||
FrameMeta, OverlayBackend, OverlayEventData, RenderResources, ShouldRender,
|
||||
},
|
||||
};
|
||||
|
||||
use super::capture::{receive_callback, ScreenPipeline, WlxCaptureIn, WlxCaptureOut};
|
||||
@@ -199,6 +201,10 @@ impl OverlayBackend for ScreenBackend {
|
||||
self.meta
|
||||
}
|
||||
|
||||
fn notify(&mut self, _app: &mut AppState, _event_data: OverlayEventData) -> anyhow::Result<()> {
|
||||
todo!();
|
||||
}
|
||||
|
||||
fn on_hover(&mut self, app: &mut AppState, hit: &PointerHit) -> HoverResult {
|
||||
#[cfg(debug_assertions)]
|
||||
log::trace!("Hover: {:?}", hit.uv);
|
||||
|
||||
@@ -1,6 +1,11 @@
|
||||
use std::{collections::HashMap, rc::Rc, time::Duration};
|
||||
|
||||
use glam::{Affine3A, Vec3, Vec3A};
|
||||
use wgui::{
|
||||
components::button::ComponentButton,
|
||||
event::{CallbackDataCommon, EventAlterables},
|
||||
parser::Fetchable,
|
||||
};
|
||||
|
||||
use crate::{
|
||||
gui::{
|
||||
@@ -9,6 +14,7 @@ use crate::{
|
||||
},
|
||||
state::AppState,
|
||||
windowing::{
|
||||
backend::OverlayEventData,
|
||||
window::{OverlayWindowConfig, OverlayWindowData, OverlayWindowState, Positioning},
|
||||
Z_ORDER_WATCH,
|
||||
},
|
||||
@@ -16,18 +22,22 @@ use crate::{
|
||||
|
||||
pub const WATCH_NAME: &str = "watch";
|
||||
|
||||
struct WatchState {}
|
||||
#[derive(Default)]
|
||||
struct WatchState {
|
||||
current_set: Option<usize>,
|
||||
set_buttons: Vec<Rc<ComponentButton>>,
|
||||
}
|
||||
|
||||
#[allow(clippy::significant_drop_tightening)]
|
||||
pub fn create_watch(app: &mut AppState, num_sets: usize) -> anyhow::Result<OverlayWindowConfig> {
|
||||
let state = WatchState {};
|
||||
let state = WatchState::default();
|
||||
let mut panel = GuiPanel::new_from_template(
|
||||
app,
|
||||
"gui/watch.xml",
|
||||
state,
|
||||
NewGuiPanelParams {
|
||||
on_custom_id: Some(Box::new(
|
||||
move |id, widget, doc_params, layout, parser_state| {
|
||||
move |id, widget, doc_params, layout, parser_state, state| {
|
||||
if &*id != "sets" {
|
||||
return Ok(());
|
||||
}
|
||||
@@ -38,6 +48,11 @@ pub fn create_watch(app: &mut AppState, num_sets: usize) -> anyhow::Result<Overl
|
||||
params.insert("handle".into(), idx.to_string().into());
|
||||
parser_state
|
||||
.instantiate_template(doc_params, "Set", layout, widget, params)?;
|
||||
|
||||
let button_id = format!("set_{idx}");
|
||||
let component =
|
||||
parser_state.fetch_component_as::<ComponentButton>(&button_id)?;
|
||||
state.set_buttons.push(component);
|
||||
}
|
||||
Ok(())
|
||||
},
|
||||
@@ -46,6 +61,27 @@ pub fn create_watch(app: &mut AppState, num_sets: usize) -> anyhow::Result<Overl
|
||||
},
|
||||
)?;
|
||||
|
||||
panel.on_notify = Some(Box::new(|panel, _app, event_data| {
|
||||
match event_data {
|
||||
OverlayEventData::SetChanged(current_set) => {
|
||||
let mut alterables = EventAlterables::default();
|
||||
let mut common = CallbackDataCommon {
|
||||
alterables: &mut alterables,
|
||||
state: &panel.layout.state,
|
||||
};
|
||||
if let Some(old_set) = panel.state.current_set.take() {
|
||||
panel.state.set_buttons[old_set].set_sticky_state(&mut common, false);
|
||||
}
|
||||
if let Some(new_set) = current_set {
|
||||
panel.state.set_buttons[new_set].set_sticky_state(&mut common, true);
|
||||
}
|
||||
panel.state.current_set = current_set;
|
||||
panel.layout.process_alterables(alterables)?;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}));
|
||||
|
||||
panel
|
||||
.timers
|
||||
.push(GuiTimer::new(Duration::from_millis(100), 0));
|
||||
|
||||
@@ -30,7 +30,10 @@ use crate::{
|
||||
state::{self, AppState},
|
||||
subsystem::{hid::WheelDelta, input::KeyboardFocus},
|
||||
windowing::{
|
||||
backend::{ui_transform, FrameMeta, OverlayBackend, RenderResources, ShouldRender},
|
||||
backend::{
|
||||
ui_transform, FrameMeta, OverlayBackend, OverlayEventData, RenderResources,
|
||||
ShouldRender,
|
||||
},
|
||||
manager::OverlayWindowManager,
|
||||
window::{OverlayWindowConfig, OverlayWindowData, OverlayWindowState},
|
||||
OverlayID, OverlaySelector, Z_ORDER_DASHBOARD,
|
||||
@@ -703,6 +706,14 @@ impl OverlayBackend for WayVRBackend {
|
||||
})
|
||||
}
|
||||
|
||||
fn notify(
|
||||
&mut self,
|
||||
_app: &mut state::AppState,
|
||||
_event_data: OverlayEventData,
|
||||
) -> anyhow::Result<()> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn on_hover(&mut self, _app: &mut state::AppState, hit: &input::PointerHit) -> HoverResult {
|
||||
let ctx = self.context.borrow();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user