Add shortcut to reload database and/or library #116

Merged
wojtek merged 14 commits from 105---add-shortcut-to-reload-database-and/or-library into main 2024-02-03 14:32:13 +01:00
Showing only changes of commit 5bda7298ab - Show all commits

View File

@ -720,12 +720,15 @@ impl<MH: IMusicHoard> Ui<MH> {
Self::render_info_widget("Track info", st.info, st.active, ar.info, fr);
}
fn render_collection<B: Backend>(&mut self, frame: &mut Frame<'_, B>) {
let active = self.selection.active;
fn render_collection<B: Backend>(
artists: &Collection,
selection: &mut Selection,
frame: &mut Frame<'_, B>,
) {
let active = selection.active;
let areas = FrameArea::new(frame.size());
let artists = self.music_hoard.get_collection();
let artist_selection = &mut self.selection.artist;
let artist_selection = &mut selection.artist;
let artist_state = ArtistState::new(
active == Category::Artist,
artists,
@ -765,17 +768,20 @@ impl<MH: IMusicHoard> Ui<MH> {
Self::render_track_column(track_state, areas.track, frame);
}
fn render_info_overlay<B: Backend>(&mut self, frame: &mut Frame<'_, B>) {
fn render_info_overlay<B: Backend>(
artists: &Collection,
selection: &mut Selection,
frame: &mut Frame<'_, B>,
) {
let area = OverlayBuilder::default().build(frame.size());
let artists = self.music_hoard.get_collection();
let artist_selection = &mut self.selection.artist;
let artist_selection = &mut selection.artist;
let artist_overlay = ArtistOverlay::new(artists, &artist_selection.state);
Self::render_overlay_widget("Artist", artist_overlay.properties, area, frame);
}
fn render_reload_overlay<B: Backend>(&mut self, frame: &mut Frame<'_, B>) {
fn render_reload_overlay<B: Backend>(frame: &mut Frame<'_, B>) {
let area = OverlayBuilder::default()
.with_width(OverlaySize::Value(39))
.with_height(OverlaySize::Value(4))
@ -790,11 +796,7 @@ impl<MH: IMusicHoard> Ui<MH> {
Self::render_overlay_widget("Reload", reload_text, area, frame);
}
fn render_error_overlay<S: AsRef<str>, B: Backend>(
&mut self,
frame: &mut Frame<'_, B>,
msg: S,
) {
fn render_error_overlay<S: AsRef<str>, B: Backend>(msg: S, frame: &mut Frame<'_, B>) {
let area = OverlayBuilder::default()
.with_height(OverlaySize::Value(4))
.build(frame.size());
@ -803,6 +805,7 @@ impl<MH: IMusicHoard> Ui<MH> {
.alignment(Alignment::Center)
.wrap(Wrap { trim: true });
// FIXME: highlight with red
Self::render_overlay_widget("Error", error_text, area, frame);
}
}
@ -835,12 +838,14 @@ impl<MH: IMusicHoard> IUi for Ui<MH> {
}
fn render<B: Backend>(&mut self, frame: &mut Frame<'_, B>) {
self.render_collection(frame);
let collection: &Collection = &self.music_hoard.get_collection();
let selection: &mut Selection = &mut self.selection;
Self::render_collection(collection, selection, frame);
match self.state {
UiState::Info(_) => self.render_info_overlay(frame),
UiState::Reload(_) => self.render_reload_overlay(frame),
// FIXME: Remove the clone
UiState::Error(ref msg) => self.render_error_overlay(frame, msg.clone()),
UiState::Info(_) => Self::render_info_overlay(collection, selection, frame),
UiState::Reload(_) => Self::render_reload_overlay(frame),
UiState::Error(ref msg) => Self::render_error_overlay(msg, frame),
_ => {}
}
}