generated from GarandPLG/rust-flake-template
Refactor board cells to 2D vector and auto‑scroll
Store cells as a nested vector instead of a flat list, simplifying indexing and rendering. Add `is_focused_cell_visible` to detect when the focused cell is outside the viewport and adjust vertical/horizontal offsets accordingly in the skirmish keybindings. Update related methods and widget rendering to use the new 2‑D structure.
This commit is contained in:
1 parent
4917068fb1
commit
e4682f1c52
3 files changed
+45
-13
No files matched your search
@@ -21,15 +21,27 @@ pub fn skirmish_keybindings(app: &mut App, key_event: &KeyEvent) {
|
||||
match action {
|
||||
Action::Up => {
|
||||
board.change_focused_cell(MoveFocusedCell::Up);
|
||||
if !board.is_focused_cell_visible() {
|
||||
board.vertical_offset.prev();
|
||||
}
|
||||
}
|
||||
Action::Down => {
|
||||
board.change_focused_cell(MoveFocusedCell::Down);
|
||||
if !board.is_focused_cell_visible() {
|
||||
board.vertical_offset.next();
|
||||
}
|
||||
}
|
||||
Action::Left => {
|
||||
board.change_focused_cell(MoveFocusedCell::Left);
|
||||
if !board.is_focused_cell_visible() {
|
||||
board.horizontal_offset.prev();
|
||||
}
|
||||
}
|
||||
Action::Right => {
|
||||
board.change_focused_cell(MoveFocusedCell::Right);
|
||||
if !board.is_focused_cell_visible() {
|
||||
board.horizontal_offset.next();
|
||||
}
|
||||
}
|
||||
Action::ScrollUp => {
|
||||
board.vertical_offset.prev();
|
||||
|
||||
Reference in new issue
Block a user