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 ---
|
// --- Button Style Helpers ---
|
||||||
let get_button_style = |button_focus: AddTableFocus, current_focus| {
|
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 is_focused = current_focus == button_focus;
|
||||||
let base_style = Style::default().fg(if is_focused {
|
let base_style = Style::default().fg(if is_focused {
|
||||||
theme.bg // Reversed text color
|
theme.highlight // Highlighted text color
|
||||||
} else {
|
} else {
|
||||||
theme.secondary // Normal text color
|
theme.secondary // Normal text color
|
||||||
});
|
});
|
||||||
if is_focused {
|
if is_focused {
|
||||||
base_style
|
base_style.add_modifier(Modifier::BOLD)
|
||||||
.add_modifier(Modifier::BOLD)
|
|
||||||
.bg(theme.highlight) // Reversed background
|
|
||||||
} else {
|
} else {
|
||||||
base_style
|
base_style
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let get_button_border_style = |button_focus: AddTableFocus, current_focus| {
|
// Updated signature to accept bool and theme
|
||||||
if current_focus == button_focus {
|
let get_button_border_style = |is_focused: bool, theme: &Theme| {
|
||||||
|
if is_focused {
|
||||||
Style::default().fg(theme.highlight)
|
Style::default().fg(theme.highlight)
|
||||||
} else {
|
} else {
|
||||||
Style::default().fg(theme.secondary)
|
Style::default().fg(theme.secondary)
|
||||||
@@ -271,50 +271,22 @@ pub fn render_add_table(
|
|||||||
};
|
};
|
||||||
|
|
||||||
// --- Add Button Rendering ---
|
// --- Add Button Rendering ---
|
||||||
let is_add_button_focused =
|
// Determine if the add button is focused
|
||||||
add_table_state.current_focus == AddTableFocus::AddColumnButton;
|
let is_add_button_focused = add_table_state.current_focus == AddTableFocus::AddColumnButton;
|
||||||
|
|
||||||
// 1. Define the block with ONLY border styling (no background here)
|
// Create the Add button Paragraph widget
|
||||||
let add_button_block = Block::default()
|
let add_button = Paragraph::new(" Add ")
|
||||||
.borders(Borders::ALL)
|
.style(get_button_style(AddTableFocus::AddColumnButton, add_table_state.current_focus)) // Use existing closure
|
||||||
.border_type(BorderType::Rounded)
|
.alignment(Alignment::Center)
|
||||||
.border_style(if is_add_button_focused {
|
.block(
|
||||||
Style::default().fg(theme.highlight) // Highlighted border
|
Block::default()
|
||||||
} else {
|
.borders(Borders::ALL)
|
||||||
Style::default().fg(theme.secondary) // Normal border
|
.border_type(BorderType::Rounded)
|
||||||
});
|
.border_style(get_button_border_style(is_add_button_focused, theme)), // Pass bool and theme
|
||||||
// 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);
|
|
||||||
|
|
||||||
|
// Render the button in its designated area
|
||||||
|
f.render_widget(add_button, add_button_area);
|
||||||
|
|
||||||
// --- Indexes Table Rendering ---
|
// --- Indexes Table Rendering ---
|
||||||
let indexes_focused = matches!(add_table_state.current_focus, AddTableFocus::IndexesTable | AddTableFocus::InsideIndexesTable);
|
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)
|
.borders(Borders::ALL)
|
||||||
.border_type(BorderType::Rounded)
|
.border_type(BorderType::Rounded)
|
||||||
.border_style(get_button_border_style(
|
.border_style(get_button_border_style(
|
||||||
AddTableFocus::SaveButton,
|
add_table_state.current_focus == AddTableFocus::SaveButton, // Pass bool
|
||||||
add_table_state.current_focus,
|
theme,
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
f.render_widget(save_button, bottom_button_chunks[0]);
|
f.render_widget(save_button, bottom_button_chunks[0]);
|
||||||
@@ -443,8 +415,8 @@ pub fn render_add_table(
|
|||||||
.borders(Borders::ALL)
|
.borders(Borders::ALL)
|
||||||
.border_type(BorderType::Rounded)
|
.border_type(BorderType::Rounded)
|
||||||
.border_style(get_button_border_style(
|
.border_style(get_button_border_style(
|
||||||
AddTableFocus::DeleteSelectedButton,
|
add_table_state.current_focus == AddTableFocus::DeleteSelectedButton, // Pass bool
|
||||||
add_table_state.current_focus,
|
theme,
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
f.render_widget(delete_button, bottom_button_chunks[1]);
|
f.render_widget(delete_button, bottom_button_chunks[1]);
|
||||||
@@ -460,8 +432,8 @@ pub fn render_add_table(
|
|||||||
.borders(Borders::ALL)
|
.borders(Borders::ALL)
|
||||||
.border_type(BorderType::Rounded)
|
.border_type(BorderType::Rounded)
|
||||||
.border_style(get_button_border_style(
|
.border_style(get_button_border_style(
|
||||||
AddTableFocus::CancelButton,
|
add_table_state.current_focus == AddTableFocus::CancelButton, // Pass bool
|
||||||
add_table_state.current_focus,
|
theme,
|
||||||
)),
|
)),
|
||||||
);
|
);
|
||||||
f.render_widget(cancel_button, bottom_button_chunks[2]);
|
f.render_widget(cancel_button, bottom_button_chunks[2]);
|
||||||
|
|||||||
Reference in New Issue
Block a user