Vital
Loading...
Searching...
No Matches
expired_section.cpp
Go to the documentation of this file.
1#include "expired_section.h"
2
3#include "skin.h"
4#include "fonts.h"
6
14class OpenGlHyperlink : public OpenGlAutoImageComponent<HyperlinkButton> {
15 public:
21 OpenGlHyperlink(String text, URL url) : OpenGlAutoImageComponent(text, url) {
23 }
24};
25
26ExpiredSection::ExpiredSection(String name) : Overlay(name), body_(Shaders::kRoundedRectangleFragment) {
27 addOpenGlComponent(&body_);
28
29 text_ = std::make_unique<PlainTextComponent>("text", "This Beta has expired");
30 text_->setTextSize(14.0f);
31 text_->setFontType(PlainTextComponent::kLight);
32 addOpenGlComponent(text_.get());
33
34 link_ = std::make_unique<OpenGlHyperlink>("Download a new version", URL(""));
35 link_->setFont(Fonts::instance()->proportional_light().withPointHeight(14.0f),
36 false, Justification::centred);
37 addAndMakeVisible(link_.get());
38 addOpenGlComponent(link_->getImageComponent());
39}
40
43 body_.setColor(findColour(Skin::kBody, true));
44 text_->setColor(findColour(Skin::kBodyText, true));
45
46 Rectangle<int> expired_rect = getExpiredRect();
47 body_.setBounds(expired_rect);
48 text_->setBounds(expired_rect.getX() + kPaddingX, expired_rect.getY() + kPaddingY,
49 expired_rect.getWidth() - 2 * kPaddingX, 22);
50 link_->setBounds(expired_rect.getX(), expired_rect.getY() + kPaddingY + 22, expired_rect.getWidth(), 22);
51
52 text_->redrawImage(false);
53 link_->redoImage();
55}
56
57void ExpiredSection::setVisible(bool should_be_visible) {
58 if (should_be_visible) {
59 // Force a background paint to ensure children are properly rendered.
60 Image image(Image::ARGB, 1, 1, false);
61 Graphics g(image);
63 }
64
65 Overlay::setVisible(should_be_visible);
66}
67
69 int x = (getWidth() - kExpiredWidth) / 2;
70 int y = getHeight() / 2 - kExpiredHeight;
71 return Rectangle<int>(x, y, kExpiredWidth, kExpiredHeight);
72}
static constexpr int kPaddingX
The horizontal padding within the overlay.
Definition expired_section.h:29
static constexpr int kPaddingY
The vertical padding within the overlay.
Definition expired_section.h:34
void setVisible(bool should_be_visible) override
Sets the visibility of this overlay.
Definition expired_section.cpp:57
static constexpr int kExpiredHeight
The fixed height of the expired section overlay.
Definition expired_section.h:24
static constexpr int kExpiredWidth
The fixed width of the expired section overlay.
Definition expired_section.h:19
ExpiredSection(String name)
Constructs an ExpiredSection overlay.
Definition expired_section.cpp:26
Rectangle< int > getExpiredRect()
Computes the rectangle area occupied by the expired message section.
Definition expired_section.cpp:68
void resized() override
Called when the component is resized.
Definition expired_section.cpp:41
static Fonts * instance()
Gets the singleton instance of the Fonts class.
Definition fonts.h:52
A template class that wraps a given ComponentType and automatically redraws an OpenGlImageComponent o...
Definition open_gl_image_component.h:153
OpenGlImageComponent image_component_
Definition open_gl_image_component.h:199
void setComponent(Component *component)
Sets the component to be drawn into the OpenGL image. If not set, uses this component.
Definition open_gl_image_component.h:83
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
@ 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