LMMS
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
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
64void MenuBarModel::removeListener (Listener* listenerToRemove)
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
91{
92 menuBarActivated (isActive);
93 listeners.call ([this, isActive] (Listener& l) { l.menuBarActivated (this, isActive); });
94}
95
98
99} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
Definition juce_ApplicationCommandManager.h:88
void triggerAsyncUpdate()
Definition juce_AsyncUpdater.cpp:62
Definition juce_MenuBarModel.h:79
virtual void menuBarActivated(MenuBarModel *menuBarModel, bool isActive)
Definition juce_MenuBarModel.cpp:97
ListenerList< Listener > listeners
Definition juce_MenuBarModel.h:186
MenuBarModel() noexcept
Definition juce_MenuBarModel.cpp:29
void applicationCommandInvoked(const ApplicationCommandTarget::InvocationInfo &) override
Definition juce_MenuBarModel.cpp:80
virtual void menuBarActivated(bool isActive)
Definition juce_MenuBarModel.cpp:96
void removeListener(Listener *listenerToRemove)
Definition juce_MenuBarModel.cpp:64
void handleAsyncUpdate() override
Definition juce_MenuBarModel.cpp:75
~MenuBarModel() override
Definition juce_MenuBarModel.cpp:34
void menuItemsChanged()
Definition juce_MenuBarModel.cpp:40
void setApplicationCommandManagerToWatch(ApplicationCommandManager *manager)
Definition juce_MenuBarModel.cpp:45
void addListener(Listener *listenerToAdd)
Definition juce_MenuBarModel.cpp:59
void applicationCommandListChanged() override
Definition juce_MenuBarModel.cpp:85
void handleMenuBarActivate(bool isActive)
Definition juce_MenuBarModel.cpp:90
ApplicationCommandManager * manager
Definition juce_MenuBarModel.h:185
int * l
Definition inflate.c:1579
struct backing_store_struct * info
Definition jmemsys.h:183
#define jassert(expression)
Definition carla_juce.cpp:31
Definition juce_ApplicationCommandTarget.h:61