tracktion-engine 3.0-10-g034fdde4aa5
Tracktion Engine — High level data model for audio applications

« « « Anklang Documentation
Loading...
Searching...
No Matches
tracktion_SelectionManager.h
Go to the documentation of this file.
1 /*
2 ,--. ,--. ,--. ,--.
3 ,-' '-.,--.--.,--,--.,---.| |,-.,-' '-.`--' ,---. ,--,--, Copyright 2024
4 '-. .-'| .--' ,-. | .--'| /'-. .-',--.| .-. || \ Tracktion Software
5 | | | | \ '-' \ `--.| \ \ | | | |' '-' '| || | Corporation
6 `---' `--' `--`--'`---'`--'`--' `---' `--' `---' `--''--' www.tracktion.com
7
8 Tracktion Engine uses a GPL/commercial licence - see LICENCE.md for details.
9*/
10
11namespace tracktion { inline namespace engine
12{
13
18 private SelectableListener
19{
20public:
21 //==============================================================================
23 ~SelectionManager() override;
24
25 //==============================================================================
26 int getNumObjectsSelected() const;
27 Selectable* getSelectedObject (int index) const;
28 bool isSelected (const Selectable*) const;
29 bool isSelected (const Selectable&) const;
30 const SelectableList& getSelectedObjects() const;
31 SelectableClass* getFirstSelectableClass() const;
32
33 void selectOnly (Selectable*);
34 void selectOnly (Selectable&);
35 void addToSelection (Selectable*);
36 void addToSelection (Selectable&);
37 void select (Selectable*, bool addToCurrentSelection);
38 void select (Selectable&, bool addToCurrentSelection);
39 void select (const SelectableList&);
40
41 void deselectAll();
42 void deselect (Selectable*);
43
45 void selectOtherObjects (SelectableClass::Relationship, bool keepOldItemsSelected);
46
47 //==============================================================================
48 template <typename SelectableClass>
49 bool containsType() const
50 {
51 return selected.containsType<SelectableClass>();
52 }
53
54 template <typename SelectableClass>
55 int getNumObjectsSelectedOfType() const
56 {
57 int numOfType = 0;
58
59 for (auto s : selected)
60 if (dynamic_cast<SelectableClass*> (s) != nullptr)
61 ++numOfType;
62
63 return numOfType;
64 }
65
66 template <typename SelectableClass>
67 juce::Array<SelectableClass*> getItemsOfType() const
68 {
70
71 for (auto s : selected)
72 if (auto item = dynamic_cast<SelectableClass*> (s))
73 items.add (item);
74
75 return items;
76 }
77
78 template <typename SelectableClass>
79 SelectableClass* getFirstItemOfType() const
80 {
81 for (auto s : selected)
82 if (auto item = dynamic_cast<SelectableClass*> (s))
83 return item;
84
85 return {};
86 }
87
88 //==============================================================================
89 void deleteSelected();
90 bool copySelected();
91 bool cutSelected();
92
96 bool pasteSelected();
97
100
101 void refreshPropertyPanel();
102 static void refreshAllPropertyPanels();
103 static void refreshAllPropertyPanelsShowing (Selectable&);
104
105 static void deselectAllFromAllWindows();
106
107 //==============================================================================
109 {
110 bool isFirstChangeSinceSelection (SelectionManager*);
111 void reset();
112
113 int lastSelectionChangeCount = 0;
114 };
115
116 // This gets incremented each time the selection changes
117 int selectionChangeCount = 0;
118
119 //==============================================================================
131
132 //==============================================================================
133 // (used internally)
134 void selectableObjectChanged (Selectable*) override;
135 void selectableObjectAboutToBeDeleted (Selectable*) override;
136
137 struct Iterator
138 {
139 Iterator();
140 bool next();
141 SelectionManager* get() const;
142 SelectionManager* operator->() const { return get(); }
143
144 int index = -1;
145 };
146
147 //==============================================================================
148 // This is a utility base-class that Components can inherit from, and which can then
149 // be found by calling SelectionManager::findSelectionManager()
151 {
154
155 virtual SelectionManager* getSelectionManager() = 0;
156 };
157
158 // walks up the parent hierarchy of a component, looking for a ComponentWithSelectionManager,
159 // and if it finds one, returns its SelectionManager.
160 static SelectionManager* findSelectionManager (const juce::Component*);
161 static SelectionManager* findSelectionManager (const juce::Component&);
162
163 //==============================================================================
164 static SelectionManager* findSelectionManagerContaining (const Selectable*);
165 static SelectionManager* findSelectionManagerContaining (const Selectable&);
166
167 Edit* getEdit() const;
168
173 int editViewID = -1;
174 EditInsertPoint* insertPoint = nullptr;
175
176 Engine& engine;
177
178private:
179 //==============================================================================
180 SelectableList selected;
181 friend class Selectable;
183
184 void selectionChanged();
185 void clearList();
186
188};
189
190}} // namespace tracktion { inline namespace engine
select
void add(const ElementType &newElement)
An EditInsertPoint is like a "paste location".
The Tracktion Edit class!
The Engine is the central class for all tracktion sessions.
Holds a pointer to some type of Selectable, which automatically becomes null if the selectable is del...
Represents a type of object that can be selected.
Base class for things that can be selected, and whose properties can appear in the properties panel.
Manages a list of items that are currently selected.
SafeSelectable< Edit > edit
If this SelectionManager is being used to represent items inside a particular view of an edit,...
void selectOtherObjects(SelectableClass::Relationship, bool keepOldItemsSelected)
Selects related objects, e.g.
bool pasteSelected()
Offers the selected things the chance to paste the contents of the clipboard onto themselves,...
void keepSelectedObjectsOnScreen()
Scrolls whatever is necessary to keep the selected stuff visible.
#define JUCE_DECLARE_NON_COPYABLE(className)
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
A list of Selectables, similar to a juce::Array but contains a cached list of the SelectableClasses f...