feat: line spacing argument
This commit is contained in:
@@ -2,7 +2,7 @@ use clap::Parser;
|
|||||||
|
|
||||||
use crate::config::{
|
use crate::config::{
|
||||||
BACKGROUND_COLOR, BACKGROUND_COLOR_ACTIVE, FONT_COLOR, FONT_COLOR_ACTIVE, FONT_POINT_SIZE,
|
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)]
|
#[derive(Parser, Debug)]
|
||||||
@@ -28,4 +28,7 @@ pub struct Arguments {
|
|||||||
|
|
||||||
#[arg(long, help = "The menu's font size", default_value_t = FONT_POINT_SIZE)]
|
#[arg(long, help = "The menu's font size", default_value_t = FONT_POINT_SIZE)]
|
||||||
pub font_size: u16,
|
pub font_size: u16,
|
||||||
|
|
||||||
|
#[arg(long, help = "The spacing between items", default_value_t = LINE_SPACING)]
|
||||||
|
pub line_spacing: u16,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,4 +16,5 @@ pub struct RunnerMenuSettings {
|
|||||||
pub background_color_active: String,
|
pub background_color_active: String,
|
||||||
pub rows: u16,
|
pub rows: u16,
|
||||||
pub font_size: u16,
|
pub font_size: u16,
|
||||||
|
pub line_spacing: u16,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ fn main() -> Result<(), Box<dyn Error>> {
|
|||||||
background_color_active: args.background_color_active,
|
background_color_active: args.background_color_active,
|
||||||
rows: args.rows,
|
rows: args.rows,
|
||||||
font_size: args.font_size,
|
font_size: args.font_size,
|
||||||
|
line_spacing: args.line_spacing,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ use sdl2::{
|
|||||||
};
|
};
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
config::{RunnerMenuSettings, LINE_SPACING, PADDING},
|
config::{RunnerMenuSettings, PADDING},
|
||||||
utils::color_from_hex,
|
utils::color_from_hex,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -42,8 +42,9 @@ impl Runner {
|
|||||||
.load_font(font_path.clone(), settings.font_size)
|
.load_font(font_path.clone(), settings.font_size)
|
||||||
.expect(&format!("Error loading font {}", font_path));
|
.expect(&format!("Error loading font {}", font_path));
|
||||||
|
|
||||||
window_height =
|
window_height = (PADDING
|
||||||
(PADDING + ((font.height() as u16 + LINE_SPACING) * (1 + settings.rows))).into();
|
+ ((font.height() as u16 + settings.line_spacing) * (1 + settings.rows)))
|
||||||
|
.into();
|
||||||
}
|
}
|
||||||
|
|
||||||
let video = context.video().expect("Error initializing SDL video");
|
let video = context.video().expect("Error initializing SDL video");
|
||||||
@@ -218,7 +219,8 @@ impl Runner {
|
|||||||
let mut display_count: u16 = 0;
|
let mut display_count: u16 = 0;
|
||||||
|
|
||||||
for i in start..end {
|
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
|
let surface = font
|
||||||
.render(&filtered_executables[i as usize])
|
.render(&filtered_executables[i as usize])
|
||||||
|
|||||||
Reference in New Issue
Block a user