Skip to content

Commit

Permalink
use enumerator for parameter IDs in the UI
Browse files Browse the repository at this point in the history
  • Loading branch information
dromer committed Nov 10, 2023
1 parent f111545 commit 564b74b
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions hvcc/generators/c2dpf/templates/HeavyDPF_UI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,14 @@
START_NAMESPACE_DISTRHO

// --------------------------------------------------------------------------------------------------------------------
{%- if receivers|length > 0 %}
enum HeavyParams {
{%- for k, v in receivers %}
{{v.display|upper}},
{%- endfor %}
};
{%- endif %}

class ImGuiPluginUI : public UI
{
{% for k, v in receivers -%}
Expand Down Expand Up @@ -51,7 +59,7 @@ class ImGuiPluginUI : public UI
{%- if receivers|length > 0 %}
switch (index) {
{% for k, v in receivers -%}
case {{loop.index-1}}:
case {{v.display|upper}}:
{%- if v.attributes.type == 'bool': %}
f{{v.display|lower}} = value != 0.0f;
{%- else %}
Expand Down Expand Up @@ -105,8 +113,8 @@ class ImGuiPluginUI : public UI
if (ImGui::Selectable({{enum_list}}[n], is_selected))
{
f{{v_display}} = n;
editParameter({{loop.index-1}}, true);
setParameterValue({{loop.index-1}}, f{{v_display}});
editParameter({{v.display|upper}}, true);
setParameterValue({{v.display|upper}}, f{{v_display}});
}
if (is_selected)
ImGui::SetItemDefaultFocus();
Expand All @@ -124,17 +132,17 @@ class ImGuiPluginUI : public UI
{
if (ImGui::IsItemActivated())
{
editParameter({{loop.index-1}}, true);
setParameterValue({{loop.index-1}}, f{{v_display}});
editParameter({{v.display|upper}}, true);
setParameterValue({{v.display|upper}}, f{{v_display}});
}
}
{%- endif %}
{% endfor %}
if (ImGui::IsItemDeactivated())
{
{%- for i in range(0, receivers|length) %}
editParameter({{i}}, false);
{%- endfor %}
{%- for k, v in receivers -%}
editParameter({{v.display|upper}}, false);
{% endfor -%}
}
}
ImGui::End();
Expand Down

0 comments on commit 564b74b

Please sign in to comment.