locking: Lock keys statelessly

Locking is not determined by button state any more, but rather based on the view active at the moment. If pressing/locking a key results in the current view being active, the key is active. If locking a key results in the current view, the unlock view is activated.
This commit is contained in:
Dorota Czaplejewicz
2020-02-02 15:41:47 +00:00
parent 97d8dfe4cb
commit 500c23beec
5 changed files with 40 additions and 41 deletions

View File

@ -38,3 +38,19 @@ pub enum Action {
},
ShowPreferences,
}
impl Action {
pub fn is_locked(&self, view_name: &str) -> bool {
match self {
Action::LockView { lock, unlock: _ } => lock == view_name,
_ => false,
}
}
pub fn is_active(&self, view_name: &str) -> bool {
match self {
Action::SetView(view) => view == view_name,
Action::LockView { lock, unlock: _ } => lock == view_name,
_ => false,
}
}
}