8 Rectangle<int> getGlobalBounds(Component* component, Rectangle<int> bounds) {
9 Component* parent = component->getParentComponent();
11 while (parent &&
dynamic_cast<FullInterface*
>(component) ==
nullptr) {
12 bounds = bounds + component->getPosition();
14 parent = component->getParentComponent();
20 Rectangle<int> getGlobalVisibleBounds(Component* component, Rectangle<int> visible_bounds) {
21 Component* parent = component->getParentComponent();
23 while (parent &&
dynamic_cast<FullInterface*
>(parent) ==
nullptr) {
24 visible_bounds = visible_bounds + component->getPosition();
25 parent->getLocalBounds().intersectRectangle(visible_bounds);
27 parent = component->getParentComponent();
30 return visible_bounds + component->getPosition();
35 parent_(nullptr), skin_override_(
Skin::kNone),
36 num_voices_readout_(nullptr) {
46 float render_scale = 1.0f;
48 render_scale *= open_gl.
context.getRenderingScale();
50 float gl_scale = render_scale * resize_scale;
52 Rectangle<int> top_level_bounds = top_level->getBounds();
53 Rectangle<int> global_bounds = getGlobalBounds(component, bounds);
54 Rectangle<int> visible_bounds = getGlobalVisibleBounds(component, bounds);
56 glViewport(gl_scale * global_bounds.getX(),
57 std::ceil(scale * render_scale * top_level_bounds.getHeight()) - gl_scale * global_bounds.getBottom(),
58 gl_scale * global_bounds.getWidth(), gl_scale * global_bounds.getHeight());
60 if (visible_bounds.getWidth() <= 0 || visible_bounds.getHeight() <= 0)
63 glScissor(gl_scale * visible_bounds.getX(),
64 std::ceil(scale * render_scale * top_level_bounds.getHeight()) - gl_scale * visible_bounds.getBottom(),
65 gl_scale * visible_bounds.getWidth(), gl_scale * visible_bounds.getHeight());
71 return setViewPort(component, component->getLocalBounds(), open_gl);
83 if (component ==
nullptr)
89 float render_scale = 1.0f;
91 render_scale *= open_gl.
context.getRenderingScale();
93 float gl_scale = render_scale * resize_scale;
95 Rectangle<int> top_level_bounds = top_level->getBounds();
96 Rectangle<int> visible_bounds = getGlobalVisibleBounds(component, bounds);
98 if (visible_bounds.getHeight() > 0 && visible_bounds.getWidth() > 0) {
99 glScissor(gl_scale * visible_bounds.getX(),
100 std::ceil(scale * render_scale * top_level_bounds.getHeight()) - gl_scale * visible_bounds.getBottom(),
101 gl_scale * visible_bounds.getWidth(), gl_scale * visible_bounds.getHeight());
116 FullInterface* parent = findParentComponentOfClass<FullInterface>();
123 corners_->setBounds(getLocalBounds());
135 Component::parentHierarchyChanged();
139 corners_ = std::make_unique<OpenGlCorners>();
156 corners_->setBottomCorners(getLocalBounds(), rounding);
158 corners_->setCorners(getLocalBounds(), rounding);
The main GUI container for the entire synthesizer interface.
Definition full_interface.h:61
void repaintOpenGlBackground(OpenGlComponent *component)
Repaints the background that shows behind OpenGL components.
Definition full_interface.cpp:338
float getResizingScale() const
Returns the scale factor for resizing operations.
Definition full_interface.h:492
bool only_bottom_corners_
Flag to round only the bottom corners.
Definition open_gl_component.h:253
static bool setViewPort(Component *component, Rectangle< int > bounds, OpenGlWrapper &open_gl)
Sets the OpenGL viewport to match a specified rectangle within a component.
Definition open_gl_component.cpp:42
void addRoundedCorners()
Adds rounded corners to the component's edges.
Definition open_gl_component.cpp:138
virtual void resized() override
Called when the component is resized.
Definition open_gl_component.cpp:121
void addBottomRoundedCorners()
Adds rounded corners only at the bottom of the component.
Definition open_gl_component.cpp:143
const vital::StatusOutput * num_voices_readout_
StatusOutput for voice count lookups.
Definition open_gl_component.h:258
void renderCorners(OpenGlWrapper &open_gl, bool animate, Colour color, float rounding)
Renders the corner shapes using the given color and rounding amount.
Definition open_gl_component.cpp:153
static void setScissorBounds(Component *component, Rectangle< int > bounds, OpenGlWrapper &open_gl)
Sets the OpenGL scissor region to a specified rectangle within a component.
Definition open_gl_component.cpp:82
static void setScissor(Component *component, OpenGlWrapper &open_gl)
Sets the OpenGL scissor region to the entire component's local bounds.
Definition open_gl_component.cpp:78
float findValue(Skin::ValueId value_id)
Finds a float value from the skin associated with this component's parent.
Definition open_gl_component.cpp:173
virtual void destroy(OpenGlWrapper &open_gl)
Destroys any OpenGL-specific resources allocated by this component.
Definition open_gl_component.cpp:168
OpenGlComponent(String name="")
Constructs an OpenGlComponent.
Definition open_gl_component.cpp:34
virtual ~OpenGlComponent()
Destructor.
Definition open_gl_component.cpp:40
virtual void paintBackground(Graphics &g)
Paints a standard background for the component.
Definition open_gl_component.cpp:105
Colour body_color_
The body color of the component.
Definition open_gl_component.h:255
virtual void init(OpenGlWrapper &open_gl)
Initializes any OpenGL-specific resources needed by the component.
Definition open_gl_component.cpp:148
Colour background_color_
The background color of the component.
Definition open_gl_component.h:254
void repaintBackground()
Requests a repaint of the component's background on the OpenGL layer.
Definition open_gl_component.cpp:112
std::unique_ptr< OpenGlCorners > corners_
Optional corners for rounded edges.
Definition open_gl_component.h:252
virtual void parentHierarchyChanged() override
Called when the component's parent hierarchy changes.
Definition open_gl_component.cpp:128
const SynthSection * parent_
Pointer to parent SynthSection for skin lookups.
Definition open_gl_component.h:256
Manages the overall color and value theme (or "skin") of the user interface.
Definition skin.h:24
ValueId
Identifiers for various UI scaling/spacing values and configuration constants.
Definition skin.h:70
@ kWidgetRoundedCorner
Definition skin.h:104
@ kWidgetBackground
Definition skin.h:173
@ kBody
Definition skin.h:129
const vital::StatusOutput * getStatusOutput(const std::string &name)
Retrieves a status output by name.
Definition synth_base.cpp:262
An interface class linking the Vital synthesizer backend (SynthBase) with a GUI.
Definition synth_gui_interface.h:56
SynthBase * getSynth()
Returns the SynthBase instance this interface is managing.
Definition synth_gui_interface.h:85
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
#define VITAL_ASSERT(x)
Definition common.h:11
A helper struct containing references to OpenGL context, shaders, and display scale.
Definition shaders.h:174
OpenGLContext & context
The OpenGLContext for current rendering.
Definition shaders.h:181
float display_scale
Display scaling factor for high-DPI rendering.
Definition shaders.h:183