Line data Source code
1 : #pragma once
2 :
3 : #include <imgui.h>
4 : #include <string>
5 : #include <functional>
6 :
7 : namespace Amplitron {
8 :
9 426 : struct KnobProps {
10 : std::string name;
11 213 : float value = 0.0f;
12 213 : float min_val = 0.0f;
13 213 : float max_val = 1.0f;
14 213 : float default_val = 0.0f;
15 : std::string unit;
16 : std::string tooltip;
17 :
18 : // MIDI status
19 213 : bool is_learning = false;
20 : std::string midi_info;
21 :
22 : // Color theme
23 213 : ImVec4 led_color = ImVec4(1.0f, 1.0f, 1.0f, 1.0f);
24 :
25 : // Callback events
26 : std::function<void(float)> on_value_changed;
27 : std::function<void(float, float)> on_value_committed; // old_val, new_val
28 : std::function<void()> on_midi_learn_param;
29 : std::function<void()> on_midi_clear_param;
30 : std::function<void()> on_midi_learn_bypass;
31 : std::function<void()> on_midi_clear_bypass;
32 : };
33 :
34 : class KnobComponent {
35 : public:
36 : /**
37 : * @brief Render a reusable parameter rotary knob.
38 : * @param imgui_id Unique ID string for ImGui tracking.
39 : * @param props Configuration, current state, and callbacks.
40 : * @param zoom DPI / GUI zoom multiplier.
41 : * @param center Center coordinates where the knob should be drawn.
42 : */
43 : static void render(const char* imgui_id, const KnobProps& props, float zoom, ImVec2 center);
44 : };
45 :
46 : } // namespace Amplitron
|