Similar to
VBlankAttachment - check for isShowing()?.
Cause I am using VBlankAttachment, I want to know when does isShowing change so that I can start/stop the vblank callback. Is it enough to override the following three methods of PluginEditor to detect the change of isShowing (i.e., if isShowing changes, at least one of them will get called)? Do I need an extra timer (like 10Hz) to check isShowing repeatedly?
void visibilityChanged() override;
void parentHierarchyChanged() override;
void minimisationStateChanged(bool isNowMinimised) override;
Looking at the implementation of isShowing(), those three callbacks should cover it, but couldn’t you just check isShowing() in the callback?
Thanks for confirming that. I want to completely stop the vblank callback when isShowing=false. Therefore, I declare the vblank as:
std::unique_ptr<juce::VBlankAttachment> vblank;
And when isShowing changes, I will call:
if (isShowing()) {
vblank = std::make_unique<juce::VBlankAttachment>(
&mainPanel, [this](const double x) { mainPanel.repaintCallBack(x); });
} else {
vblank.reset();
}
It is because some hosts will not destroy the PluginEditor (until the whole mixing session is closed). And I want to minimize my editor CPU usage in such case.