Vital
Loading...
Searching...
No Matches
open_gl_multi_quad.h
Go to the documentation of this file.
1#pragma once
2
3#include "JuceHeader.h"
4#include "open_gl_component.h"
5
6#include <mutex>
7
17 public:
19 static constexpr int kNumVertices = 4;
21 static constexpr int kNumFloatsPerVertex = 10;
25 static constexpr int kNumIndicesPerQuad = 6;
27 static constexpr float kThicknessDecay = 0.4f;
29 static constexpr float kAlphaInc = 0.2f;
30
37
41 virtual ~OpenGlMultiQuad();
42
47 virtual void init(OpenGlWrapper& open_gl) override;
48
54 virtual void render(OpenGlWrapper& open_gl, bool animate) override;
55
60 virtual void destroy(OpenGlWrapper& open_gl) override;
61
65 void paintBackground(Graphics& g) override { }
66
70 void resized() override {
72 dirty_ = true;
73 }
74
78 void markDirty() {
79 dirty_ = true;
80 }
81
87
92 void setNumQuads(int num_quads) {
93 VITAL_ASSERT(num_quads <= max_quads_);
94 num_quads_ = num_quads;
95 dirty_ = true;
96 }
97
102 force_inline void setColor(Colour color) {
103 color_ = color;
104 }
105
111 return color_;
112 }
113
118 force_inline void setAltColor(Colour color) {
119 alt_color_ = color;
120 }
121
126 force_inline void setModColor(Colour color) {
127 mod_color_ = color;
128 }
129
134 force_inline void setThumbColor(Colour color) {
135 thumb_color_ = color;
136 }
137
142 force_inline void setThumbAmount(float amount) {
143 thumb_amount_ = amount;
144 }
145
150 force_inline void setStartPos(float pos) {
151 start_pos_ = pos;
152 }
153
158 force_inline void setMaxArc(float max_arc) {
159 max_arc_ = max_arc;
160 }
161
167 return max_arc_;
168 }
169
175 force_inline float getQuadX(int i) const {
176 int index = kNumFloatsPerQuad * i;
177 return data_[index];
178 }
179
183 force_inline float getQuadY(int i) const {
184 int index = kNumFloatsPerQuad * i;
185 return data_[index + 1];
186 }
187
191 force_inline float getQuadWidth(int i) const {
192 int index = kNumFloatsPerQuad * i;
193 return data_[2 * kNumFloatsPerVertex + index] - data_[index];
194 }
195
199 force_inline float getQuadHeight(int i) const {
200 int index = kNumFloatsPerQuad * i;
201 return data_[kNumFloatsPerVertex + index + 1] - data_[index + 1];
202 }
203
209 float* getVerticesData(int i) {
210 int index = kNumFloatsPerQuad * i;
211 return data_.get() + index;
212 }
213
217 void setRotatedCoordinates(int i, float x, float y, float w, float h) {
219 int index = i * kNumFloatsPerQuad;
220
221 data_[index + 4] = x;
222 data_[index + 5] = y + h;
223 data_[kNumFloatsPerVertex + index + 4] = x + w;
224 data_[kNumFloatsPerVertex + index + 5] = y + h;
225 data_[2 * kNumFloatsPerVertex + index + 4] = x + w;
226 data_[2 * kNumFloatsPerVertex + index + 5] = y;
227 data_[3 * kNumFloatsPerVertex + index + 4] = x;
228 data_[3 * kNumFloatsPerVertex + index + 5] = y;
229 }
230
234 void setCoordinates(int i, float x, float y, float w, float h) {
236 int index = i * kNumFloatsPerQuad;
237
238 data_[index + 4] = x;
239 data_[index + 5] = y;
240 data_[kNumFloatsPerVertex + index + 4] = x;
241 data_[kNumFloatsPerVertex + index + 5] = y + h;
242 data_[2 * kNumFloatsPerVertex + index + 4] = x + w;
243 data_[2 * kNumFloatsPerVertex + index + 5] = y + h;
244 data_[3 * kNumFloatsPerVertex + index + 4] = x + w;
245 data_[3 * kNumFloatsPerVertex + index + 5] = y;
246 }
247
254 void setShaderValue(int i, float shader_value, int value_index = 0) {
256 int index = i * kNumFloatsPerQuad + 6 + value_index;
257 data_[index] = shader_value;
258 data_[kNumFloatsPerVertex + index] = shader_value;
259 data_[2 * kNumFloatsPerVertex + index] = shader_value;
260 data_[3 * kNumFloatsPerVertex + index] = shader_value;
261 dirty_ = true;
262 }
263
267 void setDimensions(int i, float quad_width, float quad_height, float full_width, float full_height) {
268 int index = i * kNumFloatsPerQuad;
269 float w = quad_width * full_width / 2.0f;
270 float h = quad_height * full_height / 2.0f;
271
272 data_[index + 2] = w;
273 data_[index + 3] = h;
274 data_[kNumFloatsPerVertex + index + 2] = w;
275 data_[kNumFloatsPerVertex + index + 3] = h;
276 data_[2 * kNumFloatsPerVertex + index + 2] = w;
277 data_[2 * kNumFloatsPerVertex + index + 3] = h;
278 data_[3 * kNumFloatsPerVertex + index + 2] = w;
279 data_[3 * kNumFloatsPerVertex + index + 3] = h;
280 }
281
285 void setQuadHorizontal(int i, float x, float w) {
287 int index = i * kNumFloatsPerQuad;
288 data_[index] = x;
289 data_[kNumFloatsPerVertex + index] = x;
290 data_[2 * kNumFloatsPerVertex + index] = x + w;
291 data_[3 * kNumFloatsPerVertex + index] = x + w;
292
293 dirty_ = true;
294 }
295
299 void setQuadVertical(int i, float y, float h) {
301 int index = i * kNumFloatsPerQuad;
302 data_[index + 1] = y;
303 data_[kNumFloatsPerVertex + index + 1] = y + h;
304 data_[2 * kNumFloatsPerVertex + index + 1] = y + h;
305 data_[3 * kNumFloatsPerVertex + index + 1] = y;
306
307 dirty_ = true;
308 }
309
313 void setQuad(int i, float x, float y, float w, float h) {
315 int index = i * kNumFloatsPerQuad;
316 data_[index] = x;
317 data_[index + 1] = y;
318 data_[kNumFloatsPerVertex + index] = x;
319 data_[kNumFloatsPerVertex + index + 1] = y + h;
320 data_[2 * kNumFloatsPerVertex + index] = x + w;
321 data_[2 * kNumFloatsPerVertex + index + 1] = y + h;
322 data_[3 * kNumFloatsPerVertex + index] = x + w;
323 data_[3 * kNumFloatsPerVertex + index + 1] = y;
324
325 dirty_ = true;
326 }
327
331 void setActive(bool active) {
332 active_ = active;
333 }
334
338 void setThickness(float thickness, bool reset = false) {
339 thickness_ = thickness;
340 if (reset)
342 }
343
347 void setRounding(float rounding) {
348 float adjusted = 2.0f * rounding;
349 if (adjusted != rounding_) {
350 dirty_ = true;
351 rounding_ = adjusted;
352 }
353 }
354
358 void setTargetComponent(Component* target_component) {
359 target_component_ = target_component;
360 }
361
365 void setScissorComponent(Component* scissor_component) {
366 scissor_component_ = scissor_component;
367 }
368
372 OpenGLShaderProgram* shader() { return shader_; }
373
377 void setAdditive(bool additive) { additive_blending_ = additive; }
378
382 void setAlpha(float alpha, bool reset = false) {
383 alpha_mult_ = alpha;
384 if (reset)
385 current_alpha_mult_ = alpha;
386 }
387
392
393 protected:
394 Component* target_component_;
399
401 bool active_;
402 bool dirty_;
403 Colour color_;
404 Colour alt_color_;
405 Colour mod_color_;
407 float max_arc_;
415 float rounding_;
416
417 std::unique_ptr<float[]> data_;
418 std::unique_ptr<int[]> indices_;
419
420 OpenGLShaderProgram* shader_;
421 std::unique_ptr<OpenGLShaderProgram::Uniform> color_uniform_;
422 std::unique_ptr<OpenGLShaderProgram::Uniform> alt_color_uniform_;
423 std::unique_ptr<OpenGLShaderProgram::Uniform> mod_color_uniform_;
424 std::unique_ptr<OpenGLShaderProgram::Uniform> background_color_uniform_;
425 std::unique_ptr<OpenGLShaderProgram::Uniform> thumb_color_uniform_;
426 std::unique_ptr<OpenGLShaderProgram::Uniform> thickness_uniform_;
427 std::unique_ptr<OpenGLShaderProgram::Uniform> rounding_uniform_;
428 std::unique_ptr<OpenGLShaderProgram::Uniform> max_arc_uniform_;
429 std::unique_ptr<OpenGLShaderProgram::Uniform> thumb_amount_uniform_;
430 std::unique_ptr<OpenGLShaderProgram::Uniform> start_pos_uniform_;
431 std::unique_ptr<OpenGLShaderProgram::Uniform> alpha_mult_uniform_;
432 std::unique_ptr<OpenGLShaderProgram::Attribute> position_;
433 std::unique_ptr<OpenGLShaderProgram::Attribute> dimensions_;
434 std::unique_ptr<OpenGLShaderProgram::Attribute> coordinates_;
435 std::unique_ptr<OpenGLShaderProgram::Attribute> shader_values_;
436
439
440 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(OpenGlMultiQuad)
441};
442
448 public:
454 setQuad(0, -1.0f, -1.0f, 2.0f, 2.0f);
455 }
456};
457
463 public:
464 OpenGlScrollQuad() : OpenGlQuad(Shaders::kRoundedRectangleFragment), scroll_bar_(nullptr),
465 hover_(false), shrink_left_(false), hover_amount_(-1.0f) { }
466
467 virtual void render(OpenGlWrapper& open_gl, bool animate) override {
468 static constexpr float kHoverChange = 0.2f;
469 float last_hover = hover_amount_;
470 if (hover_)
471 hover_amount_ = std::min(1.0f, hover_amount_ + kHoverChange);
472 else
473 hover_amount_ = std::max(0.0f, hover_amount_ - kHoverChange);
474
475 if (last_hover != hover_amount_) {
476 if (shrink_left_)
477 setQuadHorizontal(0, -1.0f, 1.0f + hover_amount_);
478 else
479 setQuadHorizontal(0, 0.0f - hover_amount_, 1.0f + hover_amount_);
480 }
481
482 Range<double> range = scroll_bar_->getCurrentRange();
483 Range<double> total_range = scroll_bar_->getRangeLimit();
484 float start_ratio = (range.getStart() - total_range.getStart()) / total_range.getLength();
485 float end_ratio = (range.getEnd() - total_range.getStart()) / total_range.getLength();
486 setQuadVertical(0, 1.0f - 2.0f * end_ratio, 2.0f * (end_ratio - start_ratio));
487
488 OpenGlQuad::render(open_gl, animate);
489 }
490
491 void setHover(bool hover) { hover_ = hover; }
492 void setShrinkLeft(bool shrink_left) { shrink_left_ = shrink_left; }
493 void setScrollBar(ScrollBar* scroll_bar) { scroll_bar_ = scroll_bar; }
494
495 private:
496 ScrollBar* scroll_bar_;
497 bool hover_;
498 bool shrink_left_;
499 float hover_amount_;
500};
501
506class OpenGlScrollBar : public ScrollBar {
507 public:
508 OpenGlScrollBar() : ScrollBar(true) {
509 bar_.setTargetComponent(this);
510 addAndMakeVisible(bar_);
511 bar_.setScrollBar(this);
512 }
513
514 OpenGlQuad* getGlComponent() { return &bar_; }
515
516 void resized() override {
517 ScrollBar::resized();
518 bar_.setBounds(getLocalBounds());
519 bar_.setRounding(getWidth() * 0.25f);
520 }
521
522 void mouseEnter(const MouseEvent& e) override {
523 ScrollBar::mouseEnter(e);
524 bar_.setHover(true);
525 }
526
527 void mouseExit(const MouseEvent& e) override {
528 ScrollBar::mouseExit(e);
529 bar_.setHover(false);
530 }
531
532 void mouseDown(const MouseEvent& e) override {
533 ScrollBar::mouseDown(e);
534 bar_.setColor(color_.overlaidWith(color_));
535 }
536
537 void mouseUp(const MouseEvent& e) override {
538 ScrollBar::mouseDown(e);
539 bar_.setColor(color_);
540 }
541
542 void setColor(Colour color) { color_ = color; bar_.setColor(color); }
543 void setShrinkLeft(bool shrink_left) { bar_.setShrinkLeft(shrink_left); }
544
545 private:
546 Colour color_;
547 OpenGlScrollQuad bar_;
548};
549
555 public:
556 OpenGlCorners() : OpenGlMultiQuad(4, Shaders::kRoundedCornerFragment) {
557 setCoordinates(0, 1.0f, 1.0f, -1.0f, -1.0f);
558 setCoordinates(1, 1.0f, 0.0f, -1.0f, 1.0f);
559 setCoordinates(2, 0.0f, 0.0f, 1.0f, 1.0f);
560 setCoordinates(3, 0.0f, 1.0f, 1.0f, -1.0f);
561 }
562
568 void setCorners(Rectangle<int> bounds, float rounding) {
569 float width = rounding / bounds.getWidth() * 2.0f;
570 float height = rounding / bounds.getHeight() * 2.0f;
571
572 setQuad(0, -1.0f, -1.0f, width, height);
573 setQuad(1, -1.0f, 1.0f - height, width, height);
574 setQuad(2, 1.0f - width, 1.0f - height, width, height);
575 setQuad(3, 1.0f - width, -1.0f, width, height);
576 }
577
581 void setBottomCorners(Rectangle<int> bounds, float rounding) {
582 float width = rounding / bounds.getWidth() * 2.0f;
583 float height = rounding / bounds.getHeight() * 2.0f;
584
585 setQuad(0, -1.0f, -1.0f, width, height);
586 setQuad(1, -2.0f, -2.0f, 0.0f, 0.0f);
587 setQuad(2, -2.0f, -2.0f, 0.0f, 0.0f);
588 setQuad(3, 1.0f - width, -1.0f, width, height);
589 }
590};
A base component class that integrates JUCE's Component with OpenGL rendering.
Definition open_gl_component.h:20
virtual void render(OpenGlWrapper &open_gl, bool animate)=0
Pure virtual function to render the component using OpenGL.
virtual void resized() override
Called when the component is resized.
Definition open_gl_component.cpp:121
A set of quads forming rounded corners, used to render corner shapes via OpenGL.
Definition open_gl_multi_quad.h:554
void setCorners(Rectangle< int > bounds, float rounding)
Configures quads to form all four rounded corners of a rectangle.
Definition open_gl_multi_quad.h:568
OpenGlCorners()
Definition open_gl_multi_quad.h:556
void setBottomCorners(Rectangle< int > bounds, float rounding)
Configures quads to form only the bottom rounded corners of a rectangle.
Definition open_gl_multi_quad.h:581
A component for rendering multiple quads using OpenGL, with customizable colors, rounding,...
Definition open_gl_multi_quad.h:16
float current_alpha_mult_
Current alpha multiplier for gradual changes.
Definition open_gl_multi_quad.h:410
Shaders::FragmentShader fragment_shader_
The fragment shader used for rendering.
Definition open_gl_multi_quad.h:396
bool draw_when_not_visible_
If true, draw even if the component is not visible.
Definition open_gl_multi_quad.h:400
std::unique_ptr< OpenGLShaderProgram::Attribute > shader_values_
Definition open_gl_multi_quad.h:435
float thickness_
Target thickness.
Definition open_gl_multi_quad.h:414
void setThickness(float thickness, bool reset=false)
Sets the thickness used by some shaders and can reset to this thickness.
Definition open_gl_multi_quad.h:338
Colour thumb_color_
Color for a "thumb" element (e.g., in a slider).
Definition open_gl_multi_quad.h:406
void setActive(bool active)
Activates or deactivates rendering of this component.
Definition open_gl_multi_quad.h:331
void paintBackground(Graphics &g) override
Suppresses background painting; rendering is handled by OpenGL.
Definition open_gl_multi_quad.h:65
Colour alt_color_
Alternate color for shader use.
Definition open_gl_multi_quad.h:404
void setQuadHorizontal(int i, float x, float w)
Sets horizontal position and width for a quad.
Definition open_gl_multi_quad.h:285
void setShaderValue(int i, float shader_value, int value_index=0)
Sets a shader value for all four vertices of a quad.
Definition open_gl_multi_quad.h:254
Colour mod_color_
Modulation color for shader.
Definition open_gl_multi_quad.h:405
void markDirty()
Marks all vertex data as dirty, prompting a refresh on the next render.
Definition open_gl_multi_quad.h:78
bool active_
If false, nothing is rendered.
Definition open_gl_multi_quad.h:401
std::unique_ptr< OpenGLShaderProgram::Uniform > color_uniform_
Definition open_gl_multi_quad.h:421
virtual void init(OpenGlWrapper &open_gl) override
Initializes OpenGL buffers and shader attributes.
Definition open_gl_multi_quad.cpp:37
void setQuad(int i, float x, float y, float w, float h)
Sets the position and size of a quad in normalized device space.
Definition open_gl_multi_quad.h:313
OpenGLShaderProgram * shader_
Definition open_gl_multi_quad.h:420
float thumb_amount_
Amount parameter for thumb effects.
Definition open_gl_multi_quad.h:408
void setQuadVertical(int i, float y, float h)
Sets vertical position and height for a quad.
Definition open_gl_multi_quad.h:299
force_inline float getQuadHeight(int i) const
Gets the height of the specified quad.
Definition open_gl_multi_quad.h:199
std::unique_ptr< OpenGLShaderProgram::Uniform > alt_color_uniform_
Definition open_gl_multi_quad.h:422
static constexpr float kThicknessDecay
Decay factor for thickness adjustments over time.
Definition open_gl_multi_quad.h:27
void setTargetComponent(Component *target_component)
Sets a target component to help position the quads.
Definition open_gl_multi_quad.h:358
void setNumQuads(int num_quads)
Sets how many quads will actually be drawn (up to max_quads).
Definition open_gl_multi_quad.h:92
bool additive_blending_
Use additive blending if true.
Definition open_gl_multi_quad.h:412
force_inline void setAltColor(Colour color)
Sets an alternate color, often used by custom shaders.
Definition open_gl_multi_quad.h:118
void setFragmentShader(Shaders::FragmentShader shader)
Sets the fragment shader used to render the quads.
Definition open_gl_multi_quad.h:86
float rounding_
Rounding radius for corners.
Definition open_gl_multi_quad.h:415
virtual void render(OpenGlWrapper &open_gl, bool animate) override
Renders the quads using OpenGL.
Definition open_gl_multi_quad.cpp:92
static constexpr int kNumFloatsPerVertex
Number of floats per vertex (x, y, w, h, plus custom shader values).
Definition open_gl_multi_quad.h:21
float * getVerticesData(int i)
Gets a pointer to the vertex data for a given quad.
Definition open_gl_multi_quad.h:209
GLuint indices_buffer_
OpenGL buffer for index data.
Definition open_gl_multi_quad.h:438
virtual void destroy(OpenGlWrapper &open_gl) override
Releases OpenGL resources when the component is destroyed.
Definition open_gl_multi_quad.cpp:69
std::unique_ptr< OpenGLShaderProgram::Uniform > background_color_uniform_
Definition open_gl_multi_quad.h:424
void resized() override
Called when the component is resized. Marks data as dirty to recalculate positions if needed.
Definition open_gl_multi_quad.h:70
void setCoordinates(int i, float x, float y, float w, float h)
Sets coordinates for a quad in normalized device space.
Definition open_gl_multi_quad.h:234
static constexpr float kAlphaInc
Increment for alpha blending adjustments.
Definition open_gl_multi_quad.h:29
force_inline void setColor(Colour color)
Sets the base color for the quads.
Definition open_gl_multi_quad.h:102
static constexpr int kNumFloatsPerQuad
Number of floats total per quad (4 vertices * 10 floats each).
Definition open_gl_multi_quad.h:23
virtual ~OpenGlMultiQuad()
Destructor. Frees any allocated OpenGL resources.
Definition open_gl_multi_quad.cpp:35
force_inline void setStartPos(float pos)
Sets a starting position used by some shaders (e.g., arc start).
Definition open_gl_multi_quad.h:150
static constexpr int kNumIndicesPerQuad
Number of indices per quad (2 triangles forming a rectangle).
Definition open_gl_multi_quad.h:25
std::unique_ptr< OpenGLShaderProgram::Uniform > mod_color_uniform_
Definition open_gl_multi_quad.h:423
void setScissorComponent(Component *scissor_component)
Sets a component for scissoring (clipping) rendering area.
Definition open_gl_multi_quad.h:365
GLuint vertex_buffer_
OpenGL buffer for vertex data.
Definition open_gl_multi_quad.h:437
force_inline float getQuadWidth(int i) const
Gets the width of the specified quad.
Definition open_gl_multi_quad.h:191
force_inline void setThumbAmount(float amount)
Sets the amount of thumb exposure (used in certain shader effects).
Definition open_gl_multi_quad.h:142
float max_arc_
Maximum arc for certain shader effects.
Definition open_gl_multi_quad.h:407
std::unique_ptr< OpenGLShaderProgram::Attribute > coordinates_
Definition open_gl_multi_quad.h:434
void setDimensions(int i, float quad_width, float quad_height, float full_width, float full_height)
Sets dimensions for a quad, typically to scale based on component size.
Definition open_gl_multi_quad.h:267
Colour color_
Base color tint.
Definition open_gl_multi_quad.h:403
std::unique_ptr< OpenGLShaderProgram::Attribute > position_
Definition open_gl_multi_quad.h:432
std::unique_ptr< OpenGLShaderProgram::Uniform > rounding_uniform_
Definition open_gl_multi_quad.h:427
std::unique_ptr< int[]> indices_
Index data for drawing quads.
Definition open_gl_multi_quad.h:418
std::unique_ptr< OpenGLShaderProgram::Uniform > thickness_uniform_
Definition open_gl_multi_quad.h:426
force_inline float getMaxArc()
Gets the current maximum arc value.
Definition open_gl_multi_quad.h:166
force_inline void setThumbColor(Colour color)
Sets a "thumb" color, potentially for scroll bars or similar widgets.
Definition open_gl_multi_quad.h:134
std::unique_ptr< OpenGLShaderProgram::Uniform > max_arc_uniform_
Definition open_gl_multi_quad.h:428
void setDrawWhenNotVisible(bool draw)
Sets whether to draw even if the component is not visible.
Definition open_gl_multi_quad.h:391
int max_quads_
Maximum number of quads.
Definition open_gl_multi_quad.h:397
std::unique_ptr< OpenGLShaderProgram::Uniform > start_pos_uniform_
Definition open_gl_multi_quad.h:430
Component * scissor_component_
The component used for scissoring (clipping).
Definition open_gl_multi_quad.h:395
void setRounding(float rounding)
Sets the rounding radius of the quads.
Definition open_gl_multi_quad.h:347
bool dirty_
If true, vertex data is dirty and needs re-upload.
Definition open_gl_multi_quad.h:402
force_inline float getQuadY(int i) const
Gets the y-position of a specified quad.
Definition open_gl_multi_quad.h:183
static constexpr int kNumVertices
Number of vertices per quad.
Definition open_gl_multi_quad.h:19
force_inline float getQuadX(int i) const
Gets the x-position of a specified quad.
Definition open_gl_multi_quad.h:175
force_inline void setMaxArc(float max_arc)
Sets the maximum arc angle or similar parameter used by some shaders.
Definition open_gl_multi_quad.h:158
float alpha_mult_
Target alpha multiplier.
Definition open_gl_multi_quad.h:411
std::unique_ptr< float[]> data_
Vertex data for all quads.
Definition open_gl_multi_quad.h:417
float start_pos_
Start position parameter for shader effects.
Definition open_gl_multi_quad.h:409
Component * target_component_
The component this relates to for sizing/positioning.
Definition open_gl_multi_quad.h:394
std::unique_ptr< OpenGLShaderProgram::Attribute > dimensions_
Definition open_gl_multi_quad.h:433
force_inline void setModColor(Colour color)
Sets a modulation color for custom effects in the shader.
Definition open_gl_multi_quad.h:126
std::unique_ptr< OpenGLShaderProgram::Uniform > thumb_color_uniform_
Definition open_gl_multi_quad.h:425
std::unique_ptr< OpenGLShaderProgram::Uniform > alpha_mult_uniform_
Definition open_gl_multi_quad.h:431
OpenGLShaderProgram * shader()
Gets the current OpenGL shader program.
Definition open_gl_multi_quad.h:372
OpenGlMultiQuad(int max_quads, Shaders::FragmentShader shader=Shaders::kColorFragment)
Constructs an OpenGlMultiQuad with a given maximum number of quads.
Definition open_gl_multi_quad.cpp:6
void setAlpha(float alpha, bool reset=false)
Sets the alpha blending multiplier, can reset to this alpha.
Definition open_gl_multi_quad.h:382
force_inline Colour getColor()
Gets the current base color.
Definition open_gl_multi_quad.h:110
std::unique_ptr< OpenGLShaderProgram::Uniform > thumb_amount_uniform_
Definition open_gl_multi_quad.h:429
void setAdditive(bool additive)
Enables or disables additive blending for rendering.
Definition open_gl_multi_quad.h:377
int num_quads_
Current number of quads to draw.
Definition open_gl_multi_quad.h:398
void setRotatedCoordinates(int i, float x, float y, float w, float h)
Sets rotated coordinates for a quad, adjusting its texture mapping.
Definition open_gl_multi_quad.h:217
float current_thickness_
Current thickness for gradual changes.
Definition open_gl_multi_quad.h:413
A convenience class for a single quad rendered via OpenGL.
Definition open_gl_multi_quad.h:447
OpenGlQuad(Shaders::FragmentShader shader)
Constructs a single quad with a given fragment shader.
Definition open_gl_multi_quad.h:453
A ScrollBar that uses OpenGlMultiQuad for rendering its visual indication.
Definition open_gl_multi_quad.h:506
void mouseDown(const MouseEvent &e) override
Definition open_gl_multi_quad.h:532
void setShrinkLeft(bool shrink_left)
Definition open_gl_multi_quad.h:543
void mouseExit(const MouseEvent &e) override
Definition open_gl_multi_quad.h:527
OpenGlScrollBar()
Definition open_gl_multi_quad.h:508
void mouseEnter(const MouseEvent &e) override
Definition open_gl_multi_quad.h:522
void resized() override
Definition open_gl_multi_quad.h:516
void mouseUp(const MouseEvent &e) override
Definition open_gl_multi_quad.h:537
void setColor(Colour color)
Definition open_gl_multi_quad.h:542
OpenGlQuad * getGlComponent()
Definition open_gl_multi_quad.h:514
A specialized quad used as a scroll indicator, responding to hover and scroll changes.
Definition open_gl_multi_quad.h:462
virtual void render(OpenGlWrapper &open_gl, bool animate) override
Renders the quads using OpenGL.
Definition open_gl_multi_quad.h:467
OpenGlScrollQuad()
Definition open_gl_multi_quad.h:464
void setHover(bool hover)
Definition open_gl_multi_quad.h:491
void setScrollBar(ScrollBar *scroll_bar)
Definition open_gl_multi_quad.h:493
void setShrinkLeft(bool shrink_left)
Definition open_gl_multi_quad.h:492
Manages and provides access to vertex and fragment shaders used by the OpenGL rendering pipeline.
Definition shaders.h:19
FragmentShader
An enumeration of all available fragment shaders.
Definition shaders.h:58
@ kColorFragment
Definition shaders.h:63
#define VITAL_ASSERT(x)
Definition common.h:11
#define force_inline
Definition common.h:23
A helper struct containing references to OpenGL context, shaders, and display scale.
Definition shaders.h:174