generated from GarandPLG/rust-flake-template
Add bounded focus and padding to skirmish UI
- Initialize FocusedCell with map dimensions and start near the map centre. - Store max rows/cols in FocusedCell and clamp moves to these bounds. - Scroll actions now adjust the corresponding offset and also move the focused cell, keeping navigation consistent. - Zoom actions modify the vertical offset to keep the view centered after changing zoom levels. - Cell widget now uses a Padding widget with dynamic top padding based on the area height.
This commit is contained in:
+6
-1
@@ -32,7 +32,12 @@ impl GameStates {
|
||||
map_height: args.map_height as usize,
|
||||
board_cells: Vec::new(),
|
||||
zoom_level: args.zoom_level,
|
||||
focused_cell: FocusedCell::new(0, 0),
|
||||
focused_cell: FocusedCell::new(
|
||||
(args.map_height / 2) as usize - 1,
|
||||
2,
|
||||
args.map_height as usize,
|
||||
args.map_width as usize,
|
||||
),
|
||||
},
|
||||
perk_decks: PerkDecksState {
|
||||
id: 2,
|
||||
|
||||
Reference in New Issue
Block a user