13 delete_button_ = std::make_unique<OpenGlToggleButton>(TRANS(
"Delete"));
14 delete_button_->setText(
"Delete");
15 delete_button_->setUiButton(
true);
16 delete_button_->addListener(
this);
17 addAndMakeVisible(delete_button_.get());
20 cancel_button_ = std::make_unique<OpenGlToggleButton>(TRANS(
"Cancel"));
21 cancel_button_->setText(
"Cancel");
22 cancel_button_->setUiButton(
false);
23 cancel_button_->addListener(
this);
24 addAndMakeVisible(cancel_button_.get());
27 delete_text_ = std::make_unique<PlainTextComponent>(
"Delete",
"Are you sure you want to delete this preset?");
31 delete_text_->setJustification(Justification::centred);
33 preset_text_ = std::make_unique<PlainTextComponent>(
"Preset",
"");
37 preset_text_->setJustification(Justification::centred);
46 delete_text_->setColor(body_text);
47 preset_text_->setColor(body_text);
50 body_.setBounds(delete_rect);
56 float button_width = (delete_rect.getWidth() - 3 * padding_x) / 2.0f;
57 cancel_button_->setBounds(delete_rect.getX() + padding_x,
58 delete_rect.getBottom() - padding_y - button_height,
59 button_width, button_height);
60 delete_button_->setBounds(delete_rect.getX() + button_width + 2 * padding_x,
61 delete_rect.getBottom() - padding_y - button_height,
62 button_width, button_height);
65 delete_text_->setTextSize(text_size);
66 preset_text_->setTextSize(text_size);
69 delete_text_->setBounds(delete_rect.getX() + padding_x, delete_rect.getY() + padding_y,
70 delete_rect.getWidth() - 2 * padding_x, text_height);
71 preset_text_->setBounds(delete_rect.getX() + padding_x, delete_rect.getY() + padding_y + 30 *
size_ratio_,
72 delete_rect.getWidth() - 2 * padding_x, text_height);
73 preset_text_->setText(file_.getFileNameWithoutExtension());
82 if (should_be_visible) {
83 Image image(Image::ARGB, 1, 1,
false);
99 if (clicked_button == delete_button_.get()) {
100 file_.deleteRecursively();
102 for (
Listener* listener : listeners_)
103 listener->fileDeleted(file_);
105 else if (clicked_button == cancel_button_.get())
114 int x = (getWidth() - width) / 2;
115 int y = (getHeight() - height) / 2;
116 return Rectangle<int>(x, y, width, height);
Interface for objects that need to respond when a file is deleted.
Definition delete_section.h:32
static constexpr int kDeleteWidth
Width of the delete confirmation box.
Definition delete_section.h:18
Rectangle< int > getDeleteRect()
Definition delete_section.cpp:111
static constexpr int kPaddingX
Horizontal padding inside the confirmation box.
Definition delete_section.h:24
void buttonClicked(Button *clicked_button) override
Definition delete_section.cpp:98
void mouseUp(const MouseEvent &e) override
Definition delete_section.cpp:91
static constexpr int kPaddingY
Vertical padding inside the confirmation box.
Definition delete_section.h:26
static constexpr int kTextHeight
The height of the text within the confirmation box.
Definition delete_section.h:22
void resized() override
Lays out the components inside the delete confirmation box.
Definition delete_section.cpp:41
DeleteSection(const String &name)
Constructs a DeleteSection overlay with a message, filename, and Delete/Cancel buttons.
Definition delete_section.cpp:10
static constexpr int kDeleteHeight
Height of the delete confirmation box.
Definition delete_section.h:20
void setVisible(bool should_be_visible) override
Sets the visibility of the DeleteSection. Repaints background if becoming visible.
Definition delete_section.cpp:79
static constexpr int kButtonHeight
Height of the buttons inside the confirmation box.
Definition delete_section.h:28
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 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
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
@ kBody
Definition skin.h:129
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
Declares the DeleteSection class, which provides a confirmation overlay for deleting a preset file.