@@ -68,8 +68,6 @@ class IldaeilUI : public UI,
68
68
static constexpr const uint kGenericWidth = 380 ;
69
69
static constexpr const uint kGenericHeight = 400 ;
70
70
static constexpr const uint kButtonHeight = 20 ;
71
- static constexpr const uint kMinWidth = 120 ;
72
- static constexpr const uint kMinHeight = 120 ;
73
71
74
72
struct PluginInfoCache {
75
73
BinaryType btype;
@@ -188,7 +186,10 @@ class IldaeilUI : public UI,
188
186
char fPluginSearchString [0xff ];
189
187
190
188
String fPopupError , fPluginFilename , fDiscoveryTool ;
191
- Size<uint> fNextSize ;
189
+ Size<uint> fCurrentConstraintSize , fLastSize , fNextSize ;
190
+ bool fIgnoreNextHostWindowResize ;
191
+ bool fShowingHostWindow ;
192
+ bool fUpdateGeometryConstraints ;
192
193
193
194
struct RunnerData {
194
195
bool needsReinit;
@@ -233,6 +234,9 @@ class IldaeilUI : public UI,
233
234
fCurrentPluginInfo(),
234
235
fPluginSearchActive(false ),
235
236
fPluginSearchFirstShow(false ),
237
+ fIgnoreNextHostWindowResize(false ),
238
+ fShowingHostWindow(false ),
239
+ fUpdateGeometryConstraints(false ),
236
240
fRunnerData()
237
241
{
238
242
const double scaleFactor = getScaleFactor ();
@@ -256,13 +260,13 @@ class IldaeilUI : public UI,
256
260
257
261
if (d_isNotEqual (scaleFactor, 1.0 ))
258
262
{
259
- setGeometryConstraints (kMinWidth * scaleFactor, kMinHeight * scaleFactor);
263
+ setGeometryConstraints (kInitialWidth * scaleFactor, kInitialWidth * scaleFactor);
260
264
setSize (kInitialWidth * scaleFactor, kInitialHeight * scaleFactor);
261
265
fPluginHostWindow .setOffset (0 , kButtonHeight * scaleFactor + paddingY);
262
266
}
263
267
else
264
268
{
265
- setGeometryConstraints (kMinWidth , kMinHeight );
269
+ setGeometryConstraints (kInitialWidth , kInitialWidth );
266
270
fPluginHostWindow .setOffset (0 , kButtonHeight + paddingY);
267
271
}
268
272
@@ -405,6 +409,9 @@ class IldaeilUI : public UI,
405
409
fPluginHasEmbedUI = true ;
406
410
fPluginHasFileOpen = false ;
407
411
412
+ fIgnoreNextHostWindowResize = false ;
413
+ fShowingHostWindow = true ;
414
+
408
415
carla_embed_custom_ui (handle, fPluginId , fPluginHostWindow .attachAndGetWindowHandle ());
409
416
}
410
417
else
@@ -448,6 +455,8 @@ class IldaeilUI : public UI,
448
455
const double scaleFactor = getScaleFactor ();
449
456
fNextSize = Size<uint>(kGenericWidth * scaleFactor,
450
457
(kGenericHeight + ImGui::GetStyle ().WindowPadding .y ) * scaleFactor);
458
+ fLastSize = Size<uint>();
459
+ fUpdateGeometryConstraints = true ;
451
460
#endif
452
461
}
453
462
@@ -659,10 +668,48 @@ class IldaeilUI : public UI,
659
668
protected:
660
669
void pluginWindowResized (const uint width, const uint height) override
661
670
{
671
+ if (fIgnoreNextHostWindowResize )
672
+ {
673
+ fIgnoreNextHostWindowResize = false ;
674
+ return ;
675
+ }
676
+
677
+ if (fShowingHostWindow )
678
+ {
679
+ fShowingHostWindow = false ;
680
+ fIgnoreNextHostWindowResize = true ;
681
+ fUpdateGeometryConstraints = true ;
682
+ }
683
+
662
684
const uint extraHeight = kButtonHeight * getScaleFactor () + ImGui::GetStyle ().WindowPadding .y * 2 ;
663
685
664
686
fNextSize = Size<uint>(width, height + extraHeight);
687
+
688
+ // reduce geometry constraint if needed
689
+ if (fIgnoreNextHostWindowResize )
690
+ return ;
691
+ if (width < fCurrentConstraintSize .getWidth () || height < fCurrentConstraintSize .getHeight ())
692
+ fUpdateGeometryConstraints = true ;
693
+ }
694
+
695
+ #if ILDAEIL_STANDALONE
696
+ void onResize (const ResizeEvent& ev) override
697
+ {
698
+ UI::onResize (ev);
699
+
700
+ if (fIgnoreNextHostWindowResize )
701
+ return ;
702
+ if (fShowingHostWindow )
703
+ return ;
704
+
705
+ if (fDrawingState == kDrawingPluginEmbedUI )
706
+ {
707
+ const uint extraHeight = kButtonHeight * getScaleFactor () + ImGui::GetStyle ().WindowPadding .y * 2 ;
708
+
709
+ fPluginHostWindow .setSize (ev.size .getWidth (), ev.size .getHeight () - extraHeight);
710
+ }
665
711
}
712
+ #endif
666
713
667
714
void uiIdle () override
668
715
{
@@ -675,10 +722,18 @@ class IldaeilUI : public UI,
675
722
repaint ();
676
723
}
677
724
678
- if (fNextSize .isValid ())
725
+ if (fNextSize .isValid () && fLastSize != fNextSize )
679
726
{
727
+ fLastSize = fNextSize ;
728
+
729
+ if (fUpdateGeometryConstraints )
730
+ {
731
+ fUpdateGeometryConstraints = false ;
732
+ fCurrentConstraintSize = fNextSize ;
733
+ setGeometryConstraints (fNextSize .getWidth (), fNextSize .getHeight ());
734
+ }
735
+
680
736
setSize (fNextSize );
681
- fNextSize = Size<uint>();
682
737
}
683
738
684
739
switch (fIdleState )
@@ -1235,6 +1290,8 @@ class IldaeilUI : public UI,
1235
1290
fDrawingState = kDrawingPluginList ;
1236
1291
#ifndef DISTRHO_OS_WASM
1237
1292
fNextSize = Size<uint>(kInitialWidth * scaleFactor, kInitialHeight * scaleFactor);
1293
+ fLastSize = Size<uint>();
1294
+ fUpdateGeometryConstraints = true ;
1238
1295
#endif
1239
1296
}
1240
1297
0 commit comments