Vital
Loading...
Searching...
No Matches
popup_browser.h
Go to the documentation of this file.
1#pragma once
2
3#include "JuceHeader.h"
4#include "delete_section.h"
5#include "load_save.h"
6#include "open_gl_image.h"
10#include "overlay.h"
11#include "save_section.h"
12#include "synth_section.h"
13
21class PopupDisplay : public SynthSection {
22 public:
25
27 void resized() override;
28
35 void setContent(const std::string& text, Rectangle<int> bounds, BubbleComponent::BubblePlacement placement);
36
37 private:
39 OpenGlQuad body_;
40 OpenGlQuad border_;
41
42 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PopupDisplay)
43};
44
52class PopupList : public SynthSection, ScrollBar::Listener {
53 public:
58 class Listener {
59 public:
60 virtual ~Listener() = default;
61
68 virtual void newSelection(PopupList* list, int id, int index) = 0;
69
76 virtual void doubleClickedSelected(PopupList* list, int id, int index) { }
77 };
78
79 static constexpr float kRowHeight = 24.0f;
80 static constexpr float kScrollSensitivity = 200.0f;
81 static constexpr float kScrollBarWidth = 15.0f;
82
84 PopupList();
85
86 void paintBackground(Graphics& g) override { }
87 void paintBackgroundShadow(Graphics& g) override { }
88 void resized() override;
89
94 void setSelections(PopupItems selections);
95
101 PopupItems getSelectionItems(int index) const { return selections_.items[index]; }
102
108 int getRowFromPosition(float mouse_position);
109
115
120 int getTextPadding() { return getRowHeight() / 4; }
121
126 int getBrowseWidth();
127
132 int getBrowseHeight() { return getRowHeight() * selections_.size(); }
133
138 Font getFont() {
139 return Fonts::instance()->proportional_light().withPointHeight(getRowHeight() * 0.55f * getPixelMultiple());
140 }
141 void mouseMove(const MouseEvent& e) override;
142 void mouseDrag(const MouseEvent& e) override;
143 void mouseExit(const MouseEvent& e) override;
144
150 int getSelection(const MouseEvent& e);
151
152 void mouseUp(const MouseEvent& e) override;
153 void mouseDoubleClick(const MouseEvent& e) override;
154
159 void setSelected(int selection) { selected_ = selection; }
160
165 int getSelected() const { return selected_; }
166 void mouseWheelMove(const MouseEvent& e, const MouseWheelDetails& wheel) override;
167 void resetScrollPosition();
168 void scrollBarMoved(ScrollBar* scroll_bar, double range_start) override;
169 void setScrollBarRange();
170
175 int getScrollableRange();
176
177 void initOpenGlComponents(OpenGlWrapper& open_gl) override;
178 void renderOpenGlComponents(OpenGlWrapper& open_gl, bool animate) override;
179 void destroyOpenGlComponents(OpenGlWrapper& open_gl) override;
180
185 void addListener(Listener* listener) {
186 listeners_.push_back(listener);
187 }
188
193 void showSelected(bool show) { show_selected_ = show; }
194
199 void select(int select);
200
201 private:
202 int getViewPosition() {
203 int view_height = getHeight();
204 return std::max(0, std::min<int>(selections_.size() * getRowHeight() - view_height, view_position_));
205 }
206 void redoImage();
207 void moveQuadToRow(OpenGlQuad& quad, int row);
208
209 std::vector<Listener*> listeners_;
210 PopupItems selections_;
211 int selected_;
212 int hovered_;
213 bool show_selected_;
214
215 float view_position_;
216 std::unique_ptr<OpenGlScrollBar> scroll_bar_;
217 OpenGlImage rows_;
218 OpenGlQuad highlight_;
219 OpenGlQuad hover_;
220
221 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PopupList)
222};
223
232class SelectionList : public SynthSection, ScrollBar::Listener {
233 public:
238 class Listener {
239 public:
240 virtual ~Listener() = default;
241
246 virtual void newSelection(File selection) = 0;
247
251 virtual void allSelected() { }
252
256 virtual void favoritesSelected() { }
257
262 virtual void doubleClickedSelected(File selection) = 0;
263 };
264
265 static constexpr int kNumCachedRows = 50;
266 static constexpr float kRowHeight = 24.0f;
267 static constexpr float kStarWidth = 38.0f;
268 static constexpr float kScrollSensitivity = 200.0f;
269 static constexpr float kScrollBarWidth = 15.0f;
270
275 static File getAllFile() { return File::getSpecialLocation(File::tempDirectory).getChildFile("All"); }
276
281 static File getFavoritesFile() { return File::getSpecialLocation(File::tempDirectory).getChildFile("Favorites"); }
282
288 public:
289 static int compareElements(const File& first, const File& second) {
290 String first_name = first.getFullPathName().toLowerCase();
291 String second_name = second.getFullPathName().toLowerCase();
292 return first_name.compareNatural(second_name);
293 }
294 };
295
298
299 void paintBackground(Graphics& g) override { }
300 void paintBackgroundShadow(Graphics& g) override { }
301 void resized() override;
302
306 void addFavoritesOption() { favorites_option_ = true; selected_ = getAllFile(); }
307
312 void setSelections(Array<File> presets);
313 Array<File> getSelections() { return selections_; }
314 Array<File> getAdditionalFolders() { return additional_roots_; }
315
316 void resetScrollPosition();
317 void mouseWheelMove(const MouseEvent& e, const MouseWheelDetails& wheel) override;
318 int getRowFromPosition(float mouse_position);
319
325
330 int getIconPadding() { return getRowHeight() * 0.25f; }
331
332 void mouseMove(const MouseEvent& e) override;
333 void mouseExit(const MouseEvent& e) override;
334 void respondToMenuCallback(int result);
335 void menuClick(const MouseEvent& e);
336 void leftClick(const MouseEvent& e);
337
343 File getSelection(const MouseEvent& e);
344
345 void mouseDown(const MouseEvent& e) override;
346 void mouseDoubleClick(const MouseEvent& e) override;
347 void addAdditionalFolder();
348 void removeAdditionalFolder(const File& folder);
349
354 void select(const File& selection);
355
360 File selected() const { return selected_; }
361
366 void setSelected(const File& selection) { selected_ = selection; }
367
372 void selectIcon(const File& selection);
373
374 void scrollBarMoved(ScrollBar* scroll_bar, double range_start) override;
375 void setScrollBarRange();
376
380 void redoCache();
381
387 int getFolderDepth(const File& file);
388
394 void addSubfolderSelections(const File& selection, std::vector<File>& selections);
395
400 void setAdditionalRootsName(const std::string& name);
401
406 void filter(const String& filter_string);
407
412 int getSelectedIndex();
413
418 int getScrollableRange();
419
423 void selectNext();
424
428 void selectPrev();
429
430 void initOpenGlComponents(OpenGlWrapper& open_gl) override;
431 void renderOpenGlComponents(OpenGlWrapper& open_gl, bool animate) override;
432 void destroyOpenGlComponents(OpenGlWrapper& open_gl) override;
433
438 void addListener(Listener* listener) {
439 listeners_.push_back(listener);
440 }
441
442 void setPassthroughFolderName(const std::string& name) { passthrough_name_ = name; }
443 std::string getPassthroughFolderName() const { return passthrough_name_; }
444
450 for (File& selection : selections_) {
451 if (selection.exists())
452 return true;
453 }
454 return false;
455 }
456
457 private:
458 void viewPositionChanged();
459 void toggleFavorite(const File& selection);
460 void toggleOpenFolder(const File& selection);
461 int getViewPosition() {
462 int view_height = getHeight();
463 return std::max(0, std::min<int>(num_view_selections_ * getRowHeight() - view_height, view_position_));
464 }
465 void loadBrowserCache(int start_index, int end_index);
466 void moveQuadToRow(OpenGlQuad& quad, int row, float y_offset);
467 void sort();
468
469 bool favorites_option_;
470 std::vector<Listener*> listeners_;
471 Array<File> selections_;
472 std::string additional_roots_name_;
473 Array<File> additional_roots_;
474 int num_view_selections_;
475 std::vector<File> filtered_selections_;
476 std::set<std::string> favorites_;
477 std::map<std::string, int> open_folders_;
478 std::unique_ptr<OpenGlScrollBar> scroll_bar_;
479 String filter_string_;
480 File selected_;
481 int hovered_;
482 bool x_area_;
483
484 Component browse_area_;
485 int cache_position_;
487 bool is_additional_[kNumCachedRows];
488 OpenGlQuad highlight_;
489 OpenGlQuad hover_;
490 PlainShapeComponent remove_additional_x_;
491 float view_position_;
492 std::string passthrough_name_;
493
494 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SelectionList)
495};
496
505 public:
508
509 void paintBackground(Graphics& g) override { }
510 void paintBackgroundShadow(Graphics& g) override { }
511 void resized() override;
512
513 void visibilityChanged() override {
514 if (isShowing() && isVisible())
515 grabKeyboardFocus();
516 }
517
523 void setPosition(Point<int> position, Rectangle<int> bounds);
524
525 void newSelection(PopupList* list, int id, int index) override {
526 if (id >= 0) {
527 cancel_ = nullptr;
528 callback_(id);
529 setVisible(false);
530 }
531 else
532 cancel_();
533 }
534
535 void focusLost(FocusChangeType cause) override {
536 setVisible(false);
537 if (cancel_)
538 cancel_();
539 }
540
545 void setCallback(std::function<void(int)> callback) { callback_ = std::move(callback); }
546
551 void setCancelCallback(std::function<void()> cancel) { cancel_ = std::move(cancel); }
552
557 void showSelections(const PopupItems& selections) {
558 popup_list_->setSelections(selections);
559 }
560
561 private:
562 OpenGlQuad body_;
563 OpenGlQuad border_;
564
565 std::function<void(int)> callback_;
566 std::function<void()> cancel_;
567 std::unique_ptr<PopupList> popup_list_;
568
569 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(SinglePopupSelector)
570};
571
581 public:
584
585 void paintBackground(Graphics& g) override { }
586 void paintBackgroundShadow(Graphics& g) override { }
587 void resized() override;
588 void visibilityChanged() override {
589 if (isShowing() && isVisible())
590 grabKeyboardFocus();
591 }
592
599 void setPosition(Point<int> position, int width, Rectangle<int> bounds);
600
601 void newSelection(PopupList* list, int id, int index) override;
602 void doubleClickedSelected(PopupList* list, int id, int index) override { setVisible(false); }
603
604 void focusLost(FocusChangeType cause) override { setVisible(false); }
605
610 void setCallback(std::function<void(int)> callback) { callback_ = std::move(callback); }
611
616 void showSelections(const PopupItems& selections) {
617 left_list_->setSelections(selections);
618
619 for (int i = 0; i < selections.size(); ++i) {
620 if (selections.items[i].selected)
621 right_list_->setSelections(selections.items[i]);
622 }
623 }
624
625 private:
626 OpenGlQuad body_;
627 OpenGlQuad border_;
628 OpenGlQuad divider_;
629
630 std::function<void(int)> callback_;
631 std::unique_ptr<PopupList> left_list_;
632 std::unique_ptr<PopupList> right_list_;
633
634 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DualPopupSelector)
635};
636
643class PopupClosingArea : public Component {
644 public:
645 PopupClosingArea() : Component("Ignore Area") { }
646
651 class Listener {
652 public:
653 virtual ~Listener() = default;
659 virtual void closingAreaClicked(PopupClosingArea* closing_area, const MouseEvent& e) = 0;
660 };
661
662 void mouseDown(const MouseEvent& e) override {
663 for (Listener* listener : listeners_)
664 listener->closingAreaClicked(this, e);
665 }
666
671 void addListener(Listener* listener) { listeners_.push_back(listener); }
672
673 private:
674 std::vector<Listener*> listeners_;
675};
676
687 public TextEditor::Listener,
688 public KeyListener,
690 public:
692 PopupBrowser();
695
696 void paintBackground(Graphics& g) override { }
697 void paintBackgroundShadow(Graphics& g) override { }
698 void resized() override;
699 void buttonClicked(Button* clicked_button) override;
700 void visibilityChanged() override;
701
705 void filterPresets();
706 void textEditorTextChanged(TextEditor& editor) override;
707 void textEditorEscapeKeyPressed(TextEditor& editor) override;
708
709 void newSelection(File selection) override;
710 void allSelected() override;
711 void favoritesSelected() override;
712 void doubleClickedSelected(File selection) override;
713 void closingAreaClicked(PopupClosingArea* closing_area, const MouseEvent& e) override;
714
715 bool keyPressed(const KeyPress &key, Component *origin) override;
716 bool keyStateChanged(bool is_key_down, Component *origin) override;
717
721 void checkNoContent();
722
726 void checkStoreButton();
727
735 void loadPresets(std::vector<File> directories, const String& extensions,
736 const std::string& passthrough_name, const std::string& additional_folders_name);
737
742 void setOwner(SynthSection* owner) {
743 owner_ = owner;
744 if (owner_)
745 selection_list_->setSelected(owner_->getCurrentFile());
747 }
748
753 void setIgnoreBounds(Rectangle<int> bounds) { passthrough_bounds_ = bounds; resized(); }
754
759 void setBrowserBounds(Rectangle<int> bounds) { browser_bounds_ = bounds; resized(); }
760
761 private:
762 OpenGlQuad body_;
763 OpenGlQuad border_;
764 OpenGlQuad horizontal_divider_;
765 OpenGlQuad vertical_divider_;
766
767 std::unique_ptr<SelectionList> folder_list_;
768 std::unique_ptr<SelectionList> selection_list_;
769 std::unique_ptr<OpenGlTextEditor> search_box_;
770 std::unique_ptr<OpenGlShapeButton> exit_button_;
771 std::unique_ptr<OpenGlToggleButton> store_button_;
772 std::unique_ptr<OpenGlToggleButton> download_button_;
773 Rectangle<int> passthrough_bounds_;
774 Rectangle<int> browser_bounds_;
775 PopupClosingArea closing_areas_[4];
776
777 SynthSection* owner_;
778 String extensions_;
779 String author_;
780 std::set<std::string> more_author_presets_;
781
782 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PopupBrowser)
783};
A popup for selecting from a hierarchical set of items in two columns.
Definition popup_browser.h:580
void setCallback(std::function< void(int)> callback)
Sets the callback for when a final selection is made.
Definition popup_browser.h:610
void paintBackground(Graphics &g) override
Paints the background of the section. Calls paintContainer, heading, knobs, children.
Definition popup_browser.h:585
void paintBackgroundShadow(Graphics &g) override
Stub for painting background shadows. Overridden by subclasses if needed.
Definition popup_browser.h:586
DualPopupSelector()
Constructs a DualPopupSelector.
Definition popup_browser.cpp:1004
void focusLost(FocusChangeType cause) override
Definition popup_browser.h:604
void visibilityChanged() override
Definition popup_browser.h:588
void newSelection(PopupList *list, int id, int index) override
Called when a new selection is made.
Definition popup_browser.cpp:1068
void showSelections(const PopupItems &selections)
Displays selections in the left list and updates the right list accordingly.
Definition popup_browser.h:616
void resized() override
Called when the component is resized. Arranges layout of child components.
Definition popup_browser.cpp:1031
void doubleClickedSelected(PopupList *list, int id, int index) override
Called when the user double-clicks the selected item.
Definition popup_browser.h:602
void setPosition(Point< int > position, int width, Rectangle< int > bounds)
Positions the DualPopupSelector.
Definition popup_browser.cpp:1056
Font & proportional_light()
Returns a reference to the proportional light font.
Definition fonts.h:28
static Fonts * instance()
Gets the singleton instance of the Fonts class.
Definition fonts.h:52
A utility class for rendering a single image using OpenGL.
Definition open_gl_image.h:16
A convenience class for a single quad rendered via OpenGL.
Definition open_gl_multi_quad.h:447
A component that draws a shape into an OpenGlImageComponent.
Definition open_gl_image_component.h:417
A text component rendered into an OpenGlImageComponent with configurable font and justification.
Definition open_gl_image_component.h:301
A popup browser interface for browsing and selecting files (e.g. presets).
Definition popup_browser.h:689
void doubleClickedSelected(File selection) override
Called when a file is double-clicked.
Definition popup_browser.cpp:1278
void paintBackgroundShadow(Graphics &g) override
Stub for painting background shadows. Overridden by subclasses if needed.
Definition popup_browser.h:697
PopupBrowser()
Constructs a PopupBrowser.
Definition popup_browser.cpp:1090
void loadPresets(std::vector< File > directories, const String &extensions, const std::string &passthrough_name, const std::string &additional_folders_name)
Loads presets from a set of directories.
Definition popup_browser.cpp:1330
bool keyStateChanged(bool is_key_down, Component *origin) override
Definition popup_browser.cpp:1302
void visibilityChanged() override
Definition popup_browser.cpp:1220
void filterPresets()
Filters the displayed presets based on the search text.
Definition popup_browser.cpp:1392
~PopupBrowser()
Destructor.
void closingAreaClicked(PopupClosingArea *closing_area, const MouseEvent &e) override
Called when the closing area is clicked.
Definition popup_browser.cpp:1308
void newSelection(File selection) override
Called when a new File is selected.
Definition popup_browser.cpp:1232
void favoritesSelected() override
Called when "Favorites" special selection is made.
Definition popup_browser.cpp:1260
void setOwner(SynthSection *owner)
Sets the owner SynthSection for which this popup browser was opened.
Definition popup_browser.h:742
void setBrowserBounds(Rectangle< int > bounds)
Sets the main browser bounds.
Definition popup_browser.h:759
void textEditorEscapeKeyPressed(TextEditor &editor) override
Definition popup_browser.cpp:1401
void setIgnoreBounds(Rectangle< int > bounds)
Sets the ignored bounds (the "passthrough" area) that won't close the browser.
Definition popup_browser.h:753
void allSelected() override
Called when "All" special selection is made.
Definition popup_browser.cpp:1247
bool keyPressed(const KeyPress &key, Component *origin) override
Definition popup_browser.cpp:1283
void textEditorTextChanged(TextEditor &editor) override
Definition popup_browser.cpp:1397
void checkStoreButton()
Checks and updates if the store button should be displayed.
Definition popup_browser.cpp:1320
void buttonClicked(Button *clicked_button) override
Called when a button is clicked. Updates the synth parameter accordingly.
Definition popup_browser.cpp:1405
void checkNoContent()
Checks and updates the UI if there is no content available.
Definition popup_browser.cpp:1313
void resized() override
Called when the component is resized. Arranges layout of child components.
Definition popup_browser.cpp:1154
void paintBackground(Graphics &g) override
Paints the background of the section. Calls paintContainer, heading, knobs, children.
Definition popup_browser.h:696
Interface for receiving closing area click events.
Definition popup_browser.h:651
virtual ~Listener()=default
virtual void closingAreaClicked(PopupClosingArea *closing_area, const MouseEvent &e)=0
Called when the closing area is clicked.
A transparent area that triggers a closing event when clicked.
Definition popup_browser.h:643
PopupClosingArea()
Definition popup_browser.h:645
void addListener(Listener *listener)
Adds a Listener to receive closing events.
Definition popup_browser.h:671
void mouseDown(const MouseEvent &e) override
Definition popup_browser.h:662
A small popup component that displays text in a styled bubble.
Definition popup_browser.h:21
void setContent(const std::string &text, Rectangle< int > bounds, BubbleComponent::BubblePlacement placement)
Sets the content of the popup display.
Definition popup_browser.cpp:82
void resized() override
Called when the component is resized.
Definition popup_browser.cpp:65
PopupDisplay()
Constructs a PopupDisplay.
Definition popup_browser.cpp:52
Interface for receiving selection events from PopupList.
Definition popup_browser.h:58
virtual void newSelection(PopupList *list, int id, int index)=0
Called when a new selection is made.
virtual void doubleClickedSelected(PopupList *list, int id, int index)
Called when the user double-clicks the selected item.
Definition popup_browser.h:76
virtual ~Listener()=default
A scrollable, selectable popup list of items.
Definition popup_browser.h:52
void mouseUp(const MouseEvent &e) override
Definition popup_browser.cpp:232
void setSelections(PopupItems selections)
Sets the list of items to be displayed.
Definition popup_browser.cpp:175
static constexpr float kScrollSensitivity
Scroll sensitivity factor.
Definition popup_browser.h:80
int getScrollableRange()
Gets the total scrollable range in pixels.
Definition popup_browser.cpp:382
int getSelected() const
Gets the currently selected item index.
Definition popup_browser.h:165
void mouseExit(const MouseEvent &e) override
Definition popup_browser.cpp:219
PopupList()
Constructs a PopupList.
Definition popup_browser.cpp:143
void renderOpenGlComponents(OpenGlWrapper &open_gl, bool animate) override
Renders all OpenGL components in this section and sub-sections.
Definition popup_browser.cpp:313
int getBrowseHeight()
Gets the total height needed to display all items.
Definition popup_browser.h:132
int getRowFromPosition(float mouse_position)
Gets the row index corresponding to a given vertical position.
Definition popup_browser.cpp:186
void resized() override
Called when the component is resized. Arranges layout of child components.
Definition popup_browser.cpp:158
void scrollBarMoved(ScrollBar *scroll_bar, double range_start) override
Definition popup_browser.cpp:368
int getSelection(const MouseEvent &e)
Retrieves the selection index at a mouse event position.
Definition popup_browser.cpp:223
void mouseWheelMove(const MouseEvent &e, const MouseWheelDetails &wheel) override
Definition popup_browser.cpp:359
void mouseDoubleClick(const MouseEvent &e) override
Definition popup_browser.cpp:239
void paintBackground(Graphics &g) override
Paints the background of the section. Calls paintContainer, heading, knobs, children.
Definition popup_browser.h:86
int getTextPadding()
Returns text padding around list items.
Definition popup_browser.h:120
static constexpr float kScrollBarWidth
Width of the scrollbar.
Definition popup_browser.h:81
void select(int select)
Programmatically selects an item by its index.
Definition popup_browser.cpp:248
void destroyOpenGlComponents(OpenGlWrapper &open_gl) override
Destroys all OpenGL components in this section and sub-sections.
Definition popup_browser.cpp:346
void paintBackgroundShadow(Graphics &g) override
Stub for painting background shadows. Overridden by subclasses if needed.
Definition popup_browser.h:87
PopupItems getSelectionItems(int index) const
Retrieves the selection items for a specified index.
Definition popup_browser.h:101
void setScrollBarRange()
Definition popup_browser.cpp:372
void setSelected(int selection)
Sets the currently selected item by index.
Definition popup_browser.h:159
void showSelected(bool show)
Enables or disables showing a highlight for the selected row.
Definition popup_browser.h:193
void mouseDrag(const MouseEvent &e) override
Definition popup_browser.cpp:212
Font getFont()
Gets the font used for displaying items.
Definition popup_browser.h:138
int getBrowseWidth()
Calculates the width needed to display all items.
Definition popup_browser.cpp:193
void mouseMove(const MouseEvent &e) override
Definition popup_browser.cpp:205
static constexpr float kRowHeight
Base row height.
Definition popup_browser.h:79
void addListener(Listener *listener)
Adds a PopupList::Listener to receive selection events.
Definition popup_browser.h:185
int getRowHeight()
Returns the row height in current scaling.
Definition popup_browser.h:114
void resetScrollPosition()
Definition popup_browser.cpp:354
void initOpenGlComponents(OpenGlWrapper &open_gl) override
Initializes all OpenGL components in this section and sub-sections.
Definition popup_browser.cpp:261
Comparator for sorting files by name ascending.
Definition popup_browser.h:287
static int compareElements(const File &first, const File &second)
Definition popup_browser.h:289
Interface for receiving selection events from SelectionList.
Definition popup_browser.h:238
virtual ~Listener()=default
virtual void favoritesSelected()
Called when "Favorites" special selection is made.
Definition popup_browser.h:256
virtual void doubleClickedSelected(File selection)=0
Called when a file is double-clicked.
virtual void allSelected()
Called when "All" special selection is made.
Definition popup_browser.h:251
virtual void newSelection(File selection)=0
Called when a new File is selected.
A scrollable file/folder selection list that supports nested folders and favorites.
Definition popup_browser.h:232
int getFolderDepth(const File &file)
Gets the depth of a given folder relative to open folders.
Definition popup_browser.cpp:666
int getRowFromPosition(float mouse_position)
Definition popup_browser.cpp:456
void mouseExit(const MouseEvent &e) override
Definition popup_browser.cpp:470
std::string getPassthroughFolderName() const
Definition popup_browser.h:443
static constexpr float kRowHeight
Base row height.
Definition popup_browser.h:266
void scrollBarMoved(ScrollBar *scroll_bar, double range_start) override
Definition popup_browser.cpp:642
File selected() const
Returns the currently selected file.
Definition popup_browser.h:360
static File getAllFile()
Returns a File object representing "All" selection.
Definition popup_browser.h:275
void selectPrev()
Selects the previous item in the list.
Definition popup_browser.cpp:758
void setPassthroughFolderName(const std::string &name)
Definition popup_browser.h:442
void paintBackgroundShadow(Graphics &g) override
Stub for painting background shadows. Overridden by subclasses if needed.
Definition popup_browser.h:300
void resetScrollPosition()
Definition popup_browser.cpp:440
static constexpr float kScrollBarWidth
Scrollbar width.
Definition popup_browser.h:269
void setAdditionalRootsName(const std::string &name)
Sets the name associated with additional roots.
Definition popup_browser.cpp:683
void setScrollBarRange()
Definition popup_browser.cpp:647
void initOpenGlComponents(OpenGlWrapper &open_gl) override
Initializes all OpenGL components in this section and sub-sections.
Definition popup_browser.cpp:767
void addListener(Listener *listener)
Adds a SelectionList::Listener.
Definition popup_browser.h:438
bool hasValidPath()
Checks if at least one displayed path exists.
Definition popup_browser.h:449
void addAdditionalFolder()
Definition popup_browser.cpp:540
static constexpr float kScrollSensitivity
Scroll sensitivity.
Definition popup_browser.h:268
void addFavoritesOption()
Adds a "Favorites" option to the list.
Definition popup_browser.h:306
void selectIcon(const File &selection)
Handles selecting the icon area (favorite toggle).
Definition popup_browser.cpp:605
File getSelection(const MouseEvent &e)
Gets the File at the mouse event position.
Definition popup_browser.cpp:492
void addSubfolderSelections(const File &selection, std::vector< File > &selections)
Adds subfolder selections if a folder is open.
Definition popup_browser.cpp:673
void mouseMove(const MouseEvent &e) override
Definition popup_browser.cpp:460
void removeAdditionalFolder(const File &folder)
Definition popup_browser.cpp:571
void mouseWheelMove(const MouseEvent &e, const MouseWheelDetails &wheel) override
Definition popup_browser.cpp:446
SelectionList()
Constructs a SelectionList.
Definition popup_browser.cpp:388
void filter(const String &filter_string)
Filters the selection list by a given string.
Definition popup_browser.cpp:696
void leftClick(const MouseEvent &e)
Definition popup_browser.cpp:501
void setSelections(Array< File > presets)
Sets the files/folders displayed in this SelectionList.
Definition popup_browser.cpp:434
void mouseDoubleClick(const MouseEvent &e) override
Definition popup_browser.cpp:526
void destroyOpenGlComponents(OpenGlWrapper &open_gl) override
Destroys all OpenGL components in this section and sub-sections.
Definition popup_browser.cpp:947
void setSelected(const File &selection)
Sets the currently selected file.
Definition popup_browser.h:366
int getScrollableRange()
Gets the total scrollable range.
Definition popup_browser.cpp:743
static File getFavoritesFile()
Returns a File object representing "Favorites" selection.
Definition popup_browser.h:281
int getSelectedIndex()
Gets the index of the currently selected file.
Definition popup_browser.cpp:735
void resized() override
Called when the component is resized. Arranges layout of child components.
Definition popup_browser.cpp:411
void redoCache()
Refreshes the cached row images.
Definition popup_browser.cpp:657
void mouseDown(const MouseEvent &e) override
Definition popup_browser.cpp:519
int getIconPadding()
Gets the icon padding.
Definition popup_browser.h:330
void paintBackground(Graphics &g) override
Paints the background of the section. Calls paintContainer, heading, knobs, children.
Definition popup_browser.h:299
void renderOpenGlComponents(OpenGlWrapper &open_gl, bool animate) override
Renders all OpenGL components in this section and sub-sections.
Definition popup_browser.cpp:884
Array< File > getAdditionalFolders()
Definition popup_browser.h:314
void respondToMenuCallback(int result)
Definition popup_browser.cpp:474
void menuClick(const MouseEvent &e)
Definition popup_browser.cpp:481
Array< File > getSelections()
Definition popup_browser.h:313
void selectNext()
Selects the next item in the list.
Definition popup_browser.cpp:749
void select(const File &selection)
Selects a given file.
Definition popup_browser.cpp:584
static constexpr float kStarWidth
Width of the star icon area.
Definition popup_browser.h:267
static constexpr int kNumCachedRows
Number of rows cached for performance.
Definition popup_browser.h:265
int getRowHeight()
Returns the scaled row height.
Definition popup_browser.h:324
A popup for selecting a single item from a list.
Definition popup_browser.h:504
void newSelection(PopupList *list, int id, int index) override
Called when a new selection is made.
Definition popup_browser.h:525
void setCallback(std::function< void(int)> callback)
Sets the callback function called when an item is selected.
Definition popup_browser.h:545
void paintBackgroundShadow(Graphics &g) override
Stub for painting background shadows. Overridden by subclasses if needed.
Definition popup_browser.h:510
void setCancelCallback(std::function< void()> cancel)
Sets the callback function called when the selection is cancelled.
Definition popup_browser.h:551
void setPosition(Point< int > position, Rectangle< int > bounds)
Sets the popup position relative to a given bounding area.
Definition popup_browser.cpp:991
void visibilityChanged() override
Definition popup_browser.h:513
void paintBackground(Graphics &g) override
Paints the background of the section. Calls paintContainer, heading, knobs, children.
Definition popup_browser.h:509
void resized() override
Called when the component is resized. Arranges layout of child components.
Definition popup_browser.cpp:974
void focusLost(FocusChangeType cause) override
Definition popup_browser.h:535
SinglePopupSelector()
Constructs a SinglePopupSelector.
Definition popup_browser.cpp:957
void showSelections(const PopupItems &selections)
Displays a set of selections.
Definition popup_browser.h:557
Base class for all synthesizer sections, providing UI layout, painting, and interaction logic.
Definition synth_section.h:193
virtual void animate(bool animate)
Triggers animation state change in sub-sections if needed.
Definition synth_section.cpp:822
virtual File getCurrentFile()
Gets the currently loaded file. Overridden by subclasses.
Definition synth_section.h:376
virtual int getPixelMultiple() const
Definition synth_section.cpp:729
float size_ratio_
Definition synth_section.h:821
Declares the DeleteSection class, which provides a confirmation overlay for deleting a preset file.
A helper struct containing references to OpenGL context, shaders, and display scale.
Definition shaders.h:174
A hierarchical structure of popup menu items for a selector component.
Definition synth_section.h:29
std::vector< PopupItems > items
Nested items for submenus or hierarchical choices.
Definition synth_section.h:33
int size() const
Returns the number of nested items.
Definition synth_section.h:65