-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make sure we run the gui callback on the main thread
- Loading branch information
Showing
6 changed files
with
98 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#include "threaded-gui-listener-proxy.hh" | ||
|
||
namespace clap { | ||
ThreadedGuiListenerProxy::ThreadedGuiListenerProxy(AbstractGuiListener &guiListener) | ||
: _guiListener(guiListener) {} | ||
|
||
void ThreadedGuiListenerProxy::onGuiRunOnMainThread(std::function<void()> callback) { | ||
_guiListener.onGuiRunOnMainThread(std::move(callback)); | ||
} | ||
|
||
void ThreadedGuiListenerProxy::onGuiPoll() { | ||
onGuiRunOnMainThread([this] { _guiListener.onGuiPoll(); }); | ||
} | ||
|
||
void ThreadedGuiListenerProxy::onGuiParamBeginAdjust(clap_id paramId) { | ||
onGuiRunOnMainThread([this, paramId] { _guiListener.onGuiParamBeginAdjust(paramId); }); | ||
} | ||
|
||
void ThreadedGuiListenerProxy::onGuiParamAdjust(clap_id paramId, double value) { | ||
onGuiRunOnMainThread([this, paramId, value] { _guiListener.onGuiParamAdjust(paramId, value); }); | ||
} | ||
|
||
void ThreadedGuiListenerProxy::onGuiParamEndAdjust(clap_id paramId) { | ||
onGuiRunOnMainThread([this, paramId] { _guiListener.onGuiParamEndAdjust(paramId); }); | ||
} | ||
|
||
void ThreadedGuiListenerProxy::onGuiSetTransportIsSubscribed(bool isSubscribed) { | ||
onGuiRunOnMainThread( | ||
[this, isSubscribed] { _guiListener.onGuiSetTransportIsSubscribed(isSubscribed); }); | ||
} | ||
|
||
void ThreadedGuiListenerProxy::onGuiWindowClosed(bool wasDestroyed) { | ||
onGuiRunOnMainThread([this, wasDestroyed] { _guiListener.onGuiWindowClosed(wasDestroyed); }); | ||
} | ||
|
||
void ThreadedGuiListenerProxy::onGuiUndo() { | ||
onGuiRunOnMainThread([this] { _guiListener.onGuiUndo(); }); | ||
} | ||
|
||
void ThreadedGuiListenerProxy::onGuiRedo() { | ||
onGuiRunOnMainThread([this] { _guiListener.onGuiRedo(); }); | ||
} | ||
|
||
void ThreadedGuiListenerProxy::onGuiInvoke(const std::string &method, | ||
const InvocationArgumentsType &args) { | ||
onGuiRunOnMainThread([this, method, args] { _guiListener.onGuiInvoke(method, args); }); | ||
} | ||
} // namespace clap |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#pragma once | ||
|
||
#include "abstract-gui-listener.hh" | ||
|
||
namespace clap { | ||
class ThreadedGuiListenerProxy final : public AbstractGuiListener { | ||
public: | ||
ThreadedGuiListenerProxy(AbstractGuiListener &guiListener); | ||
|
||
void onGuiRunOnMainThread(std::function<void()> callback) override; | ||
|
||
void onGuiPoll() override; | ||
|
||
void onGuiParamBeginAdjust(clap_id paramId) override; | ||
void onGuiParamAdjust(clap_id paramId, double value) override; | ||
void onGuiParamEndAdjust(clap_id paramId) override; | ||
|
||
void onGuiSetTransportIsSubscribed(bool isSubscribed) override; | ||
|
||
void onGuiWindowClosed(bool wasDestroyed) override; | ||
|
||
void onGuiUndo() override; | ||
void onGuiRedo() override; | ||
|
||
void onGuiInvoke(const std::string &method, const InvocationArgumentsType &args) override; | ||
|
||
private: | ||
AbstractGuiListener &_guiListener; | ||
}; | ||
} // namespace clap |