-
-
Notifications
You must be signed in to change notification settings - Fork 97
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
Allow horizontal scrollbar for ListView items #147
Conversation
Thanks for contributing. I'm a bit concerned with the potential performance impact of this change though. With optimizations the code you wrote would be welcome, but it won't be accepted in its current form. I noticed you are calling updateColumnsMaxItemWidths every time you add a single item. This means that if you add 1000 lines, you need to calculate 500,000 line widths. There are several optimizations that are probably possible (based on a quick look at the changes):
|
Thanks for the suggestions. I implemented bullet points 1, 2, and 4 in this commit but skipped the 3rd because I was having some trouble figuring out how to cleanly cache line widths in TextView. The caching could be done pretty easily in Text but would require making getLineWidth() no longer const and I'm not sure if that should be avoided. |
One last performance thing to look into is maybe only calling updateHorizontalScrollbarMaximum when needed. It probably only needs to be called when the maximum width changes instead of for each item. There is some duplicate code in changeItem and changeSubItem, maybe the lines starting at updatedLastColumnMaxItemWidth could be placed in a helper function (with oldDesiredWidthInLastColumn as parameter). The first two lines in addMultipleItems seem to be leftovers from before, so they can probably be removed. I looked into whether getLineWidth can be cached and I came to the conclusion that it might not be what you need. The function is only used in one place and was added as a helper function during some PR. You can probably just use The |
Also fixed changeSubItem() not updating horizontal scrollbar max when there are no columns.
Implemented all those (except the Text things you're looking at) in this commit and fixed some edge case with my code for changeSubItem() with no columns. |
Thanks for adding the requested optimizations. Everything looks good now. |
These changes allow the horizontal scrollbar to appear to view items too long to fit in a ListView.
When there are no columns, the scrollbar's max value will be enough to view up to the end of the longest item.
When there are 1 or more columns and m_expandLastColumn is false, the ListView will follow old behavior.
When there are 1 or more columns and m_expandLastColumn is true, the scrollbar's max value will be enough to view up to the end of the longest item in the rightmost column. Items in other columns will be clipped by their column's width (like in old behavior).