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

Library sidebar: expand items to full width to maximize click-responsive area #11708

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

ronso0
Copy link
Member

@ronso0 ronso0 commented Jul 3, 2023

A small UX helper. Works fine without glitches.

Issue

Currently, the sidebar header expands to the width of the widest item.
If the sidebar is wider than that, there's some space right next to items that is not responsive to clicks. This is somewhat frustration as it is perceived inconsistent with the state when e.g. Playlist are expanded and the entire 'Tracks' row responds to clicks.

Desired:

  • full-width items
  • full item text (no elide)
  • show scrollbars as needed

Unfortunately, there's no combination of
header()->setStretchLastSection(true);
header()->setSectionResizeMode(QHeaderView::ResizeMode);
to achieve that.
at least not when set in the constructor. If set later on, e.g. on QResizeEvent, it works as desired, though only with collapsed rows. go figure...

Probably a Qt issue, or just a use case they didn't know/care about.


Fix

The header, and thereby the rows, are (maybe) adjusted on every Resize, LayoutRequest, FontChange & Polish event, when expanding/collapsing items and when item text is changed (eg. playlist renamed, track count changed):

  • setStretchLastSection(false) to show horizontal scrollbars, ie. no ellipsis in item labels
  • setStretchLastSection(true) if sidebar is wider than the widest item

To avoid unnecessary and redundant adjustments (1), adjust requests are queued and delayed by 50 ms (2) so that only the last queued request is processed.
This is implemented along the drag'n'drop timer events with a lightweight QBasicTimer, so I think this is a compact solution.

(1) this applies in particular to skin creation/first show and manual resizing, eg. while dragging the sidebar splitter, where many events may be sent in quick succession
(2) 50 ms seem to be a good compromise between fast GUI update and long enough wait time for potential follow-up events to reduce adjust requests.
Update can be seen only when expanding from width with h-scrollbars to one without.

@github-actions github-actions bot added the ui label Jul 3, 2023
@ronso0 ronso0 added this to the 2.4.0 milestone Jul 3, 2023
@ronso0

This comment was marked as outdated.

@ronso0

This comment was marked as outdated.

@ronso0 ronso0 marked this pull request as draft July 4, 2023 10:46
@ronso0
Copy link
Member Author

ronso0 commented Jul 5, 2023

The first attempt was simple but the resize function was called way too often.
I changed it to use a timer and handle only the last queued event (and stop the timer afterwards).
Works well (except when renaming items but that's not an issue for me).

I consider it helpful but after all it's a hack to compensate for a Qt issue IMO, so I will not fight for getting this merged.
Though, if someone considers this is an okayish way to fix a small usabilty issue, or has better, less-hacky ideas to fix it (e.g. overriding or otherwise hooking up a QTreeView function) let's discuss it.

Check the first commit only, the 2nd one adds lots of debug output to catch events etc.

@ronso0 ronso0 force-pushed the lib-sidebar-stretch-items branch from 522ecb1 to 6e74192 Compare July 5, 2023 10:54
@ronso0
Copy link
Member Author

ronso0 commented Jul 5, 2023

Btw I wasted some hours just to discover a QTimer quirk: already queued callOnTimeout signals are notr removed from the event queue when the timer is stopped or even when it's deleted, that has to be done manually.
Affects the knob wheel timer (show parameter value #11077).

I'll provide a fix soonish.

Copy link

github-actions bot commented Nov 9, 2023

This PR is marked as stale because it has been open 90 days with no activity.

@github-actions github-actions bot added the stale Stale issues that haven't been updated for a long time. label Nov 9, 2023
@github-actions github-actions bot removed the stale Stale issues that haven't been updated for a long time. label Feb 22, 2024
Copy link

This PR is marked as stale because it has been open 90 days with no activity.

@github-actions github-actions bot added stale Stale issues that haven't been updated for a long time. and removed stale Stale issues that haven't been updated for a long time. labels Oct 25, 2024
@ronso0 ronso0 changed the base branch from 2.4 to main October 26, 2024 00:12
@ronso0 ronso0 force-pushed the lib-sidebar-stretch-items branch 2 times, most recently from 8ebeda8 to e177f7c Compare October 26, 2024 00:21
@ronso0
Copy link
Member Author

ronso0 commented Oct 26, 2024

If polished this and rebased onto main.
Works fine for all sorts of layout or item changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant