11using json = nlohmann::json;
51 virtual void save(File preset) = 0;
70 void setVisible(
bool should_be_visible)
override;
105 void mouseUp(
const MouseEvent& e)
override;
111 void setFileType(
const String& type) { file_type_ = type; repaint(); }
123 void setDirectory(
const File& directory) { file_directory_ = directory; }
136 saving_preset_ = preset;
173 String file_extension_;
174 File file_directory_;
179 std::unique_ptr<OpenGlTextEditor> name_;
180 std::unique_ptr<OpenGlTextEditor> author_;
181 std::unique_ptr<OpenGlTextEditor> comments_;
183 std::unique_ptr<OpenGlToggleButton> save_button_;
184 std::unique_ptr<OpenGlToggleButton> overwrite_button_;
185 std::unique_ptr<OpenGlToggleButton> cancel_button_;
189 std::unique_ptr<PlainTextComponent> preset_text_;
190 std::unique_ptr<PlainTextComponent> author_text_;
191 std::unique_ptr<PlainTextComponent> style_text_;
192 std::unique_ptr<PlainTextComponent> comments_text_;
193 std::unique_ptr<PlainTextComponent> overwrite_text_;
195 std::vector<Listener*> listeners_;
197 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(
SaveSection)
@ kNumPresetStyles
Definition load_save.h:66
static File getUserPresetDirectory()
Retrieves the user's preset directory.
Definition load_save.cpp:1791
A convenience class for a single quad rendered via OpenGL.
Definition open_gl_multi_quad.h:447
A text editor that uses an OpenGlImageComponent for rendering and updates the image on text changes.
Definition open_gl_image_component.h:209
A SynthSection that displays an overlay with a background and optional listeners.
Definition overlay.h:180
Interface for objects interested in the result of the save action.
Definition save_section.h:43
virtual ~Listener()=default
virtual void save(File preset)=0
Called after a file has been saved successfully.
A UI overlay for saving presets or other files.
Definition save_section.h:21
void setIsPreset(bool preset)
Configures the section for saving a preset (true) or another file type.
Definition save_section.h:135
Rectangle< int > getOverwriteRect()
Gets the rectangle bounds of the overwrite confirmation dialog.
Definition save_section.cpp:325
void mouseUp(const MouseEvent &e) override
Called when the mouse is released. Used to close the overlay if clicked outside.
Definition save_section.cpp:292
static constexpr int kPaddingX
Horizontal padding inside the dialog.
Definition save_section.h:35
void setFileData(const json &data)
Sets the data to be saved (if not saving a preset).
Definition save_section.h:129
static constexpr int kButtonHeight
Height of buttons.
Definition save_section.h:32
static constexpr int kOverwriteWidth
Width of overwrite confirmation dialog.
Definition save_section.h:28
static constexpr int kSaveWidth
Base width of the save dialog.
Definition save_section.h:23
void setFileExtension(const String &extension)
Sets the file extension to use when saving.
Definition save_section.h:117
void setTextColors(OpenGlTextEditor *editor, String empty_string)
Configures text editor colors and placeholder text.
Definition save_section.cpp:256
void resized() override
Called when the component is resized. Updates layout and positions of all elements.
Definition save_section.cpp:103
static constexpr int kExtraTopPadding
Extra top padding inside the dialog.
Definition save_section.h:37
void setSaveBounds()
Sets the layout and components for the normal save mode (not overwrite).
Definition save_section.cpp:135
static constexpr int kSavePresetHeight
Base height of the preset save dialog.
Definition save_section.h:24
static constexpr int kAddFolderHeight
Height for additional spacing.
Definition save_section.h:33
virtual ~SaveSection()=default
SaveSection(String name)
Constructs a SaveSection with a given name.
Definition save_section.cpp:18
void buttonClicked(Button *clicked_button) override
Called when a button is clicked.
Definition save_section.cpp:301
void setFileType(const String &type)
Sets the file type label shown in the dialog.
Definition save_section.h:111
static constexpr int kStylePaddingY
Vertical padding for style buttons.
Definition save_section.h:26
void setVisible(bool should_be_visible) override
Sets the visibility of this overlay. Adjusts layout when becoming visible.
Definition save_section.cpp:267
void textEditorReturnKeyPressed(TextEditor &editor) override
Called when the return key is pressed in any text editor.
Definition save_section.cpp:297
static constexpr int kOverwriteHeight
Height of overwrite confirmation dialog.
Definition save_section.h:29
static constexpr int kPaddingY
Vertical padding inside the dialog.
Definition save_section.h:36
void addSaveListener(Listener *listener)
Adds a listener to be notified when saving occurs.
Definition save_section.h:161
static constexpr int kTextEditorHeight
Height of each text editor component.
Definition save_section.h:30
void setDirectory(const File &directory)
Sets the directory where the file will be saved.
Definition save_section.h:123
void setOverwriteBounds()
Sets the layout and components for the overwrite confirmation mode.
Definition save_section.cpp:219
static constexpr int kStyleButtonHeight
Height of each style button.
Definition save_section.h:27
Rectangle< int > getSaveRect()
Gets the rectangle bounds of the main save dialog.
Definition save_section.cpp:314
static constexpr int kStylePaddingX
Horizontal padding for style buttons.
Definition save_section.h:25
static constexpr int kLabelHeight
Height of labels.
Definition save_section.h:31
static constexpr int kDivision
Horizontal division for layout.
Definition save_section.h:34
nlohmann::json json
Definition line_generator.h:7
const std::string kPresetExtension
File extension for Vital preset files.
Definition synth_constants.h:85