commit d3bd0ec61b6ab2d6308ec3ea737f0ddb2381e064
parent 7c5a6db2c3a44d568b1c8805273a24bdd4fd6d4f
Author: falkTX <falktx@falktx.com>
Date: Fri, 3 Sep 2021 10:59:47 +0100
Add UI::sizeChanged as needed for external UIs
Signed-off-by: falkTX <falktx@falktx.com>
Diffstat:
2 files changed, 21 insertions(+), 3 deletions(-)
diff --git a/distrho/DistrhoUI.hpp b/distrho/DistrhoUI.hpp
@@ -303,17 +303,26 @@ protected:
*/
virtual void uiFileBrowserSelected(const char* filename);
# endif
+#endif // !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
/* --------------------------------------------------------------------------------------------------------
* UI Resize Handling, internal */
+#if DISTRHO_PLUGIN_HAS_EXTERNAL_UI
+ /**
+ External Window resize function, called when the window is resized.
+ This is overriden here so the host knows when the UI is resized by you.
+ @see ExternalWindow::sizeChanged(uint,uint)
+ */
+ void sizeChanged(uint width, uint height) override;
+#else
/**
- OpenGL widget resize function, called when the widget is resized.
+ Widget resize function, called when the widget is resized.
This is overriden here so the host knows when the UI is resized by you.
@see Widget::onResize(const ResizeEvent&)
*/
void onResize(const ResizeEvent& ev) override;
-#endif // !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
+#endif
// -------------------------------------------------------------------------------------------------------
diff --git a/distrho/src/DistrhoUI.cpp b/distrho/src/DistrhoUI.cpp
@@ -209,10 +209,19 @@ void UI::uiFileBrowserSelected(const char*)
{
}
# endif
+#endif // !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
/* ------------------------------------------------------------------------------------------------------------
* UI Resize Handling, internal */
+#if DISTRHO_PLUGIN_HAS_EXTERNAL_UI
+void UI::sizeChanged(const uint width, const uint height)
+{
+ UIWidget::sizeChanged(width, height);
+
+ uiData->setSizeCallback(width, height);
+}
+#else
void UI::onResize(const ResizeEvent& ev)
{
UIWidget::onResize(ev);
@@ -221,7 +230,7 @@ void UI::onResize(const ResizeEvent& ev)
const uint height = ev.size.getHeight();
uiData->setSizeCallback(width, height);
}
-#endif // !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
+#endif
// -----------------------------------------------------------------------------------------------------------