generated from GarandPLG/rust-flake-template
Encapsulate FocusedCell fields and add getters
This commit is contained in:
@@ -83,8 +83,8 @@ impl BoardState {
|
||||
Offset::new(Some(self.horizontal_offset.get_value()), Some(h_max_offset));
|
||||
|
||||
self.focused_cell = FocusedCell::new(
|
||||
self.focused_cell.row,
|
||||
self.focused_cell.col,
|
||||
self.focused_cell.get_row(),
|
||||
self.focused_cell.get_col(),
|
||||
self.map_height,
|
||||
self.map_width,
|
||||
);
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
|
||||
pub struct FocusedCell {
|
||||
pub row: usize,
|
||||
pub col: usize,
|
||||
pub max_row: usize,
|
||||
pub max_col: usize,
|
||||
row: usize,
|
||||
col: usize,
|
||||
max_row: usize,
|
||||
max_col: usize,
|
||||
}
|
||||
|
||||
impl FocusedCell {
|
||||
@@ -16,6 +16,14 @@ impl FocusedCell {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_row(&self) -> usize {
|
||||
self.row
|
||||
}
|
||||
|
||||
pub fn get_col(&self) -> usize {
|
||||
self.col
|
||||
}
|
||||
|
||||
pub fn move_up(&mut self) {
|
||||
self.row = self.row.saturating_sub(1).max(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user