Make callGUI more generic and move it to globals.h. Readme change.

This commit is contained in:
xenakios
2018-01-05 17:49:54 +02:00
parent 04a6fc33cc
commit a24d5c8c81
4 changed files with 17 additions and 15 deletions

View File

@ -193,3 +193,16 @@ inline void fill_container(Cont& c, const T& x)
{
std::fill(std::begin(c), std::end(c), x);
}
template<typename T, typename F>
inline void callGUI(T* ap, F&& f, bool async)
{
auto ed = dynamic_cast<typename T::EditorType*>(ap->getActiveEditor());
if (ed)
{
if (async == false)
f(ed);
else
MessageManager::callAsync([ed, f]() { f(ed); });
}
}