12 void barEditorCallback(
int result,
BarEditor* bar_editor) {
13 if (bar_editor ==
nullptr)
39 if (e.mods.isPopupMenu()) {
48 SynthSection* parent = findParentComponentOfClass<SynthSection>();
50 [=](
int selection) { barEditorCallback(selection, this); });
62 if (!e.mods.isPopupMenu()) {
66 listener->barsChanged(index, index,
true);
72 if (!e.mods.isPopupMenu()) {
105 listener->barsChanged(position + 1,
num_points_ - 1,
true);
110 for (
int i = 0; i < position; ++i)
114 listener->barsChanged(0, position - 1,
true);
134 Point<int> mouse_position = e.getPosition();
139 float x = mouse_position.x;
140 float y = mouse_position.y;
143 float slope = y_delta == 0 ? 0 : y_delta / x_delta;
147 if (selected_index < from_index) {
151 float inc_x = next_x - x;
153 for (
int index = selected_index; index != from_index + direction; index += direction) {
155 float new_value = -2.0f * y / getHeight() + 1.0f;
163 int min_index = std::min(from_index, selected_index);
164 int max_index = std::max(from_index, selected_index);
167 listener->barsChanged(min_index, max_index,
false);
Interface for receiving notifications when bar values are changed.
Definition bar_editor.h:24
An interactive component that allows editing individual bars in a bar graph visually.
Definition bar_editor.h:18
void mouseExit(const MouseEvent &e) override
Handles mouse exit events. Clears hover state.
Definition bar_editor.cpp:78
void clearOdd()
Clears every odd-indexed bar.
Definition bar_editor.cpp:125
void mouseDown(const MouseEvent &e) override
Handles mouse down events. Initiates editing or shows popup menu.
Definition bar_editor.cpp:35
Point< int > current_mouse_position_
Current mouse position.
Definition bar_editor.h:196
void mouseDrag(const MouseEvent &e) override
Handles mouse drag events. Updates bar values while dragging.
Definition bar_editor.cpp:70
void mouseMove(const MouseEvent &e) override
Handles mouse move events to update hovered bar.
Definition bar_editor.cpp:31
void mouseUp(const MouseEvent &e) override
Handles mouse up events. Completes editing operation.
Definition bar_editor.cpp:58
vital::utils::RandomGenerator random_generator_
Random generator for randomizing bars.
Definition bar_editor.h:194
float clear_value_
Value to clear bars to.
Definition bar_editor.h:199
void changeValues(const MouseEvent &e)
Changes values based on mouse drag position.
Definition bar_editor.cpp:133
void clearLeft()
Clears bars to the left of the currently hovered bar.
Definition bar_editor.cpp:108
void clearRight()
Clears bars to the right of the currently hovered bar.
Definition bar_editor.cpp:99
@ kClearEven
Definition bar_editor.h:47
@ kClearLeft
Definition bar_editor.h:46
@ kRandomize
Definition bar_editor.h:49
@ kClearOdd
Definition bar_editor.h:48
@ kClear
Definition bar_editor.h:44
@ kClearRight
Definition bar_editor.h:45
void clearEven()
Clears every even-indexed bar.
Definition bar_editor.cpp:117
bool editing_
Whether the user is currently editing bars.
Definition bar_editor.h:198
int getHoveredIndex(Point< int > position)
Gets the index of the bar under the given position.
Definition bar_editor.cpp:172
void randomize()
Randomizes all bars using a uniform distribution.
Definition bar_editor.cpp:82
void clear()
Clears all bars to the clear value.
Definition bar_editor.cpp:91
std::vector< Listener * > listeners_
List of listeners for bar changes.
Definition bar_editor.h:195
Point< int > last_edit_position_
Last position during editing for interpolation.
Definition bar_editor.h:197
int num_points_
Number of bars to render.
Definition bar_renderer.h:280
bool dirty_
True if bar data needs to be re-uploaded to the GPU.
Definition bar_renderer.h:279
float scale_
Scale factor for bar dimensions.
Definition bar_renderer.h:271
force_inline void setY(int index, float val)
Sets the top y-position of a specific bar.
Definition bar_renderer.h:154
Base class for all synthesizer sections, providing UI layout, painting, and interaction logic.
Definition synth_section.h:193
void showPopupSelector(Component *source, Point< int > position, const PopupItems &options, std::function< void(int)> callback, std::function< void()> cancel={ })
Shows a popup selector with options.
Definition synth_section.cpp:119
force_inline mono_float next()
Returns the next random float in [min, max].
Definition utils.h:85
force_inline int iclamp(int value, int min_val, int max_val)
Clamps an integer between [min_val, max_val].
Definition utils.h:250
force_inline poly_float clamp(poly_float value, mono_float min, mono_float max)
Clamps each lane of a vector to [min, max].
Definition poly_utils.h:306
Provides various utility functions, classes, and constants for audio, math, and general-purpose opera...