mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-06 19:56:42 +01:00
focus: allow entering phrase list
This commit is contained in:
parent
ac8e8b2bf0
commit
89cb8d7bbe
3 changed files with 15 additions and 7 deletions
|
|
@ -283,7 +283,7 @@ impl<E: Engine> FocusGrid for Arranger<E> {
|
|||
//transport.write().unwrap().entered = focused == Transport
|
||||
}
|
||||
self.arrangement.entered = focused == Arrangement;
|
||||
//self.phrases.write().unwrap().entered = focused == PhrasePool;
|
||||
self.phrases.write().unwrap().entered = focused == PhrasePool;
|
||||
self.editor.entered = focused == PhraseEditor;
|
||||
}
|
||||
}
|
||||
|
|
@ -292,6 +292,7 @@ impl<E: Engine> FocusGrid for Arranger<E> {
|
|||
self.entered = false;
|
||||
self.arrangement.entered = false;
|
||||
self.editor.entered = false;
|
||||
self.phrases.write().unwrap().entered = false;
|
||||
}
|
||||
}
|
||||
fn entered (&self) -> Option<ArrangerFocus> {
|
||||
|
|
|
|||
|
|
@ -49,10 +49,12 @@ pub struct PhrasePool<E: Engine> {
|
|||
pub phrase: usize,
|
||||
/// Phrases in the pool
|
||||
pub phrases: Vec<Arc<RwLock<Phrase>>>,
|
||||
/// Whether this widget is focused
|
||||
pub focused: bool,
|
||||
/// Mode switch
|
||||
pub mode: Option<PhrasePoolMode>,
|
||||
/// Whether this widget is focused
|
||||
pub focused: bool,
|
||||
/// Whether this widget is entered
|
||||
pub entered: bool,
|
||||
}
|
||||
/// Modes for phrase pool
|
||||
pub enum PhrasePoolMode {
|
||||
|
|
@ -195,8 +197,9 @@ impl<E: Engine> PhrasePool<E> {
|
|||
scroll: 0,
|
||||
phrase: 0,
|
||||
phrases: vec![Arc::new(RwLock::new(Phrase::default()))],
|
||||
focused: false,
|
||||
mode: None,
|
||||
focused: false,
|
||||
entered: false,
|
||||
}
|
||||
}
|
||||
pub fn len (&self) -> usize { self.phrases.len() }
|
||||
|
|
|
|||
|
|
@ -89,9 +89,13 @@ impl Content for PhrasePool<Tui> {
|
|||
let border = Lozenge(Style::default().bg(Color::Rgb(40, 50, 30)).fg(border_color));
|
||||
let content = content.fill_xy().bg(Color::Rgb(28, 35, 25)).border(border);
|
||||
let title_color = if *focused {Color::Rgb(150, 160, 90)} else {Color::Rgb(120, 130, 100)};
|
||||
let title = format!("[{}] Phrases ({})", phrases.len(), " ");
|
||||
let title = TuiStyle::fg(title, title_color).push_x(1);
|
||||
Layers::new(move|add|{ add(&content)?; Ok(add(&title)?) })
|
||||
let upper_left = format!("[{}] Phrases", if self.entered {"■"} else {" "});
|
||||
let upper_right = format!("({})", phrases.len());
|
||||
lay!(
|
||||
content,
|
||||
TuiStyle::fg(upper_left.to_string(), title_color).push_x(1).align_nw().fill_xy(),
|
||||
TuiStyle::fg(upper_right.to_string(), title_color).pull_x(1).align_ne().fill_xy(),
|
||||
)
|
||||
}
|
||||
}
|
||||
impl Handle<Tui> for PhrasePool<Tui> {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue