Fixing color schemes
This commit is contained in:
@@ -7,13 +7,15 @@ use ratatui::Frame;
|
||||
use crate::app::App;
|
||||
use crate::engine::LinkState;
|
||||
use crate::state::OptionsFocus;
|
||||
use crate::theme::{hint, link_status, modal, ui, values};
|
||||
use crate::theme;
|
||||
|
||||
pub fn render(frame: &mut Frame, app: &App, link: &LinkState, area: Rect) {
|
||||
let theme = theme::get();
|
||||
|
||||
let block = Block::default()
|
||||
.borders(Borders::ALL)
|
||||
.title(" Options ")
|
||||
.border_style(Style::new().fg(modal::INPUT));
|
||||
.border_style(Style::new().fg(theme.modal.input));
|
||||
|
||||
let inner = block.inner(area);
|
||||
frame.render_widget(block, area);
|
||||
@@ -32,11 +34,11 @@ pub fn render(frame: &mut Frame, app: &App, link: &LinkState, area: Rect) {
|
||||
let enabled = link.is_enabled();
|
||||
let peers = link.peers();
|
||||
let (status_text, status_color) = if !enabled {
|
||||
("DISABLED", link_status::DISABLED)
|
||||
("DISABLED", theme.link_status.disabled)
|
||||
} else if peers > 0 {
|
||||
("CONNECTED", link_status::CONNECTED)
|
||||
("CONNECTED", theme.link_status.connected)
|
||||
} else {
|
||||
("LISTENING", link_status::LISTENING)
|
||||
("LISTENING", theme.link_status.listening)
|
||||
};
|
||||
let peer_text = if enabled && peers > 0 {
|
||||
if peers == 1 {
|
||||
@@ -51,14 +53,14 @@ pub fn render(frame: &mut Frame, app: &App, link: &LinkState, area: Rect) {
|
||||
let link_header = Line::from(vec![
|
||||
Span::styled(
|
||||
"ABLETON LINK",
|
||||
Style::new().fg(ui::HEADER).add_modifier(Modifier::BOLD),
|
||||
Style::new().fg(theme.ui.header).add_modifier(Modifier::BOLD),
|
||||
),
|
||||
Span::raw(" "),
|
||||
Span::styled(
|
||||
status_text,
|
||||
Style::new().fg(status_color).add_modifier(Modifier::BOLD),
|
||||
),
|
||||
Span::styled(peer_text, Style::new().fg(ui::TEXT_MUTED)),
|
||||
Span::styled(peer_text, Style::new().fg(theme.ui.text_muted)),
|
||||
]);
|
||||
|
||||
// Prepare values
|
||||
@@ -68,28 +70,37 @@ pub fn render(frame: &mut Frame, app: &App, link: &LinkState, area: Rect) {
|
||||
let beat_str = format!("{:.2}", link.beat());
|
||||
let phase_str = format!("{:.2}", link.phase());
|
||||
|
||||
let tempo_style = Style::new().fg(values::TEMPO).add_modifier(Modifier::BOLD);
|
||||
let value_style = Style::new().fg(values::VALUE);
|
||||
let tempo_style = Style::new().fg(theme.values.tempo).add_modifier(Modifier::BOLD);
|
||||
let value_style = Style::new().fg(theme.values.value);
|
||||
|
||||
// Build flat list of all lines
|
||||
let lines: Vec<Line> = vec![
|
||||
// DISPLAY section (lines 0-7)
|
||||
render_section_header("DISPLAY"),
|
||||
render_divider(content_width),
|
||||
// DISPLAY section (lines 0-8)
|
||||
render_section_header("DISPLAY", &theme),
|
||||
render_divider(content_width, &theme),
|
||||
render_option_line(
|
||||
"Theme",
|
||||
app.ui.color_scheme.label(),
|
||||
focus == OptionsFocus::ColorScheme,
|
||||
&theme,
|
||||
),
|
||||
render_option_line(
|
||||
"Refresh rate",
|
||||
app.audio.config.refresh_rate.label(),
|
||||
focus == OptionsFocus::RefreshRate,
|
||||
&theme,
|
||||
),
|
||||
render_option_line(
|
||||
"Runtime highlight",
|
||||
if app.ui.runtime_highlight { "On" } else { "Off" },
|
||||
focus == OptionsFocus::RuntimeHighlight,
|
||||
&theme,
|
||||
),
|
||||
render_option_line(
|
||||
"Show scope",
|
||||
if app.audio.config.show_scope { "On" } else { "Off" },
|
||||
focus == OptionsFocus::ShowScope,
|
||||
&theme,
|
||||
),
|
||||
render_option_line(
|
||||
"Show spectrum",
|
||||
@@ -99,22 +110,25 @@ pub fn render(frame: &mut Frame, app: &App, link: &LinkState, area: Rect) {
|
||||
"Off"
|
||||
},
|
||||
focus == OptionsFocus::ShowSpectrum,
|
||||
&theme,
|
||||
),
|
||||
render_option_line(
|
||||
"Completion",
|
||||
if app.ui.show_completion { "On" } else { "Off" },
|
||||
focus == OptionsFocus::ShowCompletion,
|
||||
&theme,
|
||||
),
|
||||
render_option_line("Flash brightness", &flash_str, focus == OptionsFocus::FlashBrightness),
|
||||
// Blank line (line 8)
|
||||
render_option_line("Flash brightness", &flash_str, focus == OptionsFocus::FlashBrightness, &theme),
|
||||
// Blank line (line 9)
|
||||
Line::from(""),
|
||||
// ABLETON LINK section (lines 9-14)
|
||||
// ABLETON LINK section (lines 10-15)
|
||||
link_header,
|
||||
render_divider(content_width),
|
||||
render_divider(content_width, &theme),
|
||||
render_option_line(
|
||||
"Enabled",
|
||||
if link.is_enabled() { "On" } else { "Off" },
|
||||
focus == OptionsFocus::LinkEnabled,
|
||||
&theme,
|
||||
),
|
||||
render_option_line(
|
||||
"Start/Stop sync",
|
||||
@@ -124,16 +138,17 @@ pub fn render(frame: &mut Frame, app: &App, link: &LinkState, area: Rect) {
|
||||
"Off"
|
||||
},
|
||||
focus == OptionsFocus::StartStopSync,
|
||||
&theme,
|
||||
),
|
||||
render_option_line("Quantum", &quantum_str, focus == OptionsFocus::Quantum),
|
||||
// Blank line (line 15)
|
||||
render_option_line("Quantum", &quantum_str, focus == OptionsFocus::Quantum, &theme),
|
||||
// Blank line (line 16)
|
||||
Line::from(""),
|
||||
// SESSION section (lines 16-21)
|
||||
render_section_header("SESSION"),
|
||||
render_divider(content_width),
|
||||
render_readonly_line("Tempo", &tempo_str, tempo_style),
|
||||
render_readonly_line("Beat", &beat_str, value_style),
|
||||
render_readonly_line("Phase", &phase_str, value_style),
|
||||
// SESSION section (lines 17-22)
|
||||
render_section_header("SESSION", &theme),
|
||||
render_divider(content_width, &theme),
|
||||
render_readonly_line("Tempo", &tempo_str, tempo_style, &theme),
|
||||
render_readonly_line("Beat", &beat_str, value_style, &theme),
|
||||
render_readonly_line("Phase", &phase_str, value_style, &theme),
|
||||
];
|
||||
|
||||
let total_lines = lines.len();
|
||||
@@ -141,15 +156,16 @@ pub fn render(frame: &mut Frame, app: &App, link: &LinkState, area: Rect) {
|
||||
|
||||
// Map focus to line index
|
||||
let focus_line: usize = match focus {
|
||||
OptionsFocus::RefreshRate => 2,
|
||||
OptionsFocus::RuntimeHighlight => 3,
|
||||
OptionsFocus::ShowScope => 4,
|
||||
OptionsFocus::ShowSpectrum => 5,
|
||||
OptionsFocus::ShowCompletion => 6,
|
||||
OptionsFocus::FlashBrightness => 7,
|
||||
OptionsFocus::LinkEnabled => 11,
|
||||
OptionsFocus::StartStopSync => 12,
|
||||
OptionsFocus::Quantum => 13,
|
||||
OptionsFocus::ColorScheme => 2,
|
||||
OptionsFocus::RefreshRate => 3,
|
||||
OptionsFocus::RuntimeHighlight => 4,
|
||||
OptionsFocus::ShowScope => 5,
|
||||
OptionsFocus::ShowSpectrum => 6,
|
||||
OptionsFocus::ShowCompletion => 7,
|
||||
OptionsFocus::FlashBrightness => 8,
|
||||
OptionsFocus::LinkEnabled => 12,
|
||||
OptionsFocus::StartStopSync => 13,
|
||||
OptionsFocus::Quantum => 14,
|
||||
};
|
||||
|
||||
// Calculate scroll offset to keep focused line visible (centered when possible)
|
||||
@@ -172,7 +188,7 @@ pub fn render(frame: &mut Frame, app: &App, link: &LinkState, area: Rect) {
|
||||
frame.render_widget(Paragraph::new(visible_lines), padded);
|
||||
|
||||
// Render scroll indicators
|
||||
let indicator_style = Style::new().fg(ui::TEXT_DIM);
|
||||
let indicator_style = Style::new().fg(theme.ui.text_dim);
|
||||
let indicator_x = padded.x + padded.width.saturating_sub(1);
|
||||
|
||||
if scroll_offset > 0 {
|
||||
@@ -192,24 +208,24 @@ pub fn render(frame: &mut Frame, app: &App, link: &LinkState, area: Rect) {
|
||||
}
|
||||
}
|
||||
|
||||
fn render_section_header(title: &str) -> Line<'static> {
|
||||
fn render_section_header(title: &str, theme: &theme::ThemeColors) -> Line<'static> {
|
||||
Line::from(Span::styled(
|
||||
title.to_string(),
|
||||
Style::new().fg(ui::HEADER).add_modifier(Modifier::BOLD),
|
||||
Style::new().fg(theme.ui.header).add_modifier(Modifier::BOLD),
|
||||
))
|
||||
}
|
||||
|
||||
fn render_divider(width: usize) -> Line<'static> {
|
||||
fn render_divider(width: usize, theme: &theme::ThemeColors) -> Line<'static> {
|
||||
Line::from(Span::styled(
|
||||
"─".repeat(width),
|
||||
Style::new().fg(ui::BORDER),
|
||||
Style::new().fg(theme.ui.border),
|
||||
))
|
||||
}
|
||||
|
||||
fn render_option_line<'a>(label: &'a str, value: &'a str, focused: bool) -> Line<'a> {
|
||||
let highlight = Style::new().fg(hint::KEY).add_modifier(Modifier::BOLD);
|
||||
let normal = Style::new().fg(ui::TEXT_PRIMARY);
|
||||
let label_style = Style::new().fg(ui::TEXT_MUTED);
|
||||
fn render_option_line<'a>(label: &'a str, value: &'a str, focused: bool, theme: &theme::ThemeColors) -> Line<'a> {
|
||||
let highlight = Style::new().fg(theme.hint.key).add_modifier(Modifier::BOLD);
|
||||
let normal = Style::new().fg(theme.ui.text_primary);
|
||||
let label_style = Style::new().fg(theme.ui.text_muted);
|
||||
|
||||
let prefix = if focused { "> " } else { " " };
|
||||
let prefix_style = if focused { highlight } else { normal };
|
||||
@@ -231,8 +247,8 @@ fn render_option_line<'a>(label: &'a str, value: &'a str, focused: bool) -> Line
|
||||
])
|
||||
}
|
||||
|
||||
fn render_readonly_line<'a>(label: &'a str, value: &'a str, value_style: Style) -> Line<'a> {
|
||||
let label_style = Style::new().fg(ui::TEXT_MUTED);
|
||||
fn render_readonly_line<'a>(label: &'a str, value: &'a str, value_style: Style, theme: &theme::ThemeColors) -> Line<'a> {
|
||||
let label_style = Style::new().fg(theme.ui.text_muted);
|
||||
let label_width = 20;
|
||||
let padded_label = format!("{label:<label_width$}");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user