From 03a537e4b93898e3d7e7ffa343cfb7ee324cfe12 Mon Sep 17 00:00:00 2001 From: falkTX Date: Mon, 24 Jul 2023 11:29:46 +0200 Subject: [PATCH] Auto-scale carla-vst plugin GUI Signed-off-by: falkTX --- source/plugin/carla-vst.cpp | 7 ++++--- source/plugin/carla-vst.hpp | 7 ++++++- source/plugin/ui_launcher.cpp | 14 +++++++++++++- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/source/plugin/carla-vst.cpp b/source/plugin/carla-vst.cpp index 789711b8c..2cb278ba4 100644 --- a/source/plugin/carla-vst.cpp +++ b/source/plugin/carla-vst.cpp @@ -1,6 +1,6 @@ /* * Carla Native Plugins - * Copyright (C) 2013-2022 Filipe Coelho + * Copyright (C) 2013-2023 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -398,7 +398,7 @@ public: break; case effEditGetRect: - *(ERect**)ptr = &fVstRect; + *(VstRect**)ptr = &fVstRect; ret = 1; break; @@ -409,6 +409,7 @@ public: { destoryUILauncher(fUiLauncher); fUiLauncher = createUILauncher((uintptr_t)ptr, fDescriptor, fHandle); + getUILauncherSize(fUiLauncher, &fVstRect); } else { @@ -833,7 +834,7 @@ private: NativeMidiEvent fMidiEvents[kMaxMidiEvents]; char fProgramName[32+1]; NativeTimeInfo fTimeInfo; - ERect fVstRect; + VstRect fVstRect; // UI button CarlaUILauncher* fUiLauncher; diff --git a/source/plugin/carla-vst.hpp b/source/plugin/carla-vst.hpp index 7c5372bca..9d3da55cb 100644 --- a/source/plugin/carla-vst.hpp +++ b/source/plugin/carla-vst.hpp @@ -1,6 +1,6 @@ /* * Carla Native Plugins - * Copyright (C) 2013-2022 Filipe Coelho + * Copyright (C) 2013-2023 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -32,7 +32,12 @@ struct VstObject { NativePlugin* plugin; }; +struct VstRect { + int16_t top, left, bottom, right; +}; + CarlaUILauncher* createUILauncher(uintptr_t winId, const NativePluginDescriptor* d, NativePluginHandle h); +void getUILauncherSize(CarlaUILauncher* ui, VstRect* rect); void idleUILauncher(CarlaUILauncher* ui); void destoryUILauncher(CarlaUILauncher* ui); diff --git a/source/plugin/ui_launcher.cpp b/source/plugin/ui_launcher.cpp index 41ae64a8b..744526ce2 100644 --- a/source/plugin/ui_launcher.cpp +++ b/source/plugin/ui_launcher.cpp @@ -1,6 +1,6 @@ /* * Carla Native Plugin UI launcher - * Copyright (C) 2018-2022 Filipe Coelho + * Copyright (C) 2018-2023 Filipe Coelho * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -90,6 +90,12 @@ public: handle(h), pluginWindow(parent) { + const uint width = ui_launcher_res::carla_uiWidth; + const uint height = ui_launcher_res::carla_uiHeight; + + Widget::setSize(width, height); + setGeometryConstraints(width, height, true, true, true); + startButton.setCallback(this); pluginWindow.leaveContextAfterCreation(); @@ -148,6 +154,12 @@ CarlaUILauncher* createUILauncher(const uintptr_t winId, return new CarlaUILauncher(winId, d, h); } +void getUILauncherSize(CarlaUILauncher* const ui, VstRect* const rect) +{ + rect->right = ui->window.getWidth(); + rect->bottom = ui->window.getHeight(); +} + void idleUILauncher(CarlaUILauncher* const ui) { ui->app.idle();