Refactor CellWidget constructor to accept selected

Update `CellWidget::new` to take a `selected` flag and remove the
chaining return values from `set_selected` and `set_zoom_level`. The
board code now passes the selection state directly during construction.
This commit is contained in:
2026-04-08 23:43:16 +02:00
parent 247f5c143b
commit 56bef7c98e
2 changed files with 9 additions and 12 deletions
+4 -6
View File
@@ -25,23 +25,21 @@ pub struct CellWidget {
}
impl CellWidget {
pub fn new(row: usize, col: usize, zoom_level: ZoomLevel) -> Self {
pub fn new(row: usize, col: usize, selected: bool, zoom_level: ZoomLevel) -> Self {
Self {
row,
col,
selected: false,
selected,
zoom_level,
}
}
pub fn set_selected(&mut self, selected: bool) -> &mut Self {
pub fn set_selected(&mut self, selected: bool) {
self.selected = selected;
self
}
pub fn set_zoom_level(&mut self, zoom_level: ZoomLevel) -> &mut Self {
pub fn set_zoom_level(&mut self, zoom_level: ZoomLevel) {
self.zoom_level = zoom_level;
self
}
fn col_to_letters(&self) -> String {