mirror of
https://github.com/hannobraun/Fornjot
synced 2025-05-05 10:28:27 +00:00
Support expanding operation
This commit is contained in:
parent
ffee556a97
commit
ea792690f2
@ -102,6 +102,9 @@ impl ApplicationHandler for App {
|
||||
Key::Named(NamedKey::ArrowDown) => {
|
||||
self.view.select_next();
|
||||
}
|
||||
Key::Named(NamedKey::ArrowRight) => {
|
||||
self.view.selected_mut().select_last();
|
||||
}
|
||||
Key::Named(NamedKey::ArrowUp) => {
|
||||
self.view.select_previous();
|
||||
}
|
||||
|
@ -70,6 +70,26 @@ impl OperationView {
|
||||
.unwrap_or(self)
|
||||
}
|
||||
|
||||
pub fn selected_mut(&mut self) -> &mut Self {
|
||||
let Some(selected) = self.selected else {
|
||||
return self;
|
||||
};
|
||||
|
||||
// The way this is done, first checking for `is_none` and then
|
||||
// `unwrap`ing below, is really ugly. But the borrow checker is forcing
|
||||
// my hand.
|
||||
//
|
||||
// I've tried several variations of matching, and it can't see that in
|
||||
// the `None` case, `self` no longer needs to be borrowed, preventing me
|
||||
// from `returning it.
|
||||
|
||||
if self.children.get_mut(selected).is_none() {
|
||||
return self;
|
||||
};
|
||||
|
||||
self.children.get_mut(selected).unwrap().selected_mut()
|
||||
}
|
||||
|
||||
fn last_index(&self) -> usize {
|
||||
self.children.len().saturating_sub(1)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user