Skip to content

Commit 74c5f20

Browse files
authored
Add a VisibilityParentWatcher utility (#156)
* Add a VisibilityParentWatcher utility which forces visibilityChanged calls for you *or your parent* visibility changing, optionally. * Add a needed include
1 parent 61d9bb3 commit 74c5f20

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/*
2+
* sst-jucegui - an open source library of juce widgets
3+
* built by Surge Synth Team.
4+
*
5+
* Copyright 2023-2024, various authors, as described in the GitHub
6+
* transaction log.
7+
*
8+
* sst-jucegui is released under the MIT license, as described
9+
* by "LICENSE.md" in this repository. This means you may use this
10+
* in commercial software if you are a JUCE Licensee. If you use JUCE
11+
* in the open source / GPL3 context, your combined work must be
12+
* released under GPL3.
13+
*
14+
* All source in sst-jucegui available at
15+
* https://github.com/surge-synthesizer/sst-jucegui
16+
*/
17+
18+
#ifndef INCLUDE_SST_JUCEGUI_UTIL_VISIBILITYPARENTWATCHER_H
19+
#define INCLUDE_SST_JUCEGUI_UTIL_VISIBILITYPARENTWATCHER_H
20+
21+
#include <juce_gui_basics/juce_gui_basics.h>
22+
23+
namespace sst::jucegui::util
24+
{
25+
/*
26+
* If you create a member of this class, then you get
27+
* visibilityChanged called *not* just when your visibility
28+
* changes but when any of your parent hierarchy visibility
29+
* changes
30+
*/
31+
struct VisibilityParentWatcher : juce::ComponentMovementWatcher
32+
{
33+
VisibilityParentWatcher(juce::Component *that) : juce::ComponentMovementWatcher(that) {}
34+
void componentMovedOrResized(bool wasMoved, bool wasResized) override {}
35+
void componentPeerChanged() override {}
36+
void componentVisibilityChanged() override { getComponent()->visibilityChanged(); }
37+
};
38+
} // namespace sst::jucegui::util
39+
#endif // VISIBILITYPARENTWATCHER_H

0 commit comments

Comments
 (0)