panel: per-element interactibility

This commit is contained in:
galister
2025-10-31 17:32:10 +09:00
parent 01d11e8485
commit fa562f7b12
19 changed files with 423 additions and 361 deletions

View File

@@ -11,11 +11,11 @@ use wgui::{
};
use crate::{
backend::input::{Haptics, PointerHit},
backend::input::{HoverResult, PointerHit},
graphics::CommandBuffers,
gui::panel::GuiPanel,
state::AppState,
subsystem::hid::{ALT, CTRL, KeyModifier, META, SHIFT, SUPER, VirtualKey},
subsystem::hid::{KeyModifier, VirtualKey, ALT, CTRL, META, SHIFT, SUPER},
windowing::backend::{FrameMeta, OverlayBackend, ShouldRender},
};
@@ -75,7 +75,7 @@ impl OverlayBackend for KeyboardBackend {
fn on_left(&mut self, app: &mut AppState, pointer: usize) {
self.panel.on_left(app, pointer);
}
fn on_hover(&mut self, app: &mut AppState, hit: &PointerHit) -> Option<Haptics> {
fn on_hover(&mut self, app: &mut AppState, hit: &PointerHit) -> HoverResult {
self.panel.on_hover(app, hit)
}
fn get_interaction_transform(&mut self) -> Option<glam::Affine2> {

View File

@@ -10,7 +10,7 @@ use wlx_capture::pipewire::{pipewire_select_screen, PipewireCapture, PipewireSel
use crate::{
backend::{
input::{Haptics, PointerHit},
input::{HoverResult, PointerHit},
task::TaskType,
},
graphics::CommandBuffers,
@@ -130,8 +130,11 @@ impl OverlayBackend for MirrorBackend {
self.renderer.as_mut().and_then(ScreenBackend::frame_meta)
}
fn on_hover(&mut self, _: &mut AppState, _: &PointerHit) -> Option<Haptics> {
None
fn on_hover(&mut self, _: &mut AppState, _: &PointerHit) -> HoverResult {
HoverResult {
consume: true,
..HoverResult::default()
}
}
fn on_left(&mut self, _: &mut AppState, _: usize) {}
fn on_pointer(&mut self, _: &mut AppState, _: &PointerHit, _: bool) {}

View File

@@ -1,21 +1,21 @@
use std::{
sync::{Arc, LazyLock, atomic::AtomicU64},
sync::{atomic::AtomicU64, Arc, LazyLock},
time::Instant,
};
use glam::{Affine2, Vec2, vec2};
use glam::{vec2, Affine2, Vec2};
use vulkano::image::view::ImageView;
use wlx_capture::{WlxCapture, frame::Transform};
use wlx_capture::{frame::Transform, WlxCapture};
use crate::{
backend::input::{Haptics, PointerHit, PointerMode},
backend::input::{HoverResult, PointerHit, PointerMode},
graphics::{CommandBuffers, ExtentExt},
state::AppState,
subsystem::hid::{MOUSE_LEFT, MOUSE_MIDDLE, MOUSE_RIGHT},
windowing::backend::{FrameMeta, OverlayBackend, ShouldRender},
};
use super::capture::{ScreenPipeline, WlxCaptureIn, WlxCaptureOut, receive_callback};
use super::capture::{receive_callback, ScreenPipeline, WlxCaptureIn, WlxCaptureOut};
const CURSOR_SIZE: f32 = 16. / 1440.;
@@ -211,7 +211,7 @@ impl OverlayBackend for ScreenBackend {
self.meta
}
fn on_hover(&mut self, app: &mut AppState, hit: &PointerHit) -> Option<Haptics> {
fn on_hover(&mut self, app: &mut AppState, hit: &PointerHit) -> HoverResult {
#[cfg(debug_assertions)]
log::trace!("Hover: {:?}", hit.uv);
if can_move()
@@ -222,7 +222,10 @@ impl OverlayBackend for ScreenBackend {
app.hid_provider.inner.mouse_move(pos);
set_next_move(u64::from(app.session.config.mouse_move_interval_ms));
}
None
HoverResult {
consume: true,
..HoverResult::default()
}
}
fn on_pointer(&mut self, app: &mut AppState, hit: &PointerHit, pressed: bool) {
let btn = match hit.mode {

View File

@@ -17,7 +17,7 @@ use wlx_capture::frame::{DmabufFrame, FourCC, FrameFormat, FramePlane};
use crate::{
backend::{
input::{self},
input::{self, HoverResult},
task::TaskType,
wayvr::{
self, display,
@@ -716,11 +716,7 @@ impl OverlayBackend for WayVRBackend {
})
}
fn on_hover(
&mut self,
_app: &mut state::AppState,
hit: &input::PointerHit,
) -> Option<input::Haptics> {
fn on_hover(&mut self, _app: &mut state::AppState, hit: &input::PointerHit) -> HoverResult {
let ctx = self.context.borrow();
let wayvr = &mut ctx.wayvr.borrow_mut();
@@ -737,7 +733,10 @@ impl OverlayBackend for WayVRBackend {
.send_mouse_move(ctx.display, x as u32, y as u32);
}
wayvr.pending_haptics.take()
HoverResult {
haptics: wayvr.pending_haptics.take(),
consume: true,
}
}
fn on_left(&mut self, _app: &mut state::AppState, _pointer: usize) {