remove AppFocus

This commit is contained in:
🪞👃🪞 2024-11-26 01:40:30 +01:00
parent 3273c85630
commit e4027619e8
14 changed files with 127 additions and 140 deletions

View file

@ -238,14 +238,6 @@ impl Debug for PhrasePlayerModel {
}
}
#[derive(Clone, Copy, Debug, PartialEq)]
pub enum AppFocus<T: Copy + Debug + PartialEq> {
/// The menu bar is focused
Menu,
/// The app content is focused
Content(T)
}
pub trait FocusWrap<T> {
fn wrap <'a, W: Widget<Engine = Tui>> (self, focus: T, content: &'a W)
-> impl Widget<Engine = Tui> + 'a;
@ -254,7 +246,7 @@ pub trait FocusWrap<T> {
#[macro_export] macro_rules! impl_focus {
($Struct:ident $Focus:ident $Grid:expr) => {
impl HasFocus for $Struct {
type Item = AppFocus<$Focus>;
type Item = $Focus;
/// Get the currently focused item.
fn focused (&self) -> Self::Item {
self.focus.inner()
@ -285,8 +277,7 @@ pub trait FocusWrap<T> {
fn focus_cursor_mut (&mut self) -> &mut (usize, usize) {
&mut self.cursor
}
fn focus_layout (&self) -> &[&[AppFocus<$Focus>]] {
use AppFocus::*;
fn focus_layout (&self) -> &[&[$Focus]] {
use $Focus::*;
&$Grid
}