JUCE-7.0.12-0-g4f43011b96 JUCE-7.0.12-0-g4f43011b96
JUCE — C++ application framework with suport for VST, VST3, LV2 audio plug-ins

« « « Anklang Documentation
Loading...
Searching...
No Matches
juce_MenuBarModel.cpp
Go to the documentation of this file.
1 /*
2 ==============================================================================
3
4 This file is part of the JUCE library.
5 Copyright (c) 2022 - Raw Material Software Limited
6
7 JUCE is an open source library subject to commercial or open-source
8 licensing.
9
10 By using JUCE, you agree to the terms of both the JUCE 7 End-User License
11 Agreement and JUCE Privacy Policy.
12
13 End User License Agreement: www.juce.com/juce-7-licence
14 Privacy Policy: www.juce.com/juce-privacy-policy
15
16 Or: You may also use this code under the terms of the GPL v3 (see
17 www.gnu.org/licenses).
18
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.
22
23 ==============================================================================
24*/
25
26namespace juce
27{
28
29MenuBarModel::MenuBarModel() noexcept
30 : manager (nullptr)
31{
32}
33
38
39//==============================================================================
44
46{
47 if (manager != newManager)
48 {
49 if (manager != nullptr)
50 manager->removeListener (this);
51
52 manager = newManager;
53
54 if (manager != nullptr)
55 manager->addListener (this);
56 }
57}
58
60{
61 listeners.add (newListener);
62}
63
65{
66 // Trying to remove a listener that isn't on the list!
67 // If this assertion happens because this object is a dangling pointer, make sure you've not
68 // deleted this menu model while it's still being used by something (e.g. by a MenuBarComponent)
69 jassert (listeners.contains (listenerToRemove));
70
71 listeners.remove (listenerToRemove);
72}
73
74//==============================================================================
76{
77 listeners.call ([this] (Listener& l) { l.menuBarItemsChanged (this); });
78}
79
81{
82 listeners.call ([this, &info] (Listener& l) { l.menuCommandInvoked (this, info); });
83}
84
89
90void MenuBarModel::handleMenuBarActivate (bool isActive)
91{
92 menuBarActivated (isActive);
93 listeners.call ([this, isActive] (Listener& l) { l.menuBarActivated (this, isActive); });
94}
95
98
99} // namespace juce
One of these objects holds a list of all the commands your app can perform, and despatches these comm...
void addListener(ApplicationCommandManagerListener *listener)
Registers a listener that will be called when various events occur.
void removeListener(ApplicationCommandManagerListener *listener)
Deregisters a previously-added listener.
void triggerAsyncUpdate()
Causes the callback to be triggered at a later time.
A class to receive callbacks when a MenuBarModel changes.
virtual void menuBarActivated(MenuBarModel *menuBarModel, bool isActive)
Called when the menu bar is first activated or when the user finished interacting with the menu bar.
A class for controlling MenuBar components.
void applicationCommandInvoked(const ApplicationCommandTarget::InvocationInfo &) override
Called when an app command is about to be invoked.
virtual void menuBarActivated(bool isActive)
This is called when the user starts/stops navigating the menu bar.
void removeListener(Listener *listenerToRemove)
Removes a listener.
void handleAsyncUpdate() override
Called back to do whatever your class needs to do.
~MenuBarModel() override
Destructor.
void menuItemsChanged()
Call this when some of your menu items have changed.
void setApplicationCommandManagerToWatch(ApplicationCommandManager *manager)
Tells the menu bar to listen to the specified command manager, and to update itself when the commands...
void addListener(Listener *listenerToAdd)
Registers a listener for callbacks when the menu items in this model change.
void applicationCommandListChanged() override
Called when commands are registered or deregistered from the command manager, or when commands are ma...
#define jassert(expression)
Platform-independent assertion macro.
JUCE Namespace.
Type unalignedPointerCast(void *ptr) noexcept
Casts a pointer to another type via void*, which suppresses the cast-align warning which sometimes ar...
Definition juce_Memory.h:88
Contains contextual details about the invocation of a command.