store notes area size at render

This commit is contained in:
🪞👃🪞 2024-10-23 23:22:34 +03:00
parent ecbbef22b5
commit 03e2e20258
2 changed files with 8 additions and 0 deletions

View file

@ -103,6 +103,10 @@ pub struct PhraseEditor<E: Engine> {
pub notes_out: Arc<RwLock<[bool; 128]>>, pub notes_out: Arc<RwLock<[bool; 128]>>,
/// Current position of global playhead /// Current position of global playhead
pub now: Arc<AtomicUsize>, pub now: Arc<AtomicUsize>,
/// Width of notes area at last render
pub width: AtomicUsize,
/// Height of notes area at last render
pub height: AtomicUsize,
} }
/// Phrase player. /// Phrase player.
pub struct PhrasePlayer<E: Engine> { pub struct PhrasePlayer<E: Engine> {
@ -237,6 +241,8 @@ impl<E: Engine> PhraseEditor<E> {
entered: false, entered: false,
mode: false, mode: false,
now: Arc::new(0.into()), now: Arc::new(0.into()),
width: 0.into(),
height: 0.into(),
} }
} }
} }

View file

@ -67,6 +67,8 @@ impl Content for PhraseEditor<Tui> {
}).fill_y(); }).fill_y();
let notes_bg_null = Color::Rgb(28, 35, 25); let notes_bg_null = Color::Rgb(28, 35, 25);
let notes = CustomWidget::new(|to|Ok(Some(to)), move|to: &mut TuiOutput|{ let notes = CustomWidget::new(|to|Ok(Some(to)), move|to: &mut TuiOutput|{
self.width.store(to.area.w() as usize, Ordering::Relaxed);
self.height.store(to.area.h() as usize, Ordering::Relaxed);
if to.area().h() >= 2 { if to.area().h() >= 2 {
let area = to.area(); let area = to.area();
to.buffer_update(area, &move |cell, x, y|{ to.buffer_update(area, &move |cell, x, y|{