Feat: begin slight refactoring

This commit is contained in:
2026-02-01 12:38:48 +01:00
parent 5b4a6ddd14
commit c356aebfde
39 changed files with 4699 additions and 3168 deletions

View File

@@ -1,4 +1,4 @@
use crate::theme::meter;
use crate::theme;
use ratatui::buffer::Buffer;
use ratatui::layout::Rect;
use ratatui::style::Color;
@@ -30,13 +30,13 @@ impl VuMeter {
(db - DB_MIN) / DB_RANGE
}
fn row_to_color(row_position: f32) -> Color {
fn row_to_color(row_position: f32, colors: &theme::ThemeColors) -> Color {
if row_position > 0.9 {
meter::HIGH
colors.meter.high
} else if row_position > 0.75 {
meter::MID
colors.meter.mid
} else {
meter::LOW
colors.meter.low
}
}
}
@@ -47,6 +47,7 @@ impl Widget for VuMeter {
return;
}
let colors = theme::get();
let height = area.height as usize;
let half_width = area.width / 2;
let gap = 1u16;
@@ -62,7 +63,7 @@ impl Widget for VuMeter {
for row in 0..height {
let y = area.y + area.height - 1 - row as u16;
let row_position = (row as f32 + 0.5) / height as f32;
let color = Self::row_to_color(row_position);
let color = Self::row_to_color(row_position, &colors);
for col in 0..half_width.saturating_sub(gap) {
let x = area.x + col;