LMMS
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//==============================================================================
42 private FileBrowserListener,
43 private FileFilter,
44 private Timer
45{
46public:
47 //==============================================================================
68
69 //==============================================================================
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 //==============================================================================
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;
191
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
207
213 Button* goUpButton) = 0;
214 };
215
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;
255
256protected:
262 virtual void getRoots (StringArray& rootNames, StringArray& rootPaths);
263
265 void resetRecentPaths();
266
267private:
268 //==============================================================================
271
272 int flags;
276
282 std::unique_ptr<Button> goUpButton;
285
287 void timerCallback() override;
290 void updateSelectedPath();
291 void changeFilename();
292
294};
295
296} // namespace juce
#define noexcept
Definition DistrhoDefines.h:72
#define override
Definition DistrhoDefines.h:73
Definition juce_AccessibilityHandler.h:41
Definition juce_Array.h:56
Definition juce_AttributedString.h:47
Definition juce_Button.h:43
Definition juce_ComboBox.h:49
Component() noexcept
Definition juce_Component.cpp:517
Definition juce_DirectoryContentsDisplayComponent.h:38
Definition juce_DirectoryContentsList.h:43
Definition juce_Drawable.h:38
Definition juce_FileBrowserComponent.h:45
void updateSelectedPath()
Definition juce_FileBrowserComponent.cpp:488
int flags
Definition juce_FileBrowserComponent.h:272
void timerCallback() override
Definition juce_FileBrowserComponent.cpp:606
void sendListenerChangeMessage()
Definition juce_FileBrowserComponent.cpp:377
FileChooserFlags
Definition juce_FileBrowserComponent.h:53
@ saveMode
Definition juce_FileBrowserComponent.h:56
@ canSelectMultipleItems
Definition juce_FileBrowserComponent.h:62
@ warnAboutOverwriting
Definition juce_FileBrowserComponent.h:65
@ canSelectFiles
Definition juce_FileBrowserComponent.h:58
@ filenameBoxIsReadOnly
Definition juce_FileBrowserComponent.h:64
@ doNotClearFileNameOnRootChange
Definition juce_FileBrowserComponent.h:66
@ useTreeView
Definition juce_FileBrowserComponent.h:63
@ canSelectDirectories
Definition juce_FileBrowserComponent.h:60
@ openMode
Definition juce_FileBrowserComponent.h:54
std::unique_ptr< DirectoryContentsList > fileList
Definition juce_FileBrowserComponent.h:269
ComboBox currentPathBox
Definition juce_FileBrowserComponent.h:279
FileBrowserComponent(int flags, const File &initialFileOrDirectory, const FileFilter *fileFilter, FilePreviewComponent *previewComp)
Definition juce_FileBrowserComponent.cpp:29
File currentRoot
Definition juce_FileBrowserComponent.h:273
bool wasProcessActive
Definition juce_FileBrowserComponent.h:284
Array< File > chosenFiles
Definition juce_FileBrowserComponent.h:274
ListenerList< FileBrowserListener > listeners
Definition juce_FileBrowserComponent.h:275
bool isFileOrDirSuitable(const File &) const
Definition juce_FileBrowserComponent.cpp:205
const FileFilter * fileFilter
Definition juce_FileBrowserComponent.h:270
std::unique_ptr< DirectoryContentsDisplayComponent > fileListComponent
Definition juce_FileBrowserComponent.h:277
std::unique_ptr< Button > goUpButton
Definition juce_FileBrowserComponent.h:282
TextEditor filenameBox
Definition juce_FileBrowserComponent.h:280
void changeFilename()
Definition juce_FileBrowserComponent.cpp:459
FilePreviewComponent * previewComp
Definition juce_FileBrowserComponent.h:278
std::unique_ptr< AccessibilityHandler > createAccessibilityHandler() override
Definition juce_FileBrowserComponent.cpp:620
ColourIds
Definition juce_FileBrowserComponent.h:224
@ currentPathBoxTextColourId
Definition juce_FileBrowserComponent.h:226
@ filenameBoxBackgroundColourId
Definition juce_FileBrowserComponent.h:228
@ currentPathBoxBackgroundColourId
Definition juce_FileBrowserComponent.h:225
@ filenameBoxTextColourId
Definition juce_FileBrowserComponent.h:229
@ currentPathBoxArrowColourId
Definition juce_FileBrowserComponent.h:227
TimeSliceThread thread
Definition juce_FileBrowserComponent.h:283
Label fileLabel
Definition juce_FileBrowserComponent.h:281
Definition juce_FileBrowserListener.h:38
Definition juce_FileFilter.h:38
FileFilter(const String &filterDescription)
Definition juce_FileFilter.cpp:26
Definition juce_File.h:45
Definition juce_FilePreviewComponent.h:44
Definition juce_GraphicsContext.h:45
Definition juce_Image.h:58
Definition juce_KeyPress.h:40
Definition juce_Label.h:41
Definition juce_ListenerList.h:70
Definition juce_MouseEvent.h:39
Definition juce_StringArray.h:35
Definition juce_String.h:53
Definition juce_TextEditor.h:43
Definition juce_TimeSliceThread.h:83
Timer() noexcept
Definition juce_Timer.cpp:316
static char filename[]
Definition features.c:5
static const char * title
Definition pugl.h:1747
static const char * name
Definition pugl.h:1582
static int int height
Definition pugl.h:1594
static int width
Definition pugl.h:1593
#define JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(className)
#define JUCE_API
Definition juce_StandardHeader.h:152
Definition carla_juce.cpp:31
jack_client_t client jack_client_t client jack_client_t client jack_client_t JackInfoShutdownCallback void arg jack_client_t jack_port_t port void func jack_client_t const char const char unsigned long flags
Definition juce_linux_JackAudio.cpp:69
Definition juce_Uuid.h:141
Definition juce_FileBrowserComponent.h:184
virtual AttributedString createFileChooserHeaderText(const String &title, const String &instructions)=0
virtual void layoutFileBrowserComponent(FileBrowserComponent &browserComp, DirectoryContentsDisplayComponent *fileListComponent, FilePreviewComponent *previewComp, ComboBox *currentPathBox, TextEditor *filenameBox, Button *goUpButton)=0
virtual const Drawable * getDefaultFolderImage()=0
virtual const Drawable * getDefaultDocumentFileImage()=0
virtual void drawFileBrowserRow(Graphics &, int width, int height, const File &file, const String &filename, Image *optionalIcon, const String &fileSizeDescription, const String &fileTimeDescription, bool isDirectory, bool isItemSelected, int itemIndex, DirectoryContentsDisplayComponent &)=0
struct zdirent * file
Definition win32.c:1500
#define const
Definition zconf.h:137