Skip to content

Commit

Permalink
Add FinishLoading signal to ResourcesListBox to detect when the resou…
Browse files Browse the repository at this point in the history
…rces were loaded

In this way we avoid using ui::ListBox::Change signal as a
workaround (which is a signal that should be fired only from
ui::ListBox::onChange()).
  • Loading branch information
dacap committed Jan 5, 2021
1 parent 78fc63c commit de22d69
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app/ui/palette_popup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ PalettePopup::PalettePopup()
addChild(m_popup);

m_paletteListBox.DoubleClickItem.connect(base::Bind<void>(&PalettePopup::onLoadPal, this));
m_paletteListBox.Change.connect(base::Bind<void>(&PalettePopup::onSearchChange, this));
m_paletteListBox.FinishLoading.connect(base::Bind<void>(&PalettePopup::onSearchChange, this));
m_popup->search()->Change.connect(base::Bind<void>(&PalettePopup::onSearchChange, this));
m_popup->loadPal()->Click.connect(base::Bind<void>(&PalettePopup::onLoadPal, this));
m_popup->openFolder()->Click.connect(base::Bind<void>(&PalettePopup::onOpenFolder, this));
Expand Down
5 changes: 3 additions & 2 deletions src/app/ui/resources_listbox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,10 +210,11 @@ void ResourcesListBox::onTick()
resource.release();
listItem.release();
}
Change();

if (m_resourcesLoader->isDone())
if (m_resourcesLoader->isDone()) {
FinishLoading();
stop();
}
}

void ResourcesListBox::stop()
Expand Down
3 changes: 3 additions & 0 deletions src/app/ui/resources_listbox.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#pragma once

#include "app/res/resources_loader.h"
#include "obs/signal.h"
#include "ui/listbox.h"
#include "ui/listitem.h"
#include "ui/timer.h"
Expand Down Expand Up @@ -43,6 +44,8 @@ class ResourceListItem : public ui::ListItem {

void reload();

obs::signal<void()> FinishLoading;

protected:
virtual bool onProcessMessage(ui::Message* msg) override;
virtual void onChange() override;
Expand Down

0 comments on commit de22d69

Please sign in to comment.