Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions include/mostly_harmless/core/mostlyharmless_ISharedState.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,16 @@ namespace mostly_harmless::core {
*/
void rescanParams() const;

/**
* Asks the host to resize your gui to the specified dimensions.
* Doesn't block, and is thread safe, more of a "please do this when you get a chance" than a "do this now".
* That said - if you call this from the audio thread it's kinda against the spirit of the framework, and this is my answer to JUCE's "tut tut tut..." comment..
* @param width The requested width.
* @param height The requested height.
* @return true if the host acknowledged the resize request, false otherwise.
*/
bool requestGuiResize(std::uint32_t width, std::uint32_t height) const;

private:
SharedStateContext m_context;
std::vector<Parameter<float>> m_params;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ namespace mostly_harmless::core {
* Call this to request that the host rescans the param values, to keep them up to date.
*/
std::function<void(void)> requestParamRescan{ nullptr };

/**
* Call this to ask the host to resize your editor to the specified dimensions.
* It's up to the host *when* it does this, and doesn't block.
* It's *technically* fine to call this from any thread, but obviously it doesn't really make sense to do from the audio thread...
* Args are width and height, and return value is whether the host acknowledged your resize request.
*/
std::function<bool(std::uint32_t, std::uint32_t)> requestGuiResize{ nullptr };
};
} // namespace mostly_harmless::core
#endif // MOSTLYHARMLESS_MOSTLYHARMLESS_SHAREDSTATECONTEXT_H
4 changes: 4 additions & 0 deletions source/core/mostlyharmless_ISharedState.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,9 @@ namespace mostly_harmless::core {
m_context.requestParamRescan();
}

bool ISharedState::requestGuiResize(std::uint32_t width, std::uint32_t height) const {
return m_context.requestGuiResize(width, height);
}


} // namespace mostly_harmless::core
3 changes: 3 additions & 0 deletions source/mostlyharmless_PluginBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ namespace mostly_harmless::internal {
} },
.requestParamRescan = [this]() -> void {
_host.paramsRescan(CLAP_PARAM_RESCAN_VALUES);
},
.requestGuiResize = [this](std::uint32_t width, std::uint32_t height) -> bool {
return _host.guiRequestResize(width, height);
}
};
m_state = m_pluginEntry->createState(std::move(context));
Expand Down