Skip to content

Commit

Permalink
TUI/PaneArray draw_from take refs to items
Browse files Browse the repository at this point in the history
  • Loading branch information
Beinsezii committed Aug 10, 2024
1 parent d3d94e8 commit 7e617dd
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/tui/widgets/filtertreeview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ impl ContainedWidget for FilterTreeView {
self.pane_cache = (new_items, new_highlights);
}

let (items, highlights) = self.pane_cache.clone();
let (items, highlights) = &self.pane_cache;
self.pane_array.draw_from(frame, stylesheet, items, highlights)
}
}
Expand Down
6 changes: 3 additions & 3 deletions src/tui/widgets/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ impl PaneArray {
// # prep_event # }}}

// # draw_from # {{{
pub fn draw_from(&mut self, frame: &mut Frame, stylesheet: StyleSheet, items: Vec<(String, Vec<String>)>, highlights: Vec<Vec<String>>) {
pub fn draw_from(&mut self, frame: &mut Frame, stylesheet: StyleSheet, items: &Vec<(String, Vec<String>)>, highlights: &Vec<Vec<String>>) {
// clamp index
self.index = self.index.min(items.len().saturating_sub(1));

Expand Down Expand Up @@ -358,7 +358,7 @@ impl PaneArray {
frame.render_widget(
List::new(
item.1
.into_iter()
.iter()
.enumerate()
.map(|(n, s)| {
ListItem::new(s.clone()).style(if self.active && num == self.index {
Expand Down Expand Up @@ -391,7 +391,7 @@ impl PaneArray {
.block(
Block::default()
.title(Span::styled(
item.0,
&item.0,
if self.active && num == self.index {
match highlights.get(num).unwrap_or(&vec![]).is_empty() {
true => stylesheet.active,
Expand Down
2 changes: 1 addition & 1 deletion src/tui/widgets/queuetable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ impl ContainedWidget for QueueTable {
items.push(("[unsorted]".to_string(), library.get_taglist("title")))
}

self.pane_array.draw_from(frame, stylesheet, items, highlights);
self.pane_array.draw_from(frame, stylesheet, &items, &highlights);
}
}
// ### impl ContainedWidget }}}
Expand Down

0 comments on commit 7e617dd

Please sign in to comment.