Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrap selection around at the bottom/top of the library's tracks list #11090

Merged

Conversation

robbert-vdh
Copy link
Contributor

@robbert-vdh robbert-vdh commented Nov 23, 2022

As described in #11088. This makes navigating key-sorted track lists using a controller much more convenient. Though as mentioned in the comment, this does not match the Up/Down cursor key behavior. Should that maybe also cause the tracks list to wrap around? On a keyboard you have Home/End to go to the start and end of the list, but there I'd also expect the cursor keys there to wrap the list around in a similar way. See below.

This makes navigating key-sorted track lists using a controller much
more convenient. Though as mentioned in the comment, this does not match
the Up/Down cursor key behavior. Should those also wrap around?
@robbert-vdh robbert-vdh changed the title Restore wraparound in [Library],MoveVertical Wrap selection around at the bottom/top of the library's tracks list Nov 23, 2022
@robbert-vdh
Copy link
Contributor Author

Since it made a lot of sense to me both consistency and functionality wise to also use this same behavior for Up/Down cursor key presses, I ended up changing the implementation to instead add the wraparound directly to the cursor movement handler in the libraryWLibraryTableView widget. The added benefit is that this also interacts nicely with the other common selection hotkeys, like Shift+Up/Down to select the previous/next row and Ctrl+Up/Down to focus a row without selecting it (+ Space to actually toggle selection).

Let me know what you think.

@robbert-vdh robbert-vdh force-pushed the feature/library-tracks-wraparound branch from 565c8bc to fbee730 Compare November 23, 2022 18:15
This matches the new(ly restored) behavior from
dc83783 by overriding `QTableView`'s
`moveCursor()` function. This way this also works as expected with the
other common selection hotkeys like Shift+Up/Down and Ctrl+Up/Down ->
Space.
The event handler for `WLibraryTableView` now also wraps around the list
when navigating it using the cursor keys. So `[Library],MoveVertical`
can revert to just sending Up/Down key events to the
`WLibraryTableView`.
This happens when the view has not yet been interacted with.
@robbert-vdh robbert-vdh force-pushed the feature/library-tracks-wraparound branch from fbee730 to 11f5f89 Compare November 23, 2022 18:42
@ronso0
Copy link
Member

ronso0 commented Nov 23, 2022

Thank you, this looks good. Overriding moveCursor is smart move IMO. IIRC I didn't consider the move only the cursor. Looks like it would make sense to adjust the Home/End key handler from WTrackTableView::keyPressEvent as well? Atm it always moves the selection, Ctrl has no effect. unfortunately QAbstractItemView::MoveHome / ..MoveEnd also affect the column IIUC so this would require handling the modifiers?

@ronso0
Copy link
Member

ronso0 commented Nov 23, 2022

Btw, I wondered why we actually have WTrackTableView and WLibraryTableView, so I moved moveCursor and moveSelection to WTrackTableView (and it works as before). I didn't find a place where WLibraryTableView is used. Is this just legacy from previous implementations? Any idea @daschuer ?
I think we may simply merge those two classes, no? Then we'd have all methods dealing with cursor and selection in one place.

@robbert-vdh
Copy link
Contributor Author

Looks like it would make sense to adjust the Home/End key handler from WTrackTableView::keyPressEvent as well? Atm it always moves the selection, Ctrl has no effect. unfortunately QAbstractItemView::MoveHome / ..MoveEnd also affect the column IIUC so this would require handling the modifiers?

Yeah sure! So you're referring to the Shift/Ctrl handling, right? I took a peek at how this works in QAbstractItemView and it doesn't like like there's a helper function for this, so we'd probably need to copy some bits and pieces from that.

@ronso0
Copy link
Member

ronso0 commented Nov 23, 2022

Yes, that's what I mean.
So it would work like this, right?
press Home/End

  • (no modifiers): jump to and select first/last row, keep focused column
  • with Ctrl: focus first/last row, keep focused column, keep selection, select with Space
  • with Shift: focus cell in first/last column in focused row, keep selection, select with Space
    Edit or should Shift+Home just select a range? So this would be Ctrl+Shift?

@robbert-vdh
Copy link
Contributor Author

