Feat: UI / UX fixes
This commit is contained in:
@@ -9,6 +9,7 @@ use crate::theme;
|
||||
pub enum FxId {
|
||||
#[default]
|
||||
PageTransition,
|
||||
NavSwitch,
|
||||
}
|
||||
|
||||
pub fn tick_effects(ui: &mut UiState, page: Page) {
|
||||
@@ -39,6 +40,14 @@ pub fn tick_effects(ui: &mut UiState, page: Page) {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn nav_sweep(ui: &UiState, direction: Motion) {
|
||||
let bg = theme::get().ui.bg;
|
||||
ui.effects.borrow_mut().add_unique_effect(
|
||||
FxId::NavSwitch,
|
||||
fx::sweep_in(direction, 10, 0, bg, (300, Interpolation::QuadOut)),
|
||||
);
|
||||
}
|
||||
|
||||
fn page_direction(from: Page, to: Page) -> Motion {
|
||||
let (fc, fr) = from.grid_pos();
|
||||
let (tc, tr) = to.grid_pos();
|
||||
|
||||
@@ -77,7 +77,6 @@ pub enum Modal {
|
||||
JumpToStep(String),
|
||||
AddSamplePath(Box<FileBrowserState>),
|
||||
Editor,
|
||||
Preview,
|
||||
PatternProps {
|
||||
bank: usize,
|
||||
pattern: usize,
|
||||
|
||||
@@ -3,7 +3,7 @@ use std::time::{Duration, Instant};
|
||||
|
||||
use cagire_markdown::ParsedMarkdown;
|
||||
use cagire_ratatui::Sparkles;
|
||||
use tachyonfx::{fx, Effect, EffectManager, Interpolation};
|
||||
use tachyonfx::{fx, Effect, EffectManager, Interpolation, Motion};
|
||||
|
||||
use crate::page::Page;
|
||||
use crate::state::effects::FxId;
|
||||
@@ -83,6 +83,8 @@ pub struct UiState {
|
||||
pub window_height: u32,
|
||||
pub load_demo_on_startup: bool,
|
||||
pub demo_index: usize,
|
||||
pub nav_indicator_until: Option<Instant>,
|
||||
pub nav_fx: RefCell<Option<Effect>>,
|
||||
}
|
||||
|
||||
impl Default for UiState {
|
||||
@@ -135,6 +137,8 @@ impl Default for UiState {
|
||||
window_height: 800,
|
||||
load_demo_on_startup: true,
|
||||
demo_index: 0,
|
||||
nav_indicator_until: None,
|
||||
nav_fx: RefCell::new(None),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -196,6 +200,19 @@ impl UiState {
|
||||
self.minimap = MinimapMode::Hidden;
|
||||
}
|
||||
|
||||
pub fn show_nav_indicator(&mut self, duration_ms: u64, direction: Motion) {
|
||||
self.nav_indicator_until = Some(Instant::now() + Duration::from_millis(duration_ms));
|
||||
let bg = crate::theme::get().ui.bg;
|
||||
*self.nav_fx.borrow_mut() = Some(fx::fade_from_fg(bg, (150, Interpolation::QuadOut)));
|
||||
crate::state::effects::nav_sweep(self, direction);
|
||||
}
|
||||
|
||||
pub fn nav_indicator_visible(&self) -> bool {
|
||||
self.nav_indicator_until
|
||||
.map(|t| Instant::now() < t)
|
||||
.unwrap_or(false)
|
||||
}
|
||||
|
||||
pub fn invalidate_help_cache(&self) {
|
||||
self.help_parsed
|
||||
.borrow_mut()
|
||||
|
||||
Reference in New Issue
Block a user