|
|
|
|
@@ -28,52 +28,47 @@ pub fn render(frame: &mut Frame, state: &mut AppState, player: &mut Player) -> (
|
|
|
|
|
])
|
|
|
|
|
.split(frame.area());
|
|
|
|
|
|
|
|
|
|
// Always use tab mode - show only the focused panel
|
|
|
|
|
let tab_mode = true;
|
|
|
|
|
// Split main content into files (70%) and playlist (30%)
|
|
|
|
|
let content_chunks = Layout::default()
|
|
|
|
|
.direction(Direction::Vertical)
|
|
|
|
|
.constraints([
|
|
|
|
|
Constraint::Percentage(70), // Files panel
|
|
|
|
|
Constraint::Percentage(30), // Playlist panel
|
|
|
|
|
])
|
|
|
|
|
.split(main_chunks[1]);
|
|
|
|
|
|
|
|
|
|
// Build the title with focused panel in bold
|
|
|
|
|
let file_style = if !state.focus_playlist {
|
|
|
|
|
Style::default().fg(Theme::bright_foreground()).add_modifier(Modifier::BOLD)
|
|
|
|
|
} else {
|
|
|
|
|
Style::default().fg(Theme::bright_foreground())
|
|
|
|
|
};
|
|
|
|
|
// Build the files panel title
|
|
|
|
|
let file_style = Style::default().fg(Theme::bright_foreground());
|
|
|
|
|
|
|
|
|
|
let playlist_style = if state.focus_playlist {
|
|
|
|
|
Style::default().fg(Theme::bright_foreground()).add_modifier(Modifier::BOLD)
|
|
|
|
|
} else {
|
|
|
|
|
Style::default().fg(Theme::bright_foreground())
|
|
|
|
|
};
|
|
|
|
|
let files_block = Block::default()
|
|
|
|
|
.borders(Borders::ALL)
|
|
|
|
|
.title(Span::styled("files", file_style))
|
|
|
|
|
.style(Theme::widget_border_style());
|
|
|
|
|
|
|
|
|
|
// Build the playlist panel title
|
|
|
|
|
let playlist_style = Style::default().fg(Theme::bright_foreground());
|
|
|
|
|
|
|
|
|
|
// Add playlist counter
|
|
|
|
|
let playlist_text = if !state.playlist.is_empty() {
|
|
|
|
|
format!("playlist [{}/{}]", state.playlist_index + 1, state.playlist.len())
|
|
|
|
|
} else {
|
|
|
|
|
"playlist (empty)".to_string()
|
|
|
|
|
"playlist".to_string()
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let title = Line::from(vec![
|
|
|
|
|
Span::styled("files", file_style),
|
|
|
|
|
Span::raw(" | "),
|
|
|
|
|
Span::styled(playlist_text, playlist_style),
|
|
|
|
|
]);
|
|
|
|
|
|
|
|
|
|
// Create one border around the entire content area with fixed gray border
|
|
|
|
|
let main_block = Block::default()
|
|
|
|
|
let playlist_block = Block::default()
|
|
|
|
|
.borders(Borders::ALL)
|
|
|
|
|
.title(title)
|
|
|
|
|
.title(Span::styled(playlist_text, playlist_style))
|
|
|
|
|
.style(Theme::widget_border_style());
|
|
|
|
|
|
|
|
|
|
let inner_area = main_block.inner(main_chunks[1]);
|
|
|
|
|
let files_inner = files_block.inner(content_chunks[0]);
|
|
|
|
|
let playlist_inner = playlist_block.inner(content_chunks[1]);
|
|
|
|
|
|
|
|
|
|
render_title_bar(frame, state, player, main_chunks[0]);
|
|
|
|
|
frame.render_widget(main_block, main_chunks[1]);
|
|
|
|
|
|
|
|
|
|
// Tab mode - show only focused panel
|
|
|
|
|
if state.focus_playlist {
|
|
|
|
|
render_right_panel(frame, state, inner_area, tab_mode);
|
|
|
|
|
} else {
|
|
|
|
|
render_file_panel(frame, state, inner_area, tab_mode);
|
|
|
|
|
}
|
|
|
|
|
frame.render_widget(files_block, content_chunks[0]);
|
|
|
|
|
frame.render_widget(playlist_block, content_chunks[1]);
|
|
|
|
|
|
|
|
|
|
render_file_panel(frame, state, files_inner, false);
|
|
|
|
|
render_right_panel(frame, state, playlist_inner, false);
|
|
|
|
|
|
|
|
|
|
render_status_bar(frame, state, player, main_chunks[2]);
|
|
|
|
|
|
|
|
|
|
@@ -93,12 +88,7 @@ pub fn render(frame: &mut Frame, state: &mut AppState, player: &mut Player) -> (
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Return title bar area, file panel area, and playlist area for mouse event handling
|
|
|
|
|
// Use main_chunks[1] (full area) so mouse coordinates align properly
|
|
|
|
|
if state.focus_playlist {
|
|
|
|
|
(main_chunks[0], Rect::default(), main_chunks[1])
|
|
|
|
|
} else {
|
|
|
|
|
(main_chunks[0], main_chunks[1], Rect::default())
|
|
|
|
|
}
|
|
|
|
|
(main_chunks[0], content_chunks[0], content_chunks[1])
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
fn highlight_search_matches<'a>(text: &str, query: &str, is_selected: bool) -> Vec<Span<'a>> {
|
|
|
|
|
@@ -239,15 +229,30 @@ fn render_file_panel(frame: &mut Frame, state: &mut AppState, area: Rect, _tab_m
|
|
|
|
|
|
|
|
|
|
let suffix = if item.is_dir { "/" } else { "" };
|
|
|
|
|
|
|
|
|
|
// Check if item is in playlist (for files) or contains playlist items (for folders)
|
|
|
|
|
let in_playlist = if item.is_dir {
|
|
|
|
|
state.playlist.iter().any(|p| p.starts_with(&item.path))
|
|
|
|
|
} else {
|
|
|
|
|
state.playlist.contains(&item.path)
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
let base_style = if is_selected {
|
|
|
|
|
// Selection bar: yellow/orange when in search (typing or viewing results), blue otherwise
|
|
|
|
|
if in_search {
|
|
|
|
|
let style = if in_search {
|
|
|
|
|
Theme::search_selected()
|
|
|
|
|
} else {
|
|
|
|
|
Theme::selected()
|
|
|
|
|
};
|
|
|
|
|
// Bold if item is in playlist
|
|
|
|
|
if in_playlist {
|
|
|
|
|
style.add_modifier(ratatui::style::Modifier::BOLD)
|
|
|
|
|
} else {
|
|
|
|
|
style
|
|
|
|
|
}
|
|
|
|
|
} else if state.marked_files.contains(&item.path) {
|
|
|
|
|
Theme::marked()
|
|
|
|
|
} else if in_playlist {
|
|
|
|
|
Theme::in_playlist()
|
|
|
|
|
} else {
|
|
|
|
|
Theme::secondary()
|
|
|
|
|
};
|
|
|
|
|
|