feat: line spacing argument

This commit is contained in:
2024-05-22 01:12:01 +02:00
parent 715d0d7d5a
commit 60b1682a5a
4 changed files with 12 additions and 5 deletions

View File

@@ -2,7 +2,7 @@ use clap::Parser;
use crate::config::{
BACKGROUND_COLOR, BACKGROUND_COLOR_ACTIVE, FONT_COLOR, FONT_COLOR_ACTIVE, FONT_POINT_SIZE,
MAX_ITEM_DISPLAY_COUNT,
LINE_SPACING, MAX_ITEM_DISPLAY_COUNT,
};
#[derive(Parser, Debug)]
@@ -28,4 +28,7 @@ pub struct Arguments {
#[arg(long, help = "The menu's font size", default_value_t = FONT_POINT_SIZE)]
pub font_size: u16,
#[arg(long, help = "The spacing between items", default_value_t = LINE_SPACING)]
pub line_spacing: u16,
}

View File

@@ -16,4 +16,5 @@ pub struct RunnerMenuSettings {
pub background_color_active: String,
pub rows: u16,
pub font_size: u16,
pub line_spacing: u16,
}

View File

@@ -30,6 +30,7 @@ fn main() -> Result<(), Box<dyn Error>> {
background_color_active: args.background_color_active,
rows: args.rows,
font_size: args.font_size,
line_spacing: args.line_spacing,
},
);

View File

@@ -12,7 +12,7 @@ use sdl2::{
};
use crate::{
config::{RunnerMenuSettings, LINE_SPACING, PADDING},
config::{RunnerMenuSettings, PADDING},
utils::color_from_hex,
};
@@ -42,8 +42,9 @@ impl Runner {
.load_font(font_path.clone(), settings.font_size)
.expect(&format!("Error loading font {}", font_path));
window_height =
(PADDING + ((font.height() as u16 + LINE_SPACING) * (1 + settings.rows))).into();
window_height = (PADDING
+ ((font.height() as u16 + settings.line_spacing) * (1 + settings.rows)))
.into();
}
let video = context.video().expect("Error initializing SDL video");
@@ -218,7 +219,8 @@ impl Runner {
let mut display_count: u16 = 0;
for i in start..end {
let offset = PADDING + (font.height() as u16 + LINE_SPACING) * (display_count + 1);
let offset = PADDING
+ (font.height() as u16 + self.settings.line_spacing) * (display_count + 1);
let surface = font
.render(&filtered_executables[i as usize])