VST3: fetch midi mappings all at once, use it for note/sound-off
[carla.git] / source / modules / juce_gui_basics / windows / juce_TopLevelWindow.h
blob4cd5aefe0f299c067c62bc9bfe2df93d7433b110
1 /*
2 ==============================================================================
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
19 JUCE IS PROVIDED "AS IS" WITHOUT ANY WARRANTY, AND ALL WARRANTIES, WHETHER
20 EXPRESSED OR IMPLIED, INCLUDING MERCHANTABILITY AND FITNESS FOR PURPOSE, ARE
21 DISCLAIMED.
23 ==============================================================================
26 namespace juce
29 //==============================================================================
30 /**
31 A base class for top-level windows.
33 This class is used for components that are considered a major part of your
34 application - e.g. ResizableWindow, DocumentWindow, DialogWindow, AlertWindow,
35 etc. Things like menus that pop up briefly aren't derived from it.
37 A TopLevelWindow is probably on the desktop, but this isn't mandatory - it
38 could itself be the child of another component.
40 The class manages a list of all instances of top-level windows that are in use,
41 and each one is also given the concept of being "active". The active window is
42 one that is actively being used by the user. This isn't quite the same as the
43 component with the keyboard focus, because there may be a popup menu or other
44 temporary window which gets keyboard focus while the active top level window is
45 unchanged.
47 A top-level window also has an optional drop-shadow.
49 @see ResizableWindow, DocumentWindow, DialogWindow
51 @tags{GUI}
53 class JUCE_API TopLevelWindow : public Component
55 public:
56 //==============================================================================
57 /** Creates a TopLevelWindow.
59 @param name the name to give the component
60 @param addToDesktop if true, the window will be automatically added to the
61 desktop; if false, you can use it as a child component
63 TopLevelWindow (const String& name, bool addToDesktop);
65 /** Destructor. */
66 ~TopLevelWindow() override;
68 //==============================================================================
69 /** True if this is currently the TopLevelWindow that is actively being used.
71 This isn't quite the same as having keyboard focus, because the focus may be
72 on a child component or a temporary pop-up menu, etc, while this window is
73 still considered to be active.
75 @see activeWindowStatusChanged
77 bool isActiveWindow() const noexcept { return isCurrentlyActive; }
79 //==============================================================================
80 /** This will set the bounds of the window so that it's centred in front of another
81 window.
83 If your app has a few windows open and want to pop up a dialog box for one of
84 them, you can use this to show it in front of the relevant parent window, which
85 is a bit neater than just having it appear in the middle of the screen.
87 If componentToCentreAround is nullptr, then the currently active TopLevelWindow will
88 be used instead. If no window is focused, it'll just default to the middle of the
89 screen.
91 void centreAroundComponent (Component* componentToCentreAround,
92 int width, int height);
94 //==============================================================================
95 /** Turns the drop-shadow on and off. */
96 void setDropShadowEnabled (bool useShadow);
98 /** True if drop-shadowing is enabled. */
99 bool isDropShadowEnabled() const noexcept { return useDropShadow; }
101 /** Sets whether an OS-native title bar will be used, or a JUCE one.
102 @see isUsingNativeTitleBar
104 void setUsingNativeTitleBar (bool useNativeTitleBar);
106 /** Returns true if the window is currently using an OS-native title bar.
107 @see setUsingNativeTitleBar
109 bool isUsingNativeTitleBar() const noexcept;
111 //==============================================================================
112 /** Returns the number of TopLevelWindow objects currently in use.
113 @see getTopLevelWindow
115 static int getNumTopLevelWindows() noexcept;
117 /** Returns one of the TopLevelWindow objects currently in use.
118 The index is 0 to (getNumTopLevelWindows() - 1).
120 static TopLevelWindow* getTopLevelWindow (int index) noexcept;
122 /** Returns the currently-active top level window.
123 There might not be one, of course, so this can return nullptr.
125 static TopLevelWindow* getActiveTopLevelWindow() noexcept;
127 /** Adds the window to the desktop using the default flags. */
128 void addToDesktop();
130 //==============================================================================
131 /** @internal */
132 void addToDesktop (int windowStyleFlags, void* nativeWindowToAttachTo = nullptr) override;
134 protected:
135 //==============================================================================
136 /** This callback happens when this window becomes active or inactive.
137 @see isActiveWindow
139 virtual void activeWindowStatusChanged();
142 //==============================================================================
143 /** @internal */
144 void focusOfChildComponentChanged (FocusChangeType) override;
145 /** @internal */
146 void parentHierarchyChanged() override;
147 /** @internal */
148 virtual int getDesktopWindowStyleFlags() const;
149 /** @internal */
150 void recreateDesktopWindow();
151 /** @internal */
152 void visibilityChanged() override;
154 private:
155 friend class TopLevelWindowManager;
156 friend class ResizableWindow;
157 bool useDropShadow = true, useNativeTitleBar = true, isCurrentlyActive = false;
158 std::unique_ptr<DropShadower> shadower;
160 std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override;
161 void setWindowActive (bool);
163 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (TopLevelWindow)
166 } // namespace juce