mirror of
https://github.com/figsoda/mmtc
synced 2024-11-21 22:53:02 +00:00
add QueueTitleExist, fix QueueFile
This commit is contained in:
parent
b131fa9776
commit
cd646e7914
4 changed files with 18 additions and 5 deletions
4
mmtc.ron
4
mmtc.ron
|
@ -21,8 +21,8 @@ Config(
|
||||||
Min(0, Queue([
|
Min(0, Queue([
|
||||||
Column(
|
Column(
|
||||||
item: Ratio(12, If(QueueCurrent,
|
item: Ratio(12, If(QueueCurrent,
|
||||||
Styled([Italic], QueueTitle),
|
Styled([Italic], If(QueueTitleExist, QueueTitle, QueueFile)),
|
||||||
QueueTitle,
|
If(QueueTitleExist, QueueTitle, QueueFile),
|
||||||
)),
|
)),
|
||||||
style: [Fg(Indexed(75))],
|
style: [Fg(Indexed(75))],
|
||||||
selected_style: [Fg(Black), Bg(Indexed(75)), Bold],
|
selected_style: [Fg(Black), Bg(Indexed(75)), Bold],
|
||||||
|
|
|
@ -119,6 +119,7 @@ pub enum Condition {
|
||||||
TitleExist,
|
TitleExist,
|
||||||
ArtistExist,
|
ArtistExist,
|
||||||
AlbumExist,
|
AlbumExist,
|
||||||
|
QueueTitleExist,
|
||||||
QueueCurrent,
|
QueueCurrent,
|
||||||
Selected,
|
Selected,
|
||||||
Searching,
|
Searching,
|
||||||
|
|
|
@ -87,9 +87,17 @@ pub fn layout() -> Widget {
|
||||||
Condition::QueueCurrent,
|
Condition::QueueCurrent,
|
||||||
Box::new(Texts::Styled(
|
Box::new(Texts::Styled(
|
||||||
vec![AddStyle::Italic],
|
vec![AddStyle::Italic],
|
||||||
Box::new(Texts::QueueTitle),
|
Box::new(Texts::If(
|
||||||
|
Condition::QueueTitleExist,
|
||||||
|
Box::new(Texts::QueueTitle),
|
||||||
|
Some(Box::new(Texts::QueueFile)),
|
||||||
|
)),
|
||||||
)),
|
)),
|
||||||
Some(Box::new(Texts::QueueTitle)),
|
Some(Box::new(Texts::If(
|
||||||
|
Condition::QueueTitleExist,
|
||||||
|
Box::new(Texts::QueueTitle),
|
||||||
|
Some(Box::new(Texts::QueueFile)),
|
||||||
|
))),
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
style: vec![AddStyle::Fg(Color::Indexed(75))],
|
style: vec![AddStyle::Fg(Color::Indexed(75))],
|
||||||
|
|
|
@ -28,6 +28,7 @@ struct FlattenState<'a, 'b> {
|
||||||
struct ConditionState<'a> {
|
struct ConditionState<'a> {
|
||||||
status: &'a Status,
|
status: &'a Status,
|
||||||
current_track: Option<&'a Track>,
|
current_track: Option<&'a Track>,
|
||||||
|
queue_track: Option<&'a Track>,
|
||||||
queue_current: bool,
|
queue_current: bool,
|
||||||
selected: bool,
|
selected: bool,
|
||||||
searching: bool,
|
searching: bool,
|
||||||
|
@ -343,7 +344,7 @@ fn _flatten<'a>(spans: &mut Vec<Span<'a>>, xs: &'a Texts, s: &FlattenState<'a, '
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Texts::QueueFile => {
|
Texts::QueueFile => {
|
||||||
if let Some(Track { file, .. }) = s.current_track {
|
if let Some(Track { file, .. }) = s.queue_track {
|
||||||
spans.push(Span::styled(file, *s.style));
|
spans.push(Span::styled(file, *s.style));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -398,6 +399,7 @@ fn _flatten<'a>(spans: &mut Vec<Span<'a>>, xs: &'a Texts, s: &FlattenState<'a, '
|
||||||
&ConditionState {
|
&ConditionState {
|
||||||
status: s.status,
|
status: s.status,
|
||||||
current_track: s.current_track,
|
current_track: s.current_track,
|
||||||
|
queue_track: s.queue_track,
|
||||||
queue_current: s.queue_current,
|
queue_current: s.queue_current,
|
||||||
selected: s.selected,
|
selected: s.selected,
|
||||||
searching: s.searching,
|
searching: s.searching,
|
||||||
|
@ -417,6 +419,7 @@ fn _flatten<'a>(spans: &mut Vec<Span<'a>>, xs: &'a Texts, s: &FlattenState<'a, '
|
||||||
&ConditionState {
|
&ConditionState {
|
||||||
status: s.status,
|
status: s.status,
|
||||||
current_track: s.current_track,
|
current_track: s.current_track,
|
||||||
|
queue_track: s.queue_track,
|
||||||
queue_current: s.queue_current,
|
queue_current: s.queue_current,
|
||||||
selected: s.selected,
|
selected: s.selected,
|
||||||
searching: s.searching,
|
searching: s.searching,
|
||||||
|
@ -517,6 +520,7 @@ fn eval_cond(cond: &Condition, s: &ConditionState) -> bool {
|
||||||
})
|
})
|
||||||
),
|
),
|
||||||
Condition::AlbumExist => matches!(s.current_track, Some(Track { album: Some(_), .. })),
|
Condition::AlbumExist => matches!(s.current_track, Some(Track { album: Some(_), .. })),
|
||||||
|
Condition::QueueTitleExist => matches!(s.queue_track, Some(Track { title: Some(_), .. })),
|
||||||
Condition::QueueCurrent => s.queue_current,
|
Condition::QueueCurrent => s.queue_current,
|
||||||
Condition::Selected => s.selected,
|
Condition::Selected => s.selected,
|
||||||
Condition::Searching => s.searching,
|
Condition::Searching => s.searching,
|
||||||
|
|
Loading…
Reference in a new issue