fluxxcode / egui-file-dialog

Full featured and customizable file dialog for egui
MIT License
91 stars 14 forks source link

Follow up for drag&drop #200

Closed hacknus closed 4 days ago

hacknus commented 6 days ago

After implementing drag&drop I noticed that the scrolling does not really work the way it should - is this also the case on your end or is this only occurring on mac? see attached video

https://github.com/user-attachments/assets/e584c421-623f-445b-ae80-b19e26d6f75a

the scrolling is activated but it somehow seems to go to a random place - sometimes the the selected item is in view, but some times not (as in the video)

fluxxcode commented 6 days ago

Yes, I noticed that too, it only happens in large directories. But I can fix it tomorrow, it should be easy.

hacknus commented 6 days ago

Thanks! I really appreciate your responsiveness and support! :)

fluxxcode commented 5 days ago

The problem is, as expected, that in large directories the animation to the scroll target takes too long and ScrollArea::show_rows is used before the item is visible. In general, we should only set scroll_to_selection to false when the item is visible. I actually thought there was something in egui to check if an item is currently visible, but apparently that's not the case yet. That makes the whole thing much more complicated.

fluxxcode commented 5 days ago

Nevermind - the problem was the switch from ScrollArea::show to ScrollArea::show_rows when scrolling. Since the row height in show_rows was set slightly incorrect, there was an offset when using show_rows. Will merge the fix tomorrow.

There is still a scroll offset if there are items in the directory whose name takes up multiple lines. But we won't be able to change that because we won't be able to predict how big the individual items will be.

hacknus commented 5 days ago

ah cool, good catch! Maybe truncating the file names when displaying them would be an option. Something like:

a_very_large_file_name_that_will_take_up_multiple_lines.pdf will become a_very_large_file_name...lines.pdf

macOS does something like this

fluxxcode commented 5 days ago

That's a good idea! Truncating in the middle is not easy though 🤔