mirror of
https://codeberg.org/unspeaker/tek.git
synced 2025-12-07 20:26:42 +01:00
wip(p62,e21)
This commit is contained in:
parent
76da19d9c6
commit
5673dd7e8a
14 changed files with 170 additions and 190 deletions
|
|
@ -12,7 +12,7 @@ pub enum FocusCommand {
|
|||
Exit
|
||||
}
|
||||
|
||||
impl<F: HasFocus + FocusGrid + FocusEnter> Command<F> for FocusCommand {
|
||||
impl<F: HasFocus + FocusGrid> Command<F> for FocusCommand {
|
||||
fn execute (self, state: &mut F) -> Perhaps<FocusCommand> {
|
||||
use FocusCommand::*;
|
||||
match self {
|
||||
|
|
@ -46,6 +46,12 @@ pub trait HasFocus {
|
|||
self.focus_next()
|
||||
}
|
||||
}
|
||||
/// Enter the focused item
|
||||
fn focus_enter (&mut self) {}
|
||||
/// Exit the focused item
|
||||
fn focus_exit (&mut self) {}
|
||||
/// Return the focused item, if any
|
||||
fn focus_entered (&self) -> Option<Self::Item> { None }
|
||||
}
|
||||
|
||||
/// Trait for things that implement directional focus.
|
||||
|
|
@ -94,7 +100,7 @@ pub trait FocusGrid {
|
|||
impl<T, U> HasFocus for U
|
||||
where
|
||||
T: Copy + PartialEq + Debug,
|
||||
U: FocusGrid<Item = T> + FocusEnter<Item = T>,
|
||||
U: FocusGrid<Item = T>
|
||||
{
|
||||
type Item = T;
|
||||
fn focused (&self) -> Self::Item {
|
||||
|
|
@ -134,11 +140,3 @@ where
|
|||
self.focus_update();
|
||||
}
|
||||
}
|
||||
|
||||
/// Trait for things that can be focused into.
|
||||
pub trait FocusEnter {
|
||||
type Item: Copy + PartialEq + Debug;
|
||||
fn focus_enter (&mut self) {}
|
||||
fn focus_exit (&mut self) {}
|
||||
fn focus_entered (&self) -> Option<Self::Item>;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue