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_ComponentBuilder.h
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
29//==============================================================================
47class JUCE_API ComponentBuilder : private ValueTree::Listener
48{
49public:
55 explicit ComponentBuilder (const ValueTree& state);
56
59
61 ~ComponentBuilder() override;
62
65
66 //==============================================================================
82 Component* getManagedComponent();
83
88 Component* createComponent();
89
90 //==============================================================================
100 class JUCE_API TypeHandler
101 {
102 public:
103 //==============================================================================
107 explicit TypeHandler (const Identifier& valueTreeType);
108
110 virtual ~TypeHandler();
111
114
116 ComponentBuilder* getBuilder() const noexcept;
117
118 //==============================================================================
128 virtual Component* addNewComponentFromState (const ValueTree& state, Component* parent) = 0;
129
140 virtual void updateComponentFromState (Component* component, const ValueTree& state) = 0;
141
142 private:
143 //==============================================================================
144 friend class ComponentBuilder;
145 ComponentBuilder* builder;
146
148 };
149
150 //==============================================================================
154 void registerTypeHandler (TypeHandler* type);
155
157 TypeHandler* getHandlerForState (const ValueTree& state) const;
158
162 int getNumHandlers() const noexcept;
163
167 TypeHandler* getHandler (int index) const noexcept;
168
170 void registerStandardComponentTypes();
171
172 //==============================================================================
185 class JUCE_API ImageProvider
186 {
187 public:
188 ImageProvider() = default;
189 virtual ~ImageProvider() = default;
190
197 virtual Image getImageForIdentifier (const var& imageIdentifier) = 0;
198
202 virtual var getIdentifierForImage (const Image& image) = 0;
203 };
204
205 //==============================================================================
213 void setImageProvider (ImageProvider* newImageProvider) noexcept;
214
216 ImageProvider* getImageProvider() const noexcept;
217
218 //==============================================================================
222 void updateChildComponents (Component& parent, const ValueTree& children);
223
227 static const Identifier idProperty;
228
229private:
230 //==============================================================================
231 OwnedArray<TypeHandler> types;
232 std::unique_ptr<Component> component;
233 ImageProvider* imageProvider;
234 #if JUCE_DEBUG
235 WeakReference<Component> componentRef;
236 #endif
237
238 void valueTreePropertyChanged (ValueTree&, const Identifier&) override;
239 void valueTreeChildAdded (ValueTree&, ValueTree&) override;
240 void valueTreeChildRemoved (ValueTree&, ValueTree&, int) override;
241 void valueTreeChildOrderChanged (ValueTree&, int, int) override;
242 void valueTreeParentChanged (ValueTree&) override;
243
245};
246
247} // namespace juce
This class is used when references to images need to be stored in ValueTrees.
virtual var getIdentifierForImage(const Image &image)=0
Returns an identifier to be used to refer to a given image.
virtual Image getImageForIdentifier(const var &imageIdentifier)=0
Retrieves the image associated with this identifier, which could be any kind of string,...
The class is a base class for objects that manage the loading of a type of component from a ValueTree...
const Identifier type
Returns the type of the ValueTrees that this handler can parse.
Loads and maintains a tree of Components from a ValueTree that represents them.
ValueTree state
This is the ValueTree data object that the builder is working with.
The base class for all JUCE user-interface objects.
Represents a string identifier, designed for accessing properties by name.
Holds a fixed-size bitmap.
Definition juce_Image.h:58
An array designed for holding objects.
Listener class for events that happen to a ValueTree.
A powerful tree structure that can be used to hold free-form data, and which can handle its own undo ...
This class acts as a pointer which will automatically become null if the object to which it points is...
A variant class, that can be used to hold a range of primitive values.
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
This is a shorthand way of writing both a JUCE_DECLARE_NON_COPYABLE and JUCE_LEAK_DETECTOR macro for ...
JUCE Namespace.