1
1
#include < CLI/ArgumentParser.h>
2
- #include < MS/Plugin .h>
2
+ #include < MS/VstPlugin .h>
3
3
#include < Ty/Defer.h>
4
4
#include < Ty/ErrorOr.h>
5
5
#include < UI/Application.h>
9
9
#include < Main/Main.h>
10
10
11
11
#include < stdio.h>
12
+ #include < libgen.h>
12
13
13
14
namespace Main {
14
15
@@ -31,7 +32,7 @@ ErrorOr<int> main(int argc, char const* argv[])
31
32
plugin.destroy ();
32
33
};
33
34
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)) );
35
36
auto plugin_author = plugin.author ().or_else (" <none>" sv);
36
37
37
38
auto plugin_product_version = plugin.product_version ();
@@ -59,15 +60,33 @@ ErrorOr<int> main(int argc, char const* argv[])
59
60
printf (" Silent stopped: %s\n " , plugin.is_silent_when_stopped () ? " yes" : " no" );
60
61
printf (" ----------------------------------\n\n " );
61
62
63
+ auto plugin_name_c_string = TRY (StringBuffer::create_fill (plugin_name, " \0 " sv));
64
+
62
65
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)) {
66
83
return Error::from_string_literal (" could not open editor" );
67
84
}
68
- app.add_child_window (window);
69
85
70
- app.run ();
86
+ while (!ui_window_should_close (window)) {
87
+ ui_application_poll_events (app);
88
+ }
89
+
71
90
return 0 ;
72
91
}
73
92
0 commit comments