Skip to content

Commit 06e8a92

Browse files
committed
Merge branch 'workspace/imgui-impl' into develop
2 parents 344d84f + e5665f1 commit 06e8a92

File tree

5 files changed

+454
-11
lines changed

5 files changed

+454
-11
lines changed

CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ add_subdirectory (dpf)
1212

1313
include_directories (
1414
src/
15+
dpf-widgets/opengl/
1516
)
1617

1718
set (SRC_BACKEND
@@ -42,5 +43,7 @@ dpf_add_plugin (${PROJECT_NAME}
4243
src/CetoneUIHelper.cpp
4344
src/Images/CetoneArtwork.cpp
4445
src/Fonts/CetoneFonts.cpp
46+
dpf-widgets/opengl/DearImGui.cpp
47+
src/Widgets/ImGui_UI.cpp
4548
)
4649

src/CetoneUI.cpp

Lines changed: 102 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,34 @@ CCetoneUI::CCetoneUI()
107107
_createSwitchButton(fBtnGlideState, pPortaMode, 764, 150);
108108

109109
_createSwitchButton(fBtnLFOTrigger, pLfo1Trig, 677, 260);
110+
111+
/* ImGui instance (popup menus, subwindows, etc.) */
112+
fImGuiInstance = new ImGuiUI(getTopLevelWidget(), this);
113+
114+
/* "About" button (by clicking the plugin logo) */
115+
_createHiddenButton(fBtnAbout, BTN_ABOUT, Size<uint>(118, 25), Point<int>(0, 0));
116+
117+
/* Popup menu button on params which has constant value sets */
118+
_createHiddenButton(fBtnOsc1Waveform, pOsc1Wave, Size<uint>(45, 10 + 2), Point<int>(10 + 48 * 2, 200 + 2));
119+
_createHiddenButton(fBtnOsc2Waveform, pOsc2Wave, Size<uint>(45, 10 + 2), Point<int>(262 + 48 * 2, 200 + 2));
120+
_createHiddenButton(fBtnOsc3Waveform, pOsc3Wave, Size<uint>(45, 10 + 2), Point<int>(514 + 48 * 2, 200 + 2));
121+
122+
_createHiddenButton(fBtnFilterType, pFilterType, Size<uint>(45, 10 + 2), Point<int>(514, 96 - 4));
123+
_createHiddenButton(fBtnFilterMode, pFilterMode, Size<uint>(45, 10 + 2), Point<int>(514 + 48, 96 - 4));
124+
125+
_createHiddenButton(fBtnLfo1Waveform, pLfo1Wave, Size<uint>(45, 10 + 2), Point<int>(534 + 48, 316 - 4));
126+
127+
_createHiddenButton(fBtnArpMode, pArpMode, Size<uint>(45, 10 + 2), Point<int>(767, 316 - 4 - 2));
128+
129+
_createHiddenButton(fBtnMod1Src, pMod1Src, Size<uint>(45, 10 + 2), Point<int>(10, 426 - 4 - 2));
130+
_createHiddenButton(fBtnMod2Src, pMod2Src, Size<uint>(45, 10 + 2), Point<int>(230, 426 - 4 - 2));
131+
_createHiddenButton(fBtnMod3Src, pMod3Src, Size<uint>(45, 10 + 2), Point<int>(450, 426 - 4 - 2));
132+
_createHiddenButton(fBtnMod4Src, pMod4Src, Size<uint>(45, 10 + 2), Point<int>(670, 426 - 4 - 2));
133+
134+
_createHiddenButton(fBtnMod1Dest, pMod1Dest, Size<uint>(45, 10 + 2), Point<int>(10 + 48, 426 - 4 - 2));
135+
_createHiddenButton(fBtnMod2Dest, pMod2Dest, Size<uint>(45, 10 + 2), Point<int>(230 + 48, 426 - 4 - 2));
136+
_createHiddenButton(fBtnMod3Dest, pMod3Dest, Size<uint>(45, 10 + 2), Point<int>(450 + 48, 426 - 4 - 2));
137+
_createHiddenButton(fBtnMod4Dest, pMod4Dest, Size<uint>(45, 10 + 2), Point<int>(670 + 48, 426 - 4 - 2));
110138
}
111139

