generated from GarandPLG/rust-flake-template
Add zoom support and emoji keybinding icons
- CellWidget now stores a ZoomLevel, renders size‑dependent text, and provides methods to set the zoom level and build its block. - BoardState creates cells with the current zoom level, adds a helper to get a mutable cell, and updates each cell’s zoom level in `zoom_change`. - KeybindingsWidget constructor now takes the widget height, calculates vertical padding to centre groups, and adds left borders between groups. - Views (default, main_menu, skirmish) pass the area height to the new constructor. - Keybinding descriptions are replaced with emoji symbols (🔈, 🔊, 🔉). - BoardWidget clones the cell template instead of dereferencing it.
This commit is contained in:
@@ -45,7 +45,7 @@ impl BoardState {
|
||||
|
||||
for row in 0..map_height {
|
||||
for col in 0..map_width {
|
||||
cells.push(CellWidget::new(row, col));
|
||||
cells.push(CellWidget::new(row, col, zoom_level));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -65,6 +65,10 @@ impl BoardState {
|
||||
}
|
||||
}
|
||||
|
||||
fn get_mut_cell(&mut self, row: usize, col: usize) -> &mut CellWidget {
|
||||
&mut self.cells[row * self.map_width + col]
|
||||
}
|
||||
|
||||
pub fn zoom_change(&mut self, new_zoom_level: ZoomLevel) {
|
||||
self.zoom_level = new_zoom_level;
|
||||
|
||||
@@ -88,6 +92,12 @@ impl BoardState {
|
||||
self.map_height,
|
||||
self.map_width,
|
||||
);
|
||||
|
||||
for row in 0..self.map_height {
|
||||
for col in 0..self.map_width {
|
||||
self.get_mut_cell(row, col).set_zoom_level(new_zoom_level);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn max_offset(map_size: usize, size: usize) -> usize {
|
||||
|
||||
Reference in New Issue
Block a user