annotate DPF-Prymula-audioplugins/dpf/distrho/src/DistrhoUIPrivateData.hpp @ 3:84e66ea83026

DPF-Prymula-audioplugins-0.231015-2
author prymula <prymula76@outlook.com>
date Mon, 16 Oct 2023 21:53:34 +0200
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
1 /*
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
2 * DISTRHO Plugin Framework (DPF)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
3 * Copyright (C) 2012-2022 Filipe Coelho <falktx@falktx.com>
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
4 *
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
5 * Permission to use, copy, modify, and/or distribute this software for any purpose with
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
6 * or without fee is hereby granted, provided that the above copyright notice and this
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
7 * permission notice appear in all copies.
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
8 *
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
9 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
10 * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
11 * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
12 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
13 * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
14 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
15 */
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
16
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
17 #ifndef DISTRHO_UI_PRIVATE_DATA_HPP_INCLUDED
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
18 #define DISTRHO_UI_PRIVATE_DATA_HPP_INCLUDED
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
19
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
20 #include "../DistrhoUI.hpp"
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
21
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
22 #ifdef DISTRHO_PLUGIN_TARGET_VST3
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
23 # include "DistrhoPluginVST.hpp"
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
24 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
25
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
26 #if DISTRHO_PLUGIN_HAS_EXTERNAL_UI
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
27 # include "../extra/Sleep.hpp"
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
28 // TODO import and use file browser here
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
29 #else
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
30 # include "../../dgl/src/ApplicationPrivateData.hpp"
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
31 # include "../../dgl/src/WindowPrivateData.hpp"
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
32 # include "../../dgl/src/pugl.hpp"
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
33 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
34
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
35 #if DISTRHO_PLUGIN_WANT_STATE && DISTRHO_UI_FILE_BROWSER && !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
36 # include <map>
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
37 # include <string>
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
38 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
39
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
40 #if defined(DISTRHO_PLUGIN_TARGET_JACK) || defined(DISTRHO_PLUGIN_TARGET_DSSI)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
41 # define DISTRHO_UI_IS_STANDALONE 1
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
42 #else
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
43 # define DISTRHO_UI_IS_STANDALONE 0
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
44 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
45
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
46 #if defined(DISTRHO_PLUGIN_TARGET_VST3) || defined(DISTRHO_PLUGIN_TARGET_CLAP)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
47 # define DISTRHO_UI_USES_SIZE_REQUEST true
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
48 #else
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
49 # define DISTRHO_UI_USES_SIZE_REQUEST false
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
50 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
51
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
52 #ifdef DISTRHO_PLUGIN_TARGET_VST2
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
53 # undef DISTRHO_UI_USER_RESIZABLE
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
54 # define DISTRHO_UI_USER_RESIZABLE 0
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
55 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
56
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
57 START_NAMESPACE_DISTRHO
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
58
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
59 // -----------------------------------------------------------------------
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
60 // Plugin Application, will set class name based on plugin details
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
61
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
62 #if DISTRHO_PLUGIN_HAS_EXTERNAL_UI
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
63 struct PluginApplication
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
64 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
65 DGL_NAMESPACE::IdleCallback* idleCallback;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
66 UI* ui;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
67
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
68 explicit PluginApplication(const char*)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
69 : idleCallback(nullptr),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
70 ui(nullptr) {}
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
71
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
72 void addIdleCallback(DGL_NAMESPACE::IdleCallback* const cb)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
73 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
74 DISTRHO_SAFE_ASSERT_RETURN(cb != nullptr,);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
75 DISTRHO_SAFE_ASSERT_RETURN(idleCallback == nullptr,);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
76
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
77 idleCallback = cb;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
78 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
79
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
80 bool isQuitting() const noexcept
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
81 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
82 return ui->isQuitting();
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
83 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
84
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
85 bool isStandalone() const noexcept
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
86 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
87 return DISTRHO_UI_IS_STANDALONE;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
88 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
89
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
90 void exec()
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
91 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
92 while (ui->isRunning())
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
93 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
94 d_msleep(30);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
95 idleCallback->idleCallback();
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
96 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
97
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
98 if (! ui->isQuitting())
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
99 ui->close();
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
100 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
101
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
102 // these are not needed
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
103 void idle() {}
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
104 void quit() {}
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
105 void triggerIdleCallbacks() {}
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
106
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
107 DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginApplication)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
108 };
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
109 #else
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
110 class PluginApplication : public DGL_NAMESPACE::Application
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
111 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
112 public:
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
113 explicit PluginApplication(const char* className)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
114 : DGL_NAMESPACE::Application(DISTRHO_UI_IS_STANDALONE)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
115 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
116 #if defined(__MOD_DEVICES__) || !defined(__EMSCRIPTEN__)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
117 if (className == nullptr)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
118 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
119 className = (
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
120 #ifdef DISTRHO_PLUGIN_BRAND
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
121 DISTRHO_PLUGIN_BRAND
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
122 #else
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
123 DISTRHO_MACRO_AS_STRING(DISTRHO_NAMESPACE)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
124 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
125 "-" DISTRHO_PLUGIN_NAME
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
126 );
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
127 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
128 setClassName(className);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
129 #else
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
130 // unused
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
131 (void)className;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
132 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
133 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
134
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
135 void triggerIdleCallbacks()
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
136 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
137 pData->triggerIdleCallbacks();
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
138 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
139
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
140 DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginApplication)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
141 };
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
142 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
143
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
144 // -----------------------------------------------------------------------
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
145 // Plugin Window, will pass some Window events to UI
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
146
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
147 #if DISTRHO_PLUGIN_HAS_EXTERNAL_UI
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
148 class PluginWindow
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
149 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
150 UI* const ui;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
151
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
152 public:
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
153 explicit PluginWindow(UI* const uiPtr, PluginApplication& app)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
154 : ui(uiPtr)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
155 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
156 app.ui = ui;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
157 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
158
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
159 // fetch cached data
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
160 uint getWidth() const noexcept { return ui->pData.width; }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
161 uint getHeight() const noexcept { return ui->pData.height; }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
162 double getScaleFactor() const noexcept { return ui->pData.scaleFactor; }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
163
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
164 // direct mappings
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
165 void close() { ui->close(); }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
166 void focus() { ui->focus(); }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
167 void show() { ui->show(); }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
168 bool isResizable() const noexcept { return ui->isResizable(); }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
169 bool isVisible() const noexcept { return ui->isVisible(); }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
170 void setTitle(const char* const title) { ui->setTitle(title); }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
171 void setVisible(const bool visible) { ui->setVisible(visible); }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
172 uintptr_t getNativeWindowHandle() const noexcept { return ui->getNativeWindowHandle(); }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
173 void getGeometryConstraints(uint& minimumWidth, uint& minimumHeight, bool& keepAspectRatio) const noexcept
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
174 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
175 minimumWidth = ui->pData.minWidth;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
176 minimumHeight = ui->pData.minHeight;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
177 keepAspectRatio = ui->pData.keepAspectRatio;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
178 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
179
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
180 DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginWindow)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
181 };
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
182 #else // DISTRHO_PLUGIN_HAS_EXTERNAL_UI
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
183 class PluginWindow : public DGL_NAMESPACE::Window
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
184 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
185 UI* const ui;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
186 bool initializing;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
187 bool receivedReshapeDuringInit;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
188
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
189 public:
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
190 explicit PluginWindow(UI* const uiPtr,
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
191 PluginApplication& app,
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
192 const uintptr_t parentWindowHandle,
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
193 const uint width,
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
194 const uint height,
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
195 const double scaleFactor)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
196 : Window(app, parentWindowHandle, width, height, scaleFactor,
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
197 DISTRHO_UI_USER_RESIZABLE, DISTRHO_UI_USES_SIZE_REQUEST, false),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
198 ui(uiPtr),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
199 initializing(true),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
200 receivedReshapeDuringInit(false)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
201 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
202 if (pData->view == nullptr)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
203 return;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
204
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
205 // this is called just before creating UI, ensuring proper context to it
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
206 if (pData->initPost())
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
207 puglBackendEnter(pData->view);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
208 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
209
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
210 ~PluginWindow() override
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
211 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
212 if (pData->view != nullptr)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
213 puglBackendLeave(pData->view);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
214 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
215
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
216 // called after creating UI, restoring proper context
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
217 void leaveContext()
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
218 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
219 if (pData->view == nullptr)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
220 return;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
221
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
222 if (receivedReshapeDuringInit)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
223 ui->uiReshape(getWidth(), getHeight());
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
224
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
225 initializing = false;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
226 puglBackendLeave(pData->view);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
227 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
228
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
229 // used for temporary windows (VST/CLAP get size without active/visible view)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
230 void setIgnoreIdleCallbacks(const bool ignore = true)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
231 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
232 pData->ignoreIdleCallbacks = ignore;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
233 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
234
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
235 // called right before deleting UI, ensuring correct context
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
236 void enterContextForDeletion()
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
237 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
238 if (pData->view != nullptr)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
239 puglBackendEnter(pData->view);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
240 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
241
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
242 #if defined(DISTRHO_PLUGIN_TARGET_VST3) || defined(DISTRHO_PLUGIN_TARGET_CLAP)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
243 void setSizeFromHost(const uint width, const uint height)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
244 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
245 puglSetSizeAndDefault(pData->view, width, height);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
246 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
247 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
248
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
249 std::vector<DGL_NAMESPACE::ClipboardDataOffer> getClipboardDataOfferTypes()
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
250 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
251 return Window::getClipboardDataOfferTypes();
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
252 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
253
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
254 protected:
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
255 uint32_t onClipboardDataOffer() override
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
256 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
257 DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr, 0);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
258
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
259 if (initializing)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
260 return 0;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
261
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
262 return ui->uiClipboardDataOffer();
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
263 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
264
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
265 void onFocus(const bool focus, const DGL_NAMESPACE::CrossingMode mode) override
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
266 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
267 DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr,);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
268
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
269 if (initializing)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
270 return;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
271
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
272 ui->uiFocus(focus, mode);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
273 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
274
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
275 void onReshape(const uint width, const uint height) override
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
276 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
277 DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr,);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
278
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
279 if (initializing)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
280 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
281 receivedReshapeDuringInit = true;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
282 return;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
283 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
284
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
285 ui->uiReshape(width, height);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
286 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
287
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
288 void onScaleFactorChanged(const double scaleFactor) override
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
289 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
290 DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr,);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
291
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
292 if (initializing)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
293 return;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
294
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
295 ui->uiScaleFactorChanged(scaleFactor);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
296 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
297
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
298 # if DISTRHO_UI_FILE_BROWSER
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
299 void onFileSelected(const char* filename) override;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
300 # endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
301
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
302 DISTRHO_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(PluginWindow)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
303 };
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
304 #endif // DISTRHO_PLUGIN_HAS_EXTERNAL_UI
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
305
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
306 // -----------------------------------------------------------------------
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
307 // UI callbacks
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
308
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
309 typedef void (*editParamFunc) (void* ptr, uint32_t rindex, bool started);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
310 typedef void (*setParamFunc) (void* ptr, uint32_t rindex, float value);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
311 typedef void (*setStateFunc) (void* ptr, const char* key, const char* value);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
312 typedef void (*sendNoteFunc) (void* ptr, uint8_t channel, uint8_t note, uint8_t velo);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
313 typedef void (*setSizeFunc) (void* ptr, uint width, uint height);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
314 typedef bool (*fileRequestFunc) (void* ptr, const char* key);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
315
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
316 // -----------------------------------------------------------------------
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
317 // UI private data
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
318
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
319 struct UI::PrivateData {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
320 // DGL
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
321 PluginApplication app;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
322 ScopedPointer<PluginWindow> window;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
323
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
324 // DSP
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
325 double sampleRate;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
326 uint32_t parameterOffset;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
327 void* dspPtr;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
328
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
329 // UI
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
330 uint bgColor;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
331 uint fgColor;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
332 double scaleFactor;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
333 uintptr_t winId;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
334 #if DISTRHO_PLUGIN_WANT_STATE && DISTRHO_UI_FILE_BROWSER && !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
335 char* uiStateFileKeyRequest;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
336 std::map<std::string,std::string> lastUsedDirnames;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
337 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
338 char* bundlePath;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
339
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
340 // Ignore initial resize events while initializing
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
341 bool initializing;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
342
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
343 // Callbacks
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
344 void* callbacksPtr;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
345 editParamFunc editParamCallbackFunc;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
346 setParamFunc setParamCallbackFunc;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
347 setStateFunc setStateCallbackFunc;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
348 sendNoteFunc sendNoteCallbackFunc;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
349 setSizeFunc setSizeCallbackFunc;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
350 fileRequestFunc fileRequestCallbackFunc;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
351
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
352 PrivateData(const char* const appClassName) noexcept
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
353 : app(appClassName),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
354 window(nullptr),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
355 sampleRate(0),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
356 parameterOffset(0),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
357 dspPtr(nullptr),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
358 bgColor(0),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
359 fgColor(0xffffffff),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
360 scaleFactor(1.0),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
361 winId(0),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
362 #if DISTRHO_PLUGIN_WANT_STATE && DISTRHO_UI_FILE_BROWSER && !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
363 uiStateFileKeyRequest(nullptr),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
364 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
365 bundlePath(nullptr),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
366 initializing(true),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
367 callbacksPtr(nullptr),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
368 editParamCallbackFunc(nullptr),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
369 setParamCallbackFunc(nullptr),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
370 setStateCallbackFunc(nullptr),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
371 sendNoteCallbackFunc(nullptr),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
372 setSizeCallbackFunc(nullptr),
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
373 fileRequestCallbackFunc(nullptr)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
374 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
375 #if defined(DISTRHO_PLUGIN_TARGET_DSSI) || defined(DISTRHO_PLUGIN_TARGET_LV2)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
376 parameterOffset += DISTRHO_PLUGIN_NUM_INPUTS + DISTRHO_PLUGIN_NUM_OUTPUTS;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
377 #if DISTRHO_PLUGIN_WANT_LATENCY
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
378 parameterOffset += 1;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
379 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
380 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
381
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
382 #ifdef DISTRHO_PLUGIN_TARGET_LV2
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
383 #if (DISTRHO_PLUGIN_WANT_MIDI_INPUT || DISTRHO_PLUGIN_WANT_TIMEPOS || DISTRHO_PLUGIN_WANT_STATE)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
384 parameterOffset += 1;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
385 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
386 #if (DISTRHO_PLUGIN_WANT_MIDI_OUTPUT || DISTRHO_PLUGIN_WANT_STATE)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
387 parameterOffset += 1;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
388 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
389 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
390
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
391 #ifdef DISTRHO_PLUGIN_TARGET_VST3
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
392 parameterOffset += kVst3InternalParameterCount;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
393 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
394 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
395
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
396 ~PrivateData() noexcept
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
397 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
398 #if DISTRHO_PLUGIN_WANT_STATE && DISTRHO_UI_FILE_BROWSER && !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
399 std::free(uiStateFileKeyRequest);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
400 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
401 std::free(bundlePath);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
402 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
403
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
404 void editParamCallback(const uint32_t rindex, const bool started)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
405 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
406 if (editParamCallbackFunc != nullptr)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
407 editParamCallbackFunc(callbacksPtr, rindex, started);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
408 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
409
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
410 void setParamCallback(const uint32_t rindex, const float value)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
411 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
412 if (setParamCallbackFunc != nullptr)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
413 setParamCallbackFunc(callbacksPtr, rindex, value);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
414 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
415
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
416 void setStateCallback(const char* const key, const char* const value)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
417 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
418 if (setStateCallbackFunc != nullptr)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
419 setStateCallbackFunc(callbacksPtr, key, value);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
420 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
421
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
422 void sendNoteCallback(const uint8_t channel, const uint8_t note, const uint8_t velocity)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
423 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
424 if (sendNoteCallbackFunc != nullptr)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
425 sendNoteCallbackFunc(callbacksPtr, channel, note, velocity);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
426 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
427
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
428 void setSizeCallback(const uint width, const uint height)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
429 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
430 if (setSizeCallbackFunc != nullptr)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
431 setSizeCallbackFunc(callbacksPtr, width, height);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
432 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
433
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
434 // implemented below, after PluginWindow
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
435 bool fileRequestCallback(const char* const key);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
436
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
437 static UI::PrivateData* s_nextPrivateData;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
438 #if DISTRHO_PLUGIN_HAS_EXTERNAL_UI
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
439 static ExternalWindow::PrivateData createNextWindow(UI* ui, uint width, uint height, bool adjustForScaleFactor);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
440 #else
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
441 static PluginWindow& createNextWindow(UI* ui, uint width, uint height, bool adjustForScaleFactor);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
442 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
443 };
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
444
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
445 // -----------------------------------------------------------------------
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
446 // UI private data fileRequestCallback, which requires PluginWindow definitions
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
447
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
448 inline bool UI::PrivateData::fileRequestCallback(const char* const key)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
449 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
450 if (fileRequestCallbackFunc != nullptr)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
451 return fileRequestCallbackFunc(callbacksPtr, key);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
452
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
453 #if DISTRHO_PLUGIN_WANT_STATE && DISTRHO_UI_FILE_BROWSER && !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
454 std::free(uiStateFileKeyRequest);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
455 uiStateFileKeyRequest = strdup(key);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
456 DISTRHO_SAFE_ASSERT_RETURN(uiStateFileKeyRequest != nullptr, false);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
457
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
458 char title[0xff];
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
459 snprintf(title, sizeof(title)-1u, DISTRHO_PLUGIN_NAME ": %s", key);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
460 title[sizeof(title)-1u] = '\0';
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
461
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
462 DGL_NAMESPACE::FileBrowserOptions opts;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
463 opts.title = title;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
464 if (lastUsedDirnames.count(key))
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
465 opts.startDir = lastUsedDirnames[key].c_str();
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
466 return window->openFileBrowser(opts);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
467 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
468
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
469 return false;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
470 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
471
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
472 // -----------------------------------------------------------------------
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
473 // PluginWindow onFileSelected that require UI::PrivateData definitions
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
474
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
475 #if DISTRHO_UI_FILE_BROWSER && !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
476 inline void PluginWindow::onFileSelected(const char* const filename)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
477 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
478 DISTRHO_SAFE_ASSERT_RETURN(ui != nullptr,);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
479
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
480 if (initializing)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
481 return;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
482
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
483 #if DISTRHO_PLUGIN_WANT_STATE && DISTRHO_UI_FILE_BROWSER && !DISTRHO_PLUGIN_HAS_EXTERNAL_UI
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
484 if (char* const key = ui->uiData->uiStateFileKeyRequest)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
485 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
486 ui->uiData->uiStateFileKeyRequest = nullptr;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
487 if (filename != nullptr)
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
488 {
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
489 // notify DSP
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
490 ui->setState(key, filename);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
491
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
492 // notify UI
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
493 ui->stateChanged(key, filename);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
494
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
495 // save dirname for next time
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
496 if (const char* const lastsep = std::strrchr(filename, DISTRHO_OS_SEP))
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
497 ui->uiData->lastUsedDirnames[key] = std::string(filename, lastsep-filename);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
498 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
499 std::free(key);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
500 return;
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
501 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
502 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
503
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
504 puglBackendEnter(pData->view);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
505 ui->uiFileBrowserSelected(filename);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
506 puglBackendLeave(pData->view);
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
507 }
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
508 #endif
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
509
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
510 // -----------------------------------------------------------------------
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
511
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
512 END_NAMESPACE_DISTRHO
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
513
84e66ea83026 DPF-Prymula-audioplugins-0.231015-2
prymula <prymula76@outlook.com>
parents:
diff changeset
514 #endif // DISTRHO_UI_PRIVATE_DATA_HPP_INCLUDED