Skip to content

Commit e72ea90

Browse files
committed
trial with window resizing
1 parent 354fde1 commit e72ea90

1 file changed

Lines changed: 48 additions & 13 deletions

File tree

override/HeavyDPF_WSTD_EQ_UI.cpp

Lines changed: 48 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
#include "ResizeHandle.hpp"
1010
#include "veramobd.hpp"
1111
#include "wstdcolors.hpp"
12+
#include "DearImGui/imgui_impl_opengl2.h"
1213

1314

1415
START_NAMESPACE_DISTRHO
@@ -22,7 +23,9 @@ class ImGuiPluginUI : public UI
2223
float flow = 0.0f;
2324
float fmid = 0.0f;
2425

25-
ResizeHandle fResizeHandle;
26+
int isize = 1;
27+
28+
bool sizeChanged = false;
2629

2730
// ----------------------------------------------------------------------------------------------------------------
2831

@@ -32,11 +35,8 @@ class ImGuiPluginUI : public UI
3235
The UI should be initialized to a default state that matches the plugin side.
3336
*/
3437
ImGuiPluginUI()
35-
: UI(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT, true),
36-
fResizeHandle(this)
38+
: UI(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT)
3739
{
38-
setGeometryConstraints(DISTRHO_UI_DEFAULT_WIDTH, DISTRHO_UI_DEFAULT_HEIGHT, true);
39-
4040
ImGuiIO& io(ImGui::GetIO());
4141

4242
ImFontConfig fc;
@@ -45,12 +45,38 @@ class ImGuiPluginUI : public UI
4545
fc.OversampleV = 1;
4646
fc.PixelSnapH = true;
4747

48-
io.Fonts->AddFontFromMemoryCompressedTTF((void*)veramobd_compressed_data, veramobd_compressed_size, 16.0f * getScaleFactor(), &fc);
49-
io.Fonts->AddFontFromMemoryCompressedTTF((void*)veramobd_compressed_data, veramobd_compressed_size, 21.0f * getScaleFactor(), &fc);
48+
io.Fonts->AddFontFromMemoryCompressedTTF((void*)veramobd_compressed_data, veramobd_compressed_size, 16.0f * getScaleFactor() * isize, &fc);
49+
io.Fonts->AddFontFromMemoryCompressedTTF((void*)veramobd_compressed_data, veramobd_compressed_size, 21.0f * getScaleFactor() * isize, &fc);
5050
io.Fonts->Build();
5151
io.FontDefault = io.Fonts->Fonts[1];
52+
}
5253

53-
fResizeHandle.hide();
54+
void uiIdle() override
55+
{
56+
if (sizeChanged) {
57+
ImGuiIO& io(ImGui::GetIO());
58+
59+
io.Fonts->Clear();
60+
61+
ImFontConfig fc;
62+
fc.FontDataOwnedByAtlas = true;
63+
fc.OversampleH = 1;
64+
fc.OversampleV = 1;
65+
fc.PixelSnapH = true;
66+
67+
io.Fonts->AddFontFromMemoryCompressedTTF((void*)veramobd_compressed_data, veramobd_compressed_size, 16.0f * getScaleFactor() * isize, &fc);
68+
io.Fonts->AddFontFromMemoryCompressedTTF((void*)veramobd_compressed_data, veramobd_compressed_size, 21.0f * getScaleFactor() * isize, &fc);
69+
io.Fonts->Build();
70+
io.FontDefault = io.Fonts->Fonts[1];
71+
72+
#if defined(DGL_USE_GLES2) || defined(DGL_USE_GLES3) || defined(DGL_USE_OPENGL3)
73+
ImGui_ImplOpenGL3_CreateFontsTexture();
74+
#else
75+
ImGui_ImplOpenGL2_CreateFontsTexture();
76+
#endif
77+
78+
sizeChanged = false;
79+
}
5480
}
5581

5682
protected:
@@ -95,7 +121,7 @@ class ImGuiPluginUI : public UI
95121
*/
96122
void onImGuiDisplay() override
97123
{
98-
124+
const float scaleFactor = isize * getScaleFactor();
99125
const float width = getWidth();
100126
const float height = getHeight();
101127
const float margin = 0.0f;
@@ -125,8 +151,8 @@ class ImGuiPluginUI : public UI
125151
auto LowColorActive = ColorBright(Red, flow);
126152
auto LowColorHovered = ColorBright(RedBr, flow);
127153

128-
const float hundred = 100 * getScaleFactor();
129-
const float seventy = 70 * getScaleFactor();
154+
const float hundred = 100 * scaleFactor;
155+
const float seventy = 70 * scaleFactor;
130156

131157
auto dbstep = 0.1f;
132158
auto hzstep = 20.0f;
@@ -140,7 +166,7 @@ class ImGuiPluginUI : public UI
140166
ImGui::PushFont(titleBarFont);
141167
if (ImGui::Begin("WSTD EQ", nullptr, ImGuiWindowFlags_NoResize + ImGuiWindowFlags_NoCollapse))
142168
{
143-
ImGui::Dummy(ImVec2(0.0f, 8.0f * getScaleFactor()));
169+
ImGui::Dummy(ImVec2(0.0f, 8.0f * scaleFactor));
144170
ImGui::PushFont(defaultFont);
145171

146172
#ifdef DISTRHO_OS_WASM
@@ -165,6 +191,15 @@ class ImGuiPluginUI : public UI
165191
auto ImGuiKnob_FlagsDB = ImGuiKnob_Flags + ImGuiKnobFlags_dB;
166192
auto ImGuiKnob_FlagsLog = ImGuiKnob_Flags + ImGuiKnobFlags_Logarithmic;
167193

194+
if (ImGui::SliderInt("Size", &isize, 1, 2))
195+
{
196+
if (ImGui::IsItemActivated())
197+
{
198+
sizeChanged = true;
199+
setSize(isize * getWidth(), isize * getHeight());
200+
}
201+
}
202+
168203
ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)HighColorActive);
169204
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)HighColorHovered);
170205
if (ImGuiKnobs::Knob("High", &fhigh, -15.0f, 15.0, dbstep, "%.2fdB", ImGuiKnobVariant_SteppedTick, hundred, ImGuiKnob_FlagsDB, 7))
@@ -193,7 +228,7 @@ class ImGuiPluginUI : public UI
193228
}
194229
ImGui::PopStyleColor(2);
195230

196-
ImGui::Dummy(ImVec2(7.5f * getScaleFactor(), 0.0f)); ImGui::SameLine();
231+
ImGui::Dummy(ImVec2(7.5f * scaleFactor, 0.0f)); ImGui::SameLine();
197232
ImGui::PushStyleColor(ImGuiCol_ButtonActive, (ImVec4)MidFreqColorActive);
198233
ImGui::PushStyleColor(ImGuiCol_ButtonHovered, (ImVec4)MidFreqColorHovered);
199234
if (ImGuiKnobs::Knob("Mid Freq", &ffreq, 313.3f, 5705.6f, hzstep, "%.1fHz", ImGuiKnobVariant_SteppedTick, seventy, ImGuiKnob_FlagsLog, 11))

0 commit comments

Comments
 (0)