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_FileBrowserComponent.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//==============================================================================
41class JUCE_API FileBrowserComponent : public Component,
42 private FileBrowserListener,
43 private FileFilter,
44 private Timer
45{
46public:
47 //==============================================================================
53 {
54 openMode = 1,
56 saveMode = 2,
58 canSelectFiles = 4,
60 canSelectDirectories = 8,
62 canSelectMultipleItems = 16,
63 useTreeView = 32,
64 filenameBoxIsReadOnly = 64,
65 warnAboutOverwriting = 128,
66 doNotClearFileNameOnRootChange = 256
67 };
68
69 //==============================================================================
84 FileBrowserComponent (int flags,
85 const File& initialFileOrDirectory,
86 const FileFilter* fileFilter,
87 FilePreviewComponent* previewComp);
88
90 ~FileBrowserComponent() override;
91
92 //==============================================================================
97 int getNumSelectedFiles() const noexcept;
98
104 File getSelectedFile (int index) const noexcept;
105
107 void deselectAllFiles();
108
116 bool currentFileIsValid() const;
117
124 File getHighlightedFile() const noexcept;
125
126 //==============================================================================
128 const File& getRoot() const;
129
131 void setRoot (const File& newRootDirectory);
132
134 void setFileName (const String& newName);
135
137 void goUp();
138
140 void refresh();
141
143 void setFileFilter (const FileFilter* newFileFilter);
144
150 virtual String getActionVerb() const;
151
153 bool isSaveMode() const noexcept;
154
159 void setFilenameBoxLabel (const String& name);
160
161 //==============================================================================
165 void addListener (FileBrowserListener* listener);
166
170 void removeListener (FileBrowserListener* listener);
171
177 static void getDefaultRoots (StringArray& rootNames, StringArray& rootPaths);
178
179 //==============================================================================
183 struct JUCE_API LookAndFeelMethods
184 {
185 virtual ~LookAndFeelMethods() = default;
186
187 // These return a pointer to an internally cached drawable - make sure you don't keep
188 // a copy of this pointer anywhere, as it may become invalid in the future.
189 virtual const Drawable* getDefaultFolderImage() = 0;
190 virtual const Drawable* getDefaultDocumentFileImage() = 0;
191
192 virtual AttributedString createFileChooserHeaderText (const String& title,
193 const String& instructions) = 0;
194
195 virtual void drawFileBrowserRow (Graphics&, int width, int height,
196 const File& file,
197 const String& filename,
198 Image* optionalIcon,
199 const String& fileSizeDescription,
200 const String& fileTimeDescription,
201 bool isDirectory,
202 bool isItemSelected,
203 int itemIndex,
205
206 virtual Button* createFileBrowserGoUpButton() = 0;
207
208 virtual void layoutFileBrowserComponent (FileBrowserComponent& browserComp,
209 DirectoryContentsDisplayComponent* fileListComponent,
210 FilePreviewComponent* previewComp,
211 ComboBox* currentPathBox,
212 TextEditor* filenameBox,
213 Button* goUpButton) = 0;
214 };
215
224 {
225 currentPathBoxBackgroundColourId = 0x1000640,
226 currentPathBoxTextColourId = 0x1000641,
227 currentPathBoxArrowColourId = 0x1000642,
228 filenameBoxBackgroundColourId = 0x1000643,
229 filenameBoxTextColourId = 0x1000644
230 };
231
232 //==============================================================================
234 void resized() override;
236 void lookAndFeelChanged() override;
238 bool keyPressed (const KeyPress&) override;
240 void selectionChanged() override;
242 void fileClicked (const File&, const MouseEvent&) override;
244 void fileDoubleClicked (const File&) override;
246 void browserRootChanged (const File&) override;
248 bool isFileSuitable (const File&) const override;
250 bool isDirectorySuitable (const File&) const override;
252 FilePreviewComponent* getPreviewComponent() const noexcept;
254 DirectoryContentsDisplayComponent* getDisplayComponent() const noexcept;
256 std::unique_ptr<AccessibilityHandler> createAccessibilityHandler() override;
257
258protected:
264 virtual void getRoots (StringArray& rootNames, StringArray& rootPaths);
265
267 void resetRecentPaths();
268
269private:
270 //==============================================================================
271 std::unique_ptr<DirectoryContentsList> fileList;
272 const FileFilter* fileFilter;
273
274 int flags;
275 File currentRoot;
276 Array<File> chosenFiles;
278
279 std::unique_ptr<DirectoryContentsDisplayComponent> fileListComponent;
280 FilePreviewComponent* previewComp;
281 ComboBox currentPathBox;
282 TextEditor filenameBox;
283 Label fileLabel;
284 std::unique_ptr<Button> goUpButton;
285 TimeSliceThread thread;
286 bool wasProcessActive;
287
288 void timerCallback() override;
289 void sendListenerChangeMessage();
290 bool isFileOrDirSuitable (const File&) const;
291 void updateSelectedPath();
292 void changeFilename();
293
295};
296
297} // namespace juce
Base class for accessible Components.
Holds a resizable array of primitive or copy-by-value objects.
Definition juce_Array.h:56
A text string with a set of colour/font settings that are associated with sub-ranges of the text.
A base class for buttons.
Definition juce_Button.h:43
A component that lets the user choose from a drop-down list of choices.
The base class for all JUCE user-interface objects.
A base class for components that display a list of the files in a directory.
A class to asynchronously scan for details about the files in a directory.
The base class for objects which can draw themselves, e.g.
A component for browsing and selecting a file or directory to open or save.
FileChooserFlags
Various options for the browser.
ColourIds
A set of colour IDs to use to change the colour of various aspects of the FileBrowserComponent.
A listener for user selection events in a file browser.
Interface for deciding which files are suitable for something.
Base class for components that live inside a file chooser dialog box and show previews of the files t...
Represents a local file or directory.
Definition juce_File.h:45
A graphics context, used for drawing a component or image.
Holds a fixed-size bitmap.
Definition juce_Image.h:58
Represents a key press, including any modifier keys that are needed.
A component that displays a text string, and can optionally become a text editor when clicked.
Definition juce_Label.h:41
Holds a set of objects and can invoke a member function callback on each object in the set with a sin...
Contains position and status information about a mouse event.
A special array for holding a list of strings.
The JUCE String class!
Definition juce_String.h:53
An editable text box.
A thread that keeps a list of clients, and calls each one in turn, giving them all a chance to run so...
Makes repeated callbacks to a virtual method at a specified time interval.
Definition juce_Timer.h:52
#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.
This abstract base class is implemented by LookAndFeel classes to provide various file-browser layout...