generated from GarandPLG/rust-flake-template
Add zoom support and dynamic keybinding layout
Introduce ZoomIn/ZoomOut actions and a Zoom group with corresponding keybindings. Add a CLI option to set the initial zoom level and a ZoomLevel enum. Expose a utility to compute the largest keybinding group size for layout sizing. Refactor board widget to adjust cell dimensions based on zoom level and simplify offset calculations. Update views to use the new layout sizing helper and integrate zoom handling in skirmish logic.
This commit is contained in:
1 parent
edf491457e
commit
1d1dc0f2f7
11 files changed
+145
-49
No files matched your search
+14
-12
@@ -1,6 +1,6 @@
|
||||
use crate::app::{
|
||||
App,
|
||||
keybindings::Action,
|
||||
keybindings::{Action, count_largest_group},
|
||||
widgets::{BoardWidget, KeybindingsWidget},
|
||||
};
|
||||
use ratatui::{
|
||||
@@ -12,10 +12,22 @@ use ratatui::{
|
||||
};
|
||||
|
||||
pub fn skirmish_view(app: &mut App, area: Rect, buf: &mut Buffer) {
|
||||
let actions: Vec<Action> = vec![
|
||||
Action::ScrollUp,
|
||||
Action::ScrollDown,
|
||||
Action::ScrollLeft,
|
||||
Action::ScrollRight,
|
||||
Action::ZoomIn,
|
||||
Action::ZoomOut,
|
||||
Action::Quit,
|
||||
Action::Quit2,
|
||||
Action::Esc,
|
||||
];
|
||||
|
||||
let vertical_layout: Layout = Layout::vertical([
|
||||
Constraint::Length(4),
|
||||
Constraint::Fill(1),
|
||||
Constraint::Length(6),
|
||||
Constraint::Length(count_largest_group(&actions) + 2),
|
||||
]);
|
||||
|
||||
let [title_area, main_area, keybindings_area] = vertical_layout.areas(area);
|
||||
@@ -78,16 +90,6 @@ pub fn skirmish_view(app: &mut App, area: Rect, buf: &mut Buffer) {
|
||||
}
|
||||
|
||||
{
|
||||
let actions: Vec<Action> = vec![
|
||||
Action::ScrollUp,
|
||||
Action::ScrollDown,
|
||||
Action::ScrollLeft,
|
||||
Action::ScrollRight,
|
||||
Action::Quit,
|
||||
Action::Quit2,
|
||||
Action::Esc,
|
||||
];
|
||||
|
||||
KeybindingsWidget::new(actions).render(keybindings_area, buf);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user