Repository navigation
add play_queue total_time - #1309
Conversation
|
It could benefit from further consideration in I'm playing around with how we present the information in #1317 but a |
|
As a user I have As a matter of fact the old line I am just adding total time is either the library total time or the playlist total time or the queue time depending on which is playing. |
|
If I add an explicit |
Incidentally since the queue isn't "active" until the first track gets pulled from it, it might make more sense to set that condition as (!queue_empty || queue_active). The queue feels different to library vs playlist because it's a temporary state and there isn't a good indication of whether it's "active". But I'm not opposing your proposal, just wondering what works best for the use case. What you're suggesting is probably fine. If it was a separate format option then depending on the implementation you could have something like Either way if you expect it to be used in the statusline, you need to extend the redraw condition in Lines 1966 to 1972 in 23afab3 |
|
I think this is meant to indicate when the queue is active Line 547 in 23afab3 I am using this change already locally, and it feels fine to me. The only issue that I have, now that you mention it, is that the queue is active whenever there is at least one element there no matter if I am currently playing a track from a playlist or a the library; the next track will always be the one on the top of the queue. But that is not up to me. |
|
At the end of the day I just want to extend the meaning of |
|
The logical behavior is subjective (and I'm not sure how useful the existing
With regards to what I'm saying about |
|
True, I haven't noticed the update condition for the status bar. Now added a quick fix 8ea3b84. |
| /* total time changed? */ | ||
| if (play_library) { | ||
| if (cmus_queue_active()) { | ||
| needs_status_update += queue_needs_redraw(); |
There was a problem hiding this comment.
You need to clear changed to 0 when you read it similar to what's done for lib_editable, otherwise it'll still be set on every loop.
There was a problem hiding this comment.
There is the same problem with the playlist view then. pl_needs_redraw checks on pl_editable_shared.win->changed, but changed is only set to 0 after pl_draw is called. So that means the status bar redraws on every loop if playing from the playlist but pl_draw is not called, eg. if on another view.
There was a problem hiding this comment.
I was thinking to set all changed flags to 0 in post_update. Would that make sense? I will propose it for the play queue, and later it could be also extended to the playlists and library.
There was a problem hiding this comment.
I did a check, and it wouldn't work resetting the changed flag in post_update().
I would get a frozen queue while on the queue view, for example after typing :clear.
I am not sure why.
Instead I clear the flag at the end of the update() function and that seems to work 13f7980.
There was a problem hiding this comment.
True. I hadn't noticed that about playlist updates, but I guess you can just ignore it if you want.
I would get a frozen queue while on the queue view
The queue view shouldn't freeze since it doesn't use changed as far as I see. But you probably meant playlist view since pl_draw() does check changed (although this optimization is probably not worth the headache).
| /* total time changed? */ | ||
| if (play_library) { | ||
| if (cmus_queue_active()) { | ||
| needs_status_update += queue_needs_redraw(); |
There was a problem hiding this comment.
True. I hadn't noticed that about playlist updates, but I guess you can just ignore it if you want.
I would get a frozen queue while on the queue view
The queue view shouldn't freeze since it doesn't use changed as far as I see. But you probably meant playlist view since pl_draw() does check changed (although this optimization is probably not worth the headache).
pgaskin
left a comment
There was a problem hiding this comment.
Works, makes sense.
The queue_post_update thing seems out of scope for this PR at first, but the existence of the lib_editable.shared->win->changed = 0; line earlier in the function (which has a similar purpose, but for the library/playlist views) kind of justifies this change being part of the PR (since otherwise the logic wouldn't be the same for the queue). It's a bit hacky, but no worse than what's already done.
| } | ||
|
|
||
| /* Reset changed flags */ | ||
| queue_post_update(); |
There was a problem hiding this comment.
It took a while to understand why this is needed, but basically:
- Usually, the changed flag is cleared by update_window.
- That function is called by do_update_view in update if any view's changed flag is set.
- The do_update_view only calls update_window for the currently visible view, even if other views bad the changed flag set.
- Thus, all views should have their changed flag cleared after the entire update is done since all views which should be visible have already been updated.
- There is already a workaround for this for library/playlist earlier in the update function where the editable changed flag is reset if playing from the library.
The comment above this line is a little bit vague, if not misleading. Also, to match the way the rest of the update function is written (specifically the parts which check the changed flag on all the views), the flags of all views should be cleared here.
This is fine for now though.
|
|
||
| void queue_post_update(void) | ||
| { | ||
| pq_editable.shared->win->changed = 0; |
There was a problem hiding this comment.
Nitpick: I don't think this function should exist; it's good for encapsulation, but it's inconsistent with the rest of cmus, where the changed flags on the views are directly manipulated by the update function.
|
@flyingmutant, probably merge this as a rebase to keep the changes separate. |
13f7980 to
dda9e0d
Compare
|
@flyingmutant, do you plan to merge this, or are you still reviewing it? |
The format option "total" will display the total time in the library or the current playing list, but if the queue is active it should instead display the total time of the queue.
The update condition for the status bar now takes into account changes to the queue. This is needed for example if queue values, like total time, are displayed in the status bar.
dda9e0d to
fbd13c1
Compare
|
Merged, finally! Thanks a lot for the PR. |
The format option "total" will display the total time in the library or the current playing list, but if the queue is active it should instead display the total time of the queue.