112140
void CCetoneUI::parameterChanged(uint32_t index, float value)
@@ -349,14 +377,66 @@ void CCetoneUI::parameterChanged(uint32_t index, float value)
349377

350378
void CCetoneUI::imageButtonClicked(ImageButton* button, int)
351379
{
352-
#if 0
353-
switch (button->getId()) {
354-
case BTN_PANIC: {
355-
panic();
356-
break;
357-
}
380+
DISTRHO_SAFE_ASSERT_RETURN(fImGuiInstance, )
381+
382+
switch (button->getId())
383+
{
384+
case BTN_ABOUT:
385+
{
386+
fImGuiInstance->isAboutWindowOpen = !fImGuiInstance->isAboutWindowOpen;
387+
break;
388+
}
389+
case pOsc1Wave:
390+
{
391+
fImGuiInstance->menuPos = ImVec2(fBtnOsc1Waveform->getAbsolutePos().getX(), fBtnOsc1Waveform->getAbsolutePos().getY() + fBtnOsc1Waveform->getHeight());
392+
fImGuiInstance->requestMenuId = pOsc1Wave;
393+
break;
394+
}
395+
case pOsc2Wave:
396+
{
397+
fImGuiInstance->menuPos = ImVec2(fBtnOsc2Waveform->getAbsolutePos().getX(), fBtnOsc2Waveform->getAbsolutePos().getY() + fBtnOsc2Waveform->getHeight());
398+
fImGuiInstance->requestMenuId = pOsc2Wave;
399+
break;
400+
}
401+
case pOsc3Wave:
402+
{
403+
fImGuiInstance->menuPos = ImVec2(fBtnOsc3Waveform->getAbsolutePos().getX(), fBtnOsc3Waveform->getAbsolutePos().getY() + fBtnOsc3Waveform->getHeight());
404+
fImGuiInstance->requestMenuId = pOsc3Wave;
405+
break;
406+
}
407+
case pFilterType:
408+
{
409+
fImGuiInstance->menuPos = ImVec2(fBtnFilterType->getAbsolutePos().getX(), fBtnFilterType->getAbsolutePos().getY() + fBtnFilterType->getHeight());
410+
fImGuiInstance->requestMenuId = pFilterType;
411+
break;
412+
}
413+
case pFilterMode:
414+
{
415+
fImGuiInstance->menuPos = ImVec2(fBtnFilterMode->getAbsolutePos().getX(), fBtnFilterMode->getAbsolutePos().getY() + fBtnFilterMode->getHeight());
416+
fImGuiInstance->requestMenuId = pFilterMode;
417+
break;
418+
}
419+
case pLfo1Wave:
420+
{
421+
fImGuiInstance->menuPos = ImVec2(fBtnLfo1Waveform->getAbsolutePos().getX(), fBtnLfo1Waveform->getAbsolutePos().getY() + fBtnLfo1Waveform->getHeight());
422+
fImGuiInstance->requestMenuId = pLfo1Wave;
423+
break;
424+
}
425+
// NOTICE: For those buttons below, no need to specify menu position. Let Dear ImGui decide menu's position.
426+
case pArpMode:
427+
case pMod1Src:
428+
case pMod2Src:
429+
case pMod3Src:
430+
case pMod4Src:
431+
case pMod1Dest:
432+
case pMod2Dest:
433+
case pMod3Dest:
434+
case pMod4Dest:
435+
{
436+
fImGuiInstance->requestMenuId = button->getId();
437+
break;
438+
}
358439
}
359-
#endif
360440
}
361441

362442
void CCetoneUI::imageSwitchClicked(ImageSwitch* button, bool down)
@@ -445,13 +525,24 @@ void CCetoneUI::onDisplay()
445525
fNanoText.textBox(514, 96, 45.0f, fLabelBuffer);
446526

447527
// Mode
448-
// FIXME: Some filter types does not support setting mode.
528+
// NOTE: Some filter types does not support setting mode.
449529
const auto _filterMode = _pf2i(fKnobFilterMode->getValue(), FMODE_MAX);
450-
std::snprintf(fLabelBuffer, 32, "%s", _filterMode2str(_filterMode));
530+
switch (_pf2i(fKnobFilterType->getValue(), FTYPE_MAX))
531+
{
532+
case FTYPE_DIRTY:
533+
case FTYPE_MOOG2:
534+
case FTYPE_CH12DB:
535+
case FTYPE_8580:
536+
std::snprintf(fLabelBuffer, 32, "%s", _filterMode2str(_filterMode));
537+
break;
538+
default:
539+
std::snprintf(fLabelBuffer, 32, "Low");
540+
break;
541+
}
451542
fNanoText.textBox(514 + 48, 96, 45.0f, fLabelBuffer);
452543

453544
// Cutoff
454-
std::snprintf(fLabelBuffer, 32, "%.1f", fKnobCutoff->getValue() * 100.0f);
545+
std::snprintf(fLabelBuffer, 32, "%.1f", fKnobCutoff->getValue() * 24000.0f); // Cutoff frequency range: 0.0 ~ 24000.0 Hz
455546
fNanoText.textBox(514 + 48 * 2, 96, 45.0f, fLabelBuffer);
456547

457548
// Resonance
@@ -571,7 +662,7 @@ void CCetoneUI::onDisplay()
571662

572663
/* LFO */
573664
// Speed
574-
std::snprintf(fLabelBuffer, 32, "%.2f", fLfoSpeed->getValue() * 100.0f);
665+
std::snprintf(fLabelBuffer, 32, "%.2f", fLfoSpeed->getValue() * 50.0f); // Speed range: 0.0 ~ 50.0 Hz
575666
fNanoText.textBox(534, 316, 45.0f, fLabelBuffer);
576667

577668
// Waveform

src/CetoneUI.hpp

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "ImageWidgets.hpp"
55
#include "NanoVG.hpp"
66

7+
#include "Widgets/ImGui_UI.hpp"
8+
79
using DGL_NAMESPACE::ImageAboutWindow;
810
using DGL_NAMESPACE::ImageButton;
911
using DGL_NAMESPACE::ImageKnob;
@@ -55,6 +57,12 @@ class CCetoneUI : public DISTRHO::UI,
5557
NanoVG fNanoText;
5658
char fLabelBuffer[32 + 1];
5759

60+
// -------------------------------------------------------------------
61+
// Dear ImGui Instance
62+
63+
ScopedPointer<ImGuiUI> fImGuiInstance;
64+
friend class ImGuiUI;
65+
5866
// -------------------------------------------------------------------
5967
// Image resources
6068

@@ -93,6 +101,19 @@ class CCetoneUI : public DISTRHO::UI,
93101
ScopedPointer<ImageSwitch> fBtnGlideState;
94102
ScopedPointer<ImageSwitch> fBtnLFOTrigger;
95103

104+
// -------------------------------------------------------------------
105+
// Buttons
106+
107+
ScopedPointer<ImageButton> fBtnAbout;
108+
109+
ScopedPointer<ImageButton> fBtnOsc1Waveform, fBtnOsc2Waveform, fBtnOsc3Waveform;
110+
ScopedPointer<ImageButton> fBtnFilterType, fBtnFilterMode;
111+
ScopedPointer<ImageButton> fBtnLfo1Waveform;
112+
ScopedPointer<ImageButton> fBtnArpMode;
113+
114+
ScopedPointer<ImageButton> fBtnMod1Src, fBtnMod2Src, fBtnMod3Src, fBtnMod4Src;
115+
ScopedPointer<ImageButton> fBtnMod1Dest, fBtnMod2Dest, fBtnMod3Dest, fBtnMod4Dest;
116+
96117
// -------------------------------------------------------------------
97118
// Helpers
98119

@@ -127,5 +148,6 @@ class CCetoneUI : public DISTRHO::UI,
127148
// Button IDs
128149

129150
constexpr uint BTN_PANIC = d_cconst('p', 'n', 'i', 'c');
151+
constexpr uint BTN_ABOUT = d_cconst('a', 'b', 't', '.');
130152

131153
// -----------------------------------------------------------------------

0 commit comments

Comments
 (0)