Vital
Loading...
Searching...
No Matches
delete_section.h
Go to the documentation of this file.
1
3
4#pragma once
5
6#include "JuceHeader.h"
7#include "overlay.h"
8
15class DeleteSection : public Overlay {
16public:
18 static constexpr int kDeleteWidth = 340;
20 static constexpr int kDeleteHeight = 140;
22 static constexpr int kTextHeight = 15;
24 static constexpr int kPaddingX = 25;
26 static constexpr int kPaddingY = 20;
28 static constexpr int kButtonHeight = 30;
29
32 class Listener {
33 public:
35 virtual ~Listener() = default;
36
39 virtual void fileDeleted(File save_file) = 0;
40 };
41
44 DeleteSection(const String& name);
45
47 virtual ~DeleteSection() = default;
48
50 void resized() override;
51
54 void setVisible(bool should_be_visible) override;
55
58 void mouseUp(const MouseEvent& e) override;
59
62 void buttonClicked(Button* clicked_button) override;
63
66 void setFileToDelete(File file) {
67 file_ = std::move(file);
68 preset_text_->setText(file_.getFileNameWithoutExtension());
69 }
70
73 Rectangle<int> getDeleteRect();
74
77 void addDeleteListener(Listener* listener) { listeners_.add(listener); }
78
81 void removeDeleteListener(Listener* listener) { listeners_.removeAllInstancesOf(listener); }
82
83private:
84 File file_;
85
86 OpenGlQuad body_;
87
88 std::unique_ptr<PlainTextComponent> delete_text_;
89 std::unique_ptr<PlainTextComponent> preset_text_;
90
91 std::unique_ptr<OpenGlToggleButton> delete_button_;
92 std::unique_ptr<OpenGlToggleButton> cancel_button_;
93
94 Array<Listener*> listeners_;
95
96 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(DeleteSection)
97};
Interface for objects that need to respond when a file is deleted.
Definition delete_section.h:32
virtual ~Listener()=default
Virtual destructor for proper cleanup.
virtual void fileDeleted(File save_file)=0
An overlay that asks the user to confirm deletion of a preset file.
Definition delete_section.h:15
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
virtual ~DeleteSection()=default
Destructor.
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
void addDeleteListener(Listener *listener)
Definition delete_section.h:77
void setFileToDelete(File file)
Definition delete_section.h:66
void removeDeleteListener(Listener *listener)
Definition delete_section.h:81
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
A convenience class for a single quad rendered via OpenGL.
Definition open_gl_multi_quad.h:447
A SynthSection that displays an overlay with a background and optional listeners.
Definition overlay.h:180