feat: persist layout between sessions
This commit is contained in:
@@ -10,10 +10,10 @@ use serde::Deserialize;
|
||||
use thiserror::Error;
|
||||
|
||||
use crate::{
|
||||
config::{AStrMapExt, AStrSetExt},
|
||||
config::AStrSetExt,
|
||||
overlays::{
|
||||
anchor::create_anchor,
|
||||
keyboard::{create_keyboard, KEYBOARD_NAME},
|
||||
keyboard::create_keyboard,
|
||||
screen::WlxClientAlias,
|
||||
watch::{create_watch, WATCH_NAME},
|
||||
},
|
||||
@@ -82,12 +82,6 @@ where
|
||||
state.show_hide = true;
|
||||
state.want_visible = false;
|
||||
}
|
||||
state.curvature = app
|
||||
.session
|
||||
.config
|
||||
.curve_values
|
||||
.arc_get(state.name.as_ref())
|
||||
.copied();
|
||||
overlays.insert(
|
||||
state.id,
|
||||
OverlayData::<T> {
|
||||
@@ -109,12 +103,6 @@ where
|
||||
let mut keyboard = create_keyboard(app)?;
|
||||
keyboard.state.show_hide = true;
|
||||
keyboard.state.want_visible = false;
|
||||
keyboard.state.curvature = app
|
||||
.session
|
||||
.config
|
||||
.curve_values
|
||||
.arc_get(KEYBOARD_NAME)
|
||||
.copied();
|
||||
overlays.insert(keyboard.state.id, keyboard);
|
||||
|
||||
Ok(Self { overlays, wl })
|
||||
|
||||
@@ -535,7 +535,6 @@ impl Pointer {
|
||||
Some(snap_upright(*anchor, Vec3A::Y).inverse() * overlay.state.transform);
|
||||
|
||||
if let Some(grab_data) = self.interaction.grabbed.as_ref() {
|
||||
let mut state_dirty = false;
|
||||
if overlay.state.curvature != grab_data.old_curvature {
|
||||
if let Some(val) = overlay.state.curvature {
|
||||
config.curve_values.arc_ins(overlay.state.name.clone(), val);
|
||||
@@ -543,13 +542,14 @@ impl Pointer {
|
||||
let ref_name = overlay.state.name.as_ref();
|
||||
config.curve_values.arc_rm(ref_name);
|
||||
}
|
||||
state_dirty = true;
|
||||
}
|
||||
if state_dirty {
|
||||
match save_state(config) {
|
||||
Ok(_) => log::debug!("Saved state"),
|
||||
Err(e) => log::error!("Failed to save state: {:?}", e),
|
||||
}
|
||||
config.transform_values.arc_ins(
|
||||
overlay.state.name.clone(),
|
||||
overlay.state.saved_transform.unwrap(),
|
||||
);
|
||||
match save_state(config) {
|
||||
Ok(_) => log::debug!("Saved state"),
|
||||
Err(e) => log::error!("Failed to save state: {:?}", e),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ use anyhow::Ok;
|
||||
use glam::{Affine2, Affine3A, Mat3A, Quat, Vec2, Vec3, Vec3A};
|
||||
use vulkano::image::view::ImageView;
|
||||
|
||||
use crate::state::AppState;
|
||||
use crate::{config::AStrMapExt, state::AppState};
|
||||
|
||||
use super::input::{DummyInteractionHandler, Haptics, InteractionHandler, PointerHit};
|
||||
|
||||
@@ -178,7 +178,26 @@ where
|
||||
T: Default,
|
||||
{
|
||||
pub fn init(&mut self, app: &mut AppState) -> anyhow::Result<()> {
|
||||
self.state.reset(app, true);
|
||||
self.state.curvature = app
|
||||
.session
|
||||
.config
|
||||
.curve_values
|
||||
.arc_get(self.state.name.as_ref())
|
||||
.copied();
|
||||
|
||||
let hard_reset;
|
||||
if let Some(transform) = app
|
||||
.session
|
||||
.config
|
||||
.transform_values
|
||||
.arc_get(self.state.name.as_ref())
|
||||
{
|
||||
self.state.saved_transform = Some(*transform);
|
||||
hard_reset = false;
|
||||
} else {
|
||||
hard_reset = true;
|
||||
}
|
||||
self.state.reset(app, hard_reset);
|
||||
self.backend.init(app)
|
||||
}
|
||||
pub fn render(&mut self, app: &mut AppState) -> anyhow::Result<()> {
|
||||
|
||||
Reference in New Issue
Block a user