watch toolbox to support various overlay types
This commit is contained in:
@@ -1,9 +1,13 @@
|
||||
use std::sync::Arc;
|
||||
|
||||
use glam::{Affine3A, Quat, Vec3, vec3};
|
||||
use glam::{vec3, Affine3A, Quat, Vec3};
|
||||
use wlx_common::windowing::OverlayWindowState;
|
||||
|
||||
use crate::{gui::panel::GuiPanel, state::AppState, windowing::window::OverlayWindowConfig};
|
||||
use crate::{
|
||||
gui::panel::GuiPanel,
|
||||
state::AppState,
|
||||
windowing::window::{OverlayCategory, OverlayWindowConfig},
|
||||
};
|
||||
|
||||
const SETTINGS_NAME: &str = "settings";
|
||||
|
||||
@@ -20,6 +24,7 @@ pub fn create_custom(app: &mut AppState, name: Arc<str>) -> Option<OverlayWindow
|
||||
|
||||
Some(OverlayWindowConfig {
|
||||
name,
|
||||
category: OverlayCategory::PanelCustom,
|
||||
default_state: OverlayWindowState {
|
||||
interactable: true,
|
||||
grabbable: true,
|
||||
|
||||
@@ -271,7 +271,7 @@ fn make_edit_panel(app: &mut AppState) -> anyhow::Result<EditModeWrapPanel> {
|
||||
Ok(EventResult::Consumed)
|
||||
}),
|
||||
"::EditModeDeleteRelease" => Box::new(move |_common, _data, app, state| {
|
||||
if state.delete.pressed.elapsed() < Duration::from_secs(2) {
|
||||
if state.delete.pressed.elapsed() < Duration::from_secs(1) {
|
||||
return Ok(EventResult::Pass);
|
||||
}
|
||||
app.tasks.enqueue(TaskType::Overlay(
|
||||
|
||||
@@ -5,7 +5,7 @@ use std::{
|
||||
|
||||
use futures::{Future, FutureExt};
|
||||
use glam::{Affine2, Affine3A, Vec3};
|
||||
use wlx_capture::pipewire::{PipewireCapture, PipewireSelectScreenResult, pipewire_select_screen};
|
||||
use wlx_capture::pipewire::{pipewire_select_screen, PipewireCapture, PipewireSelectScreenResult};
|
||||
use wlx_common::windowing::OverlayWindowState;
|
||||
|
||||
use crate::{
|
||||
@@ -16,12 +16,12 @@ use crate::{
|
||||
state::{AppSession, AppState},
|
||||
subsystem::hid::WheelDelta,
|
||||
windowing::{
|
||||
OverlaySelector,
|
||||
backend::{
|
||||
FrameMeta, OverlayBackend, OverlayEventData, RenderResources, ShouldRender,
|
||||
ui_transform,
|
||||
ui_transform, FrameMeta, OverlayBackend, OverlayEventData, RenderResources,
|
||||
ShouldRender,
|
||||
},
|
||||
window::OverlayWindowConfig,
|
||||
window::{OverlayCategory, OverlayWindowConfig},
|
||||
OverlaySelector,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -152,6 +152,7 @@ impl OverlayBackend for MirrorBackend {
|
||||
pub fn new_mirror(name: Arc<str>, session: &AppSession) -> OverlayWindowConfig {
|
||||
OverlayWindowConfig {
|
||||
name: name.clone(),
|
||||
category: OverlayCategory::Mirror,
|
||||
default_state: OverlayWindowState {
|
||||
interactable: true,
|
||||
grabbable: true,
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
use std::{f32::consts::PI, sync::Arc};
|
||||
|
||||
use glam::{Affine3A, Quat, Vec3, vec3};
|
||||
use glam::{vec3, Affine3A, Quat, Vec3};
|
||||
use wlx_capture::frame::Transform;
|
||||
use wlx_common::windowing::{OverlayWindowState, Positioning};
|
||||
|
||||
use crate::{
|
||||
state::{AppSession, AppState, ScreenMeta},
|
||||
subsystem::{hid::XkbKeymap, input::KeyboardFocus},
|
||||
windowing::{backend::OverlayBackend, window::OverlayWindowConfig},
|
||||
windowing::{
|
||||
backend::OverlayBackend,
|
||||
window::{OverlayCategory, OverlayWindowConfig},
|
||||
},
|
||||
};
|
||||
|
||||
pub mod backend;
|
||||
@@ -38,6 +41,7 @@ fn create_screen_from_backend(
|
||||
|
||||
OverlayWindowConfig {
|
||||
name,
|
||||
category: OverlayCategory::Screen,
|
||||
default_state: OverlayWindowState {
|
||||
grabbable: true,
|
||||
positioning: Positioning::Anchored,
|
||||
|
||||
@@ -25,7 +25,7 @@ use crate::{
|
||||
overlays::edit::LongPressButtonState,
|
||||
state::AppState,
|
||||
windowing::{
|
||||
backend::OverlayEventData,
|
||||
backend::{OverlayEventData, OverlayMeta},
|
||||
manager::MAX_OVERLAY_SETS,
|
||||
window::{OverlayWindowConfig, OverlayWindowData},
|
||||
OverlaySelector, Z_ORDER_WATCH,
|
||||
@@ -33,12 +33,14 @@ use crate::{
|
||||
};
|
||||
|
||||
pub const WATCH_NAME: &str = "watch";
|
||||
const MAX_TOOLBOX_BUTTONS: usize = 16;
|
||||
|
||||
#[derive(Default)]
|
||||
struct WatchState {
|
||||
current_set: Option<usize>,
|
||||
set_buttons: Vec<Rc<ComponentButton>>,
|
||||
screen_buttons: Vec<Rc<ComponentButton>>,
|
||||
overlay_buttons: Vec<Rc<ComponentButton>>,
|
||||
overlay_metas: Vec<OverlayMeta>,
|
||||
edit_mode_widgets: Vec<(WidgetID, bool)>,
|
||||
edit_add_widget: WidgetID,
|
||||
num_sets: usize,
|
||||
@@ -66,7 +68,7 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
||||
Ok(EventResult::Consumed)
|
||||
}),
|
||||
"::EditModeDeleteUp" => Box::new(move |_common, _data, app, state| {
|
||||
if state.delete.pressed.elapsed() < Duration::from_secs(2) {
|
||||
if state.delete.pressed.elapsed() < Duration::from_secs(1) {
|
||||
return Ok(EventResult::Consumed);
|
||||
}
|
||||
app.tasks
|
||||
@@ -77,20 +79,20 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
||||
app.tasks.enqueue(TaskType::Manager(ManagerTask::AddSet));
|
||||
Ok(EventResult::Consumed)
|
||||
}),
|
||||
"::EditModeScreenToggle" => {
|
||||
"::EditModeOverlayToggle" => {
|
||||
let arg = args.next().unwrap_or_default();
|
||||
let Ok(idx) = arg.parse::<usize>() else {
|
||||
log::error!("{command} has invalid argument: \"{arg}\"");
|
||||
return;
|
||||
};
|
||||
Box::new(move |_common, _data, app, _state| {
|
||||
let Some(screen) = app.screens.get(idx) else {
|
||||
log::error!("No screen at index {idx}.");
|
||||
Box::new(move |_common, _data, app, state| {
|
||||
let Some(overlay) = state.overlay_metas.get(idx) else {
|
||||
log::error!("No overlay at index {idx}.");
|
||||
return Ok(EventResult::Consumed);
|
||||
};
|
||||
|
||||
app.tasks.enqueue(TaskType::Overlay(
|
||||
OverlaySelector::Name(screen.name.clone()),
|
||||
OverlaySelector::Id(overlay.id.clone()),
|
||||
Box::new(move |app, owc| {
|
||||
if owc.active_state.is_none() {
|
||||
owc.activate(app);
|
||||
@@ -137,17 +139,17 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
||||
state.set_buttons.push(component);
|
||||
}
|
||||
} else if &*id == "toolbox" {
|
||||
for idx in 0..9 {
|
||||
let screen_id = format!("screen_{idx}");
|
||||
for idx in 0..MAX_TOOLBOX_BUTTONS {
|
||||
let overlay_id = format!("overlay_{idx}");
|
||||
let mut params: HashMap<Rc<str>, Rc<str>> = HashMap::new();
|
||||
params.insert("idx".into(), idx.to_string().into());
|
||||
parser_state.instantiate_template(
|
||||
doc_params, "Screen", layout, widget, params,
|
||||
doc_params, "Overlay", layout, widget, params,
|
||||
)?;
|
||||
|
||||
let component =
|
||||
parser_state.fetch_component_as::<ComponentButton>(&screen_id)?;
|
||||
state.screen_buttons.push(component);
|
||||
parser_state.fetch_component_as::<ComponentButton>(&overlay_id)?;
|
||||
state.overlay_buttons.push(component);
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
@@ -158,7 +160,7 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
||||
},
|
||||
)?;
|
||||
|
||||
panel.on_notify = Some(Box::new(|panel, app, event_data| {
|
||||
panel.on_notify = Some(Box::new(|panel, _app, event_data| {
|
||||
let mut alterables = EventAlterables::default();
|
||||
let mut common = CallbackDataCommon {
|
||||
alterables: &mut alterables,
|
||||
@@ -218,10 +220,12 @@ pub fn create_watch(app: &mut AppState) -> anyhow::Result<OverlayWindowConfig> {
|
||||
&mut common.alterables,
|
||||
);
|
||||
}
|
||||
OverlayEventData::ScreensChanged => {
|
||||
for (idx, btn) in panel.state.screen_buttons.iter().enumerate() {
|
||||
let display = if let Some(screen) = app.screens.get(idx) {
|
||||
btn.set_text(&mut common, Translation::from_raw_text(&screen.name));
|
||||
OverlayEventData::OverlaysChanged(metas) => {
|
||||
panel.state.overlay_metas = metas;
|
||||
for (idx, btn) in panel.state.overlay_buttons.iter().enumerate() {
|
||||
let display = if let Some(meta) = panel.state.overlay_metas.get(idx) {
|
||||
btn.set_text(&mut common, Translation::from_raw_text(&meta.name));
|
||||
//TODO: add category icons
|
||||
taffy::Display::Flex
|
||||
} else {
|
||||
taffy::Display::None
|
||||
|
||||
@@ -1,17 +1,17 @@
|
||||
use glam::{Affine2, Affine3A, Quat, Vec3, vec3};
|
||||
use glam::{vec3, Affine2, Affine3A, Quat, Vec3};
|
||||
use smallvec::smallvec;
|
||||
use std::{cell::RefCell, collections::HashMap, rc::Rc, sync::Arc};
|
||||
use vulkano::{
|
||||
buffer::{BufferUsage, Subbuffer},
|
||||
command_buffer::CommandBufferUsage,
|
||||
format::Format,
|
||||
image::{Image, ImageTiling, SubresourceLayout, view::ImageView},
|
||||
image::{view::ImageView, Image, ImageTiling, SubresourceLayout},
|
||||
};
|
||||
use wayvr_ipc::packet_server::{self, PacketServer, WvrStateChanged};
|
||||
use wgui::gfx::{
|
||||
WGfx,
|
||||
pass::WGfxPass,
|
||||
pipeline::{WGfxPipeline, WPipelineCreateInfo},
|
||||
WGfx,
|
||||
};
|
||||
use wlx_capture::frame::{DmabufFrame, FourCC, FrameFormat, FramePlane};
|
||||
use wlx_common::windowing::OverlayWindowState;
|
||||
@@ -21,22 +21,23 @@ use crate::{
|
||||
input::{self, HoverResult},
|
||||
task::TaskType,
|
||||
wayvr::{
|
||||
self, WayVR, WayVRAction, WayVRDisplayClickAction, display,
|
||||
self, display,
|
||||
server_ipc::{gen_args_vec, gen_env_vec},
|
||||
WayVR, WayVRAction, WayVRDisplayClickAction,
|
||||
},
|
||||
},
|
||||
config_wayvr,
|
||||
graphics::{Vert2Uv, dmabuf::WGfxDmabuf},
|
||||
graphics::{dmabuf::WGfxDmabuf, Vert2Uv},
|
||||
state::{self, AppState},
|
||||
subsystem::{hid::WheelDelta, input::KeyboardFocus},
|
||||
windowing::{
|
||||
OverlayID, OverlaySelector, Z_ORDER_DASHBOARD,
|
||||
backend::{
|
||||
FrameMeta, OverlayBackend, OverlayEventData, RenderResources, ShouldRender,
|
||||
ui_transform,
|
||||
ui_transform, FrameMeta, OverlayBackend, OverlayEventData, RenderResources,
|
||||
ShouldRender,
|
||||
},
|
||||
manager::OverlayWindowManager,
|
||||
window::{OverlayWindowConfig, OverlayWindowData},
|
||||
window::{OverlayCategory, OverlayWindowConfig, OverlayWindowData},
|
||||
OverlayID, OverlaySelector, Z_ORDER_DASHBOARD,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -45,7 +46,7 @@ use super::toast::error_toast;
|
||||
// Hard-coded for now
|
||||
const DASHBOARD_WIDTH: u16 = 1920;
|
||||
const DASHBOARD_HEIGHT: u16 = 1080;
|
||||
const DASHBOARD_DISPLAY_NAME: &str = "_DASHBOARD";
|
||||
const DASHBOARD_DISPLAY_NAME: &str = "DASHBOARD";
|
||||
|
||||
pub struct WayVRContext {
|
||||
wayvr: Rc<RefCell<WayVRData>>,
|
||||
@@ -794,9 +795,16 @@ pub fn create_wayvr_display_overlay(
|
||||
[display_width, display_height],
|
||||
)?);
|
||||
|
||||
let category = if name == DASHBOARD_DISPLAY_NAME {
|
||||
OverlayCategory::Internal
|
||||
} else {
|
||||
OverlayCategory::WayVR
|
||||
};
|
||||
|
||||
Ok(OverlayWindowConfig {
|
||||
name: format!("WayVR - {name}").into(),
|
||||
name: format!("WVR-{name}").into(),
|
||||
keyboard_focus: Some(KeyboardFocus::WayVR),
|
||||
category,
|
||||
default_state: OverlayWindowState {
|
||||
interactable: true,
|
||||
grabbable: true,
|
||||
|
||||
Reference in New Issue
Block a user