Remove rendering dependence on self
This commit is contained in:
parent
883d6170a8
commit
5bda7298ab
@ -720,12 +720,15 @@ impl<MH: IMusicHoard> Ui<MH> {
|
|||||||
Self::render_info_widget("Track info", st.info, st.active, ar.info, fr);
|
Self::render_info_widget("Track info", st.info, st.active, ar.info, fr);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_collection<B: Backend>(&mut self, frame: &mut Frame<'_, B>) {
|
fn render_collection<B: Backend>(
|
||||||
let active = self.selection.active;
|
artists: &Collection,
|
||||||
|
selection: &mut Selection,
|
||||||
|
frame: &mut Frame<'_, B>,
|
||||||
|
) {
|
||||||
|
let active = selection.active;
|
||||||
let areas = FrameArea::new(frame.size());
|
let areas = FrameArea::new(frame.size());
|
||||||
|
|
||||||
let artists = self.music_hoard.get_collection();
|
let artist_selection = &mut selection.artist;
|
||||||
let artist_selection = &mut self.selection.artist;
|
|
||||||
let artist_state = ArtistState::new(
|
let artist_state = ArtistState::new(
|
||||||
active == Category::Artist,
|
active == Category::Artist,
|
||||||
artists,
|
artists,
|
||||||
@ -765,17 +768,20 @@ impl<MH: IMusicHoard> Ui<MH> {
|
|||||||
Self::render_track_column(track_state, areas.track, frame);
|
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 area = OverlayBuilder::default().build(frame.size());
|
||||||
|
|
||||||
let artists = self.music_hoard.get_collection();
|
let artist_selection = &mut selection.artist;
|
||||||
let artist_selection = &mut self.selection.artist;
|
|
||||||
let artist_overlay = ArtistOverlay::new(artists, &artist_selection.state);
|
let artist_overlay = ArtistOverlay::new(artists, &artist_selection.state);
|
||||||
|
|
||||||
Self::render_overlay_widget("Artist", artist_overlay.properties, area, frame);
|
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()
|
let area = OverlayBuilder::default()
|
||||||
.with_width(OverlaySize::Value(39))
|
.with_width(OverlaySize::Value(39))
|
||||||
.with_height(OverlaySize::Value(4))
|
.with_height(OverlaySize::Value(4))
|
||||||
@ -790,11 +796,7 @@ impl<MH: IMusicHoard> Ui<MH> {
|
|||||||
Self::render_overlay_widget("Reload", reload_text, area, frame);
|
Self::render_overlay_widget("Reload", reload_text, area, frame);
|
||||||
}
|
}
|
||||||
|
|
||||||
fn render_error_overlay<S: AsRef<str>, B: Backend>(
|
fn render_error_overlay<S: AsRef<str>, B: Backend>(msg: S, frame: &mut Frame<'_, B>) {
|
||||||
&mut self,
|
|
||||||
frame: &mut Frame<'_, B>,
|
|
||||||
msg: S,
|
|
||||||
) {
|
|
||||||
let area = OverlayBuilder::default()
|
let area = OverlayBuilder::default()
|
||||||
.with_height(OverlaySize::Value(4))
|
.with_height(OverlaySize::Value(4))
|
||||||
.build(frame.size());
|
.build(frame.size());
|
||||||
@ -803,6 +805,7 @@ impl<MH: IMusicHoard> Ui<MH> {
|
|||||||
.alignment(Alignment::Center)
|
.alignment(Alignment::Center)
|
||||||
.wrap(Wrap { trim: true });
|
.wrap(Wrap { trim: true });
|
||||||
|
|
||||||
|
// FIXME: highlight with red
|
||||||
Self::render_overlay_widget("Error", error_text, area, frame);
|
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>) {
|
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 {
|
match self.state {
|
||||||
UiState::Info(_) => self.render_info_overlay(frame),
|
UiState::Info(_) => Self::render_info_overlay(collection, selection, frame),
|
||||||
UiState::Reload(_) => self.render_reload_overlay(frame),
|
UiState::Reload(_) => Self::render_reload_overlay(frame),
|
||||||
// FIXME: Remove the clone
|
UiState::Error(ref msg) => Self::render_error_overlay(msg, frame),
|
||||||
UiState::Error(ref msg) => self.render_error_overlay(frame, msg.clone()),
|
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user