buttons are only border and text colors now in add_table
This commit is contained in:
@@ -248,22 +248,22 @@ pub fn render_add_table(
|
||||
|
||||
// --- Button Style Helpers ---
|
||||
let get_button_style = |button_focus: AddTableFocus, current_focus| {
|
||||
// Only handles text style (FG + Bold) now, no BG
|
||||
let is_focused = current_focus == button_focus;
|
||||
let base_style = Style::default().fg(if is_focused {
|
||||
theme.bg // Reversed text color
|
||||
theme.highlight // Highlighted text color
|
||||
} else {
|
||||
theme.secondary // Normal text color
|
||||
});
|
||||
if is_focused {
|
||||
base_style
|
||||
.add_modifier(Modifier::BOLD)
|
||||
.bg(theme.highlight) // Reversed background
|
||||
base_style.add_modifier(Modifier::BOLD)
|
||||
} else {
|
||||
base_style
|
||||
}
|
||||
};
|
||||
let get_button_border_style = |button_focus: AddTableFocus, current_focus| {
|
||||
if current_focus == button_focus {
|
||||
// Updated signature to accept bool and theme
|
||||
let get_button_border_style = |is_focused: bool, theme: &Theme| {
|
||||
if is_focused {
|
||||
Style::default().fg(theme.highlight)
|
||||
} else {
|
||||
Style::default().fg(theme.secondary)
|
||||
@@ -271,50 +271,22 @@ pub fn render_add_table(
|
||||
};
|
||||
|
||||
// --- Add Button Rendering ---
|
||||
let is_add_button_focused =
|
||||
add_table_state.current_focus == AddTableFocus::AddColumnButton;
|
||||
// Determine if the add button is focused
|
||||
let is_add_button_focused = add_table_state.current_focus == AddTableFocus::AddColumnButton;
|
||||
|
||||
// 1. Define the block with ONLY border styling (no background here)
|
||||
let add_button_block = Block::default()
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded)
|
||||
.border_style(if is_add_button_focused {
|
||||
Style::default().fg(theme.highlight) // Highlighted border
|
||||
} else {
|
||||
Style::default().fg(theme.secondary) // Normal border
|
||||
});
|
||||
// DO NOT add .style(Style::default().bg(...)) here
|
||||
|
||||
// 2. Render the border block first
|
||||
// Need to clone the block because inner() consumes it
|
||||
let inner_add_button_area = add_button_block.clone().inner(add_button_area);
|
||||
f.render_widget(add_button_block, add_button_area);
|
||||
|
||||
// 3. If focused, render a background fill widget INSIDE the inner area
|
||||
if is_add_button_focused {
|
||||
let background_fill = Block::default() // Or Paragraph::new("")
|
||||
.style(Style::default().bg(theme.highlight));
|
||||
f.render_widget(background_fill, inner_add_button_area);
|
||||
}
|
||||
|
||||
// 4. Define the paragraph text style (FG color and bold only)
|
||||
let mut add_button_text_style = Style::default().fg(if is_add_button_focused {
|
||||
theme.bg // Reversed text color for contrast on highlight bg
|
||||
} else {
|
||||
theme.secondary // Normal text color
|
||||
});
|
||||
|
||||
if is_add_button_focused {
|
||||
add_button_text_style = add_button_text_style.add_modifier(Modifier::BOLD);
|
||||
}
|
||||
|
||||
let add_button_paragraph = Paragraph::new(" Add ")
|
||||
.style(add_button_text_style) // Style without BG
|
||||
.alignment(Alignment::Center);
|
||||
|
||||
// 5. Render the text paragraph inside the inner area (on top of the background fill)
|
||||
f.render_widget(add_button_paragraph, inner_add_button_area);
|
||||
// Create the Add button Paragraph widget
|
||||
let add_button = Paragraph::new(" Add ")
|
||||
.style(get_button_style(AddTableFocus::AddColumnButton, add_table_state.current_focus)) // Use existing closure
|
||||
.alignment(Alignment::Center)
|
||||
.block(
|
||||
Block::default()
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded)
|
||||
.border_style(get_button_border_style(is_add_button_focused, theme)), // Pass bool and theme
|
||||
);
|
||||
|
||||
// Render the button in its designated area
|
||||
f.render_widget(add_button, add_button_area);
|
||||
|
||||
// --- Indexes Table Rendering ---
|
||||
let indexes_focused = matches!(add_table_state.current_focus, AddTableFocus::IndexesTable | AddTableFocus::InsideIndexesTable);
|
||||
@@ -426,8 +398,8 @@ pub fn render_add_table(
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded)
|
||||
.border_style(get_button_border_style(
|
||||
AddTableFocus::SaveButton,
|
||||
add_table_state.current_focus,
|
||||
add_table_state.current_focus == AddTableFocus::SaveButton, // Pass bool
|
||||
theme,
|
||||
)),
|
||||
);
|
||||
f.render_widget(save_button, bottom_button_chunks[0]);
|
||||
@@ -443,8 +415,8 @@ pub fn render_add_table(
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded)
|
||||
.border_style(get_button_border_style(
|
||||
AddTableFocus::DeleteSelectedButton,
|
||||
add_table_state.current_focus,
|
||||
add_table_state.current_focus == AddTableFocus::DeleteSelectedButton, // Pass bool
|
||||
theme,
|
||||
)),
|
||||
);
|
||||
f.render_widget(delete_button, bottom_button_chunks[1]);
|
||||
@@ -460,8 +432,8 @@ pub fn render_add_table(
|
||||
.borders(Borders::ALL)
|
||||
.border_type(BorderType::Rounded)
|
||||
.border_style(get_button_border_style(
|
||||
AddTableFocus::CancelButton,
|
||||
add_table_state.current_focus,
|
||||
add_table_state.current_focus == AddTableFocus::CancelButton, // Pass bool
|
||||
theme,
|
||||
)),
|
||||
);
|
||||
f.render_widget(cancel_button, bottom_button_chunks[2]);
|
||||
|
||||
Reference in New Issue
Block a user