|
|
@@ -6,21 +6,27 @@
|
|
|
|
|
|
namespace lynx
|
|
|
{
|
|
|
-// File browser (like FL's Browser): FL and user sample folders, drawn by LYNX itself so it can show
|
|
|
-// what the mouse is over and explain it in the hint bar.
|
|
|
+// File browser (like FL's Browser): drawn by LYNX itself so it can show what the mouse is over and explain it
|
|
|
+// in the hint bar.
|
|
|
+// - two tabs, as FL's Browser: ALL (the current project, then every sample folder: FL's folders, Documents,
|
|
|
+// Music, Desktop, Downloads and the user's folders, each with its own colour) and PROJECT (only the current
|
|
|
+// project, opened)
|
|
|
+// - "Current project" (REA_rodada115): history, patterns, effects, generators, automation, the project folder
|
|
|
+// and the audio files the project uses, each item in the colour of what it belongs to, with a short detail
|
|
|
+// (the insert, how often it is used, "missing"); click / double-click / drag / right-click act on it
|
|
|
// - a click on a folder opens / closes it; a click on an audio file previews it (the strip at the bottom
|
|
|
// shows its waveform and the playback position); double-click: new sampler channel with it
|
|
|
// - drag a file onto the Channel Rack (new channel, or onto a row: replaces its sample), the Playlist (audio
|
|
|
-// clip where it is dropped) or a mixer insert (effect presets)
|
|
|
+// clip where it is dropped) or a mixer insert (effect presets); drag a pattern onto the Playlist (a clip)
|
|
|
// - double-click a .lynx/.flp/.mid: opens it (onOpenProject)
|
|
|
-// - search box (Ctrl+F): searches the current folder and below (core/SearchQuery syntax); Esc clears
|
|
|
+// - search box (Ctrl+F): ALL searches the folder of the selection (or every folder) and below
|
|
|
+// (core/SearchQuery syntax); PROJECT filters the project's items; Esc clears
|
|
|
// - keys while the Browser has focus: Up/Down step and preview, Shift+Up/Down step and load each file
|
|
|
// into the selected channel, Enter loads the selected file into the selected channel, Left/Right
|
|
|
// close / open folders
|
|
|
-// - right-click: folder menu (collapse all, open in the file manager, add folder)
|
|
|
-// - the folder list has "Add folder..." for user folders (kept in the user settings)
|
|
|
class BrowserComponent final : public juce::Component,
|
|
|
private juce::TextEditor::Listener,
|
|
|
+ private juce::ChangeListener,
|
|
|
private juce::Timer
|
|
|
{
|
|
|
public:
|
|
|
@@ -30,6 +36,26 @@ public:
|
|
|
std::function<void (const juce::File&)> onOpenProject;
|
|
|
// Enter / Shift+Up/Down: put this file into the selected channel; returns false if it can't take it.
|
|
|
std::function<bool (const juce::File&)> onLoadIntoChannel;
|
|
|
+ // Current project items (set by the main window)
|
|
|
+ std::function<void (int)> onOpenPattern; // double-click a pattern: it opens in the Piano Roll
|
|
|
+ std::function<void (int)> onPatternMenu; // right-click a pattern (already selected): the pattern menu
|
|
|
+ std::function<void (int)> onOpenChannel; // double-click a generator: its settings / plugin window
|
|
|
+ std::function<void (int, int)> onOpenEffect; // double-click an effect (insert, slot): its editor
|
|
|
+ std::function<void (int)> onShowInsert; // an effect's / generator's insert in the Mixer
|
|
|
+ std::function<void (int)> onOpenAutomation; // double-click an automation clip: its editor
|
|
|
+ std::function<void (const juce::File&)> onSendToPlaylist; // a sample's "Send to the Playlist as an audio clip"
|
|
|
+
|
|
|
+ // The project's file (.lynx, or the imported .flp): its folder shows as "Project folder".
|
|
|
+ void setProjectFile (const juce::File& file);
|
|
|
+
|
|
|
+ enum Tab
|
|
|
+ {
|
|
|
+ allTab,
|
|
|
+ projectTab,
|
|
|
+ tabCount
|
|
|
+ };
|
|
|
+ void setTab (int tab);
|
|
|
+ int getTab() const noexcept { return tab; }
|
|
|
|
|
|
void focusSearch();
|
|
|
void addUserFolder(); // asks for a folder and adds it to the folder list
|
|
|
@@ -38,6 +64,8 @@ public:
|
|
|
// For snapshots: selects (and "previews" without sound) the first audio file under the first folder,
|
|
|
// and puts the mouse over the row after it.
|
|
|
void selectFirstSampleForSnapshot();
|
|
|
+ // --snapshot: the PROJECT tab with the patterns, generators and samples open, a sample selected
|
|
|
+ void showProjectForSnapshot();
|
|
|
// --snapshot: shows this audio file in the preview strip (without playing it)
|
|
|
void showPreviewForSnapshot (const juce::File& file);
|
|
|
// Up/Down (load = false) or Shift+Up/Down (load = true); Enter = loadSelected()
|
|
|
@@ -50,6 +78,8 @@ public:
|
|
|
// Drags from the Browser (tree or search results): is it one, and which file it carries.
|
|
|
static bool isBrowserDrag (const juce::DragAndDropTarget::SourceDetails& details);
|
|
|
static juce::File draggedFile (const juce::DragAndDropTarget::SourceDetails& details);
|
|
|
+ // A pattern dragged from "Current project > Patterns": its index, else -1.
|
|
|
+ static int draggedPattern (const juce::DragAndDropTarget::SourceDetails& details);
|
|
|
static bool isAudioFile (const juce::File& file);
|
|
|
|
|
|
void resized() override;
|
|
|
@@ -59,40 +89,47 @@ public:
|
|
|
void paint (juce::Graphics& g) override;
|
|
|
|
|
|
static constexpr const char* dragDescription = "lynx-arquivo";
|
|
|
+ static constexpr const char* patternDragDescription = "lynx-pattern";
|
|
|
static constexpr int addFolderId = 1000;
|
|
|
|
|
|
- class FileTree; // the folder tree / search results (implementation detail)
|
|
|
+ class FileTree; // the folder tree / search results (implementation detail)
|
|
|
class PreviewStrip; // waveform of the selected sample
|
|
|
+ class TabBar; // ALL / PROJECT
|
|
|
|
|
|
private:
|
|
|
- void setRoot (int index);
|
|
|
void textEditorTextChanged (juce::TextEditor&) override;
|
|
|
void textEditorEscapeKeyPressed (juce::TextEditor&) override;
|
|
|
void textEditorReturnKeyPressed (juce::TextEditor&) override;
|
|
|
+ void changeListenerCallback (juce::ChangeBroadcaster*) override;
|
|
|
void timerCallback() override;
|
|
|
void runSearch();
|
|
|
void rebuildRoots();
|
|
|
+ void rebuildTree();
|
|
|
static juce::File userFoldersFile();
|
|
|
void openFile (const juce::File& file); // what a double-click does
|
|
|
void fileSelected (const juce::File& file, bool preview);
|
|
|
void showFolderMenu (const juce::File& folder);
|
|
|
void showFileMenu (const juce::File& file);
|
|
|
FileTree& activeList() const;
|
|
|
+ juce::Array<juce::File> searchRoots() const;
|
|
|
juce::File previewedFile; // the sample last sent to the preview player
|
|
|
bool isPreviewPlaying() const;
|
|
|
|
|
|
std::unique_ptr<FileTree> tree, results;
|
|
|
std::unique_ptr<juce::Viewport> treeView, resultsView;
|
|
|
std::unique_ptr<PreviewStrip> strip;
|
|
|
+ std::unique_ptr<TabBar> tabs;
|
|
|
class SearchJob;
|
|
|
std::unique_ptr<SearchJob> job;
|
|
|
juce::TextEditor searchBox;
|
|
|
std::unique_ptr<juce::FileChooser> chooser;
|
|
|
- int currentRoot = 0;
|
|
|
+ int tab = allTab;
|
|
|
+ bool searchPending = false, projectDirty = false;
|
|
|
+ juce::File projectFile;
|
|
|
|
|
|
AudioEngine& engine;
|
|
|
- juce::ComboBox rootBox;
|
|
|
juce::Array<juce::File> roots;
|
|
|
+ juce::StringArray rootNames;
|
|
|
|
|
|
JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (BrowserComponent)
|
|
|
};
|