mirror of
https://github.com/aseprite/aseprite.git
synced 2025-02-07 06:40:10 +00:00
Avoid locking the UI when we enter in a new folder
Instead of calling ThumbnailGenerator::generateThumbnail() for each visible item on FileList::onPaint(), we create another queue of items to be generated on each monitoring tick.
This commit is contained in:
parent
9e7e2767c8
commit
5acadc69ca
@ -624,6 +624,15 @@ void FileList::onCurrentFolderChanged()
|
||||
|
||||
void FileList::onMonitoringTick()
|
||||
{
|
||||
auto start = base::current_tick();
|
||||
while (!m_generateThumbnailsForTheseItems.empty() &&
|
||||
// No more than 200ms launching thumbnail generators
|
||||
base::current_tick() - start < 200) {
|
||||
auto fi = m_generateThumbnailsForTheseItems.front();
|
||||
m_generateThumbnailsForTheseItems.pop_front();
|
||||
ThumbnailGenerator::instance()->generateThumbnail(fi);
|
||||
}
|
||||
|
||||
if (ThumbnailGenerator::instance()->checkWorkers())
|
||||
invalidate();
|
||||
}
|
||||
@ -842,8 +851,13 @@ void FileList::selectIndex(int index)
|
||||
|
||||
void FileList::generateThumbnailForFileItem(IFileItem* fi)
|
||||
{
|
||||
if (fi && animation() == ANI_NONE)
|
||||
ThumbnailGenerator::instance()->generateThumbnail(fi);
|
||||
if (fi && animation() == ANI_NONE) {
|
||||
auto it = std::find(m_generateThumbnailsForTheseItems.begin(),
|
||||
m_generateThumbnailsForTheseItems.end(), fi);
|
||||
if (it != m_generateThumbnailsForTheseItems.end())
|
||||
m_generateThumbnailsForTheseItems.erase(it);
|
||||
m_generateThumbnailsForTheseItems.push_front(fi);
|
||||
}
|
||||
}
|
||||
|
||||
void FileList::delayThumbnailGenerationForSelectedItem()
|
||||
|
@ -17,6 +17,7 @@
|
||||
#include "ui/timer.h"
|
||||
#include "ui/widget.h"
|
||||
|
||||
#include <deque>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
@ -123,6 +124,10 @@ namespace app {
|
||||
// thumbnail to generate when the m_generateThumbnailTimer ticks.
|
||||
IFileItem* m_itemToGenerateThumbnail;
|
||||
|
||||
// List of thumbnails to generate in the next m_monitoringTimer in
|
||||
// a isIconView()
|
||||
std::deque<IFileItem*> m_generateThumbnailsForTheseItems;
|
||||
|
||||
// True if this listbox accepts selecting multiple items at the
|
||||
// same time.
|
||||
bool m_multiselect;
|
||||
|
Loading…
x
Reference in New Issue
Block a user