fix: row parameter now affects window height

This commit is contained in:
2024-05-22 00:50:30 +02:00
parent 84b186451b
commit bda23ba16e

View File

@@ -12,7 +12,7 @@ use sdl2::{
}; };
use crate::{ use crate::{
config::{RunnerMenuSettings, FONT_POINT_SIZE, LINE_SPACING, MAX_ITEM_DISPLAY_COUNT, PADDING}, config::{RunnerMenuSettings, FONT_POINT_SIZE, LINE_SPACING, PADDING},
utils::color_from_hex, utils::color_from_hex,
}; };
@@ -28,7 +28,7 @@ pub struct Runner {
} }
impl Runner { impl Runner {
pub fn new(prompt: String, executables: Vec<String>, colors: RunnerMenuSettings) -> Self { pub fn new(prompt: String, executables: Vec<String>, settings: RunnerMenuSettings) -> Self {
let context = sdl2::init().expect("Error creating SDL context"); let context = sdl2::init().expect("Error creating SDL context");
let ttf = ttf::init().expect("Error creating SDL TTF context"); let ttf = ttf::init().expect("Error creating SDL TTF context");
@@ -42,9 +42,8 @@ impl Runner {
.load_font(font_path.clone(), FONT_POINT_SIZE) .load_font(font_path.clone(), FONT_POINT_SIZE)
.expect(&format!("Error loading font {}", font_path)); .expect(&format!("Error loading font {}", font_path));
window_height = (PADDING window_height =
+ ((font.height() as u16 + LINE_SPACING) * (1 + MAX_ITEM_DISPLAY_COUNT))) (PADDING + ((font.height() as u16 + LINE_SPACING) * (1 + settings.rows))).into();
.into();
} }
let video = context.video().expect("Error initializing SDL video"); let video = context.video().expect("Error initializing SDL video");
@@ -73,7 +72,7 @@ impl Runner {
input: String::from(""), input: String::from(""),
ttf, ttf,
window_size, window_size,
settings: colors, settings,
} }
} }