|
| 1 | +#include "ImGui_UI.hpp" |
| 2 | +#include "DistrhoPluginInfo.h" |
| 3 | + |
| 4 | +#include "Structures.h" |
| 5 | +#include "Defines.h" |
| 6 | + |
| 7 | +#include "CetoneUI.hpp" // For class CCetoneUI |
| 8 | + |
| 9 | +void ImGuiUI::onImGuiDisplay() |
| 10 | +{ |
| 11 | + double scaleFactor = getScaleFactor() * userScaling; |
| 12 | + const double initialSize = 800 * scaleFactor; |
| 13 | + |
| 14 | + // |
| 15 | + // "About" Window |
| 16 | + // |
| 17 | + { |
| 18 | + ImGui::SetNextWindowPos(ImVec2(initialSize / 4, initialSize / 16), ImGuiCond_Once); |
| 19 | + ImGui::SetNextWindowSize(ImVec2(600, 230), ImGuiCond_Once); |
| 20 | + |
| 21 | + if (isAboutWindowOpen) |
| 22 | + { |
| 23 | + ImGui::Begin("About " DISTRHO_PLUGIN_NAME, &isAboutWindowOpen, ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize); |
| 24 | + { |
| 25 | + ImGui::SeparatorText("Cetone Synth Light"); |
| 26 | + ImGui::Text("Light-weight monophonic analogue-style synthesizer, by Neotec Software.\n"); |
| 27 | + |
| 28 | + ImGui::SeparatorText("Authors"); |
| 29 | + ImGui::BulletText("René 'Neotec' Jeschke - Original developer"); |
| 30 | + ImGui::BulletText( "AnClark Liu <[email protected]> - Ported to DPF, Further developments"); |
| 31 | + |
| 32 | + ImGui::SeparatorText("License"); |
| 33 | + ImGui::BulletText("This project is licensed under GNU General Public License, version 3."); |
| 34 | + |
| 35 | + ImGui::Text("\n\n"); |
| 36 | + ImGui::Dummy(ImVec2(490, 0)); |
| 37 | + ImGui::SameLine(); |
| 38 | + if (ImGui::Button("OK", ImVec2(80, 0))) |
| 39 | + isAboutWindowOpen = false; |
| 40 | + } |
| 41 | + ImGui::End(); |
| 42 | + } |
| 43 | + } |
| 44 | + |
| 45 | + // |
| 46 | + // Handle menu opening requests |
| 47 | + // |
| 48 | + // Here, variable `requestTestMenuOpen` acts as an "event flag" to request ImGui to show the menu. |
| 49 | + // |
| 50 | + // Dear ImGui has its own mechanism to show popup menus, which does not require a flag to control its exisitance. |
| 51 | + // This is quite different from window (ImGui::Begin()). |
| 52 | + // So just call this function once, your popup will stick on the screen unless you do some operations. |
| 53 | + // |
| 54 | + switch (requestMenuId) |
| 55 | + { |
| 56 | + case pOsc1Wave: |
| 57 | + ImGui::OpenPopup("menu_osc1_wave"); |
| 58 | + requestMenuId = 0; |
| 59 | + break; |
| 60 | + case pOsc2Wave: |
| 61 | + ImGui::OpenPopup("menu_osc2_wave"); |
| 62 | + requestMenuId = 0; |
| 63 | + break; |
| 64 | + case pOsc3Wave: |
| 65 | + ImGui::OpenPopup("menu_osc3_wave"); |
| 66 | + requestMenuId = 0; |
| 67 | + break; |
| 68 | + case pFilterType: |
| 69 | + ImGui::OpenPopup("menu_filter_type"); |
| 70 | + requestMenuId = 0; |
| 71 | + break; |
| 72 | + |
| 73 | + default: |
| 74 | + requestMenuId = 0; |
| 75 | + } |
| 76 | + |
| 77 | + // |
| 78 | + // Create popup menus |
| 79 | + // [NOTICE] ImGui::BeginPopup() MUST be put after ImGui::OpenPopup(), otherwise popup won't show! |
| 80 | + // |
| 81 | + |
| 82 | + ImGui::SetNextWindowPos(menuPos); // Specify menu position |
| 83 | + |
| 84 | + if (ImGui::BeginPopup("menu_osc1_wave")) |
| 85 | + { |
| 86 | + ImGui::SeparatorText("OSC1 Waveform"); |
| 87 | + if (ImGui::MenuItem("Saw")) { _triggerParamUpdate(pOsc1Wave, ui->_pi2f(OWAVE_SAW, OWAVE_MAX)); } |
| 88 | + if (ImGui::MenuItem("Pulse")) { _triggerParamUpdate(pOsc1Wave, ui->_pi2f(OWAVE_PULSE, OWAVE_MAX)); } |
| 89 | + if (ImGui::MenuItem("Triangle")) { _triggerParamUpdate(pOsc1Wave, ui->_pi2f(OWAVE_TRI, OWAVE_MAX)); } |
| 90 | + if (ImGui::MenuItem("Sine")) { _triggerParamUpdate(pOsc1Wave, ui->_pi2f(OWAVE_SINE, OWAVE_MAX)); } |
| 91 | + if (ImGui::MenuItem("C64 Noise")) { _triggerParamUpdate(pOsc1Wave, ui->_pi2f(OWAVE_C64NOISE, OWAVE_MAX)); } |
| 92 | + ImGui::EndPopup(); |
| 93 | + } |
| 94 | + |
| 95 | + ImGui::SetNextWindowPos(menuPos); // Specify menu position |
| 96 | + |
| 97 | + if (ImGui::BeginPopup("menu_osc2_wave")) |
| 98 | + { |
| 99 | + ImGui::SeparatorText("OSC2 Waveform"); |
| 100 | + if (ImGui::MenuItem("Saw")) { _triggerParamUpdate(pOsc2Wave, ui->_pi2f(OWAVE_SAW, OWAVE_MAX)); } |
| 101 | + if (ImGui::MenuItem("Pulse")) { _triggerParamUpdate(pOsc2Wave, ui->_pi2f(OWAVE_PULSE, OWAVE_MAX)); } |
| 102 | + if (ImGui::MenuItem("Triangle")) { _triggerParamUpdate(pOsc2Wave, ui->_pi2f(OWAVE_TRI, OWAVE_MAX)); } |
| 103 | + if (ImGui::MenuItem("Sine")) { _triggerParamUpdate(pOsc2Wave, ui->_pi2f(OWAVE_SINE, OWAVE_MAX)); } |
| 104 | + if (ImGui::MenuItem("C64 Noise")) { _triggerParamUpdate(pOsc2Wave, ui->_pi2f(OWAVE_C64NOISE, OWAVE_MAX)); } |
| 105 | + ImGui::EndPopup(); |
| 106 | + } |
| 107 | + |
| 108 | + ImGui::SetNextWindowPos(menuPos); // Specify menu position |
| 109 | + |
| 110 | + if (ImGui::BeginPopup("menu_osc3_wave")) |
| 111 | + { |
| 112 | + ImGui::SeparatorText("OSC3 Waveform"); |
| 113 | + if (ImGui::MenuItem("Saw")) { _triggerParamUpdate(pOsc3Wave, ui->_pi2f(OWAVE_SAW, OWAVE_MAX)); } |
| 114 | + if (ImGui::MenuItem("Pulse")) { _triggerParamUpdate(pOsc3Wave, ui->_pi2f(OWAVE_PULSE, OWAVE_MAX)); } |
| 115 | + if (ImGui::MenuItem("Triangle")) { _triggerParamUpdate(pOsc3Wave, ui->_pi2f(OWAVE_TRI, OWAVE_MAX)); } |
| 116 | + if (ImGui::MenuItem("Sine")) { _triggerParamUpdate(pOsc3Wave, ui->_pi2f(OWAVE_SINE, OWAVE_MAX)); } |
| 117 | + if (ImGui::MenuItem("C64 Noise")) { _triggerParamUpdate(pOsc3Wave, ui->_pi2f(OWAVE_C64NOISE, OWAVE_MAX)); } |
| 118 | + ImGui::EndPopup(); |
| 119 | + } |
| 120 | + |
| 121 | + ImGui::SetNextWindowPos(menuPos); // Specify menu position |
| 122 | + |
| 123 | + if (ImGui::BeginPopup("menu_filter_type")) |
| 124 | + { |
| 125 | + ImGui::SeparatorText("Filter Type"); |
| 126 | + if (ImGui::MenuItem("None")) { _triggerParamUpdate(pFilterType, ui->_pi2f(FTYPE_NONE, FTYPE_MAX)); } |
| 127 | + if (ImGui::MenuItem("Dirty")) { _triggerParamUpdate(pFilterType, ui->_pi2f(FTYPE_DIRTY, FTYPE_MAX)); } |
| 128 | + if (ImGui::MenuItem("Moog")) { _triggerParamUpdate(pFilterType, ui->_pi2f(FTYPE_MOOG, FTYPE_MAX)); } |
| 129 | + if (ImGui::MenuItem("Moog 2")) { _triggerParamUpdate(pFilterType, ui->_pi2f(FTYPE_MOOG2, FTYPE_MAX)); } |
| 130 | + if (ImGui::MenuItem("Ch12db")) { _triggerParamUpdate(pFilterType, ui->_pi2f(FTYPE_CH12DB, FTYPE_MAX)); } |
| 131 | + if (ImGui::MenuItem("x0x (303)")) { _triggerParamUpdate(pFilterType, ui->_pi2f(FTYPE_303, FTYPE_MAX)); } |
| 132 | + if (ImGui::MenuItem("8580")) { _triggerParamUpdate(pFilterType, ui->_pi2f(FTYPE_8580, FTYPE_MAX)); } |
| 133 | + if (ImGui::MenuItem("Bi12db (Budda)")) { _triggerParamUpdate(pFilterType, ui->_pi2f(FTYPE_BUDDA, FTYPE_MAX)); } |
| 134 | + ImGui::EndPopup(); |
| 135 | + } |
| 136 | +} |
| 137 | + |
| 138 | +void ImGuiUI::_triggerParamUpdate(uint32_t paramId, float newValue) |
| 139 | +{ |
| 140 | + ui->setParameterValue(paramId, newValue); // Tell the DSP to update parameter value |
| 141 | + ui->parameterChanged(paramId, newValue); // Request UI refresh |
| 142 | +} |
0 commit comments