Vital
Loading...
Searching...
No Matches
preset_selector.h
Go to the documentation of this file.
1
3#pragma once
4
5#include "JuceHeader.h"
6#include "synth_section.h"
7
15 public:
17 static constexpr float kDefaultFontHeightRatio = 0.63f;
18
24 class Listener {
25 public:
27 virtual ~Listener() { }
28
30 virtual void prevClicked() = 0;
31
33 virtual void nextClicked() = 0;
34
37 virtual void textMouseUp(const MouseEvent& e) { }
38
41 virtual void textMouseDown(const MouseEvent& e) { }
42 };
43
46
49
52 void paintBackground(Graphics& g) override;
53
55 void resized() override;
56
59 void mouseDown(const MouseEvent& e) override;
60
63 void mouseUp(const MouseEvent& e) override;
64
67 void buttonClicked(Button* clicked_button) override;
68
71 void mouseEnter(const MouseEvent& e) override { hover_ = true; }
72
75 void mouseExit(const MouseEvent& e) override { hover_ = false; }
76
79 void setText(String text);
80
85 void setText(String left, String center, String right);
86
89 String getText() { return text_->getText(); }
90
93 void setFontRatio(float ratio) { font_height_ratio_ = ratio; }
94
97 void setRoundAmount(float round_amount) { round_amount_ = round_amount; }
98
101 void addListener(Listener* listener) { listeners_.push_back(listener); }
102
104 void clickPrev();
105
107 void clickNext();
108
111 void setTextComponent(bool text_component) { text_component_ = text_component; }
112
113 private:
116 void textMouseDown(const MouseEvent& e);
117
120 void textMouseUp(const MouseEvent& e);
121
122 std::vector<Listener*> listeners_;
123 float font_height_ratio_;
124 float round_amount_;
125 bool hover_;
126 bool text_component_;
127
128 std::unique_ptr<PlainTextComponent> text_;
129 std::unique_ptr<OpenGlShapeButton> prev_preset_;
130 std::unique_ptr<OpenGlShapeButton> next_preset_;
131
132 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PresetSelector)
133};
134
Interface for objects that want to be notified of PresetSelector events.
Definition preset_selector.h:24
virtual void textMouseUp(const MouseEvent &e)
Definition preset_selector.h:37
virtual void prevClicked()=0
Called when the "previous" button is clicked.
virtual void textMouseDown(const MouseEvent &e)
Definition preset_selector.h:41
virtual void nextClicked()=0
Called when the "next" button is clicked.
virtual ~Listener()
Virtual destructor for proper cleanup.
Definition preset_selector.h:27
A UI component for selecting presets within the synthesizer.
Definition preset_selector.h:14
void mouseExit(const MouseEvent &e) override
Definition preset_selector.h:75
void setFontRatio(float ratio)
Definition preset_selector.h:93
PresetSelector()
Constructor.
Definition preset_selector.cpp:8
void resized() override
Resizes and lays out the child components.
Definition preset_selector.cpp:62
void addListener(Listener *listener)
Definition preset_selector.h:101
static constexpr float kDefaultFontHeightRatio
Default ratio of the font height relative to the component's height.
Definition preset_selector.h:17
void buttonClicked(Button *clicked_button) override
Definition preset_selector.cpp:101
void clickNext()
Programmatically simulate a click on the "next" preset button.
Definition preset_selector.cpp:129
void mouseEnter(const MouseEvent &e) override
Definition preset_selector.h:71
void setRoundAmount(float round_amount)
Definition preset_selector.h:97
void clickPrev()
Programmatically simulate a click on the "previous" preset button.
Definition preset_selector.cpp:123
void mouseDown(const MouseEvent &e) override
Definition preset_selector.cpp:88
~PresetSelector()
Destructor.
Definition preset_selector.cpp:51
String getText()
Definition preset_selector.h:89
void setText(String text)
Definition preset_selector.cpp:110
void paintBackground(Graphics &g) override
Definition preset_selector.cpp:55
void setTextComponent(bool text_component)
Definition preset_selector.h:111
void mouseUp(const MouseEvent &e) override
Definition preset_selector.cpp:95
Base class for all synthesizer sections, providing UI layout, painting, and interaction logic.
Definition synth_section.h:193