mirror of
https://github.com/figsoda/mmtc
synced 2024-11-21 14:43: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([
|
||||
Column(
|
||||
item: Ratio(12, If(QueueCurrent,
|
||||
Styled([Italic], QueueTitle),
|
||||
QueueTitle,
|
||||
Styled([Italic], If(QueueTitleExist, QueueTitle, QueueFile)),
|
||||
If(QueueTitleExist, QueueTitle, QueueFile),
|
||||
)),
|
||||
style: [Fg(Indexed(75))],
|
||||
selected_style: [Fg(Black), Bg(Indexed(75)), Bold],
|
||||
|
|
|
@ -119,6 +119,7 @@ pub enum Condition {
|
|||
TitleExist,
|
||||
ArtistExist,
|
||||
AlbumExist,
|
||||
QueueTitleExist,
|
||||
QueueCurrent,
|
||||
Selected,
|
||||
Searching,
|
||||
|
|
|
@ -87,9 +87,17 @@ pub fn layout() -> Widget {
|
|||
Condition::QueueCurrent,
|
||||
Box::new(Texts::Styled(
|
||||
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))],
|
||||
|
|
|
@ -28,6 +28,7 @@ struct FlattenState<'a, 'b> {
|
|||
struct ConditionState<'a> {
|
||||
status: &'a Status,
|
||||
current_track: Option<&'a Track>,
|
||||
queue_track: Option<&'a Track>,
|
||||
queue_current: bool,
|
||||
selected: bool,
|
||||
searching: bool,
|
||||
|
@ -343,7 +344,7 @@ fn _flatten<'a>(spans: &mut Vec<Span<'a>>, xs: &'a Texts, s: &FlattenState<'a, '
|
|||
}
|
||||
}
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
@ -398,6 +399,7 @@ fn _flatten<'a>(spans: &mut Vec<Span<'a>>, xs: &'a Texts, s: &FlattenState<'a, '
|
|||
&ConditionState {
|
||||
status: s.status,
|
||||
current_track: s.current_track,
|
||||
queue_track: s.queue_track,
|
||||
queue_current: s.queue_current,
|
||||
selected: s.selected,
|
||||
searching: s.searching,
|
||||
|
@ -417,6 +419,7 @@ fn _flatten<'a>(spans: &mut Vec<Span<'a>>, xs: &'a Texts, s: &FlattenState<'a, '
|
|||
&ConditionState {
|
||||
status: s.status,
|
||||
current_track: s.current_track,
|
||||
queue_track: s.queue_track,
|
||||
queue_current: s.queue_current,
|
||||
selected: s.selected,
|
||||
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::QueueTitleExist => matches!(s.queue_track, Some(Track { title: Some(_), .. })),
|
||||
Condition::QueueCurrent => s.queue_current,
|
||||
Condition::Selected => s.selected,
|
||||
Condition::Searching => s.searching,
|
||||
|
|
Loading…
Reference in a new issue