feat(tui): adaptive layout & polish refresh
This commit is contained in:
@@ -1818,6 +1818,10 @@ pub struct UiSettings {
|
||||
pub keymap_path: Option<String>,
|
||||
#[serde(default)]
|
||||
pub accessibility: AccessibilitySettings,
|
||||
#[serde(default)]
|
||||
pub layers: LayerSettings,
|
||||
#[serde(default)]
|
||||
pub animations: AnimationSettings,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
@@ -1847,6 +1851,101 @@ impl Default for AccessibilitySettings {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct LayerSettings {
|
||||
#[serde(default = "LayerSettings::default_shadow_elevation")]
|
||||
pub shadow_elevation: u8,
|
||||
#[serde(default = "LayerSettings::default_glass_tint")]
|
||||
pub glass_tint: f32,
|
||||
#[serde(default = "LayerSettings::default_neon_intensity")]
|
||||
pub neon_intensity: u8,
|
||||
#[serde(default = "LayerSettings::default_focus_ring")]
|
||||
pub focus_ring: bool,
|
||||
}
|
||||
|
||||
impl LayerSettings {
|
||||
const fn default_shadow_elevation() -> u8 {
|
||||
2
|
||||
}
|
||||
|
||||
const fn default_neon_intensity() -> u8 {
|
||||
60
|
||||
}
|
||||
|
||||
const fn default_focus_ring() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
const fn default_glass_tint() -> f32 {
|
||||
0.82
|
||||
}
|
||||
|
||||
pub fn shadow_depth(&self) -> u8 {
|
||||
self.shadow_elevation.min(3)
|
||||
}
|
||||
|
||||
pub fn neon_factor(&self) -> f64 {
|
||||
(self.neon_intensity as f64).clamp(0.0, 100.0) / 100.0
|
||||
}
|
||||
|
||||
pub fn glass_tint_factor(&self) -> f64 {
|
||||
self.glass_tint.clamp(0.0, 1.0) as f64
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for LayerSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
shadow_elevation: Self::default_shadow_elevation(),
|
||||
glass_tint: Self::default_glass_tint(),
|
||||
neon_intensity: Self::default_neon_intensity(),
|
||||
focus_ring: Self::default_focus_ring(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||
pub struct AnimationSettings {
|
||||
#[serde(default = "AnimationSettings::default_micro")]
|
||||
pub micro: bool,
|
||||
#[serde(default = "AnimationSettings::default_gauge_smoothing")]
|
||||
pub gauge_smoothing: f32,
|
||||
#[serde(default = "AnimationSettings::default_pane_decay")]
|
||||
pub pane_decay: f32,
|
||||
}
|
||||
|
||||
impl AnimationSettings {
|
||||
const fn default_micro() -> bool {
|
||||
true
|
||||
}
|
||||
|
||||
const fn default_gauge_smoothing() -> f32 {
|
||||
0.24
|
||||
}
|
||||
|
||||
const fn default_pane_decay() -> f32 {
|
||||
0.68
|
||||
}
|
||||
|
||||
pub fn gauge_smoothing_factor(&self) -> f64 {
|
||||
self.gauge_smoothing.clamp(0.05, 1.0) as f64
|
||||
}
|
||||
|
||||
pub fn pane_decay_factor(&self) -> f64 {
|
||||
self.pane_decay.clamp(0.2, 0.95) as f64
|
||||
}
|
||||
}
|
||||
|
||||
impl Default for AnimationSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
micro: Self::default_micro(),
|
||||
gauge_smoothing: Self::default_gauge_smoothing(),
|
||||
pane_decay: Self::default_pane_decay(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Preference for which symbol set to render in the terminal UI.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize, Default)]
|
||||
#[serde(rename_all = "lowercase")]
|
||||
@@ -1994,6 +2093,8 @@ impl Default for UiSettings {
|
||||
keymap_leader: Self::default_keymap_leader(),
|
||||
keymap_path: None,
|
||||
accessibility: AccessibilitySettings::default(),
|
||||
layers: LayerSettings::default(),
|
||||
animations: AnimationSettings::default(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user