Skip to content

Commit f3f6096

Browse files
committed
vst-run-gui: Use new UI library
1 parent bd0d290 commit f3f6096

File tree

2 files changed

+38
-10
lines changed

2 files changed

+38
-10
lines changed

Tools/build.def

+12-3
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,30 @@ auto const list_devices = target([] {
6666
});
6767
});
6868

69-
#if 0
7069
auto const vst_run_gui = target([] {
7170
return cpp_binary("vst-run-gui", {
7271
.srcs = {
7372
"./vst-run-gui.cpp",
7473
},
7574
.compile_flags = {},
76-
.linker_flags = {},
75+
.linker_flags = {
76+
#ifdef __APPLE__
77+
"-F/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk/System/Library/Frameworks",
78+
"-framework", "AppKit",
79+
"-framework", "OpenGL",
80+
"-framework", "CoreFoundation",
81+
"-framework", "CoreAudio",
82+
"-framework", "AudioUnit",
83+
#endif
84+
},
7785
.target_triple = system_target_triple(),
7886
.deps = {
7987
libraries.main,
88+
libraries.ms,
8089
libraries.soundio,
8190
libraries.ty,
8291
libraries.cli,
92+
libraries.ui
8393
}
8494
});
8595
});
86-
#endif

Tools/vst-run-gui.cpp

+26-7
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#include <CLI/ArgumentParser.h>
2-
#include <MS/Plugin.h>
2+
#include <MS/VstPlugin.h>
33
#include <Ty/Defer.h>
44
#include <Ty/ErrorOr.h>
55
#include <UI/Application.h>
@@ -9,6 +9,7 @@
99
#include <Main/Main.h>
1010

1111
#include <stdio.h>
12+
#include <libgen.h>
1213

1314
namespace Main {
1415

@@ -31,7 +32,7 @@ ErrorOr<int> main(int argc, char const* argv[])
3132
plugin.destroy();
3233
};
3334

34-
auto plugin_name = plugin.name().or_else("<none>"sv);
35+
auto plugin_name = plugin.name().or_else(StringView::from_c_string(basename((char*)plugin_path)));
3536
auto plugin_author = plugin.author().or_else("<none>"sv);
3637

3738
auto plugin_product_version = plugin.product_version();
@@ -59,15 +60,33 @@ ErrorOr<int> main(int argc, char const* argv[])
5960
printf(" Silent stopped: %s\n", plugin.is_silent_when_stopped() ? "yes" : "no");
6061
printf("----------------------------------\n\n");
6162

63+
auto plugin_name_c_string = TRY(StringBuffer::create_fill(plugin_name, "\0"sv));
64+
6265
auto rect = plugin.editor_rectangle().or_else(Vst::Rectangle{ 0, 0, 800, 600 });
63-
auto app = TRY(UI::Application::create(plugin_name, rect.x, rect.y, rect.width, rect.height));
64-
auto window = TRY(UI::Window::create(plugin_name, rect.x, rect.y, rect.width, rect.height));
65-
if (!plugin.open_editor(window->native_handle())) {
66+
67+
auto* app = ui_application_create(UIApplicationHint_NativeLike);
68+
Defer destroy_app = [&] {
69+
ui_application_destroy(app);
70+
};
71+
72+
auto* window = ui_window_create(app, {
73+
.parent = nullptr,
74+
.title = plugin_name_c_string.data(),
75+
.x = rect.x,
76+
.y = rect.y,
77+
.width = rect.width,
78+
.height = rect.height,
79+
});
80+
81+
void* window_handle = ui_window_native_handle(window);
82+
if (!plugin.open_editor(window_handle)) {
6683
return Error::from_string_literal("could not open editor");
6784
}
68-
app.add_child_window(window);
6985

70-
app.run();
86+
while (!ui_window_should_close(window)) {
87+
ui_application_poll_events(app);
88+
}
89+
7190
return 0;
7291
}
7392

0 commit comments

Comments
 (0)