I'll take a look at that tomorrow. Want me to tack it onto this PR or should I create a second one?

@ronso0
Copy link
Member

ronso0 commented Nov 23, 2022

I think a separate PR is better because this one can be merged as soon as we did some testing, and agreed to make wrapping around the default.

Actually it depends on where you want to implement Home/End modifiers. If you do it in moveCursor() you may have to rebase this PR since the new will probably get merged quicker, it's a small improvement = doesn't break anything.
You can also modify keyPressEvent first, then --when it's merged-- move it to moveCursor() in this PR here. 🤷

@ronso0
Copy link
Member

ronso0 commented Dec 6, 2022

@mixxxdj/developers Does anyone have objections making Up/Down keys wrap around?

Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No Objections.

The code looks good and the cursor behaves natural when using Keyboard.
Thank you very much.

@daschuer daschuer added this to the 2.4.0 milestone Dec 8, 2022
@daschuer daschuer added the changelog This PR should be included in the changelog label Dec 8, 2022
@daschuer daschuer merged commit 4127490 into mixxxdj:main Dec 8, 2022
@ronso0
Copy link
Member

ronso0 commented Dec 8, 2022

Btw, I wondered why we actually have WTrackTableView and WLibraryTableView, so I moved moveCursor and moveSelection to WTrackTableView (and it works as before). I didn't find a place where WLibraryTableView is used. Is this just legacy from previous implementations? Any idea @daschuer ? I think we may simply merge those two classes, no? Then we'd have all methods dealing with cursor and selection in one place.

@daschuer Any thoughts on that? Continued in #11100 (comment)

@robbert-vdh robbert-vdh deleted the feature/library-tracks-wraparound branch December 8, 2022 12:55
@ronso0
Copy link
Member

ronso0 commented Feb 7, 2023

I'm torn apart regarding this feature:

  1. yes, now I don't have to hit Home/End anymore to get to the other end of the list, but I need it to rarely it would make up for 2:
  2. wrapround (scroll "overshoot") is still surprising / confusing because there's no clear feedback when I reach the top/bottom

That is due to the default scroll behaviour: the selection needs to reach the top/bottom of the viewport before it'd scroll the view.

Possible fixes:

  • re-implement scrolling:
    always show 1-3 lines below/above the selection while scrolling
    might be rather difficult..
    could help with the track 'overview'
    not sure if 3 lines would help when moving fast
  • "stop" when hitting the top/bottom:
    when sending Up/Down commands rapidly, require a pause before wrapping around

What do you think?

@robbert-vdh
Copy link
Contributor Author

Always keeping 1-3 lines of context when scrolling is a good idea regardless. And I do still think wraparound without pauses or anything is a necessary feature. If you're scrolling through the list with the cursor keys then you may as well use a mouse which is faster. But if you're using a controller to navigate you won't have the equivalent of a home/end key to bring you to the start/end of the list. Wraparound is the only logical behavior as I see it.

@ronso0
Copy link
Member

ronso0 commented Feb 7, 2023

I'm using a controller and I still prefer to hit Home when I'm midway in the tracks.

Do you have pointers how to get more context when scrolling?

@robbert-vdh
Copy link
Contributor Author

I've never used Qt so I'd also need to dig through the APIs first. I doubt something like this would already exist within Qt, but the idea would be that whenever the selection/focus changes the view would be scrolled as necessary to make sure the 2-3 items above and below the focused item are visible. With some extra behavior to reduce this number as the widget's height decreases and fewer items fit (so if only three rows fit it would try to keep one above and one below the selected row visible).

@ronso0
Copy link
Member

ronso0 commented Feb 10, 2023

well, for the time being, this is my personal workaround:
https://github.com/ronso0/mixxx/tree/tracks-wraparound-delay
when pressing Up/Down repeatedly, require a keypress pause of 1 second before wrapping around. 1 second is just a guess, will probably adjust that after testing with my controller.
also, this can be adjusted to work with one timer, but 🤷‍♂️

@ronso0
Copy link
Member

ronso0 commented Feb 14, 2023

and show some lines above/below when moving the cursor 9d39314

I filed #11276

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog This PR should be included in the changelog library ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants