13 String
filterNewText(TextEditor& editor,
const String& new_input)
override {
14 return new_input.removeCharacters(
"<>?*/|\\[]\":");
19 body_(
Shaders::kRoundedRectangleFragment) {
22#if !defined(NO_TEXT_ENTRY)
23 name_ = std::make_unique<OpenGlTextEditor>(
"Name");
24 name_->addListener(
this);
26 addAndMakeVisible(name_.get());
29 author_ = std::make_unique<OpenGlTextEditor>(
"Author");
30 author_->addListener(
this);
32 addAndMakeVisible(author_.get());
35 comments_ = std::make_unique<OpenGlTextEditor>(
"Comments");
36 comments_->addListener(
this);
37 comments_->setReturnKeyStartsNewLine(
true);
39 addAndMakeVisible(comments_.get());
41 comments_->setMultiLine(
true);
44 save_button_ = std::make_unique<OpenGlToggleButton>(TRANS(
"Save"));
45 save_button_->setButtonText(
"Save");
46 save_button_->setUiButton(
true);
47 save_button_->addListener(
this);
48 addAndMakeVisible(save_button_.get());
51 overwrite_button_ = std::make_unique<OpenGlToggleButton>(TRANS(
"Overwrite"));
52 overwrite_button_->setButtonText(
"Overwrite");
53 overwrite_button_->setUiButton(
true);
54 overwrite_button_->addListener(
this);
55 addAndMakeVisible(overwrite_button_.get());
58 cancel_button_ = std::make_unique<OpenGlToggleButton>(TRANS(
"Cancel"));
59 cancel_button_->setButtonText(
"Cancel");
60 cancel_button_->setUiButton(
false);
61 cancel_button_->addListener(
this);
62 addAndMakeVisible(cancel_button_.get());
65 preset_text_ = std::make_unique<PlainTextComponent>(
"Preset",
"NAME");
69 preset_text_->setJustification(Justification::centredRight);
71 author_text_ = std::make_unique<PlainTextComponent>(
"Author",
"AUTHOR");
75 author_text_->setJustification(Justification::centredRight);
77 style_text_ = std::make_unique<PlainTextComponent>(
"Style",
"STYLE");
81 style_text_->setJustification(Justification::centredRight);
83 comments_text_ = std::make_unique<PlainTextComponent>(
"Comments",
"COMMENTS");
87 comments_text_->setJustification(Justification::centredRight);
89 overwrite_text_ = std::make_unique<PlainTextComponent>(
"overwrite",
"Overwrite existing file?");
93 overwrite_text_->setJustification(Justification::centred);
97 style_buttons_[i]->addListener(
this);
98 addAndMakeVisible(style_buttons_[i].get());
108 preset_text_->setColor(text_color);
109 author_text_->setColor(text_color);
110 style_text_->setColor(text_color);
111 comments_text_->setColor(text_color);
112 overwrite_text_->setColor(text_color);
123 author_->redoImage();
124 comments_->redoImage();
128 preset_text_->setTextSize(label_height);
129 author_text_->setTextSize(label_height);
130 comments_text_->setTextSize(label_height);
131 style_text_->setTextSize(label_height);
132 overwrite_text_->setTextSize(label_height);
137 body_.setBounds(save_rect);
147 save_button_->setVisible(
true);
148 overwrite_button_->setVisible(
false);
149 float button_width = (save_rect.getWidth() - 3 * padding_x) / 2.0f;
150 save_button_->setBounds(save_rect.getX() + button_width + 2 * padding_x,
151 save_rect.getBottom() - padding_y - button_height,
152 button_width, button_height);
153 cancel_button_->setBounds(save_rect.getX() + padding_x,
154 save_rect.getBottom() - padding_y - button_height,
155 button_width, button_height);
157 int text_x = save_rect.getX() + padding_x;
158 int text_y = save_rect.getY() + extra_top_padding;
160 preset_text_->setVisible(
true);
161 author_text_->setVisible(
true);
162 style_text_->setVisible(saving_preset_);
163 comments_text_->setVisible(saving_preset_);
164 overwrite_text_->setVisible(
false);
166 if (name_ ==
nullptr || author_ ==
nullptr || comments_ ==
nullptr)
169 name_->setVisible(
true);
170 author_->setVisible(
true);
171 comments_->setVisible(saving_preset_);
173 style_buttons_[i]->
setVisible(saving_preset_);
176 int editor_x = save_rect.getX() + padding_x + division;
177 int editor_width = save_rect.getWidth() - 2 * padding_x - division;
178 name_->setBounds(editor_x, save_rect.getY() + padding_y + extra_top_padding,
179 editor_width, editor_height);
180 author_->setBounds(editor_x, save_rect.getY() + 2 * padding_y + editor_height + extra_top_padding,
181 editor_width, editor_height);
183 int style_width = editor_width + style_padding_x;
184 int style_y = save_rect.getY() + 3 * padding_y + 2 * editor_height + extra_top_padding;
187 int column = i % num_in_row;
188 int x = editor_x + (style_width * column) / num_in_row;
189 int next_x = editor_x + (style_width * (column + 1)) / num_in_row;
190 int width = next_x - x - style_padding_x;
191 int y = style_y + (i / num_in_row) * (style_button_height + style_padding_y);
192 style_buttons_[i]->setBounds(x, y, width, style_button_height);
195 int comments_y = style_y + 3 * style_button_height + 2 * style_padding_y + padding_y;
196 int comments_height = save_button_->getY() - comments_y - padding_y;
197 comments_->setBounds(editor_x, comments_y, editor_width, comments_height);
200 preset_text_->setBounds(text_x, text_y + padding_y, text_width, name_->getHeight());
201 author_text_->setBounds(text_x, text_y + 2 * padding_y + name_->getHeight(),
202 text_width, name_->getHeight());
204 int style_height = 3 * style_button_height + 2 * style_padding_y;
205 style_text_->setBounds(text_x, text_y + 3 * padding_y + 2 * name_->getHeight(),
206 text_width, style_height);
207 comments_text_->setBounds(text_x, text_y + 4 * padding_y + style_height + 2 * name_->getHeight(),
208 text_width, author_->getHeight());
211 setTextColors(name_.get(), file_type_ +
" " + TRANS(
"Name"));
214 name_->applyFontToAllText(editor_font,
true);
215 author_->applyFontToAllText(editor_font,
true);
216 comments_->applyFontToAllText(editor_font,
true);
220 preset_text_->setVisible(
false);
221 author_text_->setVisible(
false);
222 style_text_->setVisible(
false);
223 comments_text_->setVisible(
false);
224 overwrite_text_->setVisible(
true);
225 name_->setVisible(
false);
226 author_->setVisible(
false);
227 comments_->setVisible(
false);
233 body_.setBounds(overwrite_rect);
235 save_button_->setVisible(
false);
236 overwrite_button_->setVisible(
true);
238 overwrite_text_->setText(String(
"Overwrite existing file?"));
242 overwrite_text_->setBounds(overwrite_rect.getX() + padding_x,
244 overwrite_rect.getWidth() - 2 * padding_x, 24 *
size_ratio_);
245 overwrite_text_->redrawImage(
true);
247 float button_width = (overwrite_rect.getWidth() - 3 * padding_x) / 2.0f;
248 cancel_button_->setBounds(overwrite_rect.getX() + padding_x,
249 overwrite_rect.getBottom() - padding_y - button_height,
250 button_width, button_height);
251 overwrite_button_->setBounds(overwrite_rect.getX() + button_width + 2 * padding_x,
252 overwrite_rect.getBottom() - padding_y - button_height,
253 button_width, button_height);
258 editor->setColour(TextEditor::textColourId, findColour(
Skin::kPresetText,
true));
259 editor->setColour(TextEditor::highlightedTextColourId, findColour(
Skin::kBodyText,
true));
262 empty_color = empty_color.withAlpha(0.5f * empty_color.getFloatAlpha());
263 editor->setTextToShowWhenEmpty(empty_string, empty_color);
270 if (should_be_visible) {
273 if (parent && name_) {
282 Image image(Image::ARGB, 1, 1,
false);
288 if (name_ && name_->isShowing())
289 name_->grabKeyboardFocus();
302 if (clicked_button == save_button_.get() || clicked_button == overwrite_button_.get())
304 else if (clicked_button == cancel_button_.get())
308 if (style_buttons_[i].get() != clicked_button)
309 style_buttons_[i]->setToggleState(
false, dontSendNotification);
320 int x = (getWidth() - save_width) / 2;
321 int y = (getHeight() - save_height) / 2;
322 return Rectangle<int>(x, y, save_width, save_height);
331void SaveSection::save() {
332 if (name_ ==
nullptr || name_->getText().trim() ==
"")
335 String file_name = name_->getText().trim() + String(
".") + file_extension_;
336 File save_file = file_directory_.getChildFile(File::createLegalFileName(file_name));
337 if (!overwrite_ && save_file.exists()) {
344 if (saving_preset_) {
352 if (style_buttons_[i]->getToggleState())
353 style = style_buttons_[i]->getName();
358 for (Listener* listener : listeners_)
359 listener->save(save_file);
363 file_data_[
"name"] = name_->getText().trim().toStdString();
364 file_data_[
"author"] = author_->getText().trim().toStdString();
365 save_file.replaceWithText(file_data_.dump());
366 for (Listener* listener : listeners_)
367 listener->save(save_file);
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
static void saveAuthor(std::string author)
Saves the provided author name to the config.
Definition load_save.cpp:1261
@ kNumPresetStyles
Definition load_save.h:66
static std::string getAuthor()
Retrieves the saved author name from the config.
Definition load_save.cpp:1671
static const int kMaxCommentLength
Maximum length of preset comments.
Definition load_save.h:70
virtual void redoImage()
Redraws the image after a state change.
Definition open_gl_image_component.h:196
force_inline void setColor(Colour color)
Sets the base color for the quads.
Definition open_gl_multi_quad.h:102
void setRounding(float rounding)
Sets the rounding radius of the quads.
Definition open_gl_multi_quad.h:347
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
virtual void resized() override
Called when the overlay is resized. Updates background color and size.
Definition overlay.h:237
void setVisible(bool should_be_visible) override
Sets the visibility of the overlay and notifies listeners.
Definition overlay.h:224
float size_ratio_
A scaling factor for the overlay size.
Definition overlay.h:267
@ kLight
Definition open_gl_image_component.h:309
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
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 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
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
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
static constexpr int kTextEditorHeight
Height of each text editor component.
Definition save_section.h:30
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
Manages and provides access to vertex and fragment shaders used by the OpenGL rendering pipeline.
Definition shaders.h:19
@ kBodyRounding
Definition skin.h:71
@ kBodyText
Definition skin.h:133
@ kPresetText
Definition skin.h:132
@ kTextEditorSelection
Definition skin.h:203
@ kTextEditorCaret
Definition skin.h:202
@ kBody
Definition skin.h:129
void setAuthor(const String &author)
Sets the author metadata of the current preset.
Definition synth_base.cpp:681
void setComments(const String &comments)
Sets the comments or description metadata of the current preset.
Definition synth_base.cpp:685
bool saveToFile(File preset)
Saves the current preset state to the specified file.
Definition synth_base.cpp:531
void setStyle(const String &style)
Sets the style metadata of the current preset (e.g., bass, lead, etc.).
Definition synth_base.cpp:689
String getComments()
Gets the comments for the current preset.
Definition synth_base.cpp:705
String getPresetName()
Gets the current preset’s name.
Definition synth_base.cpp:713
String getStyle()
Gets the style of the current preset.
Definition synth_base.cpp:709
An interface class linking the Vital synthesizer backend (SynthBase) with a GUI.
Definition synth_gui_interface.h:56
SynthBase * getSynth()
Returns the SynthBase instance this interface is managing.
Definition synth_gui_interface.h:85
void paintOpenGlChildrenBackgrounds(Graphics &g)
Paints the backgrounds for all OpenGL child components.
Definition synth_section.cpp:267
float findValue(Skin::ValueId value_id) const
Finds a value in the skin overrides or from the parent if not found locally.
Definition synth_section.cpp:18
void addOpenGlComponent(OpenGlComponent *open_gl_component, bool to_beginning=false)
Definition synth_section.cpp:489
const std::string kPresetStyleNames[]
Names for preset categories or styles.
Definition synth_strings.h:81