Vital
Loading...
Searching...
No Matches
about_section.cpp
Go to the documentation of this file.
1
3
4#include "about_section.h"
5#include "skin.h"
6#include "fonts.h"
7#include "load_save.h"
8#include "paths.h"
10#include "synth_section.h"
11#include "text_look_and_feel.h"
12
13namespace {
15 void setColorRecursively(Component *component, int color_id, const Colour& color) {
16 component->setColour(color_id, color);
17 for (Component *child : component->getChildren())
18 setColorRecursively(child, color_id, color);
19 }
20}
21
22AboutSection::AboutSection(const String& name) : Overlay(name), body_(Shaders::kRoundedRectangleFragment) {
23 addOpenGlComponent(&body_);
24 logo_ = std::make_unique<AppLogo>("logo");
25 addOpenGlComponent(logo_.get());
26
27 name_text_ = std::make_unique<PlainTextComponent>("plugin name", "VIAL");
28 addOpenGlComponent(name_text_.get());
29 name_text_->setFontType(PlainTextComponent::kRegular);
30 name_text_->setTextSize(40.0f);
31
32 version_text_ = std::make_unique<PlainTextComponent>("version", String("version ") + ProjectInfo::versionString);
33 addOpenGlComponent(version_text_.get());
34 version_text_->setFontType(PlainTextComponent::kLight);
35 version_text_->setTextSize(12.0f);
36
37 check_for_updates_text_ = std::make_unique<PlainTextComponent>("Check for updates", String("Check for updates"));
38 addOpenGlComponent(check_for_updates_text_.get());
39 check_for_updates_text_->setFontType(PlainTextComponent::kLight);
40 check_for_updates_text_->setTextSize(14.0f);
41 check_for_updates_text_->setJustification(Justification::centredLeft);
42
43 check_for_updates_ = std::make_unique<OpenGlToggleButton>("");
44 check_for_updates_->setToggleState(LoadSave::shouldCheckForUpdates(), NotificationType::dontSendNotification);
45 check_for_updates_->addListener(this);
46 addAndMakeVisible(check_for_updates_.get());
47 addOpenGlComponent(check_for_updates_->getGlComponent());
48
49 size_button_extra_small_ = std::make_unique<OpenGlToggleButton>(String(100 * kMultExtraSmall) + "%");
50 size_button_extra_small_->setUiButton(false);
51 addAndMakeVisible(size_button_extra_small_.get());
52 addOpenGlComponent(size_button_extra_small_->getGlComponent());
53 size_button_extra_small_->addListener(this);
54
55 size_button_small_ = std::make_unique<OpenGlToggleButton>(String(100 * kMultSmall) + "%");
56 size_button_small_->setUiButton(false);
57 addAndMakeVisible(size_button_small_.get());
58 addOpenGlComponent(size_button_small_->getGlComponent());
59 size_button_small_->addListener(this);
60
61 size_button_normal_ = std::make_unique<OpenGlToggleButton>(String("100") + "%");
62 size_button_normal_->setUiButton(false);
63 addAndMakeVisible(size_button_normal_.get());
64 addOpenGlComponent(size_button_normal_->getGlComponent());
65 size_button_normal_->addListener(this);
66
67 size_button_large_ = std::make_unique<OpenGlToggleButton>(String(100 * kMultLarge) + "%");
68 size_button_large_->setUiButton(false);
69 addAndMakeVisible(size_button_large_.get());
70 addOpenGlComponent(size_button_large_->getGlComponent());
71 size_button_large_->addListener(this);
72
73 size_button_double_ = std::make_unique<OpenGlToggleButton>(String(100 * kMultDouble) + "%");
74 size_button_double_->setUiButton(false);
75 addAndMakeVisible(size_button_double_.get());
76 addOpenGlComponent(size_button_double_->getGlComponent());
77 size_button_double_->addListener(this);
78
79 size_button_triple_ = std::make_unique<OpenGlToggleButton>(String(100 * kMultTriple) + "%");
80 size_button_triple_->setUiButton(false);
81 addAndMakeVisible(size_button_triple_.get());
82 addOpenGlComponent(size_button_triple_->getGlComponent());
83 size_button_triple_->addListener(this);
84
85 size_button_quadruple_ = std::make_unique<OpenGlToggleButton>(String(100 * kMultQuadruple) + "%");
86 size_button_quadruple_->setUiButton(false);
87 addAndMakeVisible(size_button_quadruple_.get());
88 addOpenGlComponent(size_button_quadruple_->getGlComponent());
89 size_button_quadruple_->addListener(this);
90}
91
93
95 Rectangle<int> info_rect = getInfoRect();
96 int left_buffer = kLeftLogoBuffer * size_ratio_;
97 logo_->setBounds(info_rect.getX() + left_buffer, info_rect.getY() + (kPaddingY + 12) * size_ratio_,
99}
100
102 SynthGuiInterface* parent = findParentComponentOfClass<SynthGuiInterface>();
103 if (parent && device_selector_ == nullptr) {
104 AudioDeviceManager* device_manager = parent->getAudioDeviceManager();
105 if (device_manager) {
106 device_selector_ = std::make_unique<OpenGlDeviceSelector>(
107 *device_manager, 0, 0, vital::kNumChannels, vital::kNumChannels, true, false, false, false);
108 addAndMakeVisible(device_selector_.get());
109 addOpenGlComponent(device_selector_->getImageComponent());
110 }
111 }
112
113 Rectangle<int> info_rect = getInfoRect();
114 body_.setBounds(info_rect);
116 body_.setColor(findColour(Skin::kBody, true));
117 Colour body_text = findColour(Skin::kBodyText, true);
118 name_text_->setColor(body_text);
119 check_for_updates_text_->setColor(body_text);
120 version_text_->setColor(body_text);
121 int padding_x = size_ratio_ * kPaddingX;
122 int padding_y = size_ratio_ * kPaddingY;
123 int button_height = size_ratio_ * kButtonHeight;
124
125 if (isVisible())
127
128 int name_x = (kLogoWidth + kLeftLogoBuffer) * size_ratio_;
129 name_text_->setBounds(info_rect.getX() + name_x, info_rect.getY() + padding_y + 40 * size_ratio_,
130 info_rect.getWidth() - name_x - kNameRightBuffer * size_ratio_, 40 * size_ratio_);
131
132 version_text_->setBounds(info_rect.getX() + name_x, info_rect.getY() + padding_y + 76 * size_ratio_,
133 info_rect.getWidth() - name_x - kNameRightBuffer * size_ratio_, 32 * size_ratio_);
134
135 int size_padding = 5 * size_ratio_;
136 int size_start_x = info_rect.getX() + padding_x;
137 int size_end_x = info_rect.getRight() - padding_x + size_padding;
138 std::vector<OpenGlToggleButton*> size_buttons = {
139 size_button_extra_small_.get(),
140 size_button_small_.get(),
141 size_button_normal_.get(),
142 size_button_large_.get(),
143 size_button_double_.get(),
144 size_button_triple_.get(),
145 size_button_quadruple_.get(),
146 };
147
148 float size_width = (size_end_x - size_start_x) * 1.0f / size_buttons.size() - size_padding;
149
150 int check_updates_height = button_height * 0.6f;
151 check_for_updates_->setBounds(info_rect.getX() + padding_x,
152 info_rect.getY() + padding_y + 145.0f * size_ratio_,
153 check_updates_height, check_updates_height);
154 int check_for_updates_width = 3 * size_width + 2 * size_padding;
155 check_for_updates_text_->setBounds(check_for_updates_->getRight() + size_padding, check_for_updates_->getY(),
156 check_for_updates_width, check_updates_height);
157
158 int size_y = check_for_updates_->getBottom() + padding_y;
159
160 int index = 0;
161 for (OpenGlToggleButton* size_button : size_buttons) {
162 int start_x = std::round(size_start_x + index * (size_width + size_padding));
163 size_button->setBounds(start_x, size_y, size_width, button_height);
164 index++;
165 }
166
167 if (device_selector_) {
168 int y = size_button_quadruple_->getBottom() + padding_y;
169 device_selector_->setBounds(info_rect.getX(), y,
170 info_rect.getWidth(), info_rect.getBottom() - y);
171 }
172
173 if (device_selector_) {
174 Colour background = findColour(Skin::kPopupBackground, true);
175 setColorRecursively(device_selector_.get(), ListBox::backgroundColourId, background);
176 setColorRecursively(device_selector_.get(), ComboBox::backgroundColourId, background);
177 setColorRecursively(device_selector_.get(), PopupMenu::backgroundColourId, background);
178 setColorRecursively(device_selector_.get(), BubbleComponent::backgroundColourId, background);
179
180 Colour text = findColour(Skin::kBodyText, true);
181 setColorRecursively(device_selector_.get(), ListBox::textColourId, text);
182 setColorRecursively(device_selector_.get(), ComboBox::textColourId, text);
183
184 setColorRecursively(device_selector_.get(), TextEditor::highlightColourId, Colours::transparentBlack);
185 setColorRecursively(device_selector_.get(), ListBox::outlineColourId, Colours::transparentBlack);
186 setColorRecursively(device_selector_.get(), ComboBox::outlineColourId, Colours::transparentBlack);
187 }
188
189 name_text_->setTextSize(40.0f * size_ratio_);
190 version_text_->setTextSize(12.0f * size_ratio_);
191 check_for_updates_text_->setTextSize(14.0f * size_ratio_);
192
194}
195
196void AboutSection::mouseUp(const MouseEvent &e) {
197 if (!getInfoRect().contains(e.getPosition()))
198 setVisible(false);
199}
200
201void AboutSection::setVisible(bool should_be_visible) {
202 if (should_be_visible) {
204 Image image(Image::ARGB, 1, 1, false);
205 Graphics g(image);
207 }
208
209 Overlay::setVisible(should_be_visible);
210}
211
212void AboutSection::buttonClicked(Button* clicked_button) {
213 if (clicked_button == check_for_updates_.get())
214 LoadSave::saveUpdateCheckConfig(check_for_updates_->getToggleState());
215 else if (clicked_button == size_button_extra_small_.get())
216 setGuiSize(kMultExtraSmall);
217 else if (clicked_button == size_button_small_.get())
218 setGuiSize(kMultSmall);
219 else if (clicked_button == size_button_normal_.get())
220 setGuiSize(1.0);
221 else if (clicked_button == size_button_large_.get())
222 setGuiSize(kMultLarge);
223 else if (clicked_button == size_button_double_.get())
224 setGuiSize(kMultDouble);
225 else if (clicked_button == size_button_triple_.get())
226 setGuiSize(kMultTriple);
227 else if (clicked_button == size_button_quadruple_.get())
228 setGuiSize(kMultQuadruple);
229}
230
232 int info_height = kBasicInfoHeight * size_ratio_;
233 int info_width = kInfoWidth * size_ratio_;
234 if (device_selector_)
235 info_height += device_selector_->getBounds().getHeight();
236
237 int x = (getWidth() - info_width) / 2;
238 int y = (getHeight() - info_width) / 2;
239 return Rectangle<int>(x, y, info_width, info_height);
240}
241
242void AboutSection::setGuiSize(float multiplier) {
243 if (Desktop::getInstance().getKioskModeComponent()) {
244 Desktop::getInstance().setKioskModeComponent(nullptr);
245 return;
246 }
247
248 float percent = sqrtf(multiplier);
249 SynthGuiInterface* parent = findParentComponentOfClass<SynthGuiInterface>();
250 if (parent)
251 parent->setGuiSize(percent);
252}
253
254void AboutSection::fullScreen() {
255 if (Desktop::getInstance().getKioskModeComponent())
256 Desktop::getInstance().setKioskModeComponent(nullptr);
257 else
258 Desktop::getInstance().setKioskModeComponent(getTopLevelComponent());
259}
Declares the AboutSection class, which displays information about the application and allows configur...
static constexpr float kMultTriple
Definition about_section.h:81
virtual ~AboutSection()
Destructor.
static constexpr float kMultExtraSmall
Scaling multipliers for adjusting GUI size.
Definition about_section.h:77
AboutSection(const String &name)
Definition about_section.cpp:22
static constexpr int kInfoWidth
The fixed dimensions and layout constants for this section.
Definition about_section.h:67
static constexpr int kNameRightBuffer
Definition about_section.h:73
void buttonClicked(Button *clicked_button) override
Definition about_section.cpp:212
void setVisible(bool should_be_visible) override
Definition about_section.cpp:201
void setLogoBounds()
Sets the bounds of the logo within the info rectangle.
Definition about_section.cpp:94
static constexpr int kPaddingX
Definition about_section.h:69
void mouseUp(const MouseEvent &e) override
Definition about_section.cpp:196
void resized() override
Handles resizing of the section, laying out child components and controls.
Definition about_section.cpp:101
static constexpr int kBasicInfoHeight
Definition about_section.h:68
static constexpr int kPaddingY
Definition about_section.h:70
Rectangle< int > getInfoRect()
Definition about_section.cpp:231
static constexpr float kMultDouble
Definition about_section.h:80
static constexpr float kMultSmall
Definition about_section.h:78
static constexpr int kLogoWidth
Definition about_section.h:74
static constexpr int kButtonHeight
Definition about_section.h:71
static constexpr int kLeftLogoBuffer
Definition about_section.h:72
static constexpr float kMultLarge
Definition about_section.h:79
static constexpr float kMultQuadruple
Definition about_section.h:82
static void saveUpdateCheckConfig(bool check_for_updates)
Saves the user's preference regarding update checks.
Definition load_save.cpp:1288
static bool shouldCheckForUpdates()
Checks if Vital should perform update checks.
Definition load_save.cpp:1554
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 ToggleButton that uses an OpenGlButtonComponent for its rendering.
Definition synth_button.h:342
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
@ kRegular
Definition open_gl_image_component.h:310
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
@ kPopupBackground
Definition skin.h:144
@ kBody
Definition skin.h:129
An interface class linking the Vital synthesizer backend (SynthBase) with a GUI.
Definition synth_gui_interface.h:56
void setGuiSize(float scale)
Sets the GUI window or component size based on a scale factor.
Definition synth_gui_interface.cpp:193
virtual AudioDeviceManager * getAudioDeviceManager()
Retrieves the audio device manager if available.
Definition synth_gui_interface.h:78
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
constexpr int kNumChannels
Number of output channels (stereo = 2).
Definition synth_constants.h:37